From 7a0a580eddf4fb7608d1bd84b7eccd2653075184 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 17 May 2018 15:50:27 +0300 Subject: MAINT-8344 Prevent multislider from locking in infinit cycle --- indra/llui/llmultislider.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'indra/llui/llmultislider.cpp') diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index 0aa3e17075..aab77c2bd8 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -334,10 +334,15 @@ void LLMultiSlider::deleteSlider(const std::string& name) void LLMultiSlider::clear() { - while(mThumbRects.size() > 0) { + while(mThumbRects.size() > 0 && mValue.size() > 0) { deleteCurSlider(); } + if (mThumbRects.size() > 0 || mValue.size() > 0) + { + LL_WARNS() << "Failed to fully clear Multi slider" << LL_ENDL; + } + LLF32UICtrl::clear(); } -- cgit v1.2.3 From e4973e0f92b524e7f9c2d10745f4c5e3a8557284 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 18 May 2018 21:09:42 +0300 Subject: MAINT-8344 Day Cycle Editor (part 3) --- indra/llui/llmultislider.cpp | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) (limited to 'indra/llui/llmultislider.cpp') diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index aab77c2bd8..93045a6578 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -196,7 +196,11 @@ void LLMultiSlider::setValue(const LLSD& value) F32 LLMultiSlider::getSliderValue(const std::string& name) const { - return (F32)mValue[name].asReal(); + if (mValue.has(name)) + { + return (F32)mValue[name].asReal(); + } + return 0; } void LLMultiSlider::setCurSlider(const std::string& name) @@ -206,6 +210,11 @@ void LLMultiSlider::setCurSlider(const std::string& name) } } +void LLMultiSlider::resetCurSlider() +{ + mCurSlider = LLStringUtil::null; +} + const std::string& LLMultiSlider::addSlider() { return addSlider(mInitialValue); @@ -421,20 +430,23 @@ BOOL LLMultiSlider::handleMouseDown(S32 x, S32 y, MASK mask) } } - // Find the offset of the actual mouse location from the center of the thumb. - if (mThumbRects[mCurSlider].pointInRect(x,y)) + if (!mCurSlider.empty()) { - mMouseOffset = (mThumbRects[mCurSlider].mLeft + mThumbWidth/2) - x; - } - else - { - mMouseOffset = 0; - } + // Find the offset of the actual mouse location from the center of the thumb. + if (mThumbRects[mCurSlider].pointInRect(x,y)) + { + mMouseOffset = (mThumbRects[mCurSlider].mLeft + mThumbWidth/2) - x; + } + else + { + mMouseOffset = 0; + } - // Start dragging the thumb - // No handler needed for focus lost since this class has no state that depends on it. - gFocusMgr.setMouseCapture( this ); - mDragStartThumbRect = mThumbRects[mCurSlider]; + // Start dragging the thumb + // No handler needed for focus lost since this class has no state that depends on it. + gFocusMgr.setMouseCapture( this ); + mDragStartThumbRect = mThumbRects[mCurSlider]; + } } make_ui_sound("UISndClick"); @@ -551,7 +563,7 @@ void LLMultiSlider::draw() thumb_imagep->drawSolid(mDragStartThumbRect, mThumbCenterColor.get() % 0.3f); // draw the highlight - if (hasFocus()) + if (hasFocus() && !mCurSlider.empty()) { thumb_imagep->drawBorder(mThumbRects[mCurSlider], gFocusMgr.getFocusColor(), gFocusMgr.getFocusFlashWidth()); } @@ -583,7 +595,7 @@ void LLMultiSlider::draw() else { // draw highlight - if (hasFocus()) + if (hasFocus() && !mCurSlider.empty()) { thumb_imagep->drawBorder(mThumbRects[mCurSlider], gFocusMgr.getFocusColor(), gFocusMgr.getFocusFlashWidth()); } -- cgit v1.2.3 From 2ddad24c4d5e64711cdbffd98e290d3da8e9714a Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 30 May 2018 17:08:28 -0700 Subject: Timeline behavior in day cycle edit. --- indra/llui/llmultislider.cpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'indra/llui/llmultislider.cpp') diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index 93045a6578..5cfe79267f 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -210,6 +210,19 @@ void LLMultiSlider::setCurSlider(const std::string& name) } } +F32 LLMultiSlider::getSliderValueFromX(S32 xpos) const +{ + S32 left_edge = mThumbWidth / 2; + S32 right_edge = getRect().getWidth() - (mThumbWidth / 2); + + xpos += mMouseOffset; + xpos = llclamp(xpos, left_edge, right_edge); + + F32 t = F32(xpos - left_edge) / (right_edge - left_edge); + + return((t * (mMaxValue - mMinValue)) + mMinValue); +} + void LLMultiSlider::resetCurSlider() { mCurSlider = LLStringUtil::null; @@ -359,14 +372,15 @@ BOOL LLMultiSlider::handleHover(S32 x, S32 y, MASK mask) { if( gFocusMgr.getMouseCapture() == this ) { - S32 left_edge = mThumbWidth/2; - S32 right_edge = getRect().getWidth() - (mThumbWidth/2); - - x += mMouseOffset; - x = llclamp( x, left_edge, right_edge ); - - F32 t = F32(x - left_edge) / (right_edge - left_edge); - setCurSliderValue(t * (mMaxValue - mMinValue) + mMinValue ); +// S32 left_edge = mThumbWidth/2; +// S32 right_edge = getRect().getWidth() - (mThumbWidth/2); +// +// x += mMouseOffset; +// x = llclamp( x, left_edge, right_edge ); +// +// F32 t = F32(x - left_edge) / (right_edge - left_edge); +// setCurSliderValue(t * (mMaxValue - mMinValue) + mMinValue ); + setCurSliderValue(getSliderValueFromX(x)); onCommit(); getWindow()->setCursor(UI_CURSOR_ARROW); -- cgit v1.2.3 From c822d8af16428cf245ae57305a4f39d3fccd672b Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 20 Jul 2018 19:10:22 +0300 Subject: MAINT-8344 implement slider support for an overlap threshold and reenable shift-copy --- indra/llui/llmultislider.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'indra/llui/llmultislider.cpp') diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index 5cfe79267f..cd9c77585a 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -41,8 +41,6 @@ static LLDefaultChildRegistry::Register r("multi_slider_bar"); -const F32 FLOAT_THRESHOLD = 0.00001f; - S32 LLMultiSlider::mNameCounter = 0; LLMultiSlider::SliderParams::SliderParams() @@ -54,6 +52,7 @@ LLMultiSlider::SliderParams::SliderParams() LLMultiSlider::Params::Params() : max_sliders("max_sliders", 1), allow_overlap("allow_overlap", false), + overlap_threshold("overlap_threshold", 0), draw_track("draw_track", true), use_triangle("use_triangle", false), track_color("track_color"), @@ -98,6 +97,15 @@ LLMultiSlider::LLMultiSlider(const LLMultiSlider::Params& p) setMouseUpCallback(initCommitCallback(p.mouse_up_callback)); } + if (p.overlap_threshold.isProvided()) + { + mOverlapThreshold = p.overlap_threshold; + } + else + { + mOverlapThreshold = 0; + } + for (LLInitParam::ParamIterator::const_iterator it = p.sliders.begin(); it != p.sliders.end(); ++it) @@ -143,11 +151,14 @@ void LLMultiSlider::setSliderValue(const std::string& name, F32 value, BOOL from // look at the current spot // and see if anything is there LLSD::map_iterator mIt = mValue.beginMap(); + F32 threshold = mOverlapThreshold + (mIncrement / 4); // increment is our distance between points, use to eliminate round error for(;mIt != mValue.endMap(); mIt++) { F32 testVal = (F32)mIt->second.asReal() - newValue; - if(testVal > -FLOAT_THRESHOLD && testVal < FLOAT_THRESHOLD && - mIt->first != name) { + if (testVal > -threshold + && testVal < threshold + && mIt->first != name) + { hit = true; break; } @@ -300,11 +311,13 @@ bool LLMultiSlider::findUnusedValue(F32& initVal) // look at the current spot // and see if anything is there + F32 threshold = mOverlapThreshold + (mIncrement / 4); LLSD::map_iterator mIt = mValue.beginMap(); for(;mIt != mValue.endMap(); mIt++) { F32 testVal = (F32)mIt->second.asReal() - initVal; - if(testVal > -FLOAT_THRESHOLD && testVal < FLOAT_THRESHOLD) { + if(testVal > -threshold && testVal < threshold) + { hit = true; break; } -- cgit v1.2.3 From 51abc168c03f80d63c85d4bb48624f440b585390 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 3 Aug 2018 21:01:43 +0300 Subject: MAINT-8902 fix encroaching 'legacy' issues --- indra/llui/llmultislider.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'indra/llui/llmultislider.cpp') diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index cd9c77585a..725f1e8f65 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -41,6 +41,8 @@ static LLDefaultChildRegistry::Register r("multi_slider_bar"); +const F32 FLOAT_THRESHOLD = 0.00001f; + S32 LLMultiSlider::mNameCounter = 0; LLMultiSlider::SliderParams::SliderParams() @@ -52,6 +54,7 @@ LLMultiSlider::SliderParams::SliderParams() LLMultiSlider::Params::Params() : max_sliders("max_sliders", 1), allow_overlap("allow_overlap", false), + loop_overlap("loop_overlap", false), overlap_threshold("overlap_threshold", 0), draw_track("draw_track", true), use_triangle("use_triangle", false), @@ -73,6 +76,7 @@ LLMultiSlider::LLMultiSlider(const LLMultiSlider::Params& p) mDragStartThumbRect( 0, getRect().getHeight(), p.thumb_width, 0 ), mMaxNumSliders(p.max_sliders), mAllowOverlap(p.allow_overlap), + mLoopOverlap(p.loop_overlap), mDrawTrack(p.draw_track), mUseTriangle(p.use_triangle), mTrackColor(p.track_color()), @@ -151,7 +155,14 @@ void LLMultiSlider::setSliderValue(const std::string& name, F32 value, BOOL from // look at the current spot // and see if anything is there LLSD::map_iterator mIt = mValue.beginMap(); - F32 threshold = mOverlapThreshold + (mIncrement / 4); // increment is our distance between points, use to eliminate round error + + // 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; + // 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; + for(;mIt != mValue.endMap(); mIt++) { F32 testVal = (F32)mIt->second.asReal() - newValue; @@ -162,6 +173,18 @@ void LLMultiSlider::setSliderValue(const std::string& name, F32 value, BOOL from hit = true; break; } + if (loop_up_check != 0 + && testVal < loop_up_check) + { + hit = true; + break; + } + if (loop_down_check != 0 + && testVal > loop_down_check) + { + hit = true; + break; + } } // if none found, stop @@ -311,7 +334,7 @@ bool LLMultiSlider::findUnusedValue(F32& initVal) // look at the current spot // and see if anything is there - F32 threshold = mOverlapThreshold + (mIncrement / 4); + F32 threshold = mAllowOverlap ? FLOAT_THRESHOLD : mOverlapThreshold + (mIncrement / 4); LLSD::map_iterator mIt = mValue.beginMap(); for(;mIt != mValue.endMap(); mIt++) { -- cgit v1.2.3 From e539236a75a163b1c6748617bd1e4d2b84aaa3d6 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 6 Sep 2018 21:29:28 +0300 Subject: MAINT-9099 Implementation of vertical orientation support for multislider --- indra/llui/llmultislider.cpp | 95 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 77 insertions(+), 18 deletions(-) (limited to 'indra/llui/llmultislider.cpp') diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index 725f1e8f65..6d6b6c4e90 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -55,6 +55,7 @@ LLMultiSlider::Params::Params() : max_sliders("max_sliders", 1), allow_overlap("allow_overlap", false), loop_overlap("loop_overlap", false), + orientation("orientation"), overlap_threshold("overlap_threshold", 0), draw_track("draw_track", true), use_triangle("use_triangle", false), @@ -86,6 +87,7 @@ LLMultiSlider::LLMultiSlider(const LLMultiSlider::Params& p) mDisabledThumbColor(p.thumb_disabled_color()), mTriangleColor(p.triangle_color()), mThumbWidth(p.thumb_width), + mOrientation((p.orientation() == "vertical") ? VERTICAL : HORIZONTAL), mMouseDownSignal(NULL), mMouseUpSignal(NULL) { @@ -204,13 +206,26 @@ void LLMultiSlider::setSliderValue(const std::string& name, F32 value, BOOL from } F32 t = (newValue - mMinValue) / (mMaxValue - mMinValue); + if (mOrientation == HORIZONTAL) + { + S32 left_edge = mThumbWidth/2; + S32 right_edge = getRect().getWidth() - (mThumbWidth/2); + + S32 x = left_edge + S32( t * (right_edge - left_edge) ); + + mThumbRects[name].mLeft = x - (mThumbWidth / 2); + mThumbRects[name].mRight = x + (mThumbWidth / 2); + } + else + { + S32 bottom_edge = mThumbWidth/2; + S32 top_edge = getRect().getHeight() - (mThumbWidth/2); - S32 left_edge = mThumbWidth/2; - S32 right_edge = getRect().getWidth() - (mThumbWidth/2); + S32 x = bottom_edge + S32( t * (top_edge - bottom_edge) ); - S32 x = left_edge + S32( t * (right_edge - left_edge) ); - mThumbRects[name].mLeft = x - (mThumbWidth/2); - mThumbRects[name].mRight = x + (mThumbWidth/2); + mThumbRects[name].mTop = x + (mThumbWidth / 2); + mThumbRects[name].mBottom = x - (mThumbWidth / 2); + } } void LLMultiSlider::setValue(const LLSD& value) @@ -244,15 +259,29 @@ void LLMultiSlider::setCurSlider(const std::string& name) } } -F32 LLMultiSlider::getSliderValueFromX(S32 xpos) const +F32 LLMultiSlider::getSliderValueFromPos(S32 xpos, S32 ypos) const { - S32 left_edge = mThumbWidth / 2; - S32 right_edge = getRect().getWidth() - (mThumbWidth / 2); + F32 t = 0; + if (mOrientation == HORIZONTAL) + { + S32 left_edge = mThumbWidth / 2; + S32 right_edge = getRect().getWidth() - (mThumbWidth / 2); - xpos += mMouseOffset; - xpos = llclamp(xpos, left_edge, right_edge); + xpos += mMouseOffset; + xpos = llclamp(xpos, left_edge, right_edge); - F32 t = F32(xpos - left_edge) / (right_edge - left_edge); + t = F32(xpos - left_edge) / (right_edge - left_edge); + } + else + { + S32 bottom_edge = mThumbWidth / 2; + S32 top_edge = getRect().getHeight() - (mThumbWidth / 2); + + ypos += mMouseOffset; + ypos = llclamp(ypos, bottom_edge, top_edge); + + t = F32(ypos - bottom_edge) / (top_edge - bottom_edge); + } return((t * (mMaxValue - mMinValue)) + mMinValue); } @@ -286,7 +315,14 @@ const std::string& LLMultiSlider::addSlider(F32 val) } // add a new thumb rect - mThumbRects[newName.str()] = LLRect( 0, getRect().getHeight(), mThumbWidth, 0 ); + if (mOrientation == HORIZONTAL) + { + mThumbRects[newName.str()] = LLRect(0, getRect().getHeight(), mThumbWidth, 0); + } + else + { + mThumbRects[newName.str()] = LLRect(0, mThumbWidth, getRect().getWidth(), 0); + } // add the value and set the current slider to this one mValue.insert(newName.str(), initVal); @@ -312,7 +348,14 @@ void LLMultiSlider::addSlider(F32 val, const std::string& name) } // add a new thumb rect - mThumbRects[name] = LLRect( 0, getRect().getHeight(), mThumbWidth, 0 ); + if (mOrientation == HORIZONTAL) + { + mThumbRects[name] = LLRect(0, getRect().getHeight(), mThumbWidth, 0); + } + else + { + mThumbRects[name] = LLRect(0, mThumbWidth, getRect().getWidth(), 0); + } // add the value and set the current slider to this one mValue.insert(name, initVal); @@ -416,7 +459,7 @@ BOOL LLMultiSlider::handleHover(S32 x, S32 y, MASK mask) // // F32 t = F32(x - left_edge) / (right_edge - left_edge); // setCurSliderValue(t * (mMaxValue - mMinValue) + mMinValue ); - setCurSliderValue(getSliderValueFromX(x)); + setCurSliderValue(getSliderValueFromPos(x, y)); onCommit(); getWindow()->setCursor(UI_CURSOR_ARROW); @@ -485,7 +528,14 @@ BOOL LLMultiSlider::handleMouseDown(S32 x, S32 y, MASK mask) // Find the offset of the actual mouse location from the center of the thumb. if (mThumbRects[mCurSlider].pointInRect(x,y)) { - mMouseOffset = (mThumbRects[mCurSlider].mLeft + mThumbWidth/2) - x; + if (mOrientation == HORIZONTAL) + { + mMouseOffset = (mThumbRects[mCurSlider].mLeft + mThumbWidth / 2) - x; + } + else + { + mMouseOffset = (mThumbRects[mCurSlider].mBottom + mThumbWidth / 2) - y; + } } else { @@ -550,9 +600,18 @@ void LLMultiSlider::draw() // Track LLUIImagePtr thumb_imagep = LLUI::getUIImage("Rounded_Square"); - static LLUICachedControl multi_track_height ("UIMultiTrackHeight", 0); - S32 height_offset = (getRect().getHeight() - multi_track_height) / 2; - LLRect track_rect(0, getRect().getHeight() - height_offset, getRect().getWidth(), height_offset ); + static LLUICachedControl multi_track_height_width ("UIMultiTrackHeight", 0); + S32 height_offset = 0; + S32 width_offset = 0; + if (mOrientation == HORIZONTAL) + { + height_offset = (getRect().getHeight() - multi_track_height_width) / 2; + } + else + { + width_offset = (getRect().getWidth() - multi_track_height_width) / 2; + } + LLRect track_rect(width_offset, getRect().getHeight() - height_offset, getRect().getWidth() - width_offset, height_offset); if(mDrawTrack) -- cgit v1.2.3 From 43c8f5959f8afaf2f67fbbf49e78965802859b55 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 10 Sep 2018 16:44:56 +0300 Subject: MAINT-9099 Adjustable region altitudes. --- indra/llui/llmultislider.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'indra/llui/llmultislider.cpp') diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index 6d6b6c4e90..b5e3032626 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -74,7 +74,6 @@ LLMultiSlider::Params::Params() LLMultiSlider::LLMultiSlider(const LLMultiSlider::Params& p) : LLF32UICtrl(p), mMouseOffset( 0 ), - mDragStartThumbRect( 0, getRect().getHeight(), p.thumb_width, 0 ), mMaxNumSliders(p.max_sliders), mAllowOverlap(p.allow_overlap), mLoopOverlap(p.loop_overlap), @@ -93,7 +92,16 @@ LLMultiSlider::LLMultiSlider(const LLMultiSlider::Params& p) { mValue.emptyMap(); mCurSlider = LLStringUtil::null; - + + if (mOrientation == HORIZONTAL) + { + mDragStartThumbRect = LLRect(0, getRect().getHeight(), p.thumb_width, 0); + } + else + { + mDragStartThumbRect = LLRect(0, p.thumb_width, getRect().getWidth(), 0); + } + if (p.mouse_down_callback.isProvided()) { setMouseDownCallback(initCommitCallback(p.mouse_down_callback)); -- cgit v1.2.3 From c5936bbba031272b1deb78ce8ea52663d033695b Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Wed, 12 Sep 2018 21:02:58 +0300 Subject: SL-1961 Icon support for multislider and icons on altitudes slider --- indra/llui/llmultislider.cpp | 91 ++++++++++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 37 deletions(-) (limited to 'indra/llui/llmultislider.cpp') diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index b5e3032626..caf9f06074 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() : gFocusMgr.getFocusColor(); } LLMultiSlider::~LLMultiSlider() @@ -644,7 +652,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 +682,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 +725,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); + } } } -- cgit v1.2.3 From 53de3916a16e316543cd12491556999a4c84f545 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 13 Sep 2018 10:48:55 -0700 Subject: Explicit cast for LLUIColor --- indra/llui/llmultislider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui/llmultislider.cpp') diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index caf9f06074..ef907e620e 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -140,7 +140,7 @@ LLMultiSlider::LLMultiSlider(const LLMultiSlider::Params& p) { mThumbImagep = LLUI::getUIImage(p.thumb_image()); } - mThumbHighlightColor = p.thumb_highlight_color.isProvided() ? p.thumb_highlight_color() : gFocusMgr.getFocusColor(); + mThumbHighlightColor = p.thumb_highlight_color.isProvided() ? p.thumb_highlight_color() : static_cast(gFocusMgr.getFocusColor()); } LLMultiSlider::~LLMultiSlider() -- cgit v1.2.3 From 8290206887972bcd3d3acac0a02d9df37a82e637 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 14 Sep 2018 17:52:08 +0300 Subject: SL-9653 Multy slider edge overlap cases --- indra/llui/llmultislider.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'indra/llui/llmultislider.cpp') diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index ef907e620e..c35b7c5496 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -177,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) @@ -191,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) - { - hit = true; - break; - } - if (loop_down_check != 0 - && testVal > loop_down_check) + if (mLoopOverlap) { - hit = true; - break; + // Check edge overlap values + if (locationVal < loop_up_check) + { + hit = true; + break; + } + if (locationVal > loop_down_check) + { + hit = true; + break; + } } } -- cgit v1.2.3 From b030d7036f87d30babb4a8df8d256113f46182e9 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 5 Oct 2018 19:31:35 +0300 Subject: SL-1961 EEP correct disabling of altitude multislider and cleanup --- indra/llui/llmultislider.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'indra/llui/llmultislider.cpp') diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index c35b7c5496..ece6edd285 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -731,7 +731,14 @@ void LLMultiSlider::draw() // the draw command if (mThumbImagep) { - mThumbImagep->draw(mIt->second); + if (getEnabled()) + { + mThumbImagep->draw(mIt->second); + } + else + { + mThumbImagep->draw(mIt->second, LLColor4::grey % 0.8f); + } } else if (capture == this) { @@ -748,7 +755,14 @@ void LLMultiSlider::draw() { if (mThumbImagep) { - mThumbImagep->draw(curSldrIt->second); + if (getEnabled()) + { + mThumbImagep->draw(curSldrIt->second); + } + else + { + mThumbImagep->draw(curSldrIt->second, LLColor4::grey % 0.8f); + } } else if (capture == this) { -- cgit v1.2.3 From 58ffb2e4b11d7aaf1fb66531f4925bd359f551cb Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Thu, 29 Nov 2018 17:55:23 +0200 Subject: SL-10141 FIXED [EEP] Neighboring sky levels may be closer than 100 meters to each other in edit mode --- indra/llui/llmultislider.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llui/llmultislider.cpp') diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index ece6edd285..9a7b6f9f6b 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -113,9 +113,9 @@ LLMultiSlider::LLMultiSlider(const LLMultiSlider::Params& p) setMouseUpCallback(initCommitCallback(p.mouse_up_callback)); } - if (p.overlap_threshold.isProvided()) + if (p.overlap_threshold.isProvided() && p.overlap_threshold > mIncrement) { - mOverlapThreshold = p.overlap_threshold; + mOverlapThreshold = p.overlap_threshold - mIncrement; } else { -- cgit v1.2.3 From 6762c4515a9b0f98164d6efd191abec5ca4dd211 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 7 Dec 2018 17:10:05 +0200 Subject: SL-1894 When crossing regions altitude slider could misbehave --- indra/llui/llmultislider.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'indra/llui/llmultislider.cpp') diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index 9a7b6f9f6b..ed93b3d44c 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -354,17 +354,17 @@ const std::string& LLMultiSlider::addSlider(F32 val) return mCurSlider; } -void LLMultiSlider::addSlider(F32 val, const std::string& name) +bool LLMultiSlider::addSlider(F32 val, const std::string& name) { F32 initVal = val; if(mValue.size() >= mMaxNumSliders) { - return; + return false; } bool foundOne = findUnusedValue(initVal); if(!foundOne) { - return; + return false; } // add a new thumb rect @@ -383,6 +383,8 @@ void LLMultiSlider::addSlider(F32 val, const std::string& name) // move the slider setSliderValue(mCurSlider, initVal, TRUE); + + return true; } bool LLMultiSlider::findUnusedValue(F32& initVal) -- cgit v1.2.3 From 8227a0b270f6e7cc521adeb7b97ad2d5fb646973 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 21 Dec 2018 15:30:57 -0800 Subject: SL-10279: Rework the environment pannel. Still in progress. --- indra/llui/llmultislider.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indra/llui/llmultislider.cpp') diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index ed93b3d44c..f30ce28b9d 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -306,6 +306,15 @@ F32 LLMultiSlider::getSliderValueFromPos(S32 xpos, S32 ypos) const return((t * (mMaxValue - mMinValue)) + mMinValue); } + +LLRect LLMultiSlider::getSliderThumbRect(const std::string& name) const +{ + auto it = mThumbRects.find(name); + if (it != mThumbRects.end()) + return (*it).second; + return LLRect(); +} + void LLMultiSlider::resetCurSlider() { mCurSlider = LLStringUtil::null; -- cgit v1.2.3 From d607d81dba25dfe7dd1ecdf123af656ca939924f Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 2 Jan 2019 17:10:15 -0800 Subject: SL-10279: Temp fix for stale estate info when editing parcel environment. --- indra/llui/llmultislider.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'indra/llui/llmultislider.cpp') diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index f30ce28b9d..61e8bdd38c 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -315,6 +315,21 @@ LLRect LLMultiSlider::getSliderThumbRect(const std::string& name) const return LLRect(); } +void LLMultiSlider::setSliderThumbImage(const std::string &name) +{ + if (!name.empty()) + { + mThumbImagep = LLUI::getUIImage(name); + } + else + clearSliderThumbImage(); +} + +void LLMultiSlider::clearSliderThumbImage() +{ + mThumbImagep = NULL; +} + void LLMultiSlider::resetCurSlider() { mCurSlider = LLStringUtil::null; -- cgit v1.2.3 From 531ad5b3ec1b6785bf6cde04c1d7203233b552a2 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 31 Jan 2019 18:45:01 +0200 Subject: SL-1531 EEP Visual feedback on the timeline --- indra/llui/llmultislider.cpp | 102 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 83 insertions(+), 19 deletions(-) (limited to 'indra/llui/llmultislider.cpp') diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index 61e8bdd38c..b8f0a01b86 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -497,14 +497,6 @@ BOOL LLMultiSlider::handleHover(S32 x, S32 y, MASK mask) { if( gFocusMgr.getMouseCapture() == this ) { -// S32 left_edge = mThumbWidth/2; -// S32 right_edge = getRect().getWidth() - (mThumbWidth/2); -// -// x += mMouseOffset; -// x = llclamp( x, left_edge, right_edge ); -// -// F32 t = F32(x - left_edge) / (right_edge - left_edge); -// setCurSliderValue(t * (mMaxValue - mMinValue) + mMinValue ); setCurSliderValue(getSliderValueFromPos(x, y)); onCommit(); @@ -513,6 +505,27 @@ BOOL LLMultiSlider::handleHover(S32 x, S32 y, MASK mask) } else { + if (getEnabled()) + { + if (mHoverSlider.empty() || !getSliderThumbRect(mHoverSlider).pointInRect(x, y)) + { + mHoverSlider.clear(); + std::map::iterator mIt = mThumbRects.begin(); + for (; mIt != mThumbRects.end(); mIt++) + { + if (mIt->second.pointInRect(x, y)) + { + mHoverSlider = mIt->first; + break; + } + } + } + } + else + { + mHoverSlider.clear(); + } + getWindow()->setCursor(UI_CURSOR_ARROW); LL_DEBUGS("UserInput") << "hover handled by " << getName() << " (inactive)" << LL_ENDL; } @@ -625,6 +638,13 @@ BOOL LLMultiSlider::handleKeyHere(KEY key, MASK mask) return handled; } +/*virtual*/ +void LLMultiSlider::onMouseLeave(S32 x, S32 y, MASK mask) +{ + mHoverSlider.clear(); + LLF32UICtrl::onMouseLeave(x, y, mask); +} + void LLMultiSlider::draw() { static LLUICachedControl extra_triangle_height ("UIExtraTriangleHeight", 0); @@ -633,6 +653,7 @@ void LLMultiSlider::draw() std::map::iterator mIt; std::map::iterator curSldrIt; + std::map::iterator hoverSldrIt; // Draw background and thumb. @@ -686,6 +707,7 @@ void LLMultiSlider::draw() { // draw all the thumbs curSldrIt = mThumbRects.end(); + hoverSldrIt = mThumbRects.end(); for(mIt = mThumbRects.begin(); mIt != mThumbRects.end(); mIt++) { // choose the color @@ -694,15 +716,21 @@ void LLMultiSlider::draw() curSldrIt = mIt; continue; - //curThumbColor = mThumbCenterSelectedColor; + } + if (mIt->first == mHoverSlider && getEnabled() && gFocusMgr.getMouseCapture() != this) + { + // draw last, after current one + hoverSldrIt = mIt; + continue; } // the draw command gl_rect_2d(mIt->second, curThumbColor, TRUE); } - // now draw the current slider - if(curSldrIt != mThumbRects.end()) { + // now draw the current and hover sliders + if(curSldrIt != mThumbRects.end()) + { gl_rect_2d(curSldrIt->second, mThumbCenterSelectedColor.get(), TRUE); } @@ -711,6 +739,10 @@ void LLMultiSlider::draw() { gl_rect_2d(mDragStartThumbRect, mThumbCenterColor.get() % opacity, FALSE); } + else if (hoverSldrIt != mThumbRects.end()) + { + gl_rect_2d(hoverSldrIt->second, mThumbCenterSelectedColor.get(), TRUE); + } } else { @@ -729,20 +761,35 @@ void LLMultiSlider::draw() } // draw the highlight - if (hasFocus() && !mCurSlider.empty()) + if (hasFocus()) { - if (mThumbImagep) + if (!mCurSlider.empty()) { - mThumbImagep->drawBorder(mThumbRects[mCurSlider], mThumbHighlightColor, gFocusMgr.getFocusFlashWidth()); - } - else - { - 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()); + } } } + if (!mHoverSlider.empty()) + { + if (mThumbImagep) + { + mThumbImagep->drawBorder(mThumbRects[mHoverSlider], mThumbHighlightColor, gFocusMgr.getFocusFlashWidth()); + } + else + { + thumb_imagep->drawBorder(mThumbRects[mHoverSlider], gFocusMgr.getFocusColor(), gFocusMgr.getFocusFlashWidth()); + } + } // draw the thumbs curSldrIt = mThumbRects.end(); + hoverSldrIt = mThumbRects.end(); for(mIt = mThumbRects.begin(); mIt != mThumbRects.end(); mIt++) { // choose the color @@ -753,6 +800,12 @@ void LLMultiSlider::draw() curSldrIt = mIt; continue; } + if (mIt->first == mHoverSlider && getEnabled() && gFocusMgr.getMouseCapture() != this) + { + // don't draw now, draw last, after current one + hoverSldrIt = mIt; + continue; + } // the draw command if (mThumbImagep) @@ -776,7 +829,7 @@ void LLMultiSlider::draw() } } - // draw cur slider last + // draw cur and hover slider last if(curSldrIt != mThumbRects.end()) { if (mThumbImagep) @@ -799,6 +852,17 @@ void LLMultiSlider::draw() thumb_imagep->drawSolid(curSldrIt->second, mThumbCenterSelectedColor.get() % opacity); } } + if(hoverSldrIt != mThumbRects.end()) + { + if (mThumbImagep) + { + mThumbImagep->draw(hoverSldrIt->second); + } + else + { + thumb_imagep->drawSolid(hoverSldrIt->second, mThumbCenterSelectedColor.get()); + } + } } LLF32UICtrl::draw(); -- cgit v1.2.3 From b7a1b499fd03bd6bfaef37dbdaa9db734dc293b5 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 1 Feb 2019 15:03:02 +0200 Subject: SL-1531 Hover highlight should be consistent with mouse selection --- indra/llui/llmultislider.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'indra/llui/llmultislider.cpp') diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index b8f0a01b86..fbe0d3f065 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -507,17 +507,14 @@ BOOL LLMultiSlider::handleHover(S32 x, S32 y, MASK mask) { if (getEnabled()) { - if (mHoverSlider.empty() || !getSliderThumbRect(mHoverSlider).pointInRect(x, y)) + mHoverSlider.clear(); + std::map::iterator mIt = mThumbRects.begin(); + for (; mIt != mThumbRects.end(); mIt++) { - mHoverSlider.clear(); - std::map::iterator mIt = mThumbRects.begin(); - for (; mIt != mThumbRects.end(); mIt++) + if (mIt->second.pointInRect(x, y)) { - if (mIt->second.pointInRect(x, y)) - { - mHoverSlider = mIt->first; - break; - } + mHoverSlider = mIt->first; + break; } } } -- cgit v1.2.3 From db2c32285b95d3517ebcd1dbf84faa2872ab6428 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 25 Feb 2020 18:59:43 +0200 Subject: SL-12591 Fixed slider value comparison --- indra/llui/llmultislider.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'indra/llui/llmultislider.cpp') diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index fbe0d3f065..acfe4a0cba 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -149,6 +149,16 @@ LLMultiSlider::~LLMultiSlider() delete mMouseUpSignal; } +F32 LLMultiSlider::getNearestIncrement(F32 value) const +{ + value = llclamp(value, mMinValue, mMaxValue); + + // Round to nearest increment (bias towards rounding down) + value -= mMinValue; + value += mIncrement / 2.0001f; + value -= fmod(value, mIncrement); + return mMinValue + value; +} void LLMultiSlider::setSliderValue(const std::string& name, F32 value, BOOL from_event) { @@ -157,13 +167,7 @@ void LLMultiSlider::setSliderValue(const std::string& name, F32 value, BOOL from return; } - value = llclamp( value, mMinValue, mMaxValue ); - - // Round to nearest increment (bias towards rounding down) - value -= mMinValue; - value += mIncrement/2.0001f; - value -= fmod(value, mIncrement); - F32 newValue = mMinValue + value; + F32 newValue = getNearestIncrement(value); // now, make sure no overlap // if we want that -- cgit v1.2.3