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

View File

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

View File

@@ -880,7 +880,7 @@ void init_menus()
menu = new LLMenuGL(CLIENT_MENU_NAME);
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);
menu->updateParent(LLMenuGL::sMenuContainer);
@@ -1223,7 +1223,7 @@ void init_client_menu(LLMenuGL* menu)
&menu_check_control,
(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 LLMenuItemCallGL("Request Admin Status",

View File

@@ -17,7 +17,7 @@
</combo_box>
<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"
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"
name="val_spinner_1" visible="false" width="120" />
<spinner bottom_delta="0" height="20" label="x" label_width="40" left_delta="135"