4 : Framebuffer(width, height, format, txt_cnf)
12UIModelObject::UIModelObject()
22 return this->change_flag;
25void UIModelObject::clear_change_flag()
27 this->change_flag =
false;
32 if (this->current_controller != _new_controller)
34 this->current_controller = _new_controller;
41 if (this->status != _new_status)
43 this->status = _new_status;
55 this->change_flag =
true;
62 this->min_value = _min_value;
63 this->max_value = _max_value;
64 this->is_wrappable = _is_wrapable;
65 this->increment = _increment;
72void UIControlledIncrementalValue::increment_value()
74 int previous_value = value;
76 if (value > max_value)
77 value = (is_wrappable) ? min_value : max_value;
78 if (value != previous_value)
82void UIControlledIncrementalValue::decrement_value()
84 int previous_value = value;
86 if (value < min_value)
87 value = (is_wrappable) ? max_value : min_value;
88 if (value != previous_value)
94 int previous_value = value;
95 value = std::min(max_value, std::max(min_value, _new_value));
96 if (value != previous_value)
115UIObjectManager::UIObjectManager()
119 current_active_model =
this;
128 this->managed_models.push_back(_new_model);
129 this->max_value = managed_models.size() - 1;
132void UIObjectManager::increment_focus()
134 int previous_value = value;
135 this->increment_value();
136 if (value != previous_value)
138 this->managed_models[previous_value]->update_status(ControlledObjectStatus::IS_WAITING);
139 this->managed_models[this->value]->update_status(ControlledObjectStatus::HAS_FOCUS);
143void UIObjectManager::decrement_focus()
145 int previous_value = value;
146 this->decrement_value();
147 if (value != previous_value)
149 this->managed_models[previous_value]->update_status(ControlledObjectStatus::IS_WAITING);
150 this->managed_models[this->value]->update_status(ControlledObjectStatus::HAS_FOCUS);
154void UIObjectManager::make_managed_object_active()
156 this->current_active_model = this->managed_models[this->value];
157 this->current_active_model->
update_status(ControlledObjectStatus::IS_ACTIVE);
161void UIObjectManager::make_manager_active()
163 if (managed_models.size() != 0)
165 current_active_model->
update_status(ControlledObjectStatus::HAS_FOCUS);
166 for (
auto &&model : managed_models)
169 current_active_model =
this;
173UIController::UIController()
183 if (this->current_controlled_object != _new_controlled_object)
185 this->current_controlled_object = _new_controlled_object;
190void UIWidget::draw_border()
192 rect(0, 0, frame_width, frame_height);
197 return ((time_us_32() / _blink_period) % 2) ? FramebufferColor::WHITE : FramebufferColor::BLACK;
201 uint8_t _widget_border_width, FramebufferFormat _framebuffer_format, StructFramebufferText _framebuffer_txt_cnf)
202 : Framebuffer(_frame_width, _frame_height, _framebuffer_format, _framebuffer_txt_cnf)
204 this->display_screen = _display_screen;
205 this->widget_anchor_x = _widget_anchor_x;
206 this->widget_anchor_y = _widget_anchor_y;
207 this->widget_with_border = _widget_with_border;
208 this->widget_border_width = (widget_with_border) ? _widget_border_width : 0;
210 widget_start_x = widget_border_width;
211 widget_start_y = widget_border_width;
212 widget_width = frame_width - 2 * widget_border_width;
213 widget_height = frame_height - 2 * widget_border_width;
222 this->displayed_model = _new_displayed_model;
227 this->display_screen = _new_display_device;
232 this->widgets.push_back(_sub_widget);
241 if (widgets.size() != 0)
243 for (
auto &&w : widgets)
251 if ((this->displayed_model !=
nullptr) and (this->displayed_model->
has_changed()))
254 if (widget_with_border)
256 this->display_screen->
show(
this, this->widget_anchor_x, this->widget_anchor_y);
257 this->displayed_model->clear_change_flag();
~UIControlledIncrementalValue()
Destroy the UIControlledIncrementalValue object.
int get_max_value()
Get the max value object.
UIControlledIncrementalValue(int _min_value=0, int _max_value=10, bool _is_wrapable=false, int increment=1)
Construct a new UIControlledIncrementalValue object.
int get_min_value()
Get the min value object.
void set_clipped_value(int _new_value)
Set the clipped value object.
int get_value()
Get the value object.
void update_current_controlled_object(UIModelObject *_new_controlled_object)
~UIController()
Destroy the UIController object.
This is the abstract class to handle all generic behavior of physical display devices (e....
UIDisplayDevice(size_t width, size_t height, FramebufferFormat format=FramebufferFormat::MONO_VLSB, StructFramebufferText txt_cnf={.font=font_8x8})
Construct a new UIDisplayDevice object.
virtual ~UIDisplayDevice()
Destroy the UIDisplayDevice object.
virtual void show()=0
This is an pure virtual member function that all final derived class must implement....
void update_status(ControlledObjectStatus _new_status)
~UIModelObject()
Destroy the UIModelObject object.
void set_change_flag()
Set the change flag object.
ControlledObjectStatus get_status()
Get the status object.
void update_current_controller(UIController *_new_controller)
~UIObjectManager()
Destroy the UIObjectManager object.
void add_managed_model(UIModelObject *_new_model)
ControlledObjectStatus
The list of status that a model can have.