Fix panel scrolling issue (clamping scroll value was only done when scrollers were on)
This commit is contained in:
parent
6fe1a29a4b
commit
0becc301d0
20
src/ui.c
20
src/ui.c
|
@ -519,8 +519,13 @@ ui_box* ui_box_make_str8(str8 string, ui_flags flags)
|
||||||
memset(box, 0, sizeof(ui_box));
|
memset(box, 0, sizeof(ui_box));
|
||||||
|
|
||||||
box->key = key;
|
box->key = key;
|
||||||
|
box->fresh = true;
|
||||||
ui_box_cache(ui, box);
|
ui_box_cache(ui, box);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
box->fresh = false;
|
||||||
|
}
|
||||||
|
|
||||||
//NOTE: setup hierarchy
|
//NOTE: setup hierarchy
|
||||||
ListInit(&box->children);
|
ListInit(&box->children);
|
||||||
|
@ -709,6 +714,12 @@ void ui_box_compute_styling(ui_context* ui, ui_box* box)
|
||||||
//TODO: interpolate based on transition values
|
//TODO: interpolate based on transition values
|
||||||
u32 flags = box->computedStyle.animationFlags;
|
u32 flags = box->computedStyle.animationFlags;
|
||||||
|
|
||||||
|
if(box->fresh)
|
||||||
|
{
|
||||||
|
box->computedStyle = *targetStyle;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if(flags & UI_STYLE_ANIMATE_BG_COLOR)
|
if(flags & UI_STYLE_ANIMATE_BG_COLOR)
|
||||||
{
|
{
|
||||||
ui_animate_color(ui, &box->computedStyle.bgColor, targetStyle->bgColor, animationTime);
|
ui_animate_color(ui, &box->computedStyle.bgColor, targetStyle->bgColor, animationTime);
|
||||||
|
@ -772,6 +783,7 @@ void ui_box_compute_styling(ui_context* ui, ui_box* box)
|
||||||
box->computedStyle.roundness = targetStyle->roundness;
|
box->computedStyle.roundness = targetStyle->roundness;
|
||||||
}
|
}
|
||||||
box->computedStyle.font = targetStyle->font;
|
box->computedStyle.font = targetStyle->font;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_layout_prepass(ui_context* ui, ui_box* box)
|
void ui_layout_prepass(ui_context* ui, ui_box* box)
|
||||||
|
@ -936,7 +948,8 @@ void ui_layout_compute_rect(ui_context* ui, ui_box* box, vec2 pos)
|
||||||
if(child->floating[i])
|
if(child->floating[i])
|
||||||
{
|
{
|
||||||
ui_style* style = child->targetStyle;
|
ui_style* style = child->targetStyle;
|
||||||
if(child->targetStyle->animationFlags & UI_STYLE_ANIMATE_POS)
|
if((child->targetStyle->animationFlags & UI_STYLE_ANIMATE_POS)
|
||||||
|
&& !child->fresh)
|
||||||
{
|
{
|
||||||
ui_animate_f32(ui, &child->floatPos.c[i], child->floatTarget.c[i], style->animationTime);
|
ui_animate_f32(ui, &child->floatPos.c[i], child->floatTarget.c[i], style->animationTime);
|
||||||
}
|
}
|
||||||
|
@ -1437,7 +1450,6 @@ void ui_panel_end()
|
||||||
panel->scroll.x += sig.wheel.x;
|
panel->scroll.x += sig.wheel.x;
|
||||||
ui_box_activate(scrollBarX);
|
ui_box_activate(scrollBarX);
|
||||||
}
|
}
|
||||||
panel->scroll.x = Clamp(panel->scroll.x, 0, contentsW - panel->rect.w);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(contentsH > panel->rect.h)
|
if(contentsH > panel->rect.h)
|
||||||
|
@ -1455,9 +1467,11 @@ void ui_panel_end()
|
||||||
panel->scroll.y += sig.wheel.y;
|
panel->scroll.y += sig.wheel.y;
|
||||||
ui_box_activate(scrollBarY);
|
ui_box_activate(scrollBarY);
|
||||||
}
|
}
|
||||||
panel->scroll.y = Clamp(panel->scroll.y, 0, contentsH - panel->rect.h);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
panel->scroll.x = Clamp(panel->scroll.x, 0, contentsW - panel->rect.w);
|
||||||
|
panel->scroll.y = Clamp(panel->scroll.y, 0, contentsH - panel->rect.h);
|
||||||
|
|
||||||
if(scrollBarX)
|
if(scrollBarX)
|
||||||
{
|
{
|
||||||
ui_box_set_floating(scrollBarX, UI_AXIS_X, panel->scroll.x);
|
ui_box_set_floating(scrollBarX, UI_AXIS_X, panel->scroll.x);
|
||||||
|
|
Loading…
Reference in New Issue