29#define _Class _RGBColorPicker
31#pragma mark - Delegates
40 const int c = round(value);
42 if (slider == this->redSlider) {
44 }
else if (slider == this->greenSlider) {
46 }
else if (slider == this->blueSlider) {
48 }
else if (slider == this->alphaSlider) {
56 if (this->delegate.didPickColor) {
57 this->delegate.didPickColor(
this, &this->color);
70 memset(&this->delegate, 0,
sizeof(this->delegate));
72 release(this->colorView);
73 release(this->redSlider);
74 release(this->redInput);
75 release(this->greenSlider);
76 release(this->greenInput);
77 release(this->blueSlider);
78 release(this->blueInput);
79 release(this->alphaSlider);
80 release(this->alphaInput);
81 release(this->stackView);
111 $(self, bind, inlets, dictionary);
130 $(this->redSlider,
setValue, this->color.r);
131 $(this->greenSlider,
setValue, this->color.g);
132 $(this->blueSlider,
setValue, this->color.b);
133 $(this->alphaSlider,
setValue, this->color.a);
135 this->colorView->backgroundColor = this->color;
138#pragma mark - RGBColorPicker
155 assert(self->colorView);
161 assert(self->redSlider);
163 self->redSlider->delegate.self = self;
165 self->redSlider->max = 255.0;
169 assert(self->redInput);
172 $(self->redInput->label->text,
setText,
"R");
177 assert(self->greenSlider);
179 self->greenSlider->delegate.self = self;
181 self->greenSlider->max = 255.0;
185 assert(self->greenInput);
188 $(self->greenInput->label->text,
setText,
"G");
193 assert(self->blueSlider);
195 self->blueSlider->delegate.self = self;
197 self->blueSlider->max = 255.0;
201 assert(self->blueInput);
204 $(self->blueInput->label->text,
setText,
"B");
209 assert(self->alphaSlider);
211 self->alphaSlider->delegate.self = self;
213 self->alphaSlider->max = 255.0;
217 assert(self->alphaInput);
220 $(self->alphaInput->label->text,
setText,
"A");
238 self->
color = *color;
243#pragma mark - Class lifecycle
250 ((ObjectInterface *) clazz->interface)->dealloc =
dealloc;
253 ((ViewInterface *) clazz->interface)->init =
init;
256 ((RGBColorPickerInterface *) clazz->interface)->initWithFrame =
initWithFrame;
269 clazz = _initialize(&(
const ClassDef) {
270 .name =
"RGBColorPicker",
274 .interfaceSize =
sizeof(RGBColorPickerInterface),
static void addSubview(View *self, View *subview)
static void setValue(ProgressBar *self, double value)
static void setLabelFormat(ProgressBar *self, const char *labelFormat)
static View * init(View *self)
static void awakeWithDictionary(View *self, const Dictionary *dictionary)
static RGBColorPicker * initWithFrame(RGBColorPicker *self, const SDL_Rect *frame)
static void dealloc(Object *self)
static void initialize(Class *clazz)
static void updateBindings(View *self)
static void setColor(RGBColorPicker *self, const SDL_Color *color)
static void didSetComponent(Slider *slider, double value)
SliderDelegate callback for color component modification.
Class * _RGBColorPicker(void)
static void setText(Text *self, const char *text)
#define MakeInlets(...)
Creates a null-termianted array of Inlets.
#define MakeInlet(name, type, dest, data)
Creates an Inlet with the specified parameters.
static void addClassName(View *self, const char *className)
Controls are Views which capture and respond to events.
Inlets enable inbound data binding of View attributes through JSON.
void setColor(RGBColorPicker *self, const SDL_Color *color)
Sets the color of the RGBColorPicker.
StackView * stackView
The StackView.
SDL_Color color
The color.
ident self
The delegate self-reference.
A Control allowing users to drag a handle to select a numeric value.
SliderDelegate delegate
The delegate.
StackViews are containers that manage the arrangement of their subviews.
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
void updateBindings(View *self)
Updates data bindings, prompting the appropriate layout changes.