Refactor: U.dpi_fac -> U.scale_factor #105750

Merged
Harley Acheson merged 3 commits from Harley/blender:DpiFac into main 2023-03-17 04:19:17 +01:00
Member

A renaming of UI scale factors from names that imply a relationship to
monitor DPI to names that imply that they simply change "scale"


This is a disruptive change request that should be considered carefully. When posted on Phab Brecht approved it, but I still worry that this is a big change just because "Harley doesn't like a word".

With the last release we changed U.dpi so that it contains actual monitor DPI and is no longer scaled by line width. This might be a time to consider changing other UI variable names to be less confusing as well. The term "dpi_fac" has always seemed a bit odd to me as its not really related to DPI and "fac" is a clumsy shortening of factor. My hope is the following makes it all a bit less confusing for new developers.

This PR first renames the following:

  • U.dpi_fac 🡒 U.scale_factor
  • U.inv_dpi_fac 🡒 U.inv_scale_factor
  • UI_DPI_FAC 🡒 UI_SCALE_FAC
  • UI_DPI_ICON_SIZE 🡒 UI_ICON_SIZE

Then ALL current uses of U.scale_factor are changed to instead use the macro UI_SCALE_FAC, making it easier to move or change this later. And all uses of U.inv_scale_factor use macro UI_INV_SCALE_FAC. Our current code contains a mixture of U.dpi_fac and UI_DPI_FAC, often in the same file.

A review item that was previously "Not Done" is completed here. Campbell wanted a doc-string on UI_SCALE_FAC and it is now in DNA_userdef_types.h as "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."

A renaming of UI scale factors from names that imply a relationship to monitor DPI to names that imply that they simply change "scale" --- This is a disruptive change request that should be considered carefully. When posted [on Phab](https://archive.blender.org/developer/D16807) Brecht approved it, but I still worry that this is a big change just because "Harley doesn't like a word". With the last release we changed U.dpi so that it contains actual monitor DPI and is no longer scaled by line width. This might be a time to *consider* changing other UI variable names to be less confusing as well. The term "dpi_fac" has always seemed a bit odd to me as its not *really* related to DPI and "fac" is a clumsy shortening of factor. My hope is the following makes it all a bit less confusing for new developers. This PR first renames the following: * U.dpi_fac 🡒 U.scale_factor * U.inv_dpi_fac 🡒 U.inv_scale_factor * UI_DPI_FAC 🡒 UI_SCALE_FAC * UI_DPI_ICON_SIZE 🡒 UI_ICON_SIZE Then **ALL** current uses of U.scale_factor are changed to instead use the macro UI_SCALE_FAC, making it easier to move or change this later. And all uses of U.inv_scale_factor use macro UI_INV_SCALE_FAC. Our current code contains a mixture of U.dpi_fac and UI_DPI_FAC, often in the same file. A review item that was previously "Not Done" is completed here. Campbell wanted a doc-string on UI_SCALE_FAC and it is now in DNA_userdef_types.h as "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."
Harley Acheson changed title from Refactor: .dpi_fac -> U.scale_factor to Refactor: U.dpi_fac -> U.scale_factor 2023-03-14 03:42:59 +01:00
Brecht Van Lommel requested changes 2023-03-14 16:36:02 +01:00
@ -18,0 +21,4 @@
* `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)

Why is (void)0 used here, I don't think it's necessary?

Why is `(void)0` used here, I don't think it's necessary?
brecht marked this conversation as resolved

Since dpi_fac does not represent nor DPI, it seems convenient to rename it to scale_factor IMHO.

Perhaps we don't even need the _factor suffix.

However, I noticed that you already have a member with a similar name. The U.ui_scale. Not sure if it's something to be concerned about.

Since `dpi_fac` does not represent nor DPI, it seems convenient to rename it to `scale_factor` IMHO. Perhaps we don't even need the `_factor` suffix. However, I noticed that you already have a member with a similar name. The `U.ui_scale`. Not sure if it's something to be concerned about.
Author
Member

@blender-bot build

@blender-bot build
Author
Member

@brecht - Why is (void)0 used here, I don't think it's necessary?

I did that based on Campbell's suggestion that this would "avoid accidental assignment", unless I am misunderstanding. https://archive.blender.org/developer/differential/0016/0016807/#461990

> @brecht - Why is (void)0 used here, I don't think it's necessary? I did that based on Campbell's suggestion that this would "avoid accidental assignment", unless I am misunderstanding. https://archive.blender.org/developer/differential/0016/0016807/#461990
Brecht Van Lommel approved these changes 2023-03-15 17:45:28 +01:00
Brecht Van Lommel left a comment
Owner

Ok, that's fine then.

Ok, that's fine then.
Harley Acheson force-pushed DpiFac from 30fb5ea3d7 to 5e6ec529c4 2023-03-16 22:52:39 +01:00 Compare
Harley Acheson added 1 commit 2023-03-17 03:06:56 +01:00
buildbot/vexp-code-patch-coordinator Build done. Details
25aedb4466
Merge branch 'main' into DpiFac
Author
Member

@blender-bot build

@blender-bot build
Harley Acheson added 1 commit 2023-03-17 04:18:01 +01:00
Harley Acheson merged commit f78f05c749 into main 2023-03-17 04:19:17 +01:00
Harley Acheson deleted branch DpiFac 2023-03-17 04:19:18 +01:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#105750
No description provided.