diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llmultislider.cpp | 125 | ||||
-rw-r--r-- | indra/llui/llmultislider.h | 10 | ||||
-rw-r--r-- | indra/llui/llmultisliderctrl.cpp | 12 | ||||
-rw-r--r-- | indra/llui/llmultisliderctrl.h | 13 |
4 files changed, 103 insertions, 57 deletions
diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index b5e3032626..c35b7c5496 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -61,9 +61,11 @@ LLMultiSlider::Params::Params() use_triangle("use_triangle", false), track_color("track_color"), thumb_disabled_color("thumb_disabled_color"), + thumb_highlight_color("thumb_highlight_color"), thumb_outline_color("thumb_outline_color"), thumb_center_color("thumb_center_color"), thumb_center_selected_color("thumb_center_selected_color"), + thumb_image("thumb_image"), triangle_color("triangle_color"), mouse_down_callback("mouse_down_callback"), mouse_up_callback("mouse_up_callback"), @@ -133,6 +135,12 @@ LLMultiSlider::LLMultiSlider(const LLMultiSlider::Params& p) addSlider(it->value); } } + + if (p.thumb_image.isProvided()) + { + mThumbImagep = LLUI::getUIImage(p.thumb_image()); + } + mThumbHighlightColor = p.thumb_highlight_color.isProvided() ? p.thumb_highlight_color() : static_cast<LLUIColor>(gFocusMgr.getFocusColor()); } LLMultiSlider::~LLMultiSlider() @@ -169,13 +177,15 @@ void LLMultiSlider::setSliderValue(const std::string& name, F32 value, BOOL from // increment is our distance between points, use to eliminate round error F32 threshold = mOverlapThreshold + (mIncrement / 4); // If loop overlap is enabled, check if we overlap with points 'after' max value (project to lower) - F32 loop_up_check = (mLoopOverlap && (value + threshold) > mMaxValue) ? (value + threshold - mMaxValue + mMinValue) : 0.0f; + F32 loop_up_check = (mLoopOverlap && (value + threshold) > mMaxValue) ? (value + threshold - mMaxValue + mMinValue) : mMinValue - 1.0f; // If loop overlap is enabled, check if we overlap with points 'before' min value (project to upper) - F32 loop_down_check = (mLoopOverlap && (value - threshold) < mMinValue) ? (value - threshold - mMinValue + mMaxValue) : 0.0f; + F32 loop_down_check = (mLoopOverlap && (value - threshold) < mMinValue) ? (value - threshold - mMinValue + mMaxValue) : mMaxValue + 1.0f; - for(;mIt != mValue.endMap(); mIt++) { - - F32 testVal = (F32)mIt->second.asReal() - newValue; + for(;mIt != mValue.endMap(); mIt++) + { + F32 locationVal = (F32)mIt->second.asReal(); + // Check nearby values + F32 testVal = locationVal - newValue; if (testVal > -threshold && testVal < threshold && mIt->first != name) @@ -183,17 +193,19 @@ void LLMultiSlider::setSliderValue(const std::string& name, F32 value, BOOL from hit = true; break; } - if (loop_up_check != 0 - && testVal < loop_up_check) + if (mLoopOverlap) { - hit = true; - break; - } - if (loop_down_check != 0 - && testVal > loop_down_check) - { - hit = true; - break; + // Check edge overlap values + if (locationVal < loop_up_check) + { + hit = true; + break; + } + if (locationVal > loop_down_check) + { + hit = true; + break; + } } } @@ -644,7 +656,7 @@ void LLMultiSlider::draw() mTriangleColor.get() % opacity, TRUE); } } - else if (!thumb_imagep) + else if (!thumb_imagep && !mThumbImagep) { // draw all the thumbs curSldrIt = mThumbRects.end(); @@ -674,15 +686,33 @@ void LLMultiSlider::draw() gl_rect_2d(mDragStartThumbRect, mThumbCenterColor.get() % opacity, FALSE); } } - else if( gFocusMgr.getMouseCapture() == this ) + else { - // draw drag start - thumb_imagep->drawSolid(mDragStartThumbRect, mThumbCenterColor.get() % 0.3f); + LLMouseHandler* capture = gFocusMgr.getMouseCapture(); + if (capture == this) + { + // draw drag start (ghost) + if (mThumbImagep) + { + mThumbImagep->draw(mDragStartThumbRect, mThumbCenterColor.get() % 0.3f); + } + else + { + thumb_imagep->drawSolid(mDragStartThumbRect, mThumbCenterColor.get() % 0.3f); + } + } // draw the highlight if (hasFocus() && !mCurSlider.empty()) { - thumb_imagep->drawBorder(mThumbRects[mCurSlider], gFocusMgr.getFocusColor(), gFocusMgr.getFocusFlashWidth()); + if (mThumbImagep) + { + mThumbImagep->drawBorder(mThumbRects[mCurSlider], mThumbHighlightColor, gFocusMgr.getFocusFlashWidth()); + } + else + { + thumb_imagep->drawBorder(mThumbRects[mCurSlider], gFocusMgr.getFocusColor(), gFocusMgr.getFocusFlashWidth()); + } } // draw the thumbs @@ -699,44 +729,35 @@ void LLMultiSlider::draw() } // the draw command - thumb_imagep->drawSolid(mIt->second, curThumbColor); + if (mThumbImagep) + { + mThumbImagep->draw(mIt->second); + } + else if (capture == this) + { + thumb_imagep->drawSolid(mIt->second, curThumbColor); + } + else + { + thumb_imagep->drawSolid(mIt->second, curThumbColor % opacity); + } } // draw cur slider last if(curSldrIt != mThumbRects.end()) { - thumb_imagep->drawSolid(curSldrIt->second, mThumbCenterSelectedColor.get()); - } - - } - else - { - // draw highlight - if (hasFocus() && !mCurSlider.empty()) - { - thumb_imagep->drawBorder(mThumbRects[mCurSlider], gFocusMgr.getFocusColor(), gFocusMgr.getFocusFlashWidth()); - } - - // draw thumbs - curSldrIt = mThumbRects.end(); - for(mIt = mThumbRects.begin(); mIt != mThumbRects.end(); mIt++) - { - - // choose the color - curThumbColor = mThumbCenterColor.get(); - if(mIt->first == mCurSlider) + if (mThumbImagep) { - curSldrIt = mIt; - continue; - //curThumbColor = mThumbCenterSelectedColor; - } - - thumb_imagep->drawSolid(mIt->second, curThumbColor % opacity); - } - - if(curSldrIt != mThumbRects.end()) - { - thumb_imagep->drawSolid(curSldrIt->second, mThumbCenterSelectedColor.get() % opacity); + mThumbImagep->draw(curSldrIt->second); + } + else if (capture == this) + { + thumb_imagep->drawSolid(curSldrIt->second, mThumbCenterSelectedColor.get()); + } + else + { + thumb_imagep->drawSolid(curSldrIt->second, mThumbCenterSelectedColor.get() % opacity); + } } } diff --git a/indra/llui/llmultislider.h b/indra/llui/llmultislider.h index 3884b0a2a0..52c6d1ddef 100644 --- a/indra/llui/llmultislider.h +++ b/indra/llui/llmultislider.h @@ -55,12 +55,14 @@ public: Optional<LLUIColor> track_color, thumb_disabled_color, + thumb_highlight_color, thumb_outline_color, thumb_center_color, thumb_center_selected_color, triangle_color; - Optional<std::string> orientation; + Optional<std::string> orientation, + thumb_image; Optional<CommitCallbackParam> mouse_down_callback, mouse_up_callback; @@ -105,6 +107,10 @@ public: /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask); /*virtual*/ void draw(); + S32 getMaxNumSliders() { return mMaxNumSliders; } + S32 getCurNumSliders() { return mValue.size(); } + bool canAddSliders() { return mValue.size() < mMaxNumSliders; } + protected: LLSD mValue; std::string mCurSlider; @@ -125,10 +131,12 @@ protected: mThumbRects; LLUIColor mTrackColor; LLUIColor mThumbOutlineColor; + LLUIColor mThumbHighlightColor; LLUIColor mThumbCenterColor; LLUIColor mThumbCenterSelectedColor; LLUIColor mDisabledThumbColor; LLUIColor mTriangleColor; + LLUIImagePtr mThumbImagep; //blimps on the slider, for now no 'disabled' support const EOrientation mOrientation; diff --git a/indra/llui/llmultisliderctrl.cpp b/indra/llui/llmultisliderctrl.cpp index 73792206a6..972567ef9b 100644 --- a/indra/llui/llmultisliderctrl.cpp +++ b/indra/llui/llmultisliderctrl.cpp @@ -55,6 +55,9 @@ LLMultiSliderCtrl::Params::Params() allow_overlap("allow_overlap", false), loop_overlap("loop_overlap", false), orientation("orientation"), + thumb_image("thumb_image"), + thumb_width("thumb_width"), + thumb_highlight_color("thumb_highlight_color"), overlap_threshold("overlap_threshold", 0), draw_track("draw_track", true), use_triangle("use_triangle", false), @@ -171,11 +174,18 @@ LLMultiSliderCtrl::LLMultiSliderCtrl(const LLMultiSliderCtrl::Params& p) params.max_sliders(p.max_sliders); params.allow_overlap(p.allow_overlap); params.loop_overlap(p.loop_overlap); - params.orientation(p.orientation()); if (p.overlap_threshold.isProvided()) { params.overlap_threshold = p.overlap_threshold; } + params.orientation(p.orientation); + params.thumb_image(p.thumb_image); + params.thumb_highlight_color(p.thumb_highlight_color); + if (p.thumb_width.isProvided()) + { + // otherwise should be provided by template + params.thumb_width(p.thumb_width); + } params.draw_track(p.draw_track); params.use_triangle(p.use_triangle); params.control_name(p.control_name); diff --git a/indra/llui/llmultisliderctrl.h b/indra/llui/llmultisliderctrl.h index a1593c28e0..c370ebf505 100644 --- a/indra/llui/llmultisliderctrl.h +++ b/indra/llui/llmultisliderctrl.h @@ -51,19 +51,22 @@ public: text_width; Optional<bool> show_text, can_edit_text; - Optional<S32> decimal_digits; + Optional<S32> decimal_digits, + thumb_width; Optional<S32> max_sliders; Optional<bool> allow_overlap, loop_overlap, draw_track, use_triangle; - Optional<std::string> orientation; + Optional<std::string> orientation, + thumb_image; Optional<F32> overlap_threshold; Optional<LLUIColor> text_color, - text_disabled_color; + text_disabled_color, + thumb_highlight_color; Optional<CommitCallbackParam> mouse_down_callback, mouse_up_callback; @@ -115,6 +118,10 @@ public: F32 getMinValue() const { return mMultiSlider->getMinValue(); } F32 getMaxValue() const { return mMultiSlider->getMaxValue(); } + S32 getMaxNumSliders() { return mMultiSlider->getMaxNumSliders(); } + S32 getCurNumSliders() { return mMultiSlider->getCurNumSliders(); } + bool canAddSliders() { return mMultiSlider->canAddSliders(); } + void setLabel(const std::string& label) { if (mLabelBox) mLabelBox->setText(label); } void setLabelColor(const LLColor4& c) { mTextEnabledColor = c; } void setDisabledLabelColor(const LLColor4& c) { mTextDisabledColor = c; } |