diff options
author | brad kittenbrink <brad@lindenlab.com> | 2009-08-13 01:28:38 -0400 |
---|---|---|
committer | brad kittenbrink <brad@lindenlab.com> | 2009-08-13 01:28:38 -0400 |
commit | 39c2a584f47785c826c3bc133106f3689120bf32 (patch) | |
tree | 898695d92fc467672618f08260106ab773e456b5 /indra/llui | |
parent | a15feff98c13cd693e60fc59345609c007de16db (diff) | |
parent | efd58603da6062d90a5d7019987409994bc73858 (diff) |
Merged latest viewer-2.0.0-3 change up through svn r130333 into login-api.
Diffstat (limited to 'indra/llui')
27 files changed, 311 insertions, 328 deletions
diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index 269c02263d..2f6ae72ef5 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -48,6 +48,7 @@ set(llui_SOURCE_FILES llkeywords.cpp
lllayoutstack.cpp
lllineeditor.cpp
+ lllink.cpp
llmenugl.cpp
llmodaldialog.cpp
llmultifloater.cpp
@@ -126,6 +127,7 @@ set(llui_HEADER_FILES lllayoutstack.h
lllazyvalue.h
lllineeditor.h
+ lllink.h
llmenugl.h
llmodaldialog.h
llmultifloater.h
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index fc3af34951..c566282bef 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -64,12 +64,15 @@ LLButton::Params::Params() : label_selected("label_selected"), // requires is_toggle true label_shadow("label_shadow", true), auto_resize("auto_resize", false), + use_ellipses("use_ellipses", false), image_unselected("image_unselected"), image_selected("image_selected"), image_hover_selected("image_hover_selected"), image_hover_unselected("image_hover_unselected"), image_disabled_selected("image_disabled_selected"), image_disabled("image_disabled"), + image_pressed("image_pressed"), + image_pressed_selected("image_pressed_selected"), image_overlay("image_overlay"), image_overlay_alignment("image_overlay_alignment", std::string("center")), label_color("label_color"), @@ -108,7 +111,6 @@ LLButton::LLButton(const LLButton::Params& p) mFlashing( FALSE ), mCurGlowStrength(0.f), mNeedsHighlight(FALSE), - mImagep( NULL ), mUnselectedLabel(p.label()), mSelectedLabel(p.label_selected()), mGLFont(p.font), @@ -118,6 +120,8 @@ LLButton::LLButton(const LLButton::Params& p) mImageSelected(p.image_selected), mImageDisabled(p.image_disabled), mImageDisabledSelected(p.image_disabled_selected), + mImagePressed(p.image_pressed), + mImagePressedSelected(p.image_pressed_selected), mImageHoverSelected(p.image_hover_selected), mImageHoverUnselected(p.image_hover_unselected), mUnselectedLabelColor(p.label_color()), @@ -135,6 +139,7 @@ LLButton::LLButton(const LLButton::Params& p) mScaleImage(p.scale_image), mDropShadowedText(p.label_shadow), mAutoResize(p.auto_resize), + mUseEllipses( p.use_ellipses ), mHAlign(p.font_halign), mLeftHPad(p.pad_left), mRightHPad(p.pad_right), @@ -182,6 +187,11 @@ LLButton::LLButton(const LLButton::Params& p) mImageDisabled = p.image_unselected; mFadeWhenDisabled = TRUE; } + + if (p.image_pressed_selected == default_params.image_pressed_selected) + { + mImagePressedSelected = mImageUnselected; + } } // if custom selected button image provided... @@ -193,6 +203,21 @@ LLButton::LLButton(const LLButton::Params& p) mImageDisabledSelected = p.image_selected; mFadeWhenDisabled = TRUE; } + + if (p.image_pressed == default_params.image_pressed) + { + mImagePressed = mImageSelected; + } + } + + if (!p.image_pressed.isProvided()) + { + mImagePressed = mImageSelected; + } + + if (!p.image_pressed_selected.isProvided()) + { + mImagePressedSelected = mImageUnselected; } if (mImageUnselected.isNull()) @@ -257,11 +282,6 @@ boost::signals2::connection LLButton::setHeldDownCallback( const commit_signal_t { return mHeldDownSignal.connect(cb); } - -boost::signals2::connection LLButton::setRightClickedCallback( const commit_signal_t::slot_type& cb ) -{ - return mRightClickSignal.connect(cb); -} // *TODO: Deprecate (for backwards compatability only) @@ -414,7 +434,7 @@ BOOL LLButton::handleRightMouseUp(S32 x, S32 y, MASK mask) if (pointInView(x, y)) { - mRightClickSignal(this, getValue()); + mRightClickSignal(this, x,y,mask); } } else @@ -427,7 +447,7 @@ BOOL LLButton::handleRightMouseUp(S32 x, S32 y, MASK mask) void LLButton::onMouseEnter(S32 x, S32 y, MASK mask) { - if (getEnabled()) + if (isInEnabledChain()) mNeedsHighlight = TRUE; } @@ -462,7 +482,7 @@ BOOL LLButton::handleHover(S32 x, S32 y, MASK mask) // virtual void LLButton::draw() { - BOOL flash = FALSE; + bool flash = FALSE; static LLUICachedControl<F32> button_flash_rate("ButtonFlashRate", 0); static LLUICachedControl<S32> button_flash_count("ButtonFlashCount", 0); @@ -474,7 +494,7 @@ void LLButton::draw() flash = (flash_count % 2 == 0) || flash_count > S32((F32)button_flash_count * 2.f); } - BOOL pressed_by_keyboard = FALSE; + bool pressed_by_keyboard = FALSE; if (hasFocus()) { pressed_by_keyboard = gKeyboard->getKeyDown(' ') || (mCommitOnReturn && gKeyboard->getKeyDown(KEY_RETURN)); @@ -485,24 +505,31 @@ void LLButton::draw() S32 local_mouse_y; LLUI::getCursorPositionLocal(this, &local_mouse_x, &local_mouse_y); - BOOL pressed = pressed_by_keyboard - || (hasMouseCapture() && pointInView(local_mouse_x, local_mouse_y)) - || getToggleState(); + bool enabled = isInEnabledChain(); + + bool pressed = pressed_by_keyboard + || (hasMouseCapture() && pointInView(local_mouse_x, local_mouse_y)); + bool selected = getToggleState(); - BOOL use_glow_effect = FALSE; + bool use_glow_effect = FALSE; LLColor4 glow_color = LLColor4::white; LLRender::eBlendType glow_type = LLRender::BT_ADD_WITH_ALPHA; - if ( mNeedsHighlight ) + LLUIImage* imagep = NULL; + if (pressed) { - if (pressed) + imagep = selected ? mImagePressedSelected : mImagePressed; + } + else if ( mNeedsHighlight ) + { + if (selected) { if (mImageHoverSelected) { - mImagep = mImageHoverSelected; + imagep = mImageHoverSelected; } else { - mImagep = mImageSelected; + imagep = mImageSelected; use_glow_effect = TRUE; } } @@ -510,22 +537,37 @@ void LLButton::draw() { if (mImageHoverUnselected) { - mImagep = mImageHoverUnselected; + imagep = mImageHoverUnselected; } else { - mImagep = mImageUnselected; + imagep = mImageUnselected; use_glow_effect = TRUE; } } } - else if ( pressed ) + else { - mImagep = mImageSelected; + imagep = selected ? mImageSelected : mImageUnselected; } - else + + // Override if more data is available + // HACK: Use gray checked state to mean either: + // enabled and tentative + // or + // disabled but checked + if (!mImageDisabledSelected.isNull() + && + ( (enabled && getTentative()) + || (!enabled && selected ) ) ) { - mImagep = mImageUnselected; + imagep = mImageDisabledSelected; + } + else if (!mImageDisabled.isNull() + && !enabled + && !selected) + { + imagep = mImageDisabled; } if (mFlashing) @@ -540,26 +582,7 @@ void LLButton::draw() glow_color = flash_color; } - // Override if more data is available - // HACK: Use gray checked state to mean either: - // enabled and tentative - // or - // disabled but checked - if (!mImageDisabledSelected.isNull() - && - ( (getEnabled() && getTentative()) - || (!getEnabled() && pressed ) ) ) - { - mImagep = mImageDisabledSelected; - } - else if (!mImageDisabled.isNull() - && !getEnabled() - && !pressed) - { - mImagep = mImageDisabled; - } - - if (mNeedsHighlight && !mImagep) + if (mNeedsHighlight && !imagep) { use_glow_effect = TRUE; } @@ -568,7 +591,7 @@ void LLButton::draw() LLColor4 label_color; // label changes when button state changes, not when pressed - if ( getEnabled() ) + if ( enabled ) { if ( getToggleState() ) { @@ -596,32 +619,18 @@ void LLButton::draw() if( getToggleState() ) { - if( getEnabled() || mDisabledSelectedLabel.empty() ) - { - label = mSelectedLabel; - } - else - { - label = mDisabledSelectedLabel; - } + label = mSelectedLabel; } else { - if( getEnabled() || mDisabledLabel.empty() ) - { - label = mUnselectedLabel; - } - else - { - label = mDisabledLabel; - } + label = mUnselectedLabel; } // overlay with keyboard focus border if (hasFocus()) { F32 lerp_amt = gFocusMgr.getFocusFlashAmt(); - drawBorder(gFocusMgr.getFocusColor(), llround(lerp(1.f, 3.f, lerp_amt))); + drawBorder(imagep, gFocusMgr.getFocusColor(), llround(lerp(1.f, 3.f, lerp_amt))); } if (use_glow_effect) @@ -638,27 +647,27 @@ void LLButton::draw() // Draw button image, if available. // Otherwise draw basic rectangular button. - if (mImagep.notNull()) + if (imagep != NULL) { // apply automatic 50% alpha fade to disabled image LLColor4 disabled_color = mFadeWhenDisabled ? mDisabledImageColor.get() % 0.5f : mDisabledImageColor.get(); if ( mScaleImage) { - mImagep->draw(getLocalRect(), getEnabled() ? mImageColor.get() : disabled_color ); + imagep->draw(getLocalRect(), enabled ? mImageColor.get() : disabled_color ); if (mCurGlowStrength > 0.01f) { gGL.setSceneBlendType(glow_type); - mImagep->drawSolid(0, 0, getRect().getWidth(), getRect().getHeight(), glow_color % mCurGlowStrength); + imagep->drawSolid(0, 0, getRect().getWidth(), getRect().getHeight(), glow_color % mCurGlowStrength); gGL.setSceneBlendType(LLRender::BT_ALPHA); } } else { - mImagep->draw(0, 0, getEnabled() ? mImageColor.get() : disabled_color ); + imagep->draw(0, 0, enabled ? mImageColor.get() : disabled_color ); if (mCurGlowStrength > 0.01f) { gGL.setSceneBlendType(glow_type); - mImagep->drawSolid(0, 0, glow_color % mCurGlowStrength); + imagep->drawSolid(0, 0, glow_color % mCurGlowStrength); gGL.setSceneBlendType(LLRender::BT_ALPHA); } } @@ -699,7 +708,7 @@ void LLButton::draw() // fade out overlay images on disabled buttons LLColor4 overlay_color = mImageOverlayColor.get(); - if (!getEnabled()) + if (!enabled) { overlay_color.mV[VALPHA] = 0.5f; } @@ -768,28 +777,33 @@ void LLButton::draw() x++; } + // *NOTE: mantipov: before mUseEllipses is implemented in EXT-279 U32_MAX has been passed as + // max_chars. + // LLFontGL::render expects S32 max_chars variable but process in a separate way -1 value. + // Due to U32_MAX is equal to S32 -1 value I have rest this value for non-ellipses mode. + // Not sure if it is really needed. Probably S32_MAX should be always passed as max_chars. mGLFont->render(label, 0, (F32)x, (F32)(LLBUTTON_V_PAD + y_offset), label_color, mHAlign, LLFontGL::BOTTOM, LLFontGL::NORMAL, mDropShadowedText ? LLFontGL::DROP_SHADOW_SOFT : LLFontGL::NO_SHADOW, - U32_MAX, text_width, - NULL, FALSE, FALSE); + S32_MAX, text_width, + NULL, FALSE, mUseEllipses); } - LLView::draw(); + LLUICtrl::draw(); } -void LLButton::drawBorder(const LLColor4& color, S32 size) +void LLButton::drawBorder(LLUIImage* imagep, const LLColor4& color, S32 size) { - if (mImagep.isNull()) return; + if (imagep == NULL) return; if (mScaleImage) { - mImagep->drawBorder(getLocalRect(), color, size); + imagep->drawBorder(getLocalRect(), color, size); } else { - mImagep->drawBorder(0, 0, color, size); + imagep->drawBorder(0, 0, color, size); } } @@ -851,16 +865,6 @@ void LLButton::setLabelSelected( const LLStringExplicit& label ) mSelectedLabel = label; } -void LLButton::setDisabledLabel( const LLStringExplicit& label ) -{ - mDisabledLabel = label; -} - -void LLButton::setDisabledSelectedLabel( const LLStringExplicit& label ) -{ - mDisabledSelectedLabel = label; -} - void LLButton::setImageUnselected(LLPointer<LLUIImage> image) { mImageUnselected = image; @@ -875,25 +879,11 @@ void LLButton::autoResize() LLUIString label; if(getToggleState()) { - if( getEnabled() || mDisabledSelectedLabel.empty() ) - { - label = mSelectedLabel; - } - else - { - label = mDisabledSelectedLabel; - } + label = mSelectedLabel; } else { - if( getEnabled() || mDisabledLabel.empty() ) - { - label = mUnselectedLabel; - } - else - { - label = mDisabledLabel; - } + label = mUnselectedLabel; } resize(label); } @@ -915,9 +905,8 @@ void LLButton::resize(LLUIString label) } void LLButton::setImages( const std::string &image_name, const std::string &selected_name ) { - setImageUnselected(image_name); - setImageSelected(selected_name); - + setImageUnselected(LLUI::getUIImage(image_name)); + setImageSelected(LLUI::getUIImage(selected_name)); } void LLButton::setImageSelected(LLPointer<LLUIImage> image) @@ -950,19 +939,6 @@ void LLButton::setImageDisabledSelected(LLPointer<LLUIImage> image) mFadeWhenDisabled = TRUE; } -void LLButton::setDisabledImages( const std::string &image_name, const std::string &selected_name) -{ - setDisabledImages( image_name, selected_name, mImageColor.get()); - mFadeWhenDisabled = TRUE; -} - -void LLButton::setDisabledImages( const std::string &image_name, const std::string &selected_name, const LLColor4& c ) -{ - setImageDisabled(image_name); - setImageDisabledSelected(selected_name); - mDisabledImageColor = c; -} - void LLButton::setImageHoverSelected(LLPointer<LLUIImage> image) { mImageHoverSelected = image; @@ -973,12 +949,6 @@ void LLButton::setImageHoverUnselected(LLPointer<LLUIImage> image) mImageHoverUnselected = image; } -void LLButton::setHoverImages( const std::string& image_name, const std::string& selected_name ) -{ - setImageHoverUnselected(image_name); - setImageHoverSelected(selected_name); -} - void LLButton::setImageOverlay(const std::string& image_name, LLFontGL::HAlign alignment, const LLColor4& color) { if (image_name.empty()) @@ -1016,42 +986,6 @@ S32 round_up(S32 grid, S32 value) } } -void LLButton::setImageUnselected(const std::string &image_name) -{ - setImageUnselected(LLUI::getUIImage(image_name)); - mImageUnselectedName = image_name; -} - -void LLButton::setImageSelected(const std::string &image_name) -{ - setImageSelected(LLUI::getUIImage(image_name)); - mImageSelectedName = image_name; -} - -void LLButton::setImageHoverSelected(const std::string &image_name) -{ - setImageHoverSelected(LLUI::getUIImage(image_name)); - mImageHoverSelectedName = image_name; -} - -void LLButton::setImageHoverUnselected(const std::string &image_name) -{ - setImageHoverUnselected(LLUI::getUIImage(image_name)); - mImageHoverUnselectedName = image_name; -} - -void LLButton::setImageDisabled(const std::string &image_name) -{ - setImageDisabled(LLUI::getUIImage(image_name)); - mImageDisabledName = image_name; -} - -void LLButton::setImageDisabledSelected(const std::string &image_name) -{ - setImageDisabledSelected(LLUI::getUIImage(image_name)); - mImageDisabledSelectedName = image_name; -} - void LLButton::addImageAttributeToXML(LLXMLNodePtr node, const std::string& image_name, const LLUUID& image_id, diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index e387c91a17..249882013a 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -76,6 +76,7 @@ public: Optional<std::string> label_selected; Optional<bool> label_shadow; Optional<bool> auto_resize; + Optional<bool> use_ellipses; // images Optional<LLUIImage*> image_unselected, @@ -84,6 +85,8 @@ public: image_hover_unselected, image_disabled_selected, image_disabled, + image_pressed, + image_pressed_selected, image_overlay; Optional<std::string> image_overlay_alignment; @@ -150,14 +153,14 @@ public: void setUnselectedLabelColor( const LLColor4& c ) { mUnselectedLabelColor = c; } void setSelectedLabelColor( const LLColor4& c ) { mSelectedLabelColor = c; } + void setUseEllipses( BOOL use_ellipses ) { mUseEllipses = use_ellipses; } + boost::signals2::connection setClickedCallback( const commit_signal_t::slot_type& cb ); // mouse down and up within button boost::signals2::connection setMouseDownCallback( const commit_signal_t::slot_type& cb ); boost::signals2::connection setMouseUpCallback( const commit_signal_t::slot_type& cb ); // mouse up, EVEN IF NOT IN BUTTON // Passes a 'count' parameter in the commit param payload, i.e. param["count"]) boost::signals2::connection setHeldDownCallback( const commit_signal_t::slot_type& cb ); // Mouse button held down and in button - boost::signals2::connection setRightClickedCallback( const commit_signal_t::slot_type& cb ); // right mouse down and up within button - // *TODO: Deprecate (for backwards compatability only) @@ -190,11 +193,7 @@ public: virtual void setColor(const LLColor4& c); void setImages(const std::string &image_name, const std::string &selected_name); - void setDisabledImages(const std::string &image_name, const std::string &selected_name); - void setDisabledImages(const std::string &image_name, const std::string &selected_name, const LLColor4& c); - void setHoverImages(const std::string &image_name, const std::string &selected_name); - void setDisabledImageColor(const LLColor4& c) { mDisabledImageColor = c; } void setDisabledSelectedLabelColor( const LLColor4& c ) { mDisabledSelectedLabelColor = c; } @@ -208,8 +207,6 @@ public: virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text ); void setLabelUnselected(const LLStringExplicit& label); void setLabelSelected(const LLStringExplicit& label); - void setDisabledLabel(const LLStringExplicit& disabled_label); - void setDisabledSelectedLabel(const LLStringExplicit& disabled_label); void setDisabledLabelColor( const LLColor4& c ) { mDisabledLabelColor = c; } void setFont(const LLFontGL *font) @@ -223,15 +220,6 @@ public: void setHoverGlowStrength(F32 strength) { mHoverGlowStrength = strength; } - void setImageUnselected(const std::string &image_name); - const std::string& getImageUnselectedName() const { return mImageUnselectedName; } - void setImageSelected(const std::string &image_name); - const std::string& getImageSelectedName() const { return mImageSelectedName; } - void setImageHoverSelected(const std::string &image_name); - void setImageHoverUnselected(const std::string &image_name); - void setImageDisabled(const std::string &image_name); - void setImageDisabledSelected(const std::string &image_name); - void setImageUnselected(LLPointer<LLUIImage> image); void setImageSelected(LLPointer<LLUIImage> image); void setImageHoverSelected(LLPointer<LLUIImage> image); @@ -250,106 +238,85 @@ public: static void setFloaterToggle(LLUICtrl* ctrl, const LLSD& sdname); protected: - - virtual void drawBorder(const LLColor4& color, S32 size); - - void setImageUnselectedID(const LLUUID &image_id); - const LLUUID& getImageUnselectedID() const { return mImageUnselectedID; } - void setImageSelectedID(const LLUUID &image_id); - const LLUUID& getImageSelectedID() const { return mImageSelectedID; } - void setImageHoverSelectedID(const LLUUID &image_id); - void setImageHoverUnselectedID(const LLUUID &image_id); - void setImageDisabledID(const LLUUID &image_id); - void setImageDisabledSelectedID(const LLUUID &image_id); const LLPointer<LLUIImage>& getImageUnselected() const { return mImageUnselected; } const LLPointer<LLUIImage>& getImageSelected() const { return mImageSelected; } - void resetMouseDownTimer(); LLFrameTimer mMouseDownTimer; // If the label is empty, set the picture_style attribute static void setupParamsForExport(Params& p, LLView* parent); +private: + void drawBorder(LLUIImage* imagep, const LLColor4& color, S32 size); + 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; + const LLFontGL* mGLFont; - S32 mMouseDownFrame; - S32 mMouseHeldDownCount; // Counter for parameter passed to held-down callback - F32 mHeldDownDelay; // seconds, after which held-down callbacks get called - S32 mHeldDownFrameDelay; // frames, after which held-down callbacks get called + S32 mMouseDownFrame; + S32 mMouseHeldDownCount; // Counter for parameter passed to held-down callback + F32 mHeldDownDelay; // seconds, after which held-down callbacks get called + S32 mHeldDownFrameDelay; // frames, after which held-down callbacks get called LLPointer<LLUIImage> mImageOverlay; LLFontGL::HAlign mImageOverlayAlignment; - LLUIColor mImageOverlayColor; + LLUIColor mImageOverlayColor; LLPointer<LLUIImage> mImageUnselected; LLUIString mUnselectedLabel; - LLUIColor mUnselectedLabelColor; + LLUIColor mUnselectedLabelColor; LLPointer<LLUIImage> mImageSelected; LLUIString mSelectedLabel; - LLUIColor mSelectedLabelColor; + LLUIColor mSelectedLabelColor; LLPointer<LLUIImage> mImageHoverSelected; LLPointer<LLUIImage> mImageHoverUnselected; LLPointer<LLUIImage> mImageDisabled; - LLUIString mDisabledLabel; - LLUIColor mDisabledLabelColor; + LLUIColor mDisabledLabelColor; LLPointer<LLUIImage> mImageDisabledSelected; LLUIString mDisabledSelectedLabel; - LLUIColor mDisabledSelectedLabelColor; - - LLUUID mImageUnselectedID; - LLUUID mImageSelectedID; - LLUUID mImageHoverSelectedID; - LLUUID mImageHoverUnselectedID; - LLUUID mImageDisabledID; - LLUUID mImageDisabledSelectedID; - std::string mImageUnselectedName; - std::string mImageSelectedName; - std::string mImageHoverSelectedName; - std::string mImageHoverUnselectedName; - std::string mImageDisabledName; - std::string mImageDisabledSelectedName; + LLUIColor mDisabledSelectedLabelColor; - LLUIColor mHighlightColor; - LLUIColor mFlashBgColor; + LLPointer<LLUIImage> mImagePressed; + LLPointer<LLUIImage> mImagePressedSelected; - LLUIColor mImageColor; - LLUIColor mDisabledImageColor; + LLUIColor mHighlightColor; + LLUIColor mFlashBgColor; - BOOL mIsToggle; - BOOL mScaleImage; + LLUIColor mImageColor; + LLUIColor mDisabledImageColor; - BOOL mDropShadowedText; - BOOL mAutoResize; - BOOL mBorderEnabled; + BOOL mIsToggle; + BOOL mScaleImage; - BOOL mFlashing; + BOOL mDropShadowedText; + BOOL mAutoResize; + BOOL mUseEllipses; + BOOL mBorderEnabled; - LLFontGL::HAlign mHAlign; - S32 mLeftHPad; - S32 mRightHPad; + BOOL mFlashing; - F32 mHoverGlowStrength; - F32 mCurGlowStrength; + LLFontGL::HAlign mHAlign; + S32 mLeftHPad; + S32 mRightHPad; - BOOL mNeedsHighlight; - BOOL mCommitOnReturn; - BOOL mFadeWhenDisabled; + F32 mHoverGlowStrength; + F32 mCurGlowStrength; - std::string mHelpURL; + BOOL mNeedsHighlight; + BOOL mCommitOnReturn; + BOOL mFadeWhenDisabled; - LLPointer<LLUIImage> mImagep; + std::string mHelpURL; - LLFrameTimer mFlashingTimer; + LLFrameTimer mFlashingTimer; }; diff --git a/indra/llui/llcheckboxctrl.cpp b/indra/llui/llcheckboxctrl.cpp index b43f91e766..455b17ffc7 100644 --- a/indra/llui/llcheckboxctrl.cpp +++ b/indra/llui/llcheckboxctrl.cpp @@ -161,7 +161,6 @@ void LLCheckBoxCtrl::onCommit() void LLCheckBoxCtrl::setEnabled(BOOL b) { LLView::setEnabled(b); - mButton->setEnabled(b); if (b) { diff --git a/indra/llui/llclipboard.cpp b/indra/llui/llclipboard.cpp index 2cb8197a67..cbd4cb380f 100644 --- a/indra/llui/llclipboard.cpp +++ b/indra/llui/llclipboard.cpp @@ -61,6 +61,12 @@ void LLClipboard::copyFromSubstring(const LLWString &src, S32 pos, S32 len, cons LLView::getWindow()->copyTextToClipboard( mString ); } +void LLClipboard::copyFromString(const LLWString &src, const LLUUID& source_id ) +{ + mSourceID = source_id; + mString = src; + LLView::getWindow()->copyTextToClipboard( mString ); +} const LLWString& LLClipboard::getPasteWString( LLUUID* source_id ) { diff --git a/indra/llui/llclipboard.h b/indra/llui/llclipboard.h index 034a7a6aeb..d7ffeb33e0 100644 --- a/indra/llui/llclipboard.h +++ b/indra/llui/llclipboard.h @@ -50,6 +50,7 @@ public: (i.e. X11/Linux). */ void copyFromSubstring(const LLWString ©_from, S32 pos, S32 len, const LLUUID& source_id = LLUUID::null ); + void copyFromString(const LLWString ©_from, const LLUUID& source_id = LLUUID::null ); BOOL canPasteString() const; const LLWString& getPasteWString(LLUUID* source_id = NULL); diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp index f8c6204afb..93d2b83c9f 100644 --- a/indra/llui/llcombobox.cpp +++ b/indra/llui/llcombobox.cpp @@ -182,12 +182,6 @@ LLComboBox::~LLComboBox() } -void LLComboBox::setEnabled(BOOL enabled) -{ - LLView::setEnabled(enabled); - mButton->setEnabled(enabled); -} - void LLComboBox::clear() { if (mTextEntry) @@ -196,8 +190,6 @@ void LLComboBox::clear() } mButton->setLabelSelected(LLStringUtil::null); mButton->setLabelUnselected(LLStringUtil::null); - mButton->setDisabledLabel(LLStringUtil::null); - mButton->setDisabledSelectedLabel(LLStringUtil::null); mList->deselectAllItems(); } @@ -376,10 +368,7 @@ void LLComboBox::setLabel(const LLStringExplicit& name) if (!mAllowTextEntry) { - mButton->setLabelUnselected(name); - mButton->setLabelSelected(name); - mButton->setDisabledLabel(name); - mButton->setDisabledSelectedLabel(name); + mButton->setLabel(name); } } @@ -441,14 +430,6 @@ void LLComboBox::setButtonVisible(BOOL visible) } } -void LLComboBox::draw() -{ - mButton->setEnabled(getEnabled() /*&& !mList->isEmpty()*/); - - // Draw children normally - LLUICtrl::draw(); -} - BOOL LLComboBox::setCurrentByIndex( S32 index ) { BOOL found = mList->selectNthItem( index ); diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h index db97b0df75..4becda195f 100644 --- a/indra/llui/llcombobox.h +++ b/indra/llui/llcombobox.h @@ -110,11 +110,8 @@ protected: public: // LLView interface - virtual void draw(); virtual void onFocusLost(); - virtual void setEnabled(BOOL enabled); - virtual BOOL handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect); virtual BOOL handleKeyHere(KEY key, MASK mask); virtual BOOL handleUnicodeCharHere(llwchar uni_char); diff --git a/indra/llui/llfiltereditor.cpp b/indra/llui/llfiltereditor.cpp index 0f36483fc2..7d6a4007a2 100644 --- a/indra/llui/llfiltereditor.cpp +++ b/indra/llui/llfiltereditor.cpp @@ -87,6 +87,12 @@ BOOL LLFilterEditor::setLabelArg( const std::string& key, const LLStringExplicit } //virtual +void LLFilterEditor::setLabel( const LLStringExplicit &new_label ) +{ + mFilterEditor->setLabel(new_label); +} + +//virtual void LLFilterEditor::clear() { if (mFilterEditor) diff --git a/indra/llui/llfiltereditor.h b/indra/llui/llfiltereditor.h index 4240fd770c..fceb82af8d 100644 --- a/indra/llui/llfiltereditor.h +++ b/indra/llui/llfiltereditor.h @@ -74,6 +74,7 @@ public: virtual LLSD getValue() const; virtual BOOL setTextArg( const std::string& key, const LLStringExplicit& text ); virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text ); + virtual void setLabel( const LLStringExplicit &new_label ); virtual void clear(); private: diff --git a/indra/llui/llflyoutbutton.cpp b/indra/llui/llflyoutbutton.cpp index 536919c072..3483bac782 100644 --- a/indra/llui/llflyoutbutton.cpp +++ b/indra/llui/llflyoutbutton.cpp @@ -74,13 +74,6 @@ void LLFlyoutButton::draw() LLComboBox::draw(); } -void LLFlyoutButton::setEnabled(BOOL enabled) -{ - mActionButton->setEnabled(enabled); - LLComboBox::setEnabled(enabled); -} - - void LLFlyoutButton::setToggleState(BOOL state) { mToggleState = state; diff --git a/indra/llui/llflyoutbutton.h b/indra/llui/llflyoutbutton.h index 1f1716593a..d8c0f1a50d 100644 --- a/indra/llui/llflyoutbutton.h +++ b/indra/llui/llflyoutbutton.h @@ -61,7 +61,6 @@ protected: friend class LLUICtrlFactory; public: virtual void draw(); - virtual void setEnabled(BOOL enabled); void setToggleState(BOOL state); diff --git a/indra/llui/llfocusmgr.cpp b/indra/llui/llfocusmgr.cpp index a66f147dcc..3899897c5f 100644 --- a/indra/llui/llfocusmgr.cpp +++ b/indra/llui/llfocusmgr.cpp @@ -49,7 +49,6 @@ LLFocusMgr::LLFocusMgr() mDefaultKeyboardFocus( NULL ), mKeystrokesOnly(FALSE), mTopCtrl( NULL ), - mFocusWeight(0.f), mAppHasFocus(TRUE) // Macs don't seem to notify us that we've gotten focus, so default to true #ifdef _DEBUG , mMouseCaptorName("none") @@ -98,8 +97,6 @@ void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, BOOL lock, BOOL keystroke return; } - //llinfos << "Keyboard focus handled by " << (new_focus ? new_focus->getName() : "nothing") << llendl; - mKeystrokesOnly = keystrokes_only; if( new_focus != mKeyboardFocus ) @@ -107,18 +104,48 @@ void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, BOOL lock, BOOL keystroke mLastKeyboardFocus = mKeyboardFocus; mKeyboardFocus = new_focus; - if( mLastKeyboardFocus ) + view_handle_list_t new_focus_list; + + // walk up the tree to root and add all views to the new_focus_list + for (LLView* ctrl = mKeyboardFocus; ctrl && ctrl != LLUI::getRootView(); ctrl = ctrl->getParent()) { - mLastKeyboardFocus->onFocusLost(); + if (ctrl) + { + new_focus_list.push_front(ctrl->getHandle()); + } } - // clear out any existing flash - if (new_focus) + view_handle_list_t::iterator new_focus_iter = new_focus_list.begin(); + view_handle_list_t::iterator old_focus_iter = mCachedKeyboardFocusList.begin(); + + // compare the new focus sub-tree to the old focus sub-tree + // iterate through the lists in lockstep until we get to a non-common ancestor + while ((new_focus_iter != new_focus_list.end()) && + (old_focus_iter != mCachedKeyboardFocusList.end()) && + ((*new_focus_iter) == (*old_focus_iter))) { - mFocusWeight = 0.f; - new_focus->onFocusReceived(); + new_focus_iter++; + old_focus_iter++; } - mFocusTimer.reset(); + + // call onFocusLost on all remaining in the old focus list + while (old_focus_iter != mCachedKeyboardFocusList.end()) + { + if (old_focus_iter->get() != NULL) { + old_focus_iter->get()->onFocusLost(); + } + old_focus_iter++; + } + + // call onFocusReceived on all remaining in the new focus list + while (new_focus_iter != new_focus_list.end()) + { + new_focus_iter->get()->onFocusReceived(); + new_focus_iter++; + } + + // cache the new focus list for next time + swap(mCachedKeyboardFocusList, new_focus_list); #ifdef _DEBUG mKeyboardFocusName = new_focus ? new_focus->getName() : std::string("none"); @@ -318,7 +345,7 @@ void LLFocusMgr::unlockFocus() F32 LLFocusMgr::getFocusFlashAmt() const { - return clamp_rescale(getFocusTime(), 0.f, FOCUS_FADE_TIME, mFocusWeight, 0.f); + return clamp_rescale(mFocusFlashTimer.getElapsedTimeF32(), 0.f, FOCUS_FADE_TIME, 1.f, 0.f); } LLColor4 LLFocusMgr::getFocusColor() const @@ -335,8 +362,7 @@ LLColor4 LLFocusMgr::getFocusColor() const void LLFocusMgr::triggerFocusFlash() { - mFocusTimer.reset(); - mFocusWeight = 1.f; + mFocusFlashTimer.reset(); } void LLFocusMgr::setAppHasFocus(BOOL focus) diff --git a/indra/llui/llfocusmgr.h b/indra/llui/llfocusmgr.h index aaeb25a870..fbe0d22084 100644 --- a/indra/llui/llfocusmgr.h +++ b/indra/llui/llfocusmgr.h @@ -63,7 +63,6 @@ public: BOOL getKeystrokesOnly() { return mKeystrokesOnly; } void setKeystrokesOnly(BOOL keystrokes_only) { mKeystrokesOnly = keystrokes_only; } - F32 getFocusTime() const { return mFocusTimer.getElapsedTimeF32(); } F32 getFocusFlashAmt() const; S32 getFocusFlashWidth() const { return llround(lerp(1.f, 3.f, getFocusFlashAmt())); } LLColor4 getFocusColor() const; @@ -102,12 +101,15 @@ private: LLUICtrl* mLastKeyboardFocus; // who last had focus LLUICtrl* mDefaultKeyboardFocus; BOOL mKeystrokesOnly; + + // caching list of keyboard focus ancestors for calling onFocusReceived and onFocusLost + typedef std::list<LLHandle<LLView> > view_handle_list_t; + view_handle_list_t mCachedKeyboardFocusList; // Top View LLUICtrl* mTopCtrl; - LLFrameTimer mFocusTimer; - F32 mFocusWeight; + LLFrameTimer mFocusFlashTimer; BOOL mAppHasFocus; diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index f94eb7fcc3..20957499bc 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -318,10 +318,8 @@ void LLLineEditor::setMaxTextLength(S32 max_text_length) void LLLineEditor::updateTextPadding() { static LLUICachedControl<S32> line_editor_hpad ("UILineEditorHPad", 0); - mTextPadLeft = llclamp(mTextPadLeft, 0, getRect().getWidth()); - mTextPadRight = llclamp(mTextPadRight, 0, getRect().getWidth()); - mMinHPixels = line_editor_hpad + mTextPadLeft; - mMaxHPixels = getRect().getWidth() - mMinHPixels - mTextPadRight; + mMinHPixels = line_editor_hpad + llclamp(mTextPadLeft, 0, getRect().getWidth());; + mMaxHPixels = getRect().getWidth() - mMinHPixels - llclamp(mTextPadRight, 0, getRect().getWidth()); } @@ -625,6 +623,8 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask) // delay cursor flashing mKeystrokeTimer.reset(); + + LLUICtrl::handleMouseDown(x,y,mask); return TRUE; } @@ -738,7 +738,9 @@ BOOL LLLineEditor::handleMouseUp(S32 x, S32 y, MASK mask) // take selection to 'primary' clipboard updatePrimary(); } - + + // We won't call LLUICtrl::handleMouseUp to avoid double calls of childrenHandleMouseUp().Just invoke the signal manually. + mMouseUpSignal(this,x,y, mask); return handled; } diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index e355cfda8b..e5c32846a0 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -176,6 +176,12 @@ LLMenuItemGL::LLMenuItemGL(const LLMenuItemGL::Params& p) std::string key_str = shortcut.substr(pipe_pos+1); LLKeyboard::keyFromString(key_str, &mAcceleratorKey); + + LL_DEBUGS("HotKeys") << "Process short cut key: shortcut: " << shortcut + << ", key str: " << key_str + << ", accelerator mask: " << mAcceleratorMask + << ", accelerator key: " << mAcceleratorKey + << LL_ENDL; } BOOL LLMenuItemGL::handleAcceleratorKey(KEY key, MASK mask) @@ -285,6 +291,7 @@ void LLMenuItemGL::appendAcceleratorString( std::string& st ) const st.append( " " ); } st.append( keystr ); + LL_DEBUGS("HotKeys") << "appendAcceleratorString: " << st << LL_ENDL; } void LLMenuItemGL::setJumpKey(KEY key) @@ -797,7 +804,7 @@ BOOL LLMenuItemCallGL::handleRightMouseUp(S32 x, S32 y, MASK mask) { if (pointInView(x, y)) { - mRightClickSignal(this, getValue()); + mRightClickSignal(this,x,y, mask); } return TRUE; @@ -2996,6 +3003,7 @@ BOOL LLMenuBarGL::handleMouseDown(S32 x, S32 y, MASK mask) return LLMenuGL::handleMouseDown(x, y, mask); } +/* BOOL LLMenuBarGL::handleRightMouseDown(S32 x, S32 y, MASK mask) { // clicks on menu bar closes existing menus from other contexts but leave @@ -3007,6 +3015,7 @@ BOOL LLMenuBarGL::handleRightMouseDown(S32 x, S32 y, MASK mask) return LLMenuGL::handleMouseDown(x, y, mask); } +*/ void LLMenuBarGL::draw() diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index 828956a217..930276f7bc 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -297,10 +297,6 @@ public: return mEnableSignal.connect(cb); } - boost::signals2::connection setRightClickedCallback( const commit_signal_t::slot_type& cb ) - { - return mRightClickSignal.connect(cb); - } private: enable_signal_t mEnableSignal; @@ -492,9 +488,6 @@ public: void buildDrawLabels(); void createJumpKeys(); - // Show popup in global screen space based on last mouse location. - static void showPopup(LLMenuGL* menu); - // Show popup at a specific location. static void showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y); @@ -716,7 +709,9 @@ public: /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask); /*virtual*/ BOOL handleJumpKey(KEY key); /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask); - /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); +// /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); + + /*virtual*/ void draw(); /*virtual*/ BOOL jumpKeysActive(); diff --git a/indra/llui/llmultislider.h b/indra/llui/llmultislider.h index 89d44eaa87..da633cc1cd 100644 --- a/indra/llui/llmultislider.h +++ b/indra/llui/llmultislider.h @@ -120,4 +120,4 @@ protected: commit_signal_t mMouseUpSignal; }; -#endif // LL_LLSLIDER_H +#endif // LL_MULTI_SLIDER_H diff --git a/indra/llui/llscrollbar.cpp b/indra/llui/llscrollbar.cpp index bc489592d4..566825ff3b 100644 --- a/indra/llui/llscrollbar.cpp +++ b/indra/llui/llscrollbar.cpp @@ -497,8 +497,8 @@ void LLScrollbar::draw() } // Draw background and thumb. - if ( ( mOrientation == VERTICAL&&(mThumbImageV.isNull() || mThumbImageV.isNull()) ) - || (mOrientation == HORIZONTAL&&(mTrackImageH.isNull() || mThumbImageH.isNull()) )) + if ( ( mOrientation == VERTICAL&&(mThumbImageV.isNull() || mThumbImageH.isNull()) ) + || (mOrientation == HORIZONTAL&&(mTrackImageH.isNull() || mTrackImageV.isNull()) )) { gl_rect_2d(mOrientation == HORIZONTAL ? mThickness : 0, mOrientation == VERTICAL ? getRect().getHeight() - 2 * mThickness : getRect().getHeight(), @@ -513,7 +513,6 @@ void LLScrollbar::draw() // Thumb LLRect outline_rect = mThumbRect; outline_rect.stretch(2); - S32 rect_fix = 0; // Background if(mOrientation == HORIZONTAL) @@ -521,7 +520,7 @@ void LLScrollbar::draw() mTrackImageH->drawSolid(mThickness //S32 x , 0 //S32 y , getRect().getWidth() - 2 * mThickness //S32 width - , getRect().getHeight()- rect_fix //S32 height + , getRect().getHeight() //S32 height , mTrackColor.get()); //const LLColor4& color if (gFocusMgr.getKeyboardFocus() == this) @@ -540,7 +539,7 @@ void LLScrollbar::draw() } else if(mOrientation == VERTICAL) { - mTrackImageV->drawSolid( 0+rect_fix //S32 x + mTrackImageV->drawSolid( 0 //S32 x , mThickness //S32 y , getRect().getWidth() //S32 width , getRect().getHeight() - 2 * mThickness //S32 height diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 79f0f9d71b..3041773fb2 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -1684,7 +1684,8 @@ BOOL LLScrollListCtrl::handleDoubleClick(S32 x, S32 y, MASK mask) // so the scroll bars will work. if (NULL == LLView::childrenHandleDoubleClick(x, y, mask)) { - if( mCanSelect && mOnDoubleClickCallback ) + // Run the callback only if an item is being double-clicked. + if( mCanSelect && hitItem(x, y) && mOnDoubleClickCallback ) { mOnDoubleClickCallback(); } diff --git a/indra/llui/llslider.cpp b/indra/llui/llslider.cpp index 9483cca104..840dd9b089 100644 --- a/indra/llui/llslider.cpp +++ b/indra/llui/llslider.cpp @@ -51,6 +51,8 @@ LLSlider::Params::Params() thumb_outline_color("thumb_outline_color"), thumb_center_color("thumb_center_color"), thumb_image("thumb_image"), + thumb_image_pressed("thumb_image_pressed"), + thumb_image_disabled("thumb_image_disabled"), track_image("track_image"), track_highlight_image("track_highlight_image"), mouse_down_callback("mouse_down_callback"), @@ -66,6 +68,8 @@ LLSlider::LLSlider(const LLSlider::Params& p) mThumbOutlineColor(p.thumb_outline_color()), mThumbCenterColor(p.thumb_center_color()), mThumbImage(p.thumb_image), + mThumbImagePressed(p.thumb_image_pressed), + mThumbImageDisabled(p.thumb_image_disabled), mTrackImage(p.track_image), mTrackHighlightImage(p.track_highlight_image) { @@ -245,10 +249,6 @@ void LLSlider::draw() // drawing solids requires texturing be disabled gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - F32 opacity = getEnabled() ? 1.f : 0.3f; - LLColor4 center_color = (mThumbCenterColor.get() % opacity); - LLColor4 track_color = (mTrackColor.get() % opacity); - // Track LLRect track_rect(mThumbImage->getWidth() / 2, getLocalRect().getCenterY() + (mTrackImage->getHeight() / 2), @@ -259,18 +259,38 @@ void LLSlider::draw() mTrackHighlightImage->draw(highlight_rect); // Thumb - if( hasMouseCapture() ) - { - // Show ghost where thumb was before dragging began. - mThumbImage->draw(mDragStartThumbRect, mThumbCenterColor.get() % 0.3f); - } if (hasFocus()) { // Draw focus highlighting. mThumbImage->drawBorder(mThumbRect, gFocusMgr.getFocusColor(), gFocusMgr.getFocusFlashWidth()); } - // Fill in the thumb. - mThumbImage->draw(mThumbRect, hasMouseCapture() ? mThumbOutlineColor.get() : center_color); + if( hasMouseCapture() ) // currently clicking on slider + { + // Show ghost where thumb was before dragging began. + if (mThumbImage.notNull()) + { + mThumbImage->draw(mDragStartThumbRect, mThumbCenterColor.get() % 0.3f); + } + if (mThumbImagePressed.notNull()) + { + mThumbImagePressed->draw(mThumbRect, mThumbOutlineColor); + } + } + else if (!isInEnabledChain()) + { + if (mThumbImageDisabled.notNull()) + { + mThumbImageDisabled->draw(mThumbRect, mThumbCenterColor); + } + } + else + { + if (mThumbImage.notNull()) + { + mThumbImage->draw(mThumbRect, mThumbCenterColor); + } + } + LLUICtrl::draw(); } diff --git a/indra/llui/llslider.h b/indra/llui/llslider.h index 088fd20d94..e2a94e4d8c 100644 --- a/indra/llui/llslider.h +++ b/indra/llui/llslider.h @@ -46,6 +46,8 @@ public: thumb_center_color; Optional<LLUIImage*> thumb_image, + thumb_image_pressed, + thumb_image_disabled, track_image, track_highlight_image; @@ -85,9 +87,11 @@ private: S32 mMouseOffset; LLRect mDragStartThumbRect; - LLUIImage* mThumbImage; - LLUIImage* mTrackImage; - LLUIImage* mTrackHighlightImage; + LLPointer<LLUIImage> mThumbImage; + LLPointer<LLUIImage> mThumbImagePressed; + LLPointer<LLUIImage> mThumbImageDisabled; + LLPointer<LLUIImage> mTrackImage; + LLPointer<LLUIImage> mTrackHighlightImage; LLRect mThumbRect; LLUIColor mTrackColor; diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index 3dd8d21f6b..f9bcb685b8 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -32,12 +32,18 @@ #include "linden_common.h" #include "lltextbox.h" +#include "lllink.h" #include "lluictrlfactory.h" #include "llfocusmgr.h" #include "llwindow.h" static LLDefaultChildRegistry::Register<LLTextBox> r("text"); +//*NOTE +// LLLink is not used in code for now, therefor Visual Studio doesn't build it. +// "link" is registered here to force Visual Studio to build LLLink class. +static LLDefaultChildRegistry::Register<LLLink> register_link("link"); + LLTextBox::Params::Params() : text_color("text_color"), length("length"), diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index 19d1d4040c..8aa7540446 100644 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -47,7 +47,6 @@ LLUICtrl::Params::Params() init_callback("init_callback"), commit_callback("commit_callback"), validate_callback("validate_callback"), - rightclick_callback("rightclick_callback"), mouseenter_callback("mouseenter_callback"), mouseleave_callback("mouseleave_callback"), control_name("control_name") @@ -199,9 +198,6 @@ void LLUICtrl::initFromParams(const Params& p) } } - if(p.rightclick_callback.isProvided()) - initCommitCallback(p.rightclick_callback, mRightClickSignal); - if(p.mouseenter_callback.isProvided()) initCommitCallback(p.mouseenter_callback, mMouseEnterSignal); @@ -282,7 +278,24 @@ void LLUICtrl::onMouseLeave(S32 x, S32 y, MASK mask) { 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); + return handled; +} +//virtual +BOOL LLUICtrl::handleMouseUp(S32 x, S32 y, MASK mask){ + BOOL handled = LLView::handleMouseUp(x,y,mask); + mMouseUpSignal(this,x,y,mask); + return handled; +} +//virtual +BOOL LLUICtrl::handleRightMouseUp(S32 x, S32 y, MASK mask){ + BOOL handled = LLView::handleRightMouseUp(x,y,mask); + mRightClickSignal(this,x,y,mask); + return handled; +} void LLUICtrl::onCommit() { mCommitSignal(this, getValue()); diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index cf6634f370..6ba3b01fcb 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -81,6 +81,8 @@ public: typedef boost::function<void (LLUICtrl* ctrl, const LLSD& param)> commit_callback_t; typedef boost::signals2::signal<void (LLUICtrl* ctrl, const LLSD& param)> commit_signal_t; + // *TODO: add xml support for this type of signal in the future + typedef boost::signals2::signal<void (LLUICtrl* ctrl, S32 x, S32 y, MASK mask)> mouse_signal_t; typedef boost::function<bool (LLUICtrl* ctrl, const LLSD& param)> enable_callback_t; typedef boost::signals2::signal<bool (LLUICtrl* ctrl, const LLSD& param), boost_boolean_combiner> enable_signal_t; @@ -144,8 +146,6 @@ public: commit_callback; Optional<EnableCallbackParam> validate_callback; - Optional<CommitCallbackParam> rightclick_callback; - Optional<CommitCallbackParam> mouseenter_callback; Optional<CommitCallbackParam> mouseleave_callback; @@ -186,6 +186,9 @@ public: /*virtual*/ BOOL getTentative() const; /*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask); /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL handleRightMouseUp(S32 x, S32 y, MASK mask); // From LLFocusableElement /*virtual*/ void setFocus( BOOL b ); @@ -253,6 +256,10 @@ public: 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 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 setRightClickedCallback( const mouse_signal_t::slot_type& cb ) { return mRightClickSignal.connect(cb); } + // *TODO: Deprecate; for backwards compatability only: boost::signals2::connection setCommitCallback( boost::function<void (LLUICtrl*,void*)> cb, void* data); boost::signals2::connection setValidateBeforeCommit( boost::function<bool (const LLSD& data)> cb ); @@ -279,11 +286,14 @@ protected: commit_signal_t mCommitSignal; enable_signal_t mValidateSignal; - commit_signal_t mRightClickSignal; commit_signal_t mMouseEnterSignal; commit_signal_t mMouseLeaveSignal; - + + mouse_signal_t mMouseDownSignal; + mouse_signal_t mMouseUpSignal; + mouse_signal_t mRightClickSignal; + LLViewModelPtr mViewModel; LLControlVariable* mControlVariable; diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h index 9dbe458bae..b82feb3f58 100644 --- a/indra/llui/lluictrlfactory.h +++ b/indra/llui/lluictrlfactory.h @@ -459,6 +459,14 @@ LLChildRegistry<DERIVED>::Register<T>::Register(const char* tag, LLWidgetCreator { const std::type_info* widget_type_infop = &typeid(T); // associate parameter block type with template .xml file + std::string* existing_tag = LLWidgetNameRegistry ::instance().getValue(&typeid(typename T::Params)); + if (existing_tag != NULL && *existing_tag != tag) + { + // duplicate entry for T::Params + // try creating empty param block in derived classes that inherit T::Params + int* crash = 0; + *crash = 0; + } LLWidgetNameRegistry ::instance().defaultRegistrar().add(&typeid(typename T::Params), tag); // associate widget type with factory function LLDefaultWidgetRegistry::instance().defaultRegistrar().add(widget_type_infop, &LLUICtrlFactory::createDefaultWidget<T>); diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index d94472a8e5..e3b61dfaa2 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -75,6 +75,8 @@ S32 LLView::sLastBottomXML = S32_MIN; BOOL LLView::sIsDrawing = FALSE; #endif +static LLDefaultChildRegistry::Register<LLView> r("view"); + LLView::Params::Params() : name("name", std::string("unnamed")), enabled("enabled", true), |