ObjectivelyMVC
Object oriented MVC framework for SDL3 and GNU C
Loading...
Searching...
No Matches
Slider.h
Go to the documentation of this file.
1/*
2 * ObjectivelyMVC: Object oriented MVC framework for SDL3 and C.
3 * Copyright (C) 2014 Jay Dolan <jay@jaydolan.com>
4 *
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 *
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
12 *
13 * 1. The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software
15 * in a product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
17 *
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
20 *
21 * 3. This notice may not be removed or altered from any source distribution.
22 */
23
24#pragma once
25
26#include <Objectively/Array.h>
27#include <Objectively/Vector.h>
28
30#include <ObjectivelyMVC/Text.h>
31
37typedef struct SliderDelegate SliderDelegate;
38
39typedef struct Slider Slider;
40typedef struct SliderInterface SliderInterface;
41
46
50 ident self;
51
57 void (*didSetValue)(Slider *slider, double value);
58};
59
65struct Slider {
66
71
76 SliderInterface *interface[0];
77
82
87
92 View *handle;
93
98
103
108 Array *labels;
109
113 double min, max;
114
118 double step;
119
124
128 double value;
129
135 Vector *values;
136};
137
141struct SliderInterface {
142
146 ControlInterface controlInterface;
147
154 void (*formatLabel)(Slider *self);
155
163 Slider *(*initWithFrame)(Slider *self, const SDL_Rect *frame);
164
172 void (*setLabelFormat)(Slider *self, const char *labelFormat);
173
181 void (*setValue)(Slider *self, double value);
182};
183
190OBJECTIVELYMVC_EXPORT Class *_Slider(void);
Controls are Views which capture and respond to events.
OBJECTIVELYMVC_EXPORT Class * _Slider(void)
Definition Slider.c:502
Text rendered with TrueType fonts.
#define OBJECTIVELYMVC_EXPORT
Definition Types.h:40
Controls are Views which capture and respond to events.
Definition Control.h:83
The Slider delegate protocol.
Definition Slider.h:45
void(* didSetValue)(Slider *slider, double value)
Delegate callback for Slider value modification.
Definition Slider.h:57
ident self
The delegate self-reference.
Definition Slider.h:50
A Control allowing users to drag a handle to select a numeric value.
Definition Slider.h:65
double max
Definition Slider.h:113
double min
The slider bounds.
Definition Slider.h:113
Vector * values
An optional Vector of non-linear values.
Definition Slider.h:135
Array * labels
An optional Array of non-linear labels parallel to values.
Definition Slider.h:108
View * bar
The slider bar.
Definition Slider.h:81
Text * label
The Text displaying the current value.
Definition Slider.h:97
SliderDelegate delegate
The delegate.
Definition Slider.h:86
char * labelFormat
The label format, e.g. "%0.01f".
Definition Slider.h:102
double value
The slider value.
Definition Slider.h:128
SliderInterface * interface[0]
The interface type.
Definition Slider.h:76
bool snapToStep
Enable snapping the slider handle to the step.
Definition Slider.h:123
double step
The step to increment on key events.
Definition Slider.h:118
Control control
The superclass.
Definition Slider.h:70
Text rendered with TrueType fonts.
Definition Text.h:131
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
Definition View.h:225