ObjectivelyMVC 0.1.0
Object oriented MVC framework for OpenGL, SDL2 and GNU C
Slider.h
Go to the documentation of this file.
1/*
2 * ObjectivelyMVC: Object oriented MVC framework for OpenGL, SDL2 and GNU 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
27#include <ObjectivelyMVC/Text.h>
28
34typedef struct SliderDelegate SliderDelegate;
35
36typedef struct Slider Slider;
37typedef struct SliderInterface SliderInterface;
38
43
47 ident self;
48
54 void (*didSetValue)(Slider *slider, double value);
55};
56
62struct Slider {
63
68
73 SliderInterface *interface;
74
79
84
89 Control *handle;
90
95
100
104 double min, max;
105
109 double step;
110
115
119 double value;
120};
121
125struct SliderInterface {
126
130 ControlInterface controlInterface;
131
138 void (*formatLabel)(Slider *self);
139
147 Slider *(*initWithFrame)(Slider *self, const SDL_Rect *frame);
148
156 void (*setLabelFormat)(Slider *self, const char *labelFormat);
157
165 void (*setValue)(Slider *self, double value);
166};
167
174OBJECTIVELYMVC_EXPORT Class *_Slider(void);
Controls are Views which capture events and dispatch Actions.
static void setValue(ProgressBar *self, double value)
Definition: ProgressBar.c:159
static void setLabelFormat(ProgressBar *self, const char *labelFormat)
Definition: ProgressBar.c:145
static void formatLabel(ProgressBar *self)
Definition: ProgressBar.c:90
Text rendered with TrueType fonts.
#define OBJECTIVELYMVC_EXPORT
Definition: Types.h:39
Controls are Views which capture events and dispatch Actions.
Definition: Control.h:83
The Slider delegate protocol.
Definition: Slider.h:42
void(* didSetValue)(Slider *slider, double value)
Delegate callback for Slider value modification.
Definition: Slider.h:54
ident self
The delegate self-reference.
Definition: Slider.h:47
A Control allowing users to drag a handle to select a numeric value.
Definition: Slider.h:62
double max
Definition: Slider.h:104
double min
The slider bounds.
Definition: Slider.h:104
Class * _Slider(void)
The Slider archetype.
Definition: Slider.c:298
View * bar
The slider bar.
Definition: Slider.h:78
Text * label
The Text displaying the current value.
Definition: Slider.h:94
SliderDelegate delegate
The delegate.
Definition: Slider.h:83
char * labelFormat
The label format, e.g. "%0.01f".
Definition: Slider.h:99
_Bool snapToStep
Enable snapping the slider handle to the step.
Definition: Slider.h:114
double value
The slider value.
Definition: Slider.h:119
double step
The step to increment on key events.
Definition: Slider.h:109
Control control
The superclass.
Definition: Slider.h:67
SliderInterface * interface
The interface.
Definition: Slider.h:73
Text rendered with TrueType fonts.
Definition: Text.h:41
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
Definition: View.h:133