X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fslider.h;h=7b878d21fb2f1f6a32be486d4154c05e273c65ed;hb=56c41b294aa47a38ac3e1be70d4868f260cb4274;hp=d4ae46b632040fe9b6fb8dd8c90a21a7a5125af8;hpb=c062ca892fc6e10f74a76991b5d4b4349c046b5f;p=libs%2Fgltk.git diff --git a/source/slider.h b/source/slider.h index d4ae46b..7b878d2 100644 --- a/source/slider.h +++ b/source/slider.h @@ -2,26 +2,90 @@ #define MSP_GLTK_SLIDER_H_ #include +#include "mspgltk_api.h" #include "widget.h" namespace Msp { namespace GLtk { -class Slider: public Widget +/** +Sliders are used to adjust numeric values visually. This class provides the +common interface and logic for sliders but can't be instantiated. Use HSlider +or VSlider depending on which direction you want the slider to be in. +*/ +class MSPGLTK_API Slider: public Widget { +public: + class MSPGLTK_API Loader: public DataFile::DerivedObjectLoader + { + public: + Loader(Slider &); + }; + +protected: + enum Direction + { + HORIZONTAL, + VERTICAL + }; + public: sigc::signal signal_value_changed; +protected: + Direction dir; + double min, max; + double value; + double step; + double page_size; + + bool dragging; + double drag_start_pos; + double drag_start_value; + unsigned drag_area_size; + unsigned drag_area_offset; + unsigned slider_min_size; + unsigned slider_size; + unsigned total_margin; + + Slider(Direction); + +public: void set_value(double); void set_range(double, double); void set_step(double); + void set_page_size(double); double get_value() const { return value; } + protected: - double min, max; - double value; - double step; + virtual void autosize_special(const Part &, Geometry &) const; + virtual void rebuild_special(const Part &); + +public: + virtual void button_press(int, int, unsigned); + virtual void button_release(int, int, unsigned); + virtual void pointer_motion(int, int); + +protected: + virtual void on_size_change(); + virtual void on_style_change(); +}; + + +class MSPGLTK_API VSlider: public Slider +{ +public: + VSlider(): Slider(VERTICAL) { } + + virtual const char *get_class() const { return "vslider"; } +}; + +class MSPGLTK_API HSlider: public Slider +{ +public: + HSlider(): Slider(HORIZONTAL) { } - Slider(const Resources &); + virtual const char *get_class() const { return "hslider"; } }; } // namespace GLtk