diff options
author | Tofu Linden <tofu.linden@lindenlab.com> | 2009-11-25 10:49:49 +0000 |
---|---|---|
committer | Tofu Linden <tofu.linden@lindenlab.com> | 2009-11-25 10:49:49 +0000 |
commit | 664b848bac30a7f3f1177a683e0913c9457dc041 (patch) | |
tree | b284602f6911e31d5ef687e1c06b343ef83627e1 /indra/llui | |
parent | 6f4099e413d41ba56a5a339122050122363ca952 (diff) | |
parent | 41eb231e6a41da13549e5cbd4cfe6f5efeab74b1 (diff) |
merge from trunk.
Diffstat (limited to 'indra/llui')
29 files changed, 487 insertions, 140 deletions
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index b65f248db2..8930e32055 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -147,7 +147,11 @@ LLButton::LLButton(const LLButton::Params& p) mCommitOnReturn(p.commit_on_return), mFadeWhenDisabled(FALSE), mForcePressedState(false), - mLastDrawCharsCount(0) + mLastDrawCharsCount(0), + mMouseDownSignal(NULL), + mMouseUpSignal(NULL), + mHeldDownSignal(NULL) + { static LLUICachedControl<S32> llbutton_orig_h_pad ("UIButtonOrigHPad", 0); static Params default_params(LLUICtrlFactory::getDefaultParams<LLButton>()); @@ -215,13 +219,28 @@ LLButton::LLButton(const LLButton::Params& p) } if (p.click_callback.isProvided()) - initCommitCallback(p.click_callback, mCommitSignal); // alias -> commit_callback + { + setCommitCallback(initCommitCallback(p.click_callback)); // alias -> commit_callback + } if (p.mouse_down_callback.isProvided()) - initCommitCallback(p.mouse_down_callback, mMouseDownSignal); + { + setMouseDownCallback(initCommitCallback(p.mouse_down_callback)); + } if (p.mouse_up_callback.isProvided()) - initCommitCallback(p.mouse_up_callback, mMouseUpSignal); + { + setMouseUpCallback(initCommitCallback(p.mouse_up_callback)); + } if (p.mouse_held_callback.isProvided()) - initCommitCallback(p.mouse_held_callback, mHeldDownSignal); + { + setHeldDownCallback(initCommitCallback(p.mouse_held_callback)); + } +} + +LLButton::~LLButton() +{ + delete mMouseDownSignal; + delete mMouseUpSignal; + delete mHeldDownSignal; } // HACK: Committing a button is the same as instantly clicking it. @@ -232,9 +251,9 @@ void LLButton::onCommit() // panel containing it. Therefore we need to call LLUICtrl::onCommit() // LAST, otherwise this becomes deleted memory. - mMouseDownSignal(this, LLSD()); + if (mMouseDownSignal) (*mMouseDownSignal)(this, LLSD()); - mMouseUpSignal(this, LLSD()); + if (mMouseUpSignal) (*mMouseUpSignal)(this, LLSD()); if (getSoundFlags() & MOUSE_DOWN) { @@ -257,19 +276,23 @@ void LLButton::onCommit() boost::signals2::connection LLButton::setClickedCallback( const commit_signal_t::slot_type& cb ) { - return mCommitSignal.connect(cb); + if (!mCommitSignal) mCommitSignal = new commit_signal_t(); + return mCommitSignal->connect(cb); } boost::signals2::connection LLButton::setMouseDownCallback( const commit_signal_t::slot_type& cb ) { - return mMouseDownSignal.connect(cb); + if (!mMouseDownSignal) mMouseDownSignal = new commit_signal_t(); + return mMouseDownSignal->connect(cb); } boost::signals2::connection LLButton::setMouseUpCallback( const commit_signal_t::slot_type& cb ) { - return mMouseUpSignal.connect(cb); + if (!mMouseUpSignal) mMouseUpSignal = new commit_signal_t(); + return mMouseUpSignal->connect(cb); } boost::signals2::connection LLButton::setHeldDownCallback( const commit_signal_t::slot_type& cb ) { - return mHeldDownSignal.connect(cb); + if (!mHeldDownSignal) mHeldDownSignal = new commit_signal_t(); + return mHeldDownSignal->connect(cb); } @@ -351,7 +374,7 @@ BOOL LLButton::handleMouseDown(S32 x, S32 y, MASK mask) */ LLUICtrl::handleMouseDown(x, y, mask); - mMouseDownSignal(this, LLSD()); + if(mMouseDownSignal) (*mMouseDownSignal)(this, LLSD()); mMouseDownTimer.start(); mMouseDownFrame = (S32) LLFrameTimer::getFrameCount(); @@ -383,7 +406,7 @@ BOOL LLButton::handleMouseUp(S32 x, S32 y, MASK mask) LLUICtrl::handleMouseUp(x, y, mask); // Regardless of where mouseup occurs, handle callback - mMouseUpSignal(this, LLSD()); + if(mMouseUpSignal) (*mMouseUpSignal)(this, LLSD()); resetMouseDownTimer(); @@ -493,7 +516,7 @@ BOOL LLButton::handleHover(S32 x, S32 y, MASK mask) { LLSD param; param["count"] = mMouseHeldDownCount++; - mHeldDownSignal(this, param); + if (mHeldDownSignal) (*mHeldDownSignal)(this, param); } } diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 3c1b57c4be..8c3b4bd859 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -128,6 +128,8 @@ protected: LLButton(const Params&); public: + + ~LLButton(); // For backward compatability only typedef boost::function<void(void*)> button_callback_t; @@ -251,9 +253,9 @@ private: void resetMouseDownTimer(); private: - commit_signal_t mMouseDownSignal; - commit_signal_t mMouseUpSignal; - commit_signal_t mHeldDownSignal; + commit_signal_t* mMouseDownSignal; + commit_signal_t* mMouseUpSignal; + commit_signal_t* mHeldDownSignal; const LLFontGL* mGLFont; diff --git a/indra/llui/llconsole.cpp b/indra/llui/llconsole.cpp index 48c76cf105..fa0abd55d0 100644 --- a/indra/llui/llconsole.cpp +++ b/indra/llui/llconsole.cpp @@ -392,9 +392,4 @@ void LLConsole::addLine(const LLWString& wline, F32 size, const LLColor4 &color) Paragraph paragraph(wline, color, mTimer.getElapsedTimeF32(), mFont, (F32)getRect().getWidth() ); mParagraphs.push_back ( paragraph ); - -#if LL_WINDOWS && LL_LCD_COMPILE - // add to LCD screen - AddNewDebugConsoleToLCD(wline); -#endif } diff --git a/indra/llui/llflatlistview.h b/indra/llui/llflatlistview.h index eac947a0d7..3867e910c0 100644 --- a/indra/llui/llflatlistview.h +++ b/indra/llui/llflatlistview.h @@ -50,7 +50,7 @@ class LLTextBox; * is ignored. The option "keep_one_selected" forces at least one item to be selected at any time (only for mouse events on items) * since any item of the list was selected. * - * Examples of using this control are presented in Picks panel (Me Profile and Profile View), where this control is used to + * Examples of using this control are presented in Picks panel (My Profile and Profile View), where this control is used to * manage the list of pick items. * * ASSUMPTIONS AND STUFF diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index bf965e8e28..262afbe661 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -2642,10 +2642,14 @@ void LLFloater::initFromParams(const LLFloater::Params& p) // open callback if (p.open_callback.isProvided()) - initCommitCallback(p.open_callback, mOpenSignal); + { + mOpenSignal.connect(initCommitCallback(p.open_callback)); + } // close callback if (p.close_callback.isProvided()) - initCommitCallback(p.close_callback, mCloseSignal); + { + mCloseSignal.connect(initCommitCallback(p.close_callback)); + } } LLFastTimer::DeclareTimer POST_BUILD("Floater Post Build"); diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 95c8dd84f6..1b98dddddc 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -195,6 +195,7 @@ public: /// The static isShown() can accept a NULL pointer (which of course /// returns false). When non-NULL, it calls the non-static isShown(). static bool isShown(const LLFloater* floater); + BOOL isFirstLook() { return mFirstLook; } // EXT-2653: This function is necessary to prevent overlapping for secondary showed toasts BOOL isFrontmost(); BOOL isDependent() { return !mDependeeHandle.isDead(); } void setCanMinimize(BOOL can_minimize); diff --git a/indra/llui/llfocusmgr.cpp b/indra/llui/llfocusmgr.cpp index 00a80478cf..35fbc7b0a8 100644 --- a/indra/llui/llfocusmgr.cpp +++ b/indra/llui/llfocusmgr.cpp @@ -41,6 +41,10 @@ const F32 FOCUS_FADE_TIME = 0.3f; // NOTE: the LLFocusableElement implementation has been moved here from lluictrl.cpp. LLFocusableElement::LLFocusableElement() +: mFocusLostCallback(NULL), + mFocusReceivedCallback(NULL), + mFocusChangedCallback(NULL), + mTopLostCallback(NULL) { } @@ -59,23 +63,27 @@ BOOL LLFocusableElement::handleUnicodeChar(llwchar uni_char, BOOL called_from_pa // virtual LLFocusableElement::~LLFocusableElement() { + delete mFocusLostCallback; + delete mFocusReceivedCallback; + delete mFocusChangedCallback; + delete mTopLostCallback; } void LLFocusableElement::onFocusReceived() { - mFocusReceivedCallback(this); - mFocusChangedCallback(this); + if (mFocusReceivedCallback) (*mFocusReceivedCallback)(this); + if (mFocusChangedCallback) (*mFocusChangedCallback)(this); } void LLFocusableElement::onFocusLost() { - mFocusLostCallback(this); - mFocusChangedCallback(this); + if (mFocusLostCallback) (*mFocusLostCallback)(this); + if (mFocusChangedCallback) (*mFocusChangedCallback)(this); } void LLFocusableElement::onTopLost() { - mTopLostCallback(this); + if (mTopLostCallback) (*mTopLostCallback)(this); } BOOL LLFocusableElement::hasFocus() const @@ -87,6 +95,31 @@ void LLFocusableElement::setFocus(BOOL b) { } +boost::signals2::connection LLFocusableElement::setFocusLostCallback( const focus_signal_t::slot_type& cb) +{ + if (!mFocusLostCallback) mFocusLostCallback = new focus_signal_t(); + return mFocusLostCallback->connect(cb); +} + +boost::signals2::connection LLFocusableElement::setFocusReceivedCallback(const focus_signal_t::slot_type& cb) +{ + if (!mFocusReceivedCallback) mFocusReceivedCallback = new focus_signal_t(); + return mFocusReceivedCallback->connect(cb); +} + +boost::signals2::connection LLFocusableElement::setFocusChangedCallback(const focus_signal_t::slot_type& cb) +{ + if (!mFocusChangedCallback) mFocusChangedCallback = new focus_signal_t(); + return mFocusChangedCallback->connect(cb); +} + +boost::signals2::connection LLFocusableElement::setTopLostCallback(const focus_signal_t::slot_type& cb) +{ + if (!mTopLostCallback) mTopLostCallback = new focus_signal_t(); + return mTopLostCallback->connect(cb); +} + + LLFocusMgr gFocusMgr; diff --git a/indra/llui/llfocusmgr.h b/indra/llui/llfocusmgr.h index 2fa4e124fb..83ecd1d301 100644 --- a/indra/llui/llfocusmgr.h +++ b/indra/llui/llfocusmgr.h @@ -56,10 +56,10 @@ public: typedef boost::signals2::signal<void(LLFocusableElement*)> focus_signal_t; - boost::signals2::connection setFocusLostCallback( const focus_signal_t::slot_type& cb) { return mFocusLostCallback.connect(cb);} - boost::signals2::connection setFocusReceivedCallback(const focus_signal_t::slot_type& cb) { return mFocusReceivedCallback.connect(cb);} - boost::signals2::connection setFocusChangedCallback(const focus_signal_t::slot_type& cb) { return mFocusChangedCallback.connect(cb);} - void setTopLostCallback(const focus_signal_t::slot_type& cb) { mTopLostCallback.connect(cb);} + boost::signals2::connection setFocusLostCallback( const focus_signal_t::slot_type& cb); + boost::signals2::connection setFocusReceivedCallback(const focus_signal_t::slot_type& cb); + boost::signals2::connection setFocusChangedCallback(const focus_signal_t::slot_type& cb); + boost::signals2::connection setTopLostCallback(const focus_signal_t::slot_type& cb); // These were brought up the hierarchy from LLView so that we don't have to use dynamic_cast when dealing with keyboard focus. virtual BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent); @@ -69,10 +69,10 @@ protected: virtual void onFocusReceived(); virtual void onFocusLost(); virtual void onTopLost(); // called when registered as top ctrl and user clicks elsewhere - focus_signal_t mFocusLostCallback; - focus_signal_t mFocusReceivedCallback; - focus_signal_t mFocusChangedCallback; - focus_signal_t mTopLostCallback; + focus_signal_t* mFocusLostCallback; + focus_signal_t* mFocusReceivedCallback; + focus_signal_t* mFocusChangedCallback; + focus_signal_t* mTopLostCallback; }; diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index c2f91ff7e0..bd5734312a 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -323,6 +323,19 @@ void LLLineEditor::setMaxTextLength(S32 max_text_length) mMaxLengthBytes = max_len; } +void LLLineEditor::getTextPadding(S32 *left, S32 *right) +{ + *left = mTextPadLeft; + *right = mTextPadRight; +} + +void LLLineEditor::setTextPadding(S32 left, S32 right) +{ + mTextPadLeft = left; + mTextPadRight = right; + updateTextPadding(); +} + void LLLineEditor::updateTextPadding() { static LLUICachedControl<S32> line_editor_hpad ("UILineEditorHPad", 0); @@ -626,7 +639,8 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask) // delay cursor flashing mKeystrokeTimer.reset(); - mMouseDownSignal(this,x,y,mask); + if (mMouseDownSignal) + (*mMouseDownSignal)(this,x,y,mask); return TRUE; } @@ -742,7 +756,8 @@ BOOL LLLineEditor::handleMouseUp(S32 x, S32 y, MASK mask) } // We won't call LLUICtrl::handleMouseUp to avoid double calls of childrenHandleMouseUp().Just invoke the signal manually. - mMouseUpSignal(this,x,y, mask); + if (mMouseUpSignal) + (*mMouseUpSignal)(this,x,y, mask); return handled; } diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index 4474963b1a..4c4b00094d 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -226,6 +226,9 @@ public: void setKeystrokeCallback(callback_t callback, void* user_data); void setMaxTextLength(S32 max_text_length); + // Manipulate left and right padding for text + void getTextPadding(S32 *left, S32 *right); + void setTextPadding(S32 left, S32 right); // Prevalidation controls which keystrokes can affect the editor void setPrevalidate( LLLinePrevalidateFunc func ); diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index de9a854f63..f8935d03ac 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -760,21 +760,25 @@ void LLMenuItemCallGL::initFromParams(const Params& p) { if (p.on_visible.isProvided()) { - initVisibleCallback(p.on_visible, mVisibleSignal); + mVisibleSignal.connect(initVisibleCallback(p.on_visible)); } if (p.on_enable.isProvided()) { - initEnableCallback(p.on_enable, mEnableSignal); + setEnableCallback(initEnableCallback(p.on_enable)); // Set the enabled control variable (for backwards compatability) if (p.on_enable.control_name.isProvided() && !p.on_enable.control_name().empty()) { LLControlVariable* control = findControl(p.on_enable.control_name()); if (control) + { setEnabledControlVariable(control); + } } } if (p.on_click.isProvided()) - initCommitCallback(p.on_click, mCommitSignal); + { + setCommitCallback(initCommitCallback(p.on_click)); + } LLUICtrl::initFromParams(p); } @@ -795,7 +799,10 @@ void LLMenuItemCallGL::updateEnabled( void ) if (mEnabledControlVariable) { if (!enabled) - mEnabledControlVariable->set(false); // callback overrides control variable; this will call setEnabled() + { + // callback overrides control variable; this will call setEnabled() + mEnabledControlVariable->set(false); + } } else { @@ -854,7 +861,7 @@ void LLMenuItemCheckGL::initFromParams(const Params& p) { if (p.on_check.isProvided()) { - initEnableCallback(p.on_check, mCheckSignal); + setCheckCallback(initEnableCallback(p.on_check)); // Set the control name (for backwards compatability) if (p.on_check.control_name.isProvided() && !p.on_check.control_name().empty()) { diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index 68e496aed1..1891bca36c 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -84,17 +84,30 @@ LLMultiSlider::LLMultiSlider(const LLMultiSlider::Params& p) mThumbCenterSelectedColor(p.thumb_center_selected_color()), mDisabledThumbColor(p.thumb_disabled_color()), mTriangleColor(p.triangle_color()), - mThumbWidth(p.thumb_width) + mThumbWidth(p.thumb_width), + mMouseDownSignal(NULL), + mMouseUpSignal(NULL) { mValue.emptyMap(); mCurSlider = LLStringUtil::null; if (p.mouse_down_callback.isProvided()) - initCommitCallback(p.mouse_down_callback, mMouseDownSignal); + { + setMouseDownCallback(initCommitCallback(p.mouse_down_callback)); + } if (p.mouse_up_callback.isProvided()) - initCommitCallback(p.mouse_up_callback, mMouseUpSignal); + { + setMouseUpCallback(initCommitCallback(p.mouse_up_callback)); + } +} + +LLMultiSlider::~LLMultiSlider() +{ + delete mMouseDownSignal; + delete mMouseUpSignal; } + void LLMultiSlider::setSliderValue(const std::string& name, F32 value, BOOL from_event) { // exit if not there @@ -325,7 +338,8 @@ BOOL LLMultiSlider::handleMouseUp(S32 x, S32 y, MASK mask) { gFocusMgr.setMouseCapture( NULL ); - mMouseUpSignal( this, LLSD() ); + if (mMouseUpSignal) + (*mMouseUpSignal)( this, LLSD() ); handled = TRUE; make_ui_sound("UISndClickRelease"); @@ -345,7 +359,8 @@ BOOL LLMultiSlider::handleMouseDown(S32 x, S32 y, MASK mask) { setFocus(TRUE); } - mMouseDownSignal( this, LLSD() ); + if (mMouseDownSignal) + (*mMouseDownSignal)( this, LLSD() ); if (MASK_CONTROL & mask) // if CTRL is modifying { @@ -557,3 +572,15 @@ void LLMultiSlider::draw() LLF32UICtrl::draw(); } + +boost::signals2::connection LLMultiSlider::setMouseDownCallback( const commit_signal_t::slot_type& cb ) +{ + if (!mMouseDownSignal) mMouseDownSignal = new commit_signal_t(); + return mMouseDownSignal->connect(cb); +} + +boost::signals2::connection LLMultiSlider::setMouseUpCallback( const commit_signal_t::slot_type& cb ) +{ + if (!mMouseUpSignal) mMouseUpSignal = new commit_signal_t(); + return mMouseUpSignal->connect(cb); +} diff --git a/indra/llui/llmultislider.h b/indra/llui/llmultislider.h index da633cc1cd..f8e43a0470 100644 --- a/indra/llui/llmultislider.h +++ b/indra/llui/llmultislider.h @@ -67,6 +67,7 @@ protected: LLMultiSlider(const Params&); friend class LLUICtrlFactory; public: + virtual ~LLMultiSlider(); void setSliderValue(const std::string& name, F32 value, BOOL from_event = FALSE); F32 getSliderValue(const std::string& name) const; @@ -78,8 +79,8 @@ public: /*virtual*/ void setValue(const LLSD& value); /*virtual*/ LLSD getValue() const { return mValue; } - boost::signals2::connection setMouseDownCallback( const commit_signal_t::slot_type& cb ) { return mMouseDownSignal.connect(cb); } - boost::signals2::connection setMouseUpCallback( const commit_signal_t::slot_type& cb ) { return mMouseUpSignal.connect(cb); } + boost::signals2::connection setMouseDownCallback( const commit_signal_t::slot_type& cb ); + boost::signals2::connection setMouseUpCallback( const commit_signal_t::slot_type& cb ); bool findUnusedValue(F32& initVal); const std::string& addSlider(); @@ -116,8 +117,8 @@ protected: LLUIColor mDisabledThumbColor; LLUIColor mTriangleColor; - commit_signal_t mMouseDownSignal; - commit_signal_t mMouseUpSignal; + commit_signal_t* mMouseDownSignal; + commit_signal_t* mMouseUpSignal; }; #endif // LL_MULTI_SLIDER_H diff --git a/indra/llui/llmultisliderctrl.cpp b/indra/llui/llmultisliderctrl.cpp index a9f462173d..87938c19d4 100644 --- a/indra/llui/llmultisliderctrl.cpp +++ b/indra/llui/llmultisliderctrl.cpp @@ -344,7 +344,7 @@ void LLMultiSliderCtrl::onEditorCommit( LLUICtrl* ctrl, const LLSD& userdata) if( self->mMultiSlider->getMinValue() <= val && val <= self->mMultiSlider->getMaxValue() ) { self->setCurSliderValue( val ); // set the value temporarily so that the callback can retrieve it. - if( self->mValidateSignal( self, val ) ) + if( !self->mValidateSignal || (*(self->mValidateSignal))( self, val ) ) { success = TRUE; } @@ -378,7 +378,7 @@ void LLMultiSliderCtrl::onSliderCommit(LLUICtrl* ctrl, const LLSD& userdata) F32 new_val = self->mMultiSlider->getCurSliderValue(); self->mCurValue = new_val; // set the value temporarily so that the callback can retrieve it. - if( self->mValidateSignal( self, new_val ) ) + if( !self->mValidateSignal || (*(self->mValidateSignal))( self, new_val ) ) { success = TRUE; } diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index 89c4656297..063822dd56 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -106,7 +106,8 @@ LLPanel::LLPanel(const LLPanel::Params& p) mHelpTopic(p.help_topic), mCommitCallbackRegistrar(false), mEnableCallbackRegistrar(false), - mXMLFilename(p.filename) + mXMLFilename(p.filename), + mVisibleSignal(NULL) // *NOTE: Be sure to also change LLPanel::initFromParams(). We have too // many classes derived from LLPanel to retrofit them all to pass in params. { @@ -118,6 +119,11 @@ LLPanel::LLPanel(const LLPanel::Params& p) mPanelHandle.bind(this); } +LLPanel::~LLPanel() +{ + delete mVisibleSignal; +} + // virtual BOOL LLPanel::isPanel() const { @@ -332,7 +338,8 @@ BOOL LLPanel::handleKeyHere( KEY key, MASK mask ) void LLPanel::handleVisibilityChange ( BOOL new_visibility ) { LLUICtrl::handleVisibilityChange ( new_visibility ); - mVisibleSignal(this, LLSD(new_visibility) ); // Pass BOOL as LLSD + if (mVisibleSignal) + (*mVisibleSignal)(this, LLSD(new_visibility) ); // Pass BOOL as LLSD } void LLPanel::setFocus(BOOL b) @@ -424,7 +431,9 @@ void LLPanel::initFromParams(const LLPanel::Params& p) // visible callback if (p.visible_callback.isProvided()) - initCommitCallback(p.visible_callback, mVisibleSignal); + { + setVisibleCallback(initCommitCallback(p.visible_callback)); + } for (LLInitParam::ParamIterator<LocalizedString>::const_iterator it = p.strings().begin(); it != p.strings().end(); @@ -907,3 +916,13 @@ void LLPanel::childSetControlName(const std::string& id, const std::string& cont view->setControlName(control_name, NULL); } } + +boost::signals2::connection LLPanel::setVisibleCallback( const commit_signal_t::slot_type& cb ) +{ + if (!mVisibleSignal) + { + mVisibleSignal = new commit_signal_t(); + } + + return mVisibleSignal->connect(cb); +} diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index c213809d68..0a0fed82fb 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -109,7 +109,7 @@ protected: public: // LLPanel(const std::string& name, const LLRect& rect = LLRect(), BOOL bordered = TRUE); - /*virtual*/ ~LLPanel() {} + /*virtual*/ ~LLPanel(); // LLView interface /*virtual*/ BOOL isPanel() const; @@ -241,6 +241,8 @@ public: void setXMLFilename(std::string filename) { mXMLFilename = filename; }; std::string getXMLFilename() { return mXMLFilename; }; + boost::signals2::connection setVisibleCallback( const commit_signal_t::slot_type& cb ); + protected: // Override to set not found list LLButton* getDefaultButton() { return mDefaultBtn; } @@ -249,7 +251,7 @@ protected: EnableCallbackRegistry::ScopedRegistrar mEnableCallbackRegistrar; VisibleCallbackRegistry::ScopedRegistrar mVisibleCallbackRegistrar; - commit_signal_t mVisibleSignal; // Called when visibility changes, passes new visibility as LLSD() + commit_signal_t* mVisibleSignal; // Called when visibility changes, passes new visibility as LLSD() std::string mHelpTopic; // the name of this panel's help topic to display in the Help Viewer diff --git a/indra/llui/llslider.cpp b/indra/llui/llslider.cpp index da2fc7c68b..a6f729b396 100644 --- a/indra/llui/llslider.cpp +++ b/indra/llui/llslider.cpp @@ -77,7 +77,9 @@ LLSlider::LLSlider(const LLSlider::Params& p) mTrackImageHorizontal(p.track_image_horizontal), mTrackImageVertical(p.track_image_vertical), mTrackHighlightHorizontalImage(p.track_highlight_horizontal_image), - mTrackHighlightVerticalImage(p.track_highlight_vertical_image) + mTrackHighlightVerticalImage(p.track_highlight_vertical_image), + mMouseDownSignal(NULL), + mMouseUpSignal(NULL) { mViewModel->setValue(p.initial_value); updateThumbRect(); @@ -86,9 +88,19 @@ LLSlider::LLSlider(const LLSlider::Params& p) setValue(getValueF32()); if (p.mouse_down_callback.isProvided()) - initCommitCallback(p.mouse_down_callback, mMouseDownSignal); + { + setMouseDownCallback(initCommitCallback(p.mouse_down_callback)); + } if (p.mouse_up_callback.isProvided()) - initCommitCallback(p.mouse_up_callback, mMouseUpSignal); + { + setMouseUpCallback(initCommitCallback(p.mouse_up_callback)); + } +} + +LLSlider::~LLSlider() +{ + delete mMouseDownSignal; + delete mMouseUpSignal; } void LLSlider::setValue(F32 value, BOOL from_event) @@ -202,7 +214,8 @@ BOOL LLSlider::handleMouseUp(S32 x, S32 y, MASK mask) { gFocusMgr.setMouseCapture( NULL ); - mMouseUpSignal( this, getValueF32() ); + if (mMouseUpSignal) + (*mMouseUpSignal)( this, getValueF32() ); handled = TRUE; make_ui_sound("UISndClickRelease"); @@ -222,7 +235,8 @@ BOOL LLSlider::handleMouseDown(S32 x, S32 y, MASK mask) { setFocus(TRUE); } - mMouseDownSignal( this, getValueF32() ); + if (mMouseDownSignal) + (*mMouseDownSignal)( this, getValueF32() ); if (MASK_CONTROL & mask) // if CTRL is modifying { @@ -364,3 +378,15 @@ void LLSlider::draw() LLUICtrl::draw(); } + +boost::signals2::connection LLSlider::setMouseDownCallback( const commit_signal_t::slot_type& cb ) +{ + if (!mMouseDownSignal) mMouseDownSignal = new commit_signal_t(); + return mMouseDownSignal->connect(cb); +} + +boost::signals2::connection LLSlider::setMouseUpCallback( const commit_signal_t::slot_type& cb ) +{ + if (!mMouseUpSignal) mMouseUpSignal = new commit_signal_t(); + return mMouseUpSignal->connect(cb); +} diff --git a/indra/llui/llslider.h b/indra/llui/llslider.h index 6ab0ed7922..45f8f81e40 100644 --- a/indra/llui/llslider.h +++ b/indra/llui/llslider.h @@ -67,6 +67,7 @@ protected: LLSlider(const Params&); friend class LLUICtrlFactory; public: + virtual ~LLSlider(); void setValue( F32 value, BOOL from_event = FALSE ); // overrides for LLF32UICtrl methods virtual void setValue(const LLSD& value ) { setValue((F32)value.asReal(), TRUE); } @@ -76,8 +77,8 @@ public: virtual void setMinValue(F32 min_value) { LLF32UICtrl::setMinValue(min_value); updateThumbRect(); } virtual void setMaxValue(F32 max_value) { LLF32UICtrl::setMaxValue(max_value); updateThumbRect(); } - boost::signals2::connection setMouseDownCallback( const commit_signal_t::slot_type& cb ) { return mMouseDownSignal.connect(cb); } - boost::signals2::connection setMouseUpCallback( const commit_signal_t::slot_type& cb ) { return mMouseUpSignal.connect(cb); } + boost::signals2::connection setMouseDownCallback( const commit_signal_t::slot_type& cb ); + boost::signals2::connection setMouseUpCallback( const commit_signal_t::slot_type& cb ); virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); @@ -109,8 +110,8 @@ private: LLUIColor mThumbOutlineColor; LLUIColor mThumbCenterColor; - commit_signal_t mMouseDownSignal; - commit_signal_t mMouseUpSignal; + commit_signal_t* mMouseDownSignal; + commit_signal_t* mMouseUpSignal; }; #endif // LL_LLSLIDER_H diff --git a/indra/llui/llsliderctrl.cpp b/indra/llui/llsliderctrl.cpp index ed22c0a47f..01c274bb4e 100644 --- a/indra/llui/llsliderctrl.cpp +++ b/indra/llui/llsliderctrl.cpp @@ -122,7 +122,8 @@ LLSliderCtrl::LLSliderCtrl(const LLSliderCtrl::Params& p) slider_p.min_value.setIfNotProvided(p.min_value); slider_p.max_value.setIfNotProvided(p.max_value); slider_p.increment.setIfNotProvided(p.increment); - + slider_p.orientation.setIfNotProvided(p.orientation); + slider_p.commit_callback.function(&LLSliderCtrl::onSliderCommit); slider_p.control_name(p.control_name); slider_p.mouse_down_callback( p.mouse_down_callback ); @@ -260,7 +261,7 @@ void LLSliderCtrl::onEditorCommit( LLUICtrl* ctrl, const LLSD& userdata ) if( self->mSlider->getMinValue() <= val && val <= self->mSlider->getMaxValue() ) { self->setValue( val ); // set the value temporarily so that the callback can retrieve it. - if( self->mValidateSignal( self, val ) ) + if( !self->mValidateSignal || (*(self->mValidateSignal))( self, val ) ) { success = TRUE; } @@ -294,7 +295,7 @@ void LLSliderCtrl::onSliderCommit( LLUICtrl* ctrl, const LLSD& userdata ) F32 new_val = self->mSlider->getValueF32(); self->mValue = new_val; // set the value temporarily so that the callback can retrieve it. - if( self->mValidateSignal( self, new_val ) ) + if( !self->mValidateSignal || (*(self->mValidateSignal))( self, new_val ) ) { success = TRUE; } diff --git a/indra/llui/llsliderctrl.h b/indra/llui/llsliderctrl.h index 4a1574d502..c425849782 100644 --- a/indra/llui/llsliderctrl.h +++ b/indra/llui/llsliderctrl.h @@ -46,6 +46,7 @@ class LLSliderCtrl : public LLF32UICtrl public: struct Params : public LLInitParam::Block<Params, LLF32UICtrl::Params> { + Optional<std::string> orientation; Optional<S32> label_width; Optional<S32> text_width; Optional<bool> show_text; @@ -78,7 +79,8 @@ public: value_text("value_text"), slider_label("slider_label"), mouse_down_callback("mouse_down_callback"), - mouse_up_callback("mouse_up_callback") + mouse_up_callback("mouse_up_callback"), + orientation("orientation", std::string ("horizontal")) {} }; protected: diff --git a/indra/llui/llspinctrl.cpp b/indra/llui/llspinctrl.cpp index bedf16a397..d6d46654d5 100644 --- a/indra/llui/llspinctrl.cpp +++ b/indra/llui/llspinctrl.cpp @@ -190,7 +190,7 @@ void LLSpinCtrl::onUpBtn( const LLSD& data ) F32 saved_val = (F32)getValue().asReal(); setValue(val); - if( !mValidateSignal( this, val ) ) + if( mValidateSignal && !(*mValidateSignal)( this, val ) ) { setValue( saved_val ); reportInvalidData(); @@ -224,7 +224,7 @@ void LLSpinCtrl::onDownBtn( const LLSD& data ) F32 saved_val = (F32)getValue().asReal(); setValue(val); - if( !mValidateSignal( this, val ) ) + if( mValidateSignal && !(*mValidateSignal)( this, val ) ) { setValue( saved_val ); reportInvalidData(); @@ -316,7 +316,7 @@ void LLSpinCtrl::onEditorCommit( const LLSD& data ) F32 saved_val = getValueF32(); setValue(val); - if( mValidateSignal( this, val ) ) + if( !mValidateSignal || (*mValidateSignal)( this, val ) ) { success = TRUE; onCommit(); diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index f5d8174820..d7d61cf6cb 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -1339,12 +1339,12 @@ BOOL LLTabContainer::selectTab(S32 which) cbdata = selected_tuple->mTabPanel->getName(); BOOL res = FALSE; - if( mValidateSignal( this, cbdata ) ) + if( !mValidateSignal || (*mValidateSignal)( this, cbdata ) ) { res = setTab(which); - if (res) + if (res && mCommitSignal) { - mCommitSignal(this, cbdata); + (*mCommitSignal)(this, cbdata); } } diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index e210667764..7bf10d774c 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -60,6 +60,11 @@ LLTextBase::line_info::line_info(S32 index_start, S32 index_end, LLRect rect, S3 bool LLTextBase::compare_segment_end::operator()(const LLTextSegmentPtr& a, const LLTextSegmentPtr& b) const { + // sort empty spans (e.g. 11-11) after previous non-empty spans (e.g. 5-11) + if (a->getEnd() == b->getEnd()) + { + return a->getStart() < b->getStart(); + } return a->getEnd() < b->getEnd(); } @@ -2060,16 +2065,16 @@ void LLTextBase::updateRects() mContentsRect.unionWith(line_iter->mRect); } - mContentsRect.mLeft = 0; + S32 delta_pos_x = -mContentsRect.mLeft; mContentsRect.mTop += mVPad; S32 delta_pos = -mContentsRect.mBottom; // move line segments to fit new document rect for (line_list_t::iterator it = mLineInfoList.begin(); it != mLineInfoList.end(); ++it) { - it->mRect.translate(0, delta_pos); + it->mRect.translate(delta_pos_x, delta_pos); } - mContentsRect.translate(0, delta_pos); + mContentsRect.translate(delta_pos_x, delta_pos); } // update document container dimensions according to text contents diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 224f066968..3f4ef24f82 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -750,8 +750,10 @@ BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask) { if( mIsSelecting ) { - mScroller->autoScroll(x, y); - + if(mScroller) + { + mScroller->autoScroll(x, y); + } S32 clamped_x = llclamp(x, mTextRect.mLeft, mTextRect.mRight); S32 clamped_y = llclamp(y, mTextRect.mBottom, mTextRect.mTop); setCursorAtLocalPos( clamped_x, clamped_y, true ); @@ -799,7 +801,10 @@ BOOL LLTextEditor::handleMouseUp(S32 x, S32 y, MASK mask) { if( mIsSelecting ) { - mScroller->autoScroll(x, y); + if(mScroller) + { + mScroller->autoScroll(x, y); + } S32 clamped_x = llclamp(x, mTextRect.mLeft, mTextRect.mRight); S32 clamped_y = llclamp(y, mTextRect.mBottom, mTextRect.mTop); setCursorAtLocalPos( clamped_x, clamped_y, true ); @@ -1696,7 +1701,15 @@ BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask ) */ if (mReadOnly) { - handled = mScroller->handleKeyHere( key, mask ); + if(mScroller) + { + handled = mScroller->handleKeyHere( key, mask ); + } + else + { + handled = handleNavigationKey( key, mask ); + } + } else { @@ -2135,9 +2148,8 @@ void LLTextEditor::drawPreeditMarker() void LLTextEditor::drawLineNumbers() { LLGLSUIDefault gls_ui; - - LLRect scrolled_view_rect = mScroller->getVisibleContentRect(); - LLRect content_rect = mScroller->getContentWindowRect(); + LLRect scrolled_view_rect = getVisibleDocumentRect(); + LLRect content_rect = getTextRect(); LLLocalClipRect clip(content_rect); S32 first_line = getFirstVisibleLine(); S32 num_lines = getLineCount(); diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index 08fc8fb784..a30d5b4651 100644 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -78,7 +78,16 @@ LLUICtrl::LLUICtrl(const LLUICtrl::Params& p, const LLViewModelPtr& viewmodel) mEnabledControlVariable(NULL), mDisabledControlVariable(NULL), mMakeVisibleControlVariable(NULL), - mMakeInvisibleControlVariable(NULL) + mMakeInvisibleControlVariable(NULL), + mCommitSignal(NULL), + mValidateSignal(NULL), + mMouseEnterSignal(NULL), + mMouseLeaveSignal(NULL), + mMouseDownSignal(NULL), + mMouseUpSignal(NULL), + mRightMouseDownSignal(NULL), + mRightMouseUpSignal(NULL), + mDoubleClickSignal(NULL) { mUICtrlHandle.bind(this); } @@ -129,10 +138,14 @@ void LLUICtrl::initFromParams(const Params& p) } if (p.commit_callback.isProvided()) - initCommitCallback(p.commit_callback, mCommitSignal); + { + setCommitCallback(initCommitCallback(p.commit_callback)); + } if (p.validate_callback.isProvided()) - initEnableCallback(p.validate_callback, mValidateSignal); + { + setValidateCallback(initEnableCallback(p.validate_callback)); + } if (p.init_callback.isProvided()) { @@ -151,10 +164,14 @@ void LLUICtrl::initFromParams(const Params& p) } if(p.mouseenter_callback.isProvided()) - initCommitCallback(p.mouseenter_callback, mMouseEnterSignal); + { + setMouseEnterCallback(initCommitCallback(p.mouseenter_callback)); + } if(p.mouseleave_callback.isProvided()) - initCommitCallback(p.mouseleave_callback, mMouseLeaveSignal); + { + setMouseLeaveCallback(initCommitCallback(p.mouseleave_callback)); + } } @@ -167,16 +184,40 @@ LLUICtrl::~LLUICtrl() llwarns << "UI Control holding top ctrl deleted: " << getName() << ". Top view removed." << llendl; gFocusMgr.removeTopCtrlWithoutCallback( this ); } + + delete mCommitSignal; + delete mValidateSignal; + delete mMouseEnterSignal; + delete mMouseLeaveSignal; + delete mMouseDownSignal; + delete mMouseUpSignal; + delete mRightMouseDownSignal; + delete mRightMouseUpSignal; + delete mDoubleClickSignal; } -void LLUICtrl::initCommitCallback(const CommitCallbackParam& cb, commit_signal_t& sig) +void default_commit_handler(LLUICtrl* ctrl, const LLSD& param) +{} + +bool default_enable_handler(LLUICtrl* ctrl, const LLSD& param) +{ + return true; +} + +bool default_visible_handler(LLUICtrl* ctrl, const LLSD& param) +{ + return true; +} + + +LLUICtrl::commit_signal_t::slot_type LLUICtrl::initCommitCallback(const CommitCallbackParam& cb) { if (cb.function.isProvided()) { if (cb.parameter.isProvided()) - sig.connect(boost::bind(cb.function(), _1, cb.parameter)); + return boost::bind(cb.function(), _1, cb.parameter); else - sig.connect(cb.function()); + return cb.function(); } else { @@ -185,26 +226,27 @@ void LLUICtrl::initCommitCallback(const CommitCallbackParam& cb, commit_signal_t if (func) { if (cb.parameter.isProvided()) - sig.connect(boost::bind((*func), _1, cb.parameter)); + return boost::bind((*func), _1, cb.parameter); else - sig.connect(*func); + return commit_signal_t::slot_type(*func); } else if (!function_name.empty()) { llwarns << "No callback found for: '" << function_name << "' in control: " << getName() << llendl; } } + return default_commit_handler; } -void LLUICtrl::initEnableCallback(const EnableCallbackParam& cb, enable_signal_t& sig) +LLUICtrl::enable_signal_t::slot_type LLUICtrl::initEnableCallback(const EnableCallbackParam& cb) { // Set the callback function if (cb.function.isProvided()) { if (cb.parameter.isProvided()) - sig.connect(boost::bind(cb.function(), this, cb.parameter)); + return boost::bind(cb.function(), this, cb.parameter); else - sig.connect(cb.function()); + return cb.function(); } else { @@ -212,22 +254,23 @@ void LLUICtrl::initEnableCallback(const EnableCallbackParam& cb, enable_signal_t if (func) { if (cb.parameter.isProvided()) - sig.connect(boost::bind((*func), this, cb.parameter)); + return boost::bind((*func), this, cb.parameter); else - sig.connect(*func); + return enable_signal_t::slot_type(*func); } } + return default_enable_handler; } -void LLUICtrl::initVisibleCallback(const VisibleCallbackParam& cb, visible_signal_t& sig) +LLUICtrl::visible_signal_t::slot_type LLUICtrl::initVisibleCallback(const VisibleCallbackParam& cb) { // Set the callback function if (cb.function.isProvided()) { if (cb.parameter.isProvided()) - sig.connect(boost::bind(cb.function(), this, cb.parameter)); + return boost::bind(cb.function(), this, cb.parameter); else - sig.connect(cb.function()); + return cb.function(); } else { @@ -235,30 +278,40 @@ void LLUICtrl::initVisibleCallback(const VisibleCallbackParam& cb, visible_signa if (func) { if (cb.parameter.isProvided()) - sig.connect(boost::bind((*func), this, cb.parameter)); + return boost::bind((*func), this, cb.parameter); else - sig.connect(*func); + return visible_signal_t::slot_type(*func); } } + return default_visible_handler; } // virtual void LLUICtrl::onMouseEnter(S32 x, S32 y, MASK mask) { - mMouseEnterSignal(this, getValue()); + if (mMouseEnterSignal) + { + (*mMouseEnterSignal)(this, getValue()); + } } // virtual void LLUICtrl::onMouseLeave(S32 x, S32 y, MASK mask) { - mMouseLeaveSignal(this, getValue()); + if(mMouseLeaveSignal) + { + (*mMouseLeaveSignal)(this, getValue()); + } } //virtual BOOL LLUICtrl::handleMouseDown(S32 x, S32 y, MASK mask) { BOOL handled = LLView::handleMouseDown(x,y,mask); - mMouseDownSignal(this,x,y,mask); + if (mMouseDownSignal) + { + (*mMouseDownSignal)(this,x,y,mask); + } return handled; } @@ -266,7 +319,10 @@ BOOL LLUICtrl::handleMouseDown(S32 x, S32 y, MASK mask) BOOL LLUICtrl::handleMouseUp(S32 x, S32 y, MASK mask) { BOOL handled = LLView::handleMouseUp(x,y,mask); - mMouseUpSignal(this,x,y,mask); + if (mMouseUpSignal) + { + (*mMouseUpSignal)(this,x,y,mask); + } return handled; } @@ -274,7 +330,10 @@ BOOL LLUICtrl::handleMouseUp(S32 x, S32 y, MASK mask) BOOL LLUICtrl::handleRightMouseDown(S32 x, S32 y, MASK mask) { BOOL handled = LLView::handleRightMouseDown(x,y,mask); - mRightMouseDownSignal(this,x,y,mask); + if (mRightMouseDownSignal) + { + (*mRightMouseDownSignal)(this,x,y,mask); + } return handled; } @@ -282,14 +341,20 @@ BOOL LLUICtrl::handleRightMouseDown(S32 x, S32 y, MASK mask) BOOL LLUICtrl::handleRightMouseUp(S32 x, S32 y, MASK mask) { BOOL handled = LLView::handleRightMouseUp(x,y,mask); - mRightMouseUpSignal(this,x,y,mask); + if(mRightMouseUpSignal) + { + (*mRightMouseUpSignal)(this,x,y,mask); + } return handled; } BOOL LLUICtrl::handleDoubleClick(S32 x, S32 y, MASK mask) { BOOL handled = LLView::handleDoubleClick(x, y, mask); - mDoubleClickSignal(this, x, y, mask); + if (mDoubleClickSignal) + { + (*mDoubleClickSignal)(this, x, y, mask); + } return handled; } @@ -302,7 +367,8 @@ BOOL LLUICtrl::canFocusChildren() const void LLUICtrl::onCommit() { - mCommitSignal(this, getValue()); + if (mCommitSignal) + (*mCommitSignal)(this, getValue()); } //virtual @@ -832,7 +898,8 @@ boost::signals2::connection LLUICtrl::setCommitCallback( boost::function<void (L } boost::signals2::connection LLUICtrl::setValidateBeforeCommit( boost::function<bool (const LLSD& data)> cb ) { - return mValidateSignal.connect(boost::bind(cb, _2)); + if (!mValidateSignal) mValidateSignal = new enable_signal_t(); + return mValidateSignal->connect(boost::bind(cb, _2)); } // virtual @@ -850,3 +917,57 @@ BOOL LLUICtrl::getTentative() const // virtual void LLUICtrl::setColor(const LLColor4& color) { } + +boost::signals2::connection LLUICtrl::setCommitCallback( const commit_signal_t::slot_type& cb ) +{ + if (!mCommitSignal) mCommitSignal = new commit_signal_t(); + return mCommitSignal->connect(cb); +} + +boost::signals2::connection LLUICtrl::setValidateCallback( const enable_signal_t::slot_type& cb ) +{ + if (!mValidateSignal) mValidateSignal = new enable_signal_t(); + return mValidateSignal->connect(cb); +} + +boost::signals2::connection LLUICtrl::setMouseEnterCallback( const commit_signal_t::slot_type& cb ) +{ + if (!mMouseEnterSignal) mMouseEnterSignal = new commit_signal_t(); + return mMouseEnterSignal->connect(cb); +} + +boost::signals2::connection LLUICtrl::setMouseLeaveCallback( const commit_signal_t::slot_type& cb ) +{ + if (!mMouseLeaveSignal) mMouseLeaveSignal = new commit_signal_t(); + return mMouseLeaveSignal->connect(cb); +} + +boost::signals2::connection LLUICtrl::setMouseDownCallback( const mouse_signal_t::slot_type& cb ) +{ + if (!mMouseDownSignal) mMouseDownSignal = new mouse_signal_t(); + return mMouseDownSignal->connect(cb); +} + +boost::signals2::connection LLUICtrl::setMouseUpCallback( const mouse_signal_t::slot_type& cb ) +{ + if (!mMouseUpSignal) mMouseUpSignal = new mouse_signal_t(); + return mMouseUpSignal->connect(cb); +} + +boost::signals2::connection LLUICtrl::setRightMouseDownCallback( const mouse_signal_t::slot_type& cb ) +{ + if (!mRightMouseDownSignal) mRightMouseDownSignal = new mouse_signal_t(); + return mRightMouseDownSignal->connect(cb); +} + +boost::signals2::connection LLUICtrl::setRightMouseUpCallback( const mouse_signal_t::slot_type& cb ) +{ + if (!mRightMouseUpSignal) mRightMouseUpSignal = new mouse_signal_t(); + return mRightMouseUpSignal->connect(cb); +} + +boost::signals2::connection LLUICtrl::setDoubleClickCallback( const mouse_signal_t::slot_type& cb ) +{ + if (!mDoubleClickSignal) mDoubleClickSignal = new mouse_signal_t(); + return mDoubleClickSignal->connect(cb); +} diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index dd22851100..aef1bcd519 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -162,9 +162,9 @@ protected: LLUICtrl(const Params& p = getDefaultParams(), const LLViewModelPtr& viewmodel=LLViewModelPtr(new LLViewModel)); - void initCommitCallback(const CommitCallbackParam& cb, commit_signal_t& sig); - void initEnableCallback(const EnableCallbackParam& cb, enable_signal_t& sig); - void initVisibleCallback(const VisibleCallbackParam& cb, visible_signal_t& sig); + commit_signal_t::slot_type initCommitCallback(const CommitCallbackParam& cb); + enable_signal_t::slot_type initEnableCallback(const EnableCallbackParam& cb); + visible_signal_t::slot_type initVisibleCallback(const VisibleCallbackParam& cb); // We need this virtual so we can override it with derived versions virtual LLViewModel* getViewModel() const; @@ -254,18 +254,18 @@ public: // topic then put in help_topic_out bool findHelpTopic(std::string& help_topic_out); - boost::signals2::connection setCommitCallback( const commit_signal_t::slot_type& cb ) { return mCommitSignal.connect(cb); } - boost::signals2::connection setValidateCallback( const enable_signal_t::slot_type& cb ) { return mValidateSignal.connect(cb); } + boost::signals2::connection setCommitCallback( const commit_signal_t::slot_type& cb ); + boost::signals2::connection setValidateCallback( const enable_signal_t::slot_type& cb ); - boost::signals2::connection setMouseEnterCallback( const commit_signal_t::slot_type& cb ) { return mMouseEnterSignal.connect(cb); } - boost::signals2::connection setMouseLeaveCallback( const commit_signal_t::slot_type& cb ) { return mMouseLeaveSignal.connect(cb); } + boost::signals2::connection setMouseEnterCallback( const commit_signal_t::slot_type& cb ); + boost::signals2::connection setMouseLeaveCallback( const commit_signal_t::slot_type& cb ); - boost::signals2::connection setMouseDownCallback( const mouse_signal_t::slot_type& cb ) { return mMouseDownSignal.connect(cb); } - boost::signals2::connection setMouseUpCallback( const mouse_signal_t::slot_type& cb ) { return mMouseUpSignal.connect(cb); } - boost::signals2::connection setRightMouseDownCallback( const mouse_signal_t::slot_type& cb ) { return mRightMouseDownSignal.connect(cb); } - boost::signals2::connection setRightMouseUpCallback( const mouse_signal_t::slot_type& cb ) { return mRightMouseUpSignal.connect(cb); } + boost::signals2::connection setMouseDownCallback( const mouse_signal_t::slot_type& cb ); + boost::signals2::connection setMouseUpCallback( const mouse_signal_t::slot_type& cb ); + boost::signals2::connection setRightMouseDownCallback( const mouse_signal_t::slot_type& cb ); + boost::signals2::connection setRightMouseUpCallback( const mouse_signal_t::slot_type& cb ); - boost::signals2::connection setDoubleClickCallback( const mouse_signal_t::slot_type& cb ) { return mDoubleClickSignal.connect(cb); } + boost::signals2::connection setDoubleClickCallback( const mouse_signal_t::slot_type& cb ); // *TODO: Deprecate; for backwards compatability only: boost::signals2::connection setCommitCallback( boost::function<void (LLUICtrl*,void*)> cb, void* data); @@ -293,18 +293,18 @@ protected: static bool controlListener(const LLSD& newvalue, LLHandle<LLUICtrl> handle, std::string type); - commit_signal_t mCommitSignal; - enable_signal_t mValidateSignal; + commit_signal_t* mCommitSignal; + enable_signal_t* mValidateSignal; - commit_signal_t mMouseEnterSignal; - commit_signal_t mMouseLeaveSignal; + commit_signal_t* mMouseEnterSignal; + commit_signal_t* mMouseLeaveSignal; - mouse_signal_t mMouseDownSignal; - mouse_signal_t mMouseUpSignal; - mouse_signal_t mRightMouseDownSignal; - mouse_signal_t mRightMouseUpSignal; + mouse_signal_t* mMouseDownSignal; + mouse_signal_t* mMouseUpSignal; + mouse_signal_t* mRightMouseDownSignal; + mouse_signal_t* mRightMouseUpSignal; - mouse_signal_t mDoubleClickSignal; + mouse_signal_t* mDoubleClickSignal; LLViewModelPtr mViewModel; diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index 219fae84be..b51709e208 100644 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -34,6 +34,7 @@ #include "linden_common.h" #include "llurlentry.h" #include "lluri.h" + #include "llcachename.h" #include "lltrans.h" #include "lluicolortable.h" @@ -383,6 +384,38 @@ std::string LLUrlEntryGroup::getLabel(const std::string &url, const LLUrlLabelCa } } +// +// LLUrlEntryInventory Describes a Second Life inventory Url, e.g., +// secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/select +// +LLUrlEntryInventory::LLUrlEntryInventory() +{ + mPattern = boost::regex("secondlife:///app/inventory/[\\da-f-]+/\\w+", + boost::regex::perl|boost::regex::icase); + mMenuName = "menu_url_inventory.xml"; +} + +std::string LLUrlEntryInventory::getLabel(const std::string &url, const LLUrlLabelCallback &cb) +{ + return unescapeUrl(url); + // TODO: Figure out if we can somehow access the inventory from here to get the actual item name + /* + std::string inventory_id_string = getIDStringFromUrl(url); + if (inventory_id_string.empty()) + { + // something went wrong, give raw url + return unescapeUrl(url); + } + LLUUID inventory_id(inventory_id_string); + LLInventoryItem* item = gInventory.getItem(inventory_id); + if(!item) + { + return unescapeUrl(url); + } + return item->getName(); */ +} + + /// /// LLUrlEntryParcel Describes a Second Life parcel Url, e.g., /// secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h index 7970b48eb5..b3fb333fdd 100644 --- a/indra/llui/llurlentry.h +++ b/indra/llui/llurlentry.h @@ -174,6 +174,19 @@ private: }; /// +/// LLUrlEntryInventory Describes a Second Life inventory Url, e.g., +/// secondlife:///app/inventory/0e346d8b-4433-4d66-a6b0-fd37083abc4c/select +/// +class LLUrlEntryInventory : public LLUrlEntryBase +{ +public: + LLUrlEntryInventory(); + /*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb); +private: +}; + + +/// /// LLUrlEntryParcel Describes a Second Life parcel Url, e.g., /// secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about /// diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp index a6922b019b..b2f084e5ac 100644 --- a/indra/llui/llurlregistry.cpp +++ b/indra/llui/llurlregistry.cpp @@ -55,6 +55,7 @@ LLUrlRegistry::LLUrlRegistry() registerUrl(new LLUrlEntryPlace()); registerUrl(new LLUrlEntrySL()); registerUrl(new LLUrlEntrySLLabel()); + registerUrl(new LLUrlEntryInventory()); } LLUrlRegistry::~LLUrlRegistry() |