diff --git a/indra/newview/quickprefs.cpp b/indra/newview/quickprefs.cpp index a2338666c8..6eeb6c258f 100644 --- a/indra/newview/quickprefs.cpp +++ b/indra/newview/quickprefs.cpp @@ -2,9 +2,8 @@ * @file quickprefs.cpp * @brief Quick preferences access panel for bottomtray * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Phoenix Firestorm Viewer Source Code * Copyright (C) 2011, WoLf Loonie @ Second Life * Copyright (C) 2013, Zi Ree @ Second Life * Copyright (C) 2013, Ansariel Hiller @ Second Life @@ -25,52 +24,50 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * http://www.firestormviewer.org * $/LicenseInfo$ */ #include "llviewerprecompiledheaders.h" #include "quickprefs.h" -#include "llboost.h" -#include "llcombobox.h" -#include "lldaycyclemanager.h" -#include "llwlparamset.h" -#include "llwlparammanager.h" -#include "llwaterparammanager.h" -#include "llfloatereditsky.h" -#include "llmultisliderctrl.h" -#include "lltimectrl.h" -#include "llenvmanager.h" -#include "llviewercontrol.h" -#include "lldrawpoolbump.h" -#include "llviewertexturelist.h" -#include "llfloaterreg.h" -#include "llfeaturemanager.h" -#include "rlvhandler.h" -#include "llcheckboxctrl.h" -#include "llcubemap.h" -// Dynamic quick prefs #include "llappviewer.h" +#include "llcheckboxctrl.h" #include "llcolorswatch.h" +#include "llcombobox.h" +#include "llcubemap.h" +#include "lldaycyclemanager.h" +#include "lldrawpoolbump.h" +#include "llenvmanager.h" #include "llf32uictrl.h" +#include "llfeaturemanager.h" +#include "llfloaterreg.h" #include "lllayoutstack.h" +#include "llmultisliderctrl.h" +#include "llnotificationsutil.h" #include "llsliderctrl.h" #include "llspinctrl.h" -#include "llnotificationsutil.h" // For restore defaults confirmation - +#include "lltimectrl.h" +#include "lltoolbarview.h" +#include "llviewercontrol.h" +#include "llviewertexturelist.h" +#include "llwaterparammanager.h" +#include "llwlparamset.h" +#include "llwlparammanager.h" +#include "rlvhandler.h" #include -#include + static F32 sun_pos_to_time24(F32 sun_pos) { - return fmodf(sun_pos * 24.0f + 6, 24.0f); + return fmodf(sun_pos * 24.0f + 6.f, 24.0f); } static F32 time24_to_sun_pos(F32 time) { F32 ret = time - 6.f; - if (ret < 0) + if (ret < 0.f) { ret += 24.f; } @@ -115,29 +112,29 @@ void FloaterQuickPrefs::onOpen(const LLSD& key) // Dynamic Quickprefs // bail out here if this is a reused Phototools floater - if(getIsPhototools()) + if (getIsPhototools()) { return; } - gSavedSettings.setBOOL("QuickPrefsEditMode",FALSE); + gSavedSettings.setBOOL("QuickPrefsEditMode", FALSE); // Scan widgets and reapply control variables because some control types // (LLSliderCtrl for example) don't update their GUI when hidden control_list_t::iterator it; - for(it=mControlsList.begin();it!=mControlsList.end();++it) + for (it = mControlsList.begin(); it != mControlsList.end(); ++it) { - const ControlEntry& entry=it->second; + const ControlEntry& entry = it->second; - LLUICtrl* current_widget=entry.widget; - if(!current_widget) + LLUICtrl* current_widget = entry.widget; + if (!current_widget) { LL_WARNS() << "missing widget for control " << it->first << LL_ENDL; continue; } - LLControlVariable* var=current_widget->getControlVariable(); - if(var) + LLControlVariable* var = current_widget->getControlVariable(); + if (var) { current_widget->setValue(var->getValue()); } @@ -376,39 +373,39 @@ BOOL FloaterQuickPrefs::postBuild() // Dynamic quick prefs // bail out here if this is a reused Phototools floater - if(getIsPhototools()) + if (getIsPhototools()) { return LLDockableFloater::postBuild(); } // find the layout_stack to insert the controls into - mOptionsStack=getChild("options_stack"); + mOptionsStack = getChild("options_stack"); // get the path to the user defined or default quick preferences settings - loadSavedSettingsFromFile(getSettingsPath(FALSE)); + loadSavedSettingsFromFile(getSettingsPath(false)); // get edit widget pointers - mControlLabelEdit=getChild("label_edit"); - mControlNameCombo=getChild("control_name_combo"); - mControlTypeCombo=getChild("control_type_combo_box"); - mControlIntegerCheckbox=getChild("control_integer_checkbox"); - mControlMinSpinner=getChild("control_min_edit"); - mControlMaxSpinner=getChild("control_max_edit"); - mControlIncrementSpinner=getChild("control_increment_edit"); + mControlLabelEdit = getChild("label_edit"); + mControlNameCombo = getChild("control_name_combo"); + mControlTypeCombo = getChild("control_type_combo_box"); + mControlIntegerCheckbox = getChild("control_integer_checkbox"); + mControlMinSpinner = getChild("control_min_edit"); + mControlMaxSpinner = getChild("control_max_edit"); + mControlIncrementSpinner = getChild("control_increment_edit"); // wire up callbacks for changed values - mControlLabelEdit->setCommitCallback(boost::bind(&FloaterQuickPrefs::onValuesChanged,this)); - mControlNameCombo->setCommitCallback(boost::bind(&FloaterQuickPrefs::onValuesChanged,this)); - mControlTypeCombo->setCommitCallback(boost::bind(&FloaterQuickPrefs::onValuesChanged,this)); - mControlIntegerCheckbox->setCommitCallback(boost::bind(&FloaterQuickPrefs::onValuesChanged,this)); - mControlMinSpinner->setCommitCallback(boost::bind(&FloaterQuickPrefs::onValuesChanged,this)); - mControlMaxSpinner->setCommitCallback(boost::bind(&FloaterQuickPrefs::onValuesChanged,this)); - mControlIncrementSpinner->setCommitCallback(boost::bind(&FloaterQuickPrefs::onValuesChanged,this)); + mControlLabelEdit->setCommitCallback(boost::bind(&FloaterQuickPrefs::onValuesChanged, this)); + mControlNameCombo->setCommitCallback(boost::bind(&FloaterQuickPrefs::onValuesChanged, this)); + mControlTypeCombo->setCommitCallback(boost::bind(&FloaterQuickPrefs::onValuesChanged, this)); + mControlIntegerCheckbox->setCommitCallback(boost::bind(&FloaterQuickPrefs::onValuesChanged, this)); + mControlMinSpinner->setCommitCallback(boost::bind(&FloaterQuickPrefs::onValuesChanged, this)); + mControlMaxSpinner->setCommitCallback(boost::bind(&FloaterQuickPrefs::onValuesChanged, this)); + mControlIncrementSpinner->setCommitCallback(boost::bind(&FloaterQuickPrefs::onValuesChanged, this)); // wire up ordering and adding buttons - getChild("move_up_button")->setCommitCallback(boost::bind(&FloaterQuickPrefs::onMoveUpClicked,this)); - getChild("move_down_button")->setCommitCallback(boost::bind(&FloaterQuickPrefs::onMoveDownClicked,this)); - getChild("add_new_button")->setCommitCallback(boost::bind(&FloaterQuickPrefs::onAddNewClicked,this)); + getChild("move_up_button")->setCommitCallback(boost::bind(&FloaterQuickPrefs::onMoveUpClicked, this)); + getChild("move_down_button")->setCommitCallback(boost::bind(&FloaterQuickPrefs::onMoveDownClicked, this)); + getChild("add_new_button")->setCommitCallback(boost::bind(&FloaterQuickPrefs::onAddNewClicked, this)); // functor to add debug settings to the editor dropdown struct f : public LLControlGroup::ApplyFunctor @@ -421,7 +418,7 @@ BOOL FloaterQuickPrefs::postBuild() if (!control->isHiddenFromSettingsEditor()) { // don't add floater positions, sizes or visibility values - if(name.find("floater_")!=0) + if (name.find("floater_") != 0) { (*combo).addSimpleElement(name); } @@ -443,11 +440,11 @@ void FloaterQuickPrefs::loadSavedSettingsFromFile(const std::string& settings_pa QuickPrefsXML xml; LLXMLNodePtr root; - if(!LLXMLNode::parseFile(settings_path,root,NULL)) + if (!LLXMLNode::parseFile(settings_path, root, NULL)) { LL_WARNS() << "Unable to load quick preferences from file: " << settings_path << LL_ENDL; } - else if(!root->hasName("quickprefs")) + else if (!root->hasName("quickprefs")) { LL_WARNS() << settings_path << " is not a valid quick preferences definition file" << LL_ENDL; } @@ -455,25 +452,25 @@ void FloaterQuickPrefs::loadSavedSettingsFromFile(const std::string& settings_pa { // Parse the quick preferences settings LLXUIParser parser; - parser.readXUI(root,xml,settings_path); + parser.readXUI(root, xml, settings_path); - if(!xml.validateBlock()) + if (!xml.validateBlock()) { LL_WARNS() << "Unable to validate quick preferences from file: " << settings_path << LL_ENDL; } else { // add the elements from the XML file to the internal list of controls - BOOST_FOREACH(const QuickPrefsXMLEntry& xml_entry,xml.entries) + BOOST_FOREACH(const QuickPrefsXMLEntry& xml_entry, xml.entries) { // get the label - std::string label=xml_entry.label; + std::string label = xml_entry.label; // get the same as translated label - std::string translated_label=xml_entry.label; + std::string translated_label = xml_entry.label; // replace translated label with translated version, if available - LLTrans::findString(translated_label,"QP "+label); + LLTrans::findString(translated_label, "QP " + label); - U32 type=xml_entry.control_type; + U32 type = xml_entry.control_type; addControl( xml_entry.control_name, translated_label, @@ -940,45 +937,45 @@ void FloaterQuickPrefs::enableWindlightButtons(BOOL enable) } // Dynamic quick prefs -std::string FloaterQuickPrefs::getSettingsPath(BOOL save_mode) +std::string FloaterQuickPrefs::getSettingsPath(bool save_mode) { // get the settings file name - std::string settings_file=LLAppViewer::instance()->getSettingsFilename("Default","QuickPreferences"); + std::string settings_file = LLAppViewer::instance()->getSettingsFilename("Default", "QuickPreferences"); // expand to user defined path - std::string settings_path=gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS,settings_file); + std::string settings_path = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, settings_file); // if not in save mode, and the file was not found, use the default path - if(!save_mode && !LLFile::isfile(settings_path)) + if (!save_mode && !LLFile::isfile(settings_path)) { - settings_path=gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,settings_file); + settings_path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, settings_file); } return settings_path; } -void FloaterQuickPrefs::updateControl(const std::string& controlName,ControlEntry& entry) +void FloaterQuickPrefs::updateControl(const std::string& controlName, ControlEntry& entry) { // rename the panel to contain the control's name, for identification later entry.panel->setName(controlName); // build a list of all possible control widget types - std::map typeMap; - std::map::iterator it; + std::map typeMap; + std::map::iterator it; - typeMap[ControlTypeCheckbox]="option_checkbox_control"; - typeMap[ControlTypeText]="option_text_control"; - typeMap[ControlTypeSpinner]="option_spinner_control"; - typeMap[ControlTypeSlider]="option_slider_control"; - typeMap[ControlTypeRadio]="option_radio_control"; - typeMap[ControlTypeColor3]="option_color3_control"; - typeMap[ControlTypeColor4]="option_color4_control"; + typeMap[ControlTypeCheckbox] = "option_checkbox_control"; + typeMap[ControlTypeText] = "option_text_control"; + typeMap[ControlTypeSpinner] = "option_spinner_control"; + typeMap[ControlTypeSlider] = "option_slider_control"; + typeMap[ControlTypeRadio] = "option_radio_control"; + typeMap[ControlTypeColor3] = "option_color3_control"; + typeMap[ControlTypeColor4] = "option_color4_control"; // hide all widget types except for the one the user wants LLUICtrl* widget; - for(it=typeMap.begin();it!=typeMap.end();++it) + for (it = typeMap.begin(); it != typeMap.end(); ++it) { - if(entry.type!=it->first) + if (entry.type != it->first) { - widget=entry.panel->getChild(it->second); + widget = entry.panel->getChild(it->second); if (widget) { @@ -991,13 +988,13 @@ void FloaterQuickPrefs::updateControl(const std::string& controlName,ControlEntr } // get the widget type the user wanted from the panel - widget=entry.panel->getChild(typeMap[entry.type]); + widget = entry.panel->getChild(typeMap[entry.type]); // use 3 decimal places by default - S32 decimals=3; + S32 decimals = 3; // save pointer to the widget in our internal list - entry.widget=widget; + entry.widget = widget; // add the settings control to the widget and enable/show it widget->setControlName(controlName); @@ -1005,100 +1002,100 @@ void FloaterQuickPrefs::updateControl(const std::string& controlName,ControlEntr widget->setEnabled(TRUE); // if no increment is given, try to guess a good number - if(entry.increment==0.0f) + if (entry.increment == 0.0f) { // finer grained for sliders - if(entry.type==ControlTypeSlider) + if (entry.type == ControlTypeSlider) { - entry.increment=(entry.max_value-entry.min_value)/100.0f; + entry.increment = (entry.max_value - entry.min_value) / 100.0f; } // a little less for spinners - else if(entry.type==ControlTypeSpinner) + else if (entry.type == ControlTypeSpinner) { - entry.increment=(entry.max_value-entry.min_value)/20.0f; + entry.increment = (entry.max_value - entry.min_value) / 20.0f; } } // if it's an integer entry, round the numbers - if(entry.integer) + if (entry.integer) { - entry.min_value=llround(entry.min_value); - entry.max_value=llround(entry.max_value); + entry.min_value = llround(entry.min_value); + entry.max_value = llround(entry.max_value); // recalculate increment - entry.increment=llround(entry.increment); - if(entry.increment==0) + entry.increment = llround(entry.increment); + if (entry.increment == 0.f) { - entry.increment=1; + entry.increment = 1.f; } // no decimal places for integers - decimals=0; + decimals = 0; } // set up values for special case control widget types - LLUICtrl* alpha_widget=entry.panel->getChild("option_color_alpha_control"); + LLUICtrl* alpha_widget = entry.panel->getChild("option_color_alpha_control"); alpha_widget->setVisible(FALSE); // sadly, using LLF32UICtrl does not work properly, so we have to use a branch // for each floating point type - if(entry.type==ControlTypeSpinner) + if (entry.type == ControlTypeSpinner) { - LLSpinCtrl* spinner=(LLSpinCtrl*) widget; + LLSpinCtrl* spinner = (LLSpinCtrl*)widget; spinner->setPrecision(decimals); spinner->setMinValue(entry.min_value); spinner->setMaxValue(entry.max_value); spinner->setIncrement(entry.increment); } - else if(entry.type==ControlTypeSlider) + else if (entry.type == ControlTypeSlider) { - LLSliderCtrl* slider=(LLSliderCtrl*) widget; + LLSliderCtrl* slider = (LLSliderCtrl*)widget; slider->setPrecision(decimals); slider->setMinValue(entry.min_value); slider->setMaxValue(entry.max_value); slider->setIncrement(entry.increment); } - else if(entry.type==ControlTypeColor4) + else if (entry.type == ControlTypeColor4) { - LLColorSwatchCtrl* color_widget=(LLColorSwatchCtrl*) widget; + LLColorSwatchCtrl* color_widget = (LLColorSwatchCtrl*)widget; alpha_widget->setVisible(TRUE); alpha_widget->setValue(color_widget->get().mV[VALPHA]); } // reuse a previously created text label if possible - LLTextBox* label_textbox=entry.label_textbox; + LLTextBox* label_textbox = entry.label_textbox; // if the text label is not known yet, this is a brand new control panel - if(!label_textbox) + if (!label_textbox) { // otherwise, get the pointer to the new label - label_textbox=entry.panel->getChild("option_label"); + label_textbox = entry.panel->getChild("option_label"); // add double click and single click callbacks on the text label - label_textbox->setDoubleClickCallback(boost::bind(&FloaterQuickPrefs::onDoubleClickLabel,this,_1,entry.panel)); - label_textbox->setMouseUpCallback(boost::bind(&FloaterQuickPrefs::onClickLabel,this,_1,entry.panel)); + label_textbox->setDoubleClickCallback(boost::bind(&FloaterQuickPrefs::onDoubleClickLabel, this, _1, entry.panel)); + label_textbox->setMouseUpCallback(boost::bind(&FloaterQuickPrefs::onClickLabel, this, _1, entry.panel)); // since this is a new control, wire up the remove button signal, too - LLButton* remove_button=entry.panel->getChild("remove_button"); - remove_button->setCommitCallback(boost::bind(&FloaterQuickPrefs::onRemoveClicked,this,_1,entry.panel)); + LLButton* remove_button = entry.panel->getChild("remove_button"); + remove_button->setCommitCallback(boost::bind(&FloaterQuickPrefs::onRemoveClicked, this, _1, entry.panel)); // and the commit signal for the alpha value in a color4 control - alpha_widget->setCommitCallback(boost::bind(&FloaterQuickPrefs::onAlphaChanged,this,_1,widget)); + alpha_widget->setCommitCallback(boost::bind(&FloaterQuickPrefs::onAlphaChanged, this, _1, widget)); // save the text label pointer in the internal list - entry.label_textbox=label_textbox; + entry.label_textbox = label_textbox; } // set the value(visible text) for the text label - label_textbox->setValue(entry.label+":"); + label_textbox->setValue(entry.label + ":"); // get the named control variable from global or per account settings - LLControlVariable* var=gSavedSettings.getControl(controlName); - if(!var) + LLControlVariable* var = gSavedSettings.getControl(controlName); + if (!var) { - var=gSavedPerAccountSettings.getControl(controlName); + var = gSavedPerAccountSettings.getControl(controlName); } // if we found the control, set up the chosen widget to use it - if(var) + if (var) { widget->setValue(var->getValue()); widget->setToolTip(var->getComment()); @@ -1110,48 +1107,55 @@ void FloaterQuickPrefs::updateControl(const std::string& controlName,ControlEntr } } -LLUICtrl* FloaterQuickPrefs::addControl(const std::string& controlName,const std::string& controlLabel,LLView* slot,ControlType type,BOOL integer,F32 min_value,F32 max_value,F32 increment) +LLUICtrl* FloaterQuickPrefs::addControl(const std::string& controlName, const std::string& controlLabel, LLView* slot, ControlType type, BOOL integer, F32 min_value, F32 max_value, F32 increment) { // create a new controls panel - LLLayoutPanel* panel=LLUICtrlFactory::createFromFile("panel_quickprefs_item.xml",NULL,LLLayoutStack::child_registry_t::instance()); - if(!panel) + LLLayoutPanel* panel = LLUICtrlFactory::createFromFile("panel_quickprefs_item.xml", NULL, LLLayoutStack::child_registry_t::instance()); + if (!panel) { LL_WARNS() << "could not add panel" << LL_ENDL; return NULL; } // sanity checks - if(max_valuegetChild("option_ordering_panel"); - newControl.widget=NULL; - newControl.label_textbox=NULL; - newControl.label=controlLabel; - newControl.type=type; - newControl.integer=integer; - newControl.min_value=min_value; - newControl.max_value=max_value; - newControl.increment=increment; + newControl.panel = panel->getChild("option_ordering_panel"); + newControl.widget = NULL; + newControl.label_textbox = NULL; + newControl.label = controlLabel; + newControl.type = type; + newControl.integer = integer; + newControl.min_value = min_value; + newControl.max_value = max_value; + newControl.increment = increment; // update the new control - updateControl(controlName,newControl); + updateControl(controlName, newControl); // add the control to the internal list - mControlsList[controlName]=newControl; + mControlsList[controlName] = newControl; // if we have a slot already, reparent our new ordering panel and delete the old layout_panel - if(slot) + if (slot) { // add the ordering panel to the slot slot->addChild(newControl.panel); // make sure the panel moves to the top left corner - newControl.panel->setOrigin(0,0); + newControl.panel->setOrigin(0, 0); // resize it to make it fill the slot - newControl.panel->reshape(slot->getRect().getWidth(),slot->getRect().getHeight()); + newControl.panel->reshape(slot->getRect().getWidth(), slot->getRect().getHeight()); // remove the old layout panel from memory delete panel; } @@ -1159,11 +1163,11 @@ LLUICtrl* FloaterQuickPrefs::addControl(const std::string& controlName,const std else { // add a new layout_panel to the stack - mOptionsStack->addPanel(panel,LLLayoutStack::NO_ANIMATE); + mOptionsStack->addPanel(panel, LLLayoutStack::NO_ANIMATE); // add the panel to the list of ordering slots mOrderingSlots.push_back(panel); // make the floater fit the newly added control panel - reshape(getRect().getWidth(),getRect().getHeight()+panel->getRect().getHeight()); + reshape(getRect().getWidth(), getRect().getHeight() + panel->getRect().getHeight()); // show the panel panel->setVisible(TRUE); } @@ -1174,33 +1178,33 @@ LLUICtrl* FloaterQuickPrefs::addControl(const std::string& controlName,const std return newControl.widget; } -void FloaterQuickPrefs::removeControl(const std::string& controlName,BOOL remove_slot) +void FloaterQuickPrefs::removeControl(const std::string& controlName, bool remove_slot) { // find the control panel to remove - const control_list_t::iterator it=mControlsList.find(controlName); - if(it==mControlsList.end()) + const control_list_t::iterator it = mControlsList.find(controlName); + if (it == mControlsList.end()) { LL_WARNS() << "Couldn't find control entry " << controlName << LL_ENDL; return; } // get a pointer to the panel to remove - LLPanel* panel=it->second.panel; + LLPanel* panel = it->second.panel; // remember the panel's height because it will be deleted by removeChild() later - S32 height=panel->getRect().getHeight(); + S32 height = panel->getRect().getHeight(); // remove the panel from the internal list mControlsList.erase(it); // get a pointer to the layout slot used - LLLayoutPanel* slot=(LLLayoutPanel*) panel->getParent(); + LLLayoutPanel* slot = (LLLayoutPanel*)panel->getParent(); // remove the panel from the slot slot->removeChild(panel); // clear the panel from memory delete panel; // remove the layout_panel if desired - if(remove_slot) + if (remove_slot) { // remove the slot from our list mOrderingSlots.remove(slot); @@ -1208,31 +1212,31 @@ void FloaterQuickPrefs::removeControl(const std::string& controlName,BOOL remove mOptionsStack->removeChild(slot); // make the floater shrink to its new size - reshape(getRect().getWidth(),getRect().getHeight()-height); + reshape(getRect().getWidth(), getRect().getHeight() - height); } } void FloaterQuickPrefs::selectControl(std::string controlName) { // remove previously selected marker, if any - if(!mSelectedControl.empty() && hasControl( mSelectedControl ) ) + if (!mSelectedControl.empty() && hasControl(mSelectedControl)) { mControlsList[mSelectedControl].panel->setBorderVisible(FALSE); } // save the currently selected name in a volatile settings control to // enable/disable the editor widgets - mSelectedControl=controlName; - gSavedSettings.setString("QuickPrefsSelectedControl",controlName); + mSelectedControl = controlName; + gSavedSettings.setString("QuickPrefsSelectedControl", controlName); - if( mSelectedControl.size() && !hasControl( mSelectedControl ) ) + if (mSelectedControl.size() && !hasControl(mSelectedControl)) { mSelectedControl = ""; return; } // if we are not in edit mode, we can stop here - if(!gSavedSettings.getBOOL("QuickPrefsEditMode")) + if (!gSavedSettings.getBOOL("QuickPrefsEditMode")) { return; } @@ -1241,10 +1245,10 @@ void FloaterQuickPrefs::selectControl(std::string controlName) mControlNameCombo->selectNthItem(0); // assume we don't need the min/max/increment/integer widgets by default - BOOL enable_floating_point=FALSE; + BOOL enable_floating_point = FALSE; // if actually a selection is present, set up the editor widgets - if(!mSelectedControl.empty()) + if (!mSelectedControl.empty()) { // draw the new selection border mControlsList[mSelectedControl].panel->setBorderVisible(TRUE); @@ -1259,23 +1263,23 @@ void FloaterQuickPrefs::selectControl(std::string controlName) mControlIncrementSpinner->setValue(LLSD(mControlsList[mSelectedControl].increment)); // special handling to enable min/max/integer/increment widgets - switch(mControlsList[mSelectedControl].type) + switch (mControlsList[mSelectedControl].type) { // enable floating point widgets for these types case ControlTypeSpinner: // fall through case ControlTypeSlider: // fall through { - enable_floating_point=TRUE; + enable_floating_point = TRUE; // assume we have floating point widgets mControlIncrementSpinner->setIncrement(0.1f); // use 3 decimal places by default - S32 decimals=3; + S32 decimals = 3; // unless we have an integer control - if(mControlsList[mSelectedControl].integer) + if (mControlsList[mSelectedControl].integer) { - decimals=0; - mControlIncrementSpinner->setIncrement(1.0); + decimals = 0; + mControlIncrementSpinner->setIncrement(1.0f); } // set up floating point widgets mControlMinSpinner->setPrecision(decimals); @@ -1297,30 +1301,30 @@ void FloaterQuickPrefs::selectControl(std::string controlName) mControlIncrementSpinner->setEnabled(enable_floating_point); } -void FloaterQuickPrefs::onClickLabel(LLUICtrl* ctrl,void* userdata) +void FloaterQuickPrefs::onClickLabel(LLUICtrl* ctrl, void* userdata) { // don't do anything when we are not in edit mode - if(!gSavedSettings.getBOOL("QuickPrefsEditMode")) + if (!gSavedSettings.getBOOL("QuickPrefsEditMode")) { return; } // get the associated panel from the submitted userdata - LLUICtrl* panel=(LLUICtrl*) userdata; + LLUICtrl* panel = (LLUICtrl*)userdata; // select the clicked control, identified by its name selectControl(panel->getName()); } -void FloaterQuickPrefs::onDoubleClickLabel(LLUICtrl* ctrl,void* userdata) +void FloaterQuickPrefs::onDoubleClickLabel(LLUICtrl* ctrl, void* userdata) { // toggle edit mode - BOOL edit_mode=!gSavedSettings.getBOOL("QuickPrefsEditMode"); - gSavedSettings.setBOOL("QuickPrefsEditMode",edit_mode); + BOOL edit_mode = !gSavedSettings.getBOOL("QuickPrefsEditMode"); + gSavedSettings.setBOOL("QuickPrefsEditMode", edit_mode); // select the double clicked control if we toggled edit on - if(edit_mode) + if (edit_mode) { // get the associated widget from the submitted userdata - LLUICtrl* panel=(LLUICtrl*) userdata; + LLUICtrl* panel = (LLUICtrl*)userdata; selectControl(panel->getName()); } } @@ -1328,7 +1332,7 @@ void FloaterQuickPrefs::onDoubleClickLabel(LLUICtrl* ctrl,void* userdata) void FloaterQuickPrefs::onEditModeChanged() { // if edit mode was enabled, stop here - if(gSavedSettings.getBOOL("QuickPrefsEditMode")) + if (gSavedSettings.getBOOL("QuickPrefsEditMode")) { return; } @@ -1337,38 +1341,38 @@ void FloaterQuickPrefs::onEditModeChanged() selectControl(""); QuickPrefsXML xml; - std::string settings_path=getSettingsPath(TRUE); + std::string settings_path = getSettingsPath(true); // loop through the list of controls, in the displayed order std::list::iterator it; - for(it=mControlsOrder.begin();it!=mControlsOrder.end();++it) + for (it = mControlsOrder.begin(); it != mControlsOrder.end(); ++it) { - const ControlEntry& entry=mControlsList[*it]; + const ControlEntry& entry = mControlsList[*it]; QuickPrefsXMLEntry xml_entry; // add control values to the XML entry - xml_entry.control_name=*it; - xml_entry.label=entry.label; - xml_entry.control_type=(U32) entry.type; - xml_entry.integer=entry.integer; - xml_entry.min_value=entry.min_value; - xml_entry.max_value=entry.max_value; - xml_entry.increment=entry.increment; + xml_entry.control_name = *it; + xml_entry.label = entry.label; + xml_entry.control_type = (U32)entry.type; + xml_entry.integer = entry.integer; + xml_entry.min_value = entry.min_value; + xml_entry.max_value = entry.max_value; + xml_entry.increment = entry.increment; // add the XML entry to the overall XML container xml.entries.add(xml_entry); } // Serialize the parameter tree - LLXMLNodePtr output_node=new LLXMLNode("quickprefs",false); + LLXMLNodePtr output_node = new LLXMLNode("quickprefs", false); LLXUIParser parser; - parser.writeXUI(output_node,xml); + parser.writeXUI(output_node, xml); // Write the resulting XML to file - if(!output_node->isNull()) + if (!output_node->isNull()) { - LLFILE *fp=LLFile::fopen(settings_path,"w"); - if(fp!=NULL) + LLFILE* fp = LLFile::fopen(settings_path, "w"); + if (fp) { LLXMLNode::writeHeaderToFile(fp); output_node->writeToFile(fp); @@ -1380,111 +1384,111 @@ void FloaterQuickPrefs::onEditModeChanged() void FloaterQuickPrefs::onValuesChanged() { // safety, do nothing if we are not in edit mode - if(!gSavedSettings.getBOOL("QuickPrefsEditMode")) + if (!gSavedSettings.getBOOL("QuickPrefsEditMode")) { return; } // don't crash when we try to update values without having a control selected - if(mSelectedControl=="") + if (mSelectedControl.empty()) { return; } // remember the current and possibly new control names - std::string old_control_name=mSelectedControl; - std::string new_control_name=mControlNameCombo->getValue(); + std::string old_control_name = mSelectedControl; + std::string new_control_name = mControlNameCombo->getValue(); // if we changed the control's variable, rebuild the user interface - if(!new_control_name.empty() && old_control_name!=new_control_name) + if (!new_control_name.empty() && old_control_name != new_control_name) { // remember the old control parameters so we can restore them later - ControlEntry old_parameters=mControlsList[mSelectedControl]; + ControlEntry old_parameters = mControlsList[mSelectedControl]; // disable selection so the border doesn't cause a crash selectControl(""); // rename the old ordering entry std::list::iterator it; - for(it=mControlsOrder.begin();it!=mControlsOrder.end();++it) + for (it = mControlsOrder.begin(); it != mControlsOrder.end(); ++it) { - if(*it==old_control_name) + if (*it == old_control_name) { - *it=new_control_name; + *it = new_control_name; break; } } // remember the old slot - LLView* slot=old_parameters.panel->getParent(); + LLView* slot =old_parameters.panel->getParent(); // remove the old control name from the internal list but keep the slot available - removeControl(old_control_name,FALSE); + removeControl(old_control_name, false); // add new control with the old slot - addControl(new_control_name,new_control_name,slot); + addControl(new_control_name, new_control_name, slot); // grab the new values and make the selection border go to the right panel selectControl(new_control_name); // restore the old UI settings - mControlsList[mSelectedControl].label=old_parameters.label; + mControlsList[mSelectedControl].label = old_parameters.label; // find the control variable in global or per account settings - LLControlVariable* var=gSavedSettings.getControl(mSelectedControl); - if(!var) + LLControlVariable* var = gSavedSettings.getControl(mSelectedControl); + if (!var) { - var=gSavedPerAccountSettings.getControl(mSelectedControl); + var = gSavedPerAccountSettings.getControl(mSelectedControl); } - if(var && hasControl(mSelectedControl) ) + if (var && hasControl(mSelectedControl)) { // choose sane defaults for floating point controls, so the control value won't be destroyed // start with these - F32 min_value=0.0; - F32 max_value=1.0; - F32 value=var->getValue().asReal(); + F32 min_value = 0.0f; + F32 max_value = 1.0f; + F32 value = var->getValue().asReal(); // if the value was negative and smaller than the current minimum - if(value<0.0f) + if (value < 0.0f) { // make the minimum even smaller - min_value=value*2.0f; + min_value = value * 2.0f; } // if the value is above zero, set max to double of the current value - else if(value>0.0f) + else if (value > 0.0f) { - max_value=value*2.0f; + max_value = value * 2.0f; } // do a best guess on variable types and control widgets ControlType type; - switch(var->type()) + switch (var->type()) { // Boolean gets the full set case TYPE_BOOLEAN: { // increment will be calculated below - min_value=0.0; - max_value=1.0; - type=ControlTypeRadio; + min_value = 0.0f; + max_value = 1.0f; + type = ControlTypeRadio; break; } // LLColor3/4 are just colors case TYPE_COL3: { - type=ControlTypeColor3; + type = ControlTypeColor3; break; } case TYPE_COL4: { - type=ControlTypeColor4; + type = ControlTypeColor4; break; } // U32 can never be negative case TYPE_U32: { - min_value=0.0; + min_value = 0.0f; } // Fallthrough, S32 and U32 are integer values case TYPE_S32: // Fallthrough, S32, U32 and F32 should use sliders case TYPE_F32: { - type=ControlTypeSlider; + type = ControlTypeSlider; break; } // Everything else gets a text widget for now @@ -1495,68 +1499,59 @@ void FloaterQuickPrefs::onValuesChanged() } // choose a sane increment - F32 increment=0.1f; - if( mControlsList[mSelectedControl].type==ControlTypeSlider ) + F32 increment = 0.1f; + if (mControlsList[mSelectedControl].type == ControlTypeSlider) { // fine grained control for sliders - increment=(max_value-min_value)/100.0f; + increment = (max_value - min_value) / 100.0f; } - else if( mControlsList[mSelectedControl].type==ControlTypeSpinner) + else if (mControlsList[mSelectedControl].type == ControlTypeSpinner) { // not as fine grained for spinners - increment=(max_value-min_value)/20.0f; + increment = (max_value - min_value) / 20.0f; } // don't let values go too small - if(increment<0.1) + if (increment < 0.1f) { - increment=0.1f; + increment = 0.1f; } // save calculated values to the edit widgets - mControlsList[mSelectedControl].min_value=min_value; - mControlsList[mSelectedControl].max_value=max_value; - mControlsList[mSelectedControl].increment=increment; - mControlsList[mSelectedControl].type=type; // old_parameters.type; + mControlsList[mSelectedControl].min_value = min_value; + mControlsList[mSelectedControl].max_value = max_value; + mControlsList[mSelectedControl].increment = increment; + mControlsList[mSelectedControl].type = type; // old_parameters.type; mControlsList[mSelectedControl].widget->setValue(var->getValue()); } // rebuild controls UI (probably not needed) // updateControls(); // update our new control - updateControl(mSelectedControl,mControlsList[mSelectedControl]); + updateControl(mSelectedControl, mControlsList[mSelectedControl]); } // the control's setting variable is still the same, so just update the values - else if( hasControl(mSelectedControl) ) + else if (hasControl(mSelectedControl)) { - mControlsList[mSelectedControl].label=mControlLabelEdit->getValue().asString(); - mControlsList[mSelectedControl].type=(ControlType) mControlTypeCombo->getValue().asInteger(); - mControlsList[mSelectedControl].integer=mControlIntegerCheckbox->getValue().asBoolean(); - mControlsList[mSelectedControl].min_value=mControlMinSpinner->getValue().asReal(); - mControlsList[mSelectedControl].max_value=mControlMaxSpinner->getValue().asReal(); - mControlsList[mSelectedControl].increment=mControlIncrementSpinner->getValue().asReal(); + mControlsList[mSelectedControl].label = mControlLabelEdit->getValue().asString(); + mControlsList[mSelectedControl].type = (ControlType)mControlTypeCombo->getValue().asInteger(); + mControlsList[mSelectedControl].integer = mControlIntegerCheckbox->getValue().asBoolean(); + mControlsList[mSelectedControl].min_value = mControlMinSpinner->getValue().asReal(); + mControlsList[mSelectedControl].max_value = mControlMaxSpinner->getValue().asReal(); + mControlsList[mSelectedControl].increment = mControlIncrementSpinner->getValue().asReal(); // and update the user interface - updateControl(mSelectedControl,mControlsList[mSelectedControl]); + updateControl(mSelectedControl, mControlsList[mSelectedControl]); } // select the control selectControl(mSelectedControl); - - // - // setting focus can lead to an endless loop of two floaters fighting for focus. See FIRE-9634 - // so we rather deal with focus loss sometimes (how often?) than a nasty hang - - // // sometimes we seem to lose focus, so make sure we keep it - // setFocus(TRUE); - - // } void FloaterQuickPrefs::onAddNewClicked() { // count a number to keep control names unique - static S32 sCount=0; - std::string new_control_name="NewControl"+LLSD(sCount).asString(); + static S32 sCount = 0; + std::string new_control_name = "NewControl" + LLSD(sCount).asString(); // add the new control to the internal list and user interface - addControl(new_control_name,new_control_name); + addControl(new_control_name, new_control_name); // put it at the bottom of the ordering stack mControlsOrder.push_back(new_control_name); sCount++; @@ -1564,10 +1559,10 @@ void FloaterQuickPrefs::onAddNewClicked() selectControl(new_control_name); } -void FloaterQuickPrefs::onRemoveClicked(LLUICtrl* ctrl,void* userdata) +void FloaterQuickPrefs::onRemoveClicked(LLUICtrl* ctrl, void* userdata) { // get the associated panel from the submitted userdata - LLUICtrl* panel=(LLUICtrl*) userdata; + LLUICtrl* panel = (LLUICtrl*)userdata; // deselect the current entry selectControl(""); // first remove the control from the ordering list @@ -1578,12 +1573,12 @@ void FloaterQuickPrefs::onRemoveClicked(LLUICtrl* ctrl,void* userdata) setFocus(TRUE); } -void FloaterQuickPrefs::onAlphaChanged(LLUICtrl* ctrl,void* userdata) +void FloaterQuickPrefs::onAlphaChanged(LLUICtrl* ctrl, void* userdata) { // get the associated color swatch from the submitted userdata - LLColorSwatchCtrl* color_swatch=(LLColorSwatchCtrl*) userdata; + LLColorSwatchCtrl* color_swatch = (LLColorSwatchCtrl*)userdata; // get the current color - LLColor4 color=color_swatch->get(); + LLColor4 color = color_swatch->get(); // replace the alpha value of the color with the value in the alpha spinner color.setAlpha(ctrl->getValue().asReal()); // save the color back into the color swatch @@ -1593,12 +1588,12 @@ void FloaterQuickPrefs::onAlphaChanged(LLUICtrl* ctrl,void* userdata) void FloaterQuickPrefs::swapControls(const std::string& control1, const std::string& control2) { // get the control entries of both controls - ControlEntry temp_entry_1=mControlsList[control1]; - ControlEntry temp_entry_2=mControlsList[control2]; + ControlEntry temp_entry_1 = mControlsList[control1]; + ControlEntry temp_entry_2 = mControlsList[control2]; // find the respective ordering slots - LLView* temp_slot_1=temp_entry_1.panel->getParent(); - LLView* temp_slot_2=temp_entry_2.panel->getParent(); + LLView* temp_slot_1 = temp_entry_1.panel->getParent(); + LLView* temp_slot_2 = temp_entry_2.panel->getParent(); // swap the controls around temp_slot_1->addChild(temp_entry_2.panel); @@ -1609,24 +1604,26 @@ void FloaterQuickPrefs::onMoveUpClicked() { // find the control in the ordering list std::list::iterator it; - for(it=mControlsOrder.begin();it!=mControlsOrder.end();++it) + for (it = mControlsOrder.begin(); it != mControlsOrder.end(); ++it) { - if(*it==mSelectedControl) + if (*it == mSelectedControl) { // if it's already on top of the list, do nothing - if(it==mControlsOrder.begin()) + if (it == mControlsOrder.begin()) + { return; + } // get the iterator of the previous item - std::list::iterator previous=it; + std::list::iterator previous = it; --previous; // copy the previous item to the one we want to move - *it=*previous; + *it = *previous; // copy the moving item to previous - *previous=mSelectedControl; + *previous = mSelectedControl; // update the user interface - swapControls(mSelectedControl,*it); + swapControls(mSelectedControl, *it); return; } } @@ -1637,24 +1634,26 @@ void FloaterQuickPrefs::onMoveDownClicked() { // find the control in the ordering list std::list::iterator it; - for(it=mControlsOrder.begin();it!=mControlsOrder.end();++it) + for (it = mControlsOrder.begin(); it != mControlsOrder.end(); ++it) { - if(*it==mSelectedControl) + if (*it == mSelectedControl) { // if it's already at the end of the list, do nothing - if(*it==mControlsOrder.back()) + if (*it == mControlsOrder.back()) + { return; + } // get the iterator of the next item - std::list::iterator next=it; + std::list::iterator next = it; ++next; // copy the next item to the one we want to move - *it=*next; + *it = *next; // copy the moving item to next - *next=mSelectedControl; + *next = mSelectedControl; // update the user interface - swapControls(mSelectedControl,*it); + swapControls(mSelectedControl, *it); return; } } @@ -1664,13 +1663,13 @@ void FloaterQuickPrefs::onMoveDownClicked() void FloaterQuickPrefs::onClose(bool app_quitting) { // bail out here if this is a reused Phototools floater - if(getIsPhototools()) + if (getIsPhototools()) { return; } // close edit mode and save settings - gSavedSettings.setBOOL("QuickPrefsEditMode",FALSE); + gSavedSettings.setBOOL("QuickPrefsEditMode", FALSE); } // @@ -1727,7 +1726,7 @@ void FloaterQuickPrefs::onClickResetVignetteX() { LLVector3 vignette = gSavedSettings.getVector3("FSRenderVignette"); // FIXME: Don't use a hardcoded default value for resetting to default. - vignette.mV[VX] = 0.0; + vignette.mV[VX] = 0.0f; mSliderVignetteX->setValue(0); mSpinnerVignetteX->setValue(0); gSavedSettings.setVector3("FSRenderVignette", vignette); @@ -1737,7 +1736,7 @@ void FloaterQuickPrefs::onClickResetVignetteY() { LLVector3 vignette = gSavedSettings.getVector3("FSRenderVignette"); // FIXME: Don't use a hardcoded default value for resetting to default. - vignette.mV[VY] = 1.0; + vignette.mV[VY] = 1.0f; mSliderVignetteY->setValue(1); mSpinnerVignetteY->setValue(1); gSavedSettings.setVector3("FSRenderVignette", vignette); @@ -1747,7 +1746,7 @@ void FloaterQuickPrefs::onClickResetVignetteZ() { LLVector3 vignette = gSavedSettings.getVector3("FSRenderVignette"); // FIXME: Don't use a hardcoded default value for resetting to default. - vignette.mV[VZ] = 1.0; + vignette.mV[VZ] = 1.0f; mSliderVignetteZ->setValue(1); mSpinnerVignetteZ->setValue(1); gSavedSettings.setVector3("FSRenderVignette", vignette); diff --git a/indra/newview/quickprefs.h b/indra/newview/quickprefs.h index 2be835f95a..937a57710d 100644 --- a/indra/newview/quickprefs.h +++ b/indra/newview/quickprefs.h @@ -2,9 +2,8 @@ * @file quickprefs.h * @brief Quick preferences access panel for bottomtray * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Phoenix Firestorm Viewer Source Code * Copyright (C) 2011, WoLf Loonie @ Second Life * Copyright (C) 2013, Zi Ree @ Second Life * Copyright (C) 2013, Ansariel Hiller @ Second Life @@ -24,6 +23,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * http://www.firestormviewer.org * $/LicenseInfo$ */ @@ -259,22 +259,22 @@ protected: // returns the path to the quick_preferences.xml file. in save mode it will // always return the user_settings path, if not in save mode, it will return // the app_settings path in case the user_settings path does not (yet) exist - std::string getSettingsPath(BOOL save_mode); + std::string getSettingsPath(bool save_mode); // adds a new control and returns a pointer to the chosen widget - LLUICtrl* addControl(const std::string& controlName,const std::string& controlLabel,LLView* slot=NULL,ControlType type=ControlTypeRadio,BOOL integer=FALSE,F32 min_value=-1000000.0f,F32 max_value=1000000.0,F32 increment=0.0f); + LLUICtrl* addControl(const std::string& controlName, const std::string& controlLabel, LLView* slot = NULL, ControlType type = ControlTypeRadio, BOOL integer = FALSE, F32 min_value = -1000000.0f, F32 max_value = 1000000.0f, F32 increment = 0.0f); // removes a control - void removeControl(const std::string& controlName,BOOL remove_slot=TRUE); + void removeControl(const std::string& controlName, bool remove_slot = true); // updates a single control - void updateControl(const std::string& controlName,ControlEntry& entry); + void updateControl(const std::string& controlName, ControlEntry& entry); // make this control the currently selected one void selectControl(std::string controlName); // toggles edit mode - void onDoubleClickLabel(LLUICtrl* ctrl,void* userdata); // userdata is the associated panel + void onDoubleClickLabel(LLUICtrl* ctrl, void* userdata); // userdata is the associated panel // selects a control in edit mode - void onClickLabel(LLUICtrl* ctrl,void* userdata); // userdata is the associated panel + void onClickLabel(LLUICtrl* ctrl, void* userdata); // userdata is the associated panel // will save settings when leaving edit mode void onEditModeChanged(); @@ -282,13 +282,13 @@ protected: void onValuesChanged(); void onAddNewClicked(); - void onRemoveClicked(LLUICtrl* ctrl,void* userdata); // userdata is the associated panel - void onAlphaChanged(LLUICtrl* ctrl,void* userdata); // userdata is the associated color swatch + void onRemoveClicked(LLUICtrl* ctrl, void* userdata); // userdata is the associated panel + void onAlphaChanged(LLUICtrl* ctrl, void* userdata); // userdata is the associated color swatch void onMoveUpClicked(); void onMoveDownClicked(); // swaps two controls, used for move up and down - void swapControls(const std::string& control1,const std::string& control2); + void swapControls(const std::string& control1, const std::string& control2); // bool hasControl( std::string const &aName ) const