diff --git a/release/datafiles/userdef/userdef_default.c b/release/datafiles/userdef/userdef_default.c index ce6f0b0a072..d62f95d83f6 100644 --- a/release/datafiles/userdef/userdef_default.c +++ b/release/datafiles/userdef/userdef_default.c @@ -66,8 +66,8 @@ const UserDef U_default = { /** Default so DPI is detected automatically. */ .dpi = 0, - .dpi_fac = 0.0, - .inv_dpi_fac = 0.0, /* run-time. */ + .scale_factor = 0.0, + .inv_scale_factor = 0.0, /* run-time. */ .pixelsize = 1, .virtual_pixel = 0, diff --git a/source/blender/blenfont/intern/blf_default.c b/source/blender/blenfont/intern/blf_default.c index 738683284e3..58b4f3c8906 100644 --- a/source/blender/blenfont/intern/blf_default.c +++ b/source/blender/blenfont/intern/blf_default.c @@ -45,7 +45,7 @@ int BLF_set_default(void) { ASSERT_DEFAULT_SET; - BLF_size(global_font_default, global_font_size * U.dpi_fac); + BLF_size(global_font_default, global_font_size * UI_SCALE_FAC); return global_font_default; } @@ -53,7 +53,7 @@ int BLF_set_default(void) void BLF_draw_default(float x, float y, float z, const char *str, const size_t str_len) { ASSERT_DEFAULT_SET; - BLF_size(global_font_default, global_font_size * U.dpi_fac); + BLF_size(global_font_default, global_font_size * UI_SCALE_FAC); BLF_position(global_font_default, x, y, z); BLF_draw(global_font_default, str, str_len); } diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c index a4bd789438d..1d31c5fdeed 100644 --- a/source/blender/draw/engines/eevee/eevee_lookdev.c +++ b/source/blender/draw/engines/eevee/eevee_lookdev.c @@ -107,14 +107,14 @@ void EEVEE_lookdev_init(EEVEE_Data *vedata) /* Make the viewport width scale the lookdev spheres a bit. * Scale between 1000px and 2000px. */ const float viewport_scale = clamp_f( - BLI_rcti_size_x(rect) / (2000.0f * U.dpi_fac), 0.5f, 1.0f); - const int sphere_size = U.lookdev_sphere_size * U.dpi_fac * viewport_scale; + BLI_rcti_size_x(rect) / (2000.0f * UI_SCALE_FAC), 0.5f, 1.0f); + const int sphere_size = U.lookdev_sphere_size * UI_SCALE_FAC * viewport_scale; if (sphere_size != effects->sphere_size || rect->xmax != effects->anchor[0] || rect->ymin != effects->anchor[1]) { /* Make sphere resolution adaptive to viewport_scale, DPI and #U.lookdev_sphere_size. */ float res_scale = clamp_f( - (U.lookdev_sphere_size / 400.0f) * viewport_scale * U.dpi_fac, 0.1f, 1.0f); + (U.lookdev_sphere_size / 400.0f) * viewport_scale * UI_SCALE_FAC, 0.1f, 1.0f); if (res_scale > 0.7f) { effects->sphere_lod = DRW_LOD_HIGH; diff --git a/source/blender/draw/engines/overlay/overlay_edit_uv.cc b/source/blender/draw/engines/overlay/overlay_edit_uv.cc index 5a63f97d689..d712b163c9b 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_uv.cc +++ b/source/blender/draw/engines/overlay/overlay_edit_uv.cc @@ -158,7 +158,7 @@ void OVERLAY_edit_uv_init(OVERLAY_Data *vedata) pd->edit_uv.uv_opacity = sima->uv_opacity; pd->edit_uv.do_tiled_image_overlay = show_overlays && is_image_type && is_tiled_image; pd->edit_uv.do_tiled_image_border_overlay = is_image_type && is_tiled_image; - pd->edit_uv.dash_length = 4.0f * UI_DPI_FAC; + pd->edit_uv.dash_length = 4.0f * UI_SCALE_FAC; pd->edit_uv.line_style = edit_uv_line_style_from_space_image(sima); pd->edit_uv.do_smooth_wire = ((U.gpu_flag & USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE) != 0); pd->edit_uv.do_stencil_overlay = show_overlays && do_stencil_overlay; @@ -237,7 +237,7 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata) GPUShader *sh = OVERLAY_shader_edit_uv_verts_get(); pd->edit_uv_verts_grp = DRW_shgroup_create(sh, psl->edit_uv_verts_ps); - const float point_size = UI_GetThemeValuef(TH_VERTEX_SIZE) * U.dpi_fac; + const float point_size = UI_GetThemeValuef(TH_VERTEX_SIZE) * UI_SCALE_FAC; DRW_shgroup_uniform_block(pd->edit_uv_verts_grp, "globalsBlock", G_draw.block_ubo); DRW_shgroup_uniform_float_copy( @@ -261,7 +261,7 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata) /* uv face dots */ if (pd->edit_uv.do_face_dots) { - const float point_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) * U.dpi_fac; + const float point_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) * UI_SCALE_FAC; GPUShader *sh = OVERLAY_shader_edit_uv_face_dots_get(); pd->edit_uv_face_dots_grp = DRW_shgroup_create(sh, psl->edit_uv_verts_ps); DRW_shgroup_uniform_block(pd->edit_uv_face_dots_grp, "globalsBlock", G_draw.block_ubo); diff --git a/source/blender/draw/intern/draw_manager_text.cc b/source/blender/draw/intern/draw_manager_text.cc index 6ebcf72db3a..31215ec0090 100644 --- a/source/blender/draw/intern/draw_manager_text.cc +++ b/source/blender/draw/intern/draw_manager_text.cc @@ -127,7 +127,7 @@ static void drw_text_cache_draw_ex(DRWTextStore *dt, ARegion *region) const uiStyle *style = UI_style_get(); - BLF_size(font_id, style->widget.points * U.dpi_fac); + BLF_size(font_id, style->widget.points * UI_SCALE_FAC); BLI_memiter_iter_init(dt->cache_strings, &it); while ((vos = static_cast(BLI_memiter_iter_step(&it)))) { @@ -249,7 +249,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, if ((v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_INDICES) && (em->selectmode & SCE_SELECT_EDGE)) { edge_tex_count += 1; } - const short edge_tex_sep = short((edge_tex_count - 1) * 5.0f * U.dpi_fac); + const short edge_tex_sep = short((edge_tex_count - 1) * 5.0f * UI_SCALE_FAC); /* Make the precision of the display value proportionate to the grid-size. */ diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 48f7b67edba..ed73e9d0eae 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -5262,7 +5262,7 @@ void ANIM_channel_draw_widgets(const bContext *C, * a callback available (e.g. broken F-Curve rename) */ if (acf->name_prop(ale, &ptr, &prop)) { - const short margin_x = 3 * round_fl_to_int(UI_DPI_FAC); + const short margin_x = 3 * round_fl_to_int(UI_SCALE_FAC); const short width = ac->region->winx - offset - (margin_x * 2); uiBut *but; diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index ccefb4e75ef..e54044700e7 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -177,8 +177,8 @@ void ANIM_draw_action_framerange( immUniform4f("color1", color[0], color[1], color[2], color[3]); immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f); - immUniform1i("size1", 2 * U.dpi_fac); - immUniform1i("size2", 4 * U.dpi_fac); + immUniform1i("size1", 2 * UI_SCALE_FAC); + immUniform1i("size2", 4 * UI_SCALE_FAC); if (sfra < efra) { immRectf(pos, v2d->cur.xmin, ymin, sfra, ymax); diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 694eb1f7035..74ed7e22fd4 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -251,7 +251,7 @@ static bool region_position_is_over_marker(View2D *v2d, ListBase *markers, float float pixel_distance = UI_view2d_scale_get_x(v2d) * fabsf(nearest_marker->frame - frame_at_position); - return pixel_distance <= UI_DPI_ICON_SIZE; + return pixel_distance <= UI_ICON_SIZE; } /* --------------------------------- */ @@ -419,7 +419,7 @@ static void draw_marker_name(const uchar *text_color, } #endif - const int icon_half_width = UI_DPI_ICON_SIZE * 0.6; + const int icon_half_width = UI_ICON_SIZE * 0.6; const struct uiFontStyleDraw_Params fs_params = {.align = UI_STYLE_TEXT_LEFT, .word_wrap = 0}; const struct rcti rect = { .xmin = marker_x + icon_half_width, @@ -440,7 +440,7 @@ static void draw_marker_line(const uchar *color, int xpos, int ymin, int ymax) float viewport_size[4]; GPU_viewport_size_get_f(viewport_size); - immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); + immUniform2f("viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC); immUniformColor4ubv(color); immUniform1i("colors_len", 0); /* "simple" mode */ @@ -482,17 +482,17 @@ static void draw_marker(const uiFontStyle *fstyle, GPU_blend(GPU_BLEND_ALPHA); - draw_marker_line(line_color, xpos, UI_DPI_FAC * 20, region_height); + draw_marker_line(line_color, xpos, UI_SCALE_FAC * 20, region_height); int icon_id = marker_get_icon_id(marker, flag); - UI_icon_draw(xpos - 0.55f * UI_DPI_ICON_SIZE, UI_DPI_FAC * 18, icon_id); + UI_icon_draw(xpos - 0.55f * UI_ICON_SIZE, UI_SCALE_FAC * 18, icon_id); GPU_blend(GPU_BLEND_NONE); - float name_y = UI_DPI_FAC * 18; + float name_y = UI_SCALE_FAC * 18; /* Give an offset to the marker that is elevated. */ if (is_elevated) { - name_y += UI_DPI_FAC * 10; + name_y += UI_SCALE_FAC * 10; } draw_marker_name(text_color, fstyle, marker, xpos, xmax, name_y); } @@ -537,7 +537,7 @@ static void get_marker_region_rect(View2D *v2d, rctf *rect) static void get_marker_clip_frame_range(View2D *v2d, float xscale, int r_range[2]) { - float font_width_max = (10 * UI_DPI_FAC) / xscale; + float font_width_max = (10 * UI_SCALE_FAC) / xscale; r_range[0] = v2d->cur.xmin - sizeof(((TimeMarker *)NULL)->name) * font_width_max; r_range[1] = v2d->cur.xmax + font_width_max; } diff --git a/source/blender/editors/animation/time_scrub_ui.c b/source/blender/editors/animation/time_scrub_ui.c index ebeac6552cd..532002c2355 100644 --- a/source/blender/editors/animation/time_scrub_ui.c +++ b/source/blender/editors/animation/time_scrub_ui.c @@ -42,7 +42,7 @@ void ED_time_scrub_region_rect_get(const ARegion *region, rcti *rect) static int get_centered_text_y(const rcti *rect) { - return BLI_rcti_cent_y(rect) - UI_DPI_FAC * 4; + return BLI_rcti_cent_y(rect) - UI_SCALE_FAC * 4; } static void draw_background(const rcti *rect) @@ -84,9 +84,9 @@ static void draw_current_frame(const Scene *scene, char frame_str[64]; get_current_time_str(scene, display_seconds, current_frame, sizeof(frame_str), frame_str); float text_width = UI_fontstyle_string_width(fstyle, frame_str); - float box_width = MAX2(text_width + 8 * UI_DPI_FAC, 24 * UI_DPI_FAC); - float box_padding = 3 * UI_DPI_FAC; - const int line_outline = max_ii(1, round_fl_to_int(1 * UI_DPI_FAC)); + float box_width = MAX2(text_width + 8 * UI_SCALE_FAC, 24 * UI_SCALE_FAC); + float box_padding = 3 * UI_SCALE_FAC; + const int line_outline = max_ii(1, round_fl_to_int(1 * UI_SCALE_FAC)); float bg_color[4]; UI_GetThemeColorShade4fv(TH_CFRAME, -5, bg_color); @@ -134,7 +134,7 @@ static void draw_current_frame(const Scene *scene, 1.0f, outline_color, U.pixelsize, - 4 * UI_DPI_FAC); + 4 * UI_SCALE_FAC); uchar text_color[4]; UI_GetThemeColor4ubv(TH_HEADER_TEXT_HI, text_color); @@ -176,7 +176,7 @@ void ED_time_scrub_draw(const ARegion *region, draw_background(&scrub_region_rect); rcti numbers_rect = scrub_region_rect; - numbers_rect.ymin = get_centered_text_y(&scrub_region_rect) - 4 * UI_DPI_FAC; + numbers_rect.ymin = get_centered_text_y(&scrub_region_rect) - 4 * UI_SCALE_FAC; if (discrete_frames) { UI_view2d_draw_scale_x__discrete_frames_or_seconds( region, v2d, &numbers_rect, scene, display_seconds, TH_TEXT); @@ -217,8 +217,8 @@ void ED_time_scrub_channel_search_draw(const bContext *C, ARegion *region, bDope RNA_pointer_create(&CTX_wm_screen(C)->id, &RNA_DopeSheet, dopesheet, &ptr); const uiStyle *style = UI_style_get_dpi(); - const float padding_x = 2 * UI_DPI_FAC; - const float padding_y = UI_DPI_FAC; + const float padding_x = 2 * UI_SCALE_FAC; + const float padding_y = UI_SCALE_FAC; uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS); uiLayout *layout = UI_block_layout(block, diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index 66fb3cb06a3..b4fa97a0e0a 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -665,7 +665,7 @@ static void curve_draw_exec_precalc(wmOperator *op) selem_prev = selem; } scale_px = ((len_3d > 0.0f) && (len_2d > 0.0f)) ? (len_3d / len_2d) : 0.0f; - float error_threshold = (cps->error_threshold * U.dpi_fac) * scale_px; + float error_threshold = (cps->error_threshold * UI_SCALE_FAC) * scale_px; RNA_property_float_set(op->ptr, prop, error_threshold); } @@ -684,7 +684,7 @@ static void curve_draw_exec_precalc(wmOperator *op) } if (len_squared_v2v2(selem_first->mval, selem_last->mval) <= - square_f(STROKE_CYCLIC_DIST_PX * U.dpi_fac)) { + square_f(STROKE_CYCLIC_DIST_PX * UI_SCALE_FAC)) { use_cyclic = true; } } diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c index cde702294d0..ca31d8e43ad 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c @@ -126,7 +126,7 @@ static void arrow_draw_geom(const ArrowGizmo3D *arrow, if (draw_options & ED_GIZMO_ARROW_DRAW_FLAG_STEM) { const float stem_width = arrow->gizmo.line_width * U.pixelsize + - (select ? ARROW_SELECT_THRESHOLD_PX * U.dpi_fac : 0); + (select ? ARROW_SELECT_THRESHOLD_PX * UI_SCALE_FAC : 0); immUniform1f("lineWidth", stem_width); wm_gizmo_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GPU_PRIM_LINE_STRIP); } diff --git a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c index dca19dcf516..731b1b07193 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c @@ -251,14 +251,14 @@ static void button2d_draw_intern(const bContext *C, if (is_3d) { const float fac = 2.0f; GPU_matrix_translate_2f(-(fac / 2), -(fac / 2)); - GPU_matrix_scale_2f(fac / (ICON_DEFAULT_WIDTH * UI_DPI_FAC), - fac / (ICON_DEFAULT_HEIGHT * UI_DPI_FAC)); + GPU_matrix_scale_2f(fac / (ICON_DEFAULT_WIDTH * UI_SCALE_FAC), + fac / (ICON_DEFAULT_HEIGHT * UI_SCALE_FAC)); pos[0] = 1.0f; pos[1] = 1.0f; } else { - pos[0] = gz->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * UI_DPI_FAC; - pos[1] = gz->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * UI_DPI_FAC; + pos[0] = gz->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * UI_SCALE_FAC; + pos[1] = gz->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * UI_SCALE_FAC; GPU_matrix_pop(); need_to_pop = false; } @@ -327,7 +327,7 @@ static int gizmo_button2d_cursor_get(wmGizmo *gz) static bool gizmo_button2d_bounds(bContext *C, wmGizmo *gz, rcti *r_bounding_box) { ScrArea *area = CTX_wm_area(C); - float rad = CIRCLE_RESOLUTION_3D * U.dpi_fac / 2.0f; + float rad = CIRCLE_RESOLUTION_3D * UI_SCALE_FAC / 2.0f; const float *co = NULL; float matrix_final[4][4]; float co_proj[3]; diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index f5c1a397a8c..0ad39f8c05f 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -319,12 +319,6 @@ enum { UI_BUT_CHECKBOX_INVERT = 1 << 25, }; -/* scale fixed button widths by this to account for DPI */ - -#define UI_DPI_FAC (U.dpi_fac) -/* 16 to copy ICON_DEFAULT_HEIGHT */ -#define UI_DPI_ICON_SIZE ((float)16 * UI_DPI_FAC) - /** * Button types, bits stored in 1 value... and a short even! * - bits 0-4: #uiBut.bitnr (0-31) diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index f0bf04ed408..673ed93e1cd 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -60,11 +60,11 @@ enum eView2D_CommonViewTypes { #define V2D_SCROLL_MIN_ALPHA (0.4f) /* Minimum size needs to include outline which varies with line width. */ -#define V2D_SCROLL_MIN_WIDTH ((5.0f * U.dpi_fac) + (2.0f * U.pixelsize)) +#define V2D_SCROLL_MIN_WIDTH ((5.0f * UI_SCALE_FAC) + (2.0f * U.pixelsize)) /* When to start showing the full-width scroller. */ -#define V2D_SCROLL_HIDE_WIDTH (AREAMINX * U.dpi_fac) -#define V2D_SCROLL_HIDE_HEIGHT (HEADERY * U.dpi_fac) +#define V2D_SCROLL_HIDE_WIDTH (AREAMINX * UI_SCALE_FAC) +#define V2D_SCROLL_HIDE_HEIGHT (HEADERY * UI_SCALE_FAC) /** Scroll bars with 'handles' used for scale (zoom). */ #define V2D_SCROLL_HANDLE_HEIGHT (0.6f * U.widget_unit) @@ -74,7 +74,7 @@ enum eView2D_CommonViewTypes { #define V2D_SCROLL_HANDLE_SIZE_HOTSPOT (0.6f * U.widget_unit) /** Don't allow scroll thumb to show below this size (so it's never too small to click on). */ -#define V2D_SCROLL_THUMB_SIZE_MIN (30.0 * UI_DPI_FAC) +#define V2D_SCROLL_THUMB_SIZE_MIN (30.0 * UI_SCALE_FAC) /** \} */ @@ -490,8 +490,8 @@ void UI_view2d_smooth_view(const struct bContext *C, const struct rctf *cur, int smooth_viewtx); -#define UI_MARKER_MARGIN_Y (42 * UI_DPI_FAC) -#define UI_TIME_SCRUB_MARGIN_Y (23 * UI_DPI_FAC) +#define UI_MARKER_MARGIN_Y (42 * UI_SCALE_FAC) +#define UI_TIME_SCRUB_MARGIN_Y (23 * UI_SCALE_FAC) /** \} */ diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc index 94eeab27159..6f593c74fb9 100644 --- a/source/blender/editors/interface/interface.cc +++ b/source/blender/editors/interface/interface.cc @@ -280,7 +280,7 @@ static void ui_update_flexible_spacing(const ARegion *region, uiBlock *block) rcti rect; ui_but_to_pixelrect(&rect, region, block, static_cast(block->buttons.last)); const float buttons_width = float(rect.xmax) + UI_HEADER_OFFSET; - const float region_width = float(region->sizex) * U.dpi_fac; + const float region_width = float(region->sizex) * UI_SCALE_FAC; if (region_width <= buttons_width) { return; @@ -469,7 +469,7 @@ void ui_block_bounds_calc(uiBlock *block) /* hardcoded exception... but that one is annoying with larger safety */ uiBut *bt = static_cast(block->buttons.first); - const int xof = ((bt && STRPREFIX(bt->str, "ERROR")) ? 10 : 40) * U.dpi_fac; + const int xof = ((bt && STRPREFIX(bt->str, "ERROR")) ? 10 : 40) * UI_SCALE_FAC; block->safety.xmin = block->rect.xmin - xof; block->safety.ymin = block->rect.ymin - xof; @@ -4993,7 +4993,7 @@ int UI_preview_tile_size_x(void) int UI_preview_tile_size_y(void) { const uiStyle *style = UI_style_get(); - const float font_height = style->widget.points * UI_DPI_FAC; + const float font_height = style->widget.points * UI_SCALE_FAC; const float pad = PREVIEW_TILE_PAD; return round_fl_to_int(UI_preview_tile_size_y_no_label() + font_height + diff --git a/source/blender/editors/interface/interface_context_menu.cc b/source/blender/editors/interface/interface_context_menu.cc index 0d697cb268f..eb944b7f30e 100644 --- a/source/blender/editors/interface/interface_context_menu.cc +++ b/source/blender/editors/interface/interface_context_menu.cc @@ -180,8 +180,8 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *region, void *arg) uiItemL(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Change Shortcut"), ICON_HAND); uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE); - const int bounds_offset[2] = {int(-100 * U.dpi_fac), int(36 * U.dpi_fac)}; - UI_block_bounds_set_popup(block, 6 * U.dpi_fac, bounds_offset); + const int bounds_offset[2] = {int(-100 * UI_SCALE_FAC), int(36 * UI_SCALE_FAC)}; + UI_block_bounds_set_popup(block, 6 * UI_SCALE_FAC, bounds_offset); shortcut_free_operator_property(prop); @@ -241,8 +241,8 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *region, void *arg) uiItemL(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Assign Shortcut"), ICON_HAND); uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE); - const int bounds_offset[2] = {int(-100 * U.dpi_fac), int(36 * U.dpi_fac)}; - UI_block_bounds_set_popup(block, 6 * U.dpi_fac, bounds_offset); + const int bounds_offset[2] = {int(-100 * UI_SCALE_FAC), int(36 * UI_SCALE_FAC)}; + UI_block_bounds_set_popup(block, 6 * UI_SCALE_FAC, bounds_offset); #ifdef USE_KEYMAP_ADD_HACK g_kmi_id_hack = kmi_id; diff --git a/source/blender/editors/interface/interface_draw.cc b/source/blender/editors/interface/interface_draw.cc index 79cfb2c50c9..74761daa430 100644 --- a/source/blender/editors/interface/interface_draw.cc +++ b/source/blender/editors/interface/interface_draw.cc @@ -1098,7 +1098,8 @@ static void ui_draw_colorband_handle(uint shdr_pos, float viewport_size[4]; GPU_viewport_size_get_f(viewport_size); - immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); + immUniform2f( + "viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC); immUniform1i("colors_len", 2); /* "advanced" mode */ immUniform4f("color", 0.8f, 0.8f, 0.8f, 1.0f); @@ -1672,7 +1673,7 @@ void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol, } cmp = cuma->curve; - GPU_point_size(max_ff(1.0f, min_ff(UI_DPI_FAC / but->block->aspect * 4.0f, 4.0f))); + GPU_point_size(max_ff(1.0f, min_ff(UI_SCALE_FAC / but->block->aspect * 4.0f, 4.0f))); immBegin(GPU_PRIM_POINTS, cuma->totpoint); for (int a = 0; a < cuma->totpoint; a++) { const float fx = rect->xmin + zoomx * (cmp[a].x - offsx); @@ -1931,7 +1932,7 @@ void ui_draw_but_CURVEPROFILE(ARegion *region, GPU_line_smooth(false); if (path_len > 0) { GPU_blend(GPU_BLEND_NONE); - GPU_point_size(max_ff(3.0f, min_ff(UI_DPI_FAC / but->block->aspect * 5.0f, 5.0f))); + GPU_point_size(max_ff(3.0f, min_ff(UI_SCALE_FAC / but->block->aspect * 5.0f, 5.0f))); immBegin(GPU_PRIM_POINTS, path_len); for (int i = 0; i < path_len; i++) { fx = rect->xmin + zoomx * (pts[i].x - offsx); @@ -1946,7 +1947,7 @@ void ui_draw_but_CURVEPROFILE(ARegion *region, if (selected_free_points > 0) { GPU_line_smooth(false); GPU_blend(GPU_BLEND_NONE); - GPU_point_size(max_ff(2.0f, min_ff(UI_DPI_FAC / but->block->aspect * 4.0f, 4.0f))); + GPU_point_size(max_ff(2.0f, min_ff(UI_SCALE_FAC / but->block->aspect * 4.0f, 4.0f))); immBegin(GPU_PRIM_POINTS, selected_free_points * 2); for (int i = 0; i < path_len; i++) { if (point_draw_handles(&pts[i])) { @@ -1968,7 +1969,7 @@ void ui_draw_but_CURVEPROFILE(ARegion *region, pts = profile->segments; const int segments_len = uint(profile->segments_len); if (segments_len > 0 && pts) { - GPU_point_size(max_ff(2.0f, min_ff(UI_DPI_FAC / but->block->aspect * 3.0f, 3.0f))); + GPU_point_size(max_ff(2.0f, min_ff(UI_SCALE_FAC / but->block->aspect * 3.0f, 3.0f))); immBegin(GPU_PRIM_POINTS, segments_len); for (int i = 0; i < segments_len; i++) { fx = rect->xmin + zoomx * (pts[i].x - offsx); diff --git a/source/blender/editors/interface/interface_handlers.cc b/source/blender/editors/interface/interface_handlers.cc index 19b711f9266..05ccda5649c 100644 --- a/source/blender/editors/interface/interface_handlers.cc +++ b/source/blender/editors/interface/interface_handlers.cc @@ -3050,7 +3050,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) { if (but->flag & UI_HAS_ICON) { - startx += UI_DPI_ICON_SIZE / aspect; + startx += UI_ICON_SIZE / aspect; } } startx += (UI_TEXT_MARGIN_X * U.widget_unit - U.pixelsize) / aspect; @@ -4048,7 +4048,7 @@ static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data) const double value_step = is_float ? double(number_but->step_size * UI_PRECISION_FLOAT_SCALE) : int(number_but->step_size); - const float drag_map_softrange_max = UI_DRAG_MAP_SOFT_RANGE_PIXEL_MAX * UI_DPI_FAC; + const float drag_map_softrange_max = UI_DRAG_MAP_SOFT_RANGE_PIXEL_MAX * UI_SCALE_FAC; const float softrange_max = min_ff( softrange, 2 * (is_float ? min_ff(value_step, value_step_float_min) * @@ -5156,7 +5156,7 @@ static bool ui_numedit_but_NUM(uiButNumber *but, if (is_float == false) { /* at minimum, moving cursor 2 pixels should change an int button. */ - CLAMP_MIN(non_linear_scale, 0.5f * UI_DPI_FAC); + CLAMP_MIN(non_linear_scale, 0.5f * UI_SCALE_FAC); } data->dragf += (float(mx - data->draglastx) / deler) * non_linear_scale; @@ -7027,7 +7027,7 @@ static int ui_do_but_COLORBAND( else { CBData *cbd; /* ignore zoom-level for mindist */ - int mindist = (50 * UI_DPI_FAC) * block->aspect; + int mindist = (50 * UI_SCALE_FAC) * block->aspect; int xco; data->dragstartx = mx; data->dragstarty = my; @@ -7215,7 +7215,7 @@ static int ui_do_but_CURVE( CurveMapping *cumap = (CurveMapping *)but->poin; CurveMap *cuma = cumap->cm + cumap->cur; const float m_xy[2] = {float(mx), float(my)}; - float dist_min_sq = square_f(U.dpi_fac * 14.0f); /* 14 pixels radius */ + float dist_min_sq = square_f(UI_SCALE_FAC * 14.0f); /* 14 pixels radius */ int sel = -1; if (event->modifier & KM_CTRL) { @@ -7249,7 +7249,7 @@ static int ui_do_but_CURVE( BLI_rctf_transform_pt_v(&but->rect, &cumap->curr, f_xy, &cmp[0].x); /* with 160px height 8px should translate to the old 0.05 coefficient at no zoom */ - dist_min_sq = square_f(U.dpi_fac * 8.0f); + dist_min_sq = square_f(UI_SCALE_FAC * 8.0f); /* loop through the curve segment table and find what's near the mouse. */ for (int i = 1; i <= CM_TABLE; i++) { @@ -7383,7 +7383,7 @@ static bool ui_numedit_but_CURVEPROFILE(uiBlock *block, if (snap) { const float d[2] = {float(mx - data->dragstartx), float(data->dragstarty)}; - if (len_squared_v2(d) < (9.0f * U.dpi_fac)) { + if (len_squared_v2(d) < (9.0f * UI_SCALE_FAC)) { snap = false; } } @@ -7529,7 +7529,8 @@ static int ui_do_but_CURVEPROFILE( /* Check for selecting of a point by finding closest point in radius. */ CurveProfilePoint *pts = profile->path; - float dist_min_sq = square_f(U.dpi_fac * 14.0f); /* 14 pixels radius for selecting points. */ + float dist_min_sq = square_f(UI_SCALE_FAC * + 14.0f); /* 14 pixels radius for selecting points. */ int i_selected = -1; short selection_type = 0; /* For handle selection. */ for (int i = 0; i < profile->path_len; i++) { @@ -7571,7 +7572,7 @@ static int ui_do_but_CURVEPROFILE( CurveProfilePoint *table = profile->table; BLI_rctf_transform_pt_v(&but->rect, &profile->view_rect, f_xy, &table[0].x); - dist_min_sq = square_f(U.dpi_fac * 8.0f); /* 8 pixel radius from each table point. */ + dist_min_sq = square_f(UI_SCALE_FAC * 8.0f); /* 8 pixel radius from each table point. */ /* Loop through the path's high resolution table and find what's near the click. */ for (int i = 1; i <= BKE_curveprofile_table_size(profile); i++) { @@ -10150,7 +10151,7 @@ float ui_block_calc_pie_segment(uiBlock *block, const float event_xy[2]) const float len = normalize_v2_v2(block->pie_data.pie_dir, seg2); - if (len < U.pie_menu_threshold * U.dpi_fac) { + if (len < U.pie_menu_threshold * UI_SCALE_FAC) { block->pie_data.flags |= UI_PIE_INVALID_DIR; } else { @@ -10960,7 +10961,7 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle if (!(block->pie_data.flags & UI_PIE_ANIMATION_FINISHED)) { const double final_time = 0.01 * U.pie_animation_timeout; float fac = duration / final_time; - const float pie_radius = U.pie_menu_radius * UI_DPI_FAC; + const float pie_radius = U.pie_menu_radius * UI_SCALE_FAC; if (fac > 1.0f) { fac = 1.0f; @@ -11035,7 +11036,7 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle uiBut *but = ui_region_find_active_but(menu->region); if (but && (U.pie_menu_confirm > 0) && - (dist >= U.dpi_fac * (U.pie_menu_threshold + U.pie_menu_confirm))) { + (dist >= UI_SCALE_FAC * (U.pie_menu_threshold + U.pie_menu_confirm))) { return ui_but_pie_menu_apply(C, menu, but, true); } @@ -11060,7 +11061,7 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle /* here instead, we use the offset location to account for the initial * direction timeout */ if ((U.pie_menu_confirm > 0) && - (dist >= U.dpi_fac * (U.pie_menu_threshold + U.pie_menu_confirm))) { + (dist >= UI_SCALE_FAC * (U.pie_menu_threshold + U.pie_menu_confirm))) { block->pie_data.flags |= UI_PIE_GESTURE_END_WAIT; copy_v2_v2(block->pie_data.last_pos, event_xy); block->pie_data.duration_gesture = duration; diff --git a/source/blender/editors/interface/interface_icons.cc b/source/blender/editors/interface/interface_icons.cc index 0e0363751fa..dd0e505576a 100644 --- a/source/blender/editors/interface/interface_icons.cc +++ b/source/blender/editors/interface/interface_icons.cc @@ -1741,7 +1741,7 @@ static void icon_draw_texture(float x, bool with_border, const IconTextOverlay *text_overlay) { - const float zoom_factor = w / UI_DPI_ICON_SIZE; + const float zoom_factor = w / UI_ICON_SIZE; float text_width = 0.0f; /* No need to show if too zoomed out, otherwise it just adds noise. */ @@ -2492,13 +2492,13 @@ int UI_icon_color_from_collection(const Collection *collection) void UI_icon_draw(float x, float y, int icon_id) { UI_icon_draw_ex( - x, y, icon_id, U.inv_dpi_fac, 1.0f, 0.0f, nullptr, false, UI_NO_ICON_OVERLAY_TEXT); + x, y, icon_id, UI_INV_SCALE_FAC, 1.0f, 0.0f, nullptr, false, UI_NO_ICON_OVERLAY_TEXT); } void UI_icon_draw_alpha(float x, float y, int icon_id, float alpha) { UI_icon_draw_ex( - x, y, icon_id, U.inv_dpi_fac, alpha, 0.0f, nullptr, false, UI_NO_ICON_OVERLAY_TEXT); + x, y, icon_id, UI_INV_SCALE_FAC, alpha, 0.0f, nullptr, false, UI_NO_ICON_OVERLAY_TEXT); } void UI_icon_draw_preview(float x, float y, int icon_id, float aspect, float alpha, int size) diff --git a/source/blender/editors/interface/interface_icons_event.cc b/source/blender/editors/interface/interface_icons_event.cc index 5d8af37c55f..68a47a8aef6 100644 --- a/source/blender/editors/interface/interface_icons_event.cc +++ b/source/blender/editors/interface/interface_icons_event.cc @@ -26,12 +26,12 @@ static void icon_draw_rect_input_text( BLF_batch_draw_flush(); const int font_id = BLF_default(); BLF_color4fv(font_id, color); - BLF_size(font_id, font_size * U.dpi_fac); + BLF_size(font_id, font_size * UI_SCALE_FAC); float width, height; BLF_width_and_height(font_id, str, BLF_DRAW_STR_DUMMY_MAX, &width, &height); const float x = trunc(rect->xmin + (((rect->xmax - rect->xmin) - width) / 2.0f)); const float y = rect->ymin + (((rect->ymax - rect->ymin) - height) / 2.0f) + - (v_offset * U.dpi_fac); + (v_offset * UI_SCALE_FAC); BLF_position(font_id, x, y, 0.0f); BLF_draw(font_id, str, BLF_DRAW_STR_DUMMY_MAX); BLF_batch_draw_flush(); diff --git a/source/blender/editors/interface/interface_intern.hh b/source/blender/editors/interface/interface_intern.hh index 331e489ce05..830cc977d49 100644 --- a/source/blender/editors/interface/interface_intern.hh +++ b/source/blender/editors/interface/interface_intern.hh @@ -50,12 +50,12 @@ struct wmTimer; #define UI_MENU_WIDTH_MIN (UI_UNIT_Y * 9) /** Some extra padding added to menus containing sub-menu icons. */ -#define UI_MENU_SUBMENU_PADDING (6 * UI_DPI_FAC) +#define UI_MENU_SUBMENU_PADDING (6 * UI_SCALE_FAC) /* menu scrolling */ -#define UI_MENU_SCROLL_ARROW (12 * UI_DPI_FAC) -#define UI_MENU_SCROLL_MOUSE (UI_MENU_SCROLL_ARROW + 2 * UI_DPI_FAC) -#define UI_MENU_SCROLL_PAD (4 * UI_DPI_FAC) +#define UI_MENU_SCROLL_ARROW (12 * UI_SCALE_FAC) +#define UI_MENU_SCROLL_MOUSE (UI_MENU_SCROLL_ARROW + 2 * UI_SCALE_FAC) +#define UI_MENU_SCROLL_PAD (4 * UI_SCALE_FAC) /** Popover width (multiplied by #U.widget_unit) */ #define UI_POPOVER_WIDTH_UNITS 10 @@ -1181,12 +1181,12 @@ void ui_draw_preview_item_stateless(const uiFontStyle *fstyle, eFontStyle_Align text_align); #define UI_TEXT_MARGIN_X 0.4f -#define UI_POPUP_MARGIN (UI_DPI_FAC * 12) +#define UI_POPUP_MARGIN (UI_SCALE_FAC * 12) /** * Margin at top of screen for popups. * Note this value must be sufficient to draw a popover arrow to avoid cropping it. */ -#define UI_POPUP_MENU_TOP (int)(10 * UI_DPI_FAC) +#define UI_POPUP_MENU_TOP (int)(10 * UI_SCALE_FAC) #define UI_PIXEL_AA_JITTER 8 extern const float ui_pixel_jitter[UI_PIXEL_AA_JITTER][2]; diff --git a/source/blender/editors/interface/interface_layout.cc b/source/blender/editors/interface/interface_layout.cc index 1a4def7bed7..1cab840f100 100644 --- a/source/blender/editors/interface/interface_layout.cc +++ b/source/blender/editors/interface/interface_layout.cc @@ -3962,7 +3962,7 @@ static void ui_litem_layout_radial(uiLayout *litem) * for radiation, see http://mattebb.com/weblog/radiation/ * also the old code at #5103. */ - const int pie_radius = U.pie_menu_radius * UI_DPI_FAC; + const int pie_radius = U.pie_menu_radius * UI_SCALE_FAC; const int x = litem->x; const int y = litem->y; @@ -4046,7 +4046,7 @@ static void ui_litem_layout_root_radial(uiLayout *litem) ui_item_size(item, &itemw, &itemh); ui_item_position( - item, x - itemw / 2, y + U.dpi_fac * (U.pie_menu_threshold + 9.0f), itemw, itemh); + item, x - itemw / 2, y + UI_SCALE_FAC * (U.pie_menu_threshold + 9.0f), itemw, itemh); } } @@ -6125,13 +6125,13 @@ const char *UI_layout_introspect(uiLayout *layout) uiLayout *uiItemsAlertBox(uiBlock *block, const int size, const eAlertIcon icon) { const uiStyle *style = UI_style_get_dpi(); - const short icon_size = 64 * U.dpi_fac; + const short icon_size = 64 * UI_SCALE_FAC; const int text_points_max = MAX2(style->widget.points, style->widgetlabel.points); - const int dialog_width = icon_size + (text_points_max * size * U.dpi_fac); + const int dialog_width = icon_size + (text_points_max * size * UI_SCALE_FAC); /* By default, the space between icon and text/buttons will be equal to the 'columnspace', * this extra padding will add some space by increasing the left column width, * making the icon placement more symmetrical, between the block edge and the text. */ - const float icon_padding = 5.0f * U.dpi_fac; + const float icon_padding = 5.0f * UI_SCALE_FAC; /* Calculate the factor of the fixed icon column depending on the block width. */ const float split_factor = (float(icon_size) + icon_padding) / float(dialog_width - style->columnspace); diff --git a/source/blender/editors/interface/interface_panel.cc b/source/blender/editors/interface/interface_panel.cc index 7a7987540b2..9c15ad6d98e 100644 --- a/source/blender/editors/interface/interface_panel.cc +++ b/source/blender/editors/interface/interface_panel.cc @@ -1099,7 +1099,7 @@ static void panel_draw_aligned_widgets(const uiStyle *style, UI_icon_draw_ex(widget_rect.xmin + size_y * 0.2f, widget_rect.ymin + size_y * 0.2f, UI_panel_is_closed(panel) ? ICON_RIGHTARROW : ICON_DOWNARROW_HLT, - aspect * U.inv_dpi_fac, + aspect * UI_INV_SCALE_FAC, 0.7f, 0.0f, title_color, @@ -1128,7 +1128,7 @@ static void panel_draw_aligned_widgets(const uiStyle *style, UI_icon_draw_ex(widget_rect.xmax - scaled_unit * 2.2f, widget_rect.ymin + 5.0f / aspect, ICON_PINNED, - aspect * U.inv_dpi_fac, + aspect * UI_INV_SCALE_FAC, 1.0f, 0.0f, title_color, @@ -1288,7 +1288,7 @@ void UI_panel_category_draw_all(ARegion *region, const char *category_id_active) const float zoom = 1.0f / aspect; const int px = U.pixelsize; const int category_tabs_width = round_fl_to_int(UI_PANEL_CATEGORY_MARGIN_WIDTH * zoom); - const float dpi_fac = UI_DPI_FAC; + const float dpi_fac = UI_SCALE_FAC; /* Padding of tabs around text. */ const int tab_v_pad_text = round_fl_to_int(TABS_PADDING_TEXT_FACTOR * dpi_fac * zoom) + 2 * px; /* Padding between tabs. */ @@ -1334,7 +1334,7 @@ void UI_panel_category_draw_all(ARegion *region, const char *category_id_active) BLF_enable(fontid, BLF_ROTATION); BLF_rotation(fontid, M_PI_2); ui_fontscale(&fstyle_points, aspect); - BLF_size(fontid, fstyle_points * U.dpi_fac); + BLF_size(fontid, fstyle_points * UI_SCALE_FAC); /* Check the region type supports categories to avoid an assert * for showing 3D view panels in the properties space. */ diff --git a/source/blender/editors/interface/interface_region_hud.cc b/source/blender/editors/interface/interface_region_hud.cc index 0aa3bcbdd8c..f0a31c9e739 100644 --- a/source/blender/editors/interface/interface_region_hud.cc +++ b/source/blender/editors/interface/interface_region_hud.cc @@ -173,8 +173,8 @@ static void hud_region_layout(const bContext *C, ARegion *region) if (region->panels.first && ((area->flag & AREA_FLAG_REGION_SIZE_UPDATE) || (region->sizey != size_y))) { - int winx_new = UI_DPI_FAC * (region->sizex + 0.5f); - int winy_new = UI_DPI_FAC * (region->sizey + 0.5f); + int winx_new = UI_SCALE_FAC * (region->sizex + 0.5f); + int winy_new = UI_SCALE_FAC * (region->sizey + 0.5f); View2D *v2d = ®ion->v2d; if (region->flag & RGN_FLAG_SIZE_CLAMP_X) { diff --git a/source/blender/editors/interface/interface_region_popup.cc b/source/blender/editors/interface/interface_region_popup.cc index 7943e7dc6fa..edc6d94c250 100644 --- a/source/blender/editors/interface/interface_region_popup.cc +++ b/source/blender/editors/interface/interface_region_popup.cc @@ -288,8 +288,8 @@ static void ui_popup_block_position(wmWindow *window, /* when you are outside parent button, safety there should be smaller */ - const int s1 = 40 * U.dpi_fac; - const int s2 = 3 * U.dpi_fac; + const int s1 = 40 * UI_SCALE_FAC; + const int s2 = 3 * UI_SCALE_FAC; /* parent button to left */ if (midx < block->rect.xmin) { diff --git a/source/blender/editors/interface/interface_region_search.cc b/source/blender/editors/interface/interface_region_search.cc index 1b63cbe4c97..ccc8586d9fe 100644 --- a/source/blender/editors/interface/interface_region_search.cc +++ b/source/blender/editors/interface/interface_region_search.cc @@ -651,7 +651,7 @@ static void ui_searchbox_region_draw_fn(const bContext *C, ARegion *region) if (icon == ICON_BLANK1) { icon = ICON_NONE; - rect.xmin -= UI_DPI_ICON_SIZE / 4; + rect.xmin -= UI_ICON_SIZE / 4; } /* The previous menu item draws the active selection. */ @@ -762,7 +762,7 @@ static void ui_searchbox_region_layout_fn(const struct bContext *C, struct ARegi /* We should make this wider if there is a path or hint on the right. */ if (ui_searchbox_item_separator(data) != UI_MENU_ITEM_SEPARATOR_NONE) { - searchbox_width += 12 * data->fstyle.points * U.dpi_fac; + searchbox_width += 12 * data->fstyle.points * UI_SCALE_FAC; } rctf rect_fl; diff --git a/source/blender/editors/interface/interface_region_tooltip.cc b/source/blender/editors/interface/interface_region_tooltip.cc index fb87d940506..1216359a345 100644 --- a/source/blender/editors/interface/interface_region_tooltip.cc +++ b/source/blender/editors/interface/interface_region_tooltip.cc @@ -253,7 +253,7 @@ static void ui_tooltip_region_draw_cb(const bContext * /*C*/, ARegion *region) UI_fontstyle_set(&fstyle_mono); /* XXX: needed because we don't have mono in 'U.uifonts'. */ - BLF_size(fstyle_mono.uifont_id, fstyle_mono.points * U.dpi_fac); + BLF_size(fstyle_mono.uifont_id, fstyle_mono.points * UI_SCALE_FAC); rgb_float_to_uchar(drawcol, tip_colors[int(field->format.color_id)]); UI_fontstyle_draw(&fstyle_mono, &bbox, field->text, UI_TIP_STR_MAX, drawcol, &fs_params); } @@ -1132,7 +1132,7 @@ static ARegion *ui_tooltip_create_with_data(bContext *C, int font_id; if (field->format.style == uiTooltipFormat::Style::Mono) { - BLF_size(blf_mono_font, data->fstyle.points * U.dpi_fac); + BLF_size(blf_mono_font, data->fstyle.points * UI_SCALE_FAC); font_id = blf_mono_font; } else { diff --git a/source/blender/editors/interface/interface_style.cc b/source/blender/editors/interface/interface_style.cc index 96eef4fdb60..38301599930 100644 --- a/source/blender/editors/interface/interface_style.cc +++ b/source/blender/editors/interface/interface_style.cc @@ -321,20 +321,20 @@ const uiStyle *UI_style_get_dpi(void) _style = *style; - _style.paneltitle.shadx = short(UI_DPI_FAC * _style.paneltitle.shadx); - _style.paneltitle.shady = short(UI_DPI_FAC * _style.paneltitle.shady); - _style.grouplabel.shadx = short(UI_DPI_FAC * _style.grouplabel.shadx); - _style.grouplabel.shady = short(UI_DPI_FAC * _style.grouplabel.shady); - _style.widgetlabel.shadx = short(UI_DPI_FAC * _style.widgetlabel.shadx); - _style.widgetlabel.shady = short(UI_DPI_FAC * _style.widgetlabel.shady); + _style.paneltitle.shadx = short(UI_SCALE_FAC * _style.paneltitle.shadx); + _style.paneltitle.shady = short(UI_SCALE_FAC * _style.paneltitle.shady); + _style.grouplabel.shadx = short(UI_SCALE_FAC * _style.grouplabel.shadx); + _style.grouplabel.shady = short(UI_SCALE_FAC * _style.grouplabel.shady); + _style.widgetlabel.shadx = short(UI_SCALE_FAC * _style.widgetlabel.shadx); + _style.widgetlabel.shady = short(UI_SCALE_FAC * _style.widgetlabel.shady); - _style.columnspace = short(UI_DPI_FAC * _style.columnspace); - _style.templatespace = short(UI_DPI_FAC * _style.templatespace); - _style.boxspace = short(UI_DPI_FAC * _style.boxspace); - _style.buttonspacex = short(UI_DPI_FAC * _style.buttonspacex); - _style.buttonspacey = short(UI_DPI_FAC * _style.buttonspacey); - _style.panelspace = short(UI_DPI_FAC * _style.panelspace); - _style.panelouter = short(UI_DPI_FAC * _style.panelouter); + _style.columnspace = short(UI_SCALE_FAC * _style.columnspace); + _style.templatespace = short(UI_SCALE_FAC * _style.templatespace); + _style.boxspace = short(UI_SCALE_FAC * _style.boxspace); + _style.buttonspacex = short(UI_SCALE_FAC * _style.buttonspacex); + _style.buttonspacey = short(UI_SCALE_FAC * _style.buttonspacey); + _style.panelspace = short(UI_SCALE_FAC * _style.panelspace); + _style.panelouter = short(UI_SCALE_FAC * _style.panelouter); return &_style; } @@ -351,7 +351,7 @@ int UI_fontstyle_string_width_with_block_aspect(const uiFontStyle *fs, { /* FIXME(@ideasman42): the final scale of the font is rounded which should be accounted for. * Failing to do so causes bad alignment when zoomed out very far in the node-editor. */ - fontstyle_set_ex(fs, U.dpi_fac / aspect); + fontstyle_set_ex(fs, UI_SCALE_FAC / aspect); return int(BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX) * aspect); } @@ -492,5 +492,5 @@ static void fontstyle_set_ex(const uiFontStyle *fs, const float dpi_fac) void UI_fontstyle_set(const uiFontStyle *fs) { - fontstyle_set_ex(fs, U.dpi_fac); + fontstyle_set_ex(fs, UI_SCALE_FAC); } diff --git a/source/blender/editors/interface/interface_templates.cc b/source/blender/editors/interface/interface_templates.cc index 089949c2c60..50a6a983fd8 100644 --- a/source/blender/editors/interface/interface_templates.cc +++ b/source/blender/editors/interface/interface_templates.cc @@ -5687,7 +5687,7 @@ void uiTemplateColorPicker(uiLayout *layout, "", WHEEL_SIZE + 6, 0, - 14 * UI_DPI_FAC, + 14 * UI_SCALE_FAC, WHEEL_SIZE, ptr, prop, @@ -5708,7 +5708,7 @@ void uiTemplateColorPicker(uiLayout *layout, 0, 4, WHEEL_SIZE, - 18 * UI_DPI_FAC, + 18 * UI_SCALE_FAC, ptr, prop, -1, @@ -5728,7 +5728,7 @@ void uiTemplateColorPicker(uiLayout *layout, 0, 4, WHEEL_SIZE, - 18 * UI_DPI_FAC, + 18 * UI_SCALE_FAC, ptr, prop, -1, @@ -5748,7 +5748,7 @@ void uiTemplateColorPicker(uiLayout *layout, 0, 4, WHEEL_SIZE, - 18 * UI_DPI_FAC, + 18 * UI_SCALE_FAC, ptr, prop, -1, @@ -5770,7 +5770,7 @@ void uiTemplateColorPicker(uiLayout *layout, "", WHEEL_SIZE + 6, 0, - 14 * UI_DPI_FAC, + 14 * UI_SCALE_FAC, WHEEL_SIZE, ptr, prop, @@ -6358,7 +6358,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) UI_fontstyle_set(&style->widgetlabel); int width = BLF_width(style->widgetlabel.uifont_id, report->message, report->len); width = min_ii(int(rti->widthfac * width), width); - width = max_ii(width, 10 * UI_DPI_FAC); + width = max_ii(width, 10 * UI_SCALE_FAC); UI_block_align_begin(block); @@ -6369,7 +6369,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) "", 0, 0, - UI_UNIT_X + (6 * UI_DPI_FAC), + UI_UNIT_X + (6 * UI_SCALE_FAC), UI_UNIT_Y, nullptr, 0.0f, @@ -6385,7 +6385,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) UI_BTYPE_ROUNDBOX, 0, "", - UI_UNIT_X + (6 * UI_DPI_FAC), + UI_UNIT_X + (6 * UI_SCALE_FAC), 0, UI_UNIT_X + width, UI_UNIT_Y, @@ -6409,7 +6409,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) "SCREEN_OT_info_log_show", WM_OP_INVOKE_REGION_WIN, UI_icon_from_report_type(report->type), - (3 * UI_DPI_FAC), + (3 * UI_SCALE_FAC), 0, UI_UNIT_X, UI_UNIT_Y, diff --git a/source/blender/editors/interface/interface_widgets.cc b/source/blender/editors/interface/interface_widgets.cc index 55ede2eda80..f50f199357d 100644 --- a/source/blender/editors/interface/interface_widgets.cc +++ b/source/blender/editors/interface/interface_widgets.cc @@ -1354,7 +1354,7 @@ static void widget_draw_icon( return; } - const float aspect = but->block->aspect * U.inv_dpi_fac; + const float aspect = but->block->aspect * UI_INV_SCALE_FAC; const float height = ICON_DEFAULT_HEIGHT / aspect; /* calculate blend color */ @@ -1447,7 +1447,7 @@ static void widget_draw_submenu_tria(const uiBut *but, const rcti *rect, const uiWidgetColors *wcol) { - const float aspect = but->block->aspect * U.inv_dpi_fac; + const float aspect = but->block->aspect * UI_INV_SCALE_FAC; const int tria_height = int(ICON_DEFAULT_HEIGHT / aspect); const int tria_width = int(ICON_DEFAULT_WIDTH / aspect) - 2 * U.pixelsize; const int xs = rect->xmax - tria_width; @@ -1641,7 +1641,7 @@ static void ui_text_clip_middle(const uiFontStyle *fstyle, uiBut *but, const rct int(UI_TEXT_CLIP_MARGIN + 0.5f); const float okwidth = float(max_ii(BLI_rcti_size_x(rect) - border, 0)); const size_t max_len = sizeof(but->drawstr); - const float minwidth = float(UI_DPI_ICON_SIZE) / but->block->aspect * 2.0f; + const float minwidth = float(UI_ICON_SIZE) / but->block->aspect * 2.0f; but->ofs = 0; but->strwidth = UI_text_clip_middle_ex(fstyle, but->drawstr, okwidth, minwidth, max_len, '\0'); @@ -1664,7 +1664,7 @@ static void ui_text_clip_middle_protect_right(const uiFontStyle *fstyle, int(UI_TEXT_CLIP_MARGIN + 0.5f); const float okwidth = float(max_ii(BLI_rcti_size_x(rect) - border, 0)); const size_t max_len = sizeof(but->drawstr); - const float minwidth = float(UI_DPI_ICON_SIZE) / but->block->aspect * 2.0f; + const float minwidth = float(UI_ICON_SIZE) / but->block->aspect * 2.0f; but->ofs = 0; but->strwidth = UI_text_clip_middle_ex(fstyle, but->drawstr, okwidth, minwidth, max_len, rsep); @@ -2297,8 +2297,8 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle, const BIFIconID icon = BIFIconID(ui_but_icon(but)); const int icon_size_init = is_tool ? ICON_DEFAULT_HEIGHT_TOOLBAR : ICON_DEFAULT_HEIGHT; - const float icon_size = icon_size_init / (but->block->aspect * U.inv_dpi_fac); - const float icon_padding = 2 * UI_DPI_FAC; + const float icon_size = icon_size_init / (but->block->aspect * UI_INV_SCALE_FAC); + const float icon_padding = 2 * UI_SCALE_FAC; #ifdef USE_UI_TOOLBAR_HACK if (is_tool) { @@ -4994,11 +4994,11 @@ static void ui_draw_clip_tri(uiBlock *block, rcti *rect, uiWidgetType *wt) if (block->flag & UI_BLOCK_CLIPTOP) { /* XXX no scaling for UI here yet */ - UI_draw_icon_tri(BLI_rcti_cent_x(rect), rect->ymax - 6 * U.dpi_fac, 't', draw_color); + UI_draw_icon_tri(BLI_rcti_cent_x(rect), rect->ymax - 6 * UI_SCALE_FAC, 't', draw_color); } if (block->flag & UI_BLOCK_CLIPBOTTOM) { /* XXX no scaling for UI here yet */ - UI_draw_icon_tri(BLI_rcti_cent_x(rect), rect->ymin + 10 * U.dpi_fac, 'v', draw_color); + UI_draw_icon_tri(BLI_rcti_cent_x(rect), rect->ymin + 10 * UI_SCALE_FAC, 'v', draw_color); } } } @@ -5172,8 +5172,8 @@ void ui_draw_pie_center(uiBlock *block) float *pie_dir = block->pie_data.pie_dir; - const float pie_radius_internal = U.dpi_fac * U.pie_menu_threshold; - const float pie_radius_external = U.dpi_fac * (U.pie_menu_threshold + 7.0f); + const float pie_radius_internal = UI_SCALE_FAC * U.pie_menu_threshold; + const float pie_radius_external = UI_SCALE_FAC * (U.pie_menu_threshold + 7.0f); const int subd = 40; @@ -5246,8 +5246,8 @@ void ui_draw_pie_center(uiBlock *block) if (U.pie_menu_confirm > 0 && !(block->pie_data.flags & (UI_PIE_INVALID_DIR | UI_PIE_CLICK_STYLE))) { - const float pie_confirm_radius = U.dpi_fac * (pie_radius_internal + U.pie_menu_confirm); - const float pie_confirm_external = U.dpi_fac * + const float pie_confirm_radius = UI_SCALE_FAC * (pie_radius_internal + U.pie_menu_confirm); + const float pie_confirm_external = UI_SCALE_FAC * (pie_radius_internal + U.pie_menu_confirm + 7.0f); const uchar col[4] = {UNPACK3(btheme->tui.wcol_pie_menu.text_sel), 64}; @@ -5361,7 +5361,7 @@ void ui_draw_menu_item(const uiFontStyle *fstyle, if (separator_type == UI_MENU_ITEM_SEPARATOR_SHORTCUT) { /* Shrink rect to exclude the shortcut string. */ - rect->xmax -= BLF_width(fstyle->uifont_id, cpoin + 1, INT_MAX) + UI_DPI_ICON_SIZE; + rect->xmax -= BLF_width(fstyle->uifont_id, cpoin + 1, INT_MAX) + UI_ICON_SIZE; } else if (separator_type == UI_MENU_ITEM_SEPARATOR_HINT) { /* Determine max-width for the hint string to leave the name string un-clipped (if there's @@ -5390,7 +5390,7 @@ void ui_draw_menu_item(const uiFontStyle *fstyle, char drawstr[UI_MAX_DRAW_STR]; const float okwidth = float(BLI_rcti_size_x(rect)); const size_t max_len = sizeof(drawstr); - const float minwidth = float(UI_DPI_ICON_SIZE); + const float minwidth = float(UI_ICON_SIZE); BLI_strncpy(drawstr, name, sizeof(drawstr)); if (drawstr[0]) { @@ -5439,7 +5439,7 @@ void ui_draw_menu_item(const uiFontStyle *fstyle, char hint_drawstr[UI_MAX_DRAW_STR]; { const size_t max_len = sizeof(hint_drawstr); - const float minwidth = float(UI_DPI_ICON_SIZE); + const float minwidth = float(UI_ICON_SIZE); BLI_strncpy(hint_drawstr, cpoin + 1, sizeof(hint_drawstr)); if (hint_drawstr[0] && (max_hint_width < INT_MAX)) { @@ -5494,7 +5494,7 @@ void ui_draw_preview_item_stateless(const uiFontStyle *fstyle, char drawstr[UI_MAX_DRAW_STR]; const float okwidth = float(BLI_rcti_size_x(&trect)); const size_t max_len = sizeof(drawstr); - const float minwidth = float(UI_DPI_ICON_SIZE); + const float minwidth = float(UI_ICON_SIZE); BLI_strncpy(drawstr, name, sizeof(drawstr)); UI_text_clip_middle_ex(fstyle, drawstr, okwidth, minwidth, max_len, '\0'); diff --git a/source/blender/editors/interface/resources.cc b/source/blender/editors/interface/resources.cc index b0c8d4739e0..6a2e2ff9073 100644 --- a/source/blender/editors/interface/resources.cc +++ b/source/blender/editors/interface/resources.cc @@ -1468,7 +1468,7 @@ void UI_ThemeClearColor(int colorid) int UI_ThemeMenuShadowWidth() { bTheme *btheme = UI_GetTheme(); - return int(btheme->tui.menu_shadow_width * UI_DPI_FAC); + return int(btheme->tui.menu_shadow_width * UI_SCALE_FAC); } void UI_make_axis_color(const uchar src_col[3], uchar dst_col[3], const char axis) diff --git a/source/blender/editors/interface/view2d.cc b/source/blender/editors/interface/view2d.cc index a8d5b1ad22c..ec81711caeb 100644 --- a/source/blender/editors/interface/view2d.cc +++ b/source/blender/editors/interface/view2d.cc @@ -1288,7 +1288,7 @@ void UI_view2d_dot_grid_draw(const View2D *v2d, immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); /* Scaling the dots fully with the zoom looks too busy, but a bit of size variation is nice. */ - const float min_point_size = 2.0f * UI_DPI_FAC; + const float min_point_size = 2.0f * UI_SCALE_FAC; const float point_size_factor = 1.5f; const float max_point_size = point_size_factor * min_point_size; diff --git a/source/blender/editors/interface/view2d_draw.cc b/source/blender/editors/interface/view2d_draw.cc index c20ad465748..30791a84876 100644 --- a/source/blender/editors/interface/view2d_draw.cc +++ b/source/blender/editors/interface/view2d_draw.cc @@ -38,7 +38,7 @@ /* Compute display grid resolution ********************************************************/ -#define MIN_MAJOR_LINE_DISTANCE (U.v2d_min_gridsize * UI_DPI_FAC) +#define MIN_MAJOR_LINE_DISTANCE (U.v2d_min_gridsize * UI_SCALE_FAC) static float select_major_distance(const float *possible_distances, uint amount, @@ -303,7 +303,7 @@ static void draw_horizontal_scale_indicators(const ARegion *region, BLF_batch_draw_begin(); - const float ypos = rect->ymin + 4 * UI_DPI_FAC; + const float ypos = rect->ymin + 4 * UI_SCALE_FAC; const float xmin = rect->xmin; const float xmax = rect->xmax; @@ -383,7 +383,7 @@ static void draw_vertical_scale_indicators(const ARegion *region, BLF_shadow_offset(font_id, 1, -1); const float x_offset = 8.0f; - const float xpos = (rect->xmin + x_offset) * UI_DPI_FAC; + const float xpos = (rect->xmin + x_offset) * UI_SCALE_FAC; const float ymin = rect->ymin; const float ymax = rect->ymax; const float y_offset = (BLF_height(font_id, "0", 1) / 2.0f) - U.pixelsize; diff --git a/source/blender/editors/interface/view2d_edge_pan.cc b/source/blender/editors/interface/view2d_edge_pan.cc index 897a638dfe5..5f1600647b2 100644 --- a/source/blender/editors/interface/view2d_edge_pan.cc +++ b/source/blender/editors/interface/view2d_edge_pan.cc @@ -174,7 +174,7 @@ static float edge_pan_speed(View2DEdgePanData *vpd, const float zoom_factor = 1.0f + CLAMPIS(vpd->zoom_influence, 0.0f, 1.0f) * (zoomx - 1.0f); return distance_factor * delay_factor * zoom_factor * vpd->max_speed * U.widget_unit * - float(U.dpi_fac); + float(UI_SCALE_FAC); } static void edge_pan_apply_delta(bContext *C, View2DEdgePanData *vpd, float dx, float dy) diff --git a/source/blender/editors/interface/view2d_gizmo_navigate.cc b/source/blender/editors/interface/view2d_gizmo_navigate.cc index 05cb955c660..9e7a62e140e 100644 --- a/source/blender/editors/interface/view2d_gizmo_navigate.cc +++ b/source/blender/editors/interface/view2d_gizmo_navigate.cc @@ -221,7 +221,7 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *g navgroup->state.rect_visible = *rect_visible; const float icon_size = GIZMO_SIZE; - const float icon_offset_mini = icon_size * GIZMO_MINI_OFFSET_FAC * UI_DPI_FAC; + const float icon_offset_mini = icon_size * GIZMO_MINI_OFFSET_FAC * UI_SCALE_FAC; const float co[2] = { roundf(rect_visible->xmax - (icon_offset_mini * 0.75f)), roundf(rect_visible->ymax - (icon_offset_mini * 0.75f)), diff --git a/source/blender/editors/interface/view2d_ops.cc b/source/blender/editors/interface/view2d_ops.cc index 41bc73e4616..7fd898bbff8 100644 --- a/source/blender/editors/interface/view2d_ops.cc +++ b/source/blender/editors/interface/view2d_ops.cc @@ -976,8 +976,8 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op) const bool zoom_to_pos = use_cursor_init && vzd->zoom_to_mouse_pos; /* get amount to move view by */ - float dx = RNA_float_get(op->ptr, "deltax") / U.dpi_fac; - float dy = RNA_float_get(op->ptr, "deltay") / U.dpi_fac; + float dx = RNA_float_get(op->ptr, "deltax") / UI_SCALE_FAC; + float dy = RNA_float_get(op->ptr, "deltay") / UI_SCALE_FAC; /* Check if the 'timer' is initialized, as zooming with the trackpad * never uses the "Continuous" zoom method, and the 'timer' is not initialized. */ diff --git a/source/blender/editors/interface/views/tree_view.cc b/source/blender/editors/interface/views/tree_view.cc index 04987fad59b..ffbd0c56439 100644 --- a/source/blender/editors/interface/views/tree_view.cc +++ b/source/blender/editors/interface/views/tree_view.cc @@ -145,7 +145,7 @@ void AbstractTreeViewItem::add_indent(uiLayout &row) const uiLayout *subrow = uiLayoutRow(&row, true); uiLayoutSetFixedSize(subrow, true); - const float indent_size = count_parents() * UI_DPI_ICON_SIZE; + const float indent_size = count_parents() * UI_ICON_SIZE; uiDefBut(block, UI_BTYPE_SEPR, 0, "", 0, 0, indent_size, 0, nullptr, 0.0, 0.0, 0, 0, ""); /* Indent items without collapsing icon some more within their parent. Makes it clear that they diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index ea4050d0ba0..8019fee01fb 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -469,7 +469,8 @@ static void mask_draw_curve_type(const bContext *C, float viewport_size[4]; GPU_viewport_size_get_f(viewport_size); - immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); + immUniform2f( + "viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC); immUniform1i("colors_len", 2); /* "advanced" mode */ immUniform4fv("color", colors[0]); @@ -806,7 +807,7 @@ void ED_mask_draw_frames( int height = (frame == cfra) ? 22 : 10; int x = (frame - sfra) * framelen; immVertex2i(pos, x, region_bottom); - immVertex2i(pos, x, region_bottom + height * UI_DPI_FAC); + immVertex2i(pos, x, region_bottom + height * UI_SCALE_FAC); } immEnd(); immUnbindProgram(); diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 736555d678c..a9cc62e6a51 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -66,7 +66,7 @@ /* Detect isolated holes and fill them. */ #define USE_NET_ISLAND_CONNECT -#define KMAXDIST (10 * U.dpi_fac) /* Max mouse distance from edge before not detecting it. */ +#define KMAXDIST (10 * UI_SCALE_FAC) /* Max mouse distance from edge before not detecting it. */ /* WARNING: Knife float precision is fragile: * Be careful before making changes here see: (#43229, #42864, #42459, #41164). @@ -495,7 +495,7 @@ static void knifetool_draw_visible_distances(const KnifeTool_OpData *kcd) char numstr[256]; float numstr_size[2]; float posit[2]; - const float bg_margin = 4.0f * U.dpi_fac; + const float bg_margin = 4.0f * UI_SCALE_FAC; const float font_size = 14.0f; const int distance_precision = 4; @@ -517,7 +517,7 @@ static void knifetool_draw_visible_distances(const KnifeTool_OpData *kcd) } BLF_enable(blf_mono_font, BLF_ROTATION); - BLF_size(blf_mono_font, font_size * U.dpi_fac); + BLF_size(blf_mono_font, font_size * UI_SCALE_FAC); BLF_rotation(blf_mono_font, 0.0f); BLF_width_and_height(blf_mono_font, numstr, sizeof(numstr), &numstr_size[0], &numstr_size[1]); @@ -563,9 +563,9 @@ static void knifetool_draw_angle(const KnifeTool_OpData *kcd, { const RegionView3D *rv3d = kcd->region->regiondata; const int arc_steps = 24; - const float arc_size = 64.0f * U.dpi_fac; - const float bg_margin = 4.0f * U.dpi_fac; - const float cap_size = 4.0f * U.dpi_fac; + const float arc_size = 64.0f * UI_SCALE_FAC; + const float bg_margin = 4.0f * UI_SCALE_FAC; + const float cap_size = 4.0f * UI_SCALE_FAC; const float font_size = 14.0f; const int angle_precision = 3; @@ -647,7 +647,7 @@ static void knifetool_draw_angle(const KnifeTool_OpData *kcd, } BLF_enable(blf_mono_font, BLF_ROTATION); - BLF_size(blf_mono_font, font_size * U.dpi_fac); + BLF_size(blf_mono_font, font_size * UI_SCALE_FAC); BLF_rotation(blf_mono_font, 0.0f); BLF_width_and_height(blf_mono_font, numstr, sizeof(numstr), &numstr_size[0], &numstr_size[1]); @@ -907,7 +907,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(region), v if (kcd->prev.vert) { immUniformColor3ubv(kcd->colors.point); - GPU_point_size(11 * UI_DPI_FAC); + GPU_point_size(11 * UI_SCALE_FAC); immBegin(GPU_PRIM_POINTS, 1); immVertex3fv(pos, kcd->prev.cage); @@ -916,7 +916,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(region), v if (kcd->prev.bmface || kcd->prev.edge) { immUniformColor3ubv(kcd->colors.curpoint); - GPU_point_size(9 * UI_DPI_FAC); + GPU_point_size(9 * UI_SCALE_FAC); immBegin(GPU_PRIM_POINTS, 1); immVertex3fv(pos, kcd->prev.cage); @@ -925,7 +925,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(region), v if (kcd->curr.vert) { immUniformColor3ubv(kcd->colors.point); - GPU_point_size(11 * UI_DPI_FAC); + GPU_point_size(11 * UI_SCALE_FAC); immBegin(GPU_PRIM_POINTS, 1); immVertex3fv(pos, kcd->curr.cage); @@ -943,7 +943,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(region), v if (kcd->curr.bmface || kcd->curr.edge) { immUniformColor3ubv(kcd->colors.curpoint); - GPU_point_size(9 * UI_DPI_FAC); + GPU_point_size(9 * UI_SCALE_FAC); immBegin(GPU_PRIM_POINTS, 1); immVertex3fv(pos, kcd->curr.cage); @@ -984,7 +984,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(region), v KnifeVert *kfv; immUniformColor3ubv(kcd->colors.point); - GPU_point_size(5.0 * UI_DPI_FAC); + GPU_point_size(5.0 * UI_SCALE_FAC); GPUBatch *batch = immBeginBatchAtMost(GPU_PRIM_POINTS, BLI_mempool_len(kcd->kverts)); @@ -1040,7 +1040,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(region), v /* Draw any snapped verts first. */ rgba_uchar_to_float(fcol, kcd->colors.point_a); GPU_batch_uniform_4fv(batch, "color", fcol); - GPU_point_size(11 * UI_DPI_FAC); + GPU_point_size(11 * UI_SCALE_FAC); if (snapped_verts_count > 0) { GPU_batch_draw_range(batch, 0, snapped_verts_count); } @@ -1048,7 +1048,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(region), v /* Now draw the rest. */ rgba_uchar_to_float(fcol, kcd->colors.curpoint_a); GPU_batch_uniform_4fv(batch, "color", fcol); - GPU_point_size(7 * UI_DPI_FAC); + GPU_point_size(7 * UI_SCALE_FAC); if (other_verts_count > 0) { GPU_batch_draw_range(batch, snapped_verts_count, other_verts_count); } diff --git a/source/blender/editors/object/object_remesh.cc b/source/blender/editors/object/object_remesh.cc index 987f652dc84..678b19f8ef2 100644 --- a/source/blender/editors/object/object_remesh.cc +++ b/source/blender/editors/object/object_remesh.cc @@ -354,7 +354,7 @@ static void voxel_size_edit_draw(const bContext *C, ARegion * /*region*/, void * GPU_matrix_push(); GPU_matrix_mul(cd->text_mat); - BLF_size(fontid, 10.0f * fstyle_points * U.dpi_fac); + BLF_size(fontid, 10.0f * fstyle_points * UI_SCALE_FAC); BLF_color3f(fontid, 1.0f, 1.0f, 1.0f); BLF_width_and_height(fontid, str, strdrawlen, &strwidth, &strheight); BLF_position(fontid, -0.5f * strwidth, -0.5f * strheight, 0.0f); diff --git a/source/blender/editors/render/render_view.cc b/source/blender/editors/render/render_view.cc index f0427bf8683..7f212f03731 100644 --- a/source/blender/editors/render/render_view.cc +++ b/source/blender/editors/render/render_view.cc @@ -134,8 +134,8 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports) int sizex, sizey; BKE_render_resolution(&scene->r, false, &sizex, &sizey); - sizex += 30 * UI_DPI_FAC; - sizey += 60 * UI_DPI_FAC; + sizex += 30 * UI_SCALE_FAC; + sizey += 60 * UI_SCALE_FAC; /* arbitrary... miniature image window views don't make much sense */ if (sizex < 320) { diff --git a/source/blender/editors/screen/area.cc b/source/blender/editors/screen/area.cc index 89c7dd7cf65..bfbea031fdd 100644 --- a/source/blender/editors/screen/area.cc +++ b/source/blender/editors/screen/area.cc @@ -183,7 +183,7 @@ static void area_draw_azone_fullscreen(short /*x1*/, short /*y1*/, short x2, sho UI_icon_draw_ex(x2 - U.widget_unit, y2 - U.widget_unit, ICON_FULLSCREEN_EXIT, - U.inv_dpi_fac, + UI_INV_SCALE_FAC, min_ff(alpha, 0.75f), 0.0f, nullptr, @@ -359,7 +359,7 @@ static void region_draw_status_text(ScrArea *area, ARegion *region) const float y = 0.4f * UI_UNIT_Y; if (overlap) { - const float pad = 2.0f * UI_DPI_FAC; + const float pad = 2.0f * UI_SCALE_FAC; const float x1 = x - (UI_UNIT_X - pad); const float x2 = x + width + (UI_UNIT_X - pad); const float y1 = pad; @@ -1301,13 +1301,13 @@ static void region_rect_recursive( } /* `prefsizex/y`, taking into account DPI. */ - int prefsizex = UI_DPI_FAC * + int prefsizex = UI_SCALE_FAC * ((region->sizex > 1) ? region->sizex + 0.5f : region->type->prefsizex); int prefsizey; if (region->flag & RGN_FLAG_PREFSIZE_OR_HIDDEN) { - prefsizex = UI_DPI_FAC * region->type->prefsizex; - prefsizey = UI_DPI_FAC * region->type->prefsizey; + prefsizex = UI_SCALE_FAC * region->type->prefsizex; + prefsizey = UI_SCALE_FAC * region->type->prefsizey; } else if (region->regiontype == RGN_TYPE_HEADER) { prefsizey = ED_area_headersize(); @@ -1322,7 +1322,8 @@ static void region_rect_recursive( prefsizey = ED_region_global_size_y(); } else { - prefsizey = UI_DPI_FAC * (region->sizey > 1 ? region->sizey + 0.5f : region->type->prefsizey); + prefsizey = UI_SCALE_FAC * + (region->sizey > 1 ? region->sizey + 0.5f : region->type->prefsizey); } if (region->flag & RGN_FLAG_HIDDEN) { @@ -1510,12 +1511,12 @@ static void region_rect_recursive( region->winy = BLI_rcti_size_y(®ion->winrct) + 1; /* If region opened normally, we store this for hide/reveal usage. */ - /* Prevent rounding errors for UI_DPI_FAC multiply and divide. */ + /* Prevent rounding errors for UI_SCALE_FAC multiply and divide. */ if (region->winx > 1) { - region->sizex = (region->winx + 0.5f) / UI_DPI_FAC; + region->sizex = (region->winx + 0.5f) / UI_SCALE_FAC; } if (region->winy > 1) { - region->sizey = (region->winy + 0.5f) / UI_DPI_FAC; + region->sizey = (region->winy + 0.5f) / UI_SCALE_FAC; } /* exception for multiple overlapping regions on same spot */ @@ -3024,8 +3025,8 @@ void ED_region_panels_layout_ex(const bContext *C, Panel *panel = static_cast(region->panels.last); if (panel != nullptr) { const int size_dyn[2] = { - int(UI_UNIT_X * (UI_panel_is_closed(panel) ? 8 : 14) / UI_DPI_FAC), - int(UI_panel_size_y(panel) / UI_DPI_FAC), + int(UI_UNIT_X * (UI_panel_is_closed(panel) ? 8 : 14) / UI_SCALE_FAC), + int(UI_panel_size_y(panel) / UI_SCALE_FAC), }; /* region size is layout based and needs to be updated */ if ((region->sizex != size_dyn[0]) || (region->sizey != size_dyn[1])) { @@ -3033,7 +3034,7 @@ void ED_region_panels_layout_ex(const bContext *C, region->sizey = size_dyn[1]; area->flag |= AREA_FLAG_REGION_SIZE_UPDATE; } - y = fabsf(region->sizey * UI_DPI_FAC - 1); + y = fabsf(region->sizey * UI_SCALE_FAC - 1); } } else { @@ -3288,7 +3289,7 @@ void ED_region_header_layout(const bContext *C, ARegion *region) bool region_layout_based = region->flag & RGN_FLAG_DYNAMIC_SIZE; /* Height of buttons and scaling needed to achieve it. */ - const int buttony = min_ii(UI_UNIT_Y, region->winy - 2 * UI_DPI_FAC); + const int buttony = min_ii(UI_UNIT_Y, region->winy - 2 * UI_SCALE_FAC); const float buttony_scale = buttony / float(UI_UNIT_Y); /* Vertically center buttons. */ @@ -3342,7 +3343,7 @@ void ED_region_header_layout(const bContext *C, ARegion *region) maxco = xco; } - int new_sizex = (maxco + UI_HEADER_OFFSET) / UI_DPI_FAC; + int new_sizex = (maxco + UI_HEADER_OFFSET) / UI_SCALE_FAC; if (region_layout_based && (region->sizex != new_sizex)) { /* region size is layout based and needs to be updated */ @@ -3402,7 +3403,7 @@ void ED_region_header_init(ARegion *region) int ED_area_headersize(void) { /* Accommodate widget and padding. */ - return U.widget_unit + int(UI_DPI_FAC * HEADER_PADDING_Y); + return U.widget_unit + int(UI_SCALE_FAC * HEADER_PADDING_Y); } int ED_area_footersize(void) @@ -3413,17 +3414,17 @@ int ED_area_footersize(void) int ED_area_global_size_y(const ScrArea *area) { BLI_assert(ED_area_is_global(area)); - return round_fl_to_int(area->global->cur_fixed_height * UI_DPI_FAC); + return round_fl_to_int(area->global->cur_fixed_height * UI_SCALE_FAC); } int ED_area_global_min_size_y(const ScrArea *area) { BLI_assert(ED_area_is_global(area)); - return round_fl_to_int(area->global->size_min * UI_DPI_FAC); + return round_fl_to_int(area->global->size_min * UI_SCALE_FAC); } int ED_area_global_max_size_y(const ScrArea *area) { BLI_assert(ED_area_is_global(area)); - return round_fl_to_int(area->global->size_max * UI_DPI_FAC); + return round_fl_to_int(area->global->size_max * UI_SCALE_FAC); } bool ED_area_is_global(const ScrArea *area) @@ -3510,7 +3511,7 @@ void ED_region_info_draw_multiline(ARegion *region, rcti rect = *ED_region_visible_rect(region); /* Needed in case scripts leave the font size at an unexpected value, see: #102213. */ - BLF_size(fontid, style->widget.points * U.dpi_fac); + BLF_size(fontid, style->widget.points * UI_SCALE_FAC); /* Box fill entire width or just around text. */ if (!full_redraw) { @@ -3764,7 +3765,7 @@ void ED_region_cache_draw_background(ARegion *region) immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor4ub(128, 128, 255, 64); - immRecti(pos, 0, region_bottom, region->winx, region_bottom + 8 * UI_DPI_FAC); + immRecti(pos, 0, region_bottom, region->winx, region_bottom + 8 * UI_SCALE_FAC); immUnbindProgram(); } @@ -3776,7 +3777,7 @@ void ED_region_cache_draw_curfra_label(const int framenr, const float x, const f float font_dims[2] = {0.0f, 0.0f}; /* frame number */ - BLF_size(fontid, 11.0f * U.dpi_fac); + BLF_size(fontid, 11.0f * UI_SCALE_FAC); BLI_snprintf(numstr, sizeof(numstr), "%d", framenr); BLF_width_and_height(fontid, numstr, sizeof(numstr), &font_dims[0], &font_dims[1]); @@ -3810,7 +3811,7 @@ void ED_region_cache_draw_cached_segments( float x1 = float(points[a * 2] - sfra) / (efra - sfra + 1) * region->winx; float x2 = float(points[a * 2 + 1] - sfra + 1) / (efra - sfra + 1) * region->winx; - immRecti(pos, x1, region_bottom, x2, region_bottom + 8 * UI_DPI_FAC); + immRecti(pos, x1, region_bottom, x2, region_bottom + 8 * UI_SCALE_FAC); /* TODO(merwin): use primitive restart to draw multiple rects more efficiently */ } diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 58473219cde..25034dd835b 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -629,8 +629,8 @@ int ED_draw_imbuf_method(ImBuf *ibuf) void immDrawBorderCorners(uint pos, const rcti *border, float zoomx, float zoomy) { - float delta_x = 4.0f * UI_DPI_FAC / zoomx; - float delta_y = 4.0f * UI_DPI_FAC / zoomy; + float delta_x = 4.0f * UI_SCALE_FAC / zoomx; + float delta_y = 4.0f * UI_SCALE_FAC / zoomy; delta_x = min_ff(delta_x, border->xmax - border->xmin); delta_y = min_ff(delta_y, border->ymax - border->ymin); diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index cb96d2b6bdf..e0969b444eb 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1064,7 +1064,7 @@ static void screen_global_area_refresh(wmWindow *win, static int screen_global_header_size(void) { - return (int)ceilf(ED_area_headersize() / UI_DPI_FAC); + return (int)ceilf(ED_area_headersize() / UI_SCALE_FAC); } static void screen_global_topbar_area_refresh(wmWindow *win, bScreen *screen) diff --git a/source/blender/editors/screen/screen_geometry.c b/source/blender/editors/screen/screen_geometry.c index 3ad3fa7892c..309bedda4fd 100644 --- a/source/blender/editors/screen/screen_geometry.c +++ b/source/blender/editors/screen/screen_geometry.c @@ -284,7 +284,7 @@ short screen_geom_find_area_split_point(const ScrArea *area, { const int cur_area_width = screen_geom_area_width(area); const int cur_area_height = screen_geom_area_height(area); - const short area_min_x = AREAMINX * U.dpi_fac; + const short area_min_x = AREAMINX * UI_SCALE_FAC; const short area_min_y = ED_area_headersize(); /* area big enough? */ diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h index d1fe516b406..1d8bb7cb0bc 100644 --- a/source/blender/editors/screen/screen_intern.h +++ b/source/blender/editors/screen/screen_intern.h @@ -46,13 +46,13 @@ typedef enum eScreenAxis { #define AZONEFADEOUT (6.5f * U.widget_unit) /* when we start seeing the #AZone */ /* Edges must be within these to allow joining. */ -#define AREAJOINTOLERANCEX (AREAMINX * U.dpi_fac) -#define AREAJOINTOLERANCEY (HEADERY * U.dpi_fac) +#define AREAJOINTOLERANCEX (AREAMINX * UI_SCALE_FAC) +#define AREAJOINTOLERANCEY (HEADERY * UI_SCALE_FAC) /** * Expanded interaction influence of area borders. */ -#define BORDERPADDING ((2.0f * U.dpi_fac) + U.pixelsize) +#define BORDERPADDING ((2.0f * UI_SCALE_FAC) + U.pixelsize) /* area.cc */ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index a9c6ff11a53..ca1f190001b 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1207,7 +1207,7 @@ static ScrEdge *screen_area_edge_from_cursor(const bContext *C, if (actedge == NULL) { return NULL; } - int borderwidth = (4 * UI_DPI_FAC); + int borderwidth = (4 * UI_SCALE_FAC); ScrArea *sa1, *sa2; if (screen_geom_edge_is_horizontal(actedge)) { sa1 = BKE_screen_find_area_xy( @@ -1638,7 +1638,7 @@ static void area_move_set_limits(wmWindow *win, } } else { - int areamin = AREAMINX * U.dpi_fac; + int areamin = AREAMINX * UI_SCALE_FAC; if (area->v1->vec.x > window_rect.xmin) { areamin += U.pixelsize; @@ -1847,7 +1847,7 @@ static void area_move_apply_do(const bContext *C, if (area->v1->editflag || area->v2->editflag || area->v3->editflag || area->v4->editflag) { if (ED_area_is_global(area)) { /* Snap to minimum or maximum for global areas. */ - int height = round_fl_to_int(screen_geom_area_height(area) / UI_DPI_FAC); + int height = round_fl_to_int(screen_geom_area_height(area) / UI_SCALE_FAC); if (abs(height - area->global->size_min) < abs(height - area->global->size_max)) { area->global->cur_fixed_height = area->global->size_min; } @@ -2061,7 +2061,7 @@ static bool area_split_allowed(const ScrArea *area, const eScreenAxis dir_axis) return false; } - if ((dir_axis == SCREEN_AXIS_V && area->winx <= 2 * AREAMINX * U.dpi_fac) || + if ((dir_axis == SCREEN_AXIS_V && area->winx <= 2 * AREAMINX * UI_SCALE_FAC) || (dir_axis == SCREEN_AXIS_H && area->winy <= 2 * ED_area_headersize())) { /* Must be at least double minimum sizes to split into two. */ return false; @@ -2639,7 +2639,7 @@ static int area_max_regionsize(ScrArea *area, ARegion *scale_region, AZEdge edge } } - dist /= UI_DPI_FAC; + dist /= UI_SCALE_FAC; return dist; } @@ -2731,7 +2731,7 @@ static void region_scale_validate_size(RegionMoveData *rmd) size = &rmd->region->sizey; } - maxsize = rmd->maxsize - (UI_UNIT_Y / UI_DPI_FAC); + maxsize = rmd->maxsize - (UI_UNIT_Y / UI_SCALE_FAC); if (*size > maxsize && maxsize > 0) { *size = maxsize; @@ -2781,7 +2781,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event) } /* region sizes now get multiplied */ - delta /= UI_DPI_FAC; + delta /= UI_SCALE_FAC; const int size_no_snap = rmd->origval + delta; rmd->region->sizex = size_no_snap; @@ -2814,7 +2814,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event) } /* region sizes now get multiplied */ - delta /= UI_DPI_FAC; + delta /= UI_SCALE_FAC; const int size_no_snap = rmd->origval + delta; rmd->region->sizey = size_no_snap; @@ -5044,8 +5044,8 @@ static int userpref_show_exec(bContext *C, wmOperator *op) wmWindow *win_cur = CTX_wm_window(C); /* Use eventstate, not event from _invoke, so this can be called through exec(). */ const wmEvent *event = win_cur->eventstate; - int sizex = (500 + UI_NAVIGATION_REGION_WIDTH) * UI_DPI_FAC; - int sizey = 520 * UI_DPI_FAC; + int sizex = (500 + UI_NAVIGATION_REGION_WIDTH) * UI_SCALE_FAC; + int sizey = 520 * UI_SCALE_FAC; PropertyRNA *prop = RNA_struct_find_property(op->ptr, "section"); if (prop && RNA_property_is_set(op->ptr, prop)) { @@ -5124,8 +5124,8 @@ static int drivers_editor_show_exec(bContext *C, wmOperator *op) /* Use eventstate, not event from _invoke, so this can be called through exec(). */ const wmEvent *event = win_cur->eventstate; - int sizex = 900 * UI_DPI_FAC; - int sizey = 580 * UI_DPI_FAC; + int sizex = 900 * UI_SCALE_FAC; + int sizey = 580 * UI_SCALE_FAC; /* Get active property to show driver for * - Need to grab it first, or else this info disappears @@ -5201,8 +5201,8 @@ static int info_log_show_exec(bContext *C, wmOperator *op) wmWindow *win_cur = CTX_wm_window(C); /* Use eventstate, not event from _invoke, so this can be called through exec(). */ const wmEvent *event = win_cur->eventstate; - int sizex = 900 * UI_DPI_FAC; - int sizey = 580 * UI_DPI_FAC; + int sizex = 900 * UI_SCALE_FAC; + int sizey = 580 * UI_SCALE_FAC; int shift_y = 480; /* changes context! */ diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.cc b/source/blender/editors/sculpt_paint/sculpt_cloth.cc index 6db4fe5b718..79ba11e6db3 100644 --- a/source/blender/editors/sculpt_paint/sculpt_cloth.cc +++ b/source/blender/editors/sculpt_paint/sculpt_cloth.cc @@ -1508,7 +1508,7 @@ static int sculpt_cloth_filter_modal(bContext *C, wmOperator *op, const wmEvent } const float len = event->prev_press_xy[0] - event->xy[0]; - filter_strength = filter_strength * -len * 0.001f * UI_DPI_FAC; + filter_strength = filter_strength * -len * 0.001f * UI_SCALE_FAC; SCULPT_vertex_random_access_ensure(ss); diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc index 27bb4f11569..f9912aa4402 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc @@ -810,7 +810,7 @@ static void sculpt_mesh_update_strength(wmOperator *op, { const float len = prev_press_mouse[0] - mouse[0]; - float filter_strength = ss->filter_cache->start_filter_strength * -len * 0.001f * UI_DPI_FAC; + float filter_strength = ss->filter_cache->start_filter_strength * -len * 0.001f * UI_SCALE_FAC; RNA_float_set(op->ptr, "strength", filter_strength); } static void sculpt_mesh_filter_apply_with_history(bContext *C, wmOperator *op) diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index bd84ff23bde..2831e5d8454 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -645,7 +645,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene) /* Iterate over pointcaches on the active object, and draw each one's range. */ float y_offset = 0.0f; - const float cache_draw_height = 4.0f * UI_DPI_FAC * U.pixelsize; + const float cache_draw_height = 4.0f * UI_SCALE_FAC * U.pixelsize; LISTBASE_FOREACH (PTCacheID *, pid, &pidlist) { if (timeline_cache_is_hidden_by_setting(saction, pid)) { continue; diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.cc b/source/blender/editors/space_clip/clip_dopesheet_draw.cc index 87dd61ce1e1..e39316e8dc5 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.cc +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.cc @@ -340,7 +340,7 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *region) /* second pass: text */ y = float(CHANNEL_FIRST); - BLF_size(fontid, 11.0f * U.dpi_fac); + BLF_size(fontid, 11.0f * UI_SCALE_FAC); LISTBASE_FOREACH (MovieTrackingDopesheetChannel *, channel, &dopesheet->channels) { float yminc = float(y - CHANNEL_HEIGHT_HALF); diff --git a/source/blender/editors/space_clip/clip_draw.cc b/source/blender/editors/space_clip/clip_draw.cc index 6f95132d123..c6b730bfaf1 100644 --- a/source/blender/editors/space_clip/clip_draw.cc +++ b/source/blender/editors/space_clip/clip_draw.cc @@ -59,11 +59,11 @@ static void draw_keyframe(int frame, int cfra, int sfra, float framelen, int wid if (width == 1) { immBegin(GPU_PRIM_LINES, 2); immVertex2i(pos, x, 0); - immVertex2i(pos, x, height * UI_DPI_FAC); + immVertex2i(pos, x, height * UI_SCALE_FAC); immEnd(); } else { - immRecti(pos, x, 0, x + width, height * UI_DPI_FAC); + immRecti(pos, x, 0, x + width, height * UI_SCALE_FAC); } } @@ -191,7 +191,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *region, MovieClip *clip (i - sfra + clip->start_frame - 1) * framelen, 0, (i - sfra + clip->start_frame) * framelen, - 4 * UI_DPI_FAC); + 4 * UI_SCALE_FAC); } } } @@ -223,7 +223,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *region, MovieClip *clip (i - sfra + clip->start_frame - 1) * framelen, 0, (i - sfra + clip->start_frame) * framelen, - 8 * UI_DPI_FAC); + 8 * UI_SCALE_FAC); } } } @@ -234,11 +234,11 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *region, MovieClip *clip x = (sc->user.framenr - sfra) / (efra - sfra + 1) * region->winx; immUniformThemeColor(TH_CFRAME); - immRecti(pos, x, 0, x + ceilf(framelen), 8 * UI_DPI_FAC); + immRecti(pos, x, 0, x + ceilf(framelen), 8 * UI_SCALE_FAC); immUnbindProgram(); - ED_region_cache_draw_curfra_label(sc->user.framenr, x, 8.0f * UI_DPI_FAC); + ED_region_cache_draw_curfra_label(sc->user.framenr, x, 8.0f * UI_SCALE_FAC); pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); @@ -368,7 +368,8 @@ static void draw_stabilization_border( float viewport_size[4]; GPU_viewport_size_get_f(viewport_size); - immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); + immUniform2f( + "viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC); immUniform1i("colors_len", 0); /* "simple" mode */ immUniformColor4f(1.0f, 1.0f, 1.0f, 0.0f); @@ -743,7 +744,7 @@ static void draw_marker_areas(SpaceClip *sc, float viewport_size[4]; GPU_viewport_size_get_f(viewport_size); - immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); + immUniform2f("viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC); immUniform1i("colors_len", 0); /* "simple" mode */ @@ -954,11 +955,11 @@ static void draw_marker_slide_zones(SpaceClip *sc, dy = 6.0f / height / sc->zoom; side = get_shortest_pattern_side(marker); - patdx = min_ff(dx * 2.0f / 3.0f, side / 6.0f) * UI_DPI_FAC; - patdy = min_ff(dy * 2.0f / 3.0f, side * width / height / 6.0f) * UI_DPI_FAC; + patdx = min_ff(dx * 2.0f / 3.0f, side / 6.0f) * UI_SCALE_FAC; + patdy = min_ff(dy * 2.0f / 3.0f, side * width / height / 6.0f) * UI_SCALE_FAC; - searchdx = min_ff(dx, (marker->search_max[0] - marker->search_min[0]) / 6.0f) * UI_DPI_FAC; - searchdy = min_ff(dy, (marker->search_max[1] - marker->search_min[1]) / 6.0f) * UI_DPI_FAC; + searchdx = min_ff(dx, (marker->search_max[0] - marker->search_min[0]) / 6.0f) * UI_SCALE_FAC; + searchdy = min_ff(dy, (marker->search_max[1] - marker->search_min[1]) / 6.0f) * UI_SCALE_FAC; px[0] = 1.0f / sc->zoom / width / sc->scale; px[1] = 1.0f / sc->zoom / height / sc->scale; @@ -1035,7 +1036,7 @@ static void draw_marker_texts(SpaceClip *sc, return; } - BLF_size(fontid, 11.0f * U.dpi_fac); + BLF_size(fontid, 11.0f * UI_SCALE_FAC); fontsize = BLF_height_max(fontid); if (marker->flag & MARKER_DISABLED) { @@ -1288,7 +1289,8 @@ static void draw_plane_marker_ex(SpaceClip *sc, float viewport_size[4]; GPU_viewport_size_get_f(viewport_size); - immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); + immUniform2f( + "viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC); immUniform1i("colors_len", 0); /* "simple" mode */ diff --git a/source/blender/editors/space_clip/clip_ops.cc b/source/blender/editors/space_clip/clip_ops.cc index 3ace6605487..78466926e05 100644 --- a/source/blender/editors/space_clip/clip_ops.cc +++ b/source/blender/editors/space_clip/clip_ops.cc @@ -1104,7 +1104,7 @@ static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event ARegion *region = CTX_wm_region(C); if (region->regiontype == RGN_TYPE_WINDOW) { - if (event->mval[1] > 16 * UI_DPI_FAC) { + if (event->mval[1] > 16 * UI_SCALE_FAC) { return OPERATOR_PASS_THROUGH; } } diff --git a/source/blender/editors/space_clip/space_clip.cc b/source/blender/editors/space_clip/space_clip.cc index b30a1d6f305..f6680ed8069 100644 --- a/source/blender/editors/space_clip/space_clip.cc +++ b/source/blender/editors/space_clip/space_clip.cc @@ -997,7 +997,7 @@ static void graph_region_draw(const bContext *C, ARegion *region) { rcti rect; BLI_rcti_init( - &rect, 0, 15 * UI_DPI_FAC, 15 * UI_DPI_FAC, region->winy - UI_TIME_SCRUB_MARGIN_Y); + &rect, 0, 15 * UI_SCALE_FAC, 15 * UI_SCALE_FAC, region->winy - UI_TIME_SCRUB_MARGIN_Y); UI_view2d_draw_scale_y__values(region, v2d, &rect, TH_TEXT); } } diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index 6710d4ce0e7..8f037c3bcd8 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -167,7 +167,7 @@ static void console_textview_draw_rect_calc(const ARegion *region, rcti *r_draw_rect, rcti *r_draw_rect_outer) { - const int margin = 4 * UI_DPI_FAC; + const int margin = 4 * UI_SCALE_FAC; r_draw_rect->xmin = margin; r_draw_rect->xmax = region->winx - V2D_SCROLL_WIDTH; r_draw_rect->ymin = margin; @@ -209,7 +209,7 @@ static int console_textview_main__internal(SpaceConsole *sc, /* view */ tvc.sel_start = sc->sel_start; tvc.sel_end = sc->sel_end; - tvc.lheight = sc->lheight * UI_DPI_FAC; + tvc.lheight = sc->lheight * UI_SCALE_FAC; tvc.scroll_ymin = v2d->cur.ymin; tvc.scroll_ymax = v2d->cur.ymax; diff --git a/source/blender/editors/space_file/file_draw.cc b/source/blender/editors/space_file/file_draw.cc index 580adc0243f..eb6eadda607 100644 --- a/source/blender/editors/space_file/file_draw.cc +++ b/source/blender/editors/space_file/file_draw.cc @@ -205,7 +205,7 @@ static void file_draw_string(int sx, fs = style->widget; BLI_strncpy(fname, string, FILE_MAXFILE); - UI_text_clip_middle_ex(&fs, fname, width, UI_DPI_ICON_SIZE, sizeof(fname), '\0'); + UI_text_clip_middle_ex(&fs, fname, width, UI_ICON_SIZE, sizeof(fname), '\0'); /* no text clipping needed, UI_fontstyle_draw does it but is a bit too strict * (for buttons it works) */ @@ -340,8 +340,8 @@ static void file_draw_preview(const FileDirEntry *file, BLI_assert(imb != nullptr); - ui_imbx = imb->x * UI_DPI_FAC; - ui_imby = imb->y * UI_DPI_FAC; + ui_imbx = imb->x * UI_SCALE_FAC; + ui_imby = imb->y * UI_SCALE_FAC; /* Unlike thumbnails, icons are not scaled up. */ if (((ui_imbx > layout->prv_w) || (ui_imby > layout->prv_h)) || (!is_icon && ((ui_imbx < layout->prv_w) || (ui_imby < layout->prv_h)))) { @@ -359,7 +359,7 @@ static void file_draw_preview(const FileDirEntry *file, else { scaledx = ui_imbx; scaledy = ui_imby; - scale = UI_DPI_FAC; + scale = UI_SCALE_FAC; } ex = int(scaledx); @@ -417,7 +417,7 @@ static void file_draw_preview(const FileDirEntry *file, if (icon && is_icon) { /* Small icon in the middle of large image, scaled to fit container and UI scale */ float icon_x, icon_y; - const float icon_size = 16.0f / icon_aspect * U.dpi_fac; + const float icon_size = 16.0f / icon_aspect * UI_SCALE_FAC; float icon_opacity = 0.3f; uchar icon_color[4] = {0, 0, 0, 255}; float bgcolor[4]; @@ -432,7 +432,7 @@ static void file_draw_preview(const FileDirEntry *file, UI_icon_draw_ex(icon_x, icon_y, icon, - icon_aspect / U.dpi_fac, + icon_aspect / UI_SCALE_FAC, icon_opacity, 0.0f, icon_color, @@ -443,8 +443,8 @@ static void file_draw_preview(const FileDirEntry *file, if (is_link || is_offline) { /* Icon at bottom to indicate it is a shortcut, link, alias, or offline. */ float icon_x, icon_y; - icon_x = xco + (2.0f * UI_DPI_FAC); - icon_y = yco + (2.0f * UI_DPI_FAC); + icon_x = xco + (2.0f * UI_SCALE_FAC); + icon_y = yco + (2.0f * UI_SCALE_FAC); const int arrow = is_link ? ICON_LOOP_FORWARDS : ICON_URL; if (!is_icon) { /* At very bottom-left if preview style. */ @@ -453,7 +453,7 @@ static void file_draw_preview(const FileDirEntry *file, UI_icon_draw_ex(icon_x + 1, icon_y - 1, arrow, - 1.0f / U.dpi_fac, + 1.0f / UI_SCALE_FAC, 0.2f, 0.0f, dark, @@ -462,7 +462,7 @@ static void file_draw_preview(const FileDirEntry *file, UI_icon_draw_ex(icon_x, icon_y, arrow, - 1.0f / U.dpi_fac, + 1.0f / UI_SCALE_FAC, 0.6f, 0.0f, light, @@ -478,7 +478,7 @@ static void file_draw_preview(const FileDirEntry *file, UI_icon_draw_ex(icon_x, icon_y, arrow, - icon_aspect / U.dpi_fac * 1.8, + icon_aspect / UI_SCALE_FAC * 1.8f, 0.3f, 0.0f, icon_color, @@ -491,19 +491,26 @@ static void file_draw_preview(const FileDirEntry *file, float icon_x, icon_y; const uchar dark[4] = {0, 0, 0, 255}; const uchar light[4] = {255, 255, 255, 255}; - icon_x = xco + (2.0f * UI_DPI_FAC); - icon_y = yco + (2.0f * UI_DPI_FAC); + icon_x = xco + (2.0f * UI_SCALE_FAC); + icon_y = yco + (2.0f * UI_SCALE_FAC); UI_icon_draw_ex(icon_x + 1, icon_y - 1, icon, - 1.0f / U.dpi_fac, + 1.0f / UI_SCALE_FAC, 0.2f, 0.0f, dark, false, UI_NO_ICON_OVERLAY_TEXT); - UI_icon_draw_ex( - icon_x, icon_y, icon, 1.0f / U.dpi_fac, 0.6f, 0.0f, light, false, UI_NO_ICON_OVERLAY_TEXT); + UI_icon_draw_ex(icon_x, + icon_y, + icon, + 1.0f / UI_SCALE_FAC, + 0.6f, + 0.0f, + light, + false, + UI_NO_ICON_OVERLAY_TEXT); } const bool is_current_main_data = filelist_file_get_id(file) != nullptr; @@ -517,7 +524,7 @@ static void file_draw_preview(const FileDirEntry *file, UI_icon_draw_ex(icon_x, icon_y, ICON_CURRENT_FILE, - 1.0f / U.dpi_fac, + 1.0f / UI_SCALE_FAC, 0.6f, 0.0f, light, @@ -1041,7 +1048,7 @@ void file_draw_list(const bContext *C, ARegion *region) 0, 0); UI_but_dragflag_enable(drag_but, UI_BUT_DRAG_FULL_BUT); - file_but_enable_drag(drag_but, sfile, file, path, nullptr, icon, UI_DPI_FAC); + file_but_enable_drag(drag_but, sfile, file, path, nullptr, icon, UI_SCALE_FAC); } /* Add this after the fake draggable button, so the icon button tooltip is displayed. */ @@ -1056,7 +1063,7 @@ void file_draw_list(const bContext *C, ARegion *region) if (do_drag) { /* For some reason the dragging is unreliable for the icon button if we don't explicitly * enable dragging, even though the dummy drag button above covers the same area. */ - file_but_enable_drag(icon_but, sfile, file, path, nullptr, icon, UI_DPI_FAC); + file_but_enable_drag(icon_but, sfile, file, path, nullptr, icon, UI_SCALE_FAC); } } diff --git a/source/blender/editors/space_file/filesel.cc b/source/blender/editors/space_file/filesel.cc index 45bbb25a4de..bc9fd0140cf 100644 --- a/source/blender/editors/space_file/filesel.cc +++ b/source/blender/editors/space_file/filesel.cc @@ -630,8 +630,8 @@ void ED_fileselect_window_params_get(const wmWindow *win, int win_size[2], bool /* Get DPI/pixel-size independent size to be stored in preferences. */ WM_window_set_dpi(win); /* Ensure the DPI is taken from the right window. */ - win_size[0] = WM_window_pixels_x(win) / UI_DPI_FAC; - win_size[1] = WM_window_pixels_y(win) / UI_DPI_FAC; + win_size[0] = WM_window_pixels_x(win) / UI_SCALE_FAC; + win_size[1] = WM_window_pixels_y(win) / UI_SCALE_FAC; *is_maximized = WM_window_is_maximized(win); } @@ -967,7 +967,7 @@ float file_font_pointsize(void) #else const uiStyle *style = UI_style_get(); UI_fontstyle_set(&style->widget); - return style->widget.points * UI_DPI_FAC; + return style->widget.points * UI_SCALE_FAC; #endif } diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index ff4cc11885c..4ce7d4286df 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -84,7 +84,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, float viewport_size[4]; GPU_viewport_size_get_f(viewport_size); - immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); + immUniform2f("viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC); immUniform1i("colors_len", 0); /* Simple dashes. */ immUniformColor3f(0.0f, 0.0f, 0.0f); @@ -235,7 +235,7 @@ static void draw_fcurve_keyframe_vertices(FCurve *fcu, View2D *v2d, bool edit, u { immBindBuiltinProgram(GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA); - immUniform1f("size", UI_GetThemeValuef(TH_VERTEX_SIZE) * U.dpi_fac); + immUniform1f("size", UI_GetThemeValuef(TH_VERTEX_SIZE) * UI_SCALE_FAC); draw_fcurve_selected_keyframe_vertices(fcu, v2d, edit, false, pos); draw_fcurve_selected_keyframe_vertices(fcu, v2d, edit, true, pos); @@ -332,8 +332,8 @@ static void draw_fcurve_handle_vertices(FCurve *fcu, View2D *v2d, bool sel_handl immBindBuiltinProgram(GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA); /* set handle size */ - immUniform1f("size", (1.4f * UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE)) * U.dpi_fac); - immUniform1f("outlineWidth", 1.5f * U.dpi_fac); + immUniform1f("size", (1.4f * UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE)) * UI_SCALE_FAC); + immUniform1f("outlineWidth", 1.5f * UI_SCALE_FAC); draw_fcurve_selected_handle_vertices(fcu, v2d, false, sel_handle_only, pos); draw_fcurve_selected_handle_vertices(fcu, v2d, true, sel_handle_only, pos); @@ -1043,7 +1043,8 @@ static void draw_fcurve(bAnimContext *ac, SpaceGraph *sipo, ARegion *region, bAn if (BKE_fcurve_is_protected(fcu)) { /* Protected curves (non editable) are drawn with dotted lines. */ immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR); - immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); + immUniform2f( + "viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC); immUniform1i("colors_len", 0); /* Simple dashes. */ immUniform1f("dash_width", 4.0f); immUniform1f("udash_factor", 0.5f); @@ -1192,7 +1193,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) float viewport_size[4]; GPU_viewport_size_get_f(viewport_size); - immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); + immUniform2f("viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC); immUniform1i("colors_len", 0); /* Simple dashes. */ @@ -1312,7 +1313,7 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *region float viewport_size[4]; GPU_viewport_size_get_f(viewport_size); - immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); + immUniform2f("viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC); immUniform1i("colors_len", 0); /* Simple dashes. */ immUniform1f("dash_width", 20.0f); diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 53d75665bbd..812143d3a40 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -314,7 +314,7 @@ static void graph_main_region_draw_overlay(const bContext *C, ARegion *region) { rcti rect; BLI_rcti_init( - &rect, 0, 15 * UI_DPI_FAC, 15 * UI_DPI_FAC, region->winy - UI_TIME_SCRUB_MARGIN_Y); + &rect, 0, 15 * UI_SCALE_FAC, 15 * UI_SCALE_FAC, region->winy - UI_TIME_SCRUB_MARGIN_Y); UI_view2d_draw_scale_y__values(region, v2d, &rect, TH_SCROLL_TEXT); } } diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index d323a7162d7..786fcd4075a 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -789,7 +789,7 @@ void uiTemplateImage(uiLayout *layout, else if (ima->type == IMA_TYPE_R_RESULT) { /* browse layer/passes */ RenderResult *rr; - const float dpi_fac = UI_DPI_FAC; + const float dpi_fac = UI_SCALE_FAC; const int menus_width = 230 * dpi_fac; /* use BKE_image_acquire_renderresult so we get the correct slot in the menu */ @@ -880,7 +880,7 @@ void uiTemplateImage(uiLayout *layout, if (ima->type == IMA_TYPE_MULTILAYER && ima->rr) { uiItemS(layout); - const float dpi_fac = UI_DPI_FAC; + const float dpi_fac = UI_SCALE_FAC; uiblock_layer_pass_buttons(layout, ima, ima->rr, iuser, 230 * dpi_fac, NULL); } @@ -1162,7 +1162,7 @@ void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser /* render layers and passes */ if (ima && iuser) { RenderResult *rr; - const float dpi_fac = UI_DPI_FAC; + const float dpi_fac = UI_SCALE_FAC; const int menus_width = 160 * dpi_fac; const bool is_render_result = (ima->type == IMA_TYPE_R_RESULT); diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 9bf23ff4538..6460e6ebd7b 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -168,7 +168,7 @@ void ED_image_draw_info(Scene *scene, GPU_blend(GPU_BLEND_NONE); - BLF_size(blf_mono_font, 11.0f * U.dpi_fac); + BLF_size(blf_mono_font, 11.0f * UI_SCALE_FAC); BLF_color3ub(blf_mono_font, 255, 255, 255); SNPRINTF(str, "X:%-4d Y:%-4d |", x, y); @@ -452,7 +452,8 @@ void draw_image_sample_line(SpaceImage *sima) float viewport_size[4]; GPU_viewport_size_get_f(viewport_size); - immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); + immUniform2f( + "viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC); immUniform1i("colors_len", 2); /* Advanced dashes. */ immUniform4f("color", 1.0f, 1.0f, 1.0f, 1.0f); @@ -504,7 +505,7 @@ bool ED_space_image_show_cache_and_mval_over(const SpaceImage *sima, const int mval[2]) { const rcti *rect_visible = ED_region_visible_rect(region); - if (mval[1] > rect_visible->ymin + (16 * UI_DPI_FAC)) { + if (mval[1] > rect_visible->ymin + (16 * UI_SCALE_FAC)) { return false; } return ED_space_image_show_cache(sima); @@ -559,10 +560,10 @@ void draw_image_cache(const bContext *C, ARegion *region) immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformThemeColor(TH_CFRAME); - immRecti(pos, x, region_bottom, x + ceilf(framelen), region_bottom + 8 * UI_DPI_FAC); + immRecti(pos, x, region_bottom, x + ceilf(framelen), region_bottom + 8 * UI_SCALE_FAC); immUnbindProgram(); - ED_region_cache_draw_curfra_label(cfra, x, region_bottom + 8.0f * UI_DPI_FAC); + ED_region_cache_draw_curfra_label(cfra, x, region_bottom + 8.0f * UI_SCALE_FAC); if (mask != NULL) { ED_mask_draw_frames(mask, region, cfra, sfra, efra); diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c index 812df2fc6cc..695d13f9425 100644 --- a/source/blender/editors/space_info/info_draw.c +++ b/source/blender/editors/space_info/info_draw.c @@ -190,7 +190,7 @@ static int info_textview_main__internal(const SpaceInfo *sinfo, /* view */ tvc.sel_start = 0; tvc.sel_end = 0; - tvc.lheight = 17 * UI_DPI_FAC; + tvc.lheight = 17 * UI_SCALE_FAC; tvc.row_vpadding = 0.4 * tvc.lheight; tvc.scroll_ymin = v2d->cur.ymin; tvc.scroll_ymax = v2d->cur.ymax; diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c index 12ee6f45991..c1c21bebf2b 100644 --- a/source/blender/editors/space_info/textview.c +++ b/source/blender/editors/space_info/textview.c @@ -15,7 +15,7 @@ #include "GPU_immediate.h" #include "GPU_state.h" -#include "DNA_userdef_types.h" /* For 'U.dpi_fac' */ +#include "DNA_userdef_types.h" /* For 'UI_SCALE_FAC' */ #include "UI_interface.h" #include "UI_interface_icons.h" @@ -205,7 +205,7 @@ static bool textview_draw_string(TextViewDrawState *tds, if (icon_bg) { float col[4]; - int bg_size = UI_DPI_ICON_SIZE * 1.2; + int bg_size = UI_ICON_SIZE * 1.2; float vpadding = (tds->lheight + (tds->row_vpadding * 2) - bg_size) / 2; float hpadding = tds->draw_rect->xmin - (bg_size * 1.2f); @@ -219,19 +219,19 @@ static bool textview_draw_string(TextViewDrawState *tds, .ymax = line_top - vpadding, }, true, - 4 * UI_DPI_FAC, + 4 * UI_SCALE_FAC, col); } if (icon) { - int vpadding = (tds->lheight + (tds->row_vpadding * 2) - UI_DPI_ICON_SIZE) / 2; - int hpadding = tds->draw_rect->xmin - (UI_DPI_ICON_SIZE * 1.3f); + int vpadding = (tds->lheight + (tds->row_vpadding * 2) - UI_ICON_SIZE) / 2; + int hpadding = tds->draw_rect->xmin - (UI_ICON_SIZE * 1.3f); GPU_blend(GPU_BLEND_ALPHA); UI_icon_draw_ex(hpadding, - line_top - UI_DPI_ICON_SIZE - vpadding, + line_top - UI_ICON_SIZE - vpadding, icon, - (16 / UI_DPI_ICON_SIZE), + (16 / UI_ICON_SIZE), 1.0f, 0.0f, icon_fg, diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 058cf3c49b4..83d0d1c205b 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -183,7 +183,8 @@ static void nla_actionclip_draw_markers( float viewport_size[4]; GPU_viewport_size_get_f(viewport_size); - immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); + immUniform2f( + "viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC); immUniform1i("colors_len", 0); /* "simple" mode */ immUniform1f("dash_width", 6.0f); @@ -382,7 +383,7 @@ static uint nla_draw_use_dashed_outlines(const float color[4], bool muted) float viewport_size[4]; GPU_viewport_size_get_f(viewport_size); - immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); + immUniform2f("viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC); immUniform1i("colors_len", 0); /* Simple dashes. */ immUniformColor3fv(color); @@ -789,7 +790,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *region) { View2D *v2d = ®ion->v2d; const float pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask); - const float text_margin_x = (8 * UI_DPI_FAC) * pixelx; + const float text_margin_x = (8 * UI_SCALE_FAC) * pixelx; /* build list of channels to draw */ ListBase anim_data = {NULL, NULL}; diff --git a/source/blender/editors/space_node/add_node_search.cc b/source/blender/editors/space_node/add_node_search.cc index ed26c6c4e21..c0ba8cd998e 100644 --- a/source/blender/editors/space_node/add_node_search.cc +++ b/source/blender/editors/space_node/add_node_search.cc @@ -237,8 +237,8 @@ static void add_node_search_exec_fn(bContext *C, void *arg1, void *arg2) item->info.after_add_fn(*C, node_tree, *new_node); } - new_node->locx = storage.cursor.x / UI_DPI_FAC; - new_node->locy = storage.cursor.y / UI_DPI_FAC + 20; + new_node->locx = storage.cursor.x / UI_SCALE_FAC; + new_node->locy = storage.cursor.y / UI_SCALE_FAC + 20; nodeSetSelected(new_node, true); nodeSetActive(&node_tree, new_node); diff --git a/source/blender/editors/space_node/clipboard.cc b/source/blender/editors/space_node/clipboard.cc index 95c1c25e343..f51040d8dcc 100644 --- a/source/blender/editors/space_node/clipboard.cc +++ b/source/blender/editors/space_node/clipboard.cc @@ -260,7 +260,7 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) float2 mouse_location; RNA_property_float_get_array(op->ptr, offset_prop, mouse_location); - const float2 offset = (mouse_location - center) / UI_DPI_FAC; + const float2 offset = (mouse_location - center) / UI_SCALE_FAC; for (bNode *new_node : node_map.values()) { new_node->locx += offset.x; diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index ceb1d78a941..0b68e6b9dd4 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -1675,8 +1675,8 @@ void node_link_bezier_points_evaluated(const Span socket_locations, #define NODELINK_GROUP_SIZE 256 #define LINK_RESOL 24 -#define LINK_WIDTH (2.5f * UI_DPI_FAC) -#define ARROW_SIZE (7 * UI_DPI_FAC) +#define LINK_WIDTH (2.5f * UI_SCALE_FAC) +#define ARROW_SIZE (7 * UI_SCALE_FAC) /* Reroute arrow shape and mute bar. These are expanded here and shrunk in the glsl code. * See: gpu_shader_2D_nodelink_vert.glsl */ @@ -2228,7 +2228,7 @@ static std::array node_link_bezier_points_dragged(const SpaceNode &sn const bNodeLink &link) { const bNodeTree &node_tree = *snode.edittree; - const float2 cursor = snode.runtime->cursor * UI_DPI_FAC; + const float2 cursor = snode.runtime->cursor * UI_SCALE_FAC; std::array points; points[0] = link.fromsock ? socket_link_connection_location(node_tree.runtime->all_socket_locations, diff --git a/source/blender/editors/space_node/link_drag_search.cc b/source/blender/editors/space_node/link_drag_search.cc index b7270907c9d..58f6dc18447 100644 --- a/source/blender/editors/space_node/link_drag_search.cc +++ b/source/blender/editors/space_node/link_drag_search.cc @@ -381,8 +381,8 @@ static void link_drag_search_exec_fn(bContext *C, void *arg1, void *arg2) BLI_assert(new_nodes.size() == 1); bNode *new_node = new_nodes.first(); - new_node->locx = storage.cursor.x / UI_DPI_FAC; - new_node->locy = storage.cursor.y / UI_DPI_FAC + 20; + new_node->locx = storage.cursor.x / UI_SCALE_FAC; + new_node->locy = storage.cursor.y / UI_SCALE_FAC + 20; if (storage.in_out() == SOCK_IN) { new_node->locx -= new_node->width; } diff --git a/source/blender/editors/space_node/node_add.cc b/source/blender/editors/space_node/node_add.cc index c175d994ec3..c21c27832cf 100644 --- a/source/blender/editors/space_node/node_add.cc +++ b/source/blender/editors/space_node/node_add.cc @@ -57,8 +57,8 @@ namespace blender::ed::space_node { static void position_node_based_on_mouse(bNode &node, const float2 &location) { - node.locx = location.x - NODE_DY * 1.5f / UI_DPI_FAC; - node.locy = location.y + NODE_DY * 0.5f / UI_DPI_FAC; + node.locx = location.x - NODE_DY * 1.5f / UI_SCALE_FAC; + node.locy = location.y + NODE_DY * 0.5f / UI_SCALE_FAC; } bNode *add_node(const bContext &C, const StringRef idname, const float2 &location) @@ -206,8 +206,8 @@ static int add_reroute_exec(bContext *C, wmOperator *op) const float2 insert_point = std::accumulate( cuts.values().begin(), cuts.values().end(), float2(0)) / cuts.size(); - reroute->locx = insert_point.x / UI_DPI_FAC; - reroute->locy = insert_point.y / UI_DPI_FAC; + reroute->locx = insert_point.x / UI_SCALE_FAC; + reroute->locy = insert_point.y / UI_SCALE_FAC; /* Attach the reroute node to frame nodes behind it. */ for (const int i : frame_nodes.index_range()) { @@ -350,8 +350,8 @@ static int node_add_group_invoke(bContext *C, wmOperator *op, const wmEvent *eve &snode->runtime->cursor[0], &snode->runtime->cursor[1]); - snode->runtime->cursor[0] /= UI_DPI_FAC; - snode->runtime->cursor[1] /= UI_DPI_FAC; + snode->runtime->cursor[0] /= UI_SCALE_FAC; + snode->runtime->cursor[1] /= UI_SCALE_FAC; return node_add_group_exec(C, op); } @@ -443,7 +443,7 @@ static int node_add_group_asset_invoke(bContext *C, wmOperator *op, const wmEven &snode.runtime->cursor[0], &snode.runtime->cursor[1]); - snode.runtime->cursor /= UI_DPI_FAC; + snode.runtime->cursor /= UI_SCALE_FAC; if (!add_node_group_asset(*C, asset, *op->reports)) { return OPERATOR_CANCELLED; @@ -543,8 +543,8 @@ static int node_add_object_invoke(bContext *C, wmOperator *op, const wmEvent *ev &snode->runtime->cursor[0], &snode->runtime->cursor[1]); - snode->runtime->cursor[0] /= UI_DPI_FAC; - snode->runtime->cursor[1] /= UI_DPI_FAC; + snode->runtime->cursor[0] /= UI_SCALE_FAC; + snode->runtime->cursor[1] /= UI_SCALE_FAC; return node_add_object_exec(C, op); } @@ -630,8 +630,8 @@ static int node_add_collection_invoke(bContext *C, wmOperator *op, const wmEvent &snode->runtime->cursor[0], &snode->runtime->cursor[1]); - snode->runtime->cursor[0] /= UI_DPI_FAC; - snode->runtime->cursor[1] /= UI_DPI_FAC; + snode->runtime->cursor[0] /= UI_SCALE_FAC; + snode->runtime->cursor[1] /= UI_SCALE_FAC; return node_add_collection_exec(C, op); } @@ -745,8 +745,8 @@ static int node_add_file_invoke(bContext *C, wmOperator *op, const wmEvent *even &snode->runtime->cursor[0], &snode->runtime->cursor[1]); - snode->runtime->cursor[0] /= UI_DPI_FAC; - snode->runtime->cursor[1] /= UI_DPI_FAC; + snode->runtime->cursor[0] /= UI_SCALE_FAC; + snode->runtime->cursor[1] /= UI_SCALE_FAC; if (WM_operator_properties_id_lookup_is_set(op->ptr) || RNA_struct_property_is_set(op->ptr, "filepath")) { diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 8fe3af660bd..737b50aa288 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -308,7 +308,7 @@ float2 node_to_view(const bNode &node, const float2 &co) { float2 result; nodeToView(&node, co.x, co.y, &result.x, &result.y); - return result * UI_DPI_FAC; + return result * UI_SCALE_FAC; } void node_to_updated_rect(const bNode &node, rctf &r_rect) @@ -324,8 +324,8 @@ void node_to_updated_rect(const bNode &node, rctf &r_rect) float2 node_from_view(const bNode &node, const float2 &co) { - const float x = co.x / UI_DPI_FAC; - const float y = co.y / UI_DPI_FAC; + const float x = co.x / UI_SCALE_FAC; + const float y = co.y / UI_SCALE_FAC; float2 result; nodeFromView(&node, x, y, &result.x, &result.y); return result; @@ -768,10 +768,10 @@ static void node_socket_draw_multi_input(const float color[4], const float2 location) { /* The other sockets are drawn with the keyframe shader. There, the outline has a base thickness - * that can be varied but always scales with the size the socket is drawn at. Using `U.dpi_fac` - * has the same effect here. It scales the outline correctly across different screen DPI's - * and UI scales without being affected by the 'line-width'. */ - const float outline_width = NODE_SOCK_OUTLINE_SCALE * U.dpi_fac; + * that can be varied but always scales with the size the socket is drawn at. Using + * `UI_SCALE_FAC` has the same effect here. It scales the outline correctly across different + * screen DPI's and UI scales without being affected by the 'line-width'. */ + const float outline_width = NODE_SOCK_OUTLINE_SCALE * UI_SCALE_FAC; /* UI_draw_roundbox draws the outline on the outer side, so compensate for the outline width. */ const rctf rect = { @@ -2021,7 +2021,7 @@ static void node_draw_extra_info_row(const bNode &node, const int row, const NodeExtraInfoRow &extra_info_row) { - const float but_icon_left = rect.xmin + 6.0f * U.dpi_fac; + const float but_icon_left = rect.xmin + 6.0f * UI_SCALE_FAC; const float but_icon_width = NODE_HEADER_ICON_SIZE * 0.8f; const float but_icon_right = but_icon_left + but_icon_width; @@ -2031,7 +2031,7 @@ static void node_draw_extra_info_row(const bNode &node, 0, extra_info_row.icon, int(but_icon_left), - int(rect.ymin + row * (20.0f * U.dpi_fac)), + int(rect.ymin + row * (20.0f * UI_SCALE_FAC)), but_icon_width, UI_UNIT_Y, nullptr, @@ -2048,7 +2048,7 @@ static void node_draw_extra_info_row(const bNode &node, } UI_block_emboss_set(&block, UI_EMBOSS); - const float but_text_left = but_icon_right + 6.0f * U.dpi_fac; + const float but_text_left = but_icon_right + 6.0f * UI_SCALE_FAC; const float but_text_right = rect.xmax; const float but_text_width = but_text_right - but_text_left; @@ -2057,7 +2057,7 @@ static void node_draw_extra_info_row(const bNode &node, 0, extra_info_row.text.c_str(), int(but_text_left), - int(rect.ymin + row * (20.0f * U.dpi_fac)), + int(rect.ymin + row * (20.0f * UI_SCALE_FAC)), short(but_text_width), short(NODE_DY), nullptr, @@ -2087,19 +2087,19 @@ static void node_draw_extra_info_panel(TreeDrawContext &tree_draw_ctx, float color[4]; rctf extra_info_rect; - const float width = (node.width - 6.0f) * U.dpi_fac; + const float width = (node.width - 6.0f) * UI_SCALE_FAC; if (node.is_frame()) { extra_info_rect.xmin = rct.xmin; - extra_info_rect.xmax = rct.xmin + 95.0f * U.dpi_fac; - extra_info_rect.ymin = rct.ymin + 2.0f * U.dpi_fac; - extra_info_rect.ymax = rct.ymin + 2.0f * U.dpi_fac; + extra_info_rect.xmax = rct.xmin + 95.0f * UI_SCALE_FAC; + extra_info_rect.ymin = rct.ymin + 2.0f * UI_SCALE_FAC; + extra_info_rect.ymax = rct.ymin + 2.0f * UI_SCALE_FAC; } else { - extra_info_rect.xmin = rct.xmin + 3.0f * U.dpi_fac; + extra_info_rect.xmin = rct.xmin + 3.0f * UI_SCALE_FAC; extra_info_rect.xmax = rct.xmin + width; extra_info_rect.ymin = rct.ymax; - extra_info_rect.ymax = rct.ymax + extra_info_rows.size() * (20.0f * U.dpi_fac); + extra_info_rect.ymax = rct.ymax + extra_info_rows.size() * (20.0f * UI_SCALE_FAC); if (node.flag & NODE_MUTED) { UI_GetThemeColorBlend4f(TH_BACK, TH_NODE, 0.2f, color); @@ -2115,10 +2115,11 @@ static void node_draw_extra_info_panel(TreeDrawContext &tree_draw_ctx, /* Draw outline. */ const float outline_width = 1.0f; - extra_info_rect.xmin = rct.xmin + 3.0f * U.dpi_fac - outline_width; + extra_info_rect.xmin = rct.xmin + 3.0f * UI_SCALE_FAC - outline_width; extra_info_rect.xmax = rct.xmin + width + outline_width; extra_info_rect.ymin = rct.ymax - outline_width; - extra_info_rect.ymax = rct.ymax + outline_width + extra_info_rows.size() * (20.0f * U.dpi_fac); + extra_info_rect.ymax = rct.ymax + outline_width + + extra_info_rows.size() * (20.0f * UI_SCALE_FAC); UI_GetThemeColorBlendShade4fv(TH_BACK, TH_NODE, 0.4f, -20, color); UI_draw_roundbox_corner_set( @@ -2328,7 +2329,7 @@ static void node_draw_basis(const bContext &C, showname, int(rct.xmin + NODE_MARGIN_X + 0.4f), int(rct.ymax - NODE_DY), - short(iconofs - rct.xmin - (18.0f * U.dpi_fac)), + short(iconofs - rct.xmin - (18.0f * UI_SCALE_FAC)), short(NODE_DY), nullptr, 0, @@ -2560,7 +2561,7 @@ static void node_draw_hidden(const bContext &C, showname, round_fl_to_int(rct.xmin + NODE_MARGIN_X), round_fl_to_int(centy - NODE_DY * 0.5f), - short(BLI_rctf_size_x(&rct) - ((18.0f + 12.0f) * U.dpi_fac)), + short(BLI_rctf_size_x(&rct) - ((18.0f + 12.0f) * UI_SCALE_FAC)), short(NODE_DY), nullptr, 0, @@ -2718,7 +2719,7 @@ static void count_multi_input_socket_links(bNodeTree &ntree, SpaceNode &snode) static float frame_node_label_height(const NodeFrame &frame_data) { - return frame_data.label_size * U.dpi_fac; + return frame_data.label_size * UI_SCALE_FAC; } #define NODE_FRAME_MARGIN (1.5f * U.widget_unit) @@ -2854,7 +2855,7 @@ static void frame_node_draw_label(TreeDrawContext &tree_draw_ctx, BLF_enable(fontid, BLF_ASPECT); BLF_aspect(fontid, aspect, aspect, 1.0f); - BLF_size(fontid, font_size * U.dpi_fac); + BLF_size(fontid, font_size * UI_SCALE_FAC); /* Title color. */ int color_id = node_get_colorid(tree_draw_ctx, node); @@ -3118,7 +3119,7 @@ static void draw_tree_path(const bContext &C, ARegion ®ion) const rcti *rect = ED_region_visible_rect(®ion); const uiStyle *style = UI_style_get_dpi(); - const float padding_x = 16 * UI_DPI_FAC; + const float padding_x = 16 * UI_SCALE_FAC; const int x = rect->xmin + padding_x; const int y = region.winy - UI_UNIT_Y * 0.6f; const int width = BLI_rcti_size_x(rect) - 2 * padding_x; @@ -3272,8 +3273,8 @@ void node_draw_space(const bContext &C, ARegion ®ion) win->eventstate->xy[1] - region.winrct.ymin, &snode.runtime->cursor[0], &snode.runtime->cursor[1]); - snode.runtime->cursor[0] /= UI_DPI_FAC; - snode.runtime->cursor[1] /= UI_DPI_FAC; + snode.runtime->cursor[0] /= UI_SCALE_FAC; + snode.runtime->cursor[1] /= UI_SCALE_FAC; ED_region_draw_cb_draw(&C, ®ion, REGION_DRAW_PRE_VIEW); diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index 79473957f33..a9a1f30f5cd 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -916,8 +916,8 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event) WM_event_drag_start_mval(event, region, mval); float mx, my; UI_view2d_region_to_view(®ion->v2d, mval.x, mval.y, &mx, &my); - const float dx = (mx - nsw->mxstart) / UI_DPI_FAC; - const float dy = (my - nsw->mystart) / UI_DPI_FAC; + const float dx = (mx - nsw->mxstart) / UI_SCALE_FAC; + const float dy = (my - nsw->mystart) / UI_SCALE_FAC; if (node) { float *pwidth = &node->width; @@ -941,8 +941,8 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event) /* Height works the other way round. */ { - float heightmin = UI_DPI_FAC * node->typeinfo->minheight; - float heightmax = UI_DPI_FAC * node->typeinfo->maxheight; + float heightmin = UI_SCALE_FAC * node->typeinfo->minheight; + float heightmax = UI_SCALE_FAC * node->typeinfo->maxheight; if (nsw->directions & NODE_RESIZE_TOP) { float locmin = nsw->oldlocy - nsw->oldheight; diff --git a/source/blender/editors/space_node/node_intern.hh b/source/blender/editors/space_node/node_intern.hh index 11e64bb2f4c..2a0a49d640d 100644 --- a/source/blender/editors/space_node/node_intern.hh +++ b/source/blender/editors/space_node/node_intern.hh @@ -129,8 +129,8 @@ ENUM_OPERATORS(NodeResizeDirection, NODE_RESIZE_LEFT); #define NODE_DYS (U.widget_unit / 2) #define NODE_DY U.widget_unit #define NODE_SOCKDY (0.1f * U.widget_unit) -#define NODE_WIDTH(node) (node.width * UI_DPI_FAC) -#define NODE_HEIGHT(node) (node.height * UI_DPI_FAC) +#define NODE_WIDTH(node) (node.width * UI_SCALE_FAC) +#define NODE_HEIGHT(node) (node.height * UI_SCALE_FAC) #define NODE_MARGIN_X (1.2f * U.widget_unit) #define NODE_SOCKSIZE (0.25f * U.widget_unit) #define NODE_SOCKSIZE_DRAW_MULIPLIER 2.25f diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc index 4741b26f33f..8c56890468e 100644 --- a/source/blender/editors/space_node/node_relationships.cc +++ b/source/blender/editors/space_node/node_relationships.cc @@ -133,7 +133,7 @@ static void pick_input_link_by_link_intersect(const bContext &C, bNode &node = socket->owner_node(); /* Distance to test overlapping of cursor on link. */ - const float cursor_link_touch_distance = 12.5f * UI_DPI_FAC; + const float cursor_link_touch_distance = 12.5f * UI_SCALE_FAC; bNodeLink *link_to_pick = nullptr; clear_picking_highlight(&node_tree.links); @@ -649,7 +649,8 @@ static int view_socket(const bContext &C, const float2 socket_location = btree.runtime->all_socket_locations[bsocket_to_view.index_in_tree()]; const int viewer_type = get_default_viewer_type(&C); - const float2 location{socket_location.x / UI_DPI_FAC + 100, socket_location.y / UI_DPI_FAC}; + const float2 location{socket_location.x / UI_SCALE_FAC + 100, + socket_location.y / UI_SCALE_FAC}; viewer_node = add_static_node(C, viewer_type, location); } @@ -823,17 +824,18 @@ static void draw_draglink_tooltip(const bContext * /*C*/, ARegion * /*region*/, uchar text_col[4]; UI_GetThemeColor4ubv(TH_TEXT, text_col); - const int padding = 4 * UI_DPI_FAC; + const int padding = 4 * UI_SCALE_FAC; const float x = nldrag->in_out == SOCK_IN ? nldrag->cursor[0] - 3.3f * padding : nldrag->cursor[0]; - const float y = nldrag->cursor[1] - 2.0f * UI_DPI_FAC; + const float y = nldrag->cursor[1] - 2.0f * UI_SCALE_FAC; const bool new_link = nldrag->in_out == nldrag->start_socket->in_out; const bool swap_links = nldrag->swap_links; const int icon = !swap_links ? ICON_ADD : (new_link ? ICON_ANIM : ICON_UV_SYNC_SELECT); - UI_icon_draw_ex(x, y, icon, U.inv_dpi_fac, 1.0f, 0.0f, text_col, false, UI_NO_ICON_OVERLAY_TEXT); + UI_icon_draw_ex( + x, y, icon, UI_INV_SCALE_FAC, 1.0f, 0.0f, text_col, false, UI_NO_ICON_OVERLAY_TEXT); } static void draw_draglink_tooltip_activate(const ARegion ®ion, bNodeLinkDrag &nldrag) @@ -2321,7 +2323,7 @@ static void node_offset_apply(bNode &node, const float offset_x) /* NODE_TEST is used to flag nodes that shouldn't be offset (again) */ if ((node.flag & NODE_TEST) == 0) { node.runtime->anim_init_locx = node.locx; - node.runtime->anim_ofsx = (offset_x / UI_DPI_FAC); + node.runtime->anim_ofsx = (offset_x / UI_SCALE_FAC); node.flag |= NODE_TEST; } } @@ -2425,7 +2427,7 @@ static void node_link_insert_offset_ntree(NodeInsertOfsData *iofsd, bNode *prev = iofsd->prev, *next = iofsd->next; bNode *init_parent = insert.parent; /* store old insert.parent for restoring later */ - const float min_margin = U.node_margin * UI_DPI_FAC; + const float min_margin = U.node_margin * UI_SCALE_FAC; const float width = NODE_WIDTH(insert); const bool needs_alignment = (next->runtime->totr.xmin - prev->runtime->totr.xmax) < (width + (min_margin * 2.0f)); diff --git a/source/blender/editors/space_node/node_view.cc b/source/blender/editors/space_node/node_view.cc index b11997ba1b6..eafc963e433 100644 --- a/source/blender/editors/space_node/node_view.cc +++ b/source/blender/editors/space_node/node_view.cc @@ -370,7 +370,7 @@ static int backimage_fit_exec(bContext *C, wmOperator * /*op*/) BKE_image_release_ibuf(ima, ibuf, lock); - snode->zoom *= min_ff(facx, facy) * U.dpi_fac; + snode->zoom *= min_ff(facx, facy) * UI_SCALE_FAC; snode->xof = 0; snode->yof = 0; diff --git a/source/blender/editors/space_node/space_node.cc b/source/blender/editors/space_node/space_node.cc index a922d31829d..cc71df93963 100644 --- a/source/blender/editors/space_node/space_node.cc +++ b/source/blender/editors/space_node/space_node.cc @@ -616,8 +616,8 @@ static void node_cursor(wmWindow *win, ScrArea *area, ARegion *region) node_set_cursor(*win, *snode, snode->runtime->cursor); /* XXX snode->runtime->cursor is in placing new nodes space */ - snode->runtime->cursor[0] /= UI_DPI_FAC; - snode->runtime->cursor[1] /= UI_DPI_FAC; + snode->runtime->cursor[0] /= UI_SCALE_FAC; + snode->runtime->cursor[1] /= UI_SCALE_FAC; } /* Initialize main region, setting handlers. */ diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc index 20cca386fcc..b91e5adbb30 100644 --- a/source/blender/editors/space_outliner/outliner_draw.cc +++ b/source/blender/editors/space_outliner/outliner_draw.cc @@ -1803,7 +1803,7 @@ static void outliner_draw_overrides_rna_buts(uiBlock *block, const ListBase *lb, const int x) { - const float pad_x = 2.0f * UI_DPI_FAC; + const float pad_x = 2.0f * UI_SCALE_FAC; const float pad_y = 0.5f * U.pixelsize; const float item_max_width = round_fl_to_int(OL_RNA_COL_SIZEX - 2 * pad_x); const float item_height = round_fl_to_int(UI_UNIT_Y - 2.0f * pad_y); @@ -2903,7 +2903,7 @@ static bool tselem_draw_icon(uiBlock *block, UI_icon_draw_ex(x, y, data.icon, - U.inv_dpi_fac, + UI_INV_SCALE_FAC, alpha, 0.0f, btheme->collection_color[collection->color_tag].color, @@ -2919,10 +2919,11 @@ static bool tselem_draw_icon(uiBlock *block, /* Restrict column clip. it has been coded by simply overdrawing, doesn't work for buttons. */ uchar color[4]; if (UI_icon_get_theme_color(data.icon, color)) { - UI_icon_draw_ex(x, y, data.icon, U.inv_dpi_fac, alpha, 0.0f, color, true, &text_overlay); + UI_icon_draw_ex(x, y, data.icon, UI_INV_SCALE_FAC, alpha, 0.0f, color, true, &text_overlay); } else { - UI_icon_draw_ex(x, y, data.icon, U.inv_dpi_fac, alpha, 0.0f, nullptr, false, &text_overlay); + UI_icon_draw_ex( + x, y, data.icon, UI_INV_SCALE_FAC, alpha, 0.0f, nullptr, false, &text_overlay); } } else { @@ -3529,7 +3530,7 @@ static void outliner_draw_hierarchy_lines(SpaceOutliner *space_outliner, float viewport_size[4]; GPU_viewport_size_get_f(viewport_size); - immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); + immUniform2f("viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC); immUniform1i("colors_len", 0); /* "simple" mode */ immUniform1f("dash_width", 8.0f); UI_GetThemeColorBlend3ubv(TH_BACK, TH_TEXT, 0.4f, col); @@ -3813,7 +3814,8 @@ static int outliner_width(SpaceOutliner *space_outliner, float right_column_width) { if (space_outliner->outlinevis == SO_DATA_API) { - return outliner_data_api_buttons_start_x(max_tree_width) + OL_RNA_COL_SIZEX + 10 * UI_DPI_FAC; + return outliner_data_api_buttons_start_x(max_tree_width) + OL_RNA_COL_SIZEX + + 10 * UI_SCALE_FAC; } return max_tree_width + right_column_width; } diff --git a/source/blender/editors/space_sequencer/sequencer_drag_drop.c b/source/blender/editors/space_sequencer/sequencer_drag_drop.c index 49c2f48666b..797145fb57d 100644 --- a/source/blender/editors/space_sequencer/sequencer_drag_drop.c +++ b/source/blender/editors/space_sequencer/sequencer_drag_drop.c @@ -429,7 +429,7 @@ static void draw_seq_in_view(bContext *C, wmWindow *UNUSED(win), wmDrag *drag, c float handle_size = 8.0f; /* SEQ_HANDLE_SIZE */ /* Calculate height needed for drawing text on strip. */ - float text_margin_y = y2 - min_ff(0.40f, 20 * U.dpi_fac * pixely); + float text_margin_y = y2 - min_ff(0.40f, 20 * UI_SCALE_FAC * pixely); float text_margin_x = 2.0f * (pixelx * handle_size) * U.pixelsize; rctf rect; diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 5276914346d..debdb677d63 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -1330,10 +1330,10 @@ static void draw_seq_strip(const bContext *C, (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_STRIP_DURATION)) { /* Calculate height needed for drawing text on strip. */ - text_margin_y = y2 - min_ff(0.40f, 20 * U.dpi_fac * pixely); + text_margin_y = y2 - min_ff(0.40f, 20 * UI_SCALE_FAC * pixely); /* Is there enough space for drawing something else than text? */ - y_threshold = ((y2 - y1) / pixely) > 20 * U.dpi_fac; + y_threshold = ((y2 - y1) / pixely) > 20 * UI_SCALE_FAC; } else { text_margin_y = y2; @@ -1423,7 +1423,7 @@ static void draw_seq_strip(const bContext *C, if (sseq->flag & SEQ_SHOW_OVERLAY) { /* Don't draw strip if there is not enough vertical or horizontal space. */ - if (((x2 - x1) > 32 * pixelx * U.dpi_fac) && ((y2 - y1) > 8 * pixely * U.dpi_fac)) { + if (((x2 - x1) > 32 * pixelx * UI_SCALE_FAC) && ((y2 - y1) > 8 * pixely * UI_SCALE_FAC)) { /* Depending on the vertical space, draw text on top or in the center of strip. */ draw_seq_text_overlay( scene, v2d, seq, sseq, x1, x2, y_threshold ? text_margin_y : y1, y2, seq_active); @@ -1650,7 +1650,7 @@ static void sequencer_draw_borders_overlay(const SpaceSeq *sseq, float viewport_size[4]; GPU_viewport_size_get_f(viewport_size); - immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); + immUniform2f("viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC); immUniformThemeColor(TH_BACK); immUniform1i("colors_len", 0); /* Simple dashes. */ @@ -2470,7 +2470,7 @@ static bool draw_cache_view_iter_fn(void *userdata, if ((cache_type & SEQ_CACHE_STORE_FINAL_OUT) && (drawdata->cache_flag & SEQ_CACHE_VIEW_FINAL_OUT)) { - stripe_ht = UI_view2d_region_to_view_y(v2d, 4.0f * UI_DPI_FAC * U.pixelsize) - v2d->cur.ymin; + stripe_ht = UI_view2d_region_to_view_y(v2d, 4.0f * UI_SCALE_FAC * U.pixelsize) - v2d->cur.ymin; stripe_bot = UI_view2d_region_to_view_y(v2d, V2D_SCROLL_HANDLE_HEIGHT); stripe_top = stripe_bot + stripe_ht; vbo = drawdata->final_out_vbo; @@ -2551,7 +2551,7 @@ static void draw_cache_view(const bContext *C) float stripe_bot, stripe_top; float stripe_ofs_y = UI_view2d_region_to_view_y(v2d, 1.0f) - v2d->cur.ymin; - float stripe_ht = UI_view2d_region_to_view_y(v2d, 4.0f * UI_DPI_FAC * U.pixelsize) - + float stripe_ht = UI_view2d_region_to_view_y(v2d, 4.0f * UI_SCALE_FAC * U.pixelsize) - v2d->cur.ymin; CLAMP_MAX(stripe_ht, 0.2f); diff --git a/source/blender/editors/space_sequencer/sequencer_gizmo_retime_type.cc b/source/blender/editors/space_sequencer/sequencer_gizmo_retime_type.cc index 1b61c7d7987..829c40af23e 100644 --- a/source/blender/editors/space_sequencer/sequencer_gizmo_retime_type.cc +++ b/source/blender/editors/space_sequencer/sequencer_gizmo_retime_type.cc @@ -55,11 +55,11 @@ using blender::MutableSpan; /** Pixels from bottom of strip. */ -#define REMOVE_GIZMO_HEIGHT (14.0f * U.dpi_fac) +#define REMOVE_GIZMO_HEIGHT (14.0f * UI_SCALE_FAC) /** Size in pixels. */ -#define RETIME_HANDLE_TRIANGLE_SIZE (14.0f * U.dpi_fac) +#define RETIME_HANDLE_TRIANGLE_SIZE (14.0f * UI_SCALE_FAC) /** Size in pixels. */ -#define RETIME_HANDLE_MOUSEOVER_THRESHOLD (16.0f * U.dpi_fac) +#define RETIME_HANDLE_MOUSEOVER_THRESHOLD (16.0f * UI_SCALE_FAC) /** Factor based on icon size. */ #define RETIME_BUTTON_SIZE 0.6f @@ -182,8 +182,8 @@ static ButtonDimensions button_dimensions_get(const bContext *C, const RetimeBut const View2D *v2d = UI_view2d_fromcontext(C); const Sequence *seq = active_seq_from_context(C); - const float icon_height = UI_icon_get_height(gizmo->icon_id) * U.dpi_fac; - const float icon_width = UI_icon_get_width(gizmo->icon_id) * U.dpi_fac; + const float icon_height = UI_icon_get_height(gizmo->icon_id) * UI_SCALE_FAC; + const float icon_width = UI_icon_get_width(gizmo->icon_id) * UI_SCALE_FAC; const float icon_x = UI_view2d_view_to_region_x(v2d, BKE_scene_frame_get(scene)) + icon_width / 2; const float icon_y = UI_view2d_view_to_region_y(v2d, strip_y_rescale(seq, 0.5)) - diff --git a/source/blender/editors/space_sequencer/sequencer_thumbnails.c b/source/blender/editors/space_sequencer/sequencer_thumbnails.c index d1606b14152..13e8f109598 100644 --- a/source/blender/editors/space_sequencer/sequencer_thumbnails.c +++ b/source/blender/editors/space_sequencer/sequencer_thumbnails.c @@ -439,7 +439,7 @@ void draw_seq_strip_thumbnail(View2D *v2d, } /* If width of the strip too small ignore drawing thumbnails. */ - if ((y2 - y1) / pixely <= 20 * U.dpi_fac) { + if ((y2 - y1) / pixely <= 20 * UI_SCALE_FAC) { return; } diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 5661208dc15..b345cac7836 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -292,7 +292,7 @@ static void sequencer_refresh(const bContext *C, ScrArea *area) case SEQ_VIEW_SEQUENCE_PREVIEW: if (region_main && region_preview) { /* Get available height (without DPI correction). */ - const float height = (area->winy - ED_area_headersize()) / UI_DPI_FAC; + const float height = (area->winy - ED_area_headersize()) / UI_SCALE_FAC; /* We reuse hidden region's size, allows to find same layout as before if we just switch * between one 'full window' view and the combined one. This gets lost if we switch to both diff --git a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc index b35facd020b..30d15d46106 100644 --- a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc +++ b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc @@ -356,7 +356,7 @@ static float get_column_width(const ColumnValues &values) { float data_width = get_default_column_width(values); const int fontid = UI_style_get()->widget.uifont_id; - BLF_size(fontid, UI_DEFAULT_TEXT_POINTS * U.dpi_fac); + BLF_size(fontid, UI_DEFAULT_TEXT_POINTS * UI_SCALE_FAC); const StringRefNull name = values.name(); const float name_width = BLF_width(fontid, name.data(), name.size()); return std::max(name_width / UI_UNIT_X + 1.0f, data_width); @@ -370,7 +370,7 @@ static float get_column_width_in_pixels(const ColumnValues &values) static int get_index_column_width(const int tot_rows) { const int fontid = UI_style_get()->widget.uifont_id; - BLF_size(fontid, UI_style_get_dpi()->widget.points * U.dpi_fac); + BLF_size(fontid, UI_style_get_dpi()->widget.points * UI_SCALE_FAC); return std::to_string(std::max(0, tot_rows - 1)).size() * BLF_width(fontid, "0", 1) + UI_UNIT_X * 0.75; } diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_draw.cc b/source/blender/editors/space_spreadsheet/spreadsheet_draw.cc index e50e655853f..c199e20f9ca 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_draw.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_draw.cc @@ -13,7 +13,7 @@ #include "spreadsheet_draw.hh" -#define CELL_RIGHT_PADDING (2.0f * UI_DPI_FAC) +#define CELL_RIGHT_PADDING (2.0f * UI_SCALE_FAC) namespace blender::ed::spreadsheet { diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c index 1516435c6fc..45107547b8f 100644 --- a/source/blender/editors/space_userpref/space_userpref.c +++ b/source/blender/editors/space_userpref/space_userpref.c @@ -55,7 +55,7 @@ static SpaceLink *userpref_create(const ScrArea *area, const Scene *UNUSED(scene region->alignment = RGN_ALIGN_LEFT; /* Use smaller size when opened in area like properties editor. */ - if (area->winx && area->winx < 3.0f * UI_NAVIGATION_REGION_WIDTH * UI_DPI_FAC) { + if (area->winx && area->winx < 3.0f * UI_NAVIGATION_REGION_WIDTH * UI_SCALE_FAC) { region->sizex = UI_NARROW_NAVIGATION_REGION_WIDTH; } diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 380a0c47b3e..492282f1433 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -511,7 +511,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float int yi = 200; const float tilt_limit = DEG2RADF(21600.0f); const int butw = 200; - const int buth = 20 * UI_DPI_FAC; + const int buth = 20 * UI_SCALE_FAC; const int but_margin = 2; const char *c; @@ -1210,7 +1210,7 @@ static void v3d_object_dimension_buts(bContext *C, uiLayout *layout, View3D *v3d BLI_assert(C == NULL); int yi = 200; const int butw = 200; - const int buth = 20 * UI_DPI_FAC; + const int buth = 20 * UI_SCALE_FAC; BKE_object_dimensions_get(ob, tfp->ob_dims); copy_v3_v3(tfp->ob_dims_orig, tfp->ob_dims); diff --git a/source/blender/editors/space_view3d/view3d_cursor_snap.c b/source/blender/editors/space_view3d/view3d_cursor_snap.c index 875097b4827..bf32a509dd9 100644 --- a/source/blender/editors/space_view3d/view3d_cursor_snap.c +++ b/source/blender/editors/space_view3d/view3d_cursor_snap.c @@ -320,7 +320,7 @@ static void v3d_cursor_plane_draw(const RegionView3D *rv3d, color_alpha *= max_ff(0.3f, 1.0f - square_f(square_f(1.0f - view_dot))); } - const float scale_mod = U.gizmo_size * 2 * U.dpi_fac / U.pixelsize; + const float scale_mod = U.gizmo_size * 2 * UI_SCALE_FAC / U.pixelsize; float final_scale = (scale_mod * pixel_size); diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c index 35ae745bab3..f58f39d87a2 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c @@ -250,8 +250,8 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *g const bool show_navigate = (U.uiflag & USER_SHOW_GIZMO_NAVIGATE) != 0; const bool show_rotate_gizmo = (U.mini_axis_type == USER_MINI_AXIS_TYPE_GIZMO); - const float icon_offset = ((GIZMO_SIZE / 2.0f) + GIZMO_OFFSET) * UI_DPI_FAC; - const float icon_offset_mini = (GIZMO_MINI_SIZE + GIZMO_MINI_OFFSET) * UI_DPI_FAC; + const float icon_offset = ((GIZMO_SIZE / 2.0f) + GIZMO_OFFSET) * UI_SCALE_FAC; + const float icon_offset_mini = (GIZMO_MINI_SIZE + GIZMO_MINI_OFFSET) * UI_SCALE_FAC; const float co_rotate[2] = { rect_visible->xmax - icon_offset, rect_visible->ymax - icon_offset, diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c index 70afb0eaff1..7b811594cb5 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c @@ -42,7 +42,7 @@ #include "view3d_intern.h" /* Radius of the entire background. */ -#define WIDGET_RADIUS ((U.gizmo_size_navigate_v3d / 2.0f) * UI_DPI_FAC) +#define WIDGET_RADIUS ((U.gizmo_size_navigate_v3d / 2.0f) * UI_SCALE_FAC) /* Sizes of axis spheres containing XYZ characters in relation to above. */ #define AXIS_HANDLE_SIZE 0.20f diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c index 765a3d01405..fd940470cc1 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c @@ -621,9 +621,9 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) RulerItem *ruler_item = (RulerItem *)gz; ARegion *region = ruler_info->region; RegionView3D *rv3d = region->regiondata; - const float cap_size = 4.0f * U.dpi_fac; - const float bg_margin = 4.0f * U.dpi_fac; - const float arc_size = 64.0f * U.dpi_fac; + const float cap_size = 4.0f * UI_SCALE_FAC; + const float bg_margin = 4.0f * UI_SCALE_FAC; + const float arc_size = 64.0f * UI_SCALE_FAC; #define ARC_STEPS 24 const int arc_steps = ARC_STEPS; const float color_act[4] = {1.0f, 1.0f, 1.0f, 1.0f}; @@ -643,7 +643,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) GPU_line_width(1.0f); BLF_enable(blf_mono_font, BLF_ROTATION); - BLF_size(blf_mono_font, 14.0f * U.dpi_fac); + BLF_size(blf_mono_font, 14.0f * UI_SCALE_FAC); BLF_rotation(blf_mono_font, 0.0f); UI_GetThemeColor3ubv(TH_TEXT, color_text); diff --git a/source/blender/editors/space_view3d/view3d_navigate_rotate.c b/source/blender/editors/space_view3d/view3d_navigate_rotate.c index 446a1e929c1..b1971dda4e8 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_rotate.c +++ b/source/blender/editors/space_view3d/view3d_navigate_rotate.c @@ -234,7 +234,7 @@ static void viewrotate_apply(ViewOpsData *vod, const int event_xy[2]) float xaxis[3]; /* Radians per-pixel. */ - const float sensitivity = U.view_rotate_sensitivity_turntable / U.dpi_fac; + const float sensitivity = U.view_rotate_sensitivity_turntable / UI_SCALE_FAC; /* Get the 3x3 matrix and its inverse from the quaternion */ quat_to_mat3(m, vod->curr.viewquat); diff --git a/source/blender/editors/space_view3d/view3d_navigate_zoom.c b/source/blender/editors/space_view3d/view3d_navigate_zoom.c index 51aab367959..f766e4a454f 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_zoom.c +++ b/source/blender/editors/space_view3d/view3d_navigate_zoom.c @@ -199,7 +199,7 @@ static float viewzoom_scale_value(const rcti *winrct, fac = (float)(xy_init[1] - xy_curr[1]); } - fac /= U.dpi_fac; + fac /= UI_SCALE_FAC; if (zoom_invert != zoom_invert_force) { fac = -fac; @@ -215,8 +215,8 @@ static float viewzoom_scale_value(const rcti *winrct, BLI_rcti_cent_x(winrct), BLI_rcti_cent_y(winrct), }; - float len_new = (5 * U.dpi_fac) + ((float)len_v2v2_int(ctr, xy_curr) / U.dpi_fac); - float len_old = (5 * U.dpi_fac) + ((float)len_v2v2_int(ctr, xy_init) / U.dpi_fac); + float len_new = (5 * UI_SCALE_FAC) + ((float)len_v2v2_int(ctr, xy_curr) / UI_SCALE_FAC); + float len_old = (5 * UI_SCALE_FAC) + ((float)len_v2v2_int(ctr, xy_init) / UI_SCALE_FAC); /* intentionally ignore 'zoom_invert' for scale */ if (zoom_invert_force) { @@ -226,16 +226,16 @@ static float viewzoom_scale_value(const rcti *winrct, zfac = val_orig * (len_old / max_ff(len_new, 1.0f)) / val; } else { /* USER_ZOOM_DOLLY */ - float len_new = 5 * U.dpi_fac; - float len_old = 5 * U.dpi_fac; + float len_new = 5 * UI_SCALE_FAC; + float len_old = 5 * UI_SCALE_FAC; if (U.uiflag & USER_ZOOM_HORIZ) { - len_new += (winrct->xmax - (xy_curr[0])) / U.dpi_fac; - len_old += (winrct->xmax - (xy_init[0])) / U.dpi_fac; + len_new += (winrct->xmax - (xy_curr[0])) / UI_SCALE_FAC; + len_old += (winrct->xmax - (xy_init[0])) / UI_SCALE_FAC; } else { - len_new += (winrct->ymax - (xy_curr[1])) / U.dpi_fac; - len_old += (winrct->ymax - (xy_init[1])) / U.dpi_fac; + len_new += (winrct->ymax - (xy_curr[1])) / UI_SCALE_FAC; + len_old += (winrct->ymax - (xy_init[1])) / UI_SCALE_FAC; } if (zoom_invert != zoom_invert_force) { diff --git a/source/blender/editors/space_view3d/view3d_select.cc b/source/blender/editors/space_view3d/view3d_select.cc index 0044a325ed8..1a17d44255a 100644 --- a/source/blender/editors/space_view3d/view3d_select.cc +++ b/source/blender/editors/space_view3d/view3d_select.cc @@ -2316,7 +2316,7 @@ static Base *mouse_select_object_center(ViewContext *vc, Base *startbase, const Base *basact = nullptr; /* Put the active object at a disadvantage to cycle through other objects. */ - const float penalty_dist = 10.0f * UI_DPI_FAC; + const float penalty_dist = 10.0f * UI_SCALE_FAC; Base *base = startbase; while (base) { if (BASE_SELECTABLE(v3d, base)) { diff --git a/source/blender/editors/transform/transform_convert_node.cc b/source/blender/editors/transform/transform_convert_node.cc index 13095ff6f5a..83a54c9f9ed 100644 --- a/source/blender/editors/transform/transform_convert_node.cc +++ b/source/blender/editors/transform/transform_convert_node.cc @@ -142,7 +142,7 @@ static void createTransNodeData(bContext * /*C*/, TransInfo *t) tc->data_2d = MEM_cnew_array(tc->data_len, __func__); for (const int i : nodes.index_range()) { - create_transform_data_for_node(tc->data[i], tc->data_2d[i], *nodes[i], UI_DPI_FAC); + create_transform_data_for_node(tc->data[i], tc->data_2d[i], *nodes[i], UI_SCALE_FAC); } } @@ -197,7 +197,7 @@ static void node_snap_grid_apply(TransInfo *t) static void flushTransNodes(TransInfo *t) { using namespace blender::ed; - const float dpi_fac = UI_DPI_FAC; + const float dpi_fac = UI_SCALE_FAC; SpaceNode *snode = static_cast(t->area->spacedata.first); TransCustomDataNode *customdata = (TransCustomDataNode *)t->custom.type.data; diff --git a/source/blender/editors/transform/transform_draw_cursors.c b/source/blender/editors/transform/transform_draw_cursors.c index 0cec6e7943b..b76cfce7e96 100644 --- a/source/blender/editors/transform/transform_draw_cursors.c +++ b/source/blender/editors/transform/transform_draw_cursors.c @@ -35,9 +35,9 @@ enum eArrowDirection { static void drawArrow(const uint pos_id, const enum eArrowDirection dir) { - int offset = 5.0f * UI_DPI_FAC; - int length = (6.0f * UI_DPI_FAC) + (4.0f * U.pixelsize); - int size = (3.0f * UI_DPI_FAC) + (2.0f * U.pixelsize); + int offset = 5.0f * UI_SCALE_FAC; + int length = (6.0f * UI_SCALE_FAC) + (4.0f * U.pixelsize); + int size = (3.0f * UI_SCALE_FAC) + (2.0f * U.pixelsize); /* To line up the arrow point nicely, one end has to be extended by half its width. But * being on a 45 degree angle, Pythagoras says a movement of sqrt(2)/2 * (line width /2) */ diff --git a/source/blender/editors/util/ed_draw.c b/source/blender/editors/util/ed_draw.c index 1eacb7a2045..bc091a77aa1 100644 --- a/source/blender/editors/util/ed_draw.c +++ b/source/blender/editors/util/ed_draw.c @@ -53,7 +53,7 @@ * #ED_slider_destroy. * \{ */ -#define SLIDE_PIXEL_DISTANCE (300.0f * U.dpi_fac) +#define SLIDE_PIXEL_DISTANCE (300.0f * UI_SCALE_FAC) #define OVERSHOOT_RANGE_DELTA 0.2f typedef struct tSlider { @@ -571,7 +571,7 @@ void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *region, void *arg_ float viewport_size[4]; GPU_viewport_size_get_f(viewport_size); - immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); + immUniform2f("viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC); immUniform1i("colors_len", 0); /* "simple" mode */ immUniformThemeColor3(TH_VIEW_OVERLAY); @@ -819,7 +819,7 @@ void ED_region_image_metadata_draw( GPU_matrix_translate_2f(x, y); GPU_matrix_scale_2f(zoomx, zoomy); - BLF_size(blf_mono_font, style->widgetlabel.points * U.dpi_fac); + BLF_size(blf_mono_font, style->widgetlabel.points * UI_SCALE_FAC); /* *** upper box*** */ diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 7c59c6b5a45..ea8aa543f23 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -28,7 +28,7 @@ void ED_image_draw_cursor(ARegion *region, const float cursor[2]) UI_view2d_scale_get_inverse(®ion->v2d, &zoom[0], &zoom[1]); - mul_v2_fl(zoom, 256.0f * UI_DPI_FAC); + mul_v2_fl(zoom, 256.0f * UI_SCALE_FAC); x_fac = zoom[0]; y_fac = zoom[1]; @@ -43,7 +43,7 @@ void ED_image_draw_cursor(ARegion *region, const float cursor[2]) float viewport_size[4]; GPU_viewport_size_get_f(viewport_size); - immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); + immUniform2f("viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC); immUniform1i("colors_len", 2); /* "advanced" mode */ immUniform4f("color", 1.0f, 0.0f, 0.0f, 1.0f); diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index fb2aef28551..cc7360ae6a4 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -470,7 +470,7 @@ typedef struct ARegion { short flag; /** Current split size in unscaled pixels (if zero it uses regiontype). - * To convert to pixels use: `UI_DPI_FAC * region->sizex + 0.5f`. + * To convert to pixels use: `UI_SCALE_FAC * region->sizex + 0.5f`. * However to get the current region size, you should usually use winx/winy from above, not this! */ short sizex, sizey; diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 1affd36e95a..5b0e9c166df 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -15,6 +15,20 @@ extern "C" { #endif +/** + * Scaling factor for all UI elements, based on the "Resolution Scale" user preference and the + * DPI/OS Scale of each monitor. This is a read-only, run-time value calculated by + * `WM_window_set_dpi` at various times, including between the drawing of each window and so can + * vary between monitors. + */ +#define UI_SCALE_FAC ((void)0, U.scale_factor) + +/* Inverse of UI_SCALE_FAC ( 1 / UI_SCALE_FAC). */ +#define UI_INV_SCALE_FAC ((void)0, U.inv_scale_factor) + +/* 16 to copy ICON_DEFAULT_HEIGHT */ +#define UI_ICON_SIZE ((float)16 * U.scale_factor) + /* Themes; defines in `BIF_resource.h`. */ struct ColorBand; @@ -747,10 +761,10 @@ typedef struct UserDef { int ui_line_width; /** Runtime, full DPI divided by `pixelsize`. */ int dpi; - /** Runtime, multiplier to scale UI elements based on DPI (fractional). */ - float dpi_fac; - /** Runtime, `1.0 / dpi_fac` */ - float inv_dpi_fac; + /** Runtime multiplier to scale UI elements. Use macro UI_SCALE_FAC instead of this. */ + float scale_factor; + /** Runtime, `1.0 / scale_factor` */ + float inv_scale_factor; /** Runtime, calculated from line-width and point-size based on DPI (rounded to int). */ float pixelsize; /** Deprecated, for forward compatibility. */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 3077463e5cc..5fb55eb6f20 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2624,8 +2624,8 @@ static void rna_SpaceNodeEditor_cursor_location_from_region(SpaceNode *snode, float cursor_location[2]; UI_view2d_region_to_view(®ion->v2d, x, y, &cursor_location[0], &cursor_location[1]); - cursor_location[0] /= UI_DPI_FAC; - cursor_location[1] /= UI_DPI_FAC; + cursor_location[0] /= UI_SCALE_FAC; + cursor_location[1] /= UI_SCALE_FAC; ED_node_cursor_location_set(snode, cursor_location); } diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 04283d1395a..364ac8dbdd2 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -5497,7 +5497,7 @@ static void rna_def_userdef_system(BlenderRNA *brna) prop = RNA_def_property(srna, "ui_scale", PROP_FLOAT, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_float_sdna(prop, NULL, "dpi_fac"); + RNA_def_property_float_sdna(prop, NULL, "ui_scale"); RNA_def_property_ui_text( prop, "UI Scale", diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index c681049c4b7..bb3a18dad5f 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -187,7 +187,7 @@ int WM_window_pixels_y(const struct wmWindow *win); void WM_window_rect_calc(const struct wmWindow *win, struct rcti *r_rect); /** * Get boundaries usable by screen-layouts, excluding global areas. - * \note Depends on #U.dpi_fac. Should that be outdated, call #WM_window_set_dpi first. + * \note Depends on #UI_SCALE_FAC. Should that be outdated, call #WM_window_set_dpi first. */ void WM_window_screen_rect_calc(const struct wmWindow *win, struct rcti *r_rect); bool WM_window_is_fullscreen(const struct wmWindow *win); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 6cea9719d2d..39273ac7538 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -767,7 +767,7 @@ typedef struct wmEvent { * * Always check for <= this value since it may be zero. */ -#define WM_EVENT_CURSOR_MOTION_THRESHOLD ((float)U.move_threshold * U.dpi_fac) +#define WM_EVENT_CURSOR_MOTION_THRESHOLD ((float)U.move_threshold * UI_SCALE_FAC) /** Motion progress, for modal handlers. */ typedef enum { diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c index 9d212798f39..f503a089b76 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c @@ -453,7 +453,7 @@ void WM_gizmo_modal_set_while_modal(struct wmGizmoMap *gzmap, void wm_gizmo_calculate_scale(wmGizmo *gz, const bContext *C) { const RegionView3D *rv3d = CTX_wm_region_view3d(C); - float scale = UI_DPI_FAC; + float scale = UI_SCALE_FAC; if ((gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_SCALE) == 0) { scale *= U.gizmo_size; diff --git a/source/blender/windowmanager/intern/wm_dragdrop.cc b/source/blender/windowmanager/intern/wm_dragdrop.cc index aec761da5ff..e9ae895c4da 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.cc +++ b/source/blender/windowmanager/intern/wm_dragdrop.cc @@ -884,13 +884,13 @@ static void wm_drag_draw_icon(bContext * /*C*/, wmWindow * /*win*/, wmDrag *drag col); } else { - int padding = 4 * UI_DPI_FAC; + int padding = 4 * UI_SCALE_FAC; x = xy[0] - 2 * padding; - y = xy[1] - 2 * UI_DPI_FAC; + y = xy[1] - 2 * UI_SCALE_FAC; const uchar text_col[] = {255, 255, 255, 255}; UI_icon_draw_ex( - x, y, drag->icon, U.inv_dpi_fac, 0.8, 0.0f, text_col, false, UI_NO_ICON_OVERLAY_TEXT); + x, y, drag->icon, UI_INV_SCALE_FAC, 0.8, 0.0f, text_col, false, UI_NO_ICON_OVERLAY_TEXT); } } @@ -903,8 +903,8 @@ static void wm_drag_draw_item_name(wmDrag *drag, const int x, const int y) void WM_drag_draw_item_name_fn(bContext * /*C*/, wmWindow * /*win*/, wmDrag *drag, const int xy[2]) { - int x = xy[0] + 10 * UI_DPI_FAC; - int y = xy[1] + 1 * UI_DPI_FAC; + int x = xy[0] + 10 * UI_SCALE_FAC; + int y = xy[1] + 1 * UI_SCALE_FAC; wm_drag_draw_item_name(drag, x, y); } @@ -915,8 +915,8 @@ static void wm_drag_draw_tooltip(bContext *C, wmWindow *win, wmDrag *drag, const /* Some callbacks require the region. */ return; } - int iconsize = UI_DPI_ICON_SIZE; - int padding = 4 * UI_DPI_FAC; + int iconsize = UI_ICON_SIZE; + int padding = 4 * UI_SCALE_FAC; char *tooltip = nullptr; if (drag->drop_state.active_dropbox) { @@ -973,13 +973,13 @@ static void wm_drag_draw_default(bContext *C, wmWindow *win, wmDrag *drag, const /* Item name. */ if (drag->imb) { - int iconsize = UI_DPI_ICON_SIZE; + int iconsize = UI_ICON_SIZE; xy_tmp[0] = xy[0] - (wm_drag_imbuf_icon_width_get(drag) / 2); xy_tmp[1] = xy[1] - (wm_drag_imbuf_icon_height_get(drag) / 2) - iconsize; } else { - xy_tmp[0] = xy[0] + 10 * UI_DPI_FAC; - xy_tmp[1] = xy[1] + 1 * UI_DPI_FAC; + xy_tmp[0] = xy[0] + 10 * UI_SCALE_FAC; + xy_tmp[1] = xy[1] + 1 * UI_SCALE_FAC; } wm_drag_draw_item_name(drag, UNPACK2(xy_tmp)); diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 15707553e9d..1e0002a4f11 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -291,7 +291,7 @@ static void wm_software_cursor_draw_crosshair(const int event_xy[2]) /* Draw a primitive cross-hair cursor. * NOTE: the `win->cursor` could be used for drawing although it's complicated as some cursors * are set by the operating-system, where the pixel information isn't easily available. */ - const float unit = max_ff(U.dpi_fac, 1.0f); + const float unit = max_ff(UI_SCALE_FAC, 1.0f); uint pos = GPU_vertformat_attr_add( immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); diff --git a/source/blender/windowmanager/intern/wm_event_query.c b/source/blender/windowmanager/intern/wm_event_query.c index 2e1afe808ad..8cf736c4a84 100644 --- a/source/blender/windowmanager/intern/wm_event_query.c +++ b/source/blender/windowmanager/intern/wm_event_query.c @@ -362,7 +362,7 @@ int WM_event_drag_threshold(const struct wmEvent *event) /* Typically keyboard, could be NDOF button or other less common types. */ drag_threshold = U.drag_threshold; } - return drag_threshold * U.dpi_fac; + return drag_threshold * UI_SCALE_FAC; } bool WM_event_drag_test_with_delta(const wmEvent *event, const int drag_delta[2]) diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc index 5042ad1c1ee..ed91abf9d8e 100644 --- a/source/blender/windowmanager/intern/wm_event_system.cc +++ b/source/blender/windowmanager/intern/wm_event_system.cc @@ -2643,8 +2643,8 @@ static eHandlerActionFlag wm_handler_fileselect_do(bContext *C, IFACE_("Blender File View"), WM_window_pixels_x(win) / 2, WM_window_pixels_y(win) / 2, - U.file_space_data.temp_win_sizex * UI_DPI_FAC, - U.file_space_data.temp_win_sizey * UI_DPI_FAC, + U.file_space_data.temp_win_sizex * UI_SCALE_FAC, + U.file_space_data.temp_win_sizey * UI_SCALE_FAC, SPACE_FILE, U.filebrowser_display_type, true))) { diff --git a/source/blender/windowmanager/intern/wm_files.cc b/source/blender/windowmanager/intern/wm_files.cc index 76062b516b2..8f9e8d81142 100644 --- a/source/blender/windowmanager/intern/wm_files.cc +++ b/source/blender/windowmanager/intern/wm_files.cc @@ -3553,7 +3553,7 @@ static uiBlock *block_create_autorun_warning(struct bContext *C, UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); UI_but_flag_enable(but, UI_BUT_ACTIVE_DEFAULT); - UI_block_bounds_set_centered(block, 14 * U.dpi_fac); + UI_block_bounds_set_centered(block, 14 * UI_SCALE_FAC); return block; } @@ -3892,7 +3892,7 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C, wm_block_file_close_save_button(block, post_action); } - UI_block_bounds_set_centered(block, 14 * U.dpi_fac); + UI_block_bounds_set_centered(block, 14 * UI_SCALE_FAC); return block; } diff --git a/source/blender/windowmanager/intern/wm_gesture_ops.c b/source/blender/windowmanager/intern/wm_gesture_ops.c index 83ecad59012..c6918f302ab 100644 --- a/source/blender/windowmanager/intern/wm_gesture_ops.c +++ b/source/blender/windowmanager/intern/wm_gesture_ops.c @@ -580,7 +580,7 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event) } /* Make a simple distance check to get a smoother lasso * add only when at least 2 pixels between this and previous location. */ - else if ((x * x + y * y) > pow2f(2.0f * UI_DPI_FAC)) { + else if ((x * x + y * y) > pow2f(2.0f * UI_SCALE_FAC)) { lasso[gesture->points][0] = event->xy[0] - gesture->winrct.xmin; lasso[gesture->points][1] = event->xy[1] - gesture->winrct.ymin; gesture->points++; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index df1555dfdd7..39d0f0cf843 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1411,7 +1411,7 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *region, void *arg_op) uiTemplateOperatorPropertyButs( C, col, op, UI_BUT_LABEL_ALIGN_NONE, UI_TEMPLATE_OP_PROPS_SHOW_TITLE); - UI_block_bounds_set_popup(block, 6 * U.dpi_fac, NULL); + UI_block_bounds_set_popup(block, 6 * UI_SCALE_FAC, NULL); return block; } @@ -1486,7 +1486,7 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *region, void *userD /* center around the mouse */ UI_block_bounds_set_popup( - block, 6 * U.dpi_fac, (const int[2]){data->width / -2, data->height / 2}); + block, 6 * UI_SCALE_FAC, (const int[2]){data->width / -2, data->height / 2}); return block; } @@ -1510,7 +1510,7 @@ static uiBlock *wm_operator_ui_create(bContext *C, ARegion *region, void *userDa UI_block_func_set(block, NULL, NULL, NULL); - UI_block_bounds_set_popup(block, 6 * U.dpi_fac, NULL); + UI_block_bounds_set_popup(block, 6 * UI_SCALE_FAC, NULL); return block; } @@ -1549,7 +1549,7 @@ int WM_operator_ui_popup(bContext *C, wmOperator *op, int width) { wmOpPopUp *data = MEM_callocN(sizeof(wmOpPopUp), "WM_operator_ui_popup"); data->op = op; - data->width = width * U.dpi_fac; + data->width = width * UI_SCALE_FAC; /* Actual used height depends on the content. */ data->height = 0; data->free_op = true; /* if this runs and gets registered we may want not to free it */ @@ -1619,7 +1619,7 @@ int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width) wmOpPopUp *data = MEM_callocN(sizeof(wmOpPopUp), "WM_operator_props_dialog_popup"); data->op = op; - data->width = width * U.dpi_fac; + data->width = width * UI_SCALE_FAC; /* Actual height depends on the content. */ data->height = 0; data->free_op = true; /* if this runs and gets registered we may want not to free it */ @@ -2173,8 +2173,8 @@ void WM_paint_cursor_remove_by_type(wmWindowManager *wm, void *draw_fn, void (*f /** \name Radial Control Operator * \{ */ -#define WM_RADIAL_CONTROL_DISPLAY_SIZE (200 * UI_DPI_FAC) -#define WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE (35 * UI_DPI_FAC) +#define WM_RADIAL_CONTROL_DISPLAY_SIZE (200 * UI_SCALE_FAC) +#define WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE (35 * UI_SCALE_FAC) #define WM_RADIAL_CONTROL_DISPLAY_WIDTH \ (WM_RADIAL_CONTROL_DISPLAY_SIZE - WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE) #define WM_RADIAL_MAX_STR 10 @@ -2558,7 +2558,7 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void immUnbindProgram(); - BLF_size(fontid, 1.75f * fstyle_points * U.dpi_fac); + BLF_size(fontid, 1.75f * fstyle_points * UI_SCALE_FAC); UI_GetThemeColor4fv(TH_TEXT_HI, text_color); BLF_color4fv(fontid, text_color); diff --git a/source/blender/windowmanager/intern/wm_splash_screen.c b/source/blender/windowmanager/intern/wm_splash_screen.c index 1bcd51ed9c7..abe8161f798 100644 --- a/source/blender/windowmanager/intern/wm_splash_screen.c +++ b/source/blender/windowmanager/intern/wm_splash_screen.c @@ -83,7 +83,7 @@ static void wm_block_splash_image_roundcorners_add(ImBuf *ibuf) } bTheme *btheme = UI_GetTheme(); - const float roundness = btheme->tui.wcol_menu_back.roundness * U.dpi_fac; + const float roundness = btheme->tui.wcol_menu_back.roundness * UI_SCALE_FAC; const int size = roundness * 20; if (size < ibuf->x && size < ibuf->y) { @@ -184,7 +184,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *region, void *UNUSE UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP); const int text_points_max = MAX2(style->widget.points, style->widgetlabel.points); - int splash_width = text_points_max * 45 * U.dpi_fac; + int splash_width = text_points_max * 45 * UI_SCALE_FAC; CLAMP_MAX(splash_width, CTX_wm_window(C)->sizex * 0.7f); int splash_height; @@ -199,17 +199,17 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *region, void *UNUSE wm_block_splash_add_label(block, BKE_blender_version_string(), - splash_width - 8.0 * U.dpi_fac, - splash_height - 13.0 * U.dpi_fac); + splash_width - 8.0 * UI_SCALE_FAC, + splash_height - 13.0 * UI_SCALE_FAC); - const int layout_margin_x = U.dpi_fac * 26; + const int layout_margin_x = UI_SCALE_FAC * 26; uiLayout *layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, layout_margin_x, 0, splash_width - (layout_margin_x * 2), - U.dpi_fac * 110, + UI_SCALE_FAC * 110, 0, style); @@ -263,7 +263,7 @@ static uiBlock *wm_block_create_about(bContext *C, ARegion *region, void *UNUSED { 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 * 42 * U.dpi_fac; + const int dialog_width = text_points_max * 42 * UI_SCALE_FAC; uiBlock *block = UI_block_begin(C, region, "about", UI_EMBOSS); @@ -317,7 +317,7 @@ static uiBlock *wm_block_create_about(bContext *C, ARegion *region, void *UNUSED UI_menutype_draw(C, mt, col); } - UI_block_bounds_set_centered(block, 22 * U.dpi_fac); + UI_block_bounds_set_centered(block, 22 * UI_SCALE_FAC); return block; } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index ad146c0e393..5d89e209301 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -518,12 +518,12 @@ void WM_window_set_dpi(const wmWindow *win) /* Set user preferences globals for drawing, and for forward compatibility. */ U.pixelsize = pixelsize; U.virtual_pixel = (pixelsize == 1) ? VIRTUAL_PIXEL_NATIVE : VIRTUAL_PIXEL_DOUBLE; - U.dpi_fac = U.dpi / 72.0f; - U.inv_dpi_fac = 1.0f / U.dpi_fac; + U.scale_factor = U.dpi / 72.0f; + U.inv_scale_factor = 1.0f / U.scale_factor; /* Widget unit is 20 pixels at 1X scale. This consists of 18 user-scaled units plus * left and right borders of line-width (pixel-size). */ - U.widget_unit = (int)roundf(18.0f * U.dpi_fac) + (2 * pixelsize); + U.widget_unit = (int)roundf(18.0f * U.scale_factor) + (2 * pixelsize); } /** @@ -1778,7 +1778,7 @@ static uiBlock *block_create_opengl_usage_warning(struct bContext *C, uiItemS(layout); - UI_block_bounds_set_centered(block, 14 * U.dpi_fac); + UI_block_bounds_set_centered(block, 14 * UI_SCALE_FAC); return block; }