Various GUI tweaks
- Tweak tile size to match previous Asset Browser better - Reduce margins between preview tiles (grid view was ignoring `align` parameter). - Improve placement of text below previews (allowing previews to be slightly bigger). - Tweak margins of main asset browser layout.
This commit is contained in:
parent
f17ea3da02
commit
2011d1f6d0
|
@ -4929,21 +4929,33 @@ int UI_autocomplete_end(AutoComplete *autocpl, char *autoname)
|
|||
return match;
|
||||
}
|
||||
|
||||
#define PREVIEW_TILE_PAD (0.15f * UI_UNIT_X)
|
||||
|
||||
int UI_preview_tile_size_x(void)
|
||||
{
|
||||
return round_fl_to_int((96.0f / 20.0f) * UI_UNIT_X);
|
||||
const float pad = PREVIEW_TILE_PAD;
|
||||
return round_fl_to_int((96.0f / 20.0f) * UI_UNIT_X + 2.0f * pad);
|
||||
}
|
||||
|
||||
int UI_preview_tile_size_y(void)
|
||||
{
|
||||
return round_fl_to_int((96.0f / 20.0f) * UI_UNIT_Y);
|
||||
const uiStyle *style = UI_style_get();
|
||||
const float font_height = style->widget.points * UI_DPI_FAC;
|
||||
const float pad = PREVIEW_TILE_PAD;
|
||||
|
||||
return round_fl_to_int(UI_preview_tile_size_y_no_label() + font_height +
|
||||
/* Add some extra padding to make things less tight vertically. */
|
||||
pad);
|
||||
}
|
||||
|
||||
int UI_preview_tile_size_y_no_label(void)
|
||||
{
|
||||
return round_fl_to_int((96.0f / 20.0f) * UI_UNIT_Y - UI_UNIT_Y);
|
||||
const float pad = PREVIEW_TILE_PAD;
|
||||
return round_fl_to_int((96.0f / 20.0f) * UI_UNIT_Y + 2.0f * pad);
|
||||
}
|
||||
|
||||
#undef PREVIEW_TILE_PAD
|
||||
|
||||
static void ui_but_update_and_icon_set(uiBut *but, int icon)
|
||||
{
|
||||
if (icon) {
|
||||
|
|
|
@ -4444,8 +4444,8 @@ static void ui_litem_layout_grid_flow(uiLayout *litem)
|
|||
BLI_assert(gflow->tot_columns > 0);
|
||||
BLI_assert(gflow->tot_rows > 0);
|
||||
|
||||
const int space_x = style->columnspace;
|
||||
const int space_y = style->buttonspacey;
|
||||
const int space_x = litem->align ? 0 : style->columnspace;
|
||||
const int space_y = litem->align ? 0 : style->buttonspacey;
|
||||
|
||||
int *widths = BLI_array_alloca(widths, gflow->tot_columns);
|
||||
int *heights = BLI_array_alloca(heights, gflow->tot_rows);
|
||||
|
|
|
@ -5506,13 +5506,17 @@ void ui_draw_preview_item_stateless(const uiFontStyle *fstyle,
|
|||
eFontStyle_Align text_align)
|
||||
{
|
||||
rcti trect = *rect;
|
||||
const float text_size = UI_UNIT_Y;
|
||||
float font_dims[2] = {0.0f, 0.0f};
|
||||
const bool has_text = name && name[0];
|
||||
const float padding = PREVIEW_PAD;
|
||||
|
||||
if (has_text) {
|
||||
UI_fontstyle_set(fstyle);
|
||||
BLF_width_and_height(
|
||||
fstyle->uifont_id, name, BLF_DRAW_STR_DUMMY_MAX, &font_dims[0], &font_dims[1]);
|
||||
|
||||
/* draw icon in rect above the space reserved for the label */
|
||||
rect->ymin += text_size;
|
||||
rect->ymin += round_fl_to_int(font_dims[1] + 2 * padding);
|
||||
}
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
widget_draw_preview(iconid, 1.0f, rect);
|
||||
|
@ -5522,15 +5526,9 @@ void ui_draw_preview_item_stateless(const uiFontStyle *fstyle,
|
|||
return;
|
||||
}
|
||||
|
||||
BLF_width_and_height(
|
||||
fstyle->uifont_id, name, BLF_DRAW_STR_DUMMY_MAX, &font_dims[0], &font_dims[1]);
|
||||
|
||||
/* text rect */
|
||||
trect.ymin += U.widget_unit / 2;
|
||||
trect.ymax = trect.ymin + font_dims[1];
|
||||
if (trect.xmax > rect->xmax - PREVIEW_PAD) {
|
||||
trect.xmax = rect->xmax - PREVIEW_PAD;
|
||||
}
|
||||
BLI_rcti_pad(&trect, -padding * 2, -padding * 2);
|
||||
trect.ymax = round_fl_to_int(trect.ymin + font_dims[1]);
|
||||
|
||||
{
|
||||
char drawstr[UI_MAX_DRAW_STR];
|
||||
|
|
|
@ -46,9 +46,19 @@ void asset_browser_main_region_draw(const bContext *C, ARegion *region)
|
|||
UI_view2d_view_ortho(v2d);
|
||||
|
||||
const uiStyle *style = UI_style_get_dpi();
|
||||
const float padding = style->panelouter;
|
||||
uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS);
|
||||
uiLayout *layout = UI_block_layout(
|
||||
block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, style->panelspace, 0, region->winx, 1, 0, style);
|
||||
block,
|
||||
UI_LAYOUT_VERTICAL,
|
||||
UI_LAYOUT_PANEL,
|
||||
padding,
|
||||
-padding,
|
||||
/* 3x (instead of 2x) padding to add extra space for the scrollbar on the right. */
|
||||
region->winx - 3 * padding,
|
||||
1,
|
||||
0,
|
||||
style);
|
||||
|
||||
asset_view_create_in_layout(
|
||||
*C, asset_space->asset_library_ref, asset_space->catalog_filter, *layout);
|
||||
|
|
Loading…
Reference in New Issue