fix(ui): size flex lines by content in fixed-size containers

- subtract the line content height, not the container text sizehint, when
  distributing cross-axis free space
- center icons correctly in text-based flex containers such as empty-media
- pin the empty-media icon to a 16px box
This commit is contained in:
Liu
2026-11-22 20:11:23 +08:00
parent 3270d8f34f
commit 5b18848ef9
3 changed files with 22 additions and 2 deletions
+10 -1
View File
@@ -1395,8 +1395,10 @@ static void ui_flexbox_resolve_cross_sizes(ui_flexbox_context_t *ctx)
float cross_free_space;
float cross_space;
float line_max_cross_size;
float lines_cross_size;
/* 合并交叉轴 hint(无论交叉尺寸是否固定都合并,保持旧行为)。 */
lines_cross_size = ctx->cross_size;
ctx->cross_size = y_max(ctx->cross_size, ctx->hint_cross_size);
if (column) {
cross_axis = s->padding_left;
@@ -1413,7 +1415,14 @@ static void ui_flexbox_resolve_cross_sizes(ui_flexbox_context_t *ctx)
}
cross_free_space = ctx->widget->content_box.height;
}
cross_free_space -= ctx->cross_size;
/* A definite cross size already gives the lines their full space;
* don't let the container's own text sizehint shrink that area. */
if (column ? IS_CSS_FIXED_LENGTH(s, width)
: IS_CSS_FIXED_LENGTH(s, height)) {
cross_free_space -= lines_cross_size;
} else {
cross_free_space -= ctx->cross_size;
}
cross_space =
ctx->lines.length > 0 ? cross_free_space / ctx->lines.length : 0;
+6
View File
@@ -367,6 +367,12 @@ empty-media:icon {
@apply flex h-8 w-8 items-center justify-center rounded-lg bg-muted text-foreground dark:bg-muted-dark dark:text-foreground-dark;
}
empty-media:icon icon {
width: 16px;
height: 16px;
font-size: 16px;
}
empty-title {
@apply block text-sm font-medium;
}
+6 -1
View File
@@ -626,6 +626,11 @@ static const struct {
{ " background-color: #262626;\r\n", 30 },
{ " color: #fafafa;\n", 18 },
{ "}\n", 2 },
{ "empty-media:icon icon {\r\n", 25 },
{ " width: 16px;\r\n", 16 },
{ " height: 16px;\r\n", 17 },
{ " font-size: 16px;\n", 19 },
{ "}\n", 2 },
{ "empty-title {\r\n", 15 },
{ " display: block;\r\n", 19 },
{ " font-size: 14px;\r\n", 20 },
@@ -2555,7 +2560,7 @@ static const struct {
{ " background-color: rgb(250 250 250 / 0.6);\n", 44 },
{ "}\n", 2 },
};
static const size_t css_str_style_nova_total_length = 51394;
static const size_t css_str_style_nova_total_length = 51473;
static inline void ui_load_css_string_style_nova_chunks(void)
{
size_t i;