lecui 1.0.0-alpha.20
lecui C++ user interface library
Classes | Public Member Functions | Static Public Member Functions | List of all members
liblec::lecui::widgets::slider Class Reference

Slider widget. To instantiate and add to a container use the add static method. More...

#include <slider.h>

Inheritance diagram for liblec::lecui::widgets::slider:
liblec::lecui::widgets::widget

Classes

struct  slider_events
 Events specific to this widget. More...
 
struct  slider_range
 Slider range. More...
 

Public Member Functions

 slider ()
 Constructor.
 
slider_eventsevents ()
 Get or set slider events. More...
 
bool operator== (const slider &param)
 Check whether widget specs are equal. Only those properties that require the widget resources to be re-created are considered. More...
 
bool operator!= (const slider &param)
 Check whether widget specs are NOT equal. Only those properties that require the widget resources to be re-created are considered. More...
 
std::string & text () override
 Get or set the widget text. More...
 
slidertext (const std::string &text)
 Set the widget's text. More...
 
std::string & tooltip () override
 Get or set the widget's tooltip text. More...
 
slidertooltip (const std::string &tooltip)
 Set the tooltip text. More...
 
lecui::rectrect () override
 Get or set the position and dimensions of the widget. More...
 
sliderrect (const lecui::rect &rect)
 Set the position and dimensions of the widget. More...
 
resize_paramson_resize () override
 Get or set the behaviour of the widget when its container is resized. More...
 
slideron_resize (const resize_params &on_resize)
 Set the behaviour of the widget when its container is resized. More...
 
cursor_typecursor () override
 Get or set the mouse cursor to use then over the widget. More...
 
slidercursor (const cursor_type cursor)
 Set the mouse cursor to use when over the widget. More...
 
std::string & font () override
 Get or set the default widget font, e.g. "Georgia". More...
 
sliderfont (const std::string &font)
 Set the default widget font. More...
 
float & font_size () override
 Get or set the default widget font size in points, e.g. 9.0f. More...
 
sliderfont_size (const float &font_size)
 Set the widget's font size. More...
 
colorcolor_text () override
 Get or set the color of the widget's text. More...
 
slidercolor_text (const color &color_text)
 Set the color of the widget's text. More...
 
colorcolor_fill () override
 Get or set the fill color of the widget. More...
 
slidercolor_fill (const color &color_fill)
 Set the fill color of the widget. More...
 
colorcolor_hot () override
 Get or set the widget's color when the mouse is hovered over it. More...
 
slidercolor_hot (const color &color_hot)
 Set the widget's color when the mouse is hovered over it. More...
 
colorcolor_selected () override
 Get or set the widget's color when selected. More...
 
slidercolor_selected (const color &color_selected)
 Set the widget's color when selected. More...
 
colorcolor_disabled () override
 Get or set the widget's color when it is disabled. More...
 
slidercolor_disabled (const color &color_disabled)
 Set the widget's color when it is disabled. More...
 
float & border ()
 Get or set the thickness of the border. More...
 
sliderborder (const float &border)
 Set the thickness of the border. More...
 
colorcolor_border ()
 Get or set the color of the border. More...
 
slidercolor_border (const color &color_border)
 Set the color of the border. More...
 
colorcolor_knob ()
 Get or set the color of the knob. More...
 
slidercolor_knob (const color &color_knob)
 Set the color of the knob. More...
 
colorcolor_knob_hot ()
 Get or set the color of the knob when the mouse is over the slider. More...
 
slidercolor_knob_hot (const color &color_knob_hot)
 Set the color of the knob when the mouse is over the slider. More...
 
colorcolor_knob_border ()
 Get or set the color of the knob's border. More...
 
slidercolor_knob_border (const color &color_knob_border)
 Set the color of the knob's border. More...
 
colorcolor_tick ()
 Get or set the color of the slider ticks. More...
 
slidercolor_tick (const color &color_tick)
 Set the color of the slider ticks. More...
 
bool & snap_to_ticks ()
 Get or set the property for whether to snap slider movements to the ticks. More...
 
slidersnap_to_ticks (const bool &snap_to_ticks)
 Set the property for whether to snap slider movements to the ticks. More...
 
bool & show_tick_marks ()
 Get or set the property for whether to show ticks marks on the slider. More...
 
slidershow_tick_marks (const bool &show_tick_marks)
 Set the property for whether to show ticks marks on the slider. More...
 
bool & show_tick_labels ()
 Get or set the property for whether to show tick labels on the slider. More...
 
slidershow_tick_labels (const bool &show_tick_labels)
 Set the property for whether to show tick labels on the slider. More...
 
slider_rangerange ()
 Get or set the slider's range. More...
 
sliderrange (const slider_range &range)
 Set the slider's range. More...
 
float & knob_radius ()
 Get or set the radius of the knob. More...
 
sliderknob_radius (const float &knob_radius)
 Set the radius of the knob. More...
 
float & slide_thickness ()
 Get or set the thickness of the slide. More...
 
sliderslide_thickness (const float &slide_thickness)
 Set the thickness of the slide. More...
 
float & major_tick_unit ()
 Get or set the unit intervals for placing major ticks. More...
 
slidermajor_tick_unit (const float &major_tick_unit)
 Set the unit intervals for placing major ticks, e.g. 25.f. More...
 
long & minor_tick_count ()
 Get or set the number of minor ticks to place between successive major ticks. More...
 
sliderminor_tick_count (const long &minor_tick_count)
 Set the number of minor ticks to place between successive major ticks, e.g. 4. More...
 
float & value ()
 Get or set the position of the knob along the slide. More...
 
slidervalue (const float &value)
 Set the position of the knob along the slide, e.g. 63.5f. More...
 
- Public Member Functions inherited from liblec::lecui::widgets::widget
 widget ()
 Widget constructor.
 
virtual ~widget ()
 Widget descructor.
 
bool operator== (const widget &param)
 Check whether widget's basic specifications are equal. Only those properties that require the widget's basic resources to be re-created are considered. More...
 
bool operator!= (const widget &param)
 Check whether widget's basic specifications are NOT equal. Only those properties that require the widget's basic resources to be re-created are considered. More...
 
virtual std::string & text ()=0
 Get or set the widget text. More...
 
virtual std::string & tooltip ()=0
 Get or set the widget's tooltip text. More...
 
virtual lecui::rectrect ()=0
 Get or set the position and dimensions of the widget. More...
 
virtual resize_paramson_resize ()=0
 Get or set the behaviour of the widget when its container is resized. More...
 
virtual cursor_typecursor ()=0
 Get or set the mouse cursor to use then over the widget. More...
 
virtual std::string & font ()=0
 Get or set the default widget font, e.g. "Georgia". More...
 
virtual float & font_size ()=0
 Get or set the default widget font size in points, e.g. 9.0f. More...
 
virtual colorcolor_text ()=0
 Get or set the color of the widget's text. More...
 
virtual colorcolor_fill ()=0
 Get or set the fill color of the widget. More...
 
virtual colorcolor_hot ()=0
 Get or set the widget's color when the mouse is hovered over it. More...
 
virtual colorcolor_selected ()=0
 Get or set the widget's color when selected. More...
 
virtual colorcolor_disabled ()=0
 Get or set the widget's color when it's disabled. More...
 
basic_eventsevents ()
 Widget events. More...
 
const std::string & alias ()
 The widget's alias, either user defined or automatically generated by the library. More...
 

Static Public Member Functions

static slideradd (containers::page &page, const std::string &alias=std::string())
 Add a slider to a container. More...
 
static sliderget (form &fm, const std::string &path)
 Get the specifications of a slider. More...
 

Additional Inherited Members

- Public Types inherited from liblec::lecui::widgets::widget
enum class  cursor_type { arrow , hand , caret }
 Mouse cursor type. More...
 
- Protected Attributes inherited from liblec::lecui::widgets::widget
std::string _text
 The widget's text.
 
std::string _tooltip
 The widget's tooltip text.
 
lecui::rect _rect
 The widget's rectangle.
 
resize_params _on_resize = { 0.f, 0.f, 0.f, 0.f }
 The widget's behaviour when container is resized.
 
cursor_type _cursor = cursor_type::arrow
 The widget's cursor.
 
std::string _font = "Segoe UI"
 The widget's font.
 
float _font_size = 9.f
 The widget's font size.
 
color _color_text = { 0, 0, 0, 255 }
 The color of the widget's text.
 
color _color_fill = { 0, 120, 170, 255 }
 The fill color of the widget.
 
color _color_hot = { 0, 120, 170, 255 }
 The color to indicate when the mouse hovers over the widget.
 
color _color_selected = { 0, 120, 170, 30 }
 The color to indicate when the widget is selected.
 
color _color_disabled = { 180, 180, 180, 255 }
 The color to indicate when the widget is disabled.
 

Detailed Description

Slider widget. To instantiate and add to a container use the add static method.

The slider's orientation is computed automatically based on the its size. If the width is greater than the height it's oriented horizontally, else vertically. With the defaults, the recommended minimum height for horizontal orientation is 35px and the recommended minimum with for vertical orientation is 40px.

Member Function Documentation

◆ add()

static slider & liblec::lecui::widgets::slider::add ( containers::page page,
const std::string &  alias = std::string() 
)
static

Add a slider to a container.

Parameters
pageThe container to place the widget in.
aliasThe in-page unique alias, e.g. "volume".
Returns
A reference to the widget specifications.

If an empty alias is given an internally generated random alias will be assigned.

◆ border() [1/2]

float & liblec::lecui::widgets::slider::border ( )

Get or set the thickness of the border.

Returns
A reference to the border thickness, in pixels.

◆ border() [2/2]

slider & liblec::lecui::widgets::slider::border ( const float &  border)

Set the thickness of the border.

Parameters
borderThe border thickness, in pixels.
Returns
A reference to the modified object.

◆ color_border() [1/2]

color & liblec::lecui::widgets::slider::color_border ( )

Get or set the color of the border.

Returns
A reference to the border color, as defined in color.

◆ color_border() [2/2]

slider & liblec::lecui::widgets::slider::color_border ( const color color_border)

Set the color of the border.

Parameters
color_borderThe border color, as defined in color.
Returns
A reference to the modified object.

◆ color_disabled() [1/2]

color & liblec::lecui::widgets::slider::color_disabled ( )
overridevirtual

Get or set the widget's color when it is disabled.

Returns
a reference to the property.

Implements liblec::lecui::widgets::widget.

◆ color_disabled() [2/2]

slider & liblec::lecui::widgets::slider::color_disabled ( const color color_disabled)

Set the widget's color when it is disabled.

Parameters
color_disabledThe color of the widget when it is disabled, as defined in color.
Returns
A reference to the modified object.

◆ color_fill() [1/2]

color & liblec::lecui::widgets::slider::color_fill ( )
overridevirtual

Get or set the fill color of the widget.

Returns
A reference to the widget's fill color.

Implements liblec::lecui::widgets::widget.

◆ color_fill() [2/2]

slider & liblec::lecui::widgets::slider::color_fill ( const color color_fill)

Set the fill color of the widget.

Parameters
color_fillThe fill color.
Returns
A reference to the modified object.

◆ color_hot() [1/2]

color & liblec::lecui::widgets::slider::color_hot ( )
overridevirtual

Get or set the widget's color when the mouse is hovered over it.

Returns
A reference to the widget's hover color.

Implements liblec::lecui::widgets::widget.

◆ color_hot() [2/2]

slider & liblec::lecui::widgets::slider::color_hot ( const color color_hot)

Set the widget's color when the mouse is hovered over it.

Parameters
color_hotThe color.
Returns
A reference to the modified object.

◆ color_knob() [1/2]

color & liblec::lecui::widgets::slider::color_knob ( )

Get or set the color of the knob.

Returns
A reference to the color.

◆ color_knob() [2/2]

slider & liblec::lecui::widgets::slider::color_knob ( const color color_knob)

Set the color of the knob.

Parameters
color_knobThe color.
Returns
A reference to the modified object.

◆ color_knob_border() [1/2]

color & liblec::lecui::widgets::slider::color_knob_border ( )

Get or set the color of the knob's border.

Returns
A reference to the color.

◆ color_knob_border() [2/2]

slider & liblec::lecui::widgets::slider::color_knob_border ( const color color_knob_border)

Set the color of the knob's border.

Parameters
color_knob_borderThe color.
Returns
A reference to the modified object.

◆ color_knob_hot() [1/2]

color & liblec::lecui::widgets::slider::color_knob_hot ( )

Get or set the color of the knob when the mouse is over the slider.

Returns
A reference to the color.

◆ color_knob_hot() [2/2]

slider & liblec::lecui::widgets::slider::color_knob_hot ( const color color_knob_hot)

Set the color of the knob when the mouse is over the slider.

Parameters
color_knob_hotThe color.
Returns
A reference to the modified object.

◆ color_selected() [1/2]

color & liblec::lecui::widgets::slider::color_selected ( )
overridevirtual

Get or set the widget's color when selected.

Returns
A reference to the widget's color when selected.

Implements liblec::lecui::widgets::widget.

◆ color_selected() [2/2]

slider & liblec::lecui::widgets::slider::color_selected ( const color color_selected)

Set the widget's color when selected.

Parameters
color_selectedThe widget's color when selected.
Returns
A reference to the modified object.

◆ color_text() [1/2]

color & liblec::lecui::widgets::slider::color_text ( )
overridevirtual

Get or set the color of the widget's text.

Returns
A reference to the widget's text color.

Implements liblec::lecui::widgets::widget.

◆ color_text() [2/2]

slider & liblec::lecui::widgets::slider::color_text ( const color color_text)

Set the color of the widget's text.

Parameters
color_textThe color of the widget's text.
Returns
A reference to the modified object.

◆ color_tick() [1/2]

color & liblec::lecui::widgets::slider::color_tick ( )

Get or set the color of the slider ticks.

Returns
A reference to the color.

◆ color_tick() [2/2]

slider & liblec::lecui::widgets::slider::color_tick ( const color color_tick)

Set the color of the slider ticks.

Parameters
color_tickThe color.
Returns
A reference to the modified object.

◆ cursor() [1/2]

cursor_type & liblec::lecui::widgets::slider::cursor ( )
overridevirtual

Get or set the mouse cursor to use then over the widget.

Returns
A reference to the cursor type as defined in cursor_type.

Implements liblec::lecui::widgets::widget.

◆ cursor() [2/2]

slider & liblec::lecui::widgets::slider::cursor ( const cursor_type  cursor)

Set the mouse cursor to use when over the widget.

Parameters
cursorThe cursor type as defined in cursor_type.
Returns
A reference to the modified object.

◆ events()

slider_events & liblec::lecui::widgets::slider::events ( )
inline

Get or set slider events.

Returns

◆ font() [1/2]

std::string & liblec::lecui::widgets::slider::font ( )
overridevirtual

Get or set the default widget font, e.g. "Georgia".

Returns
A reference to the widget's font name.

Implements liblec::lecui::widgets::widget.

◆ font() [2/2]

slider & liblec::lecui::widgets::slider::font ( const std::string &  font)

Set the default widget font.

Parameters
fontThe font's name, e.g. "Georgia".
Returns
A reference to the modified object.

◆ font_size() [1/2]

float & liblec::lecui::widgets::slider::font_size ( )
overridevirtual

Get or set the default widget font size in points, e.g. 9.0f.

Returns
A reference to the widget's font size.

Implements liblec::lecui::widgets::widget.

◆ font_size() [2/2]

slider & liblec::lecui::widgets::slider::font_size ( const float &  font_size)

Set the widget's font size.

Parameters
font_sizeThe font size in points, e.g. 9.0f.
Returns
A reference to the modified object.

◆ get()

static slider & liblec::lecui::widgets::slider::get ( form fm,
const std::string &  path 
)
static

Get the specifications of a slider.

Parameters
fmA reference to the form.
pathThe full path to the widget, e.g. "sample_page/tools_tab_pane/options_tab/volume".
Returns
A reference to the widget specifications.

Throws on failure. For faster coding and more readable code consider calling this static method through the helper macro provided.

◆ knob_radius() [1/2]

float & liblec::lecui::widgets::slider::knob_radius ( )

Get or set the radius of the knob.

Returns
A reference to the radius, in pixels.

◆ knob_radius() [2/2]

slider & liblec::lecui::widgets::slider::knob_radius ( const float &  knob_radius)

Set the radius of the knob.

Parameters
knob_radiusThe knob's radius, in pixels.
Returns
A reference to the modified object.

◆ major_tick_unit() [1/2]

float & liblec::lecui::widgets::slider::major_tick_unit ( )

Get or set the unit intervals for placing major ticks.

Returns
A reference to the unit interval property.

◆ major_tick_unit() [2/2]

slider & liblec::lecui::widgets::slider::major_tick_unit ( const float &  major_tick_unit)

Set the unit intervals for placing major ticks, e.g. 25.f.

Parameters
major_tick_unitThe unit interval.
Returns
A reference to the modified object.

◆ minor_tick_count() [1/2]

long & liblec::lecui::widgets::slider::minor_tick_count ( )

Get or set the number of minor ticks to place between successive major ticks.

Returns
The number of ticks.

◆ minor_tick_count() [2/2]

slider & liblec::lecui::widgets::slider::minor_tick_count ( const long &  minor_tick_count)

Set the number of minor ticks to place between successive major ticks, e.g. 4.

Parameters
minor_tick_countThe number of ticks.
Returns
A reference to the modified object.

◆ on_resize() [1/2]

resize_params & liblec::lecui::widgets::slider::on_resize ( )
overridevirtual

Get or set the behaviour of the widget when its container is resized.

Returns
A reference to the resize parameters as defined in resize_params.

Implements liblec::lecui::widgets::widget.

◆ on_resize() [2/2]

slider & liblec::lecui::widgets::slider::on_resize ( const resize_params on_resize)

Set the behaviour of the widget when its container is resized.

Parameters
on_resizeThe resize parameters as defined in resize_params.
Returns
A reference to the modified object.

◆ operator!=()

bool liblec::lecui::widgets::slider::operator!= ( const slider param)

Check whether widget specs are NOT equal. Only those properties that require the widget resources to be re-created are considered.

Parameters
paramThe specs to compare to.
Returns
Returns true if the specs are NOT equal, else false.

◆ operator==()

bool liblec::lecui::widgets::slider::operator== ( const slider param)

Check whether widget specs are equal. Only those properties that require the widget resources to be re-created are considered.

Parameters
paramThe specs to compare to.
Returns
Returns true if the specs are equal, else false.

◆ range() [1/2]

slider_range & liblec::lecui::widgets::slider::range ( )

Get or set the slider's range.

Returns
A reference to the range, as defined in slider_range.

◆ range() [2/2]

slider & liblec::lecui::widgets::slider::range ( const slider_range range)

Set the slider's range.

Parameters
rangeThe range.
Returns
A reference to the modified object.

◆ rect() [1/2]

lecui::rect & liblec::lecui::widgets::slider::rect ( )
overridevirtual

Get or set the position and dimensions of the widget.

Returns
A reference to the widget rectangle.

The position is in reference to the widget's container.

Implements liblec::lecui::widgets::widget.

◆ rect() [2/2]

slider & liblec::lecui::widgets::slider::rect ( const lecui::rect rect)

Set the position and dimensions of the widget.

Parameters
rectThe widget's rectangle.
Returns
A reference to the modified object.

◆ show_tick_labels() [1/2]

bool & liblec::lecui::widgets::slider::show_tick_labels ( )

Get or set the property for whether to show tick labels on the slider.

Returns
A reference to the property.

◆ show_tick_labels() [2/2]

slider & liblec::lecui::widgets::slider::show_tick_labels ( const bool &  show_tick_labels)

Set the property for whether to show tick labels on the slider.

Parameters
show_tick_labelsWhether to show tick labels on the slider.
Returns
A reference to the modified object.

◆ show_tick_marks() [1/2]

bool & liblec::lecui::widgets::slider::show_tick_marks ( )

Get or set the property for whether to show ticks marks on the slider.

Returns
A reference to the property.

◆ show_tick_marks() [2/2]

slider & liblec::lecui::widgets::slider::show_tick_marks ( const bool &  show_tick_marks)

Set the property for whether to show ticks marks on the slider.

Parameters
show_tick_marksWhether to show tick marks on the slider.
Returns
A reference to the modified object.

◆ slide_thickness() [1/2]

float & liblec::lecui::widgets::slider::slide_thickness ( )

Get or set the thickness of the slide.

Returns
A reference to the thickness, in pixels.

◆ slide_thickness() [2/2]

slider & liblec::lecui::widgets::slider::slide_thickness ( const float &  slide_thickness)

Set the thickness of the slide.

Parameters
slide_thicknessThe thickness of the slide, in pixels.
Returns
A reference to the modified object.

◆ snap_to_ticks() [1/2]

bool & liblec::lecui::widgets::slider::snap_to_ticks ( )

Get or set the property for whether to snap slider movements to the ticks.

Returns
A reference to the property.

◆ snap_to_ticks() [2/2]

slider & liblec::lecui::widgets::slider::snap_to_ticks ( const bool &  snap_to_ticks)

Set the property for whether to snap slider movements to the ticks.

Parameters
snap_to_ticksWhether to snap slider movements to the ticks.
Returns
A reference to the modified object.

◆ text() [1/2]

std::string & liblec::lecui::widgets::slider::text ( )
overridevirtual

Get or set the widget text.

Returns
A reference to the widget text.

Implements liblec::lecui::widgets::widget.

◆ text() [2/2]

slider & liblec::lecui::widgets::slider::text ( const std::string &  text)

Set the widget's text.

Parameters
textThe text.
Returns
A reference to the modified object.

◆ tooltip() [1/2]

std::string & liblec::lecui::widgets::slider::tooltip ( )
overridevirtual

Get or set the widget's tooltip text.

Returns
A reference to the tooltip text.

Implements liblec::lecui::widgets::widget.

◆ tooltip() [2/2]

slider & liblec::lecui::widgets::slider::tooltip ( const std::string &  tooltip)

Set the tooltip text.

Parameters
tooltipThe tooltip text.
Returns
A reference to the modified object.

◆ value() [1/2]

float & liblec::lecui::widgets::slider::value ( )

Get or set the position of the knob along the slide.

Returns
A reference to the position.

◆ value() [2/2]

slider & liblec::lecui::widgets::slider::value ( const float &  value)

Set the position of the knob along the slide, e.g. 63.5f.

Parameters
valueThe position of the knob.
Returns
A reference to the modified object.

The documentation for this class was generated from the following file: