summaryrefslogtreecommitdiff
path: root/FL/Fl_Slider.H
diff options
context:
space:
mode:
Diffstat (limited to 'FL/Fl_Slider.H')
-rw-r--r--FL/Fl_Slider.H65
1 files changed, 63 insertions, 2 deletions
diff --git a/FL/Fl_Slider.H b/FL/Fl_Slider.H
index d1ced6731..8a70e4e85 100644
--- a/FL/Fl_Slider.H
+++ b/FL/Fl_Slider.H
@@ -24,7 +24,8 @@
#include "Fl_Valuator.H"
#endif
-// values for type(), lowest bit indicate horizontal:
+#include <FL/Fl_Rect.H>
+
#define FL_VERT_SLIDER 0
#define FL_HOR_SLIDER 1
#define FL_VERT_FILL_SLIDER 2
@@ -58,10 +59,39 @@
*/
class FL_EXPORT Fl_Slider : public Fl_Valuator {
+public:
+
+ /// Bitset for tick mark positions for Fl_Nice_Slider.
+ /// \see Fl_Slider::ticks(), Fl_Slider::ticks(Tick_Position)
+ typedef enum : uchar {
+ TICKS_NONE = 0x00, ///< draw no ticks
+ TICKS_BELOW = 0x01, ///< draw ticks below a horizontal slider
+ TICKS_ABOVE = 0x02, ///< draw ticks above a horizontal slider
+ TICKS_LEFT = 0x01, ///< draw ticks to the left of a vertical slider
+ TICKS_RIGHT = 0x02 ///< draw ticks to the right of a vertical slider
+ // Later: LABEL : label the first, middle, and last tick with its value
+ // Later: FRACTIONAL : make a half ticks a bit shorter, and quarter ticks even shorter
+ // Later: DECIMAL: make .5 ticks shorter and 0.1 ticks even shorter
+ // Later: POINTY_KNOB : make the slider knob pointy on the side where the ticks are
+ // Later: SMALLE_KNOB : make the slider knob small, so the ticks are better visible
+ } Tick_Position;
+
+ /// Bitset for tick mark positions for Fl_Nice_Slider.
+ /// \see Fl_Slider::ticks(), Fl_Slider::ticks(Tick_Position)
+ typedef enum : uchar {
+ LINEAR_SCALE = 0, ///< Linear scale (default)
+ LOG_SCALE ///< Logarithmic scale
+ } Scale_Type;
+
+private:
+
float slider_size_;
uchar slider_;
+ Scale_Type scale_type_ { LINEAR_SCALE };
+ Tick_Position ticks_ { TICKS_NONE };
+ uchar num_ticks_ { 11 };
void _Fl_Slider();
- void draw_bg(int, int, int, int);
+ void draw_bg(int, int, int, int, int S=16);
protected:
@@ -69,6 +99,9 @@ protected:
void draw(int, int, int, int);
int handle(int, int, int, int, int);
void draw() override;
+ void draw_ticks(const Fl_Rect& r, int S);
+ double value_to_position(double val) const;
+ double position_to_value(double pos) const;
public:
@@ -100,6 +133,34 @@ public:
/** Sets the slider box type. */
void slider(Fl_Boxtype c) {slider_ = (uchar)c;}
+
+ /** Gets the scale type.
+ \return scale type
+ */
+ Scale_Type scale() const { return scale_type_; }
+
+ /** Sets the scale type.
+ \param[in] s scale type
+ */
+ void scale(Scale_Type s) { scale_type_ = s; }
+
+ /** Gets the tick mark position.
+ \return tick mark position bitset
+ */
+ uchar ticks() const { return ticks_; }
+
+ /** Gets the number of tick marks.
+ \return number of tick marks
+ */
+ uchar num_ticks() const { return num_ticks_; }
+
+ /** Sets the tick mark position for Fl_Nice_Slider.
+ FL_TICKS_BELOW and FL_TICKS_ABOVE can be or'd together for horizontal sliders,
+ and FL_TICKS_LEFT and FL_TICKS_RIGHT for vertical sliders.
+ \param[in] t tick mark position bitset
+ \param[in] num_ticks number of tick marks to draw
+ */
+ void ticks(uchar t, uchar num_ticks=11) { ticks_ = (Tick_Position)t; num_ticks_ = num_ticks; }
};
#endif