summaryrefslogtreecommitdiff
path: root/indra/newview/llfloateruipreview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloateruipreview.cpp')
-rw-r--r--indra/newview/llfloateruipreview.cpp391
1 files changed, 223 insertions, 168 deletions
diff --git a/indra/newview/llfloateruipreview.cpp b/indra/newview/llfloateruipreview.cpp
index 4870494b20..e5b4657742 100644
--- a/indra/newview/llfloateruipreview.cpp
+++ b/indra/newview/llfloateruipreview.cpp
@@ -71,10 +71,6 @@
#endif
// Static initialization
-LLFloaterUIPreview* LLFloaterUIPreview::sInstance = NULL; // initialization of static instance pointer to NULL
-std::string LLFloaterUIPreview::mSavedEditorPath = std::string("");
-std::string LLFloaterUIPreview::mSavedEditorArgs = std::string("");
-std::string LLFloaterUIPreview::mSavedDiffPath = std::string("");
static const S32 PRIMARY_FLOATER = 1;
static const S32 SECONDARY_FLOATER = 2;
@@ -86,12 +82,74 @@ static std::string get_xui_dir()
return gDirUtilp->getSkinBaseDir() + delim + "default" + delim + "xui" + delim;
}
+//----------------------------------------------------------------------------
+// Local class declarations
+// Reset object to ensure that when we change the current language setting for preview purposes,
+// it automatically is reset. Constructed on the stack at the start of the method; the reset
+// occurs as it falls out of scope at the end of the method. See llfloateruipreview.cpp for usage.
+class LLLocalizationResetForcer
+{
+public:
+ LLLocalizationResetForcer(LLFloaterUIPreview* floater, S32 ID);
+ virtual ~LLLocalizationResetForcer();
+
+private:
+ std::string mSavedLocalization; // the localization before we change it
+};
+
+// Implementation of live file
+// When a floater is being previewed, any saved changes to its corresponding
+// file cause the previewed floater to be reloaded
+class LLGUIPreviewLiveFile : public LLLiveFile
+{
+public:
+ LLGUIPreviewLiveFile(std::string path, std::string name, LLFloaterUIPreview* parent);
+ virtual ~LLGUIPreviewLiveFile();
+ LLFloaterUIPreview* mParent;
+ LLFadeEventTimer* mFadeTimer; // timer for fade-to-yellow-and-back effect to warn that file has been reloaded
+ BOOL mFirstFade; // setting this avoids showing the fade reload warning on first load
+ std::string mFileName;
+protected:
+ bool loadFile();
+};
+
+// Implementation of graphical fade in/out (on timer) for when XUI files are updated
+class LLFadeEventTimer : public LLEventTimer
+{
+public:
+ LLFadeEventTimer(F32 refresh, LLGUIPreviewLiveFile* parent);
+ BOOL tick();
+ LLGUIPreviewLiveFile* mParent;
+private:
+ BOOL mFadingOut; // fades in then out; this is toggled in between
+ LLColor4 mOriginalColor; // original color; color is reset to this after fade is coimplete
+};
+
+// Implementation of previewed floater
+// Used to override draw and mouse handler
+class LLPreviewedFloater : public LLFloater
+{
+public:
+ LLPreviewedFloater(LLFloaterUIPreview* floater)
+ : LLFloater(LLSD()),
+ mFloaterUIPreview(floater)
+ {
+ }
+ virtual void draw();
+ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
+ BOOL selectElement(LLView* parent, int x, int y, int depth); // select element to display its overlappers
+
+ LLFloaterUIPreview* mFloaterUIPreview;
+};
+
+//----------------------------------------------------------------------------
+
// Localization reset forcer -- ensures that when localization is temporarily changed for previewed floater, it is reset
// Changes are made here
-LLLocalizationResetForcer::LLLocalizationResetForcer(S32 ID)
+LLLocalizationResetForcer::LLLocalizationResetForcer(LLFloaterUIPreview* floater, S32 ID)
{
mSavedLocalization = LLUI::sSettingGroups["config"]->getString("Language"); // save current localization setting
- LLUI::sSettingGroups["config"]->setString("Language", LLFloaterUIPreview::getLocStr(ID));// hack language to be the one we want to preview floaters in
+ LLUI::sSettingGroups["config"]->setString("Language", floater->getLocStr(ID));// hack language to be the one we want to preview floaters in
LLUI::setupPaths(); // forcibly reset XUI paths with this new language
}
@@ -201,7 +259,6 @@ LLFloaterUIPreview::LLFloaterUIPreview(const LLSD& key)
mLastDisplayedY(0)
{
- sInstance = this;
// called from floater reg: LLUICtrlFactory::getInstance()->buildFloater(this, "floater_ui_preview.xml");
}
@@ -211,27 +268,27 @@ LLFloaterUIPreview::~LLFloaterUIPreview()
// spawned floaters are deleted automatically, so we don't need to delete them here
// save contents of textfields so it can be restored later if the floater is created again this session
- LLFloaterUIPreview::mSavedEditorPath = mEditorPathTextBox->getText();
- LLFloaterUIPreview::mSavedEditorArgs = mEditorArgsTextBox->getText();
- LLFloaterUIPreview::mSavedDiffPath = mDiffPathTextBox->getText();
+ mSavedEditorPath = mEditorPathTextBox->getText();
+ mSavedEditorArgs = mEditorArgsTextBox->getText();
+ mSavedDiffPath = mDiffPathTextBox->getText();
// delete live file if it exists
- if(sInstance->mLiveFile)
+ if(mLiveFile)
{
- delete sInstance->mLiveFile;
- sInstance->mLiveFile = NULL;
+ delete mLiveFile;
+ mLiveFile = NULL;
}
-
- sInstance = NULL; // clear static pointer
}
// Perform post-build setup (defined in superclass)
BOOL LLFloaterUIPreview::postBuild()
{
+ mCloseSignal.connect(boost::bind(&LLFloaterUIPreview::onClose, this, _2));
+
LLPanel* main_panel_tmp = getChild<LLPanel>("main_panel"); // get a pointer to the main panel in order to...
mFileList = main_panel_tmp->getChild<LLScrollListCtrl>("name_list"); // save pointer to file list
// Double-click opens the floater, for convenience
- mFileList->setDoubleClickCallback(onClickDisplayFloater, (void*)&PRIMARY_FLOATER);
+ mFileList->setDoubleClickCallback(boost::bind(&LLFloaterUIPreview::onClickDisplayFloater, this, PRIMARY_FLOATER));
// get pointers to buttons and link to callbacks
mLanguageSelection = main_panel_tmp->getChild<LLComboBox>("language_select_combo");
@@ -240,26 +297,26 @@ BOOL LLFloaterUIPreview::postBuild()
mLanguageSelection_2->setSelectionCallback(boost::bind(&LLFloaterUIPreview::onLanguageComboSelect, this, mLanguageSelection));
LLPanel* editor_panel_tmp = main_panel_tmp->getChild<LLPanel>("editor_panel");
mDisplayFloaterBtn = main_panel_tmp->getChild<LLButton>("display_floater");
- mDisplayFloaterBtn->setClickedCallback(onClickDisplayFloater, (void*)&PRIMARY_FLOATER);
+ mDisplayFloaterBtn->setClickedCallback(boost::bind(&LLFloaterUIPreview::onClickDisplayFloater, this, PRIMARY_FLOATER));
mDisplayFloaterBtn_2 = main_panel_tmp->getChild<LLButton>("display_floater_2");
- mDisplayFloaterBtn_2->setClickedCallback(onClickDisplayFloater, (void*)&SECONDARY_FLOATER);
+ mDisplayFloaterBtn_2->setClickedCallback(boost::bind(&LLFloaterUIPreview::onClickDisplayFloater, this, SECONDARY_FLOATER));
mToggleOverlapButton = main_panel_tmp->getChild<LLButton>("toggle_overlap_panel");
- mToggleOverlapButton->setClickedCallback(onClickToggleOverlapping, this);
+ mToggleOverlapButton->setClickedCallback(boost::bind(&LLFloaterUIPreview::onClickToggleOverlapping, this));
mCloseOtherButton = main_panel_tmp->getChild<LLButton>("close_displayed_floater");
- mCloseOtherButton->setClickedCallback(onClickCloseDisplayedFloater, (void*)&PRIMARY_FLOATER);
+ mCloseOtherButton->setClickedCallback(boost::bind(&LLFloaterUIPreview::onClickCloseDisplayedFloater, this, PRIMARY_FLOATER));
mCloseOtherButton_2 = main_panel_tmp->getChild<LLButton>("close_displayed_floater_2");
- mCloseOtherButton_2->setClickedCallback(onClickCloseDisplayedFloater, (void*)&SECONDARY_FLOATER);
+ mCloseOtherButton_2->setClickedCallback(boost::bind(&LLFloaterUIPreview::onClickCloseDisplayedFloater, this, SECONDARY_FLOATER));
mEditFloaterBtn = main_panel_tmp->getChild<LLButton>("edit_floater");
- mEditFloaterBtn->setClickedCallback(onClickEditFloater, this);
+ mEditFloaterBtn->setClickedCallback(boost::bind(&LLFloaterUIPreview::onClickEditFloater, this));
mExecutableBrowseButton = editor_panel_tmp->getChild<LLButton>("browse_for_executable");
LLPanel* vlt_panel_tmp = main_panel_tmp->getChild<LLPanel>("vlt_panel");
- mExecutableBrowseButton->setClickedCallback(onClickBrowseForEditor, this);
+ mExecutableBrowseButton->setClickedCallback(boost::bind(&LLFloaterUIPreview::onClickBrowseForEditor, this));
mDiffBrowseButton = vlt_panel_tmp->getChild<LLButton>("browse_for_vlt_diffs");
- mDiffBrowseButton->setClickedCallback(onClickBrowseForDiffs, NULL);
+ mDiffBrowseButton->setClickedCallback(boost::bind(&LLFloaterUIPreview::onClickBrowseForDiffs, this));
mToggleHighlightButton = vlt_panel_tmp->getChild<LLButton>("toggle_vlt_diff_highlight");
- mToggleHighlightButton->setClickedCallback(onClickToggleDiffHighlighting, NULL);
- main_panel_tmp->getChild<LLButton>("save_floater")->setClickedCallback(onClickSaveFloater, (void*)&PRIMARY_FLOATER);
- main_panel_tmp->getChild<LLButton>("save_all_floaters")->setClickedCallback(onClickSaveAll, (void*)&PRIMARY_FLOATER);
+ mToggleHighlightButton->setClickedCallback(boost::bind(&LLFloaterUIPreview::onClickToggleDiffHighlighting, this));
+ main_panel_tmp->getChild<LLButton>("save_floater")->setClickedCallback(boost::bind(&LLFloaterUIPreview::onClickSaveFloater, this, PRIMARY_FLOATER));
+ main_panel_tmp->getChild<LLButton>("save_all_floaters")->setClickedCallback(boost::bind(&LLFloaterUIPreview::onClickSaveAll, this, PRIMARY_FLOATER));
getChild<LLButton>("export_schema")->setClickedCallback(boost::bind(&LLFloaterUIPreview::onClickExportSchema, this));
@@ -269,14 +326,14 @@ BOOL LLFloaterUIPreview::postBuild()
mDiffPathTextBox = vlt_panel_tmp->getChild<LLLineEditor>("vlt_diff_path_field");
// *HACK: restored saved editor path and args to textfields
- mEditorPathTextBox->setText(LLFloaterUIPreview::mSavedEditorPath);
- mEditorArgsTextBox->setText(LLFloaterUIPreview::mSavedEditorArgs);
- mDiffPathTextBox->setText(LLFloaterUIPreview::mSavedDiffPath);
+ mEditorPathTextBox->setText(mSavedEditorPath);
+ mEditorArgsTextBox->setText(mSavedEditorArgs);
+ mDiffPathTextBox->setText(mSavedDiffPath);
// Set up overlap panel
mOverlapPanel = getChild<LLOverlapPanel>("overlap_panel");
- sInstance->childSetVisible("overlap_scroll", mHighlightingOverlaps);
+ childSetVisible("overlap_scroll", mHighlightingOverlaps);
mDelim = gDirUtilp->getDirDelimiter(); // initialize delimiter to dir sep slash
@@ -338,7 +395,7 @@ void LLFloaterUIPreview::onLanguageComboSelect(LLUICtrl* ctrl)
{
if(mDisplayedFloater)
{
- onClickCloseDisplayedFloater((void*)&PRIMARY_FLOATER);
+ onClickCloseDisplayedFloater(PRIMARY_FLOATER);
displayFloater(TRUE,1);
}
}
@@ -346,7 +403,7 @@ void LLFloaterUIPreview::onLanguageComboSelect(LLUICtrl* ctrl)
{
if(mDisplayedFloater_2)
{
- onClickCloseDisplayedFloater((void*)&PRIMARY_FLOATER);
+ onClickCloseDisplayedFloater(PRIMARY_FLOATER);
displayFloater(TRUE,2); // *TODO: make take an arg
}
}
@@ -385,16 +442,17 @@ void LLFloaterUIPreview::onClickExportSchema()
// Close click handler -- delete my displayed floater if it exists
-void LLFloaterUIPreview::onClose(bool app_quitting)
+void LLFloaterUIPreview::onClose(const LLSD& app_quitting)
{
- if(!app_quitting && sInstance && sInstance->mDisplayedFloater)
+ if(!app_quitting.asBoolean() && mDisplayedFloater)
{
- onClickCloseDisplayedFloater((void*)&PRIMARY_FLOATER);
- onClickCloseDisplayedFloater((void*)&SECONDARY_FLOATER);
- delete sInstance->mDisplayedFloater;
- sInstance->mDisplayedFloater = NULL;
+ onClickCloseDisplayedFloater(PRIMARY_FLOATER);
+ onClickCloseDisplayedFloater(SECONDARY_FLOATER);
+ delete mDisplayedFloater;
+ mDisplayedFloater = NULL;
+ delete mDisplayedFloater_2;
+ mDisplayedFloater_2 = NULL;
}
- destroy();
}
// Error handling (to avoid code repetition)
@@ -412,18 +470,18 @@ std::string LLFloaterUIPreview::getLocStr(S32 ID)
{
if(ID == 1)
{
- return sInstance->mLanguageSelection->getSelectedItemLabel(0);
+ return mLanguageSelection->getSelectedItemLabel(0);
}
else
{
- return sInstance->mLanguageSelection_2->getSelectedItemLabel(0);
+ return mLanguageSelection_2->getSelectedItemLabel(0);
}
}
// Get localized directory (build path from data directory to XUI files, substituting localization string in for language)
std::string LLFloaterUIPreview::getLocalizedDirectory()
{
- return get_xui_dir() + (sInstance ? getLocStr(1) : "en") + mDelim; // e.g. "C:/Code/guipreview/indra/newview/skins/xui/en/";
+ return get_xui_dir() + (getLocStr(1)) + mDelim; // e.g. "C:/Code/guipreview/indra/newview/skins/xui/en/";
}
// Refresh the list of floaters by doing a directory traverse for XML XUI floater files
@@ -535,36 +593,33 @@ void LLFloaterUIPreview::addFloaterEntry(const std::string& path)
}
// Respond to button click to display/refresh currently-selected floater
-void LLFloaterUIPreview::onClickDisplayFloater(void* data)
+void LLFloaterUIPreview::onClickDisplayFloater(S32 caller_id)
{
- S32 caller_id = *((S32*)data);
displayFloater(TRUE, caller_id);
- if(caller_id == 1)
+ if(caller_id == PRIMARY_FLOATER)
{
- sInstance->mDisplayedFloater->center(); // move displayed floater to the center of the screen
+ mDisplayedFloater->center(); // move displayed floater to the center of the screen
}
}
// Saves the current floater/panel
-void LLFloaterUIPreview::onClickSaveFloater(void* data)
+void LLFloaterUIPreview::onClickSaveFloater(S32 caller_id)
{
- S32 caller_id = *((S32*)data);
displayFloater(TRUE, caller_id, true);
- if(caller_id == 1)
+ if(caller_id == PRIMARY_FLOATER)
{
- sInstance->mDisplayedFloater->center(); // move displayed floater to the center of the screen
+ mDisplayedFloater->center(); // move displayed floater to the center of the screen
}
}
// Saves all floater/panels
-void LLFloaterUIPreview::onClickSaveAll(void* data)
+void LLFloaterUIPreview::onClickSaveAll(S32 caller_id)
{
- S32 caller_id = *((S32*)data);
- int listSize = sInstance->mFileList->getItemCount();
+ int listSize = mFileList->getItemCount();
for (int index = 0; index < listSize; index++)
{
- sInstance->mFileList->selectNthItem(index);
+ mFileList->selectNthItem(index);
displayFloater(TRUE, caller_id, true);
}
}
@@ -586,43 +641,43 @@ static std::string append_new_to_xml_filename(const std::string& path)
void LLFloaterUIPreview::displayFloater(BOOL click, S32 ID, bool save)
{
// Convince UI that we're in a different language (the one selected on the drop-down menu)
- LLLocalizationResetForcer reset_forcer(ID); // save old language in reset forcer object (to be reset upon destruction when it falls out of scope)
+ LLLocalizationResetForcer reset_forcer(this, ID); // save old language in reset forcer object (to be reset upon destruction when it falls out of scope)
- LLPreviewedFloater** floaterp = (ID == 1 ? &(sInstance->mDisplayedFloater) : &(sInstance->mDisplayedFloater_2));
+ LLPreviewedFloater** floaterp = (ID == 1 ? &(mDisplayedFloater) : &(mDisplayedFloater_2));
if(ID == 1)
{
- BOOL floater_already_open = sInstance->mDisplayedFloater != NULL;
+ BOOL floater_already_open = mDisplayedFloater != NULL;
if(floater_already_open) // if we are already displaying a floater
{
- sInstance->mLastDisplayedX = sInstance->mDisplayedFloater->calcScreenRect().mLeft; // save floater's last known position to put the new one there
- sInstance->mLastDisplayedY = sInstance->mDisplayedFloater->calcScreenRect().mBottom;
- delete sInstance->mDisplayedFloater; // delete it (this closes it too)
- sInstance->mDisplayedFloater = NULL; // and reset the pointer
+ mLastDisplayedX = mDisplayedFloater->calcScreenRect().mLeft; // save floater's last known position to put the new one there
+ mLastDisplayedY = mDisplayedFloater->calcScreenRect().mBottom;
+ delete mDisplayedFloater; // delete it (this closes it too)
+ mDisplayedFloater = NULL; // and reset the pointer
}
}
else
{
- if(sInstance->mDisplayedFloater_2 != NULL)
+ if(mDisplayedFloater_2 != NULL)
{
- delete sInstance->mDisplayedFloater_2;
- sInstance->mDisplayedFloater_2 = NULL;
+ delete mDisplayedFloater_2;
+ mDisplayedFloater_2 = NULL;
}
}
- std::string path = sInstance->mFileList->getSelectedItemLabel(1); // get the path of the currently-selected floater
+ std::string path = mFileList->getSelectedItemLabel(1); // get the path of the currently-selected floater
if(std::string("") == path) // if no item is selected
{
return; // ignore click (this can only happen with empty list; otherwise an item is always selected)
}
- *floaterp = new LLPreviewedFloater();
+ *floaterp = new LLPreviewedFloater(this);
if(!strncmp(path.c_str(),"floater_",8)) // if it's a floater
{
if (save)
{
LLXMLNodePtr floater_write = new LLXMLNode();
- LLUICtrlFactory::getInstance()->buildFloater(*floaterp, path, FALSE, floater_write); // just build it
+ LLUICtrlFactory::getInstance()->buildFloater(*floaterp, path, floater_write); // just build it
if (!floater_write->isNull())
{
@@ -636,7 +691,8 @@ void LLFloaterUIPreview::displayFloater(BOOL click, S32 ID, bool save)
}
else
{
- LLUICtrlFactory::getInstance()->buildFloater(*floaterp, path, TRUE); // just build it
+ LLUICtrlFactory::getInstance()->buildFloater(*floaterp, path, NULL); // just build it
+ (*floaterp)->openFloater((*floaterp)->getKey());
}
}
@@ -702,7 +758,7 @@ void LLFloaterUIPreview::displayFloater(BOOL click, S32 ID, bool save)
if(ID == 1)
{
- (*floaterp)->setOrigin(sInstance->mLastDisplayedX, sInstance->mLastDisplayedY);
+ (*floaterp)->setOrigin(mLastDisplayedX, mLastDisplayedY);
}
// *HACK: Remove ability to close it; if you close it, its destructor gets called, but we don't know it's null and try to delete it again,
@@ -711,22 +767,22 @@ void LLFloaterUIPreview::displayFloater(BOOL click, S32 ID, bool save)
if(ID == 1)
{
- sInstance->mCloseOtherButton->setEnabled(TRUE); // enable my floater's close button
+ mCloseOtherButton->setEnabled(TRUE); // enable my floater's close button
}
else
{
- sInstance->mCloseOtherButton_2->setEnabled(TRUE);
+ mCloseOtherButton_2->setEnabled(TRUE);
}
// *TODO: Make the secondary floater pop up next to the primary one. Doesn't seem to always work if secondary was up first...
- if((sInstance->mDisplayedFloater && ID == 2) || (sInstance->mDisplayedFloater_2 && ID == 1))
+ if((mDisplayedFloater && ID == 2) || (mDisplayedFloater_2 && ID == 1))
{
- sInstance->mDisplayedFloater_2->setSnapTarget(sInstance->mDisplayedFloater->getHandle());
- sInstance->mDisplayedFloater->addDependentFloater(sInstance->mDisplayedFloater_2);
+ mDisplayedFloater_2->setSnapTarget(mDisplayedFloater->getHandle());
+ mDisplayedFloater->addDependentFloater(mDisplayedFloater_2);
}
// Add localization to title so user knows whether it's localized or defaulted to en
- std::string full_path = sInstance->getLocalizedDirectory() + path;
+ std::string full_path = getLocalizedDirectory() + path;
std::string floater_lang = "EN";
llstat dummy;
if(!LLFile::stat(full_path.c_str(), &dummy)) // if the file does not exist
@@ -740,37 +796,37 @@ void LLFloaterUIPreview::displayFloater(BOOL click, S32 ID, bool save)
if(click && ID == 1 && !save)
{
// set up live file to track it
- if(sInstance->mLiveFile)
+ if(mLiveFile)
{
- delete sInstance->mLiveFile;
- sInstance->mLiveFile = NULL;
+ delete mLiveFile;
+ mLiveFile = NULL;
}
- sInstance->mLiveFile = new LLGUIPreviewLiveFile(std::string(full_path.c_str()),std::string(path.c_str()),sInstance);
- sInstance->mLiveFile->checkAndReload();
- sInstance->mLiveFile->addToEventTimer();
+ mLiveFile = new LLGUIPreviewLiveFile(std::string(full_path.c_str()),std::string(path.c_str()),this);
+ mLiveFile->checkAndReload();
+ mLiveFile->addToEventTimer();
}
if(ID == 1)
{
- sInstance->mToggleOverlapButton->setEnabled(TRUE);
+ mToggleOverlapButton->setEnabled(TRUE);
}
if(LLView::sHighlightingDiffs && click && ID == 1)
{
- sInstance->highlightChangedElements();
+ highlightChangedElements();
}
if(ID == 1)
{
- sInstance->mOverlapMap.clear();
+ mOverlapPanel->mOverlapMap.clear();
LLView::sPreviewClickedElement = NULL; // stop overlapping elements from drawing
- sInstance->mOverlapPanel->mLastClickedElement = NULL;
- sInstance->findOverlapsInChildren((LLView*)sInstance->mDisplayedFloater);
+ mOverlapPanel->mLastClickedElement = NULL;
+ findOverlapsInChildren((LLView*)mDisplayedFloater);
// highlight and enable them
- if(sInstance->mHighlightingOverlaps)
+ if(mHighlightingOverlaps)
{
- for(OverlapMap::iterator iter = sInstance->mOverlapMap.begin(); iter != sInstance->mOverlapMap.end(); ++iter)
+ for(LLOverlapPanel::OverlapMap::iterator iter = mOverlapPanel->mOverlapMap.begin(); iter != mOverlapPanel->mOverlapMap.end(); ++iter)
{
LLView* viewp = iter->first;
LLView::sPreviewHighlightedElements.insert(viewp);
@@ -778,7 +834,7 @@ void LLFloaterUIPreview::displayFloater(BOOL click, S32 ID, bool save)
}
else if(LLView::sHighlightingDiffs)
{
- sInstance->highlightChangedElements();
+ highlightChangedElements();
}
}
@@ -786,14 +842,14 @@ void LLFloaterUIPreview::displayFloater(BOOL click, S32 ID, bool save)
}
// Respond to button click to edit currently-selected floater
-void LLFloaterUIPreview::onClickEditFloater(void*)
+void LLFloaterUIPreview::onClickEditFloater()
{
- std::string file_name = sInstance->mFileList->getSelectedItemLabel(1); // get the file name of the currently-selected floater
+ std::string file_name = mFileList->getSelectedItemLabel(1); // get the file name of the currently-selected floater
if(std::string("") == file_name) // if no item is selected
{
return; // ignore click
}
- std::string path = sInstance->getLocalizedDirectory() + file_name;
+ std::string path = getLocalizedDirectory() + file_name;
// stat file to see if it exists (some localized versions may not have it there are no diffs, and then we try to open an nonexistent file)
llstat dummy;
@@ -802,12 +858,12 @@ void LLFloaterUIPreview::onClickEditFloater(void*)
std::string warning = "No file for this floater exists in the selected localization. Opening the EN version instead.";
popupAndPrintWarning(warning);
- path = get_xui_dir() + sInstance->mDelim + "en" + sInstance->mDelim + file_name; // open the en version instead, by default
+ path = get_xui_dir() + mDelim + "en" + mDelim + file_name; // open the en version instead, by default
}
// get executable path
const char* exe_path_char;
- std::string path_in_textfield = sInstance->mEditorPathTextBox->getText();
+ std::string path_in_textfield = mEditorPathTextBox->getText();
if(std::string("") != path_in_textfield) // if the text field is not emtpy, use its path
{
exe_path_char = path_in_textfield.c_str();
@@ -842,7 +898,7 @@ void LLFloaterUIPreview::onClickEditFloater(void*)
{
// build paths and arguments
std::string args;
- std::string custom_args = sInstance->mEditorArgsTextBox->getText();
+ std::string custom_args = mEditorArgsTextBox->getText();
int position_of_file = custom_args.find(std::string("%FILE%"), 0); // prepare to replace %FILE% with actual file path
std::string first_part_of_args = "";
std::string second_part_of_args = "";
@@ -859,7 +915,7 @@ void LLFloaterUIPreview::onClickEditFloater(void*)
}
// find directory in which executable resides by taking everything after last slash
- int last_slash_position = exe_path.find_last_of(sInstance->mDelim);
+ int last_slash_position = exe_path.find_last_of(mDelim);
if(-1 == last_slash_position)
{
std::string warning = std::string("Unable to find a valid path to the specified executable for XUI XML editing: ") + exe_path;
@@ -973,7 +1029,7 @@ void LLFloaterUIPreview::onClickEditFloater(void*)
}
// Respond to button click to browse for an executable with which to edit XML files
-void LLFloaterUIPreview::onClickBrowseForEditor(void*)
+void LLFloaterUIPreview::onClickBrowseForEditor()
{
// create load dialog box
LLFilePicker::ELoadFilter type = (LLFilePicker::ELoadFilter)((intptr_t)((void*)LLFilePicker::FFLOAD_ALL)); // nothing for *.exe so just use all
@@ -1025,11 +1081,11 @@ void LLFloaterUIPreview::onClickBrowseForEditor(void*)
}
#endif
- sInstance->mEditorPathTextBox->setText(std::string(executable_path)); // copy the path to the executable to the textfield for display and later fetching
+ mEditorPathTextBox->setText(std::string(executable_path)); // copy the path to the executable to the textfield for display and later fetching
}
// Respond to button click to browse for a VLT-generated diffs file
-void LLFloaterUIPreview::onClickBrowseForDiffs(void*)
+void LLFloaterUIPreview::onClickBrowseForDiffs()
{
// create load dialog box
LLFilePicker::ELoadFilter type = (LLFilePicker::ELoadFilter)((intptr_t)((void*)LLFilePicker::FFLOAD_XML)); // nothing for *.exe so just use all
@@ -1041,35 +1097,35 @@ void LLFloaterUIPreview::onClickBrowseForDiffs(void*)
// put the selected path into text field
const std::string chosen_path = picker.getFirstFile();
- sInstance->mDiffPathTextBox->setText(std::string(chosen_path)); // copy the path to the executable to the textfield for display and later fetching
+ mDiffPathTextBox->setText(std::string(chosen_path)); // copy the path to the executable to the textfield for display and later fetching
if(LLView::sHighlightingDiffs) // if we're already highlighting, toggle off and then on so we get the data from the new file
{
- onClickToggleDiffHighlighting(NULL);
- onClickToggleDiffHighlighting(NULL);
+ onClickToggleDiffHighlighting();
+ onClickToggleDiffHighlighting();
}
}
-void LLFloaterUIPreview::onClickToggleDiffHighlighting(void*)
+void LLFloaterUIPreview::onClickToggleDiffHighlighting()
{
- if(sInstance->mHighlightingOverlaps)
+ if(mHighlightingOverlaps)
{
- onClickToggleOverlapping(NULL);
- sInstance->mToggleOverlapButton->toggleState();
+ onClickToggleOverlapping();
+ mToggleOverlapButton->toggleState();
}
LLView::sPreviewHighlightedElements.clear(); // clear lists first
- sInstance->mDiffsMap.clear();
- sInstance->mFileList->clearHighlightedItems();
+ mDiffsMap.clear();
+ mFileList->clearHighlightedItems();
if(LLView::sHighlightingDiffs) // Turning highlighting off
{
- LLView::sHighlightingDiffs = !sInstance->sHighlightingDiffs;
+ LLView::sHighlightingDiffs = !sHighlightingDiffs;
return;
}
else // Turning highlighting on
{
// Get the file and make sure it exists
- std::string path_in_textfield = sInstance->mDiffPathTextBox->getText(); // get file path
+ std::string path_in_textfield = mDiffPathTextBox->getText(); // get file path
BOOL error = FALSE;
if(std::string("") == path_in_textfield) // check for blank file
@@ -1103,18 +1159,18 @@ void LLFloaterUIPreview::onClickToggleDiffHighlighting(void*)
{
if(!strncmp("file",child->getName().c_str(),5))
{
- sInstance->scanDiffFile(child);
+ scanDiffFile(child);
}
else if(!strncmp("error",child->getName().c_str(),6))
{
std::string error_file, error_message;
child->getAttributeString("filename",error_file);
child->getAttributeString("message",error_message);
- if(sInstance->mDiffsMap.find(error_file) != sInstance->mDiffsMap.end())
+ if(mDiffsMap.find(error_file) != mDiffsMap.end())
{
- sInstance->mDiffsMap.insert(std::make_pair(error_file,std::make_pair(StringListPtr(new StringList), StringListPtr(new StringList))));
+ mDiffsMap.insert(std::make_pair(error_file,std::make_pair(StringListPtr(new StringList), StringListPtr(new StringList))));
}
- sInstance->mDiffsMap[error_file].second->push_back(error_message);
+ mDiffsMap[error_file].second->push_back(error_message);
}
else
{
@@ -1141,13 +1197,13 @@ void LLFloaterUIPreview::onClickToggleDiffHighlighting(void*)
if(error) // if we encountered an error, reset the button to off
{
- sInstance->mToggleHighlightButton->setToggleState(FALSE);
+ mToggleHighlightButton->setToggleState(FALSE);
}
else // only toggle if we didn't encounter an error
{
- LLView::sHighlightingDiffs = !sInstance->sHighlightingDiffs;
- sInstance->highlightChangedElements(); // *TODO: this is extraneous, right?
- sInstance->highlightChangedFiles(); // *TODO: this is extraneous, right?
+ LLView::sHighlightingDiffs = !sHighlightingDiffs;
+ highlightChangedElements(); // *TODO: this is extraneous, right?
+ highlightChangedFiles(); // *TODO: this is extraneous, right?
}
}
}
@@ -1204,7 +1260,7 @@ void LLFloaterUIPreview::highlightChangedElements()
for(std::list<std::string>::iterator iter = changed_element_paths->begin(); iter != changed_element_paths->end(); ++iter) // for every changed element path
{
- LLView* element = sInstance->mDisplayedFloater;
+ LLView* element = mDisplayedFloater;
if(!strncmp(iter->c_str(),".",1)) // if it's the root floater itself
{
continue;
@@ -1267,42 +1323,41 @@ void LLFloaterUIPreview::highlightChangedFiles()
}
// Respond to button click to browse for an executable with which to edit XML files
-void LLFloaterUIPreview::onClickCloseDisplayedFloater(void* data)
+void LLFloaterUIPreview::onClickCloseDisplayedFloater(S32 caller_id)
{
- S32 caller_id = *((S32*)data);
- if(caller_id == 1)
+ if(caller_id == PRIMARY_FLOATER)
{
- sInstance->mCloseOtherButton->setEnabled(FALSE);
- sInstance->mToggleOverlapButton->setEnabled(FALSE);
+ mCloseOtherButton->setEnabled(FALSE);
+ mToggleOverlapButton->setEnabled(FALSE);
- if(sInstance->mDisplayedFloater)
+ if(mDisplayedFloater)
{
- sInstance->mLastDisplayedX = sInstance->mDisplayedFloater->calcScreenRect().mLeft;
- sInstance->mLastDisplayedY = sInstance->mDisplayedFloater->calcScreenRect().mBottom;
- delete sInstance->mDisplayedFloater;
- sInstance->mDisplayedFloater = NULL;
+ mLastDisplayedX = mDisplayedFloater->calcScreenRect().mLeft;
+ mLastDisplayedY = mDisplayedFloater->calcScreenRect().mBottom;
+ delete mDisplayedFloater;
+ mDisplayedFloater = NULL;
}
- if(sInstance->mLiveFile)
+ if(mLiveFile)
{
- delete sInstance->mLiveFile;
- sInstance->mLiveFile = NULL;
+ delete mLiveFile;
+ mLiveFile = NULL;
}
- if(sInstance->mToggleOverlapButton->getToggleState())
+ if(mToggleOverlapButton->getToggleState())
{
- sInstance->mToggleOverlapButton->toggleState();
- onClickToggleOverlapping(NULL);
+ mToggleOverlapButton->toggleState();
+ onClickToggleOverlapping();
}
LLView::sPreviewClickedElement = NULL; // stop overlapping elements panel from drawing
- sInstance->mOverlapPanel->mLastClickedElement = NULL;
+ mOverlapPanel->mLastClickedElement = NULL;
}
else
{
- sInstance->mCloseOtherButton_2->setEnabled(FALSE);
- delete sInstance->mDisplayedFloater_2;
- sInstance->mDisplayedFloater_2 = NULL;
+ mCloseOtherButton_2->setEnabled(FALSE);
+ delete mDisplayedFloater_2;
+ mDisplayedFloater_2 = NULL;
}
}
@@ -1358,47 +1413,47 @@ BOOL LLPreviewedFloater::selectElement(LLView* parent, int x, int y, int depth)
void LLPreviewedFloater::draw()
{
- if(NULL != LLFloaterUIPreview::sInstance)
+ if(NULL != mFloaterUIPreview)
{
// Set and unset sDrawPreviewHighlights flag so as to avoid using two flags
- if(LLFloaterUIPreview::sInstance->mHighlightingOverlaps)
+ if(mFloaterUIPreview->mHighlightingOverlaps)
{
LLView::sDrawPreviewHighlights = TRUE;
}
LLFloater::draw();
- if(LLFloaterUIPreview::sInstance->mHighlightingOverlaps)
+ if(mFloaterUIPreview->mHighlightingOverlaps)
{
LLView::sDrawPreviewHighlights = FALSE;
}
}
}
-void LLFloaterUIPreview::onClickToggleOverlapping(void*)
+void LLFloaterUIPreview::onClickToggleOverlapping()
{
if(LLView::sHighlightingDiffs)
{
- onClickToggleDiffHighlighting(NULL);
- sInstance->mToggleHighlightButton->toggleState();
+ onClickToggleDiffHighlighting();
+ mToggleHighlightButton->toggleState();
}
LLView::sPreviewHighlightedElements.clear(); // clear lists first
S32 width, height;
- sInstance->getResizeLimits(&width, &height); // illegal call of non-static member function
- if(sInstance->mHighlightingOverlaps)
+ getResizeLimits(&width, &height); // illegal call of non-static member function
+ if(mHighlightingOverlaps)
{
- sInstance->mHighlightingOverlaps = !sInstance->mHighlightingOverlaps;
+ mHighlightingOverlaps = !mHighlightingOverlaps;
// reset list of preview highlighted elements
- sInstance->setRect(LLRect(sInstance->getRect().mLeft,sInstance->getRect().mTop,sInstance->getRect().mRight - sInstance->mOverlapPanel->getRect().getWidth(),sInstance->getRect().mBottom));
- sInstance->setResizeLimits(width - sInstance->mOverlapPanel->getRect().getWidth(), height);
+ setRect(LLRect(getRect().mLeft,getRect().mTop,getRect().mRight - mOverlapPanel->getRect().getWidth(),getRect().mBottom));
+ setResizeLimits(width - mOverlapPanel->getRect().getWidth(), height);
}
else
{
- sInstance->mHighlightingOverlaps = !sInstance->mHighlightingOverlaps;
+ mHighlightingOverlaps = !mHighlightingOverlaps;
displayFloater(FALSE,1);
- sInstance->setRect(LLRect(sInstance->getRect().mLeft,sInstance->getRect().mTop,sInstance->getRect().mRight + sInstance->mOverlapPanel->getRect().getWidth(),sInstance->getRect().mBottom));
- sInstance->setResizeLimits(width + sInstance->mOverlapPanel->getRect().getWidth(), height);
+ setRect(LLRect(getRect().mLeft,getRect().mTop,getRect().mRight + mOverlapPanel->getRect().getWidth(),getRect().mBottom));
+ setResizeLimits(width + mOverlapPanel->getRect().getWidth(), height);
}
- sInstance->childSetVisible("overlap_scroll", sInstance->mHighlightingOverlaps);
+ childSetVisible("overlap_scroll", mHighlightingOverlaps);
}
void LLFloaterUIPreview::findOverlapsInChildren(LLView* parent)
@@ -1429,7 +1484,7 @@ void LLFloaterUIPreview::findOverlapsInChildren(LLView* parent)
// if they overlap... (we don't care if they're visible or enabled -- we want to check those anyway, i.e. hidden tabs that can be later shown)
if(sibling != child && elementOverlap(child, sibling))
{
- mOverlapMap[child].push_back(sibling); // add to the map
+ mOverlapPanel->mOverlapMap[child].push_back(sibling); // add to the map
}
}
findOverlapsInChildren(child); // recur
@@ -1481,13 +1536,13 @@ void LLOverlapPanel::draw()
}
else
{
- LLFloaterUIPreview::OverlapMap::iterator iterExists = LLFloaterUIPreview::sInstance->mOverlapMap.find(LLView::sPreviewClickedElement);
- if(iterExists == LLFloaterUIPreview::sInstance->mOverlapMap.end())
+ OverlapMap::iterator iterExists = mOverlapMap.find(LLView::sPreviewClickedElement);
+ if(iterExists == mOverlapMap.end())
{
return;
}
- std::list<LLView*> overlappers = LLFloaterUIPreview::sInstance->mOverlapMap[LLView::sPreviewClickedElement];
+ std::list<LLView*> overlappers = mOverlapMap[LLView::sPreviewClickedElement];
if(overlappers.size() == 0)
{
LLUI::translate(5,getRect().getHeight()-20); // translate to top-5,left-5
@@ -1518,15 +1573,15 @@ void LLOverlapPanel::draw()
if(need_to_recalculate_bounds || LLView::sPreviewClickedElement->getName() != mLastClickedElement->getName())
{
// reset panel's rectangle to its default width and height (300x600)
- LLRect panel_rect = LLFloaterUIPreview::sInstance->mOverlapPanel->getRect();
- LLFloaterUIPreview::sInstance->mOverlapPanel->setRect(LLRect(panel_rect.mLeft,panel_rect.mTop,panel_rect.mLeft+LLFloaterUIPreview::sInstance->mOverlapPanel->getRect().getWidth(),panel_rect.mTop-LLFloaterUIPreview::sInstance->mOverlapPanel->getRect().getHeight()));
+ LLRect panel_rect = getRect();
+ setRect(LLRect(panel_rect.mLeft,panel_rect.mTop,panel_rect.mLeft+getRect().getWidth(),panel_rect.mTop-getRect().getHeight()));
LLRect rect;
// change bounds for selected element
int height_sum = mLastClickedElement->getRect().getHeight() + mSpacing + 80;
- rect = LLFloaterUIPreview::sInstance->mOverlapPanel->getRect();
- LLFloaterUIPreview::sInstance->mOverlapPanel->setRect(LLRect(rect.mLeft,rect.mTop,rect.getWidth() > mLastClickedElement->getRect().getWidth() + 5 ? rect.mRight : rect.mLeft + mLastClickedElement->getRect().getWidth() + 5, rect.mBottom));
+ rect = getRect();
+ setRect(LLRect(rect.mLeft,rect.mTop,rect.getWidth() > mLastClickedElement->getRect().getWidth() + 5 ? rect.mRight : rect.mLeft + mLastClickedElement->getRect().getWidth() + 5, rect.mBottom));
// and widen to accomodate text if that's wider
std::string display_text = current_selection_text + LLView::sPreviewClickedElement->getName();
@@ -1534,15 +1589,15 @@ void LLOverlapPanel::draw()
rect = getRect();
setRect(LLRect(rect.mLeft,rect.mTop,rect.getWidth() < text_width ? rect.mLeft + text_width : rect.mRight,rect.mTop));
- std::list<LLView*> overlappers = LLFloaterUIPreview::sInstance->mOverlapMap[LLView::sPreviewClickedElement];
+ std::list<LLView*> overlappers = mOverlapMap[LLView::sPreviewClickedElement];
for(std::list<LLView*>::iterator overlap_it = overlappers.begin(); overlap_it != overlappers.end(); ++overlap_it)
{
LLView* viewp = *overlap_it;
height_sum += viewp->getRect().getHeight() + mSpacing*3;
// widen panel's rectangle to accommodate widest overlapping element of this floater
- rect = LLFloaterUIPreview::sInstance->mOverlapPanel->getRect();
- LLFloaterUIPreview::sInstance->mOverlapPanel->setRect(LLRect(rect.mLeft,rect.mTop,rect.getWidth() > viewp->getRect().getWidth() + 5 ? rect.mRight : rect.mLeft + viewp->getRect().getWidth() + 5, rect.mBottom));
+ rect = getRect();
+ setRect(LLRect(rect.mLeft,rect.mTop,rect.getWidth() > viewp->getRect().getWidth() + 5 ? rect.mRight : rect.mLeft + viewp->getRect().getWidth() + 5, rect.mBottom));
// and widen to accomodate text if that's wider
std::string display_text = overlapper_text + viewp->getName();
@@ -1551,8 +1606,8 @@ void LLOverlapPanel::draw()
setRect(LLRect(rect.mLeft,rect.mTop,rect.getWidth() < text_width ? rect.mLeft + text_width : rect.mRight,rect.mTop));
}
// change panel's height to accommodate all element heights plus spacing between them
- rect = LLFloaterUIPreview::sInstance->mOverlapPanel->getRect();
- LLFloaterUIPreview::sInstance->mOverlapPanel->setRect(LLRect(rect.mLeft,rect.mTop,rect.mRight,rect.mTop-height_sum));
+ rect = getRect();
+ setRect(LLRect(rect.mLeft,rect.mTop,rect.mRight,rect.mTop-height_sum));
}
LLUI::translate(5,getRect().getHeight()-10); // translate to top left