diff --git a/source/blender/editors/armature/pose_slide.cc b/source/blender/editors/armature/pose_slide.cc index 75076890659..1768b8ad5a6 100644 --- a/source/blender/editors/armature/pose_slide.cc +++ b/source/blender/editors/armature/pose_slide.cc @@ -72,10 +72,6 @@ using blender::Vector; -/* Pixel distance from 0% to 100%. */ -#define SLIDE_PIXEL_DISTANCE (300 * U.pixelsize) -#define OVERSHOOT_RANGE_DELTA 0.2f - /* **************************************************** */ /* A) Push & Relax, Breakdowner */ diff --git a/source/blender/editors/screen/screen_ops.cc b/source/blender/editors/screen/screen_ops.cc index 20c82f949fc..1a8b5251131 100644 --- a/source/blender/editors/screen/screen_ops.cc +++ b/source/blender/editors/screen/screen_ops.cc @@ -4182,9 +4182,10 @@ static void area_join_update_data(bContext *C, sAreaJoinData *jd, const wmEvent jd->dock_target = area_docking_target(jd, event); if (jd->sa1 == area) { + const int drag_threshold = 30 * UI_SCALE_FAC; jd->sa2 = area; - if (!(abs(jd->start_x - event->xy[0]) > (30 * U.pixelsize) || - abs(jd->start_y - event->xy[1]) > (30 * U.pixelsize))) + if (!(abs(jd->start_x - event->xy[0]) > drag_threshold || + abs(jd->start_y - event->xy[1]) > drag_threshold)) { /* We haven't moved enough to start a split. */ jd->dir = SCREEN_DIR_NONE; diff --git a/source/blender/editors/space_view3d/view3d_draw.cc b/source/blender/editors/space_view3d/view3d_draw.cc index 25eb3990e75..4df699bb6cb 100644 --- a/source/blender/editors/space_view3d/view3d_draw.cc +++ b/source/blender/editors/space_view3d/view3d_draw.cc @@ -959,7 +959,7 @@ float ED_view3d_grid_view_scale(const Scene *scene, static void draw_view_axis(RegionView3D *rv3d, const rcti *rect) { - const float k = U.rvisize * U.pixelsize; /* axis size */ + const float k = U.rvisize * UI_SCALE_FAC; /* axis size */ /* axis alpha offset (rvibright has range 0-10) */ const int bright = -20 * (10 - U.rvibright); diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 8eab65964f4..39211be29af 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -876,7 +876,12 @@ typedef struct UserDef { /** Setting for UI scale (fractional), before screen DPI has been applied. */ float ui_scale; - /** Setting for UI line width. */ + /** + * Setting for UI line width. + * + * In most cases this should not be used directly it is an offset used to calculate `pixelsize` + * which should be used to define the line width. + */ int ui_line_width; /** Runtime, full DPI divided by `pixelsize`. */ int dpi; @@ -884,7 +889,18 @@ typedef struct UserDef { 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). */ + /** + * Runtime, calculated from line-width and point-size based on DPI. + * + * - Rounded down to an integer, clamped to a minimum of 1.0. + * - This includes both the UI scale and windowing system's DPI. + * so a HI-DPI display of 200% with a UI scale of 3.0 results in a pixel-size of 6.0 + * (when the line-width is set to auto). + * - The line-width is added to this value, so lines & vertex drawing can be adjusted. + * + * \note This should never be used as a UI scale value otherwise changing the line-width + * could double or halve the size of UI elements. Use #UI_SCALE_FAC instead. + */ float pixelsize; /** Deprecated, for forward compatibility. */ int virtual_pixel; diff --git a/source/blender/windowmanager/intern/wm_draw.cc b/source/blender/windowmanager/intern/wm_draw.cc index 3278068bc12..cc51572801c 100644 --- a/source/blender/windowmanager/intern/wm_draw.cc +++ b/source/blender/windowmanager/intern/wm_draw.cc @@ -253,7 +253,7 @@ static void wm_software_cursor_draw_bitmap(const int event_xy[2], GPU_matrix_push(); - const int scale = int(U.pixelsize); + const int scale = std::max(1, round_fl_to_int(UI_SCALE_FAC)); unit_m4(gl_matrix); diff --git a/source/blender/windowmanager/intern/wm_gesture.cc b/source/blender/windowmanager/intern/wm_gesture.cc index ffe621b214c..97adfbc11be 100644 --- a/source/blender/windowmanager/intern/wm_gesture.cc +++ b/source/blender/windowmanager/intern/wm_gesture.cc @@ -138,7 +138,7 @@ static void wm_gesture_draw_line_active_side(const rcti *rect, const bool flip) GPU_blend(GPU_BLEND_ALPHA); immBindBuiltinProgram(GPU_SHADER_3D_SMOOTH_COLOR); - const float gradient_length = 150.0f * U.pixelsize; + const float gradient_length = 150.0f * UI_SCALE_FAC; float line_dir[2]; float gradient_dir[2]; float gradient_point[2][2];