main sync #3

Merged
Patrick Busch merged 318 commits from blender/blender:main into main 2023-03-17 15:52:21 +01:00
112 changed files with 482 additions and 453 deletions
Showing only changes of commit f78f05c749 - Show all commits

View File

@ -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,

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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<ViewCachedString *>(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. */

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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,

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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];

View File

@ -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)

View File

@ -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)
/** \} */

View File

@ -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<const uiBut *>(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<uiBut *>(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 +

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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)

View File

@ -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();

View File

@ -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];

View File

@ -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);

View File

@ -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. */

View File

@ -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 = &region->v2d;
if (region->flag & RGN_FLAG_SIZE_CLAMP_X) {

View File

@ -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) {

View File

@ -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;

View File

@ -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 {

View File

@ -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);
}

View File

@ -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,

View File

@ -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');

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -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)

View File

@ -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)),

View File

@ -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. */

View File

@ -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

View File

@ -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();

View File

@ -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);
}

View File

@ -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);

View File

@ -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) {

View File

@ -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(&region->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<Panel *>(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 */
}

View File

@ -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);

View File

@ -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)

View File

@ -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? */

View File

@ -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 */

View File

@ -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! */

View File

@ -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);

View File

@ -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)

View File

@ -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;

View File

@ -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);

View File

@ -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 */

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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
}

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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,

View File

@ -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 = &region->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};

View File

@ -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);

View File

@ -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;

View File

@ -1675,8 +1675,8 @@ void node_link_bezier_points_evaluated(const Span<float2> 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<float2, 4> 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<float2, 4> points;
points[0] = link.fromsock ?
socket_link_connection_location(node_tree.runtime->all_socket_locations,

View File

@ -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;
}

View File

@ -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")) {

View File

@ -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 &region)
const rcti *rect = ED_region_visible_rect(&region);
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 &region)
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, &region, REGION_DRAW_PRE_VIEW);

View File

@ -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(&region->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;

View File

@ -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

View File

@ -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 &region, 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));

View File

@ -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;

View File

@ -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. */

View File

@ -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;
}

View File

@ -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;

View File

@ -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);

View File

@ -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)) -

View File

@ -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;
}

View File

@ -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

View File

@ -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<float>(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;
}

View File

@ -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 {

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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,

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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) {

View File

@ -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)) {

View File

@ -142,7 +142,7 @@ static void createTransNodeData(bContext * /*C*/, TransInfo *t)
tc->data_2d = MEM_cnew_array<TransData2D>(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<SpaceNode *>(t->area->spacedata.first);
TransCustomDataNode *customdata = (TransCustomDataNode *)t->custom.type.data;

View File

@ -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) */

View File

@ -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*** */

View File

@ -28,7 +28,7 @@ void ED_image_draw_cursor(ARegion *region, const float cursor[2])
UI_view2d_scale_get_inverse(&region->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);

View File

@ -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;

View File

@ -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. */

View File

@ -2624,8 +2624,8 @@ static void rna_SpaceNodeEditor_cursor_location_from_region(SpaceNode *snode,
float cursor_location[2];
UI_view2d_region_to_view(&region->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);
}

View File

@ -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",

Some files were not shown because too many files have changed in this diff Show More