[ui] Make Canvas_SetLen operate on only one canvas

I plan on using sub-canvases to fix the imui window overlap issue and
don't want the windows being affected by (eg) hud canvas size changes.
This commit is contained in:
Bill Currie 2023-07-08 20:56:40 +09:00
parent c32ffce886
commit bf05da26cc
6 changed files with 13 additions and 22 deletions

View file

@ -91,7 +91,7 @@ uint32_t Canvas_New (canvas_system_t canvas_sys);
void Canvas_Draw (canvas_system_t canvas_sys);
void Canvas_SortComponentPool (canvas_system_t canvas_sys, uint32_t ent,
uint32_t component);
void Canvas_SetLen (canvas_system_t canvas_sys, view_pos_t len);
void Canvas_SetLen (canvas_system_t canvas_sys, uint32_t ent, view_pos_t len);
CANVASINLINE view_t Canvas_GetRootView (canvas_system_t canvas_sys,
uint32_t ent);
CANVASINLINE bool *Canvas_Visible (canvas_system_t canvas_sys, uint32_t ent);

View file

@ -209,10 +209,9 @@ cl_set_size (void)
{
int xlen = cl_xlen / cl_scale;
int ylen = cl_ylen / cl_scale;
printf ("cl_set_size: %d %d %d\n", cl_scale, xlen, ylen);
//View_SetLen (cl_screen_view, xlen, ylen);
//View_UpdateHierarchy (cl_screen_view);
Canvas_SetLen (cl_canvas_sys, (view_pos_t) { xlen, ylen });
//printf ("cl_set_size: %d %d %d\n", cl_scale, xlen, ylen);
Canvas_SetLen (cl_canvas_sys, cl_canvas, (view_pos_t) { xlen, ylen });
Canvas_SetLen (cl_canvas_sys, hud_canvas, (view_pos_t) { xlen, ylen });
}
static void

View file

@ -865,8 +865,8 @@ con_set_size (void)
int xlen = win_xlen / con_scale;
int ylen = win_ylen / con_scale;
if (xlen > 0 && ylen > 0) {
View_SetLen (screen_view, xlen, ylen);
View_UpdateHierarchy (screen_view);
Canvas_SetLen (*con_data.canvas_sys, screen_canvas,
(view_pos_t) { xlen, ylen });
}
}

View file

@ -558,17 +558,9 @@ Canvas_SortComponentPool (canvas_system_t canvas_sys, uint32_t ent,
}
void
Canvas_SetLen (canvas_system_t canvas_sys, view_pos_t len)
Canvas_SetLen (canvas_system_t canvas_sys, uint32_t ent, view_pos_t len)
{
uint32_t comp = canvas_sys.base + canvas_canvas;
ecs_pool_t *canvas_pool = &canvas_sys.reg->comp_pools[comp];
uint32_t count = canvas_pool->count;
uint32_t *entities = canvas_pool->dense;
while (count-- > 0) {
uint32_t ent = *entities++;
view_t view = Canvas_GetRootView (canvas_sys, ent);
View_SetLen (view, len.x, len.y);
View_UpdateHierarchy (view);
}
view_t view = Canvas_GetRootView (canvas_sys, ent);
View_SetLen (view, len.x, len.y);
View_UpdateHierarchy (view);
}

View file

@ -252,8 +252,7 @@ IMUI_SetVisible (imui_ctx_t *ctx, bool visible)
void
IMUI_SetSize (imui_ctx_t *ctx, int xlen, int ylen)
{
View_SetLen (ctx->root_view, xlen, ylen);
View_UpdateHierarchy (ctx->root_view);
Canvas_SetLen (ctx->csys, ctx->canvas, (view_pos_t) { xlen, ylen });
}
void

View file

@ -338,7 +338,8 @@ generate_colormap (void)
static void
vidsize_listener (void *data, const viddef_t *vdef)
{
Canvas_SetLen (canvas_sys, (view_pos_t) { vdef->width, vdef->height });
Canvas_SetLen (canvas_sys, canvas,
(view_pos_t) { vdef->width, vdef->height });
}
void