]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/slider.h
Simplify constructors with C++11
[libs/gltk.git] / source / slider.h
index c4326e3eac0edf5571ac29b96ee82adb3ba63abc..70c5fc59b2882d948f7ceb543465bde4127e0895 100644 (file)
@@ -1,14 +1,8 @@
-/* $Id$
-
-This file is part of libmspgltk
-Copyright © 2007  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #ifndef MSP_GLTK_SLIDER_H_
 #define MSP_GLTK_SLIDER_H_
 
 #include <sigc++/sigc++.h>
+#include "mspgltk_api.h"
 #include "widget.h"
 
 namespace Msp {
@@ -16,43 +10,83 @@ 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
+class MSPGLTK_API Slider: public Widget
 {
 public:
-       class Loader: public Widget::Loader
+       class MSPGLTK_API Loader: public DataFile::DerivedObjectLoader<Slider, Widget::Loader>
        {
        public:
                Loader(Slider &);
-               Slider &get_object() const;
        };
 
 protected:
-       double min, max;
-       double value;
-       double step;
-
-       bool dragging;
-       double drag_start_pos;
-       double drag_start_value;
-       unsigned drag_area_size;
+       enum Direction
+       {
+               HORIZONTAL,
+               VERTICAL
+       };
 
 public:
        sigc::signal<void, double> signal_value_changed;
 
 protected:
-       Slider();
+       Direction dir;
+       double min = 0.0;
+       double max = 1.0;
+       double value = 0.0;
+       double step = 0.1;
+       double page_size = 0.25;
+
+       bool dragging = false;
+       double drag_start_pos = 0.0;
+       double drag_start_value = 0.0;
+       unsigned drag_area_size = 0;
+       unsigned drag_area_offset = 0;
+       unsigned slider_min_size = 1;
+       unsigned slider_size = 1;
+       unsigned total_margin = 0;
+
+       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 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 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) { }
+
+       virtual const char *get_class() const { return "hslider"; }
 };
 
 } // namespace GLtk