From b6858df0dd9fa06ec8fa56c5ba63925a790b4811 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 8 Nov 2011 13:47:08 -0800 Subject: LLHandle is now implicitly convertable to LLHandle and LLHandle can be downcast to LLHandle using the LLHandleProvider mixin --- indra/llui/llbutton.cpp | 2 +- indra/llui/llfloater.cpp | 22 ++++++---------- indra/llui/llfloater.h | 11 ++------ indra/llui/llhandle.h | 67 ++++++++++++++++++++++++++++++------------------ indra/llui/llmenugl.h | 2 +- indra/llui/llpanel.cpp | 2 -- indra/llui/llpanel.h | 3 +-- indra/llui/lluictrl.cpp | 11 ++++---- indra/llui/lluictrl.h | 3 +-- indra/llui/llview.h | 9 ++++--- 10 files changed, 66 insertions(+), 66 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 74b8885e1f..a01dccc7ab 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -115,7 +115,7 @@ LLButton::Params::Params() LLButton::LLButton(const LLButton::Params& p) : LLUICtrl(p), - LLBadgeOwner(LLView::getHandle()), + LLBadgeOwner(getHandle()), mMouseDownFrame(0), mMouseHeldDownCount(0), mBorderEnabled( FALSE ), diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 432397d3e9..07d2e1ed5f 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -111,7 +111,6 @@ LLFloater::click_callback LLFloater::sButtonCallbacks[BUTTON_COUNT] = LLMultiFloater* LLFloater::sHostp = NULL; BOOL LLFloater::sQuitting = FALSE; // Flag to prevent storing visibility controls while quitting -LLFloater::handle_map_t LLFloater::sFloaterMap; LLFloaterView* gFloaterView = NULL; @@ -268,7 +267,6 @@ LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p) mMinimizeSignal(NULL) // mNotificationContext(NULL) { - mHandle.bind(this); // mNotificationContext = new LLFloaterNotificationContext(getHandle()); // Clicks stop here. @@ -323,9 +321,6 @@ void LLFloater::initFloater(const Params& p) // Floaters are created in the invisible state setVisible(FALSE); - // add self to handle->floater map - sFloaterMap[mHandle] = this; - if (!getParent()) { gFloaterView->addChild(this); @@ -532,8 +527,6 @@ LLFloater::~LLFloater() // correct, non-minimized positions. setMinimized( FALSE ); - sFloaterMap.erase(mHandle); - delete mDragHandle; for (S32 i = 0; i < 4; i++) { @@ -1038,7 +1031,9 @@ BOOL LLFloater::canSnapTo(const LLView* other_view) if (other_view != getParent()) { const LLFloater* other_floaterp = dynamic_cast(other_view); - if (other_floaterp && other_floaterp->getSnapTarget() == getHandle() && mDependents.find(other_floaterp->getHandle()) != mDependents.end()) + if (other_floaterp + && other_floaterp->getSnapTarget() == getHandle() + && mDependents.find(other_floaterp->getHandle()) != mDependents.end()) { // this is a dependent that is already snapped to us, so don't snap back to it return FALSE; @@ -1677,18 +1672,17 @@ void LLFloater::onClickHelp( LLFloater* self ) LLFloater* LLFloater::getClosableFloaterFromFocus() { LLFloater* focused_floater = NULL; - - handle_map_iter_t iter; - for(iter = sFloaterMap.begin(); iter != sFloaterMap.end(); ++iter) + LLInstanceTracker::instance_iter it = beginInstances(); + LLInstanceTracker::instance_iter end_it = endInstances(); + for (; it != end_it; ++it) { - focused_floater = iter->second; - if (focused_floater->hasFocus()) + if (it->hasFocus()) { break; } } - if (iter == sFloaterMap.end()) + if (it == endInstances()) { // nothing found, return return NULL; diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 73e9c9e831..b24ae1beb9 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -83,7 +83,7 @@ namespace LLInitParam } -class LLFloater : public LLPanel +class LLFloater : public LLPanel, public LLInstanceTracker { friend class LLFloaterView; friend class LLFloaterReg; @@ -282,7 +282,7 @@ public: void clearSnapTarget() { mSnappedTo.markDead(); } LLHandle getSnapTarget() const { return mSnappedTo; } - LLHandle getHandle() const { return mHandle; } + LLHandle getHandle() const { return getDerivedHandle(); } const LLSD& getKey() { return mKey; } virtual bool matchesKey(const LLSD& key) { return mSingleInstance || KeyCompare::equate(key, mKey); } @@ -460,16 +460,9 @@ private: typedef void(*click_callback)(LLFloater*); static click_callback sButtonCallbacks[BUTTON_COUNT]; - typedef std::map, LLFloater*> handle_map_t; - typedef std::map, LLFloater*>::iterator handle_map_iter_t; - static handle_map_t sFloaterMap; - BOOL mHasBeenDraggedWhileMinimized; S32 mPreviousMinimizedBottom; S32 mPreviousMinimizedLeft; - -// LLFloaterNotificationContext* mNotificationContext; - LLRootHandle mHandle; }; diff --git a/indra/llui/llhandle.h b/indra/llui/llhandle.h index 8c000eee48..c8fff72110 100644 --- a/indra/llui/llhandle.h +++ b/indra/llui/llhandle.h @@ -28,17 +28,18 @@ #define LLHANDLE_H #include "llpointer.h" +#include +#include -template class LLTombStone : public LLRefCount { public: - LLTombStone(T* target = NULL) : mTarget(target) {} + LLTombStone(void* target = NULL) : mTarget(target) {} - void setTarget(T* target) { mTarget = target; } - T* getTarget() const { return mTarget; } + void setTarget(void* target) { mTarget = target; } + void* getTarget() const { return mTarget; } private: - T* mTarget; + mutable void* mTarget; }; // LLHandles are used to refer to objects whose lifetime you do not control or influence. @@ -53,13 +54,15 @@ private: template class LLHandle { + template friend class LLHandle; + template friend class LLHandleProvider; public: LLHandle() : mTombStone(getDefaultTombStone()) {} - const LLHandle& operator =(const LLHandle& other) - { - mTombStone = other.mTombStone; - return *this; - } + + template + LLHandle(const LLHandle& other, typename boost::enable_if< typename boost::is_convertible >::type* dummy = 0) + : mTombStone(other.mTombStone) + {} bool isDead() const { @@ -73,7 +76,7 @@ public: T* get() const { - return mTombStone->getTarget(); + return reinterpret_cast(mTombStone->getTarget()); } friend bool operator== (const LLHandle& lhs, const LLHandle& rhs) @@ -94,12 +97,13 @@ public: } protected: - LLPointer > mTombStone; + LLPointer mTombStone; private: - static LLPointer >& getDefaultTombStone() + typedef T* pointer_t; + static LLPointer& getDefaultTombStone() { - static LLPointer > sDefaultTombStone = new LLTombStone; + static LLPointer sDefaultTombStone = new LLTombStone; return sDefaultTombStone; } }; @@ -108,23 +112,26 @@ template class LLRootHandle : public LLHandle { public: + typedef LLRootHandle self_t; + typedef LLHandle base_t; + LLRootHandle(T* object) { bind(object); } LLRootHandle() {}; ~LLRootHandle() { unbind(); } - // this is redundant, since a LLRootHandle *is* an LLHandle - LLHandle getHandle() { return LLHandle(*this); } + // this is redundant, since an LLRootHandle *is* an LLHandle + //LLHandle getHandle() { return LLHandle(*this); } void bind(T* object) { // unbind existing tombstone if (LLHandle::mTombStone.notNull()) { - if (LLHandle::mTombStone->getTarget() == object) return; + if (LLHandle::mTombStone->getTarget() == (void*)object) return; LLHandle::mTombStone->setTarget(NULL); } // tombstone reference counted, so no paired delete - LLHandle::mTombStone = new LLTombStone(object); + LLHandle::mTombStone = new LLTombStone((void*)object); } void unbind() @@ -142,6 +149,15 @@ private: template class LLHandleProvider { +public: + LLHandle getHandle() const + { + // perform lazy binding to avoid small tombstone allocations for handle + // providers whose handles are never referenced + mHandle.bind(static_cast(const_cast* >(this))); + return mHandle; + } + protected: typedef LLHandle handle_type_t; LLHandleProvider() @@ -149,16 +165,17 @@ protected: // provided here to enforce T deriving from LLHandleProvider } - LLHandle getHandle() - { - // perform lazy binding to avoid small tombstone allocations for handle - // providers whose handles are never referenced - mHandle.bind(static_cast(this)); - return mHandle; + template + typename LLHandle getDerivedHandle(typename boost::enable_if< typename boost::is_convertible >::type* dummy = 0) const + { + LLHandle downcast_handle; + downcast_handle.mTombStone = mHandle.mTombStone; + return downcast_handle; } + private: - LLRootHandle mHandle; + mutable LLRootHandle mHandle; }; #endif diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index bdae899933..36f3ba34b9 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -681,7 +681,7 @@ public: BOOL appendContextSubMenu(LLContextMenu *menu); - LLHandle getHandle() { mHandle.bind(this); return mHandle; } + LLHandle getHandle() { return getDerivedHandle(); } protected: BOOL mHoveredAnyItem; diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index a45b617c2e..00318cec6b 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -122,8 +122,6 @@ LLPanel::LLPanel(const LLPanel::Params& p) { addBorder(p.border); } - - mPanelHandle.bind(this); } LLPanel::~LLPanel() diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index ab1c87caff..cd33938226 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -153,7 +153,7 @@ public: void setCtrlsEnabled(BOOL b); - LLHandle getHandle() const { return mPanelHandle; } + LLHandle getHandle() const { return getDerivedHandle(); } const LLCallbackMap::map_t& getFactoryMap() const { return mFactoryMap; } @@ -278,7 +278,6 @@ private: LLViewBorder* mBorder; LLButton* mDefaultBtn; LLUIString mLabel; - LLRootHandle mPanelHandle; typedef std::map ui_string_map_t; ui_string_map_t mUIStrings; diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index 2fa260ded1..b9c843e931 100644 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -118,7 +118,6 @@ LLUICtrl::LLUICtrl(const LLUICtrl::Params& p, const LLViewModelPtr& viewmodel) mDoubleClickSignal(NULL), mTransparencyType(TT_DEFAULT) { - mUICtrlHandle.bind(this); } void LLUICtrl::initFromParams(const Params& p) @@ -460,7 +459,7 @@ void LLUICtrl::setControlVariable(LLControlVariable* control) if (control) { mControlVariable = control; - mControlConnection = mControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getUICtrlHandle(), std::string("value"))); + mControlConnection = mControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getHandle(), std::string("value"))); setValue(mControlVariable->getValue()); } } @@ -491,7 +490,7 @@ void LLUICtrl::setEnabledControlVariable(LLControlVariable* control) if (control) { mEnabledControlVariable = control; - mEnabledControlConnection = mEnabledControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getUICtrlHandle(), std::string("enabled"))); + mEnabledControlConnection = mEnabledControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getHandle(), std::string("enabled"))); setEnabled(mEnabledControlVariable->getValue().asBoolean()); } } @@ -506,7 +505,7 @@ void LLUICtrl::setDisabledControlVariable(LLControlVariable* control) if (control) { mDisabledControlVariable = control; - mDisabledControlConnection = mDisabledControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getUICtrlHandle(), std::string("disabled"))); + mDisabledControlConnection = mDisabledControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getHandle(), std::string("disabled"))); setEnabled(!(mDisabledControlVariable->getValue().asBoolean())); } } @@ -521,7 +520,7 @@ void LLUICtrl::setMakeVisibleControlVariable(LLControlVariable* control) if (control) { mMakeVisibleControlVariable = control; - mMakeVisibleControlConnection = mMakeVisibleControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getUICtrlHandle(), std::string("visible"))); + mMakeVisibleControlConnection = mMakeVisibleControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getHandle(), std::string("visible"))); setVisible(mMakeVisibleControlVariable->getValue().asBoolean()); } } @@ -536,7 +535,7 @@ void LLUICtrl::setMakeInvisibleControlVariable(LLControlVariable* control) if (control) { mMakeInvisibleControlVariable = control; - mMakeInvisibleControlConnection = mMakeInvisibleControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getUICtrlHandle(), std::string("invisible"))); + mMakeInvisibleControlConnection = mMakeInvisibleControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getHandle(), std::string("invisible"))); setVisible(!(mMakeInvisibleControlVariable->getValue().asBoolean())); } } diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index 3e055a9d06..fb2196bb16 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -223,7 +223,7 @@ public: BOOL focusLastItem(BOOL prefer_text_fields = FALSE); // Non Virtuals - LLHandle getUICtrlHandle() const { return mUICtrlHandle; } + LLHandle getHandle() const { return getDerivedHandle(); } BOOL getIsChrome() const; void setTabStop( BOOL b ); @@ -313,7 +313,6 @@ private: BOOL mRequestsFront; BOOL mTabStop; BOOL mTentative; - LLRootHandle mUICtrlHandle; ETypeTransparency mTransparencyType; diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 08828e55e6..13f118abec 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -97,7 +97,11 @@ private: static std::vector sDrawContextStack; }; -class LLView : public LLMouseHandler, public LLMortician, public LLFocusableElement +class LLView +: public LLMouseHandler, // handles mouse events + public LLFocusableElement, // handles keyboard events + public LLMortician, // lazy deletion + public LLHandleProvider // passes out weak references to self { public: struct Follows : public LLInitParam::ChoiceBlock @@ -306,8 +310,6 @@ public: void popVisible() { setVisible(mLastVisible); } BOOL getLastVisible() const { return mLastVisible; } - LLHandle getHandle() { mHandle.bind(this); return mHandle; } - U32 getFollows() const { return mReshapeFlags; } BOOL followsLeft() const { return mReshapeFlags & FOLLOWS_LEFT; } BOOL followsRight() const { return mReshapeFlags & FOLLOWS_RIGHT; } @@ -606,7 +608,6 @@ private: BOOL mIsFocusRoot; BOOL mUseBoundingRect; // hit test against bounding rectangle that includes all child elements - LLRootHandle mHandle; BOOL mLastVisible; S32 mNextInsertionOrdinal; -- cgit v1.2.3 From 0c9d8d917a4281e2dea7fa2044e86735caca2aa9 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 10 Nov 2011 16:02:57 -0800 Subject: fixed build fixed handle downcast not initiating handle --- indra/llui/llhandle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/llhandle.h b/indra/llui/llhandle.h index c8fff72110..e6390ee599 100644 --- a/indra/llui/llhandle.h +++ b/indra/llui/llhandle.h @@ -169,7 +169,7 @@ protected: typename LLHandle getDerivedHandle(typename boost::enable_if< typename boost::is_convertible >::type* dummy = 0) const { LLHandle downcast_handle; - downcast_handle.mTombStone = mHandle.mTombStone; + downcast_handle.mTombStone = getHandle().mTombStone; return downcast_handle; } -- cgit v1.2.3 From 7d78c63c05579f72dc6998913245d793a2fbd87c Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 10 Nov 2011 17:10:47 -0800 Subject: EXP-1504 : Allow opening of tab in tab containers when drag and dropping things. Added new param to LLButton to handle this (off by default). Refactor lltabcontainer code a bit while at it. --- indra/llui/llbutton.cpp | 28 +++++++++++++ indra/llui/llbutton.h | 7 ++++ indra/llui/lltabcontainer.cpp | 94 ++++++++++++++----------------------------- 3 files changed, 65 insertions(+), 64 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 74b8885e1f..be657dbb9b 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -104,6 +104,7 @@ LLButton::Params::Params() use_draw_context_alpha("use_draw_context_alpha", true), badge("badge"), handle_right_mouse("handle_right_mouse"), + click_on_drag_and_drop("click_on_drag_and_drop", false), held_down_delay("held_down_delay"), button_flash_count("button_flash_count"), button_flash_rate("button_flash_rate") @@ -171,6 +172,7 @@ LLButton::LLButton(const LLButton::Params& p) mHeldDownSignal(NULL), mUseDrawContextAlpha(p.use_draw_context_alpha), mHandleRightMouse(p.handle_right_mouse), + mClickOnDragAndDrop(p.click_on_drag_and_drop), // if true, hovering on button while dragging -> click mButtonFlashCount(p.button_flash_count), mButtonFlashRate(p.button_flash_rate) { @@ -1240,3 +1242,29 @@ BOOL LLButton::handleDoubleClick(S32 x, S32 y, MASK mask) // just treat a double click as a second click return handleMouseDown(x, y, mask); } + +// virtual +BOOL LLButton::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType type, void* cargo_data, EAcceptance *accept, std::string &tooltip) +{ + const F32 CLICK_ON_DAD_DELAY_TIME = 0.5f; + if (mClickOnDragAndDrop) + { + // In that case, though the button doesn't really handles drops, it'll "click" if hovering on it + // while dragging something. That allows for instance drilling into tabbed containers. + // Note: we use the same timer as mouse down just as convenience and to avoid duplication. + if (mMouseDownTimer.getStarted()) + { + if (mMouseDownTimer.getElapsedTimeF32() > CLICK_ON_DAD_DELAY_TIME ) + { + onCommit(); + mMouseDownTimer.stop(); + } + } + else + { + mMouseDownTimer.start(); + } + } + // The true DaD effect is handled at the View level if any. + return LLView::handleDragAndDrop(x, y, mask, drop, type, cargo_data, accept, tooltip); +} diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index deaa0823c6..47aa675c5e 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -132,6 +132,7 @@ public: Optional badge; Optional handle_right_mouse; + Optional click_on_drag_and_drop; Optional button_flash_count; Optional button_flash_rate; @@ -159,6 +160,11 @@ public: virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleRightMouseUp(S32 x, S32 y, MASK mask); virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask); + virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, + EDragAndDropType cargo_type, + void* cargo_data, + EAcceptance* accept, + std::string& tooltip_msg); virtual void draw(); /*virtual*/ BOOL postBuild(); @@ -376,6 +382,7 @@ protected: LLFrameTimer mFlashingTimer; bool mHandleRightMouse; + bool mClickOnDragAndDrop; }; // Build time optimization, generate once in .cpp file diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index ad1f3c504d..3b2751248b 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -1025,85 +1025,51 @@ void LLTabContainer::addTabPanel(const TabPanelParams& panel) } else { + LLButton::Params& p = (mCustomIconCtrlUsed ? custom_btn_params : normal_btn_params); + + p.rect(btn_rect); + p.font(mFont); + p.font_halign = mFontHalign; + p.label(trimmed_label); + p.click_callback.function(boost::bind(&LLTabContainer::onTabBtn, this, _2, child)); + if (indent) + { + p.pad_left(indent); + } + p.pad_bottom( mLabelPadBottom ); + p.scale_image(true); + p.tab_stop(false); + p.label_shadow(false); + p.follows.flags = FOLLOWS_LEFT; + p.click_on_drag_and_drop(true); + if (mIsVertical) { - LLButton::Params& p = (mCustomIconCtrlUsed)? - custom_btn_params:normal_btn_params; - p.name(std::string("vert tab button")); - p.rect(btn_rect); - p.follows.flags(FOLLOWS_TOP | FOLLOWS_LEFT); - p.click_callback.function(boost::bind(&LLTabContainer::onTabBtn, this, _2, child)); - p.font(mFont); - p.label(trimmed_label); p.image_unselected(mMiddleTabParams.tab_left_image_unselected); p.image_selected(mMiddleTabParams.tab_left_image_selected); - p.scale_image(true); - p.font_halign = mFontHalign; - p.pad_bottom( mLabelPadBottom ); - p.tab_stop(false); - p.label_shadow(false); - if (indent) - { - p.pad_left(indent); - } - - - if(mCustomIconCtrlUsed) - { - btn = LLUICtrlFactory::create(custom_btn_params); - - } - else - { - btn = LLUICtrlFactory::create(p); - } + p.follows.flags = p.follows.flags() | FOLLOWS_TOP; } else { - LLButton::Params& p = (mCustomIconCtrlUsed)? - custom_btn_params:normal_btn_params; p.name(std::string(child->getName()) + " tab"); - p.rect(btn_rect); - p.click_callback.function(boost::bind(&LLTabContainer::onTabBtn, this, _2, child)); - p.font(mFont); - p.label(trimmed_label); p.visible(false); - p.scale_image(true); p.image_unselected(tab_img); p.image_selected(tab_selected_img); - p.tab_stop(false); - p.label_shadow(false); + p.follows.flags = p.follows.flags() | (getTabPosition() == TOP ? FOLLOWS_TOP : FOLLOWS_BOTTOM); // Try to squeeze in a bit more text p.pad_left( mLabelPadLeft ); p.pad_right(2); - p.pad_bottom( mLabelPadBottom ); - p.font_halign = mFontHalign; - p.follows.flags = FOLLOWS_LEFT; - p.follows.flags = FOLLOWS_LEFT; - - if (indent) - { - p.pad_left(indent); - } - - if( getTabPosition() == TOP ) - { - p.follows.flags = p.follows.flags() | FOLLOWS_TOP; - } - else - { - p.follows.flags = p.follows.flags() | FOLLOWS_BOTTOM; - } - - if(mCustomIconCtrlUsed) - { - btn = LLUICtrlFactory::create(custom_btn_params); - } - else - { - btn = LLUICtrlFactory::create(p); - } + } + + // *TODO : It seems wrong not to use p in both cases considering the way p is initialized + if (mCustomIconCtrlUsed) + { + btn = LLUICtrlFactory::create(custom_btn_params); + } + else + { + btn = LLUICtrlFactory::create(p); } } -- cgit v1.2.3 From 4afb450225d83fef55bfee2f63290dcfbc3cfbec Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 11 Nov 2011 09:31:07 -0800 Subject: EXP-1504 : Move the tab opening stuff to lltabcontainer and out of llbutton. Added an xui param to allow drill through tabs. Set that param for build panel only. --- indra/llui/llbutton.cpp | 29 -------------- indra/llui/llbutton.h | 7 ---- indra/llui/lltabcontainer.cpp | 93 +++++++++++++++++++++++++------------------ indra/llui/lltabcontainer.h | 6 +++ 4 files changed, 61 insertions(+), 74 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index be657dbb9b..f9e2ad8554 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -104,7 +104,6 @@ LLButton::Params::Params() use_draw_context_alpha("use_draw_context_alpha", true), badge("badge"), handle_right_mouse("handle_right_mouse"), - click_on_drag_and_drop("click_on_drag_and_drop", false), held_down_delay("held_down_delay"), button_flash_count("button_flash_count"), button_flash_rate("button_flash_rate") @@ -172,7 +171,6 @@ LLButton::LLButton(const LLButton::Params& p) mHeldDownSignal(NULL), mUseDrawContextAlpha(p.use_draw_context_alpha), mHandleRightMouse(p.handle_right_mouse), - mClickOnDragAndDrop(p.click_on_drag_and_drop), // if true, hovering on button while dragging -> click mButtonFlashCount(p.button_flash_count), mButtonFlashRate(p.button_flash_rate) { @@ -1236,35 +1234,8 @@ void LLButton::resetMouseDownTimer() mMouseDownTimer.reset(); } - BOOL LLButton::handleDoubleClick(S32 x, S32 y, MASK mask) { // just treat a double click as a second click return handleMouseDown(x, y, mask); } - -// virtual -BOOL LLButton::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType type, void* cargo_data, EAcceptance *accept, std::string &tooltip) -{ - const F32 CLICK_ON_DAD_DELAY_TIME = 0.5f; - if (mClickOnDragAndDrop) - { - // In that case, though the button doesn't really handles drops, it'll "click" if hovering on it - // while dragging something. That allows for instance drilling into tabbed containers. - // Note: we use the same timer as mouse down just as convenience and to avoid duplication. - if (mMouseDownTimer.getStarted()) - { - if (mMouseDownTimer.getElapsedTimeF32() > CLICK_ON_DAD_DELAY_TIME ) - { - onCommit(); - mMouseDownTimer.stop(); - } - } - else - { - mMouseDownTimer.start(); - } - } - // The true DaD effect is handled at the View level if any. - return LLView::handleDragAndDrop(x, y, mask, drop, type, cargo_data, accept, tooltip); -} diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 47aa675c5e..deaa0823c6 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -132,7 +132,6 @@ public: Optional badge; Optional handle_right_mouse; - Optional click_on_drag_and_drop; Optional button_flash_count; Optional button_flash_rate; @@ -160,11 +159,6 @@ public: virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleRightMouseUp(S32 x, S32 y, MASK mask); virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask); - virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, - EDragAndDropType cargo_type, - void* cargo_data, - EAcceptance* accept, - std::string& tooltip_msg); virtual void draw(); /*virtual*/ BOOL postBuild(); @@ -382,7 +376,6 @@ protected: LLFrameTimer mFlashingTimer; bool mHandleRightMouse; - bool mClickOnDragAndDrop; }; // Build time optimization, generate once in .cpp file diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index 3b2751248b..d5f8707381 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -214,6 +214,7 @@ LLTabContainer::Params::Params() middle_tab("middle_tab"), last_tab("last_tab"), use_custom_icon_ctrl("use_custom_icon_ctrl", false), + open_tabs_on_drag_and_drop("open_tabs_on_drag_and_drop", false), tab_icon_ctrl_pad("tab_icon_ctrl_pad", 0), use_ellipses("use_ellipses"), font_halign("halign") @@ -250,6 +251,7 @@ LLTabContainer::LLTabContainer(const LLTabContainer::Params& p) mMiddleTabParams(p.middle_tab), mLastTabParams(p.last_tab), mCustomIconCtrlUsed(p.use_custom_icon_ctrl), + mOpenTabsOnDragAndDrop(p.open_tabs_on_drag_and_drop), mTabIconCtrlPad(p.tab_icon_ctrl_pad), mUseTabEllipses(p.use_ellipses) { @@ -812,50 +814,62 @@ BOOL LLTabContainer::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDrag { BOOL has_scroll_arrows = (getMaxScrollPos() > 0); - if( !getTabsHidden() - && mDragAndDropDelayTimer.getStarted() - && mDragAndDropDelayTimer.getElapsedTimeF32() > SCROLL_DELAY_TIME ) + if(mOpenTabsOnDragAndDrop && !getTabsHidden()) { - if (has_scroll_arrows) + // In that case, we'll open the hovered tab while dragging and dropping items. + // This allows for drilling through tabs. + if (mDragAndDropDelayTimer.getStarted()) { - if (mJumpPrevArrowBtn && mJumpPrevArrowBtn->getRect().pointInRect(x, y)) + if (mDragAndDropDelayTimer.getElapsedTimeF32() > SCROLL_DELAY_TIME) { - S32 local_x = x - mJumpPrevArrowBtn->getRect().mLeft; - S32 local_y = y - mJumpPrevArrowBtn->getRect().mBottom; - mJumpPrevArrowBtn->handleHover(local_x, local_y, mask); - } - if (mJumpNextArrowBtn && mJumpNextArrowBtn->getRect().pointInRect(x, y)) - { - S32 local_x = x - mJumpNextArrowBtn->getRect().mLeft; - S32 local_y = y - mJumpNextArrowBtn->getRect().mBottom; - mJumpNextArrowBtn->handleHover(local_x, local_y, mask); - } - if (mPrevArrowBtn->getRect().pointInRect(x, y)) - { - S32 local_x = x - mPrevArrowBtn->getRect().mLeft; - S32 local_y = y - mPrevArrowBtn->getRect().mBottom; - mPrevArrowBtn->handleHover(local_x, local_y, mask); - } - else if (mNextArrowBtn->getRect().pointInRect(x, y)) - { - S32 local_x = x - mNextArrowBtn->getRect().mLeft; - S32 local_y = y - mNextArrowBtn->getRect().mBottom; - mNextArrowBtn->handleHover(local_x, local_y, mask); - } - } + if (has_scroll_arrows) + { + if (mJumpPrevArrowBtn && mJumpPrevArrowBtn->getRect().pointInRect(x, y)) + { + S32 local_x = x - mJumpPrevArrowBtn->getRect().mLeft; + S32 local_y = y - mJumpPrevArrowBtn->getRect().mBottom; + mJumpPrevArrowBtn->handleHover(local_x, local_y, mask); + } + if (mJumpNextArrowBtn && mJumpNextArrowBtn->getRect().pointInRect(x, y)) + { + S32 local_x = x - mJumpNextArrowBtn->getRect().mLeft; + S32 local_y = y - mJumpNextArrowBtn->getRect().mBottom; + mJumpNextArrowBtn->handleHover(local_x, local_y, mask); + } + if (mPrevArrowBtn->getRect().pointInRect(x, y)) + { + S32 local_x = x - mPrevArrowBtn->getRect().mLeft; + S32 local_y = y - mPrevArrowBtn->getRect().mBottom; + mPrevArrowBtn->handleHover(local_x, local_y, mask); + } + else if (mNextArrowBtn->getRect().pointInRect(x, y)) + { + S32 local_x = x - mNextArrowBtn->getRect().mLeft; + S32 local_y = y - mNextArrowBtn->getRect().mBottom; + mNextArrowBtn->handleHover(local_x, local_y, mask); + } + } - for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter) - { - LLTabTuple* tuple = *iter; - tuple->mButton->setVisible( TRUE ); - S32 local_x = x - tuple->mButton->getRect().mLeft; - S32 local_y = y - tuple->mButton->getRect().mBottom; - if (tuple->mButton->pointInView(local_x, local_y) && tuple->mButton->getEnabled() && !tuple->mTabPanel->getVisible()) - { - tuple->mButton->onCommit(); + for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter) + { + LLTabTuple* tuple = *iter; + tuple->mButton->setVisible( TRUE ); + S32 local_x = x - tuple->mButton->getRect().mLeft; + S32 local_y = y - tuple->mButton->getRect().mBottom; + if (tuple->mButton->pointInView(local_x, local_y) && tuple->mButton->getEnabled() && !tuple->mTabPanel->getVisible()) + { + tuple->mButton->onCommit(); + } + } + // Stop the timer whether successful or not. Don't let it run forever. mDragAndDropDelayTimer.stop(); } } + else + { + // Start a timer so we don't open tabs as soon as we hover on them + mDragAndDropDelayTimer.start(); + } } return LLView::handleDragAndDrop(x, y, mask, drop, type, cargo_data, accept, tooltip); @@ -1041,7 +1055,6 @@ void LLTabContainer::addTabPanel(const TabPanelParams& panel) p.tab_stop(false); p.label_shadow(false); p.follows.flags = FOLLOWS_LEFT; - p.click_on_drag_and_drop(true); if (mIsVertical) { @@ -1246,6 +1259,10 @@ void LLTabContainer::enableTabButton(S32 which, BOOL enable) { mTabList[which]->mButton->setEnabled(enable); } + // Stop the DaD timer as it might run forever + // enableTabButton() is typically called on refresh and draw when anything changed + // in the tab container so it's a good time to reset that. + mDragAndDropDelayTimer.stop(); } void LLTabContainer::deleteAllTabs() diff --git a/indra/llui/lltabcontainer.h b/indra/llui/lltabcontainer.h index eaa2fd54e0..cebace2ceb 100644 --- a/indra/llui/lltabcontainer.h +++ b/indra/llui/lltabcontainer.h @@ -104,6 +104,11 @@ public: */ Optional use_custom_icon_ctrl; + /** + * Open tabs on hover in drag and drop situations + */ + Optional open_tabs_on_drag_and_drop; + /** * Paddings for LLIconCtrl in case of LLCustomButtonIconCtrl usage(use_custom_icon_ctrl = true) */ @@ -300,6 +305,7 @@ private: TabParams mLastTabParams; bool mCustomIconCtrlUsed; + bool mOpenTabsOnDragAndDrop; S32 mTabIconCtrlPad; bool mUseTabEllipses; }; -- cgit v1.2.3 From 98755a62bb414f23919e003101153c20d3ab3f72 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 14 Nov 2011 15:39:32 -0800 Subject: EXP-1588 WIP Floaters do not snap to edge --- indra/llui/llfloater.cpp | 66 +++++++++++++++++++++++------------------------- indra/llui/llfloater.h | 1 + 2 files changed, 32 insertions(+), 35 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 432397d3e9..05bd7fb67f 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -58,6 +58,8 @@ #include "llhelp.h" #include "llmultifloater.h" #include "llsdutil.h" +#include + // use this to control "jumping" behavior when Ctrl-Tabbing const S32 TABBED_FLOATER_OFFSET = 0; @@ -2163,8 +2165,15 @@ LLFloaterView::LLFloaterView (const Params& p) // By default, adjust vertical. void LLFloaterView::reshape(S32 width, S32 height, BOOL called_from_parent) { - S32 old_width = getRect().getWidth(); - S32 old_height = getRect().getHeight(); + S32 old_right = mLastSnapRect.mRight; + S32 old_top = mLastSnapRect.mTop; + + LLView::reshape(width, height, called_from_parent); + + S32 new_right = getSnapRect().mRight; + S32 new_top = getSnapRect().mTop; + + mLastSnapRect = getSnapRect(); for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) { @@ -2179,59 +2188,40 @@ void LLFloaterView::reshape(S32 width, S32 height, BOOL called_from_parent) // Make if follow the edge it is closest to U32 follow_flags = 0x0; - if (floaterp->isMinimized()) - { - follow_flags |= (FOLLOWS_LEFT | FOLLOWS_TOP); - } - else + if (!floaterp->isMinimized()) { LLRect r = floaterp->getRect(); // Compute absolute distance from each edge of screen S32 left_offset = llabs(r.mLeft - 0); - S32 right_offset = llabs(old_width - r.mRight); + S32 right_offset = llabs(old_right - r.mRight); - S32 top_offset = llabs(old_height - r.mTop); + S32 top_offset = llabs(old_top - r.mTop); S32 bottom_offset = llabs(r.mBottom - 0); + S32 translate_x = 0; + S32 translate_y = 0; - if (left_offset < right_offset) - { - follow_flags |= FOLLOWS_LEFT; - } - else + if (left_offset > right_offset) { - follow_flags |= FOLLOWS_RIGHT; + translate_x = new_right - old_right; } - // "No vertical adjustment" usually means that the bottom of the view - // has been pushed up or down. Hence we want the floaters to follow - // the top. if (top_offset < bottom_offset) { - follow_flags |= FOLLOWS_TOP; - } - else - { - follow_flags |= FOLLOWS_BOTTOM; + translate_y = new_top - old_top; } - } - floaterp->setFollows(follow_flags); - - //RN: all dependent floaters copy follow behavior of "parent" - for(LLFloater::handle_set_iter_t dependent_it = floaterp->mDependents.begin(); - dependent_it != floaterp->mDependents.end(); ++dependent_it) - { - LLFloater* dependent_floaterp = dependent_it->get(); - if (dependent_floaterp) + floaterp->translate(translate_x, translate_y); + BOOST_FOREACH(LLHandle dependent_floater, floaterp->mDependents) { - dependent_floaterp->setFollows(follow_flags); + if (dependent_floater.get()) + { + dependent_floater.get()->translate(translate_x, translate_y); + } } } } - - LLView::reshape(width, height, called_from_parent); } @@ -2631,6 +2621,12 @@ void LLFloaterView::shiftFloaters(S32 x_offset, S32 y_offset) void LLFloaterView::refresh() { + LLRect snap_rect = getSnapRect(); + if (snap_rect != mLastSnapRect) + { + reshape(getRect().getWidth(), getRect().getHeight(), TRUE); + } + // Constrain children to be entirely on the screen for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) { diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 73e9c9e831..4e8c539144 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -537,6 +537,7 @@ public: private: void hiddenFloaterClosed(LLFloater* floater); + LLRect mLastSnapRect; LLHandle mSnapView; BOOL mFocusCycleMode; S32 mSnapOffsetBottom; -- cgit v1.2.3 From 28db67c3952f65d9c3ee23ce85851ba8ab29fc50 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Mon, 14 Nov 2011 17:16:34 -0800 Subject: Removed unused variable to fix the mac build --- indra/llui/llfloater.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 05bd7fb67f..c5d7d1db56 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -2185,9 +2185,6 @@ void LLFloaterView::reshape(S32 width, S32 height, BOOL called_from_parent) continue; } - // Make if follow the edge it is closest to - U32 follow_flags = 0x0; - if (!floaterp->isMinimized()) { LLRect r = floaterp->getRect(); -- cgit v1.2.3 From 30beda590a93aca9b2a27edb9be94665290c2e7c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 15 Nov 2011 16:40:31 -0800 Subject: EXP-1588 FIX Floaters do not snap to edge made non-movable floaters not use auto-follow logic toasts will now use own layout logic --- indra/llui/llfloater.cpp | 14 ++++++++++++-- indra/llui/llfloater.h | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index c5d7d1db56..a5fd3ea552 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -1951,6 +1951,12 @@ void LLFloater::setCanDrag(BOOL can_drag) } } +bool LLFloater::getCanDrag() +{ + return mDragHandle->getEnabled(); +} + + void LLFloater::updateTitleButtons() { static LLUICachedControl floater_close_box_size ("UIFloaterCloseBoxSize", 0); @@ -2181,7 +2187,7 @@ void LLFloaterView::reshape(S32 width, S32 height, BOOL called_from_parent) LLFloater* floaterp = (LLFloater*)viewp; if (floaterp->isDependent()) { - // dependents use same follow flags as their "dependee" + // dependents are moved with their "dependee" continue; } @@ -2209,7 +2215,11 @@ void LLFloaterView::reshape(S32 width, S32 height, BOOL called_from_parent) translate_y = new_top - old_top; } - floaterp->translate(translate_x, translate_y); + // don't reposition immovable floaters + if (floaterp->getCanDrag()) + { + floaterp->translate(translate_x, translate_y); + } BOOST_FOREACH(LLHandle dependent_floater, floaterp->mDependents) { if (dependent_floater.get()) diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 4e8c539144..8886ae3393 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -234,6 +234,7 @@ public: void setCanTearOff(BOOL can_tear_off); virtual void setCanResize(BOOL can_resize); void setCanDrag(BOOL can_drag); + bool getCanDrag(); void setHost(LLMultiFloater* host); BOOL isResizable() const { return mResizable; } void setResizeLimits( S32 min_width, S32 min_height ); -- cgit v1.2.3 From 700277e00aa83506808f2128705143d7ae4937bd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 28 Nov 2011 22:30:12 -0800 Subject: removed unneeded changeversion tracking in param blocks in favor of a simpler dirty bit --- indra/llui/tests/llurlentry_stub.cpp | 3 --- indra/llui/tests/llurlmatch_test.cpp | 5 ----- 2 files changed, 8 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/tests/llurlentry_stub.cpp b/indra/llui/tests/llurlentry_stub.cpp index 4f251db93b..c75df86891 100644 --- a/indra/llui/tests/llurlentry_stub.cpp +++ b/indra/llui/tests/llurlentry_stub.cpp @@ -105,8 +105,6 @@ LLStyle::Params::Params() namespace LLInitParam { - BaseBlock::BaseBlock() {} - BaseBlock::~BaseBlock() {} Param::Param(BaseBlock* enclosing_block) : mIsProvided(false) { @@ -114,7 +112,6 @@ namespace LLInitParam const U8* block_addr = reinterpret_cast(enclosing_block); mEnclosingBlockOffset = (U16)(my_addr - block_addr); } - void BaseBlock::paramChanged(const Param& last_param, bool user_provided) {} void BaseBlock::addParam(BlockDescriptor& block_data, const ParamDescriptorPtr in_param, const char* char_name){} void BaseBlock::addSynonym(Param& param, const std::string& synonym) {} diff --git a/indra/llui/tests/llurlmatch_test.cpp b/indra/llui/tests/llurlmatch_test.cpp index 627f3129e9..7183413463 100644 --- a/indra/llui/tests/llurlmatch_test.cpp +++ b/indra/llui/tests/llurlmatch_test.cpp @@ -63,9 +63,6 @@ S32 LLUIImage::getHeight() const namespace LLInitParam { - BaseBlock::BaseBlock() {} - BaseBlock::~BaseBlock() {} - BlockDescriptor::BlockDescriptor() {} ParamDescriptor::ParamDescriptor(param_handle_t p, merge_func_t merge_func, @@ -77,8 +74,6 @@ namespace LLInitParam S32 max_count){} ParamDescriptor::~ParamDescriptor() {} - void BaseBlock::paramChanged(const Param& last_param, bool user_provided) {} - void BaseBlock::addParam(BlockDescriptor& block_data, const ParamDescriptorPtr in_param, const char* char_name){} param_handle_t BaseBlock::getHandleFromParam(const Param* param) const {return 0;} void BaseBlock::addSynonym(Param& param, const std::string& synonym) {} -- cgit v1.2.3