22#include " ui.h"
33#include < chrono>
44#include < thread>
5- void ui::widget_parent::render (nanovg_context ctx) {
6- widget::render (ctx);
5+ void ui::widget::render (nanovg_context ctx) {
76 float orig_offset_x = ctx.offset_x , orig_offset_y = ctx.offset_y ;
87 for (auto &child : children) {
98 ctx.offset_x = *x + orig_offset_x;
@@ -16,8 +15,11 @@ void ui::widget_parent::render(nanovg_context ctx) {
1615 ctx.offset_x = orig_offset_x;
1716 ctx.offset_y = orig_offset_y;
1817}
19- void ui::widget_parent::update (update_context &ctx) {
20- widget::update (ctx);
18+ void ui::widget::update (update_context &ctx) {
19+ for (auto anim : anim_floats) {
20+ anim->update (ctx.delta_t );
21+ }
22+
2123 float orig_offset_x = ctx.offset_x , orig_offset_y = ctx.offset_y ;
2224
2325 for (auto &child : children) {
@@ -29,15 +31,10 @@ void ui::widget_parent::update(update_context &ctx) {
2931 ctx.offset_x = orig_offset_x;
3032 ctx.offset_y = orig_offset_y;
3133}
32- void ui::widget_parent ::add_child (std::shared_ptr<widget> child) {
34+ void ui::widget ::add_child (std::shared_ptr<widget> child) {
3335 children.push_back (std::move (child));
3436}
3537
36- void ui::widget::update (update_context &ctx) {
37- for (auto anim : anim_floats) {
38- anim->update (ctx.delta_t );
39- }
40- }
4138bool ui::update_context::hovered (widget *w, bool hittest) const {
4239 if (hittest && !hovered_widgets.empty ())
4340 return false ;
@@ -46,8 +43,8 @@ bool ui::update_context::hovered(widget *w, bool hittest) const {
4643}
4744float ui::widget::measure_height (update_context &ctx) { return height->dest (); }
4845float ui::widget::measure_width (update_context &ctx) { return width->dest (); }
49- void ui::widget_parent_flex ::update (update_context &ctx) {
50- widget_parent ::update (ctx);
46+ void ui::widget_flex ::update (update_context &ctx) {
47+ widget ::update (ctx);
5148 float x = 0 , y = 0 ;
5249 float target_width = 0 , target_height = 0 ;
5350
@@ -124,4 +121,3 @@ bool ui::widget::check_hit(const update_context &ctx) {
124121 ctx.mouse_y >= (y->dest () + ctx.offset_y ) &&
125122 ctx.mouse_y <= (y->dest () + height->dest () + ctx.offset_y );
126123}
127- void ui::widget::render (nanovg_context ctx) {}
0 commit comments