summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llmultislider.cpp48
-rw-r--r--indra/llui/llmultislider.h32
-rw-r--r--indra/llui/llmultisliderctrl.cpp4
-rw-r--r--indra/llui/llmultisliderctrl.h2
4 files changed, 72 insertions, 14 deletions
diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp
index 1891bca36c..aea7c5f87c 100644
--- a/indra/llui/llmultislider.cpp
+++ b/indra/llui/llmultislider.cpp
@@ -50,6 +50,12 @@ const F32 FLOAT_THRESHOLD = 0.00001f;
S32 LLMultiSlider::mNameCounter = 0;
+LLMultiSlider::SliderParams::SliderParams()
+: name("name"),
+ value("value", 0.f)
+{
+}
+
LLMultiSlider::Params::Params()
: max_sliders("max_sliders", 1),
allow_overlap("allow_overlap", false),
@@ -63,7 +69,8 @@ LLMultiSlider::Params::Params()
triangle_color("triangle_color"),
mouse_down_callback("mouse_down_callback"),
mouse_up_callback("mouse_up_callback"),
- thumb_width("thumb_width")
+ thumb_width("thumb_width"),
+ sliders("slider")
{
name = "multi_slider_bar";
mouse_opaque(true);
@@ -99,6 +106,20 @@ LLMultiSlider::LLMultiSlider(const LLMultiSlider::Params& p)
{
setMouseUpCallback(initCommitCallback(p.mouse_up_callback));
}
+
+ for (LLInitParam::ParamIterator<SliderParams>::const_iterator it = p.sliders().begin();
+ it != p.sliders().end();
+ ++it)
+ {
+ if (it->name.isProvided())
+ {
+ addSlider(it->value, it->name);
+ }
+ else
+ {
+ addSlider(it->value);
+ }
+ }
}
LLMultiSlider::~LLMultiSlider()
@@ -230,6 +251,30 @@ const std::string& LLMultiSlider::addSlider(F32 val)
return mCurSlider;
}
+void LLMultiSlider::addSlider(F32 val, const std::string& name)
+{
+ F32 initVal = val;
+
+ if(mValue.size() >= mMaxNumSliders) {
+ return;
+ }
+
+ bool foundOne = findUnusedValue(initVal);
+ if(!foundOne) {
+ return;
+ }
+
+ // add a new thumb rect
+ mThumbRects[name] = LLRect( 0, getRect().getHeight(), mThumbWidth, 0 );
+
+ // add the value and set the current slider to this one
+ mValue.insert(name, initVal);
+ mCurSlider = name;
+
+ // move the slider
+ setSliderValue(mCurSlider, initVal, TRUE);
+}
+
bool LLMultiSlider::findUnusedValue(F32& initVal)
{
bool firstTry = true;
@@ -572,7 +617,6 @@ void LLMultiSlider::draw()
LLF32UICtrl::draw();
}
-
boost::signals2::connection LLMultiSlider::setMouseDownCallback( const commit_signal_t::slot_type& cb )
{
if (!mMouseDownSignal) mMouseDownSignal = new commit_signal_t();
diff --git a/indra/llui/llmultislider.h b/indra/llui/llmultislider.h
index f8e43a0470..88576da85b 100644
--- a/indra/llui/llmultislider.h
+++ b/indra/llui/llmultislider.h
@@ -41,6 +41,13 @@ class LLUICtrlFactory;
class LLMultiSlider : public LLF32UICtrl
{
public:
+ struct SliderParams : public LLInitParam::Block<SliderParams>
+ {
+ Optional<std::string> name;
+ Mandatory<F32> value;
+ SliderParams();
+ };
+
struct Params : public LLInitParam::Block<Params, LLF32UICtrl::Params>
{
Optional<S32> max_sliders;
@@ -60,6 +67,7 @@ public:
mouse_up_callback;
Optional<S32> thumb_width;
+ Multiple<SliderParams> sliders;
Params();
};
@@ -68,13 +76,13 @@ protected:
friend class LLUICtrlFactory;
public:
virtual ~LLMultiSlider();
- void setSliderValue(const std::string& name, F32 value, BOOL from_event = FALSE);
- F32 getSliderValue(const std::string& name) const;
+ void setSliderValue(const std::string& name, F32 value, BOOL from_event = FALSE);
+ F32 getSliderValue(const std::string& name) const;
- const std::string& getCurSlider() const { return mCurSlider; }
- F32 getCurSliderValue() const { return getSliderValue(mCurSlider); }
- void setCurSlider(const std::string& name);
- void setCurSliderValue(F32 val, BOOL from_event = false) { setSliderValue(mCurSlider, val, from_event); }
+ const std::string& getCurSlider() const { return mCurSlider; }
+ F32 getCurSliderValue() const { return getSliderValue(mCurSlider); }
+ void setCurSlider(const std::string& name);
+ void setCurSliderValue(F32 val, BOOL from_event = false) { setSliderValue(mCurSlider, val, from_event); }
/*virtual*/ void setValue(const LLSD& value);
/*virtual*/ LLSD getValue() const { return mValue; }
@@ -82,12 +90,13 @@ public:
boost::signals2::connection setMouseDownCallback( const commit_signal_t::slot_type& cb );
boost::signals2::connection setMouseUpCallback( const commit_signal_t::slot_type& cb );
- bool findUnusedValue(F32& initVal);
+ bool findUnusedValue(F32& initVal);
const std::string& addSlider();
const std::string& addSlider(F32 val);
- void deleteSlider(const std::string& name);
- void deleteCurSlider() { deleteSlider(mCurSlider); }
- void clear();
+ void addSlider(F32 val, const std::string& name);
+ void deleteSlider(const std::string& name);
+ void deleteCurSlider() { deleteSlider(mCurSlider); }
+ void clear();
/*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
/*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
@@ -109,7 +118,8 @@ protected:
LLRect mDragStartThumbRect;
S32 mThumbWidth;
- std::map<std::string, LLRect> mThumbRects;
+ std::map<std::string, LLRect>
+ mThumbRects;
LLUIColor mTrackColor;
LLUIColor mThumbOutlineColor;
LLUIColor mThumbCenterColor;
diff --git a/indra/llui/llmultisliderctrl.cpp b/indra/llui/llmultisliderctrl.cpp
index 87938c19d4..2e7bf4b74d 100644
--- a/indra/llui/llmultisliderctrl.cpp
+++ b/indra/llui/llmultisliderctrl.cpp
@@ -65,7 +65,8 @@ LLMultiSliderCtrl::Params::Params()
text_color("text_color"),
text_disabled_color("text_disabled_color"),
mouse_down_callback("mouse_down_callback"),
- mouse_up_callback("mouse_up_callback")
+ mouse_up_callback("mouse_up_callback"),
+ sliders("slider")
{
mouse_opaque = true;
}
@@ -161,6 +162,7 @@ LLMultiSliderCtrl::LLMultiSliderCtrl(const LLMultiSliderCtrl::Params& p)
S32 slider_left = label_width ? label_width + multi_sliderctrl_spacing : 0;
LLRect slider_rect( slider_left, top, slider_right, bottom );
LLMultiSlider::Params params;
+ params.sliders = p.sliders;
params.rect(slider_rect);
params.commit_callback.function( LLMultiSliderCtrl::onSliderCommit );
params.mouse_down_callback( p.mouse_down_callback );
diff --git a/indra/llui/llmultisliderctrl.h b/indra/llui/llmultisliderctrl.h
index 16d07541f2..e8366d09c2 100644
--- a/indra/llui/llmultisliderctrl.h
+++ b/indra/llui/llmultisliderctrl.h
@@ -69,6 +69,8 @@ public:
Optional<CommitCallbackParam> mouse_down_callback,
mouse_up_callback;
+ Multiple<LLMultiSlider::SliderParams> sliders;
+
Params();
};