feat(terminal): and stylebox support

Adds support for 'normal' and 'focus' Style Boxes to Terminal node.
Changes default background color to transparent, with background to be
set by StyleBox.

If background color is not transparent, will draw a background color
rect to cover the entire control over the top of any stylebox. This is
consistent with the behavior of the TextEdit node with regards to theme
colors and styleboxes.
This commit is contained in:
Leroy Hopson 2024-04-14 20:28:26 +12:00
parent a5951978f7
commit d6a4adf6aa
No known key found for this signature in database
GPG key ID: D2747312A6DB51AA
40 changed files with 608 additions and 52 deletions

View file

@ -0,0 +1,13 @@
[gd_scene load_steps=2 format=3 uid="uid://bk450yhh0sx2f"]
[ext_resource type="Texture2D" uid="uid://2em8p7vcmp33" path="res://docs/_static/images/icon.png" id="1_osuf4"]
[node name="Background" type="TextureRect"]
z_index = -1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("1_osuf4")
stretch_mode = 1

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 822 B

After

Width:  |  Height:  |  Size: 984 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 368 B

After

Width:  |  Height:  |  Size: 503 B

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 548 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View file

@ -88,6 +88,8 @@ class TestVisualRegression:
assert_match("default_theme")
func test_transparency():
subject.add_child(preload("./background.tscn").instantiate())
subject.add_theme_stylebox_override("normal", StyleBoxEmpty.new())
subject.add_theme_color_override("foreground_color", Color(0, 1, 0, 0.5))
subject.add_theme_color_override("background_color", Color(1, 0, 0, 0.5))
subject.write("bg red, 50% transparency\r\n")
@ -104,3 +106,39 @@ class TestVisualRegression:
subject.write("👈🤮👉💩👃😍🤥😤🙏🤟")
await wait_frames(30)
assert_match("emoji")
func test_solid_invert_selection():
subject.write("██████████\r\n██████████")
subject.add_theme_color_override("background_color", Color.ORANGE)
subject.inverse_mode = Terminal.INVERSE_MODE_INVERT
subject.select(0, 5, 1, 6)
await wait_frames(30)
assert_match("solid_invert_selection")
func test_solid_swap_selection():
subject.write("██████████\r\n██████████")
subject.add_theme_color_override("background_color", Color.ORANGE)
subject.inverse_mode = Terminal.INVERSE_MODE_SWAP
subject.select(0, 5, 1, 6)
await wait_frames(30)
assert_match("solid_swap_selection")
func test_transparent_invert_selection():
subject.add_child(preload("./background.tscn").instantiate())
subject.write("██████████\r\n██████████")
subject.add_theme_color_override("background_color", Color.TRANSPARENT)
subject.add_theme_stylebox_override("normal", StyleBoxEmpty.new())
subject.inverse_mode = Terminal.INVERSE_MODE_INVERT
subject.select(0, 5, 1, 6)
await wait_frames(30)
assert_match("transparent_invert_selection")
func test_transparent_swap_selection():
subject.add_child(preload("./background.tscn").instantiate())
subject.write("██████████\r\n██████████")
subject.add_theme_color_override("background_color", Color.TRANSPARENT)
subject.add_theme_stylebox_override("normal", StyleBoxEmpty.new())
subject.inverse_mode = Terminal.INVERSE_MODE_SWAP
subject.select(0, 5, 1, 6)
await wait_frames(30)
assert_match("transparent_swap_selection")