The ZX Ecosystem v5.1.0;_GUI_v3.1.0
Loading...
Searching...
No Matches
ZXWidgetSlide.h
Go to the documentation of this file.
1
2/* **************************************************************************/
19#ifndef ZXWIDGET_SLIDE
20#define ZXWIDGET_SLIDE
21
23
24
25namespace zxeco
26{
27
28namespace gui
29{
30
31/*****************************************************************************
32*
33* Class: SlideWidget
34*
35*******************************************************************************/
36
39{
40 public:
41
42 static const CharDist kThickness;
44
45 static CharDist kLength(bool witharrows) noexcept
47 { return(static_cast<CharDist>(1 + (witharrows ? 2 : 0))); }
48
49 /* --- Methods for dealing with pairs of slides (horizontal/vertical) --- */
53 bool & vert, bool & horiz,
54 const CharArea & area,
55 bool & changed,
56 SlideWidget * phorscr = nullptr,
57 SlideWidget * pverscr = nullptr,
58 bool scrollfromcontent = true);
60
75 static void calcScrollBoundsForArea(const CharArea & content,
76 const CharArea & nudearea,
77 size_t & vertbound, size_t & horizbound,
78 SlideWidget * phorizscroll = nullptr,
79 SlideWidget * pvertscroll = nullptr);
81
87 static bool updateScrollsForAreaSilently(const CharArea & content,
88 const CharArea & area,
89 SlideWidget & horizscroll,
90 SlideWidget & vertscroll);
92
98 /* --------------------- General class methods -------------------------- */
101 static int calcMaxBoundScroll(size_t needed,
102 CharDist availleninnude) noexcept
104
107 { return(needed >= availleninnude ?
108 static_cast<int>(needed - availleninnude) : 0); }
109
113 /* --------------------- Constructors -------------------------- */
116 SlideWidget(ID id, const std::string & name,
117 char orientation, bool witharrows, CharDist maxlen,
118 const std::string & valformat, char kindofvalue,
119 double minval, double maxval, double incval,
120 const std::string & tooltiptext = "",
121 HorAlign hal = HorAlign::LEFT,
122 VertAlign val = VertAlign::TOP);
124
141 /* --------------------- General methods -------------------------- */
144 double value(void) const;
146
147 void setValue(double value);
149
152 double minBound(void) const noexcept;
154
155 double maxBound(void) const noexcept;
157
158 void bounds(double & minval, double & maxval) const noexcept;
160
161 bool changeBounds(double minval, double maxval, bool noredraw = false);
163
170 const char * className(void) const noexcept { return("SlideWidget"); }
171
175 private:
176
177 enum ChildName {
178 FIRST_ARROW = 0,
179 SECOND_ARROW,
180 NUDE_SLIDE,
181 VALUE_LABEL,
182 NUMCHILDREN
183 };
184
185 static const uint8_t kUDGs[4*8];
186 static const ID kIDSubs[NUMCHILDREN];
187
188
189 const bool witharrows_;
190 const CharDist maxlen_;
191 double incval_;
192 const std::string valformat_;
193 const char kindofvalue_;
194 CharDist maxlenval_;
195 Widget * firstarrow_;
196 Widget * secondarrow_;
197 Widget * nudeslide_;
198 Widget * valwidget_;
199 double oldval_;
200
201 CharDist valueLengthAsString(double v) const;
202 std::string valueAsString(void) const;
203 void drawRaw(void);
204 int processEvent(const EventData & evdata, Widget * who) override;
205};
206
207
208
209} // end namespace gui
210} // end namespace zxeco
211
212#endif
213 // ZXWidgetSlide
215
216
217
HorAlign
Horizontal alignment of widgets within the areas of their containers.
VertAlign
Vertical alignment of widgets within the areas of their containers.
A container of other widgets.
int ID
A numeric ID associated to the widget.
Definition: ZXWidgetsBase.h:67
static void calcScrollBoundsForArea(const CharArea &content, const CharArea &nudearea, size_t &vertbound, size_t &horizbound, SlideWidget *phorizscroll=nullptr, SlideWidget *pvertscroll=nullptr)
Calc. bounds to set in the scrolls after calcScrollVisibilityForArea().
static CharDist kLength(bool witharrows) noexcept
< Length in chars of the slide (not considering the numeric value if any)
Definition: ZXWidgetSlide.h:45
void setValue(double value)
Change the current numerical value represented by the slide.
const char * className(void) const noexcept
Return the current numerical value represented by the slide.
double minBound(void) const noexcept
Return the minimum bound of the widget.
SlideWidget(ID id, const std::string &name, char orientation, bool witharrows, CharDist maxlen, const std::string &valformat, char kindofvalue, double minval, double maxval, double incval, const std::string &tooltiptext="", HorAlign hal=HorAlign::LEFT, VertAlign val=VertAlign::TOP)
Constructor. The initial numerical value will be minval.
double value(void) const
Return the current numerical value represented by the slide.
static CharArea calcScrollVisibilityForArea(const CharArea &content, bool &vert, bool &horiz, const CharArea &area, bool &changed, SlideWidget *phorscr=nullptr, SlideWidget *pverscr=nullptr, bool scrollfromcontent=true)
Check whether sliders (scrolls) are visib. to display CONTENT into AREA.
static bool updateScrollsForAreaSilently(const CharArea &content, const CharArea &area, SlideWidget &horizscroll, SlideWidget &vertscroll)
Update visibility + bounds of scrolls and return TRUE if visib. changed.
double maxBound(void) const noexcept
Return the maximum bound of the widget.
static int calcMaxBoundScroll(size_t needed, CharDist availleninnude) noexcept
< Calculate the maximum value for a slide used as a scroll bar.
void bounds(double &minval, double &maxval) const noexcept
Fill MINVAL and MAXVAL with the current value bounds of the widget.
bool changeBounds(double minval, double maxval, bool noredraw=false)
Set new value bounds for the widget, redrawing only if they change.
static const CharDist kThickness
Thickness in chars of the nude slide (only considering the sliding bar)
Definition: ZXWidgetSlide.h:42
A slide, either horizontal or vertical, e.g., to serve as scroll bar.
Definition: ZXWidgetSlide.h:39
uint16_t CharDist
A distance meadured in screen chars.
Definition: ZXGraphics.h:97
The main namespace of the library, that spans across all the zx modules.
Definition: ZXChars.h:31