mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 05:10:53 +00:00
Scale font size in PolylineDecorator and BoundingBoxDecorator based on Blender's UI preferences
This commit is contained in:
committed by
Bruno Perdigão
parent
ece7d6b97f
commit
8df4b2cd56
@@ -29,6 +29,7 @@ import bpy
|
|||||||
import gpu
|
import gpu
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import mathutils
|
import mathutils
|
||||||
|
import sys
|
||||||
from bpy.types import SpaceView3D
|
from bpy.types import SpaceView3D
|
||||||
from bpy_extras import view3d_utils
|
from bpy_extras import view3d_utils
|
||||||
from bpy_extras.view3d_utils import location_3d_to_region_2d
|
from bpy_extras.view3d_utils import location_3d_to_region_2d
|
||||||
@@ -466,13 +467,19 @@ class PolylineDecorator:
|
|||||||
|
|
||||||
self.addon_prefs = tool.Blender.get_addon_preferences()
|
self.addon_prefs = tool.Blender.get_addon_preferences()
|
||||||
self.font_id = 0
|
self.font_id = 0
|
||||||
font_size = tool.Blender.scale_font_size(12)
|
ui_style = context.preferences.ui_styles[0]
|
||||||
|
widget_font_points = ui_style.widget.points
|
||||||
|
ui_scale = context.preferences.view.ui_scale
|
||||||
|
platform_scale = 2 if sys.platform == 'darwin' else 1
|
||||||
|
|
||||||
|
font_size = widget_font_points * ui_scale * platform_scale
|
||||||
|
offset = widget_font_points * ui_scale * (1.5 * platform_scale)
|
||||||
|
line_height = widget_font_points * ui_scale * (1.25 * platform_scale)
|
||||||
blf.size(self.font_id, font_size)
|
blf.size(self.font_id, font_size)
|
||||||
blf.enable(self.font_id, blf.SHADOW)
|
blf.enable(self.font_id, blf.SHADOW)
|
||||||
blf.shadow(self.font_id, 6, 0, 0, 0, 1)
|
blf.shadow(self.font_id, 6, 0, 0, 0, 1)
|
||||||
color = self.addon_prefs.decorations_colour
|
color = self.addon_prefs.decorations_colour
|
||||||
color_highlight = self.addon_prefs.decorator_color_special
|
color_highlight = self.addon_prefs.decorator_color_special
|
||||||
offset = 20
|
|
||||||
new_line = 0
|
new_line = 0
|
||||||
for i, (key, field_name) in enumerate(texts.items()):
|
for i, (key, field_name) in enumerate(texts.items()):
|
||||||
formatted_value = None
|
formatted_value = None
|
||||||
@@ -480,7 +487,7 @@ class PolylineDecorator:
|
|||||||
# Controls which options are displayed in the UI
|
# Controls which options are displayed in the UI
|
||||||
if key not in self.input_ui.input_options:
|
if key not in self.input_ui.input_options:
|
||||||
continue
|
continue
|
||||||
new_line += 20
|
new_line += line_height
|
||||||
if self.tool_state and key != self.tool_state.input_type:
|
if self.tool_state and key != self.tool_state.input_type:
|
||||||
formatted_value = self.input_ui.get_formatted_value(key)
|
formatted_value = self.input_ui.get_formatted_value(key)
|
||||||
else:
|
else:
|
||||||
@@ -515,7 +522,12 @@ class PolylineDecorator:
|
|||||||
self.addon_prefs = tool.Blender.get_addon_preferences()
|
self.addon_prefs = tool.Blender.get_addon_preferences()
|
||||||
self.font_id = 1
|
self.font_id = 1
|
||||||
self.shader = gpu.shader.from_builtin("UNIFORM_COLOR")
|
self.shader = gpu.shader.from_builtin("UNIFORM_COLOR")
|
||||||
font_size = tool.Blender.scale_font_size(12)
|
ui_style = context.preferences.ui_styles[0]
|
||||||
|
widget_font_points = ui_style.widget.points
|
||||||
|
ui_scale = context.preferences.view.ui_scale
|
||||||
|
platform_scale = 2 if sys.platform == 'darwin' else 1
|
||||||
|
|
||||||
|
font_size = widget_font_points * ui_scale * platform_scale
|
||||||
blf.size(self.font_id, font_size)
|
blf.size(self.font_id, font_size)
|
||||||
blf.enable(self.font_id, blf.SHADOW)
|
blf.enable(self.font_id, blf.SHADOW)
|
||||||
blf.shadow(self.font_id, 6, 0, 0, 0, 1)
|
blf.shadow(self.font_id, 6, 0, 0, 0, 1)
|
||||||
@@ -1936,7 +1948,13 @@ class BoundingBoxDecorator:
|
|||||||
|
|
||||||
addon_prefs = tool.Blender.get_addon_preferences()
|
addon_prefs = tool.Blender.get_addon_preferences()
|
||||||
font_id = 0
|
font_id = 0
|
||||||
font_size = tool.Blender.scale_font_size(12)
|
# Get Blender's default UI widget font size from preferences
|
||||||
|
ui_style = context.preferences.ui_styles[0]
|
||||||
|
widget_font_points = ui_style.widget.points
|
||||||
|
ui_scale = context.preferences.view.ui_scale
|
||||||
|
platform_scale = 2 if sys.platform == 'darwin' else 1
|
||||||
|
|
||||||
|
font_size = widget_font_points * ui_scale * platform_scale
|
||||||
blf.size(font_id, font_size)
|
blf.size(font_id, font_size)
|
||||||
blf.enable(font_id, blf.SHADOW)
|
blf.enable(font_id, blf.SHADOW)
|
||||||
blf.shadow(font_id, 6, 0, 0, 0, 1)
|
blf.shadow(font_id, 6, 0, 0, 0, 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user