1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 09:09:47 +00:00

Make the size of the text of rulers and guides be affected by the font size

This commit is contained in:
Emmanouil Papadeas 2024-07-15 00:31:52 +03:00
parent bcbd0ea7da
commit 3ea0ef0b5a
4 changed files with 37 additions and 9 deletions

View file

@ -94,3 +94,9 @@ func get_font() -> Font:
if Global.control.theme.has_default_font():
return Global.control.theme.default_font
return ThemeDB.fallback_font
func get_font_size() -> int:
if Global.control.theme.has_default_font_size():
return Global.control.theme.default_font_size
return ThemeDB.fallback_font_size

View file

@ -124,7 +124,7 @@ func _draw() -> void:
string,
HORIZONTAL_ALIGNMENT_LEFT,
-1,
16,
Themes.get_font_size(),
color
)
else:
@ -134,7 +134,7 @@ func _draw() -> void:
string,
HORIZONTAL_ALIGNMENT_LEFT,
-1,
16,
Themes.get_font_size(),
color
)
return
@ -149,7 +149,13 @@ func _draw() -> void:
< intersection.distance_squared_to(viewport_poly[0])
):
draw_string(
font, Vector2(x_offset, y_offset), string, HORIZONTAL_ALIGNMENT_LEFT, -1, 16, color
font,
Vector2(x_offset, y_offset),
string,
HORIZONTAL_ALIGNMENT_LEFT,
-1,
Themes.get_font_size(),
color
)
else:
draw_string(
@ -158,7 +164,7 @@ func _draw() -> void:
string,
HORIZONTAL_ALIGNMENT_LEFT,
-1,
16,
Themes.get_font_size(),
color
)
return
@ -179,7 +185,7 @@ func _draw() -> void:
string,
HORIZONTAL_ALIGNMENT_LEFT,
-1,
16,
Themes.get_font_size(),
color
)
else:
@ -189,7 +195,7 @@ func _draw() -> void:
string,
HORIZONTAL_ALIGNMENT_LEFT,
-1,
16,
Themes.get_font_size(),
color
)
return
@ -197,7 +203,13 @@ func _draw() -> void:
# If there's no intersection with a viewport edge, show string in top left corner
draw_set_transform(viewport_poly[0], Global.camera.rotation, Vector2(2.0, 2.0) / zoom)
draw_string(
font, Vector2(x_offset, font_height), string, HORIZONTAL_ALIGNMENT_LEFT, -1, 16, color
font,
Vector2(x_offset, font_height),
string,
HORIZONTAL_ALIGNMENT_LEFT,
-1,
Themes.get_font_size(),
color
)

View file

@ -91,7 +91,10 @@ func _draw() -> void:
draw_string(
font,
Vector2(pos.x + RULER_WIDTH + 2, font.get_height() - 4),
str(snappedf(val, 0.1))
str(snappedf(val, 0.1)),
HORIZONTAL_ALIGNMENT_LEFT,
-1,
Themes.get_font_size()
)
else:
if j % minor_subdivision == 0:

View file

@ -86,7 +86,14 @@ func _draw() -> void:
var text_xform := Transform2D(-PI / 2, Vector2(font.get_height() - 4, pos.y - 2))
draw_set_transform_matrix(get_transform() * text_xform)
var val := ((ruler_transform * major_subdivide * minor_subdivide) * Vector2(0, j)).y
draw_string(font, Vector2(), str(snappedf(val, 0.1)))
draw_string(
font,
Vector2(),
str(snappedf(val, 0.1)),
HORIZONTAL_ALIGNMENT_LEFT,
-1,
Themes.get_font_size()
)
draw_set_transform_matrix(get_transform())
else:
if j % minor_subdivision == 0: