mirror of
https://git.checksum.fail/alec/erythros
synced 2025-12-10 13:09:55 +02:00
Media/Themes/Umami: Implement @umami_list_view_repaint()
This commit is contained in:
@@ -947,6 +947,113 @@ U0 @umami_label_repaint(Window* win, BitmapFontTextLabelWidget* widget, I64 x,
|
|||||||
|
|
||||||
U0 @umami_list_view_repaint(Window* win, ListViewWidget* widget, I64 x, I64 y)
|
U0 @umami_list_view_repaint(Window* win, ListViewWidget* widget, I64 x, I64 y)
|
||||||
{
|
{
|
||||||
|
Context2D* ctx = win->render_ctx;
|
||||||
|
Context2D* list_view_ctx = NewContext2D(widget->width, widget->height);
|
||||||
|
list_view_ctx->fill(Color(255, 255, 255));
|
||||||
|
|
||||||
|
I64 list_x = 0;
|
||||||
|
I64 list_y = 0;
|
||||||
|
|
||||||
|
I64 i;
|
||||||
|
I64 j;
|
||||||
|
JsonObject* column = NULL;
|
||||||
|
JsonObject* item = NULL;
|
||||||
|
|
||||||
|
JsonArray* item_row = NULL;
|
||||||
|
JsonObject* item_column = NULL;
|
||||||
|
|
||||||
|
Context2D* icon = NULL;
|
||||||
|
U8* label = NULL;
|
||||||
|
|
||||||
|
I64 column_width = 0;
|
||||||
|
|
||||||
|
list_y = 0;
|
||||||
|
if (widget->columns && widget->columns->length && widget->items && widget->items->length) {
|
||||||
|
list_x = 0;
|
||||||
|
for (j = 0; j < widget->columns->length; j++) {
|
||||||
|
column = widget->columns->@(j);
|
||||||
|
column_width = column->@("width");
|
||||||
|
icon = column->@("icon");
|
||||||
|
label = column->@("label");
|
||||||
|
list_view_ctx->fill_rect(list_x, list_y, column_width, 20, Color(128, 128, 128));
|
||||||
|
PutS2D(list_view_ctx, widget->font, list_x + @t(icon, 24, 4), list_y + 5,
|
||||||
|
widget->color, -1, label);
|
||||||
|
if (icon) {
|
||||||
|
list_view_ctx->blot(list_x + 4, list_y, icon);
|
||||||
|
}
|
||||||
|
list_x += column_width;
|
||||||
|
}
|
||||||
|
list_y += 20;
|
||||||
|
for (i = 0; i < widget->items->length; i++) {
|
||||||
|
item = widget->items->@(i);
|
||||||
|
list_x = 0;
|
||||||
|
for (j = 0; j < widget->columns->length; j++) {
|
||||||
|
column = widget->columns->@(j);
|
||||||
|
column_width = column->@("width");
|
||||||
|
label = column->@("label");
|
||||||
|
|
||||||
|
if (item->@("selected")) {
|
||||||
|
list_view_ctx->fill_rect(list_x, list_y, column_width, 20, Compositor.theme.color.hilight);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item->@(label)) {
|
||||||
|
icon = item->o(label)->@("icon");
|
||||||
|
if (item->o(label)->@("text")) {
|
||||||
|
if (item->@("selected")) {
|
||||||
|
PutS2D(list_view_ctx, widget->font, list_x + @t(icon, 24, 4), list_y + 5,
|
||||||
|
Color(255, 255, 255), -1, item->o(label)->@("text"));
|
||||||
|
} else {
|
||||||
|
list_view_ctx->fill_rect(list_x, list_y, column_width, 20, Color(255, 255, 255));
|
||||||
|
PutS2D(list_view_ctx, widget->font, list_x + @t(icon, 24, 4), list_y + 5,
|
||||||
|
widget->color, -1, item->o(label)->@("text"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (icon) {
|
||||||
|
list_view_ctx->blot(list_x + 4, list_y, icon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
list_x += column_width;
|
||||||
|
}
|
||||||
|
if (i == widget->index) {
|
||||||
|
Line2D(list_view_ctx, 0, list_y,
|
||||||
|
0 + list_view_ctx->width - 1, list_y,
|
||||||
|
Color(0, 0, 0, win->opacity));
|
||||||
|
Line2D(list_view_ctx, 0, list_y, 0,
|
||||||
|
list_y + 20 - 2,
|
||||||
|
Color(0, 0, 0, win->opacity));
|
||||||
|
|
||||||
|
Line2D(list_view_ctx, 0 + list_view_ctx->width - 1, list_y,
|
||||||
|
0 + list_view_ctx->width - 1,
|
||||||
|
list_y + 20 - 1,
|
||||||
|
Color(0, 0, 0, win->opacity));
|
||||||
|
Line2D(list_view_ctx, 0, list_y + 20 - 1,
|
||||||
|
0 + list_view_ctx->width - 1,
|
||||||
|
list_y + 20 - 1,
|
||||||
|
Color(0, 0, 0, win->opacity));
|
||||||
|
}
|
||||||
|
list_y += 20;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Line2D(list_view_ctx, 0, 0,
|
||||||
|
0 + list_view_ctx->width - 1, 0,
|
||||||
|
Color(156, 156, 156, win->opacity));
|
||||||
|
Line2D(list_view_ctx, 0, 0, 0,
|
||||||
|
0 + list_view_ctx->height - 2,
|
||||||
|
Color(156, 156, 156, win->opacity));
|
||||||
|
|
||||||
|
Line2D(list_view_ctx, 0 + list_view_ctx->width - 1, 0,
|
||||||
|
0 + list_view_ctx->width - 1,
|
||||||
|
0 + list_view_ctx->height - 1,
|
||||||
|
Color(255, 255, 255, win->opacity));
|
||||||
|
Line2D(list_view_ctx, 0, 0 + list_view_ctx->height - 1,
|
||||||
|
0 + list_view_ctx->width - 1,
|
||||||
|
0 + list_view_ctx->height - 1,
|
||||||
|
Color(255, 255, 255, win->opacity));
|
||||||
|
|
||||||
|
ctx->blot(x, y, list_view_ctx);
|
||||||
|
DelContext2D(list_view_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 @umami_menu_item_repaint(Window* win, MenuItemWidget* widget, I64 x, I64 y)
|
U0 @umami_menu_item_repaint(Window* win, MenuItemWidget* widget, I64 x, I64 y)
|
||||||
|
|||||||
Reference in New Issue
Block a user