diff options
author | Leslie Linden <none@none> | 2011-06-07 13:57:19 -0700 |
---|---|---|
committer | Leslie Linden <none@none> | 2011-06-07 13:57:19 -0700 |
commit | 1aed9849285b574346087eb5ac7e0c8038fa21fe (patch) | |
tree | 63bed798da119dc094a360c88a02874a22d365d2 /indra | |
parent | 98bcd9e2efe4cc0dc5e51da09c6f18424b9d9144 (diff) |
EXP-865 PROGRESS -- Modify LLBadge to allow it to hang off of non-buttons
Added the following for increased LLBadge functionality:
* Panels now choose whether or not they accept buttons as children, which they
do by default.
* UI controls now shuffle controls with "requests_front" to the front of their
children list at postBuild time.
* Badges are set to "requests_front" by default
* Badges now accept border image and color attributes
Reviewed by Callum
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llui/llbadge.cpp | 11 | ||||
-rw-r--r-- | indra/llui/llbadge.h | 6 | ||||
-rw-r--r-- | indra/llui/llbutton.cpp | 2 | ||||
-rw-r--r-- | indra/llui/llbutton.h | 2 | ||||
-rw-r--r-- | indra/llui/llpanel.cpp | 8 | ||||
-rw-r--r-- | indra/llui/llpanel.h | 5 | ||||
-rw-r--r-- | indra/llui/lluictrl.cpp | 36 | ||||
-rw-r--r-- | indra/llui/lluictrl.h | 8 | ||||
-rw-r--r-- | indra/newview/skins/default/colors.xml | 2 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/widgets/badge.xml | 5 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/widgets/panel.xml | 3 |
11 files changed, 78 insertions, 10 deletions
diff --git a/indra/llui/llbadge.cpp b/indra/llui/llbadge.cpp index ea934aa93b..e4c64e327e 100644 --- a/indra/llui/llbadge.cpp +++ b/indra/llui/llbadge.cpp @@ -38,6 +38,8 @@ template class LLBadge* LLView::getChild<class LLBadge>(const std::string& name, LLBadge::Params::Params() : image("image") + , border_image("border_image") + , border_color("border_color") , image_color("image_color") , label("label") , label_color("label_color") @@ -57,6 +59,8 @@ bool LLBadge::Params::equals(const Params& a) const // skip owner in comparison on purpose + comp &= (border_image() == a.border_image()); + comp &= (border_color() == a.border_color()); comp &= (image() == a.image()); comp &= (image_color() == a.image_color()); comp &= (label() == a.label()); @@ -73,6 +77,8 @@ bool LLBadge::Params::equals(const Params& a) const LLBadge::LLBadge(const LLBadge::Params& p) : LLUICtrl(p) , mOwner(p.owner) + , mBorderImage(p.border_image) + , mBorderColor(p.border_color) , mGLFont(p.font) , mImage(p.image) , mImageColor(p.image_color) @@ -216,6 +222,11 @@ void LLBadge::draw() F32 badge_y = badge_center_y - badge_height * 0.5f; mImage->drawSolid(badge_x, badge_y, badge_width, badge_height, mImageColor % alpha); + + if (!mBorderImage.isNull()) + { + mBorderImage->drawSolid(badge_x, badge_y, badge_width, badge_height, mBorderColor % alpha); + } } else { diff --git a/indra/llui/llbadge.h b/indra/llui/llbadge.h index c2e0a763b2..05a76af42c 100644 --- a/indra/llui/llbadge.h +++ b/indra/llui/llbadge.h @@ -94,6 +94,9 @@ public: { Optional< LLHandle<LLUICtrl> > owner; // Mandatory in code but not in xml + Optional< LLUIImage* > border_image; + Optional< LLUIColor > border_color; + Optional< LLUIImage* > image; Optional< LLUIColor > image_color; @@ -126,6 +129,9 @@ public: void setLabel( const LLStringExplicit& label); private: + LLPointer< LLUIImage > mBorderImage; + LLUIColor mBorderColor; + const LLFontGL* mGLFont; LLPointer< LLUIImage > mImage; diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index a63281b3c1..c841933a5f 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -1098,7 +1098,7 @@ void LLButton::addBadgeToParentPanel() { parentPanel = dynamic_cast<LLPanel*>(parent); - if (parentPanel != NULL) + if (parentPanel && parentPanel->acceptsBadge()) { break; } diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 232ab81e0d..07f0395719 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -125,7 +125,7 @@ public: Optional<F32> hover_glow_amount; Optional<TimeIntervalParam> held_down_delay; - Optional<bool> use_draw_context_alpha; + Optional<bool> use_draw_context_alpha; Optional<LLBadge::Params> badge; diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index b2383106a8..1dcdd79efa 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -87,7 +87,8 @@ LLPanel::Params::Params() filename("filename"), class_name("class"), help_topic("help_topic"), - visible_callback("visible_callback") + visible_callback("visible_callback"), + accepts_badge("accepts_badge") { name = "panel"; addSynonym(background_visible, "bg_visible"); @@ -113,7 +114,8 @@ LLPanel::LLPanel(const LLPanel::Params& p) mCommitCallbackRegistrar(false), mEnableCallbackRegistrar(false), mXMLFilename(p.filename), - mVisibleSignal(NULL) + mVisibleSignal(NULL), + mAcceptsBadge(p.accepts_badge) // *NOTE: Be sure to also change LLPanel::initFromParams(). We have too // many classes derived from LLPanel to retrofit them all to pass in params. { @@ -485,6 +487,8 @@ void LLPanel::initFromParams(const LLPanel::Params& p) mBgAlphaImage = p.bg_alpha_image(); mBgOpaqueImageOverlay = p.bg_opaque_image_overlay; mBgAlphaImageOverlay = p.bg_alpha_image_overlay; + + mAcceptsBadge = p.accepts_badge; } static LLFastTimer::DeclareTimer FTM_PANEL_SETUP("Panel Setup"); diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index 7bbbeaf709..67674fab7e 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -89,6 +89,8 @@ public: Multiple<LocalizedString> strings; Optional<CommitCallbackParam> visible_callback; + + Optional<bool> accepts_badge; Params(); }; @@ -250,6 +252,8 @@ public: boost::signals2::connection setVisibleCallback( const commit_signal_t::slot_type& cb ); + bool acceptsBadge() const { return mAcceptsBadge; } + protected: // Override to set not found list LLButton* getDefaultButton() { return mDefaultBtn; } @@ -264,6 +268,7 @@ protected: static factory_stack_t sFactoryStack; private: + bool mAcceptsBadge; BOOL mBgVisible; // any background at all? BOOL mBgOpaque; // use opaque color or image LLUIColor mBgOpaqueColor; diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index 0a06b5e74f..d58df5801b 100644 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -68,6 +68,7 @@ LLUICtrl::ControlVisibility::ControlVisibility() LLUICtrl::Params::Params() : tab_stop("tab_stop", true), chrome("chrome", false), + requests_front("requests_front", false), label("label"), initial_value("value"), init_callback("init_callback"), @@ -96,9 +97,10 @@ const LLUICtrl::Params& LLUICtrl::getDefaultParams() LLUICtrl::LLUICtrl(const LLUICtrl::Params& p, const LLViewModelPtr& viewmodel) : LLView(p), - mTentative(FALSE), mIsChrome(FALSE), + mRequestsFront(p.requests_front), mTabStop(FALSE), + mTentative(FALSE), mViewModel(viewmodel), mControlVariable(NULL), mEnabledControlVariable(NULL), @@ -123,6 +125,8 @@ void LLUICtrl::initFromParams(const Params& p) { LLView::initFromParams(p); + mRequestsFront = p.requests_front; + setIsChrome(p.chrome); setControlName(p.control_name); if(p.enabled_controls.isProvided()) @@ -403,6 +407,36 @@ LLViewModel* LLUICtrl::getViewModel() const return mViewModel; } +//virtual +BOOL LLUICtrl::postBuild() +{ + // + // Find all of the children that want to be in front and move them to the front + // + + if (getChildCount() > 0) + { + std::vector<LLUICtrl*> childrenToMoveToFront; + + for (LLView::child_list_const_iter_t child_it = beginChild(); child_it != endChild(); ++child_it) + { + LLUICtrl* uictrl = dynamic_cast<LLUICtrl*>(*child_it); + + if (uictrl && uictrl->mRequestsFront) + { + childrenToMoveToFront.push_back(uictrl); + } + } + + for (std::vector<LLUICtrl*>::iterator it = childrenToMoveToFront.begin(); it != childrenToMoveToFront.end(); ++it) + { + sendChildToFront(*it); + } + } + + return LLView::postBuild(); +} + bool LLUICtrl::setControlValue(const LLSD& value) { if (mControlVariable) diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index b37e9f6b1b..09bed9b958 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -94,7 +94,8 @@ public: { Optional<std::string> label; Optional<bool> tab_stop, - chrome; + chrome, + requests_front; Optional<LLSD> initial_value; Optional<CommitCallbackParam> init_callback, @@ -143,6 +144,8 @@ protected: virtual LLViewModel* getViewModel() const; // We shouldn't ever need to set this directly //virtual void setViewModel(const LLViewModelPtr&); + + virtual BOOL postBuild(); public: // LLView interface @@ -301,8 +304,9 @@ protected: private: - BOOL mTabStop; BOOL mIsChrome; + BOOL mRequestsFront; + BOOL mTabStop; BOOL mTentative; LLRootHandle<LLUICtrl> mUICtrlHandle; diff --git a/indra/newview/skins/default/colors.xml b/indra/newview/skins/default/colors.xml index a548849d60..efd2559a55 100644 --- a/indra/newview/skins/default/colors.xml +++ b/indra/newview/skins/default/colors.xml @@ -136,7 +136,7 @@ name="BadgeImageColor" value="0.44 0.69 0.56 1.0" /> <color - name="BadgeImageBorderColor" + name="BadgeBorderColor" value="0.9 0.9 0.9 1.0" /> <color name="BadgeLabelColor" diff --git a/indra/newview/skins/default/xui/en/widgets/badge.xml b/indra/newview/skins/default/xui/en/widgets/badge.xml index ceec09d1e4..f77c4b7178 100644 --- a/indra/newview/skins/default/xui/en/widgets/badge.xml +++ b/indra/newview/skins/default/xui/en/widgets/badge.xml @@ -1,7 +1,9 @@ <?xml version="1.0" encoding="utf-8" standalone="yes" ?> <!-- Additional attributes: --> -<badge font="SansSerifSmall" +<badge border_image="Badge_Border" + border_color="BadgeBorderColor" + font="SansSerifSmall" image="Badge_Background" image_color="BadgeImageColor" label_color="BadgeLabelColor" @@ -10,5 +12,6 @@ location_percent_vcenter="85" padding_horiz="7" padding_vert="4" + requests_front="true" > </badge> diff --git a/indra/newview/skins/default/xui/en/widgets/panel.xml b/indra/newview/skins/default/xui/en/widgets/panel.xml index 9bf99fa363..47a210d9b7 100644 --- a/indra/newview/skins/default/xui/en/widgets/panel.xml +++ b/indra/newview/skins/default/xui/en/widgets/panel.xml @@ -10,4 +10,5 @@ bg_alpha_image_overlay="White" background_visible="false" background_opaque="false" - chrome="false"/>
\ No newline at end of file + chrome="false" + accepts_badge="true"/>
\ No newline at end of file |