Update LLFloaterSettingsDebug to match up with v-d.

Adds boost::bind and makes the floater a singleton.
This commit is contained in:
Lirusaito
2013-01-03 17:20:57 -05:00
parent c3829485e4
commit 9498375e75
4 changed files with 63 additions and 93 deletions

View File

@@ -34,27 +34,25 @@
#include "llfloatersettingsdebug.h" #include "llfloatersettingsdebug.h"
#include "llfloater.h" #include "llfloater.h"
#include "lluictrlfactory.h" #include "lluictrlfactory.h"
#include "llfirstuse.h" //#include "llfirstuse.h"
#include "llcombobox.h" #include "llcombobox.h"
#include "llspinctrl.h" #include "llspinctrl.h"
#include "llcolorswatch.h" #include "llcolorswatch.h"
#include "llviewercontrol.h" #include "llviewercontrol.h"
#include "lltexteditor.h"
// [RLVa:KB] // [RLVa:KB]
#include "rlvhandler.h" #include "rlvhandler.h"
#include "rlvextensions.h" #include "rlvextensions.h"
// [/RLVa:KB] // [/RLVa:KB]
LLFloaterSettingsDebug* LLFloaterSettingsDebug::sInstance = NULL; LLFloaterSettingsDebug::LLFloaterSettingsDebug()
: LLFloater(std::string("Configuration Editor"))
LLFloaterSettingsDebug::LLFloaterSettingsDebug() : LLFloater(std::string("Configuration Editor"))
{ {
} }
LLFloaterSettingsDebug::~LLFloaterSettingsDebug() LLFloaterSettingsDebug::~LLFloaterSettingsDebug()
{ {}
sInstance = NULL;
}
BOOL LLFloaterSettingsDebug::postBuild() BOOL LLFloaterSettingsDebug::postBuild()
{ {
@@ -78,25 +76,17 @@ BOOL LLFloaterSettingsDebug::postBuild()
gColors.applyToAll(&func); gColors.applyToAll(&func);
settings_combo->sortByName(); settings_combo->sortByName();
settings_combo->setCommitCallback(onSettingSelect); settings_combo->setCommitCallback(boost::bind(&LLFloaterSettingsDebug::onSettingSelect, this, settings_combo));
settings_combo->setCallbackUserData(this);
settings_combo->updateSelection(); settings_combo->updateSelection();
childSetCommitCallback("val_spinner_1", onCommitSettings); getChild<LLUICtrl>("val_spinner_1")->setCommitCallback(boost::bind(&LLFloaterSettingsDebug::onCommitSettings, this));
childSetUserData("val_spinner_1", this); getChild<LLUICtrl>("val_spinner_2")->setCommitCallback(boost::bind(&LLFloaterSettingsDebug::onCommitSettings, this));
childSetCommitCallback("val_spinner_2", onCommitSettings); getChild<LLUICtrl>("val_spinner_3")->setCommitCallback(boost::bind(&LLFloaterSettingsDebug::onCommitSettings, this));
childSetUserData("val_spinner_2", this); getChild<LLUICtrl>("val_spinner_4")->setCommitCallback(boost::bind(&LLFloaterSettingsDebug::onCommitSettings, this));
childSetCommitCallback("val_spinner_3", onCommitSettings); getChild<LLUICtrl>("val_text")->setCommitCallback(boost::bind(&LLFloaterSettingsDebug::onCommitSettings, this));
childSetUserData("val_spinner_3", this); getChild<LLUICtrl>("boolean_combo")->setCommitCallback(boost::bind(&LLFloaterSettingsDebug::onCommitSettings, this));
childSetCommitCallback("val_spinner_4", onCommitSettings); getChild<LLUICtrl>("color_swatch")->setCommitCallback(boost::bind(&LLFloaterSettingsDebug::onCommitSettings, this));
childSetUserData("val_spinner_4", this); getChild<LLUICtrl>("default_btn")->setCommitCallback(boost::bind(&LLFloaterSettingsDebug::onClickDefault, this));
childSetCommitCallback("val_text", onCommitSettings);
childSetUserData("val_text", this);
childSetCommitCallback("boolean_combo", onCommitSettings);
childSetUserData("boolean_combo", this);
childSetCommitCallback("color_swatch", onCommitSettings);
childSetUserData("color_swatch", this);
childSetAction("default_btn", onClickDefault, this);
mComment = getChild<LLTextEditor>("comment_text"); mComment = getChild<LLTextEditor>("comment_text");
return TRUE; return TRUE;
} }
@@ -110,35 +100,17 @@ void LLFloaterSettingsDebug::draw()
LLFloater::draw(); LLFloater::draw();
} }
//static void LLFloaterSettingsDebug::onSettingSelect(LLUICtrl* ctrl)
void LLFloaterSettingsDebug::show(void*)
{ {
if (sInstance == NULL)
{
sInstance = new LLFloaterSettingsDebug();
LLUICtrlFactory::getInstance()->buildFloater(sInstance, "floater_settings_debug.xml");
}
sInstance->open(); /* Flawfinder: ignore */
}
//static
void LLFloaterSettingsDebug::onSettingSelect(LLUICtrl* ctrl, void* user_data)
{
LLFloaterSettingsDebug* floaterp = (LLFloaterSettingsDebug*)user_data;
LLComboBox* combo_box = static_cast<LLComboBox*>(ctrl); LLComboBox* combo_box = static_cast<LLComboBox*>(ctrl);
LLControlVariable* controlp = static_cast<LLControlVariable*>(combo_box->getCurrentUserdata()); LLControlVariable* controlp = static_cast<LLControlVariable*>(combo_box->getCurrentUserdata());
floaterp->updateControl(controlp ? controlp->getCOAActive() : NULL); updateControl(controlp ? controlp->getCOAActive() : NULL);
} }
//static void LLFloaterSettingsDebug::onCommitSettings()
void LLFloaterSettingsDebug::onCommitSettings(LLUICtrl* ctrl, void* user_data)
{ {
LLFloaterSettingsDebug* floaterp = (LLFloaterSettingsDebug*)user_data; LLComboBox* settings_combo = getChild<LLComboBox>("settings_combo");
LLComboBox* settings_combo = floaterp->getChild<LLComboBox>("settings_combo");
LLControlVariable* controlp = static_cast<LLControlVariable*>(settings_combo->getCurrentUserdata()); LLControlVariable* controlp = static_cast<LLControlVariable*>(settings_combo->getCurrentUserdata());
controlp = controlp ? controlp->getCOAActive() : NULL; controlp = controlp ? controlp->getCOAActive() : NULL;
if(!controlp)//Uh oh! if(!controlp)//Uh oh!
@@ -155,55 +127,55 @@ void LLFloaterSettingsDebug::onCommitSettings(LLUICtrl* ctrl, void* user_data)
switch(controlp->type()) switch(controlp->type())
{ {
case TYPE_U32: case TYPE_U32:
controlp->set(floaterp->childGetValue("val_spinner_1")); controlp->set(getChild<LLUICtrl>("val_spinner_1")->getValue());
break; break;
case TYPE_S32: case TYPE_S32:
controlp->set(floaterp->childGetValue("val_spinner_1")); controlp->set(getChild<LLUICtrl>("val_spinner_1")->getValue());
break; break;
case TYPE_F32: case TYPE_F32:
controlp->set(LLSD(floaterp->childGetValue("val_spinner_1").asReal())); controlp->set(LLSD(getChild<LLUICtrl>("val_spinner_1")->getValue().asReal()));
break; break;
case TYPE_BOOLEAN: case TYPE_BOOLEAN:
controlp->set(floaterp->childGetValue("boolean_combo")); controlp->set(getChild<LLUICtrl>("boolean_combo")->getValue());
break; break;
case TYPE_STRING: case TYPE_STRING:
controlp->set(LLSD(floaterp->childGetValue("val_text").asString())); controlp->set(LLSD(getChild<LLUICtrl>("val_text")->getValue().asString()));
break; break;
case TYPE_VEC3: case TYPE_VEC3:
vector.mV[VX] = (F32)floaterp->childGetValue("val_spinner_1").asReal(); vector.mV[VX] = (F32)getChild<LLUICtrl>("val_spinner_1")->getValue().asReal();
vector.mV[VY] = (F32)floaterp->childGetValue("val_spinner_2").asReal(); vector.mV[VY] = (F32)getChild<LLUICtrl>("val_spinner_2")->getValue().asReal();
vector.mV[VZ] = (F32)floaterp->childGetValue("val_spinner_3").asReal(); vector.mV[VZ] = (F32)getChild<LLUICtrl>("val_spinner_3")->getValue().asReal();
controlp->set(vector.getValue()); controlp->set(vector.getValue());
break; break;
case TYPE_VEC3D: case TYPE_VEC3D:
vectord.mdV[VX] = floaterp->childGetValue("val_spinner_1").asReal(); vectord.mdV[VX] = getChild<LLUICtrl>("val_spinner_1")->getValue().asReal();
vectord.mdV[VY] = floaterp->childGetValue("val_spinner_2").asReal(); vectord.mdV[VY] = getChild<LLUICtrl>("val_spinner_2")->getValue().asReal();
vectord.mdV[VZ] = floaterp->childGetValue("val_spinner_3").asReal(); vectord.mdV[VZ] = getChild<LLUICtrl>("val_spinner_3")->getValue().asReal();
controlp->set(vectord.getValue()); controlp->set(vectord.getValue());
break; break;
case TYPE_RECT: case TYPE_RECT:
rect.mLeft = floaterp->childGetValue("val_spinner_1").asInteger(); rect.mLeft = getChild<LLUICtrl>("val_spinner_1")->getValue().asInteger();
rect.mRight = floaterp->childGetValue("val_spinner_2").asInteger(); rect.mRight = getChild<LLUICtrl>("val_spinner_2")->getValue().asInteger();
rect.mBottom = floaterp->childGetValue("val_spinner_3").asInteger(); rect.mBottom = getChild<LLUICtrl>("val_spinner_3")->getValue().asInteger();
rect.mTop = floaterp->childGetValue("val_spinner_4").asInteger(); rect.mTop = getChild<LLUICtrl>("val_spinner_4")->getValue().asInteger();
controlp->set(rect.getValue()); controlp->set(rect.getValue());
break; break;
case TYPE_COL4: case TYPE_COL4:
col3.setValue(floaterp->childGetValue("color_swatch")); col3.setValue(getChild<LLUICtrl>("val_color_swatch")->getValue());
col4 = LLColor4(col3, (F32)floaterp->childGetValue("val_spinner_4").asReal()); col4 = LLColor4(col3, (F32)getChild<LLUICtrl>("val_spinner_4")->getValue().asReal());
controlp->set(col4.getValue()); controlp->set(col4.getValue());
break; break;
case TYPE_COL3: case TYPE_COL3:
controlp->set(floaterp->childGetValue("color_swatch")); controlp->set(getChild<LLUICtrl>("val_color_swatch")->getValue());
//col3.mV[VRED] = (F32)floaterp->childGetValue("val_spinner_1").asC(); //col3.mV[VRED] = (F32)floaterp->getChild<LLUICtrl>("val_spinner_1")->getValue().asC();
//col3.mV[VGREEN] = (F32)floaterp->childGetValue("val_spinner_2").asReal(); //col3.mV[VGREEN] = (F32)floaterp->getChild<LLUICtrl>("val_spinner_2")->getValue().asReal();
//col3.mV[VBLUE] = (F32)floaterp->childGetValue("val_spinner_3").asReal(); //col3.mV[VBLUE] = (F32)floaterp->getChild<LLUICtrl>("val_spinner_3")->getValue().asReal();
//controlp->set(col3.getValue()); //controlp->set(col3.getValue());
break; break;
case TYPE_COL4U: case TYPE_COL4U:
col3.setValue(floaterp->childGetValue("color_swatch")); col3.setValue(getChild<LLUICtrl>("val_color_swatch")->getValue());
col4U.setVecScaleClamp(col3); col4U.setVecScaleClamp(col3);
col4U.mV[VALPHA] = floaterp->childGetValue("val_spinner_4").asInteger(); col4U.mV[VALPHA] = getChild<LLUICtrl>("val_spinner_4")->getValue().asInteger();
controlp->set(col4U.getValue()); controlp->set(col4U.getValue());
break; break;
default: default:
@@ -212,17 +184,16 @@ void LLFloaterSettingsDebug::onCommitSettings(LLUICtrl* ctrl, void* user_data)
} }
// static // static
void LLFloaterSettingsDebug::onClickDefault(void* user_data) void LLFloaterSettingsDebug::onClickDefault()
{ {
LLFloaterSettingsDebug* floaterp = (LLFloaterSettingsDebug*)user_data; LLComboBox* settings_combo = getChild<LLComboBox>("settings_combo");
LLComboBox* settings_combo = floaterp->getChild<LLComboBox>("settings_combo");
LLControlVariable* controlp = (LLControlVariable*)settings_combo->getCurrentUserdata(); LLControlVariable* controlp = (LLControlVariable*)settings_combo->getCurrentUserdata();
if (controlp) if (controlp)
{ {
controlp = controlp->getCOAActive(); controlp = controlp->getCOAActive();
controlp->resetToDefault(true); controlp->resetToDefault(true);
floaterp->updateControl(controlp); updateControl(controlp);
} }
} }
@@ -233,7 +204,7 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp)
LLSpinCtrl* spinner2 = getChild<LLSpinCtrl>("val_spinner_2"); LLSpinCtrl* spinner2 = getChild<LLSpinCtrl>("val_spinner_2");
LLSpinCtrl* spinner3 = getChild<LLSpinCtrl>("val_spinner_3"); LLSpinCtrl* spinner3 = getChild<LLSpinCtrl>("val_spinner_3");
LLSpinCtrl* spinner4 = getChild<LLSpinCtrl>("val_spinner_4"); LLSpinCtrl* spinner4 = getChild<LLSpinCtrl>("val_spinner_4");
LLColorSwatchCtrl* color_swatch = getChild<LLColorSwatchCtrl>("color_swatch"); LLColorSwatchCtrl* color_swatch = getChild<LLColorSwatchCtrl>("val_color_swatch");
if (!spinner1 || !spinner2 || !spinner3 || !spinner4 || !color_swatch) if (!spinner1 || !spinner2 || !spinner3 || !spinner4 || !color_swatch)
{ {
@@ -247,7 +218,7 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp)
spinner3->setVisible(FALSE); spinner3->setVisible(FALSE);
spinner4->setVisible(FALSE); spinner4->setVisible(FALSE);
color_swatch->setVisible(FALSE); color_swatch->setVisible(FALSE);
childSetVisible("val_text", FALSE); getChildView("val_text")->setVisible( FALSE);
mComment->setText(LLStringUtil::null); mComment->setText(LLStringUtil::null);
if (controlp) if (controlp)
@@ -282,7 +253,7 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp)
eControlType type = controlp->type(); eControlType type = controlp->type();
//hide combo box only for non booleans, otherwise this will result in the combo box closing every frame //hide combo box only for non booleans, otherwise this will result in the combo box closing every frame
childSetVisible("boolean_combo", type == TYPE_BOOLEAN); getChildView("boolean_combo")->setVisible(type == TYPE_BOOLEAN);
mComment->setText(controlp->getComment()); mComment->setText(controlp->getComment());
@@ -348,23 +319,23 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp)
} }
break; break;
case TYPE_BOOLEAN: case TYPE_BOOLEAN:
if (!childHasFocus("boolean_combo")) if (!getChild<LLUICtrl>("boolean_combo")->hasFocus())
{ {
if (sd.asBoolean()) if (sd.asBoolean())
{ {
childSetValue("boolean_combo", LLSD("true")); getChild<LLUICtrl>("boolean_combo")->setValue(LLSD("true"));
} }
else else
{ {
childSetValue("boolean_combo", LLSD("")); getChild<LLUICtrl>("boolean_combo")->setValue(LLSD(""));
} }
} }
break; break;
case TYPE_STRING: case TYPE_STRING:
childSetVisible("val_text", TRUE); getChildView("val_text")->setVisible( TRUE);
if (!childHasFocus("val_text")) if (!getChild<LLUICtrl>("val_text")->hasFocus())
{ {
childSetValue("val_text", sd); getChild<LLUICtrl>("val_text")->setValue(sd);
} }
break; break;
case TYPE_VEC3: case TYPE_VEC3:

View File

@@ -35,9 +35,10 @@
#include "llcontrol.h" #include "llcontrol.h"
#include "llfloater.h" #include "llfloater.h"
#include "lltexteditor.h"
class LLFloaterSettingsDebug : public LLFloater class LLFloaterSettingsDebug
: public LLFloater
, public LLSingleton<LLFloaterSettingsDebug>
{ {
public: public:
LLFloaterSettingsDebug(); LLFloaterSettingsDebug();
@@ -48,14 +49,12 @@ public:
void updateControl(LLControlVariable* control); void updateControl(LLControlVariable* control);
static void show(void*); void onSettingSelect(LLUICtrl* ctrl);
static void onSettingSelect(LLUICtrl* ctrl, void* user_data); void onCommitSettings();
static void onCommitSettings(LLUICtrl* ctrl, void* user_data); void onClickDefault();
static void onClickDefault(void* user_data);
protected: protected:
static LLFloaterSettingsDebug* sInstance; class LLTextEditor* mComment;
LLTextEditor* mComment;
}; };
#endif //LLFLOATERDEBUGSETTINGS_H #endif //LLFLOATERDEBUGSETTINGS_H

View File

@@ -880,7 +880,7 @@ void init_menus()
menu = new LLMenuGL(CLIENT_MENU_NAME); menu = new LLMenuGL(CLIENT_MENU_NAME);
menu->setCanTearOff(FALSE); menu->setCanTearOff(FALSE);
menu->addChild(new LLMenuItemCallGL("Debug Settings...", LLFloaterSettingsDebug::show, NULL, NULL)); menu->addChild(new LLMenuItemCallGL("Debug Settings...", handle_singleton_toggle<LLFloaterSettingsDebug>, NULL, NULL));
gLoginMenuBarView->addChild(menu); gLoginMenuBarView->addChild(menu);
menu->updateParent(LLMenuGL::sMenuContainer); menu->updateParent(LLMenuGL::sMenuContainer);
@@ -1223,7 +1223,7 @@ void init_client_menu(LLMenuGL* menu)
&menu_check_control, &menu_check_control,
(void*)"SaveMinidump")); (void*)"SaveMinidump"));
menu->addChild(new LLMenuItemCallGL("Debug Settings...", LLFloaterSettingsDebug::show, NULL, NULL)); menu->addChild(new LLMenuItemCallGL("Debug Settings...", handle_singleton_toggle<LLFloaterSettingsDebug>, NULL, NULL));
menu->addChild(new LLMenuItemCheckGL("View Admin Options", &handle_admin_override_toggle, NULL, &check_admin_override, NULL, 'V', MASK_CONTROL | MASK_ALT)); menu->addChild(new LLMenuItemCheckGL("View Admin Options", &handle_admin_override_toggle, NULL, &check_admin_override, NULL, 'V', MASK_CONTROL | MASK_ALT));
menu->addChild(new LLMenuItemCallGL("Request Admin Status", menu->addChild(new LLMenuItemCallGL("Request Admin Status",

View File

@@ -17,7 +17,7 @@
</combo_box> </combo_box>
<line_editor bottom_delta="0" height="20" name="val_text" visible="false" width="300" /> <line_editor bottom_delta="0" height="20" name="val_text" visible="false" width="300" />
<color_swatch bottom="30" can_apply_immediately="true" height="55" label="Color" <color_swatch bottom="30" can_apply_immediately="true" height="55" label="Color"
name="color_swatch" visible="true" width="37" /> name="val_color_swatch" visible="true" width="37" />
<spinner bottom_delta="25" height="20" label="x" label_width="40" max_val="10000000" <spinner bottom_delta="25" height="20" label="x" label_width="40" max_val="10000000"
name="val_spinner_1" visible="false" width="120" /> name="val_spinner_1" visible="false" width="120" />
<spinner bottom_delta="0" height="20" label="x" label_width="40" left_delta="135" <spinner bottom_delta="0" height="20" label="x" label_width="40" left_delta="135"