From 5f4091b4d2b315fcb1fd2c6aa0e880b69c7defe5 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Fri, 14 Jun 2013 03:55:40 -0500 Subject: [PATCH] Update LLFloaterTools to use commit callback registrar where convenient. --- indra/newview/llfloatertools.cpp | 233 ++++++++++-------- indra/newview/llfloatertools.h | 9 +- .../skins/default/xui/en-us/floater_tools.xml | 153 +++++++++--- 3 files changed, 255 insertions(+), 140 deletions(-) diff --git a/indra/newview/llfloatertools.cpp b/indra/newview/llfloatertools.cpp index 1cbaac1a7..5b7d59c28 100644 --- a/indra/newview/llfloatertools.cpp +++ b/indra/newview/llfloatertools.cpp @@ -103,23 +103,21 @@ const std::string PANEL_NAMES[LLFloaterTools::PANEL_COUNT] = // Local prototypes -void commit_grid_mode(LLUICtrl *ctrl, void*); -void commit_select_component(LLUICtrl *ctrl, void *data); +void commit_grid_mode(LLUICtrl *ctrl); +void commit_select_component(void *data); void click_show_more(void*); void click_popup_info(void*); void click_popup_done(void*); void click_popup_minimize(void*); -void click_popup_grab_drag(LLUICtrl *, void*); -void click_popup_grab_lift(LLUICtrl *, void*); -void click_popup_grab_spin(LLUICtrl *, void*); -void click_popup_dozer_mode(LLUICtrl *, void *user); -void commit_slider_dozer_size(LLUICtrl *, void*); -void commit_slider_dozer_force(LLUICtrl *, void*); +void commit_slider_dozer_size(LLUICtrl *); +void commit_slider_dozer_force(LLUICtrl *); void click_apply_to_selection(void*); -void commit_radio_zoom(LLUICtrl *, void*); -void commit_radio_orbit(LLUICtrl *, void*); -void commit_radio_pan(LLUICtrl *, void*); -void commit_slider_zoom(LLUICtrl *ctrl, void*); +void commit_radio_group_focus(LLUICtrl* ctrl); +void commit_radio_group_move(LLUICtrl* ctrl); +void commit_radio_group_edit(LLUICtrl* ctrl); +void commit_radio_group_land(LLUICtrl* ctrl); + +void commit_slider_zoom(LLUICtrl *ctrl); void commit_select_tool(LLUICtrl *ctrl, void *data); @@ -224,58 +222,39 @@ BOOL LLFloaterTools::postBuild() LLRect rect; mBtnFocus = getChild("button focus");//btn; - childSetAction("button focus",LLFloaterTools::setEditTool, (void*)LLToolCamera::getInstance()); mBtnMove = getChild("button move"); - childSetAction("button move",LLFloaterTools::setEditTool, (void*)LLToolGrab::getInstance()); mBtnEdit = getChild("button edit"); - childSetAction("button edit",LLFloaterTools::setEditTool, (void*)LLToolCompTranslate::getInstance()); mBtnCreate = getChild("button create"); - childSetAction("button create",LLFloaterTools::setEditTool, (void*)LLToolCompCreate::getInstance()); mBtnLand = getChild("button land" ); - childSetAction("button land",LLFloaterTools::setEditTool, (void*)LLToolSelectLand::getInstance()); mTextStatus = getChild("text status"); - childSetCommitCallback("slider zoom",commit_slider_zoom,this); mRadioZoom = getChild("radio zoom"); - childSetCommitCallback("radio zoom",commit_radio_zoom,this); mRadioOrbit = getChild("radio orbit"); - childSetCommitCallback("radio orbit",commit_radio_orbit,this); mRadioPan = getChild("radio pan"); - childSetCommitCallback("radio pan",commit_radio_pan,this); mRadioMove = getChild("radio move"); - childSetCommitCallback("radio move",click_popup_grab_drag,this); mRadioLift = getChild("radio lift"); - childSetCommitCallback("radio lift",click_popup_grab_lift,this); mRadioSpin = getChild("radio spin"); - childSetCommitCallback("radio spin",click_popup_grab_spin,NULL); mRadioPosition = getChild("radio position"); - childSetCommitCallback("radio position",commit_select_tool,NULL); mRadioRotate = getChild("radio rotate"); - childSetCommitCallback("radio rotate",commit_select_tool,NULL); mRadioStretch = getChild("radio stretch"); - childSetCommitCallback("radio stretch",commit_select_tool,NULL); mRadioSelectFace = getChild("radio select face"); - childSetCommitCallback("radio select face",commit_select_tool,NULL); mRadioAlign = getChild("radio align"); - childSetCommitCallback("radio align",commit_select_tool,NULL); + mCheckSelectIndividual = getChild("checkbox edit linked parts"); - childSetValue("checkbox edit linked parts",(BOOL)gSavedSettings.getBOOL("EditLinkedParts")); - childSetCommitCallback("checkbox edit linked parts",commit_select_component,this); + getChild("checkbox edit linked parts")->setValue((BOOL)gSavedSettings.getBOOL("EditLinkedParts")); mCheckSnapToGrid = getChild("checkbox snap to grid"); - childSetValue("checkbox snap to grid",(BOOL)gSavedSettings.getBOOL("SnapEnabled")); + getChild("checkbox snap to grid")->setValue((BOOL)gSavedSettings.getBOOL("SnapEnabled")); mBtnGridOptions = getChild("Options..."); - childSetAction("Options...",onClickGridOptions, this); mCheckStretchUniform = getChild("checkbox uniform"); - childSetValue("checkbox uniform",(BOOL)gSavedSettings.getBOOL("ScaleUniform")); + getChild("checkbox uniform")->setValue((BOOL)gSavedSettings.getBOOL("ScaleUniform")); mCheckStretchTexture = getChild("checkbox stretch textures"); - childSetValue("checkbox stretch textures",(BOOL)gSavedSettings.getBOOL("ScaleStretchTextures")); + getChild("checkbox stretch textures")->setValue((BOOL)gSavedSettings.getBOOL("ScaleStretchTextures")); mCheckLimitDrag = getChild("checkbox limit drag distance"); childSetValue("checkbox limit drag distance",(BOOL)gSavedSettings.getBOOL("LimitDragDistance")); mTextGridMode = getChild("text ruler mode"); mComboGridMode = getChild("combobox grid mode"); - childSetCommitCallback("combobox grid mode",commit_grid_mode, this); mCheckShowHighlight = getChild("checkbox show highlight"); mCheckActualRoot = getChild("checkbox actual root"); @@ -297,38 +276,28 @@ BOOL LLFloaterTools::postBuild() if ((mComboTreesGrass = findChild("trees_grass"))) childSetCommitCallback("trees_grass", onSelectTreesGrass, (void*)0); mCheckCopySelection = getChild("checkbox copy selection"); - childSetValue("checkbox copy selection",(BOOL)gSavedSettings.getBOOL("CreateToolCopySelection")); + getChild("checkbox copy selection")->setValue((BOOL)gSavedSettings.getBOOL("CreateToolCopySelection")); mCheckSticky = getChild("checkbox sticky"); - childSetValue("checkbox sticky",(BOOL)gSavedSettings.getBOOL("CreateToolKeepSelected")); + getChild("checkbox sticky")->setValue((BOOL)gSavedSettings.getBOOL("CreateToolKeepSelected")); mCheckCopyCenters = getChild("checkbox copy centers"); - childSetValue("checkbox copy centers",(BOOL)gSavedSettings.getBOOL("CreateToolCopyCenters")); + getChild("checkbox copy centers")->setValue((BOOL)gSavedSettings.getBOOL("CreateToolCopyCenters")); mCheckCopyRotates = getChild("checkbox copy rotates"); - childSetValue("checkbox copy rotates",(BOOL)gSavedSettings.getBOOL("CreateToolCopyRotates")); + getChild("checkbox copy rotates")->setValue((BOOL)gSavedSettings.getBOOL("CreateToolCopyRotates")); mRadioSelectLand = getChild("radio select land"); - childSetCommitCallback("radio select land",commit_select_tool, NULL); mRadioDozerFlatten = getChild("radio flatten"); - childSetCommitCallback("radio flatten",click_popup_dozer_mode, (void*)0); mRadioDozerRaise = getChild("radio raise"); - childSetCommitCallback("radio raise",click_popup_dozer_mode, (void*)1); mRadioDozerLower = getChild("radio lower"); - childSetCommitCallback("radio lower",click_popup_dozer_mode, (void*)2); mRadioDozerSmooth = getChild("radio smooth"); - childSetCommitCallback("radio smooth",click_popup_dozer_mode, (void*)3); mRadioDozerNoise = getChild("radio noise"); - childSetCommitCallback("radio noise",click_popup_dozer_mode, (void*)4); mRadioDozerRevert = getChild("radio revert"); - childSetCommitCallback("radio revert",click_popup_dozer_mode, (void*)5); mBtnApplyToSelection = getChild("button apply to selection"); - childSetAction("button apply to selection",click_apply_to_selection, (void*)0); mSliderDozerSize = getChild("slider brush size"); - childSetCommitCallback("slider brush size", commit_slider_dozer_size, (void*)0); - childSetValue( "slider brush size", gSavedSettings.getF32("LandBrushSize")); + getChild("slider brush size")->setValue(gSavedSettings.getF32("LandBrushSize")); mSliderDozerForce = getChild("slider force"); - childSetCommitCallback("slider force",commit_slider_dozer_force, (void*)0); // the setting stores the actual force multiplier, but the slider is logarithmic, so we convert here - childSetValue("slider force", log10(gSavedSettings.getF32("LandBrushForce"))); + getChild("slider force")->setValue(log10(gSavedSettings.getF32("LandBrushForce"))); mTab = getChild("Object Info Tabs"); if(mTab) @@ -431,6 +400,19 @@ LLFloaterTools::LLFloaterTools() factory_map["ContentsInventory"] = LLCallbackMap(createPanelContentsInventory, this);//LLPanelContents factory_map["land info panel"] = LLCallbackMap(createPanelLandInfo, this);//LLPanelLandInfo + mCommitCallbackRegistrar.add("BuildTool.setTool", boost::bind(&LLFloaterTools::setTool,this, _2)); + mCommitCallbackRegistrar.add("BuildTool.commitDozerSize", boost::bind(&commit_slider_dozer_size, _1)); + mCommitCallbackRegistrar.add("BuildTool.commitZoom", boost::bind(&commit_slider_zoom, _1)); + mCommitCallbackRegistrar.add("BuildTool.commitRadioFocus", boost::bind(&commit_radio_group_focus, _1)); + mCommitCallbackRegistrar.add("BuildTool.commitRadioMove", boost::bind(&commit_radio_group_move,_1)); + mCommitCallbackRegistrar.add("BuildTool.commitRadioEdit", boost::bind(&commit_radio_group_edit,_1)); + + mCommitCallbackRegistrar.add("BuildTool.gridMode", boost::bind(&commit_grid_mode,_1)); + mCommitCallbackRegistrar.add("BuildTool.selectComponent", boost::bind(&commit_select_component, this)); + mCommitCallbackRegistrar.add("BuildTool.gridOptions", boost::bind(&LLFloaterTools::onClickGridOptions,this)); + mCommitCallbackRegistrar.add("BuildTool.applyToSelection", boost::bind(&click_apply_to_selection, this)); + mCommitCallbackRegistrar.add("BuildTool.commitRadioLand", boost::bind(&commit_radio_group_land,_1)); + mCommitCallbackRegistrar.add("BuildTool.LandBrushForce", boost::bind(&commit_slider_dozer_force,_1)); LLUICtrlFactory::getInstance()->buildFloater(this,"floater_tools.xml",&factory_map,FALSE); } @@ -809,13 +791,13 @@ void LLFloaterTools::updatePopup(LLCoordGL center, MASK mask) if (mSliderDozerSize) { mSliderDozerSize ->setVisible( land_visible ); - childSetVisible("Bulldozer:", land_visible); - childSetVisible("Dozer Size:", land_visible); + getChildView("Bulldozer:")->setVisible( land_visible); + getChildView("Dozer Size:")->setVisible( land_visible); } if (mSliderDozerForce) { mSliderDozerForce ->setVisible( land_visible ); - childSetVisible("Strength:", land_visible); + getChildView("Strength:")->setVisible( land_visible); } childSetVisible("link_num_obj_count", !land_visible); @@ -903,66 +885,63 @@ void click_popup_done(void*) handle_reset_view(); } -void click_popup_grab_drag(LLUICtrl*, void*) +void commit_radio_group_move(LLUICtrl* ctrl) { - gGrabBtnVertical = FALSE; - gGrabBtnSpin = FALSE; + std::string selected = ctrl->getName(); + if (selected == "radio move") + { + gGrabBtnVertical = FALSE; + gGrabBtnSpin = FALSE; + } + else if (selected == "radio lift") + { + gGrabBtnVertical = TRUE; + gGrabBtnSpin = FALSE; + } + else if (selected == "radio spin") + { + gGrabBtnVertical = FALSE; + gGrabBtnSpin = TRUE; + } } -void click_popup_grab_lift(LLUICtrl*, void*) +void commit_radio_group_focus(LLUICtrl* ctrl) { - gGrabBtnVertical = TRUE; - gGrabBtnSpin = FALSE; + std::string selected = ctrl->getName(); + if (selected == "radio zoom") + { + gCameraBtnZoom = TRUE; + gCameraBtnOrbit = FALSE; + gCameraBtnPan = FALSE; + } + else if (selected == "radio orbit") + { + gCameraBtnZoom = FALSE; + gCameraBtnOrbit = TRUE; + gCameraBtnPan = FALSE; + } + else if (selected == "radio pan") + { + gCameraBtnZoom = FALSE; + gCameraBtnOrbit = FALSE; + gCameraBtnPan = TRUE; + } } -void click_popup_grab_spin(LLUICtrl*, void*) -{ - gGrabBtnVertical = FALSE; - gGrabBtnSpin = TRUE; -} - -void commit_radio_zoom(LLUICtrl *, void*) -{ - gCameraBtnZoom = TRUE; - gCameraBtnOrbit = FALSE; - gCameraBtnPan = FALSE; -} - -void commit_radio_orbit(LLUICtrl *, void*) -{ - gCameraBtnZoom = FALSE; - gCameraBtnOrbit = TRUE; - gCameraBtnPan = FALSE; -} - -void commit_radio_pan(LLUICtrl *, void*) -{ - gCameraBtnZoom = FALSE; - gCameraBtnOrbit = FALSE; - gCameraBtnPan = TRUE; -} - -void commit_slider_zoom(LLUICtrl *ctrl, void*) +void commit_slider_zoom(LLUICtrl *ctrl) { // renormalize value, since max "volume" level is 0.5 for some reason F32 zoom_level = (F32)ctrl->getValue().asReal() * 2.f; // / 0.5f; gAgentCamera.setCameraZoomFraction(zoom_level); } -void click_popup_dozer_mode(LLUICtrl *, void *user) -{ - S32 mode = (S32)(intptr_t) user; - gFloaterTools->setEditTool( LLToolBrushLand::getInstance() ); - gSavedSettings.setS32("RadioLandBrushAction", mode); -} - -void commit_slider_dozer_size(LLUICtrl *ctrl, void*) +void commit_slider_dozer_size(LLUICtrl *ctrl) { F32 size = (F32)ctrl->getValue().asReal(); gSavedSettings.setF32("LandBrushSize", size); } -void commit_slider_dozer_force(LLUICtrl *ctrl, void*) +void commit_slider_dozer_force(LLUICtrl *ctrl) { // the slider is logarithmic, so we exponentiate to get the actual force multiplier F32 dozer_force = pow(10.f, (F32)ctrl->getValue().asReal()); @@ -974,12 +953,11 @@ void click_apply_to_selection(void*) LLToolBrushLand::getInstance()->modifyLandInSelectionGlobal(); } -void commit_select_tool(LLUICtrl *ctrl, void *data) +void commit_radio_group_edit(LLUICtrl *ctrl) { S32 show_owners = gSavedSettings.getBOOL("ShowParcelOwners"); - LLCheckBoxCtrl* group = (LLCheckBoxCtrl*)ctrl; - std::string selected = group->getName(); + std::string selected = ctrl->getName(); if (selected == "radio position") { LLFloaterTools::setEditTool( LLToolCompTranslate::getInstance() ); @@ -1000,14 +978,37 @@ void commit_select_tool(LLUICtrl *ctrl, void *data) { LLFloaterTools::setEditTool( QToolAlign::getInstance() ); } - else if (selected == "radio select land") - { - LLFloaterTools::setEditTool( LLToolSelectLand::getInstance()); - } gSavedSettings.setBOOL("ShowParcelOwners", show_owners); } -void commit_select_component(LLUICtrl *ctrl, void *data) +void commit_radio_group_land(LLUICtrl* ctrl) +{ + std::string selected = ctrl->getName(); + if (selected == "radio select land") + { + LLFloaterTools::setEditTool( LLToolSelectLand::getInstance() ); + } + else + { + LLFloaterTools::setEditTool( LLToolBrushLand::getInstance() ); + S32 dozer_mode = gSavedSettings.getS32("RadioLandBrushAction"); + if (selected == "radio flatten") + dozer_mode = 0; + else if (selected == "radio raise") + dozer_mode = 1; + else if (selected == "radio lower") + dozer_mode = 2; + else if (selected == "radio smooth") + dozer_mode = 3; + else if (selected == "radio noise") + dozer_mode = 4; + else if (selected == "radio revert") + dozer_mode = 5; + gSavedSettings.setS32("RadioLandBrushAction", dozer_mode); + } +} + +void commit_select_component(void *data) { LLFloaterTools* floaterp = (LLFloaterTools*)data; @@ -1039,7 +1040,7 @@ void LLFloaterTools::setObjectType( LLPCode pcode ) gFocusMgr.setMouseCapture(NULL); } -void commit_grid_mode(LLUICtrl *ctrl, void *data) +void commit_grid_mode(LLUICtrl *ctrl) { LLComboBox* combo = (LLComboBox*)ctrl; @@ -1055,12 +1056,30 @@ void LLFloaterTools::onClickGridOptions(void* data) //floaterp->addDependentFloater(LLFloaterBuildOptions::getInstance(), FALSE); } +// static void LLFloaterTools::setEditTool(void* tool_pointer) { LLTool *tool = (LLTool *)tool_pointer; LLToolMgr::getInstance()->getCurrentToolset()->selectTool( tool ); } +void LLFloaterTools::setTool(const LLSD& user_data) +{ + std::string control_name = user_data.asString(); + if(control_name == "Focus") + LLToolMgr::getInstance()->getCurrentToolset()->selectTool((LLTool *) LLToolCamera::getInstance() ); + else if (control_name == "Move" ) + LLToolMgr::getInstance()->getCurrentToolset()->selectTool( (LLTool *)LLToolGrab::getInstance() ); + else if (control_name == "Edit" ) + LLToolMgr::getInstance()->getCurrentToolset()->selectTool( (LLTool *) LLToolCompTranslate::getInstance()); + else if (control_name == "Create" ) + LLToolMgr::getInstance()->getCurrentToolset()->selectTool( (LLTool *) LLToolCompCreate::getInstance()); + else if (control_name == "Land" ) + LLToolMgr::getInstance()->getCurrentToolset()->selectTool( (LLTool *) LLToolSelectLand::getInstance()); + else + llwarns<<" no parameter name "<setCurrentToolset(gBasicToolset); diff --git a/indra/newview/llfloatertools.h b/indra/newview/llfloatertools.h index 90cdf83eb..84e04df69 100644 --- a/indra/newview/llfloatertools.h +++ b/indra/newview/llfloatertools.h @@ -71,11 +71,11 @@ public: LLFloaterTools(); virtual ~LLFloaterTools(); - virtual void onOpen(); - virtual BOOL canClose(); - virtual void onClose(bool app_quitting); + /*virtual*/ void onOpen(); + /*virtual*/ BOOL canClose(); + /*virtual*/ void onClose(bool app_quitting); /*virtual*/ void draw(); - virtual void onFocusReceived(); + /*virtual*/ void onFocusReceived(); // call this once per frame to handle visibility, rect location, // button highlights, etc. @@ -100,6 +100,7 @@ public: void setStatusText(const std::string& text); static void setEditTool(void* data); + void setTool(const LLSD& user_data); void saveLastTool(); private: diff --git a/indra/newview/skins/default/xui/en-us/floater_tools.xml b/indra/newview/skins/default/xui/en-us/floater_tools.xml index 333a9b9bc..25405861d 100644 --- a/indra/newview/skins/default/xui/en-us/floater_tools.xml +++ b/indra/newview/skins/default/xui/en-us/floater_tools.xml @@ -11,75 +11,135 @@ image_disabled="tool_zoom.tga" image_disabled_selected="tool_zoom_active.tga" image_selected="tool_zoom_active.tga" image_unselected="tool_zoom.tga" label="" label_selected="" left="4" mouse_opaque="true" name="button focus" - tool_tip="Focus" width="32" /> + tool_tip="Focus" width="32" > + + + name="radio zoom" radio_style="true" width="114" > + + + + mouse_opaque="true" name="slider zoom" width="134" > + + + name="radio orbit" radio_style="true" width="114" > + + + mouse_opaque="true" name="radio pan" radio_style="true" width="114" > + + + name="radio move" radio_style="true" width="114" > + + + name="radio lift" radio_style="true" width="114" > + + + mouse_opaque="true" name="radio spin" radio_style="true" width="114" > + + + name="radio position" radio_style="true" width="114" > + + + name="radio rotate" radio_style="true" width="114" > + + + mouse_opaque="true" name="radio stretch" radio_style="true" width="123" > + + + name="radio select face" radio_style="true" width="114" > + + + name="radio align" radio_style="true" width="114" > + + + name="checkbox edit linked parts" width="114"> + + Reference + @@ -249,29 +314,53 @@ + name="radio select land" radio_style="true" width="114" > + + + name="radio flatten" radio_style="true" width="114" > + + + name="radio raise" radio_style="true" width="114" > + + + name="radio lower" radio_style="true" width="114" > + + + name="radio smooth" radio_style="true" width="114" > + + + name="radio noise" radio_style="true" width="114" > + + + name="radio revert" radio_style="true" width="114" > + +