00001
00032 #ifndef LL_LLSLIDER_H
00033 #define LL_LLSLIDER_H
00034
00035 #include "lluictrl.h"
00036 #include "v4color.h"
00037
00038 class LLImageGL;
00039
00040 class LLSlider : public LLUICtrl
00041 {
00042 public:
00043 LLSlider(
00044 const LLString& name,
00045 const LLRect& rect,
00046 void (*on_commit_callback)(LLUICtrl* ctrl, void* userdata),
00047 void* callback_userdata,
00048 F32 initial_value,
00049 F32 min_value,
00050 F32 max_value,
00051 F32 increment,
00052 BOOL volume,
00053 const LLString& control_name = LLString::null );
00054
00055 virtual LLXMLNodePtr getXML(bool save_children = true) const;
00056 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFactory *factory);
00057
00058 void setValue( F32 value, BOOL from_event = FALSE );
00059 F32 getValueF32() const { return mValue; }
00060
00061 virtual void setValue(const LLSD& value ) { setValue((F32)value.asReal(), TRUE); }
00062 virtual LLSD getValue() const { return LLSD(getValueF32()); }
00063
00064 virtual void setMinValue(LLSD min_value) { setMinValue((F32)min_value.asReal()); }
00065 virtual void setMaxValue(LLSD max_value) { setMaxValue((F32)max_value.asReal()); }
00066
00067 F32 getInitialValue() const { return mInitialValue; }
00068 F32 getMinValue() const { return mMinValue; }
00069 F32 getMaxValue() const { return mMaxValue; }
00070 F32 getIncrement() const { return mIncrement; }
00071 void setMinValue(F32 min_value) {mMinValue = min_value; updateThumbRect(); }
00072 void setMaxValue(F32 max_value) {mMaxValue = max_value; updateThumbRect(); }
00073 void setIncrement(F32 increment) {mIncrement = increment;}
00074 void setMouseDownCallback( void (*cb)(LLUICtrl* ctrl, void* userdata) ) { mMouseDownCallback = cb; }
00075 void setMouseUpCallback( void (*cb)(LLUICtrl* ctrl, void* userdata) ) { mMouseUpCallback = cb; }
00076
00077 virtual BOOL handleHover(S32 x, S32 y, MASK mask);
00078 virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
00079 virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
00080 virtual BOOL handleKeyHere(KEY key, MASK mask);
00081 virtual void draw();
00082
00083 private:
00084 void setValueAndCommit(F32 value);
00085 void updateThumbRect();
00086
00087 F32 mValue;
00088 F32 mInitialValue;
00089 F32 mMinValue;
00090 F32 mMaxValue;
00091 F32 mIncrement;
00092
00093 BOOL mVolumeSlider;
00094 S32 mMouseOffset;
00095 LLRect mDragStartThumbRect;
00096
00097 LLUIImage* mThumbImage;
00098 LLUIImage* mTrackImage;
00099 LLUIImage* mTrackHighlightImage;
00100
00101 LLRect mThumbRect;
00102 LLColor4 mTrackColor;
00103 LLColor4 mThumbOutlineColor;
00104 LLColor4 mThumbCenterColor;
00105
00106 void (*mMouseDownCallback)(LLUICtrl* ctrl, void* userdata);
00107 void (*mMouseUpCallback)(LLUICtrl* ctrl, void* userdata);
00108 };
00109
00110 #endif // LL_LLSLIDER_H