X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fslider.h;h=4260564a9f9985d80a0a7dc9171ae506beda6eaa;hb=5f73de83d46138faa2b4c1b0a725d0a705988388;hp=a95a6a57665fd905577d3e76f54afa76ef5313f1;hpb=a380303d852a3ad3f9b73ccbfbec4cf7f118123e;p=libs%2Fgltk.git diff --git a/source/slider.h b/source/slider.h index a95a6a5..4260564 100644 --- a/source/slider.h +++ b/source/slider.h @@ -9,8 +9,8 @@ namespace GLtk { /** Sliders are used to adjust numeric values visually. This class provides the -common interface for sliders - see classes HSlider and VSlider for concrete -variations. +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 Slider: public Widget { @@ -21,33 +21,70 @@ 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(); + 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: - void click(int); - void start_drag(int); - void drag(int); - void end_drag(); + 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 VSlider: public Slider +{ +public: + VSlider(): Slider(VERTICAL) { } + + virtual const char *get_class() const { return "vslider"; } +}; + +class HSlider: public Slider +{ +public: + HSlider(): Slider(HORIZONTAL) { } + + virtual const char *get_class() const { return "hslider"; } }; } // namespace GLtk