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.
|
@ -264,7 +264,7 @@ class TestSelect:
|
|||
func before_each():
|
||||
super.before_each()
|
||||
text_edit = TextEdit.new()
|
||||
text_edit.text = "0123456789\nABCDEFGHIJ\n)!@#$%^&*(\n\n\n\n\n\n\n"
|
||||
text_edit.text = "0123456789\nABCDEFGHIJ\n)!@#$%^&*(\n\n\n\n\n\n"
|
||||
add_child_autofree(text_edit)
|
||||
subject.write("0123456789\r\nABCDEFGHIJ\r\n)!@#$%^&*(")
|
||||
|
||||
|
@ -306,7 +306,7 @@ class TestSelect:
|
|||
assert_select_eq([-2, 0, 1, 10], "0123456789\nABCDEFGHIJ")
|
||||
|
||||
func test_select_exceeds_row_bounds():
|
||||
assert_select_eq([1, 5, 999, 999], "FGHIJ\n)!@#$%^&*(\n\n\n\n\n\n\n")
|
||||
assert_select_eq([1, 5, 999, 999], "FGHIJ\n)!@#$%^&*(\n\n\n\n\n\n")
|
||||
|
||||
func test_wide_bounds():
|
||||
assert_select_eq([-999, -999, 999, 999], "0123456789\nABCDEFGHIJ\n)!@#$%^&*(\n\n\n\n\n\n\n")
|
||||
assert_select_eq([-999, -999, 999, 999], "0123456789\nABCDEFGHIJ\n)!@#$%^&*(\n\n\n\n\n\n")
|
||||
|
|
13
test/visual_regression/background.tscn
Normal 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
|
BIN
test/visual_regression/baseline/blue_background.png
Normal file
After Width: | Height: | Size: 479 B |
Before Width: | Height: | Size: 822 B After Width: | Height: | Size: 984 B |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 368 B After Width: | Height: | Size: 503 B |
BIN
test/visual_regression/baseline/solid_invert_selection.png
Normal file
After Width: | Height: | Size: 548 B |
BIN
test/visual_regression/baseline/solid_swap_selection.png
Normal file
After Width: | Height: | Size: 560 B |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 12 KiB |
BIN
test/visual_regression/baseline/transparent_invert_selection.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
test/visual_regression/baseline/transparent_swap_selection.png
Normal file
After Width: | Height: | Size: 6.4 KiB |
|
@ -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")
|
||||
|
|