28#define _Class _HSVColorPicker
30#pragma mark - Delegates
39 if (slider == this->hueSlider) {
41 }
else if (slider == this->saturationSlider) {
42 this->saturation = value;
43 }
else if (slider == this->valueSlider) {
51 if (this->delegate.didPickColor) {
52 this->delegate.didPickColor(
this, this->hue, this->saturation, this->value);
65 memset(&this->delegate, 0,
sizeof(this->delegate));
67 release(this->colorView);
68 release(this->hueSlider);
69 release(this->hueInput);
70 release(this->saturationSlider);
71 release(this->saturationInput);
72 release(this->valueSlider);
73 release(this->valueInput);
74 release(this->stackView);
104 $(self, bind, inlets, dictionary);
123 $(this->hueSlider,
setValue, this->hue);
124 $(this->saturationSlider,
setValue, this->saturation);
125 $(this->valueSlider,
setValue, this->value);
127 this->colorView->backgroundColor = $(
this,
rgbColor);
130#pragma mark - HSVColorPicker
147 assert(self->colorView);
153 assert(self->hueSlider);
155 self->hueSlider->delegate.self = self;
157 self->hueSlider->max = 360.0;
161 assert(self->hueInput);
164 $(self->hueInput->label->text,
setText,
"H");
169 assert(self->saturationSlider);
171 self->saturationSlider->delegate.self = self;
173 self->saturationSlider->max = 1.0;
177 assert(self->saturationInput);
180 $(self->saturationInput->label->text,
setText,
"S");
185 assert(self->valueSlider);
187 self->valueSlider->delegate.self = self;
189 self->valueSlider->max = 1.0;
193 assert(self->valueInput);
196 $(self->valueInput->label->text,
setText,
"V");
238#pragma mark - Class lifecycle
245 ((ObjectInterface *) clazz->interface)->dealloc =
dealloc;
248 ((ViewInterface *) clazz->interface)->init =
init;
251 ((HSVColorPickerInterface *) clazz->interface)->initWithFrame =
initWithFrame;
253 ((HSVColorPickerInterface *) clazz->interface)->setColor =
setColor;
254 ((HSVColorPickerInterface *) clazz->interface)->setRGBColor =
setRGBColor;
266 clazz = _initialize(&(
const ClassDef) {
267 .name =
"HSVColorPicker",
271 .interfaceSize =
sizeof(HSVColorPickerInterface),
SDL_Color MVC_HSVToRGB(double hue, double saturation, double value)
void MVC_RGBToHSV(const SDL_Color *color, double *hue, double *saturation, double *value)
Class * _HSVColorPicker(void)
static View * init(View *self)
static void awakeWithDictionary(View *self, const Dictionary *dictionary)
static void setRGBColor(HSVColorPicker *self, const SDL_Color *color)
static HSVColorPicker * initWithFrame(HSVColorPicker *self, const SDL_Rect *frame)
static void setColor(HSVColorPicker *self, double hue, double saturation, double value)
static void dealloc(Object *self)
static SDL_Color rgbColor(const HSVColorPicker *self)
static void initialize(Class *clazz)
static void updateBindings(View *self)
static void didSetComponent(Slider *slider, double value)
SliderDelegate callback for color component modification.
static void addSubview(View *self, View *subview)
static void setValue(ProgressBar *self, double value)
static void setLabelFormat(ProgressBar *self, const char *labelFormat)
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.
SDL_Color rgbColor(const HSVColorPicker *self)
double hue
The color components.
StackView * stackView
The StackView.
Inlets enable inbound data binding of View attributes through JSON.
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.