From 347562844dc2be598f39138a39eaacaff6b4e323 Mon Sep 17 00:00:00 2001 From: James Cook Date: Mon, 23 Nov 2009 14:23:51 -0800 Subject: Initial implementation of parcel property icons and maturity string on nav bar Added new LLAgentUI location format, renamed unclear old one Renamed ShowCoordinatesOption to NavBarShowCoordinates Extended LLLocationInputCtrl to show icons. Reviewed with Rick --- indra/newview/lllocationinputctrl.cpp | 112 ++++++++++++++++++++++++++++------ 1 file changed, 94 insertions(+), 18 deletions(-) (limited to 'indra/newview/lllocationinputctrl.cpp') diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp index 7e35cfa04c..be96d7b43a 100644 --- a/indra/newview/lllocationinputctrl.cpp +++ b/indra/newview/lllocationinputctrl.cpp @@ -157,15 +157,21 @@ LLLocationInputCtrl::Params::Params() add_landmark_image_disabled("add_landmark_image_disabled"), add_landmark_image_hover("add_landmark_image_hover"), add_landmark_image_selected("add_landmark_image_selected"), + icon_hpad("icon_hpad", 0), add_landmark_button("add_landmark_button"), - add_landmark_hpad("add_landmark_hpad", 0), - info_button("info_button") + info_button("info_button"), + voice_icon("voice_icon"), + fly_icon("fly_icon"), + push_icon("push_icon"), + build_icon("build_icon"), + scripts_icon("scripts_icon"), + damage_icon("damage_icon") { } LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p) : LLComboBox(p), - mAddLandmarkHPad(p.add_landmark_hpad), + mIconHPad(p.icon_hpad), mInfoBtn(NULL), mLocationContextMenu(NULL), mAddLandmarkBtn(NULL), @@ -230,6 +236,32 @@ LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p) mAddLandmarkBtn = LLUICtrlFactory::create(al_params); enableAddLandmarkButton(true); addChild(mAddLandmarkBtn); + + // Parcel property icons + LLIconCtrl::Params voice_icon = p.voice_icon; + mParcelIcon[VOICE_ICON] = LLUICtrlFactory::create(voice_icon); + addChild(mParcelIcon[VOICE_ICON]); + + LLIconCtrl::Params fly_icon = p.fly_icon; + mParcelIcon[FLY_ICON] = LLUICtrlFactory::create(fly_icon); + addChild(mParcelIcon[FLY_ICON]); + + LLIconCtrl::Params push_icon = p.push_icon; + mParcelIcon[PUSH_ICON] = LLUICtrlFactory::create(push_icon); + addChild(mParcelIcon[PUSH_ICON]); + + LLIconCtrl::Params build_icon = p.build_icon; + mParcelIcon[BUILD_ICON] = LLUICtrlFactory::create(build_icon); + addChild(mParcelIcon[BUILD_ICON]); + + LLIconCtrl::Params scripts_icon = p.scripts_icon; + mParcelIcon[SCRIPTS_ICON] = LLUICtrlFactory::create(scripts_icon); + addChild(mParcelIcon[SCRIPTS_ICON]); + + LLIconCtrl::Params damage_icon = p.damage_icon; + mParcelIcon[DAMAGE_ICON] = LLUICtrlFactory::create(damage_icon); + addChild(mParcelIcon[DAMAGE_ICON]); + // TODO: health number? // Register callbacks and load the location field context menu (NB: the order matters). LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Navbar.Action", boost::bind(&LLLocationInputCtrl::onLocationContextMenuItemClicked, this, _2)); @@ -410,9 +442,10 @@ void LLLocationInputCtrl::onFocusLost() mTextEntry->deselect(); } } -void LLLocationInputCtrl::draw(){ - - if(!hasFocus() && gSavedSettings.getBOOL("ShowCoordinatesOption")){ + +void LLLocationInputCtrl::draw() +{ + if(!hasFocus() && gSavedSettings.getBOOL("NavBarShowCoordinates")){ refreshLocation(); } LLComboBox::draw(); @@ -532,6 +565,7 @@ void LLLocationInputCtrl::onTextEditorRightClicked(S32 x, S32 y, MASK mask) void LLLocationInputCtrl::refresh() { refreshLocation(); // update location string + refreshParcelIcons(); updateAddLandmarkButton(); // indicate whether current parcel has been landmarked } @@ -548,13 +582,57 @@ void LLLocationInputCtrl::refreshLocation() // Update location field. std::string location_name; - LLAgentUI::ELocationFormat format = (gSavedSettings.getBOOL("ShowCoordinatesOption") ? - LLAgentUI::LOCATION_FORMAT_WITHOUT_SIM: LLAgentUI::LOCATION_FORMAT_NORMAL); + LLAgentUI::ELocationFormat format = + (gSavedSettings.getBOOL("NavBarShowCoordinates") + ? LLAgentUI::LOCATION_FORMAT_FULL + : LLAgentUI::LOCATION_FORMAT_NO_COORDS); - if (!LLAgentUI::buildLocationString(location_name, format)) location_name = "Unknown"; + if (!LLAgentUI::buildLocationString(location_name, format)) + { + location_name = "???"; + } setText(location_name); } +void LLLocationInputCtrl::refreshParcelIcons() +{ + LLViewerParcelMgr* vpm = LLViewerParcelMgr::getInstance(); + // *TODO buy + //bool allow_buy = vpm->canAgentBuyParcel( vpm->getAgentParcel(), false); + bool allow_voice = vpm->allowAgentVoice(); + bool allow_fly = vpm->allowAgentFly(); + bool allow_push = vpm->allowAgentPush(); + bool allow_build = vpm->allowAgentBuild(); + bool allow_scripts = vpm->allowAgentScripts(); + bool allow_damage = vpm->allowAgentDamage(); + + // Most icons are "block this ability" + mParcelIcon[VOICE_ICON]->setVisible( !allow_voice ); + mParcelIcon[FLY_ICON]->setVisible( !allow_fly ); + mParcelIcon[PUSH_ICON]->setVisible( !allow_push ); + mParcelIcon[BUILD_ICON]->setVisible( !allow_build ); + mParcelIcon[SCRIPTS_ICON]->setVisible( !allow_scripts ); + mParcelIcon[DAMAGE_ICON]->setVisible( allow_damage ); + // *TODO damage meter + + // Slide the parcel icons rect from right to left, adjusting rectangles of + // visible icons. Assumes all icon rects are the same. + LLRect icon_rect = mParcelIcon[0]->getRect(); + S32 icon_width = icon_rect.getWidth(); + icon_rect.mRight = mAddLandmarkBtn->getRect().mLeft - mIconHPad; + icon_rect.mLeft = icon_rect.mRight - icon_width; + + for (S32 i = 0; i < ICON_COUNT; ++i) + { + if (mParcelIcon[i]->getVisible()) + { + mParcelIcon[i]->setRect( icon_rect ); + icon_rect.translate( -icon_width - mIconHPad, 0); + } + } + // *TODO: health meter +} + void LLLocationInputCtrl::rebuildLocationHistory(std::string filter) { LLLocationHistory::location_list_t filtered_items; @@ -651,13 +729,11 @@ void LLLocationInputCtrl::updateWidgetlayout() mInfoBtn->setRect(info_btn_rect); // "Add Landmark" button - { - LLRect al_btn_rect = mAddLandmarkBtn->getRect(); - al_btn_rect.translate( - hist_btn_rect.mLeft - mAddLandmarkHPad - al_btn_rect.getWidth(), - (rect.getHeight() - al_btn_rect.getHeight()) / 2); - mAddLandmarkBtn->setRect(al_btn_rect); - } + LLRect al_btn_rect = mAddLandmarkBtn->getRect(); + al_btn_rect.translate( + hist_btn_rect.mLeft - mIconHPad - al_btn_rect.getWidth(), + (rect.getHeight() - al_btn_rect.getHeight()) / 2); + mAddLandmarkBtn->setRect(al_btn_rect); } void LLLocationInputCtrl::changeLocationPresentation() @@ -680,7 +756,7 @@ void LLLocationInputCtrl::onLocationContextMenuItemClicked(const LLSD& userdata) if (item == std::string("show_coordinates")) { - gSavedSettings.setBOOL("ShowCoordinatesOption",!gSavedSettings.getBOOL("ShowCoordinatesOption")); + gSavedSettings.setBOOL("NavBarShowCoordinates",!gSavedSettings.getBOOL("NavBarShowCoordinates")); } else if (item == std::string("landmark")) { @@ -744,7 +820,7 @@ bool LLLocationInputCtrl::onLocationContextMenuItemEnabled(const LLSD& userdata) } else if(item == std::string("show_coordinates")){ - return gSavedSettings.getBOOL("ShowCoordinatesOption"); + return gSavedSettings.getBOOL("NavBarShowCoordinates"); } return false; -- cgit v1.2.3 From 2ede27a5e266794fc3d034f12344a580260a3546 Mon Sep 17 00:00:00 2001 From: James Cook Date: Mon, 23 Nov 2009 15:29:01 -0800 Subject: Context menu item to show/hide nav bar parcel property icons. --- indra/newview/lllocationinputctrl.cpp | 44 ++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 14 deletions(-) (limited to 'indra/newview/lllocationinputctrl.cpp') diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp index be96d7b43a..5d2a0aa382 100644 --- a/indra/newview/lllocationinputctrl.cpp +++ b/indra/newview/lllocationinputctrl.cpp @@ -596,6 +596,16 @@ void LLLocationInputCtrl::refreshLocation() void LLLocationInputCtrl::refreshParcelIcons() { + static LLUICachedControl show_properties("NavBarShowParcelProperties", false); + if (!show_properties) + { + for (S32 i = 0; i < ICON_COUNT; ++i) + { + mParcelIcon[i]->setVisible(false); + } + return; + } + LLViewerParcelMgr* vpm = LLViewerParcelMgr::getInstance(); // *TODO buy //bool allow_buy = vpm->canAgentBuyParcel( vpm->getAgentParcel(), false); @@ -754,11 +764,17 @@ void LLLocationInputCtrl::onLocationContextMenuItemClicked(const LLSD& userdata) { std::string item = userdata.asString(); - if (item == std::string("show_coordinates")) + if (item == "show_coordinates") { gSavedSettings.setBOOL("NavBarShowCoordinates",!gSavedSettings.getBOOL("NavBarShowCoordinates")); } - else if (item == std::string("landmark")) + else if (item == "show_properties") + { + gSavedSettings.setBOOL("NavBarShowParcelProperties", + !gSavedSettings.getBOOL("NavBarShowParcelProperties")); + refreshParcelIcons(); + } + else if (item == "landmark") { LLViewerInventoryItem* landmark = LLLandmarkActions::findLandmarkForAgentPos(); @@ -772,23 +788,23 @@ void LLLocationInputCtrl::onLocationContextMenuItemClicked(const LLSD& userdata) LLSD().insert("type", "landmark").insert("id",landmark->getUUID())); } } - else if (item == std::string("cut")) + else if (item == "cut") { mTextEntry->cut(); } - else if (item == std::string("copy")) + else if (item == "copy") { mTextEntry->copy(); } - else if (item == std::string("paste")) + else if (item == "paste") { mTextEntry->paste(); } - else if (item == std::string("delete")) + else if (item == "delete") { mTextEntry->deleteSelection(); } - else if (item == std::string("select_all")) + else if (item == "select_all") { mTextEntry->selectAll(); } @@ -798,28 +814,28 @@ bool LLLocationInputCtrl::onLocationContextMenuItemEnabled(const LLSD& userdata) { std::string item = userdata.asString(); - if (item == std::string("can_cut")) + if (item == "can_cut") { return mTextEntry->canCut(); } - else if (item == std::string("can_copy")) + else if (item == "can_copy") { return mTextEntry->canCopy(); } - else if (item == std::string("can_paste")) + else if (item == "can_paste") { return mTextEntry->canPaste(); } - else if (item == std::string("can_delete")) + else if (item == "can_delete") { return mTextEntry->canDeselect(); } - else if (item == std::string("can_select_all")) + else if (item == "can_select_all") { return mTextEntry->canSelectAll(); } - else if(item == std::string("show_coordinates")){ - + else if(item == "show_coordinates") + { return gSavedSettings.getBOOL("NavBarShowCoordinates"); } -- cgit v1.2.3 From 6634d3c1ccbe13d3c0cdd17b60628eabe633ea7d Mon Sep 17 00:00:00 2001 From: James Cook Date: Mon, 23 Nov 2009 18:16:03 -0800 Subject: Add damage % text to nav bar, clip text entry to avoid overlapping icons Fixed includes of llmenugl.h / llnotifications.h Note: Clipping is incorrect, I think due to line editor bug. --- indra/newview/lllocationinputctrl.cpp | 129 ++++++++++++++++++++++------------ 1 file changed, 86 insertions(+), 43 deletions(-) (limited to 'indra/newview/lllocationinputctrl.cpp') diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp index 5d2a0aa382..063e98a811 100644 --- a/indra/newview/lllocationinputctrl.cpp +++ b/indra/newview/lllocationinputctrl.cpp @@ -52,6 +52,7 @@ #include "llteleporthistory.h" #include "llsidetray.h" #include "llslurl.h" +#include "llstatusbar.h" // getHealth() #include "lltrans.h" #include "llviewerinventory.h" #include "llviewerparcelmgr.h" @@ -165,7 +166,8 @@ LLLocationInputCtrl::Params::Params() push_icon("push_icon"), build_icon("build_icon"), scripts_icon("scripts_icon"), - damage_icon("damage_icon") + damage_icon("damage_icon"), + damage_text("damage_text") { } @@ -200,7 +202,7 @@ LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p) params.commit_on_focus_lost(false); params.follows.flags(FOLLOWS_ALL); mTextEntry = LLUICtrlFactory::create(params); - this->addChild(mTextEntry); + addChild(mTextEntry); // LLLineEditor is replaced with LLLocationLineEditor // "Place information" button. @@ -261,7 +263,10 @@ LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p) LLIconCtrl::Params damage_icon = p.damage_icon; mParcelIcon[DAMAGE_ICON] = LLUICtrlFactory::create(damage_icon); addChild(mParcelIcon[DAMAGE_ICON]); - // TODO: health number? + + LLTextBox::Params damage_text = p.damage_text; + mDamageText = LLUICtrlFactory::create(damage_text); + addChild(mDamageText); // Register callbacks and load the location field context menu (NB: the order matters). LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Navbar.Action", boost::bind(&LLLocationInputCtrl::onLocationContextMenuItemClicked, this, _2)); @@ -405,11 +410,8 @@ void LLLocationInputCtrl::onTextEntry(LLLineEditor* line_editor) */ void LLLocationInputCtrl::setText(const LLStringExplicit& text) { - if (mTextEntry) - { - mTextEntry->setText(text); - mHasAutocompletedText = FALSE; - } + mTextEntry->setText(text); + mHasAutocompletedText = FALSE; } void LLLocationInputCtrl::setFocus(BOOL b) @@ -444,10 +446,18 @@ void LLLocationInputCtrl::onFocusLost() } void LLLocationInputCtrl::draw() -{ - if(!hasFocus() && gSavedSettings.getBOOL("NavBarShowCoordinates")){ +{ + static LLUICachedControl show_coords("NavBarShowCoordinates", false); + if(!hasFocus() && show_coords) + { refreshLocation(); } + + static LLUICachedControl show_icons("NavBarShowParcelProperties", false); + if (show_icons) + { + refreshHealth(); + } LLComboBox::draw(); } @@ -544,10 +554,12 @@ void LLLocationInputCtrl::onLocationPrearrange(const LLSD& data) mList->mouseOverHighlightNthItem(-1); // Clear highlight on the last selected item. } + bool LLLocationInputCtrl::findTeleportItemsByTitle(const LLTeleportHistoryItem& item, const std::string& filter) { return item.mTitle.find(filter) != std::string::npos; } + void LLLocationInputCtrl::onTextEditorRightClicked(S32 x, S32 y, MASK mask) { if (mLocationContextMenu) @@ -596,51 +608,82 @@ void LLLocationInputCtrl::refreshLocation() void LLLocationInputCtrl::refreshParcelIcons() { + // Our "cursor" moving right to left + S32 x = mAddLandmarkBtn->getRect().mLeft - mIconHPad; + static LLUICachedControl show_properties("NavBarShowParcelProperties", false); - if (!show_properties) + if (show_properties) + { + LLViewerParcelMgr* vpm = LLViewerParcelMgr::getInstance(); + // *TODO buy + //bool allow_buy = vpm->canAgentBuyParcel( vpm->getAgentParcel(), false); + bool allow_voice = vpm->allowAgentVoice(); + bool allow_fly = vpm->allowAgentFly(); + bool allow_push = vpm->allowAgentPush(); + bool allow_build = vpm->allowAgentBuild(); + bool allow_scripts = vpm->allowAgentScripts(); + bool allow_damage = vpm->allowAgentDamage(); + + // Most icons are "block this ability" + mParcelIcon[VOICE_ICON]->setVisible( !allow_voice ); + mParcelIcon[FLY_ICON]->setVisible( !allow_fly ); + mParcelIcon[PUSH_ICON]->setVisible( !allow_push ); + mParcelIcon[BUILD_ICON]->setVisible( !allow_build ); + mParcelIcon[SCRIPTS_ICON]->setVisible( !allow_scripts ); + mParcelIcon[DAMAGE_ICON]->setVisible( allow_damage ); + mDamageText->setVisible(allow_damage); + + // Slide the parcel icons rect from right to left, adjusting rectangles of + // visible icons. Assumes all icon rects are the same. + for (S32 i = 0; i < ICON_COUNT; ++i) + { + LLIconCtrl* icon = mParcelIcon[i]; + if (icon->getVisible()) + { + LLRect r = icon->getRect(); + r.mLeft = x - r.getWidth(); + r.mRight = x; + icon->setRect( r ); + x -= r.getWidth() + mIconHPad; + } + } + LLRect text_rect = mDamageText->getRect(); + text_rect.mLeft = x - text_rect.getWidth(); + text_rect.mRight = x; + mDamageText->setRect(text_rect); + x -= text_rect.getWidth() + mIconHPad; + } + else { for (S32 i = 0; i < ICON_COUNT; ++i) { mParcelIcon[i]->setVisible(false); } - return; + mDamageText->setVisible(false); } - LLViewerParcelMgr* vpm = LLViewerParcelMgr::getInstance(); - // *TODO buy - //bool allow_buy = vpm->canAgentBuyParcel( vpm->getAgentParcel(), false); - bool allow_voice = vpm->allowAgentVoice(); - bool allow_fly = vpm->allowAgentFly(); - bool allow_push = vpm->allowAgentPush(); - bool allow_build = vpm->allowAgentBuild(); - bool allow_scripts = vpm->allowAgentScripts(); - bool allow_damage = vpm->allowAgentDamage(); - - // Most icons are "block this ability" - mParcelIcon[VOICE_ICON]->setVisible( !allow_voice ); - mParcelIcon[FLY_ICON]->setVisible( !allow_fly ); - mParcelIcon[PUSH_ICON]->setVisible( !allow_push ); - mParcelIcon[BUILD_ICON]->setVisible( !allow_build ); - mParcelIcon[SCRIPTS_ICON]->setVisible( !allow_scripts ); - mParcelIcon[DAMAGE_ICON]->setVisible( allow_damage ); - // *TODO damage meter - - // Slide the parcel icons rect from right to left, adjusting rectangles of - // visible icons. Assumes all icon rects are the same. - LLRect icon_rect = mParcelIcon[0]->getRect(); - S32 icon_width = icon_rect.getWidth(); - icon_rect.mRight = mAddLandmarkBtn->getRect().mLeft - mIconHPad; - icon_rect.mLeft = icon_rect.mRight - icon_width; - - for (S32 i = 0; i < ICON_COUNT; ++i) + S32 left_pad, right_pad; + mTextEntry->getTextPadding(&left_pad, &right_pad); + right_pad = mTextEntry->getRect().mRight - x; + llinfos << "JAMESDEBUG text entry rect " << mTextEntry->getRect() + << " x " << x << " left_pad " << left_pad << " right_pad " << right_pad << llendl; + mTextEntry->setTextPadding(left_pad, right_pad); +} + +void LLLocationInputCtrl::refreshHealth() +{ + // *FIXME: Status bar owns health information, should be in agent + if (gStatusBar) { - if (mParcelIcon[i]->getVisible()) + static S32 last_health = -1; + S32 health = gStatusBar->getHealth(); + if (health != last_health) { - mParcelIcon[i]->setRect( icon_rect ); - icon_rect.translate( -icon_width - mIconHPad, 0); + std::string text = llformat("%d%%", health); + mDamageText->setText(text); + last_health = health; } } - // *TODO: health meter } void LLLocationInputCtrl::rebuildLocationHistory(std::string filter) -- cgit v1.2.3