diff options
author | Leyla Farazha <leyla@lindenlab.com> | 2010-09-16 12:02:24 -0700 |
---|---|---|
committer | Leyla Farazha <leyla@lindenlab.com> | 2010-09-16 12:02:24 -0700 |
commit | 60db8577a90be3ea3d4a06ab06232802be953286 (patch) | |
tree | 0fcedbdf478b3f518a0d5dc69b7d234406355d75 /indra/llui | |
parent | ae623c8068145f968f09ccf9bbdd90e993ca4283 (diff) | |
parent | 1dbcc3fff79b55038178e493df0cc0c3a4d66221 (diff) |
Merge
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llbutton.cpp | 4 | ||||
-rw-r--r-- | indra/llui/llfloater.cpp | 56 | ||||
-rw-r--r-- | indra/llui/llfloater.h | 5 | ||||
-rw-r--r-- | indra/llui/llfloaterreg.cpp | 16 | ||||
-rw-r--r-- | indra/llui/lllayoutstack.cpp | 16 | ||||
-rw-r--r-- | indra/llui/lllayoutstack.h | 5 | ||||
-rw-r--r-- | indra/llui/lllineeditor.h | 14 |
7 files changed, 91 insertions, 25 deletions
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index f0f34ebd4f..d51276bf26 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -1117,7 +1117,7 @@ void LLButton::setFloaterToggle(LLUICtrl* ctrl, const LLSD& sdname) // Get the visibility control name for the floater std::string vis_control_name = LLFloaterReg::declareVisibilityControl(sdname.asString()); // Set the button control value (toggle state) to the floater visibility control (Sets the value as well) - button->setControlVariable(LLUI::sSettingGroups["floater"]->getControl(vis_control_name)); + button->setControlVariable(LLFloater::getControlGroup()->getControl(vis_control_name)); // Set the clicked callback to toggle the floater button->setClickedCallback(boost::bind(&LLFloaterReg::toggleFloaterInstance, sdname)); } @@ -1131,7 +1131,7 @@ void LLButton::setDockableFloaterToggle(LLUICtrl* ctrl, const LLSD& sdname) // Get the visibility control name for the floater std::string vis_control_name = LLFloaterReg::declareVisibilityControl(sdname.asString()); // Set the button control value (toggle state) to the floater visibility control (Sets the value as well) - button->setControlVariable(LLUI::sSettingGroups["floater"]->getControl(vis_control_name)); + button->setControlVariable(LLFloater::getControlGroup()->getControl(vis_control_name)); // Set the clicked callback to toggle the floater button->setClickedCallback(boost::bind(&LLDockableFloater::toggleInstance, sdname)); } diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index e1203971ea..c0942cf3c7 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -499,7 +499,7 @@ void LLFloater::storeRectControl() { if( mRectControl.size() > 1 ) { - LLUI::sSettingGroups["floater"]->setRect( mRectControl, getRect() ); + getControlGroup()->setRect( mRectControl, getRect() ); } } @@ -507,7 +507,7 @@ void LLFloater::storeVisibilityControl() { if( !sQuitting && mVisibilityControl.size() > 1 ) { - LLUI::sSettingGroups["floater"]->setBOOL( mVisibilityControl, getVisible() ); + getControlGroup()->setBOOL( mVisibilityControl, getVisible() ); } } @@ -515,10 +515,47 @@ void LLFloater::storeDockStateControl() { if( !sQuitting && mDocStateControl.size() > 1 ) { - LLUI::sSettingGroups["floater"]->setBOOL( mDocStateControl, isDocked() ); + getControlGroup()->setBOOL( mDocStateControl, isDocked() ); } } +LLRect LLFloater::getSavedRect() const +{ + LLRect rect; + + if (mRectControl.size() > 1) + { + rect = getControlGroup()->getRect(mRectControl); + } + + return rect; +} + +bool LLFloater::hasSavedRect() const +{ + return !getSavedRect().isEmpty(); +} + +// static +std::string LLFloater::getControlName(const std::string& name, const LLSD& key) +{ + std::string ctrl_name = name; + + // Add the key to the control name if appropriate. + if (key.isString() && !key.asString().empty()) + { + ctrl_name += "_" + key.asString(); + } + + return ctrl_name; +} + +// static +LLControlGroup* LLFloater::getControlGroup() +{ + // Floater size, position, visibility, etc are saved in per-account settings. + return LLUI::sSettingGroups["account"]; +} void LLFloater::setVisible( BOOL visible ) { @@ -775,7 +812,7 @@ void LLFloater::applyRectControl() // override center if we have saved rect control if (mRectControl.size() > 1) { - const LLRect& rect = LLUI::sSettingGroups["floater"]->getRect(mRectControl); + const LLRect& rect = getControlGroup()->getRect(mRectControl); if (rect.getWidth() > 0 && rect.getHeight() > 0) { translate( rect.mLeft - getRect().mLeft, rect.mBottom - getRect().mBottom); @@ -791,7 +828,7 @@ void LLFloater::applyDockState() { if (mDocStateControl.size() > 1) { - bool dockState = LLUI::sSettingGroups["floater"]->getBOOL(mDocStateControl); + bool dockState = getControlGroup()->getBOOL(mDocStateControl); setDocked(dockState); } @@ -1954,6 +1991,7 @@ LLFloaterView::LLFloaterView (const Params& p) : LLUICtrl (p), mFocusCycleMode(FALSE), + mMinimizePositionVOffset(0), mSnapOffsetBottom(0), mSnapOffsetRight(0) { @@ -2664,18 +2702,20 @@ void LLFloater::setInstanceName(const std::string& name) mInstanceName = name; if (!mInstanceName.empty()) { + std::string ctrl_name = getControlName(mInstanceName, mKey); + // save_rect and save_visibility only apply to registered floaters if (!mRectControl.empty()) { - mRectControl = LLFloaterReg::declareRectControl(mInstanceName); + mRectControl = LLFloaterReg::declareRectControl(ctrl_name); } if (!mVisibilityControl.empty()) { - mVisibilityControl = LLFloaterReg::declareVisibilityControl(mInstanceName); + mVisibilityControl = LLFloaterReg::declareVisibilityControl(ctrl_name); } if(!mDocStateControl.empty()) { - mDocStateControl = LLFloaterReg::declareDockStateControl(mInstanceName); + mDocStateControl = LLFloaterReg::declareDockStateControl(ctrl_name); } } diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 5e482cbac3..5ecf515cf9 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -203,6 +203,11 @@ public: BOOL isResizable() const { return mResizable; } void setResizeLimits( S32 min_width, S32 min_height ); void getResizeLimits( S32* min_width, S32* min_height ) { *min_width = mMinWidth; *min_height = mMinHeight; } + LLRect getSavedRect() const; + bool hasSavedRect() const; + + static std::string getControlName(const std::string& name, const LLSD& key); + static LLControlGroup* getControlGroup(); bool isMinimizeable() const{ return mCanMinimize; } bool isCloseable() const{ return mCanClose; } diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index ccffe98c96..4720ebb822 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -284,9 +284,9 @@ void LLFloaterReg::showInitialVisibleInstances() { const std::string& name = iter->first; std::string controlname = getVisibilityControlName(name); - if (LLUI::sSettingGroups["floater"]->controlExists(controlname)) + if (LLFloater::getControlGroup()->controlExists(controlname)) { - BOOL isvis = LLUI::sSettingGroups["floater"]->getBOOL(controlname); + BOOL isvis = LLFloater::getControlGroup()->getBOOL(controlname); if (isvis) { showInstance(name, LLSD()); // keyed floaters shouldn't set save_vis to true @@ -340,7 +340,7 @@ std::string LLFloaterReg::getRectControlName(const std::string& name) std::string LLFloaterReg::declareRectControl(const std::string& name) { std::string controlname = getRectControlName(name); - LLUI::sSettingGroups["floater"]->declareRect(controlname, LLRect(), + LLFloater::getControlGroup()->declareRect(controlname, LLRect(), llformat("Window Position and Size for %s", name.c_str()), TRUE); return controlname; @@ -358,7 +358,7 @@ std::string LLFloaterReg::getVisibilityControlName(const std::string& name) std::string LLFloaterReg::declareVisibilityControl(const std::string& name) { std::string controlname = getVisibilityControlName(name); - LLUI::sSettingGroups["floater"]->declareBOOL(controlname, FALSE, + LLFloater::getControlGroup()->declareBOOL(controlname, FALSE, llformat("Window Visibility for %s", name.c_str()), TRUE); return controlname; @@ -368,7 +368,7 @@ std::string LLFloaterReg::declareVisibilityControl(const std::string& name) std::string LLFloaterReg::declareDockStateControl(const std::string& name) { std::string controlname = getDockStateControlName(name); - LLUI::sSettingGroups["floater"]->declareBOOL(controlname, TRUE, + LLFloater::getControlGroup()->declareBOOL(controlname, TRUE, llformat("Window Docking state for %s", name.c_str()), TRUE); return controlname; @@ -391,11 +391,11 @@ void LLFloaterReg::registerControlVariables() for (build_map_t::iterator iter = sBuildMap.begin(); iter != sBuildMap.end(); ++iter) { const std::string& name = iter->first; - if (LLUI::sSettingGroups["floater"]->controlExists(getRectControlName(name))) + if (LLFloater::getControlGroup()->controlExists(getRectControlName(name))) { declareRectControl(name); } - if (LLUI::sSettingGroups["floater"]->controlExists(getVisibilityControlName(name))) + if (LLFloater::getControlGroup()->controlExists(getVisibilityControlName(name))) { declareVisibilityControl(name); } @@ -419,7 +419,7 @@ void LLFloaterReg::initUICtrlToFloaterVisibilityControl(LLUICtrl* ctrl, const LL // Get the visibility control name for the floater std::string vis_control_name = LLFloaterReg::declareVisibilityControl(sdname.asString()); // Set the control value to the floater visibility control (Sets the value as well) - ctrl->setControlVariable(LLUI::sSettingGroups["floater"]->getControl(vis_control_name)); + ctrl->setControlVariable(LLFloater::getControlGroup()->getControl(vis_control_name)); } // callback args may use "floatername.key" format diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index 5cc9add1e2..0ff7557ead 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -368,6 +368,22 @@ S32 LLLayoutStack::getDefaultWidth(S32 cur_width) return cur_width; } +void LLLayoutStack::movePanel(LLPanel* panel_to_move, LLPanel* target_panel, bool move_to_front) +{ + LayoutPanel* embedded_panel_to_move = findEmbeddedPanel(panel_to_move); + LayoutPanel* embedded_target_panel = move_to_front ? *mPanels.begin() : findEmbeddedPanel(target_panel); + + if (!embedded_panel_to_move || !embedded_target_panel || embedded_panel_to_move == embedded_target_panel) + { + llwarns << "One of the panels was not found in stack or NULL was passed instead of valid panel" << llendl; + return; + } + e_panel_list_t::iterator it = std::find(mPanels.begin(), mPanels.end(), embedded_panel_to_move); + mPanels.erase(it); + it = move_to_front ? mPanels.begin() : std::find(mPanels.begin(), mPanels.end(), embedded_target_panel); + mPanels.insert(it, embedded_panel_to_move); +} + void LLLayoutStack::addPanel(LLPanel* panel, S32 min_width, S32 min_height, S32 max_width, S32 max_height, BOOL auto_resize, BOOL user_resize, EAnimate animate, S32 index) { // panel starts off invisible (collapsed) diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h index cd59ee3966..6fcc8e2ac3 100644 --- a/indra/llui/lllayoutstack.h +++ b/indra/llui/lllayoutstack.h @@ -72,6 +72,11 @@ public: void removePanel(LLPanel* panel); void collapsePanel(LLPanel* panel, BOOL collapsed = TRUE); S32 getNumPanels() { return mPanels.size(); } + /** + * Moves panel_to_move before target_panel inside layout stack (both panels should already be there). + * If move_to_front is true target_panel is ignored and panel_to_move is moved to the beginning of mPanels + */ + void movePanel(LLPanel* panel_to_move, LLPanel* target_panel, bool move_to_front = false); void updatePanelAutoResize(const std::string& panel_name, BOOL auto_resize); void setPanelUserResize(const std::string& panel_name, BOOL user_resize); diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index b988bc412e..a1aa6b71c6 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -59,13 +59,13 @@ public: typedef boost::function<void (LLLineEditor* caller)> keystroke_callback_t; - struct MaxLength : public LLInitParam::Choice<MaxLength>
- {
- Alternative<S32> bytes, chars;
-
- MaxLength() : bytes("max_length_bytes", 254),
- chars("max_length_chars", 0)
- {}
+ struct MaxLength : public LLInitParam::Choice<MaxLength> + { + Alternative<S32> bytes, chars; + + MaxLength() : bytes("max_length_bytes", 254), + chars("max_length_chars", 0) + {} }; struct Params : public LLInitParam::Block<Params, LLUICtrl::Params> |