From d1d195ba904490c19faf2078560f49c3a6b16a18 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Tue, 2 Mar 2010 09:58:34 +0000 Subject: CID-433 Checker: FORWARD_NULL Function: LLTabContainer::reshapeTuple(LLTabTuple *) File: /indra/llui/lltabcontainer.cpp --- indra/llui/lltabcontainer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index 85ae13a889..30fc7babae 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -1649,7 +1649,7 @@ void LLTabContainer::reshapeTuple(LLTabTuple* tuple) if(mCustomIconCtrlUsed) { LLCustomButtonIconCtrl* button = dynamic_cast(tuple->mButton); - LLIconCtrl* icon_ctrl = button->getIconCtrl(); + LLIconCtrl* icon_ctrl = button ? button->getIconCtrl() : NULL; image_overlay_width = icon_ctrl ? icon_ctrl->getRect().getWidth() : 0; } else -- cgit v1.2.3 From 41a30a59fb1b6dea2d531333d0429632f1fef2fe Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Tue, 2 Mar 2010 14:21:58 -0800 Subject: initial work changing topctrl to popup layer --- indra/llui/llcombobox.cpp | 7 ++----- indra/llui/llfloater.cpp | 15 +++----------- indra/llui/llfocusmgr.cpp | 47 +++----------------------------------------- indra/llui/llfocusmgr.h | 8 +------- indra/llui/llhandle.h | 7 +++++++ indra/llui/llmodaldialog.cpp | 6 +++--- indra/llui/llui.cpp | 29 +++++++++++++++++++++++++++ indra/llui/llui.h | 10 ++++++++++ indra/llui/llview.cpp | 5 ----- 9 files changed, 58 insertions(+), 76 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp index 9d23daf56d..de3bf719ee 100644 --- a/indra/llui/llcombobox.cpp +++ b/indra/llui/llcombobox.cpp @@ -615,7 +615,7 @@ void LLComboBox::showList() // register ourselves as a "top" control // effectively putting us into a special draw layer // and not affecting the bounding rectangle calculation - gFocusMgr.setTopCtrl(this); + LLUI::addPopup(this); // Show the list and push the button down mButton->setToggleState(TRUE); @@ -644,10 +644,7 @@ void LLComboBox::hideList() mList->mouseOverHighlightNthItem(-1); setUseBoundingRect(FALSE); - if( gFocusMgr.getTopCtrl() == this ) - { - gFocusMgr.setTopCtrl(NULL); - } + LLUI::removePopup(this); } } diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index b6d73cda3c..b93b72abf6 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -527,10 +527,7 @@ void LLFloater::setVisible( BOOL visible ) if( !visible ) { - if( gFocusMgr.childIsTopCtrl( this ) ) - { - gFocusMgr.setTopCtrl(NULL); - } + LLUI::removePopup(this); if( gFocusMgr.childHasMouseCapture( this ) ) { @@ -704,10 +701,7 @@ void LLFloater::reshape(S32 width, S32 height, BOOL called_from_parent) void LLFloater::releaseFocus() { - if( gFocusMgr.childIsTopCtrl( this ) ) - { - gFocusMgr.setTopCtrl(NULL); - } + LLUI::removePopup(this); setFocus(FALSE); @@ -2503,10 +2497,7 @@ void LLFloaterView::syncFloaterTabOrder() if (modal_dialog) { // If we have a visible modal dialog, make sure that it has focus - if( gFocusMgr.getTopCtrl() != modal_dialog ) - { - gFocusMgr.setTopCtrl( modal_dialog ); - } + LLUI::addPopup(modal_dialog); if( !gFocusMgr.childHasKeyboardFocus( modal_dialog ) ) { diff --git a/indra/llui/llfocusmgr.cpp b/indra/llui/llfocusmgr.cpp index 35fbc7b0a8..ad2940e685 100644 --- a/indra/llui/llfocusmgr.cpp +++ b/indra/llui/llfocusmgr.cpp @@ -38,8 +38,6 @@ const F32 FOCUS_FADE_TIME = 0.3f; -// NOTE: the LLFocusableElement implementation has been moved here from lluictrl.cpp. - LLFocusableElement::LLFocusableElement() : mFocusLostCallback(NULL), mFocusReceivedCallback(NULL), @@ -124,8 +122,7 @@ boost::signals2::connection LLFocusableElement::setTopLostCallback(const focus_s LLFocusMgr gFocusMgr; LLFocusMgr::LLFocusMgr() - : - mLockedView( NULL ), +: mLockedView( NULL ), mMouseCaptor( NULL ), mKeyboardFocus( NULL ), mLastKeyboardFocus( NULL ), @@ -133,16 +130,11 @@ LLFocusMgr::LLFocusMgr() mKeystrokesOnly(FALSE), mTopCtrl( NULL ), mAppHasFocus(TRUE) // Macs don't seem to notify us that we've gotten focus, so default to true - #ifdef _DEBUG - , mMouseCaptorName("none") - , mKeyboardFocusName("none") - , mTopCtrlName("none") - #endif { } -void LLFocusMgr::releaseFocusIfNeeded( const LLView* view ) +void LLFocusMgr::releaseFocusIfNeeded( LLView* view ) { if( childHasMouseCapture( view ) ) { @@ -162,10 +154,7 @@ void LLFocusMgr::releaseFocusIfNeeded( const LLView* view ) } } - if( childIsTopCtrl( view ) ) - { - setTopCtrl( NULL ); - } + LLUI::removePopup(view); } @@ -248,11 +237,6 @@ void LLFocusMgr::setKeyboardFocus(LLFocusableElement* new_focus, BOOL lock, BOOL return; } - #ifdef _DEBUG - LLUICtrl* focus_ctrl = dynamic_cast(new_focus); - mKeyboardFocusName = focus_ctrl ? focus_ctrl->getName() : std::string("none"); - #endif - // If we've got a default keyboard focus, and the caller is // releasing keyboard focus, move to the default. if (mDefaultKeyboardFocus != NULL && mKeyboardFocus == NULL) @@ -334,20 +318,12 @@ void LLFocusMgr::removeKeyboardFocusWithoutCallback( const LLFocusableElement* f if( mKeyboardFocus == focus ) { mKeyboardFocus = NULL; - #ifdef _DEBUG - mKeyboardFocusName = std::string("none"); - #endif } } void LLFocusMgr::setMouseCapture( LLMouseHandler* new_captor ) { - //if (mFocusLocked) - //{ - // return; - //} - if( new_captor != mMouseCaptor ) { LLMouseHandler* old_captor = mMouseCaptor; @@ -370,24 +346,14 @@ void LLFocusMgr::setMouseCapture( LLMouseHandler* new_captor ) old_captor->onMouseCaptureLost(); } - #ifdef _DEBUG - mMouseCaptorName = new_captor ? new_captor->getName() : std::string("none"); - #endif } } void LLFocusMgr::removeMouseCaptureWithoutCallback( const LLMouseHandler* captor ) { - //if (mFocusLocked) - //{ - // return; - //} if( mMouseCaptor == captor ) { mMouseCaptor = NULL; - #ifdef _DEBUG - mMouseCaptorName = std::string("none"); - #endif } } @@ -416,10 +382,6 @@ void LLFocusMgr::setTopCtrl( LLUICtrl* new_top ) { mTopCtrl = new_top; - #ifdef _DEBUG - mTopCtrlName = new_top ? new_top->getName() : std::string("none"); - #endif - if (old_top) { old_top->onTopLost(); @@ -432,9 +394,6 @@ void LLFocusMgr::removeTopCtrlWithoutCallback( const LLUICtrl* top_view ) if( mTopCtrl == top_view ) { mTopCtrl = NULL; - #ifdef _DEBUG - mTopCtrlName = std::string("none"); - #endif } } diff --git a/indra/llui/llfocusmgr.h b/indra/llui/llfocusmgr.h index 83ecd1d301..5b08c628d4 100644 --- a/indra/llui/llfocusmgr.h +++ b/indra/llui/llfocusmgr.h @@ -119,7 +119,7 @@ public: BOOL childIsTopCtrl( const LLView* parent ) const; // All Three - void releaseFocusIfNeeded( const LLView* top_view ); + void releaseFocusIfNeeded( LLView* top_view ); void lockFocus(); void unlockFocus(); BOOL focusLocked() const { return mLockedView != NULL; } @@ -149,12 +149,6 @@ private: typedef std::map, LLHandle > focus_history_map_t; focus_history_map_t mFocusHistory; - - #ifdef _DEBUG - std::string mMouseCaptorName; - std::string mKeyboardFocusName; - std::string mTopCtrlName; - #endif }; extern LLFocusMgr gFocusMgr; diff --git a/indra/llui/llhandle.h b/indra/llui/llhandle.h index 899f6b9326..8ade327044 100644 --- a/indra/llui/llhandle.h +++ b/indra/llui/llhandle.h @@ -67,6 +67,13 @@ public: return *this; } + template + LLHandle& operator =(const LLHandle& other) + { + mTombStone = other.mTombStone; + return *this; + } + bool isDead() const { return mTombStone->getTarget() == NULL; diff --git a/indra/llui/llmodaldialog.cpp b/indra/llui/llmodaldialog.cpp index 387af05935..6cff68c20b 100644 --- a/indra/llui/llmodaldialog.cpp +++ b/indra/llui/llmodaldialog.cpp @@ -111,7 +111,7 @@ void LLModalDialog::onOpen(const LLSD& key) // This is a modal dialog. It sucks up all mouse and keyboard operations. gFocusMgr.setMouseCapture( this ); - gFocusMgr.setTopCtrl( this ); + LLUI::addPopup(this); setFocus(TRUE); sModalStack.push_front( this ); @@ -153,7 +153,7 @@ void LLModalDialog::setVisible( BOOL visible ) gFocusMgr.setMouseCapture( this ); // The dialog view is a root view - gFocusMgr.setTopCtrl( this ); + LLUI::addPopup(this); setFocus( TRUE ); } else @@ -291,7 +291,7 @@ void LLModalDialog::onAppFocusGained() // This is a modal dialog. It sucks up all mouse and keyboard operations. gFocusMgr.setMouseCapture( instance ); instance->setFocus(TRUE); - gFocusMgr.setTopCtrl( instance ); + LLUI::addPopup(instance); instance->centerOnScreen(); } diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index b348ec2d29..64df1dbc7a 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -86,6 +86,9 @@ std::list gUntranslated; /*static*/ LLHelp* LLUI::sHelpImpl = NULL; /*static*/ std::vector LLUI::sXUIPaths; /*static*/ LLFrameTimer LLUI::sMouseIdleTimer; +/*static*/ LLUI::add_popup_t LLUI::sAddPopupFunc; +/*static*/ LLUI::remove_popup_t LLUI::sRemovePopupFunc; +/*static*/ LLUI::clear_popups_t LLUI::sClearPopupsFunc; // register filtereditor here static LLDefaultChildRegistry::Register register_filter_editor("filter_editor"); @@ -1607,6 +1610,13 @@ void LLUI::cleanupClass() sImageProvider->cleanUp(); } +void LLUI::setPopupFuncs(const add_popup_t& add_popup, const remove_popup_t& remove_popup, const clear_popups_t& clear_popups) +{ + sAddPopupFunc = add_popup; + sRemovePopupFunc = remove_popup; + sClearPopupsFunc = clear_popups; +} + //static void LLUI::dirtyRect(LLRect rect) { @@ -1877,6 +1887,25 @@ LLControlGroup& LLUI::getControlControlGroup (const std::string& controlname) return *sSettingGroups["config"]; // default group } +//static +void LLUI::addPopup(LLView* viewp) +{ + if (sAddPopupFunc) + { + sAddPopupFunc(viewp); + } +} + +//static +void LLUI::removePopup(LLView* viewp) +{ + if (sRemovePopupFunc) + { + sRemovePopupFunc(viewp); + } +} + + //static // spawn_x and spawn_y are top left corner of view in screen GL coordinates void LLUI::positionViewNearMouse(LLView* view, S32 spawn_x, S32 spawn_y) diff --git a/indra/llui/llui.h b/indra/llui/llui.h index af8d4ea03b..824d76f526 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -160,12 +160,17 @@ public: // Methods // typedef std::map settings_map_t; + typedef boost::function add_popup_t; + typedef boost::function remove_popup_t; + typedef boost::function clear_popups_t; + static void initClass(const settings_map_t& settings, LLImageProviderInterface* image_provider, LLUIAudioCallback audio_callback = NULL, const LLVector2 *scale_factor = NULL, const std::string& language = LLStringUtil::null); static void cleanupClass(); + static void setPopupFuncs(const add_popup_t& add_popup, const remove_popup_t&, const clear_popups_t& ); static void pushMatrix(); static void popMatrix(); @@ -207,6 +212,8 @@ public: static F32 getMouseIdleTime() { return sMouseIdleTimer.getElapsedTimeF32(); } static void resetMouseIdleTimer() { sMouseIdleTimer.reset(); } static LLWindow* getWindow() { return sWindow; } + static void addPopup(LLView*); + static void removePopup(LLView*); // Ensures view does not overlap mouse cursor, but is inside // the view's parent rectangle. Used for tooltips, inspectors. @@ -227,6 +234,9 @@ private: static LLImageProviderInterface* sImageProvider; static std::vector sXUIPaths; static LLFrameTimer sMouseIdleTimer; + static add_popup_t sAddPopupFunc; + static remove_popup_t sRemovePopupFunc; + static clear_popups_t sClearPopupsFunc; }; diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 63e627ceb5..db2c460eec 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -592,11 +592,6 @@ void LLView::setVisible(BOOL visible) { if ( mVisible != visible ) { - if( !visible && (gFocusMgr.getTopCtrl() == this) ) - { - gFocusMgr.setTopCtrl( NULL ); - } - mVisible = visible; // notify children of visibility change if root, or part of visible hierarchy -- cgit v1.2.3 From 9272037c9d382c210b48379a209d89502ff48dd0 Mon Sep 17 00:00:00 2001 From: Paul Guslisty Date: Wed, 3 Mar 2010 09:47:58 +0200 Subject: Fixed normal bug EXT - 4572 (Click and hold the left mouse button doesn't let you browse tabbed IM floater) - Set mouse capture to the tab container in case of some control \"grab\" it during mouse hovering over tab container. --HG-- branch : product-engine --- indra/llui/lltabcontainer.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indra/llui') diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index 30fc7babae..1dcfb4e296 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -2061,5 +2061,12 @@ void LLTabContainer::commitHoveredButton(S32 x, S32 y) tuple->mButton->onCommit(); } } + /** + * EXT - 4572 (Click and hold the left mouse button doesn't let you browse tabbed IM floater) + * + * During hovering mouse(with left mouse button hold) over tabs, a newly just activated corresponding + * to the tab(that is hovered in the given instant of time) panel may caught mouse capture. + */ + gFocusMgr.setMouseCapture(this); } } -- cgit v1.2.3 From cdb0911a7897253d269a4c8d4a5532c245bc6b32 Mon Sep 17 00:00:00 2001 From: Ychebotarev ProductEngine Date: Wed, 3 Mar 2010 11:39:45 +0200 Subject: fix for EXT-4469 Fast Timers: Minimize and Close icons do not work --HG-- branch : product-engine --- indra/llui/llfloater.cpp | 7 ++++++- indra/llui/llfloater.h | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index b6d73cda3c..e91d753a39 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -1554,7 +1554,12 @@ void LLFloater::onClickClose( LLFloater* self ) { if (!self) return; - self->closeFloater(false); + self->onClickCloseBtn(); +} + +void LLFloater::onClickCloseBtn() +{ + closeFloater(false); } diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 19e8288807..c1e8813f87 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -307,6 +307,8 @@ protected: void destroy() { die(); } // Don't call this directly. You probably want to call closeFloater() + virtual void onClickCloseBtn(); + private: void setForeground(BOOL b); // called only by floaterview void cleanupHandles(); // remove handles to dead floaters @@ -346,6 +348,7 @@ protected: LLResizeBar* mResizeBar[4]; LLResizeHandle* mResizeHandle[4]; + LLButton* mButtons[BUTTON_COUNT]; private: LLRect mExpandedRect; @@ -379,7 +382,6 @@ private: handle_set_t mDependents; bool mButtonsEnabled[BUTTON_COUNT]; - LLButton* mButtons[BUTTON_COUNT]; F32 mButtonScale; BOOL mAutoFocus; LLHandle mSnappedTo; -- cgit v1.2.3 From 0f04222acc13802d1b16dff49e17dc52c1cfae2a Mon Sep 17 00:00:00 2001 From: Ychebotarev ProductEngine Date: Wed, 3 Mar 2010 11:43:48 +0200 Subject: fix for normal EXT-1391 Group Info: Avatar name should end with ellipsis if it doesn't fit free space --HG-- branch : product-engine --- indra/llui/llscrolllistcell.cpp | 4 +++- indra/llui/llscrolllistcell.h | 5 +++++ indra/llui/llscrolllistctrl.h | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llscrolllistcell.cpp b/indra/llui/llscrolllistcell.cpp index 3cc92baa8d..d17be8b94a 100644 --- a/indra/llui/llscrolllistcell.cpp +++ b/indra/llui/llscrolllistcell.cpp @@ -185,6 +185,8 @@ LLScrollListText::LLScrollListText(const LLScrollListCell::Params& p) { sCount++; + mTextWidth = getWidth(); + // initialize rounded rect image if (!mRoundedRectImage) { @@ -340,7 +342,7 @@ void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_col 0, LLFontGL::NO_SHADOW, string_chars, - getWidth(), + getTextWidth(), &right_x, TRUE); } diff --git a/indra/llui/llscrolllistcell.h b/indra/llui/llscrolllistcell.h index 5fecf5aade..b1c8901fc4 100644 --- a/indra/llui/llscrolllistcell.h +++ b/indra/llui/llscrolllistcell.h @@ -151,11 +151,16 @@ public: /*virtual*/ const std::string & getToolTip() const; /*virtual*/ BOOL needsToolTip() const; + S32 getTextWidth() const { return mTextWidth;} + void setTextWidth(S32 value) { mTextWidth = value;} + virtual void setWidth(S32 width) { LLScrollListCell::setWidth(width); mTextWidth = width; } + void setText(const LLStringExplicit& text); void setFontStyle(const U8 font_style); private: LLUIString mText; + S32 mTextWidth; const LLFontGL* mFont; LLColor4 mColor; U8 mUseColor; diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h index e819c5fdea..ebdc82115f 100644 --- a/indra/llui/llscrolllistctrl.h +++ b/indra/llui/llscrolllistctrl.h @@ -219,7 +219,10 @@ public: void deselectAllItems(BOOL no_commit_on_change = FALSE); // by default, go ahead and commit on selection change void clearHighlightedItems(); - void mouseOverHighlightNthItem( S32 index ); + + virtual void mouseOverHighlightNthItem( S32 index ); + + S32 getHighlightedItemInx() const { return mHighlightedItem; } void setDoubleClickCallback( callback_t cb ) { mOnDoubleClickCallback = cb; } void setMaximumSelectCallback( callback_t cb) { mOnMaximumSelectCallback = cb; } -- cgit v1.2.3 From c624848d2537b302c83fe5a6aade7ed5b9e38f90 Mon Sep 17 00:00:00 2001 From: Ychebotarev ProductEngine Date: Wed, 3 Mar 2010 11:49:27 +0200 Subject: fix for low EXT-5327 Add an ability to open accordions by "Enter" button, like folders' behavior --HG-- branch : product-engine --- indra/llui/llaccordionctrltab.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/llui') diff --git a/indra/llui/llaccordionctrltab.cpp b/indra/llui/llaccordionctrltab.cpp index daa9e08f14..b90ed25058 100644 --- a/indra/llui/llaccordionctrltab.cpp +++ b/indra/llui/llaccordionctrltab.cpp @@ -562,6 +562,12 @@ BOOL LLAccordionCtrlTab::handleKey(KEY key, MASK mask, BOOL called_from_parent) if( !header->hasFocus() ) return LLUICtrl::handleKey(key, mask, called_from_parent); + if ( (key == KEY_RETURN )&& mask == MASK_NONE) + { + changeOpenClose(getDisplayChildren()); + return TRUE; + } + if ( (key == KEY_ADD || key == KEY_RIGHT)&& mask == MASK_NONE) { if(getDisplayChildren() == false) -- cgit v1.2.3 From 1eb84f5e13b2c49bdbe8d1f041bfcf0afa5b15d2 Mon Sep 17 00:00:00 2001 From: Ychebotarev ProductEngine Date: Wed, 3 Mar 2010 11:51:15 +0200 Subject: fix EXT-5652 Make accordion in the Group Info panel a little bit wider in order to avoid horizontal scroll --HG-- branch : product-engine --- indra/llui/llaccordionctrl.cpp | 8 -- indra/llui/llaccordionctrltab.cpp | 293 +++++++++++++++++++++++++++++++++----- indra/llui/llaccordionctrltab.h | 31 +++- 3 files changed, 287 insertions(+), 45 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llaccordionctrl.cpp b/indra/llui/llaccordionctrl.cpp index aa69dfe0cc..2ed1082f56 100644 --- a/indra/llui/llaccordionctrl.cpp +++ b/indra/llui/llaccordionctrl.cpp @@ -103,13 +103,6 @@ void LLAccordionCtrl::draw() LLLocalClipRect clip(local_rect); LLPanel::draw(); - /* - S32 width = getRect().getWidth(); - S32 height = getRect().getHeight(); - - gl_rect_2d(0, 0 , width - 1 ,height - 1,LLColor4::green,true); - gl_line_2d(0, 0 , width - 1 ,height - 1,LLColor4::black); - */ } @@ -125,7 +118,6 @@ BOOL LLAccordionCtrl::postBuild() scrollbar_size, getRect().getHeight() - 1); - LLScrollbar::Params sbparams; sbparams.name("scrollable vertical"); sbparams.rect(scroll_rect); diff --git a/indra/llui/llaccordionctrltab.cpp b/indra/llui/llaccordionctrltab.cpp index b90ed25058..1067c3f1d5 100644 --- a/indra/llui/llaccordionctrltab.cpp +++ b/indra/llui/llaccordionctrltab.cpp @@ -33,8 +33,9 @@ #include "linden_common.h" #include "lluictrl.h" - +#include "llscrollbar.h" #include "llaccordionctrltab.h" +#include "lllocalcliprect.h" #include "lltextbox.h" @@ -46,6 +47,8 @@ static const S32 HEADER_HEIGHT = 20; static const S32 HEADER_IMAGE_LEFT_OFFSET = 5; static const S32 HEADER_TEXT_LEFT_OFFSET = 30; static const F32 AUTO_OPEN_TIME = 1.f; +static const S32 VERTICAL_MULTIPLE = 16; +static const S32 PARENT_BORDER_MARGIN = 5; static LLDefaultChildRegistry::Register t1("accordion_tab"); @@ -277,6 +280,7 @@ LLAccordionCtrlTab::Params::Params() ,header_image_pressed("header_image_pressed") ,header_image_focused("header_image_focused") ,header_text_color("header_text_color") + ,fit_panel("fit_panel",true) { mouse_opaque(false); } @@ -293,6 +297,9 @@ LLAccordionCtrlTab::LLAccordionCtrlTab(const LLAccordionCtrlTab::Params&p) ,mPaddingTop(p.padding_top) ,mPaddingBottom(p.padding_bottom) ,mCanOpenClose(true) + ,mFitPanel(p.fit_panel) + ,mContainerPanel(NULL) + ,mScrollbar(NULL) { mStoredOpenCloseState = false; mWasStateStored = false; @@ -321,54 +328,42 @@ void LLAccordionCtrlTab::setDisplayChildren(bool display) mExpandedHeight : HEADER_HEIGHT); setRect(rect); - for(child_list_const_iter_t it = getChildList()->begin(); - getChildList()->end() != it; ++it) - { - LLView* child = *it; - if(DD_HEADER_NAME == child->getName()) - continue; + if(mContainerPanel) + mContainerPanel->setVisible(getDisplayChildren()); - child->setVisible(getDisplayChildren()); + if(mDisplayChildren) + { + adjustContainerPanel(); + } + else + { + if(mScrollbar) + mScrollbar->setVisible(false); } + } void LLAccordionCtrlTab::reshape(S32 width, S32 height, BOOL called_from_parent /* = TRUE */) { LLRect headerRect; - LLUICtrl::reshape(width, height, TRUE); - headerRect.setLeftTopAndSize( 0,height,width,HEADER_HEIGHT); mHeader->setRect(headerRect); mHeader->reshape(headerRect.getWidth(), headerRect.getHeight()); - for(child_list_const_iter_t it = getChildList()->begin(); - getChildList()->end() != it; ++it) - { - LLView* child = *it; - if(DD_HEADER_NAME == child->getName()) - continue; - if(!child->getVisible()) - continue; - - LLRect childRect = child->getRect(); - S32 childWidth = width - getPaddingLeft() - getPaddingRight(); - S32 childHeight = height - getHeaderHeight() - getPaddingTop() - getPaddingBottom(); + if(!mDisplayChildren) + return; - child->reshape(childWidth,childHeight); - - childRect.setLeftTopAndSize( - getPaddingLeft(), - childHeight + getPaddingBottom(), - childWidth, - childHeight); + LLRect childRect; - child->setRect(childRect); - - break;//suppose that there is only one panel - } + childRect.setLeftTopAndSize( + getPaddingLeft(), + height - getHeaderHeight() - getPaddingTop(), + width - getPaddingLeft() - getPaddingRight(), + height - getHeaderHeight() - getPaddingTop() - getPaddingBottom() ); + adjustContainerPanel(childRect); } void LLAccordionCtrlTab::changeOpenClose(bool is_open) @@ -439,7 +434,7 @@ void LLAccordionCtrlTab::setAccordionView(LLView* panel) } -LLView* LLAccordionCtrlTab::getAccordionView() +LLView* LLAccordionCtrlTab::findContainerView() { for(child_list_const_iter_t it = getChildList()->begin(); getChildList()->end() != it; ++it) @@ -474,6 +469,43 @@ void LLAccordionCtrlTab::setHeaderVisible(bool value) BOOL LLAccordionCtrlTab::postBuild() { mHeader->setVisible(mHeaderVisible); + + static LLUICachedControl scrollbar_size ("UIScrollbarSize", 0); + + LLRect scroll_rect; + scroll_rect.setOriginAndSize( + getRect().getWidth() - scrollbar_size, + 1, + scrollbar_size, + getRect().getHeight() - 1); + + mContainerPanel = findContainerView(); + + if(!mFitPanel) + { + LLScrollbar::Params sbparams; + sbparams.name("scrollable vertical"); + sbparams.rect(scroll_rect); + sbparams.orientation(LLScrollbar::VERTICAL); + sbparams.doc_size(getRect().getHeight()); + sbparams.doc_pos(0); + sbparams.page_size(getRect().getHeight()); + sbparams.step_size(VERTICAL_MULTIPLE); + sbparams.follows.flags(FOLLOWS_RIGHT | FOLLOWS_TOP | FOLLOWS_BOTTOM); + sbparams.change_callback(boost::bind(&LLAccordionCtrlTab::onScrollPosChangeCallback, this, _1, _2)); + + + mScrollbar = LLUICtrlFactory::create (sbparams); + LLView::addChild( mScrollbar ); + mScrollbar->setFollowsRight(); + mScrollbar->setFollowsTop(); + mScrollbar->setFollowsBottom(); + + mScrollbar->setVisible(false); + } + + mContainerPanel->setVisible(mDisplayChildren); + return LLUICtrl::postBuild(); } bool LLAccordionCtrlTab::notifyChildren (const LLSD& info) @@ -628,6 +660,7 @@ void LLAccordionCtrlTab::storeOpenCloseState() mStoredOpenCloseState = getDisplayChildren(); mWasStateStored = true; } + void LLAccordionCtrlTab::restoreOpenCloseState() { if(!mWasStateStored) @@ -638,3 +671,195 @@ void LLAccordionCtrlTab::restoreOpenCloseState() } mWasStateStored = false; } + +void LLAccordionCtrlTab::adjustContainerPanel () +{ + S32 width = getRect().getWidth(); + S32 height = getRect().getHeight(); + + LLRect child_rect; + child_rect.setLeftTopAndSize( + getPaddingLeft(), + height - getHeaderHeight() - getPaddingTop(), + width - getPaddingLeft() - getPaddingRight(), + height - getHeaderHeight() - getPaddingTop() - getPaddingBottom() ); + + adjustContainerPanel(child_rect); +} + +void LLAccordionCtrlTab::adjustContainerPanel(const LLRect& child_rect) +{ + if(!mContainerPanel) + return; + + if(!mFitPanel) + { + show_hide_scrollbar(child_rect); + updateLayout(child_rect); + } + else + { + mContainerPanel->reshape(child_rect.getWidth(),child_rect.getHeight()); + mContainerPanel->setRect(child_rect); + } +} + +S32 LLAccordionCtrlTab::getChildViewHeight() +{ + if(!mContainerPanel) + return 0; + return mContainerPanel->getRect().getHeight(); +} + +void LLAccordionCtrlTab::show_hide_scrollbar(const LLRect& child_rect) +{ + if(getChildViewHeight() > child_rect.getHeight() ) + showScrollbar(child_rect); + else + hideScrollbar(child_rect); +} +void LLAccordionCtrlTab::showScrollbar(const LLRect& child_rect) +{ + if(!mContainerPanel || !mScrollbar) + return; + bool was_visible = mScrollbar->getVisible(); + mScrollbar->setVisible(true); + + static LLUICachedControl scrollbar_size ("UIScrollbarSize", 0); + + { + ctrlSetLeftTopAndSize(mScrollbar,child_rect.getWidth()-scrollbar_size, + child_rect.getHeight()-PARENT_BORDER_MARGIN, + scrollbar_size, + child_rect.getHeight()-2*PARENT_BORDER_MARGIN); + } + + LLRect orig_rect = mContainerPanel->getRect(); + + mScrollbar->setPageSize(child_rect.getHeight()); + mScrollbar->setDocParams(orig_rect.getHeight(),mScrollbar->getDocPos()); + + if(was_visible) + { + S32 scroll_pos = llmin(mScrollbar->getDocPos(), orig_rect.getHeight() - child_rect.getHeight() - 1); + mScrollbar->setDocPos(scroll_pos); + } + else//shrink child panel + { + updateLayout(child_rect); + } + +} + +void LLAccordionCtrlTab::hideScrollbar( const LLRect& child_rect ) +{ + if(!mContainerPanel || !mScrollbar) + return; + + if(mScrollbar->getVisible() == false) + return; + mScrollbar->setVisible(false); + mScrollbar->setDocPos(0); + + //shrink child panel + updateLayout(child_rect); +} + +void LLAccordionCtrlTab::onScrollPosChangeCallback(S32, LLScrollbar*) +{ + LLRect child_rect; + + S32 width = getRect().getWidth(); + S32 height = getRect().getHeight(); + + child_rect.setLeftTopAndSize( + getPaddingLeft(), + height - getHeaderHeight() - getPaddingTop(), + width - getPaddingLeft() - getPaddingRight(), + height - getHeaderHeight() - getPaddingTop() - getPaddingBottom() ); + + updateLayout(child_rect); +} + +void LLAccordionCtrlTab::drawChild(const LLRect& root_rect,LLView* child) +{ + if (child && child->getVisible() && child->getRect().isValid()) + { + LLRect screen_rect; + localRectToScreen(child->getRect(),&screen_rect); + + if ( root_rect.overlaps(screen_rect) && LLUI::sDirtyRect.overlaps(screen_rect)) + { + glMatrixMode(GL_MODELVIEW); + LLUI::pushMatrix(); + { + LLUI::translate((F32)child->getRect().mLeft, (F32)child->getRect().mBottom, 0.f); + child->draw(); + + } + LLUI::popMatrix(); + } + } +} + +void LLAccordionCtrlTab::draw() +{ + if(mFitPanel) + LLUICtrl::draw(); + else + { + LLRect root_rect = getRootView()->getRect(); + drawChild(root_rect,mHeader); + drawChild(root_rect,mScrollbar ); + { + LLRect child_rect; + + S32 width = getRect().getWidth(); + S32 height = getRect().getHeight(); + + child_rect.setLeftTopAndSize( + getPaddingLeft(), + height - getHeaderHeight() - getPaddingTop(), + width - getPaddingLeft() - getPaddingRight(), + height - getHeaderHeight() - getPaddingTop() - getPaddingBottom() ); + + LLLocalClipRect clip(child_rect); + drawChild(root_rect,mContainerPanel); + } + + + gGL.getTexUnit(0)->disable(); + } +} + +void LLAccordionCtrlTab::updateLayout ( const LLRect& child_rect ) +{ + LLView* child = getAccordionView(); + if(!mContainerPanel) + return; + + S32 panel_top = child_rect.getHeight(); + S32 panel_width = child_rect.getWidth(); + + static LLUICachedControl scrollbar_size ("UIScrollbarSize", 0); + if(mScrollbar->getVisible() != false) + { + panel_top+=mScrollbar->getDocPos(); + panel_width-=scrollbar_size; + } + + //set sizes for first panels and dragbars + LLRect panel_rect = child->getRect(); + ctrlSetLeftTopAndSize(mContainerPanel,child_rect.mLeft,panel_top,panel_width,panel_rect.getHeight()); +} +void LLAccordionCtrlTab::ctrlSetLeftTopAndSize(LLView* panel, S32 left, S32 top, S32 width, S32 height) +{ + if(!panel) + return; + LLRect panel_rect = panel->getRect(); + panel_rect.setLeftTopAndSize( left, top, width, height); + panel->reshape( width, height, 1); + panel->setRect(panel_rect); +} + + diff --git a/indra/llui/llaccordionctrltab.h b/indra/llui/llaccordionctrltab.h index 2e0260ab16..462ccc6d53 100644 --- a/indra/llui/llaccordionctrltab.h +++ b/indra/llui/llaccordionctrltab.h @@ -41,6 +41,7 @@ class LLUICtrlFactory; class LLUIImage; class LLButton; class LLTextBox; +class LLScrollbar; @@ -84,6 +85,8 @@ public: Optional header_visible; + Optional fit_panel; + Optional padding_left; Optional padding_right; Optional padding_top; @@ -107,7 +110,7 @@ public: //set LLAccordionCtrlTab panel void setAccordionView(LLView* panel); - LLView* getAccordionView(); + LLView* getAccordionView() { return mContainerPanel; }; bool getCollapsible() {return mCollapsible;}; @@ -123,6 +126,8 @@ public: S32 notify(const LLSD& info); bool notifyChildren(const LLSD& info); + void draw(); + void storeOpenCloseState (); void restoreOpenCloseState (); @@ -164,9 +169,26 @@ public: void showAndFocusHeader(); -private: + void setFitPanel( bool fit ) { mFitPanel = true; } - +protected: + void adjustContainerPanel (const LLRect& child_rect); + void adjustContainerPanel (); + S32 getChildViewHeight (); + + void onScrollPosChangeCallback(S32, LLScrollbar*); + + void show_hide_scrollbar (const LLRect& child_rect); + void showScrollbar (const LLRect& child_rect); + void hideScrollbar (const LLRect& child_rect); + + void updateLayout ( const LLRect& child_rect ); + void ctrlSetLeftTopAndSize (LLView* panel, S32 left, S32 top, S32 width, S32 height); + + void drawChild(const LLRect& root_rect,LLView* child); + + LLView* findContainerView (); +private: class LLAccordionCtrlTabHeader; LLAccordionCtrlTabHeader* mHeader; //Header @@ -176,6 +198,7 @@ private: bool mHeaderVisible; bool mCanOpenClose; + bool mFitPanel; S32 mPaddingLeft; S32 mPaddingRight; @@ -185,6 +208,8 @@ private: bool mStoredOpenCloseState; bool mWasStateStored; + LLScrollbar* mScrollbar; + LLView* mContainerPanel; LLUIColor mDropdownBGColor; }; -- cgit v1.2.3 From f75f19be93417081f45438e3c2106bedf201fa8d Mon Sep 17 00:00:00 2001 From: Vadim Savchuk Date: Wed, 3 Mar 2010 16:40:38 +0200 Subject: Fixed bug EXT-4574 ([BSI] Unhelpful tooltip for Partner and Group links in Profile). For wiki-style links ([