diff options
author | Paul Guslisty <pguslisty@productengine.com> | 2010-11-24 19:12:02 +0200 |
---|---|---|
committer | Paul Guslisty <pguslisty@productengine.com> | 2010-11-24 19:12:02 +0200 |
commit | e997a09343ad2a1f082b63c3bce83f9cd9566637 (patch) | |
tree | e3a5c05c34a9af5a7a5f97182aa10160ed977755 /indra | |
parent | 082443b88fc719cb84d67039ab5ddc62847ec6b5 (diff) |
STORM-593 FIXED Make transparent texteditor and lineeditor
Reason: If some child of transparent LLFloater has a visible non-transparent background then this part of floater is non-transparent. As a result floater became partially transparent.
Solution: When transparent floater changes focus, iterate through its children and set corresponding (corresponding to whether control in active or in inactive floater see STORM-535) transparency value.
- Added method LLUICtrl::getCurrentTransparency. This method calculates transparency level of a control. Calculated value should be used as an alpha chennel value in case we want this control to be transparent. For now this method is used by LLFloater to adjust transparency of its children.
- Added calculating of transparecny level for: LLLineEditor, LLTextBase, LLinventoryListItem, LLScrollContainer, LLScrollListCtrl, LLAccrodionCtrlTab.
- Added method LLFlaoter::updateChildrenTransparency which updates transparency value of its children
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llui/llaccordionctrltab.cpp | 3 | ||||
-rw-r--r-- | indra/llui/llfloater.cpp | 35 | ||||
-rw-r--r-- | indra/llui/llfloater.h | 4 | ||||
-rw-r--r-- | indra/llui/lllineeditor.cpp | 3 | ||||
-rw-r--r-- | indra/llui/llpanel.cpp | 2 | ||||
-rw-r--r-- | indra/llui/llscrollcontainer.cpp | 5 | ||||
-rw-r--r-- | indra/llui/llscrolllistctrl.cpp | 3 | ||||
-rw-r--r-- | indra/llui/lltextbase.cpp | 3 | ||||
-rw-r--r-- | indra/llui/lluictrl.cpp | 33 | ||||
-rw-r--r-- | indra/llui/lluictrl.h | 17 | ||||
-rw-r--r-- | indra/newview/llinventorylistitem.cpp | 3 |
11 files changed, 90 insertions, 21 deletions
diff --git a/indra/llui/llaccordionctrltab.cpp b/indra/llui/llaccordionctrltab.cpp index 9d49c1a831..9e4849c58b 100644 --- a/indra/llui/llaccordionctrltab.cpp +++ b/indra/llui/llaccordionctrltab.cpp @@ -203,7 +203,8 @@ void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::draw() S32 width = getRect().getWidth(); S32 height = getRect().getHeight(); - gl_rect_2d(0,0,width - 1 ,height - 1,mHeaderBGColor.get(),true); + F32 alpha = getCurrentTransparency(); + gl_rect_2d(0,0,width - 1 ,height - 1,mHeaderBGColor.get() % alpha,true); LLAccordionCtrlTab* parent = dynamic_cast<LLAccordionCtrlTab*>(getParent()); bool collapsible = (parent && parent->getCollapsible()); diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 34d8e9c500..720ff86aa7 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -61,10 +61,6 @@ // use this to control "jumping" behavior when Ctrl-Tabbing const S32 TABBED_FLOATER_OFFSET = 0; -// static -F32 LLFloater::sActiveFloaterTransparency = 0.0f; -F32 LLFloater::sInactiveFloaterTransparency = 0.0f; - std::string LLFloater::sButtonNames[BUTTON_COUNT] = { "llfloater_close_btn", //BUTTON_CLOSE @@ -208,14 +204,14 @@ void LLFloater::initClass() if (ctrl) { ctrl->getSignal()->connect(boost::bind(&LLFloater::updateActiveFloaterTransparency)); - sActiveFloaterTransparency = LLUI::sSettingGroups["config"]->getF32("ActiveFloaterTransparency"); + updateActiveFloaterTransparency(); } ctrl = LLUI::sSettingGroups["config"]->getControl("InactiveFloaterTransparency").get(); if (ctrl) { ctrl->getSignal()->connect(boost::bind(&LLFloater::updateInactiveFloaterTransparency)); - sInactiveFloaterTransparency = LLUI::sSettingGroups["config"]->getF32("InactiveFloaterTransparency"); + updateInactiveFloaterTransparency(); } } @@ -225,7 +221,7 @@ static LLWidgetNameRegistry::StaticRegistrar sRegisterFloaterParams(&typeid(LLFl LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p) : LLPanel(), // intentionally do not pass params here, see initFromParams - mDragHandle(NULL), + mDragHandle(NULL), mTitle(p.title), mShortTitle(p.short_title), mSingleInstance(p.single_instance), @@ -368,13 +364,13 @@ void LLFloater::layoutDragHandle() // static void LLFloater::updateActiveFloaterTransparency() { - sActiveFloaterTransparency = LLUI::sSettingGroups["config"]->getF32("ActiveFloaterTransparency"); + sActiveControlTransparency = LLUI::sSettingGroups["config"]->getF32("ActiveFloaterTransparency"); } // static void LLFloater::updateInactiveFloaterTransparency() { - sInactiveFloaterTransparency = LLUI::sSettingGroups["config"]->getF32("InactiveFloaterTransparency"); + sInactiveControlTransparency = LLUI::sSettingGroups["config"]->getF32("InactiveFloaterTransparency"); } void LLFloater::addResizeCtrls() @@ -1193,6 +1189,7 @@ void LLFloater::setFocus( BOOL b ) last_focus->setFocus(TRUE); } } + updateChildrenTransparency(this); } // virtual @@ -1652,7 +1649,7 @@ void LLFloater::onClickCloseBtn() // virtual void LLFloater::draw() { - mCurrentTransparency = hasFocus() ? sActiveFloaterTransparency : sInactiveFloaterTransparency; + mCurrentTransparency = hasFocus() ? sActiveControlTransparency : sInactiveControlTransparency; // draw background if( isBackgroundVisible() ) @@ -1771,6 +1768,24 @@ void LLFloater::drawShadow(LLPanel* panel) llround(shadow_offset)); } +void LLFloater::updateChildrenTransparency(LLView* ctrl) +{ + child_list_t children = *ctrl->getChildList(); + child_list_t::iterator it = children.begin(); + + ETypeTransparency transparency_type = hasFocus() ? TT_ACTIVE : TT_INACTIVE; + + for(; it != children.end(); ++it) + { + LLUICtrl* ui_ctrl = dynamic_cast<LLUICtrl*>(*it); + if (ui_ctrl) + { + ui_ctrl->setTransparencyType(transparency_type); + } + updateChildrenTransparency(*it); + } +} + void LLFloater::setCanMinimize(BOOL can_minimize) { // if removing minimize/restore button programmatically, diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index fa806bb632..9eeac9fbfb 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -343,6 +343,7 @@ private: static void updateActiveFloaterTransparency(); static void updateInactiveFloaterTransparency(); + void updateChildrenTransparency(LLView* ctrl); public: // Called when floater is opened, passes mKey @@ -413,9 +414,6 @@ private: F32 mCurrentTransparency; - static F32 sActiveFloaterTransparency; - static F32 sInactiveFloaterTransparency; - static LLMultiFloater* sHostp; static BOOL sQuitting; static std::string sButtonNames[BUTTON_COUNT]; diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 3eb58e1aec..ba73b74052 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -1530,7 +1530,8 @@ void LLLineEditor::drawBackground() image = mBgImage; } - F32 alpha = getDrawContext().mAlpha; + F32 alpha = getCurrentTransparency(); + // optionally draw programmatic border if (has_focus) { diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index 900e2c789e..ff377ba3a1 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -194,6 +194,8 @@ void LLPanel::draw() // draw background if( mBgVisible ) { + alpha = getCurrentTransparency(); + LLRect local_rect = getLocalRect(); if (mBgOpaque ) { diff --git a/indra/llui/llscrollcontainer.cpp b/indra/llui/llscrollcontainer.cpp index 3146418a7d..380c477eb2 100644 --- a/indra/llui/llscrollcontainer.cpp +++ b/indra/llui/llscrollcontainer.cpp @@ -422,9 +422,10 @@ void LLScrollContainer::draw() // Draw background if( mIsOpaque ) { + F32 alpha = getCurrentTransparency(); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.color4fv( mBackgroundColor.get().mV ); - gl_rect_2d( mInnerRect ); + gl_rect_2d(mInnerRect, mBackgroundColor.get() % alpha); } // Draw mScrolledViews and update scroll bars. diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 7df7c13dc0..8854f0a02e 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -1482,8 +1482,9 @@ void LLScrollListCtrl::draw() // Draw background if (mBackgroundVisible) { + F32 alpha = getCurrentTransparency(); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gl_rect_2d(background, getEnabled() ? mBgWriteableColor.get() : mBgReadOnlyColor.get() ); + gl_rect_2d(background, getEnabled() ? mBgWriteableColor.get() % alpha : mBgReadOnlyColor.get() % alpha ); } if (mColumnsDirty) diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 3f213ed13e..49537ef78f 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -1005,6 +1005,7 @@ void LLTextBase::draw() if (mBGVisible) { + F32 alpha = getCurrentTransparency(); // clip background rect against extents, if we support scrolling LLRect bg_rect = mVisibleTextRect; if (mScroller) @@ -1016,7 +1017,7 @@ void LLTextBase::draw() : hasFocus() ? mFocusBgColor.get() : mWriteableBgColor.get(); - gl_rect_2d(doc_rect, bg_color, TRUE); + gl_rect_2d(doc_rect, bg_color % alpha, TRUE); } // draw document view diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index 3ac3bf8c41..0065d164d7 100644 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -36,6 +36,9 @@ static LLDefaultChildRegistry::Register<LLUICtrl> r("ui_ctrl"); +F32 LLUICtrl::sActiveControlTransparency = 1.0f; +F32 LLUICtrl::sInactiveControlTransparency = 1.0f; + // Compiler optimization, generate extern template template class LLUICtrl* LLView::getChild<class LLUICtrl>( const std::string& name, BOOL recurse) const; @@ -110,7 +113,8 @@ LLUICtrl::LLUICtrl(const LLUICtrl::Params& p, const LLViewModelPtr& viewmodel) mMouseUpSignal(NULL), mRightMouseDownSignal(NULL), mRightMouseUpSignal(NULL), - mDoubleClickSignal(NULL) + mDoubleClickSignal(NULL), + mTransparencyType(TT_DEFAULT) { mUICtrlHandle.bind(this); } @@ -923,6 +927,33 @@ BOOL LLUICtrl::getTentative() const void LLUICtrl::setColor(const LLColor4& color) { } +F32 LLUICtrl::getCurrentTransparency() +{ + F32 alpha; + + switch(mTransparencyType) + { + case TT_DEFAULT: + alpha = getDrawContext().mAlpha; + break; + + case TT_ACTIVE: + alpha = sActiveControlTransparency; + break; + + case TT_INACTIVE: + alpha = sInactiveControlTransparency; + break; + } + + return alpha; +} + +void LLUICtrl::setTransparencyType(ETypeTransparency type) +{ + mTransparencyType = type; +} + boost::signals2::connection LLUICtrl::setCommitCallback( const commit_signal_t::slot_type& cb ) { if (!mCommitSignal) mCommitSignal = new commit_signal_t(); diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index 76dfdf754c..a78f98ac76 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -120,6 +120,12 @@ public: Params(); }; + enum ETypeTransparency + { + TT_DEFAULT, + TT_ACTIVE, + TT_INACTIVE + }; /*virtual*/ ~LLUICtrl(); void initFromParams(const Params& p); @@ -202,6 +208,11 @@ public: virtual void setColor(const LLColor4& color); + F32 getCurrentTransparency(); + + void setTransparencyType(ETypeTransparency type); + ETypeTransparency getTransparencyType() const {return mTransparencyType;} + BOOL focusNextItem(BOOL text_entry_only); BOOL focusPrevItem(BOOL text_entry_only); BOOL focusFirstItem(BOOL prefer_text_fields = FALSE, BOOL focus_flash = TRUE ); @@ -283,6 +294,10 @@ protected: boost::signals2::connection mMakeVisibleControlConnection; LLControlVariable* mMakeInvisibleControlVariable; boost::signals2::connection mMakeInvisibleControlConnection; + + static F32 sActiveControlTransparency; + static F32 sInactiveControlTransparency; + private: BOOL mTabStop; @@ -290,6 +305,8 @@ private: BOOL mTentative; LLRootHandle<LLUICtrl> mUICtrlHandle; + ETypeTransparency mTransparencyType; + class DefaultTabGroupFirstSorter; }; diff --git a/indra/newview/llinventorylistitem.cpp b/indra/newview/llinventorylistitem.cpp index 225d0288a9..3e0849a795 100644 --- a/indra/newview/llinventorylistitem.cpp +++ b/indra/newview/llinventorylistitem.cpp @@ -97,7 +97,8 @@ void LLPanelInventoryListItemBase::draw() LLRect separator_rect = getLocalRect(); separator_rect.mTop = separator_rect.mBottom; separator_rect.mBottom -= mSeparatorImage->getHeight(); - mSeparatorImage->draw(separator_rect); + F32 alpha = getCurrentTransparency(); + mSeparatorImage->draw(separator_rect, UI_VERTEX_COLOR % alpha); } LLPanel::draw(); |