29#define _Class _ProgressBar
40 release(this->background);
41 release(this->foreground);
44 free(this->labelFormat);
60 double value = this->value;
72 $(self,
bind, inlets, dictionary);
84#pragma mark - ProgressBar
114 assert(self->foreground);
138 return 100.0 * self->
value / (self->
max - self->
min);
161 value = clamp(value, self->
min, self->
max);
163 const double delta = fabs(self->
value - value);
164 if (delta > __DBL_EPSILON__) {
168 const double frac = self->value / (self->max - self->min);
175 if (self->delegate.didSetValue) {
176 self->delegate.didSetValue(self, self->value);
181#pragma mark - Class lifecycle
188 ((ObjectInterface *) clazz->interface)->dealloc =
dealloc;
191 ((ViewInterface *) clazz->interface)->init =
init;
193 ((ProgressBarInterface *) clazz->interface)->formatLabel =
formatLabel;
194 ((ProgressBarInterface *) clazz->interface)->initWithFrame =
initWithFrame;
195 ((ProgressBarInterface *) clazz->interface)->progress =
progress;
196 ((ProgressBarInterface *) clazz->interface)->setLabelFormat =
setLabelFormat;
197 ((ProgressBarInterface *) clazz->interface)->setValue =
setValue;
209 clazz = _initialize(&(
const ClassDef) {
210 .name =
"ProgressBar",
211 .superclass =
_View(),
213 .interfaceOffset = offsetof(
ProgressBar, interface),
214 .interfaceSize =
sizeof(ProgressBarInterface),
static void dealloc(Object *self)
static void initialize(Class *clazz)
#define MakeInlets(...)
Creates a null-termianted array of Inlets.
#define MakeInlet(name, type, dest, data)
Creates an Inlet with the specified parameters.
Box * initWithFrame(Box *self, const SDL_Rect *frame)
Initializes this Box with the given frame.
CollectionView * init(CollectionView *self, const SDL_Rect *frame)
Initializes this CollectionView with the specified frame and style.
ImageViews render an Image in the context of a View hierarchy.
Inlets enable inbound data binding of View attributes through JSON.
Label * initWithText(Label *self, const char *text, Font *font)
Initializes this Label with the given text and Font.
double min
The progress bounds.
double value
The progress value.
Text * label
The progress Text.
ImageView * background
The background ImageView.
double progress(const ProgressBar *self)
Class * _ProgressBar(void)
The ProgressBar archetype.
void setLabelFormat(ProgressBar *self, const char *labelFormat)
Changes this ProgressBar's label format and calls appropriate update functions.
void formatLabel(ProgressBar *self)
Forces an update on this ProgressBar's label.
char * labelFormat
The Label format, e.g. "%0.0lf".
void setValue(const ProgressBar *self, double value)
Sets the value, which is clamped to min and max.
Text rendered with TrueType fonts.
void setText(Text *self, const char *text)
Sets this Text's text.
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
SDL_Rect bounds(const View *self)
_Bool bind(View *self, const Inlet *inlets, const Dictionary *dictionary)
Performs data binding for the Inlets described in dictionary.
_Bool needsLayout
If true, this View will layout its subviews before it is drawn.
Class * _View(void)
The View archetype.
void addSubview(View *self, View *subview)
Adds a subview to this view, to be drawn above its siblings.
void addClassName(View *self, const char *className)
Adds the given class name to this View.
void awakeWithDictionary(View *self, const Dictionary *dictionary)
Wakes this View with the specified Dictionary.
SDL_Rect frame
The frame, relative to the superview.