Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/ui_parts/display.gd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extends VBoxContainer

const NumberEdit = preload("res://src/ui_widgets/number_edit.gd")
const TabPanel = preload("res://src/ui_parts/tab_panel.tscn")
const TabsPanel = preload("res://src/ui_parts/tabs_panel.tscn")

@onready var viewport: SubViewport = %Viewport
@onready var reference_texture: TextureRect = %Viewport/ReferenceTexture
Expand All @@ -15,14 +15,16 @@ const TabPanel = preload("res://src/ui_parts/tab_panel.tscn")
@onready var input_debug_label: Label = %DebugContainer/InputDebugLabel
@onready var toolbar: PanelContainer = $ViewportPanel/VBoxContainer/Toolbar

var tab_panel: PanelContainer
var tabs_panel: PanelContainer
var should_refresh_tabs := false

var reference_overlay := false

func _ready() -> void:
Configs.language_changed.connect(update_translations)
Configs.snap_changed.connect(update_snap_config)
Configs.theme_changed.connect(update_theme)
Configs.tabs_changed.connect(set.bind("should_refresh_tabs" ,true))
Configs.active_tab_changed.connect(sync_reference_image)
Configs.active_tab_reference_changed.connect(sync_reference_image)
sync_reference_image()
Expand All @@ -37,13 +39,13 @@ func _ready() -> void:
update_snap_config()
get_window().window_input.connect(_update_input_debug)

tab_panel = TabPanel.instantiate()
tabs_panel = TabsPanel.instantiate()
var overlay_ref := ColorRect.new()
overlay_ref.color = Color(0, 0, 0, 0.4)
overlay_ref.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
overlay_ref.hide()
get_tree().root.add_child.call_deferred(overlay_ref)
overlay_ref.add_child(tab_panel)
overlay_ref.add_child(tabs_panel)

func update_translations() -> void:
%LeftMenu/Visuals.tooltip_text = Translator.translate("Visuals")
Expand Down Expand Up @@ -171,6 +173,9 @@ func _update_input_debug(event: InputEvent) -> void:
input_debug_label.text = new_text


func _on_tab_switcher_pressed() -> void:
tab_panel.get_parent().show()
tab_panel.animate_in()
func show_tabs_panel() -> void:
if should_refresh_tabs:
tabs_panel.refresh_tabs()
should_refresh_tabs = false
tabs_panel.get_parent().show()
tabs_panel.animate_in()
4 changes: 2 additions & 2 deletions src/ui_parts/display.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ allow_lower = false
layout_mode = 2
size_flags_horizontal = 3

[node name="TabSwitcher" type="Button" parent="ViewportPanel/VBoxContainer/Toolbar/ViewportOptions"]
[node name="TabsPanel" type="Button" parent="ViewportPanel/VBoxContainer/Toolbar/ViewportOptions"]
layout_mode = 2
focus_mode = 0
mouse_default_cursor_shape = 2
Expand Down Expand Up @@ -205,6 +205,6 @@ horizontal_alignment = 2
[connection signal="pressed" from="ViewportPanel/VBoxContainer/Toolbar/ViewportOptions/LeftMenu/Reference" to="." method="_on_reference_pressed"]
[connection signal="toggled" from="ViewportPanel/VBoxContainer/Toolbar/ViewportOptions/LeftMenu/Snapping/SnapButton" to="." method="_on_snap_button_toggled"]
[connection signal="value_changed" from="ViewportPanel/VBoxContainer/Toolbar/ViewportOptions/LeftMenu/Snapping/SnapNumberEdit" to="." method="_on_snap_number_edit_value_changed"]
[connection signal="pressed" from="ViewportPanel/VBoxContainer/Toolbar/ViewportOptions/TabSwitcher" to="." method="_on_tab_switcher_pressed"]
[connection signal="pressed" from="ViewportPanel/VBoxContainer/Toolbar/ViewportOptions/TabsPanel" to="." method="show_tabs_panel"]
[connection signal="zoom_changed" from="ViewportPanel/VBoxContainer/Toolbar/ViewportOptions/ZoomMenu" to="ViewportPanel/VBoxContainer/ViewportContainer/Viewport" method="_on_zoom_changed"]
[connection signal="zoom_reset_pressed" from="ViewportPanel/VBoxContainer/Toolbar/ViewportOptions/ZoomMenu" to="ViewportPanel/VBoxContainer/ViewportContainer/Viewport" method="center_frame"]
1 change: 0 additions & 1 deletion src/ui_parts/export_menu.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[gd_scene load_steps=7 format=3 uid="uid://c13dadqbljqlu"]

[ext_resource type="Script" uid="uid://bouo2y3v0gy4a" path="res://src/ui_parts/export_menu.gd" id="1_objnb"]
[ext_resource type="Script" uid="uid://chk5g6lh7jc14" path="res://src/ui_widgets/HTitledPanel.gd" id="2_07m68"]
[ext_resource type="PackedScene" uid="uid://xh26qa68xed4" path="res://src/ui_widgets/preview_rect.tscn" id="2_ewk0a"]
[ext_resource type="Texture2D" uid="uid://v0lqyuvo50yq" path="res://assets/icons/Info.svg" id="2_rk3rd"]
[ext_resource type="FontFile" uid="uid://clpf84p1lfwlp" path="res://assets/fonts/Font.ttf" id="5_s3e6m"]
Expand Down
1 change: 0 additions & 1 deletion src/ui_parts/tab_panel.gd → src/ui_parts/tabs_panel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func animate_out() -> void:
get_parent().hide()

func refresh_tabs() -> void:
print("Refreshing tabs...")
for i in tab_container.get_children():
i.queue_free()

Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions src/ui_parts/tab_panel.tscn → src/ui_parts/tabs_panel.tscn
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[gd_scene load_steps=3 format=3 uid="uid://csrfbf30rdcc0"]

[ext_resource type="Script" uid="uid://rwf3r3qie2mv" path="res://src/ui_parts/tab_panel.gd" id="1_qdc8p"]
[ext_resource type="Texture2D" uid="uid://eif2ioi0mw17" path="res://assets/icons/Plus.svg" id="2_oftom"]
[ext_resource type="Script" uid="uid://rwf3r3qie2mv" path="res://src/ui_parts/tabs_panel.gd" id="1_a4usf"]
[ext_resource type="Texture2D" uid="uid://eif2ioi0mw17" path="res://assets/icons/Plus.svg" id="2_1shv1"]

[node name="TabSwitcher" type="PanelContainer"]
[node name="TabsPanel" type="PanelContainer"]
custom_minimum_size = Vector2(180, 0)
anchors_preset = 9
anchor_bottom = 1.0
offset_right = 96.0
grow_vertical = 2
theme_type_variation = &"DarkPanel"
script = ExtResource("1_qdc8p")
script = ExtResource("1_a4usf")

[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 2
Expand All @@ -34,6 +34,6 @@ focus_mode = 0
mouse_default_cursor_shape = 2
theme_type_variation = &"IconButton"
text = "New Tab"
icon = ExtResource("2_oftom")
icon = ExtResource("2_1shv1")

[connection signal="pressed" from="VBoxContainer/NewTab" to="." method="_on_new_tab_pressed"]
1 change: 0 additions & 1 deletion src/ui_widgets/tab_item.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func setup(tab_title: String, svg_text: String, is_active: bool = false) -> void

func highlight_active_tab() -> void:
var active_index := Configs.savedata.get_active_tab_index()
print("active_index ", active_index)
if get_index() == active_index:
highlight(true)
else:
Expand Down