mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Some minor UI improvements in the text tool
The text tool's caret is now blinking, and the width of the border should now change depending on the zoom value
This commit is contained in:
parent
a7a76ff9f0
commit
5ec316a50f
|
@ -139,7 +139,7 @@ func text_to_pixels() -> void:
|
||||||
var text := text_edit.text
|
var text := text_edit.text
|
||||||
var color := tool_slot.color
|
var color := tool_slot.color
|
||||||
var font_ascent := font.get_ascent(text_size)
|
var font_ascent := font.get_ascent(text_size)
|
||||||
var pos := Vector2(1, font_ascent + text_edit.get_theme_constant(&"line_spacing"))
|
var pos := Vector2(0, font_ascent + text_edit.get_theme_constant(&"line_spacing"))
|
||||||
pos += text_edit.position
|
pos += text_edit.position
|
||||||
font.draw_multiline_string(ci_rid, pos, text, horizontal_alignment, -1, text_size, -1, color)
|
font.draw_multiline_string(ci_rid, pos, text, horizontal_alignment, -1, text_size, -1, color)
|
||||||
|
|
||||||
|
|
|
@ -5,15 +5,18 @@ var font: Font:
|
||||||
set(value):
|
set(value):
|
||||||
font = value
|
font = value
|
||||||
add_theme_font_override(&"font", font)
|
add_theme_font_override(&"font", font)
|
||||||
|
var _border_node := Control.new()
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
Global.camera.zoom_changed.connect(func(): _border_node.queue_redraw())
|
||||||
|
_border_node.draw.connect(_on_border_redraw)
|
||||||
|
_border_node.set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||||
|
_border_node.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||||
|
add_child(_border_node)
|
||||||
|
caret_blink = true
|
||||||
var stylebox := StyleBoxFlat.new()
|
var stylebox := StyleBoxFlat.new()
|
||||||
stylebox.draw_center = false
|
stylebox.draw_center = false
|
||||||
stylebox.border_width_left = 1
|
|
||||||
stylebox.border_width_top = 1
|
|
||||||
stylebox.border_width_right = 1
|
|
||||||
stylebox.border_width_bottom = 1
|
|
||||||
add_theme_stylebox_override(&"normal", stylebox)
|
add_theme_stylebox_override(&"normal", stylebox)
|
||||||
add_theme_stylebox_override(&"focus", stylebox)
|
add_theme_stylebox_override(&"focus", stylebox)
|
||||||
add_theme_constant_override(&"line_spacing", 0)
|
add_theme_constant_override(&"line_spacing", 0)
|
||||||
|
@ -44,3 +47,9 @@ func _on_text_changed() -> void:
|
||||||
var string_size := font.get_string_size(max_line, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size)
|
var string_size := font.get_string_size(max_line, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size)
|
||||||
size.x = font_size + string_size.x
|
size.x = font_size + string_size.x
|
||||||
size.y = (get_line_count() + 1) * font.get_height(font_size)
|
size.y = (get_line_count() + 1) * font.get_height(font_size)
|
||||||
|
_border_node.queue_redraw()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_border_redraw() -> void:
|
||||||
|
var border_width := (1.0 / Global.camera.zoom.x) * 2.0 + 1.0
|
||||||
|
_border_node.draw_rect(_border_node.get_rect(), Color.WHITE, false, border_width)
|
||||||
|
|
Loading…
Reference in a new issue