From f9e900f5ac9002f5ef3b44b02ac300971288e89b Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 11 Oct 2011 17:36:23 -0700 Subject: * New floater positioning code. Better than what's checked in but not great. * Floater updates for positioning and to revert some earlier string changes. --- indra/llui/llfloater.cpp | 76 +++++++++++++++++----- indra/llui/llfloater.h | 42 +++++++++--- indra/llui/llfloaterreg.cpp | 35 +++++----- indra/newview/llappviewer.cpp | 7 +- indra/newview/llfloatercamera.cpp | 2 +- indra/newview/llfloaterpreference.cpp | 1 - indra/newview/llfloatertoybox.cpp | 2 - .../newview/skins/default/xui/en/floater_about.xml | 1 + .../skins/default/xui/en/floater_about_land.xml | 3 +- .../skins/default/xui/en/floater_activeim.xml | 2 - .../skins/default/xui/en/floater_avatar.xml | 6 +- .../skins/default/xui/en/floater_avatar_picker.xml | 1 + .../skins/default/xui/en/floater_camera.xml | 6 +- .../skins/default/xui/en/floater_chat_bar.xml | 5 +- .../skins/default/xui/en/floater_critical.xml | 2 +- .../skins/default/xui/en/floater_destinations.xml | 7 +- .../skins/default/xui/en/floater_gesture.xml | 4 +- .../skins/default/xui/en/floater_help_browser.xml | 3 +- .../skins/default/xui/en/floater_im_session.xml | 2 - .../skins/default/xui/en/floater_inventory.xml | 1 - .../xui/en/floater_inventory_item_properties.xml | 1 - .../skins/default/xui/en/floater_land_holdings.xml | 1 + indra/newview/skins/default/xui/en/floater_map.xml | 5 +- .../skins/default/xui/en/floater_media_browser.xml | 1 - .../default/xui/en/floater_media_settings.xml | 1 - .../skins/default/xui/en/floater_model_preview.xml | 2 +- .../skins/default/xui/en/floater_moveview.xml | 5 +- .../skins/default/xui/en/floater_my_appearance.xml | 3 +- .../skins/default/xui/en/floater_my_inventory.xml | 3 +- .../skins/default/xui/en/floater_my_profile.xml | 3 +- .../default/xui/en/floater_outfit_save_as.xml | 2 +- .../skins/default/xui/en/floater_people.xml | 1 + .../skins/default/xui/en/floater_places.xml | 1 + .../skins/default/xui/en/floater_postcard.xml | 1 - .../skins/default/xui/en/floater_preferences.xml | 5 +- .../default/xui/en/floater_preview_animation.xml | 1 - .../default/xui/en/floater_preview_gesture.xml | 3 +- .../default/xui/en/floater_preview_notecard.xml | 1 - .../skins/default/xui/en/floater_preview_sound.xml | 1 - .../default/xui/en/floater_preview_texture.xml | 1 - .../skins/default/xui/en/floater_script.xml | 2 - .../default/xui/en/floater_script_preview.xml | 1 - .../skins/default/xui/en/floater_script_queue.xml | 1 - .../skins/default/xui/en/floater_search.xml | 14 ++-- .../skins/default/xui/en/floater_snapshot.xml | 3 +- .../skins/default/xui/en/floater_sound_devices.xml | 2 +- .../skins/default/xui/en/floater_sys_well.xml | 2 - .../skins/default/xui/en/floater_telehub.xml | 1 - .../newview/skins/default/xui/en/floater_tools.xml | 1 + .../skins/default/xui/en/floater_toybox.xml | 4 +- .../default/xui/en/floater_voice_controls.xml | 3 +- .../skins/default/xui/en/floater_web_content.xml | 1 - .../skins/default/xui/en/floater_world_map.xml | 4 +- .../skins/default/xui/en/outfit_accordion_tab.xml | 2 +- indra/newview/skins/default/xui/en/panel_toast.xml | 1 + .../skins/default/xui/en/widgets/floater.xml | 4 +- 56 files changed, 184 insertions(+), 112 deletions(-) (limited to 'indra') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 90c41e99dc..0398c0d7eb 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -62,6 +62,17 @@ // use this to control "jumping" behavior when Ctrl-Tabbing const S32 TABBED_FLOATER_OFFSET = 0; +namespace LLInitParam +{ + void TypeValues::declareValues() + { + declare("none", LLFloaterEnums::OPEN_POSITIONING_NONE); + declare("cascading", LLFloaterEnums::OPEN_POSITIONING_CASCADING); + declare("centered", LLFloaterEnums::OPEN_POSITIONING_CENTERED); + declare("specified", LLFloaterEnums::OPEN_POSITIONING_SPECIFIED); + } +} + std::string LLFloater::sButtonNames[BUTTON_COUNT] = { "llfloater_close_btn", //BUTTON_CLOSE @@ -154,7 +165,6 @@ LLFloater::Params::Params() : title("title"), short_title("short_title"), single_instance("single_instance", false), - auto_tile("auto_tile", false), can_resize("can_resize", false), can_minimize("can_minimize", true), can_close("can_close", true), @@ -164,7 +174,7 @@ LLFloater::Params::Params() save_rect("save_rect", false), save_visibility("save_visibility", false), can_dock("can_dock", false), - open_centered("open_centered", false), + open_positioning("open_positioning", LLFloaterEnums::OPEN_POSITIONING_NONE), header_height("header_height", 0), legacy_header_height("legacy_header_height", 0), close_image("close_image"), @@ -227,7 +237,6 @@ LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p) mShortTitle(p.short_title), mSingleInstance(p.single_instance), mKey(key), - mAutoTile(p.auto_tile), mCanTearOff(p.can_tear_off), mCanMinimize(p.can_minimize), mCanClose(p.can_close), @@ -831,7 +840,7 @@ LLMultiFloater* LLFloater::getHost() return (LLMultiFloater*)mHostHandle.get(); } -void LLFloater::applySavedVariables() +void LLFloater::applySavedVariables() { applyRectControl(); applyDockState(); @@ -839,13 +848,7 @@ void LLFloater::applySavedVariables() void LLFloater::applyRectControl() { - // first, center on screen if requested - if (mOpenCentered) - { - center(); - } - - // override center if we have saved rect control + // If we have a saved rect, use it if (mRectControl.size() > 1) { const LLRect& rect = getControlGroup()->getRect(mRectControl); @@ -867,7 +870,50 @@ void LLFloater::applyDockState() bool dockState = getControlGroup()->getBOOL(mDocStateControl); setDocked(dockState); } +} + +void LLFloater::applyPositioning() +{ + // Otherwise position according to the positioning code + switch (mOpenPositioning) + { + case LLFloaterEnums::OPEN_POSITIONING_CENTERED: + center(); + break; + + case LLFloaterEnums::OPEN_POSITIONING_SPECIFIED: + { + // Translate relative to snap rect + LLRect r = getRect(); + r.mBottom = getSnapRect().getHeight() - r.getHeight() - r.mBottom; + setOrigin(r.mLeft, r.mBottom); + translateIntoRect(getSnapRect(), FALSE); + } + break; + case LLFloaterEnums::OPEN_POSITIONING_CASCADING: + { + static const U32 CASCADING_FLOATER_HOFFSET = 25; + static const U32 CASCADING_FLOATER_VOFFSET = 25; + static const S32 CASCADING_FLOATER_LIMIT = 15; + static S32 cascading_floater_count = 1; + const S32 top = CASCADING_FLOATER_VOFFSET * cascading_floater_count; + const S32 left = CASCADING_FLOATER_HOFFSET * cascading_floater_count; + setOrigin(left, top); + translateIntoRect(getSnapRect(), FALSE); + + if (++cascading_floater_count > CASCADING_FLOATER_LIMIT) + { + cascading_floater_count = 1; + } + } + break; + + case LLFloaterEnums::OPEN_POSITIONING_NONE: + default: + // Do nothing + break; + } } void LLFloater::applyTitle() @@ -2784,7 +2830,6 @@ void LLFloater::setInstanceName(const std::string& name) { mDocStateControl = LLFloaterReg::declareDockStateControl(ctrl_name); } - } } @@ -2846,9 +2891,9 @@ void LLFloater::initFromParams(const LLFloater::Params& p) mHeaderHeight = p.header_height; mLegacyHeaderHeight = p.legacy_header_height; mSingleInstance = p.single_instance; - mAutoTile = p.auto_tile; - mOpenCentered = p.open_centered; + mOpenPositioning = p.open_positioning; + /* if (p.save_rect && mRectControl.empty()) { mRectControl = "t"; // flag to build mRectControl name once mInstanceName is set @@ -2856,7 +2901,7 @@ void LLFloater::initFromParams(const LLFloater::Params& p) if (p.save_visibility) { mVisibilityControl = "t"; // flag to build mVisibilityControl name once mInstanceName is set - } + }*/ if(p.save_dock_state) { @@ -3008,6 +3053,7 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::str llerrs << "Failed to construct floater " << getName() << llendl; } + applyPositioning(); applyRectControl(); // If we have a saved rect control, apply it gFloaterView->adjustToFitScreen(this, FALSE); // Floaters loaded from XML should all fit on screen diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index af9665e599..b404306e94 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -59,11 +59,35 @@ const BOOL CLOSE_NO = FALSE; const BOOL ADJUST_VERTICAL_YES = TRUE; const BOOL ADJUST_VERTICAL_NO = FALSE; +namespace LLFloaterEnums +{ + enum EOpenPositioning + { + OPEN_POSITIONING_NONE, + OPEN_POSITIONING_CASCADING, + OPEN_POSITIONING_CENTERED, + OPEN_POSITIONING_SPECIFIED, + + OPEN_POSITIONING_COUNT + }; +} + +namespace LLInitParam +{ + template<> + struct TypeValues : public TypeValuesHelper + { + static void declareValues(); + }; +} + + class LLFloater : public LLPanel { -friend class LLFloaterView; -friend class LLFloaterReg; -friend class LLMultiFloater; + friend class LLFloaterView; + friend class LLFloaterReg; + friend class LLMultiFloater; + public: struct KeyCompare { @@ -95,7 +119,6 @@ public: short_title; Optional single_instance, - auto_tile, can_resize, can_minimize, can_close, @@ -104,8 +127,10 @@ public: save_rect, save_visibility, save_dock_state, - can_dock, - open_centered; + can_dock; + + Optional open_positioning; + Optional header_height, legacy_header_height; // HACK see initFromXML() @@ -297,6 +322,7 @@ protected: virtual void applyRectControl(); void applyDockState(); + void applyPositioning(); void storeRectControl(); void storeVisibilityControl(); void storeDockStateControl(); @@ -378,14 +404,14 @@ private: BOOL mSingleInstance; // TRUE if there is only ever one instance of the floater std::string mInstanceName; // Store the instance name so we can remove ourselves from the list - BOOL mAutoTile; // TRUE if placement of new instances tiles BOOL mCanTearOff; BOOL mCanMinimize; BOOL mCanClose; BOOL mDragOnLeft; BOOL mResizable; - bool mOpenCentered; + + LLFloaterEnums::EOpenPositioning mOpenPositioning; S32 mMinWidth; S32 mMinHeight; diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index ae06eb74ac..058223abbd 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -107,7 +107,6 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) if (!groupname.empty()) { instance_list_t& list = sInstanceMap[groupname]; - int index = list.size(); res = build_func(key); if (!res) @@ -121,27 +120,18 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) llwarns << "Failed to build floater type: '" << name << "'." << llendl; return NULL; } - + // Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe if (res->mKey.isUndefined()) { - res->mKey = key; + res->mKey = key; } res->setInstanceName(name); res->applySavedVariables(); // Can't apply rect and dock state until setting instance name - if (res->mAutoTile && !res->getHost() && index > 0) - { - LLFloater* last_floater = getLastFloaterInGroup(groupname); - if (last_floater) - { - res->stackWith(*last_floater); - gFloaterView->adjustToFitScreen(res, true); - } - } - else - { - gFloaterView->adjustToFitScreen(res, false); - } + + // apply list.size() and possibly stackWith(getLastFloaterInGroup(groupname)) + gFloaterView->adjustToFitScreen(res, false); + list.push_back(res); } } @@ -477,16 +467,21 @@ void LLFloaterReg::toggleToolbarFloaterInstance(const LLSD& sdname) std::string name = sdname.asString(); parse_name_key(name, key); - LLFloater* instance = findInstance(name, key); + LLFloater* instance = getInstance(name, key); - if (LLFloater::isMinimized(instance)) + if (!instance) + { + lldebugs << "Unable to get instance of floater '" << name << "'" << llendl; + } + else if (instance->isMinimized()) { instance->setMinimized(FALSE); instance->setFocus(TRUE); } - else if (!LLFloater::isShown(instance)) + else if (!instance->isShown()) { - showInstance(name, key, TRUE); + instance->openFloater(key); + instance->setFocus(TRUE); } else if (!instance->hasFocus() && !instance->getIsChrome()) { diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 5077a0a596..2a9e411762 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -4293,12 +4293,15 @@ void LLAppViewer::idle() return; } - gViewerWindow->updateUI(); + if (!quitRequested()) + { + gViewerWindow->updateUI(); + } /////////////////////////////////////// // Agent and camera movement // - LLCoordGL current_mouse = gViewerWindow->getCurrentMouse(); + LLCoordGL current_mouse = gViewerWindow->getCurrentMouse(); { // After agent and camera moved, figure out if we need to diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp index b4658b1edb..aa78bc4f29 100644 --- a/indra/newview/llfloatercamera.cpp +++ b/indra/newview/llfloatercamera.cpp @@ -369,7 +369,7 @@ BOOL LLFloaterCamera::postBuild() // ensure that appearance mode is handled while building. See EXT-7796. handleAvatarEditingAppearance(sAppearanceEditing); - return TRUE; + return LLFloater::postBuild(); } void LLFloaterCamera::fillFlatlistFromPanel (LLFlatListView* list, LLPanel* panel) diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 8412d37810..5fdeb46daa 100755 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -1913,7 +1913,6 @@ BOOL LLFloaterPreferenceProxy::postBuild() getChild("socks5_password")->setValue(socks_cred->getAuthenticator()["creds"].asString()); } - center(); return TRUE; } diff --git a/indra/newview/llfloatertoybox.cpp b/indra/newview/llfloatertoybox.cpp index fa60022911..84881655f8 100644 --- a/indra/newview/llfloatertoybox.cpp +++ b/indra/newview/llfloatertoybox.cpp @@ -58,8 +58,6 @@ bool compare_localized_command_labels(LLCommand * cmd1, LLCommand * cmd2) BOOL LLFloaterToybox::postBuild() { - center(); - mBtnRestoreDefaults = getChild("btn_restore_defaults"); mToolBar = getChild("toybox_toolbar"); mToolBar->setStartDragCallback(boost::bind(LLToolBarView::startDragTool,_1,_2,_3)); diff --git a/indra/newview/skins/default/xui/en/floater_about.xml b/indra/newview/skins/default/xui/en/floater_about.xml index 2580c06344..36af475824 100644 --- a/indra/newview/skins/default/xui/en/floater_about.xml +++ b/indra/newview/skins/default/xui/en/floater_about.xml @@ -1,5 +1,6 @@ diff --git a/indra/newview/skins/default/xui/en/floater_activeim.xml b/indra/newview/skins/default/xui/en/floater_activeim.xml index 96fe0aa70c..670c528f08 100644 --- a/indra/newview/skins/default/xui/en/floater_activeim.xml +++ b/indra/newview/skins/default/xui/en/floater_activeim.xml @@ -4,8 +4,6 @@ name="floater_activeim" help_topic="floater_activeim" title="ACTIVE IM" - top="26" - left="0" height="22" width="320" follows="right|bottom" diff --git a/indra/newview/skins/default/xui/en/floater_avatar.xml b/indra/newview/skins/default/xui/en/floater_avatar.xml index 666aa2d164..6e5c4ada48 100644 --- a/indra/newview/skins/default/xui/en/floater_avatar.xml +++ b/indra/newview/skins/default/xui/en/floater_avatar.xml @@ -12,12 +12,12 @@ single_instance="true" help_topic="avatar" save_rect="true" - title="Avatar Picker" - width="445"> + title="AVATAR PICKER" + width="635"> diff --git a/indra/newview/skins/default/xui/en/floater_avatar_picker.xml b/indra/newview/skins/default/xui/en/floater_avatar_picker.xml index a11946d352..cbbbeb6094 100644 --- a/indra/newview/skins/default/xui/en/floater_avatar_picker.xml +++ b/indra/newview/skins/default/xui/en/floater_avatar_picker.xml @@ -1,5 +1,6 @@ diff --git a/indra/newview/skins/default/xui/en/floater_chat_bar.xml b/indra/newview/skins/default/xui/en/floater_chat_bar.xml index 6977e29b78..924e4bc11e 100644 --- a/indra/newview/skins/default/xui/en/floater_chat_bar.xml +++ b/indra/newview/skins/default/xui/en/floater_chat_bar.xml @@ -1,10 +1,13 @@