UI: Improved Display as Panels Narrow
As panels narrow to extremes the various parts overlap oddly. this PR improves this by fading out icons as their available space becomes too narrow to fit. Other items stop displaying under limits. Pull Request: https://projects.blender.org/blender/blender/pulls/136581
This commit is contained in:
committed by
Harley Acheson
parent
5be3b6acdb
commit
ca3076ed35
@@ -2286,9 +2286,15 @@ void UI_block_draw(const bContext *C, uiBlock *block)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Don't draw buttons that are wider than available space. */
|
||||
const int width = BLI_rcti_size_x(&rect);
|
||||
if ((width > U.widget_unit * 2.5f / block->aspect) && width > region->winx) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* XXX: figure out why invalid coordinates happen when closing render window */
|
||||
/* and material preview is redrawn in main window (temp fix for bug #23848) */
|
||||
if (rect.xmin < rect.xmax && rect.ymin < rect.ymax) {
|
||||
if (rect.xmin >= 0 && rect.xmin < rect.xmax && rect.ymin < rect.ymax) {
|
||||
ui_draw_but(C, region, &style, but.get(), &rect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1107,6 +1107,7 @@ static void panel_draw_aligned_widgets(const uiStyle *style,
|
||||
const uiFontStyle *fontstyle = (is_subpanel) ? &style->widget : &style->paneltitle;
|
||||
|
||||
const int header_height = BLI_rcti_size_y(header_rect);
|
||||
const int header_width = BLI_rcti_size_x(header_rect);
|
||||
const int scaled_unit = round_fl_to_int(UI_UNIT_X / aspect);
|
||||
|
||||
/* Offset triangle and text to the right for sub-panels. */
|
||||
@@ -1124,11 +1125,16 @@ static void panel_draw_aligned_widgets(const uiStyle *style,
|
||||
{
|
||||
const float size_y = BLI_rcti_size_y(&widget_rect);
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
float alpha = 0.8f;
|
||||
/* Dim as its space is reduced to zero. */
|
||||
if (header_width < (scaled_unit * 4)) {
|
||||
alpha *= std::max(float(header_width - scaled_unit) / float(scaled_unit * 3), 0.0f);
|
||||
}
|
||||
UI_icon_draw_ex(widget_rect.xmin + size_y * 0.2f,
|
||||
widget_rect.ymin + size_y * (UI_panel_is_closed(panel) ? 0.17f : 0.14f),
|
||||
UI_panel_is_closed(panel) ? ICON_RIGHTARROW : ICON_DOWNARROW_HLT,
|
||||
aspect * UI_INV_SCALE_FAC,
|
||||
0.8f,
|
||||
alpha,
|
||||
0.0f,
|
||||
title_color,
|
||||
false,
|
||||
@@ -1140,7 +1146,7 @@ static void panel_draw_aligned_widgets(const uiStyle *style,
|
||||
if (panel->drawname && panel->drawname[0] != '\0') {
|
||||
rcti title_rect;
|
||||
title_rect.xmin = widget_rect.xmin + (panel->labelofs / aspect) + scaled_unit * 1.1f;
|
||||
title_rect.xmax = widget_rect.xmax;
|
||||
title_rect.xmax = widget_rect.xmax - scaled_unit;
|
||||
title_rect.ymin = widget_rect.ymin - 2.0f / aspect;
|
||||
title_rect.ymax = widget_rect.ymax;
|
||||
|
||||
@@ -1172,7 +1178,10 @@ static void panel_draw_aligned_widgets(const uiStyle *style,
|
||||
const bool is_pin = panel_custom_pin_to_last_get(panel);
|
||||
const int icon = is_pin ? ICON_PINNED : ICON_GRIP;
|
||||
const float size = aspect * UI_INV_SCALE_FAC;
|
||||
const float alpha = is_pin ? 1.0f : 0.5f;
|
||||
float alpha = is_pin ? 1.0f : 0.5f;
|
||||
if (header_width < (scaled_unit * 5)) {
|
||||
alpha *= std::max((header_width - scaled_unit) / float(scaled_unit * 4), 0.0f);
|
||||
}
|
||||
UI_icon_draw_ex(x, y, icon, size, alpha, 0.0f, title_color, false, UI_NO_ICON_OVERLAY_TEXT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -904,6 +904,10 @@ static void shape_preset_trias_from_rect_menu(uiWidgetTrias *tria, const rcti *r
|
||||
{
|
||||
const float width = BLI_rcti_size_x(rect);
|
||||
const float height = BLI_rcti_size_y(rect);
|
||||
if ((width / height) < 0.5f) {
|
||||
/* Too narrow to fit. */
|
||||
return;
|
||||
}
|
||||
float centx, centy, size;
|
||||
|
||||
tria->type = ROUNDBOX_TRIA_MENU;
|
||||
@@ -1341,6 +1345,11 @@ static void widget_draw_icon(
|
||||
alpha *= widget_alpha_factor(&state);
|
||||
}
|
||||
|
||||
/* Dim the icon as its space is reduced to zero. */
|
||||
if (height > (rect->xmax - rect->xmin)) {
|
||||
alpha *= std::max(float(rect->xmax - rect->xmin) / height, 0.0f);
|
||||
}
|
||||
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
|
||||
if (icon && icon != ICON_BLANK1) {
|
||||
|
||||
@@ -898,6 +898,12 @@ void TreeViewLayoutBuilder::build_row(AbstractTreeViewItem &item) const
|
||||
uiBlock &block_ = block();
|
||||
|
||||
uiLayout &prev_layout = current_layout();
|
||||
|
||||
const int width = uiLayoutGetWidth(&prev_layout);
|
||||
if (width < int(40 * UI_SCALE_FAC)) {
|
||||
return;
|
||||
}
|
||||
|
||||
blender::ui::EmbossType previous_emboss = UI_block_emboss_get(&block_);
|
||||
|
||||
uiLayout *overlap = &prev_layout.overlap();
|
||||
|
||||
Reference in New Issue
Block a user