diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llbutton.cpp | 234 | ||||
-rw-r--r-- | indra/llui/llbutton.h | 115 | ||||
-rw-r--r-- | indra/llui/llcheckboxctrl.cpp | 1 | ||||
-rw-r--r-- | indra/llui/llcombobox.cpp | 21 | ||||
-rw-r--r-- | indra/llui/llcombobox.h | 3 | ||||
-rw-r--r-- | indra/llui/llflyoutbutton.cpp | 7 | ||||
-rw-r--r-- | indra/llui/llflyoutbutton.h | 1 | ||||
-rw-r--r-- | indra/llui/llfocusmgr.cpp | 8 | ||||
-rw-r--r-- | indra/llui/llfocusmgr.h | 4 | ||||
-rw-r--r-- | indra/llui/lllineeditor.cpp | 6 | ||||
-rw-r--r-- | indra/llui/llmultislider.h | 2 | ||||
-rw-r--r-- | indra/llui/llscrollbar.cpp | 9 | ||||
-rw-r--r-- | indra/llui/llslider.cpp | 42 | ||||
-rw-r--r-- | indra/llui/llslider.h | 10 | ||||
-rw-r--r-- | indra/llui/lluictrlfactory.h | 8 |
15 files changed, 180 insertions, 291 deletions
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index fc3af34951..ac368fd785 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -70,6 +70,8 @@ LLButton::Params::Params() 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 +110,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 +119,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()), @@ -182,6 +185,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 +201,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()) @@ -427,7 +450,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 +485,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 +497,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 +508,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 +540,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 ) ) ) + { + imagep = mImageDisabledSelected; + } + else if (!mImageDisabled.isNull() + && !enabled + && !selected) { - mImagep = mImageUnselected; + imagep = mImageDisabled; } if (mFlashing) @@ -540,26 +585,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 +594,7 @@ void LLButton::draw() LLColor4 label_color; // label changes when button state changes, not when pressed - if ( getEnabled() ) + if ( enabled ) { if ( getToggleState() ) { @@ -596,32 +622,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 +650,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 +711,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; } @@ -777,19 +789,19 @@ void LLButton::draw() NULL, FALSE, FALSE); } - 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 +863,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 +877,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 +903,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 +937,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 +947,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 +984,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..93e0414a02 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -84,6 +84,8 @@ public: image_hover_unselected, image_disabled_selected, image_disabled, + image_pressed, + image_pressed_selected, image_overlay; Optional<std::string> image_overlay_alignment; @@ -190,11 +192,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 +206,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 +219,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 +237,84 @@ 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 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/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/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 7e452a25a3..3fef215661 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") @@ -146,8 +145,6 @@ void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, BOOL lock, BOOL keystroke // cache the new focus list for next time swap(mCachedKeyboardFocusList, new_focus_list); - mFocusTimer.reset(); - #ifdef _DEBUG mKeyboardFocusName = new_focus ? new_focus->getName() : std::string("none"); #endif @@ -346,7 +343,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 @@ -363,8 +360,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 165a114f3d..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; @@ -110,8 +109,7 @@ private: // 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..02ee567803 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()); } 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/llslider.cpp b/indra/llui/llslider.cpp index f167836bee..1c394a71dd 100644 --- a/indra/llui/llslider.cpp +++ b/indra/llui/llslider.cpp @@ -49,6 +49,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"), @@ -64,6 +66,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) { @@ -243,10 +247,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), @@ -257,18 +257,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/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>); |