Fix for T81400: Block Width Corrections
Scale widths of popovers and dialogs with Text Style font point changes. Differential Revision: https://developer.blender.org/D9132 Reviewed by Hans Goudey
This commit is contained in:
parent
78a5895c96
commit
bdad412fa7
Notes:
blender-bot
2023-02-14 03:44:41 +01:00
Referenced by issue #81400, Width space any menu without ... (3 dots)
|
@ -247,6 +247,8 @@ uiPopupBlockHandle *ui_popover_panel_create(
|
|||
bContext *C, ARegion *butregion, uiBut *but, uiMenuCreateFunc menu_func, void *arg)
|
||||
{
|
||||
wmWindow *window = CTX_wm_window(C);
|
||||
const uiStyle *style = UI_style_get_dpi();
|
||||
const PanelType *panel_type = (PanelType *)arg;
|
||||
|
||||
/* Create popover, buttons are created from callback. */
|
||||
uiPopover *pup = MEM_callocN(sizeof(uiPopover), __func__);
|
||||
|
@ -254,8 +256,12 @@ uiPopupBlockHandle *ui_popover_panel_create(
|
|||
|
||||
/* FIXME: maybe one day we want non panel popovers? */
|
||||
{
|
||||
const int ui_units_x = ((PanelType *)arg)->ui_units_x;
|
||||
pup->ui_size_x = U.widget_unit * (ui_units_x ? ui_units_x : UI_POPOVER_WIDTH_UNITS);
|
||||
const int ui_units_x = (panel_type->ui_units_x == 0) ? UI_POPOVER_WIDTH_UNITS :
|
||||
panel_type->ui_units_x;
|
||||
/* Scale width by changes to Text Style point size. */
|
||||
const int text_points_max = MAX2(style->widget.points, style->widgetlabel.points);
|
||||
pup->ui_size_x = ui_units_x * U.widget_unit *
|
||||
(text_points_max / (float)UI_DEFAULT_TEXT_POINTS);
|
||||
}
|
||||
|
||||
pup->menu_func = menu_func;
|
||||
|
|
|
@ -2949,6 +2949,9 @@ static uiBlock *block_create_autorun_warning(struct bContext *C,
|
|||
{
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
const uiStyle *style = UI_style_get_dpi();
|
||||
const int text_points_max = MAX2(style->widget.points, style->widgetlabel.points);
|
||||
const int dialog_width = text_points_max * 44 * U.dpi_fac;
|
||||
|
||||
uiBlock *block = UI_block_begin(C, region, "autorun_warning_popup", UI_EMBOSS);
|
||||
|
||||
UI_block_flag_enable(
|
||||
|
@ -2956,15 +2959,8 @@ static uiBlock *block_create_autorun_warning(struct bContext *C,
|
|||
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
|
||||
UI_block_emboss_set(block, UI_EMBOSS);
|
||||
|
||||
uiLayout *layout = UI_block_layout(block,
|
||||
UI_LAYOUT_VERTICAL,
|
||||
UI_LAYOUT_PANEL,
|
||||
10,
|
||||
2,
|
||||
U.widget_unit * 24,
|
||||
U.widget_unit * 6,
|
||||
0,
|
||||
style);
|
||||
uiLayout *layout = UI_block_layout(
|
||||
block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 10, 2, dialog_width, 0, 0, style);
|
||||
|
||||
/* Text and some vertical space */
|
||||
uiLayout *col = uiLayoutColumn(layout, true);
|
||||
|
@ -3190,8 +3186,9 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C,
|
|||
wmGenericCallback *post_action = (wmGenericCallback *)arg1;
|
||||
Main *bmain = CTX_data_main(C);
|
||||
const uiStyle *style = UI_style_get_dpi();
|
||||
const int dialog_width = U.widget_unit * 22;
|
||||
const short icon_size = 64 * U.dpi_fac;
|
||||
const int text_points_max = MAX2(style->widget.points, style->widgetlabel.points);
|
||||
const int dialog_width = icon_size + (text_points_max * 34 * U.dpi_fac);
|
||||
|
||||
/* Calculate icon column factor. */
|
||||
const float split_factor = (float)icon_size / (float)(dialog_width - style->columnspace);
|
||||
|
|
|
@ -204,7 +204,9 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *region, void *UNUSE
|
|||
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_KEEP_OPEN | UI_BLOCK_NO_WIN_CLIP);
|
||||
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
|
||||
|
||||
int splash_width = 500.0f * U.dpi_fac;
|
||||
const int text_points_max = MAX2(style->widget.points, style->widgetlabel.points);
|
||||
int splash_width = text_points_max * 45 * U.dpi_fac;
|
||||
CLAMP_MAX(splash_width, CTX_wm_window(C)->sizex * 0.7f);
|
||||
int splash_height;
|
||||
|
||||
/* Would be nice to support caching this, so it only has to be re-read (and likely resized) on
|
||||
|
@ -261,8 +263,9 @@ void WM_OT_splash(wmOperatorType *ot)
|
|||
static uiBlock *wm_block_create_about(bContext *C, ARegion *region, void *UNUSED(arg))
|
||||
{
|
||||
const uiStyle *style = UI_style_get_dpi();
|
||||
const int dialog_width = U.widget_unit * 24;
|
||||
const short logo_size = 128 * U.dpi_fac;
|
||||
const int text_points_max = MAX2(style->widget.points, style->widgetlabel.points);
|
||||
const int dialog_width = logo_size + (text_points_max * 32 * U.dpi_fac);
|
||||
|
||||
/* Calculate icon column factor. */
|
||||
const float split_factor = (float)logo_size / (float)(dialog_width - style->columnspace);
|
||||
|
|
Loading…
Reference in New Issue