removed force update

c3
Alessandro Mauri 1 week ago
parent 740ea0c6be
commit 499f6dc79b
  1. 6
      src/main.c3
  2. 12
      src/ugui_core.c3
  3. 1
      src/ugui_input.c3

@ -126,7 +126,6 @@ fn int main(String[] args)
if (ui.button("button0", ugui::Rect{0,0,30,30}, toggle)!!.mouse_press) { if (ui.button("button0", ugui::Rect{0,0,30,30}, toggle)!!.mouse_press) {
io::printn("press button0"); io::printn("press button0");
toggle = !toggle; toggle = !toggle;
ui.force_update()!!;
} }
//ui.layout_next_column()!!; //ui.layout_next_column()!!;
if (ui.button("button1", ugui::Rect{0,0,30,30})!!.mouse_press) { if (ui.button("button1", ugui::Rect{0,0,30,30})!!.mouse_press) {
@ -181,11 +180,6 @@ fn int main(String[] args)
{| {|
ui.layout_set_row()!!; ui.layout_set_row()!!;
ui.text_unbounded("ui avg", string::tformat("ui avg: %s\ndraw avg: %s\nTOT: %s", uts.avg, dts.avg, uts.avg+dts.avg))!!; ui.text_unbounded("ui avg", string::tformat("ui avg: %s\ndraw avg: %s\nTOT: %s", uts.avg, dts.avg, uts.avg+dts.avg))!!;
//ui.layout_next_row()!!;
//ui.text_unbounded("draw avg", string::tformat("draw avg: %s", dts.avg))!!;
//ui.force_update()!!;
|}; |};
ui.div_end()!!; ui.div_end()!!;

@ -176,8 +176,6 @@ macro bool Rect.is_null(r) => r.x == 0 && r.y == 0 && r.x == 0 && r.w == 0;
// return a pointer to the parent of the current active div // return a pointer to the parent of the current active div
fn Elem*! Ctx.get_parent(&ctx) fn Elem*! Ctx.get_parent(&ctx)
{ {
// FIXME: if the tree held pointers to the elements then no more
// redundant cache search
Id parent_id = ctx.tree.get(ctx.active_div)!; Id parent_id = ctx.tree.get(ctx.active_div)!;
return ctx.cache.search(parent_id); return ctx.cache.search(parent_id);
} }
@ -249,8 +247,7 @@ fn void! Ctx.frame_begin(&ctx)
// The root should have the updated flag only if the size of the window // The root should have the updated flag only if the size of the window
// was changed between frames, this propagates an element size recalculation // was changed between frames, this propagates an element size recalculation
// down the element tree // down the element tree
c_elem.flags.updated = ctx.input.events.resize | ctx.input.events.force_update; c_elem.flags.updated = ctx.input.events.resize;
ctx.input.events.force_update = false;
// if the window has focus then the root element also has focus, no other // if the window has focus then the root element also has focus, no other
// computation needed, child elements need to check the mouse positon and // computation needed, child elements need to check the mouse positon and
// other stuff // other stuff
@ -282,11 +279,6 @@ fn void! Ctx.frame_begin(&ctx)
// TODO: add a background color taken from a theme or config // TODO: add a background color taken from a theme or config
} }
fn void! Ctx.force_update(&ctx)
{
ctx.input.events.force_update = true;
}
fn void! Ctx.frame_end(&ctx) fn void! Ctx.frame_end(&ctx)
{ {
Elem* root = ctx.get_elem_by_tree_idx(0)!; Elem* root = ctx.get_elem_by_tree_idx(0)!;
@ -296,9 +288,7 @@ fn void! Ctx.frame_end(&ctx)
ctx.tree.nuke(); ctx.tree.nuke();
// 2. clear input fields // 2. clear input fields
bool f = ctx.input.events.force_update;
ctx.input.events = (InputEvents)0; ctx.input.events = (InputEvents)0;
ctx.input.events.force_update = f;
// send atlas updates // send atlas updates
if (ctx.font.should_update) { if (ctx.font.should_update) {

@ -9,7 +9,6 @@ bitstruct InputEvents : uint {
bool change_focus : 1; // window focus changed bool change_focus : 1; // window focus changed
bool mouse_move : 2; // mouse was moved bool mouse_move : 2; // mouse was moved
bool mouse_btn : 3; // mouse button pressed or released bool mouse_btn : 3; // mouse button pressed or released
bool force_update : 4;
} }
// Window size was changed // Window size was changed

Loading…
Cancel
Save