diff --git a/CHANGES.md b/CHANGES.md
index f64a47e..5e52fd6 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [0.6.0] - 2023-10-06
+### Added
+- You can now move the sidebar for quickly adding new states to the other side of the editor. This is useful if you have your node tree on the right side of the editor. The location will be saved with the editor layout ([#47](https://github.com/derkork/godot-statecharts/issues/47)).
+
## [0.5.0] - 2023-09-27
### Added
diff --git a/addons/godot_state_charts/godot_state_charts.gd b/addons/godot_state_charts/godot_state_charts.gd
index 42df832..b79d7f0 100644
--- a/addons/godot_state_charts/godot_state_charts.gd
+++ b/addons/godot_state_charts/godot_state_charts.gd
@@ -10,20 +10,66 @@ var _ui_sidebar_spatial:Control
var _sidebar_ui:PackedScene = preload("utilities/editor_sidebar.tscn")
+enum SidebarLocation {
+ LEFT = 1,
+ RIGHT = 2
+}
+
+## The current location of the sidebar. Default is left.
+var _current_sidebar_location:SidebarLocation = SidebarLocation.LEFT
+
+
func _enter_tree():
# prepare a copy of the sidebar for both 2D and 3D.
_ui_sidebar_canvas = _sidebar_ui.instantiate()
+ _ui_sidebar_canvas.sidebar_toggle_requested.connect(_toggle_sidebar)
_ui_sidebar_canvas.hide()
_ui_sidebar_spatial = _sidebar_ui.instantiate()
+ _ui_sidebar_spatial.sidebar_toggle_requested.connect(_toggle_sidebar)
_ui_sidebar_spatial.hide()
# and add it to the right place in the editor ui
- add_control_to_container(EditorPlugin.CONTAINER_SPATIAL_EDITOR_SIDE_LEFT, _ui_sidebar_spatial)
- add_control_to_container(EditorPlugin.CONTAINER_CANVAS_EDITOR_SIDE_LEFT, _ui_sidebar_canvas)
+ _add_sidebars()
# get notified when selection changes so we can
# update the sidebar contents accordingly
get_editor_interface().get_selection().selection_changed.connect(_on_selection_changed)
+func _set_window_layout(configuration):
+ _remove_sidebars()
+ _current_sidebar_location = configuration.get_value("GodotStateCharts", "sidebar_location", SidebarLocation.LEFT)
+ _add_sidebars()
+
+
+func _get_window_layout(configuration):
+ configuration.set_value("GodotStateCharts", "sidebar_location", _current_sidebar_location)
+
+
+func _toggle_sidebar():
+ _remove_sidebars()
+ _current_sidebar_location = SidebarLocation.RIGHT if _current_sidebar_location == SidebarLocation.LEFT else SidebarLocation.LEFT
+ _add_sidebars()
+ queue_save_layout()
+
+
+func _add_sidebars():
+ if _current_sidebar_location == SidebarLocation.LEFT:
+ add_control_to_container(EditorPlugin.CONTAINER_SPATIAL_EDITOR_SIDE_LEFT, _ui_sidebar_spatial)
+ add_control_to_container(EditorPlugin.CONTAINER_CANVAS_EDITOR_SIDE_LEFT, _ui_sidebar_canvas)
+ else:
+ add_control_to_container(EditorPlugin.CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT, _ui_sidebar_spatial)
+ add_control_to_container(EditorPlugin.CONTAINER_CANVAS_EDITOR_SIDE_RIGHT, _ui_sidebar_canvas)
+
+
+func _remove_sidebars():
+ if _current_sidebar_location == SidebarLocation.LEFT:
+ remove_control_from_container(EditorPlugin.CONTAINER_CANVAS_EDITOR_SIDE_LEFT,_ui_sidebar_canvas)
+ remove_control_from_container(EditorPlugin.CONTAINER_SPATIAL_EDITOR_SIDE_LEFT, _ui_sidebar_spatial)
+ else:
+ remove_control_from_container(EditorPlugin.CONTAINER_CANVAS_EDITOR_SIDE_RIGHT,_ui_sidebar_canvas)
+ remove_control_from_container(EditorPlugin.CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT, _ui_sidebar_spatial)
+
+
+
func _ready():
# inititalize the side bars
_ui_sidebar_canvas.setup(get_editor_interface(), get_undo_redo())
@@ -32,8 +78,7 @@ func _ready():
func _exit_tree():
# remove the side bars
- remove_control_from_container(EditorPlugin.CONTAINER_SPATIAL_EDITOR_SIDE_LEFT, _ui_sidebar_spatial)
- remove_control_from_container(EditorPlugin.CONTAINER_CANVAS_EDITOR_SIDE_LEFT, _ui_sidebar_canvas)
+ _remove_sidebars()
if is_instance_valid(_ui_sidebar_canvas):
_ui_sidebar_canvas.queue_free()
if is_instance_valid(_ui_sidebar_spatial):
diff --git a/addons/godot_state_charts/plugin.cfg b/addons/godot_state_charts/plugin.cfg
index 66d73a1..618e788 100644
--- a/addons/godot_state_charts/plugin.cfg
+++ b/addons/godot_state_charts/plugin.cfg
@@ -3,5 +3,5 @@
name="Godot State Charts"
description="A simple, yet powerful state charts library for Godot"
author="Jan Thomä & Contributors"
-version="0.5.0"
+version="0.6.0"
script="godot_state_charts.gd"
diff --git a/addons/godot_state_charts/toggle_sidebar.svg b/addons/godot_state_charts/toggle_sidebar.svg
new file mode 100644
index 0000000..a799e75
--- /dev/null
+++ b/addons/godot_state_charts/toggle_sidebar.svg
@@ -0,0 +1,20 @@
+
+
+
diff --git a/addons/godot_state_charts/toggle_sidebar.svg.import b/addons/godot_state_charts/toggle_sidebar.svg.import
new file mode 100644
index 0000000..7d85b7a
--- /dev/null
+++ b/addons/godot_state_charts/toggle_sidebar.svg.import
@@ -0,0 +1,37 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://vga3avpb4gyh"
+path="res://.godot/imported/toggle_sidebar.svg-99e4fe22fa516ab6214c0533adb07ec0.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://addons/godot_state_charts/toggle_sidebar.svg"
+dest_files=["res://.godot/imported/toggle_sidebar.svg-99e4fe22fa516ab6214c0533adb07ec0.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
+svg/scale=1.0
+editor/scale_with_editor_scale=false
+editor/convert_colors_with_editor_theme=false
diff --git a/addons/godot_state_charts/utilities/editor_sidebar.gd b/addons/godot_state_charts/utilities/editor_sidebar.gd
index e846c84..f0349d7 100644
--- a/addons/godot_state_charts/utilities/editor_sidebar.gd
+++ b/addons/godot_state_charts/utilities/editor_sidebar.gd
@@ -1,6 +1,9 @@
@tool
extends Control
+## Emitted when the user requests to toggle the sidebar.
+signal sidebar_toggle_requested()
+
## The currently selected node or null
var _selected_node:Node
## The editor interface
@@ -99,3 +102,6 @@ func _on_animation_tree_state_pressed():
func _on_animation_player_state_pressed():
_create_node(AnimationPlayerState, "AnimationPlayerState")
+
+func _on_toggle_sidebar_button_pressed():
+ sidebar_toggle_requested.emit()
diff --git a/addons/godot_state_charts/utilities/editor_sidebar.tscn b/addons/godot_state_charts/utilities/editor_sidebar.tscn
index 3306a48..1b578fc 100644
--- a/addons/godot_state_charts/utilities/editor_sidebar.tscn
+++ b/addons/godot_state_charts/utilities/editor_sidebar.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=9 format=3 uid="uid://bephgxrkhh3e2"]
+[gd_scene load_steps=10 format=3 uid="uid://bephgxrkhh3e2"]
[ext_resource type="Script" path="res://addons/godot_state_charts/utilities/editor_sidebar.gd" id="1_7kcy8"]
[ext_resource type="Texture2D" uid="uid://c4ojtah20jtxc" path="res://addons/godot_state_charts/atomic_state.svg" id="2_0k4pg"]
@@ -8,6 +8,7 @@
[ext_resource type="Texture2D" uid="uid://3wqyduuj0fq" path="res://addons/godot_state_charts/animation_tree_state.svg" id="6_8npp8"]
[ext_resource type="Texture2D" uid="uid://chb8tq62aj2b2" path="res://addons/godot_state_charts/transition.svg" id="6_72e5q"]
[ext_resource type="Texture2D" uid="uid://b3m20gsesp4i0" path="res://addons/godot_state_charts/animation_player_state.svg" id="8_ci7iy"]
+[ext_resource type="Texture2D" uid="uid://vga3avpb4gyh" path="res://addons/godot_state_charts/toggle_sidebar.svg" id="9_dqcj0"]
[node name="EditorSidebar" type="MarginContainer"]
custom_minimum_size = Vector2(192, 0)
@@ -21,18 +22,21 @@ theme_override_constants/margin_top = 4
theme_override_constants/margin_bottom = 4
script = ExtResource("1_7kcy8")
-[node name="AddSection" type="VBoxContainer" parent="."]
+[node name="VBoxContainer" type="VBoxContainer" parent="."]
+layout_mode = 2
+
+[node name="AddSection" type="VBoxContainer" parent="VBoxContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 2
-[node name="AddLabel" type="Label" parent="AddSection"]
+[node name="AddLabel" type="Label" parent="VBoxContainer/AddSection"]
layout_mode = 2
text = "Add"
horizontal_alignment = 1
vertical_alignment = 1
-[node name="AddNodeNameLineEdit" type="LineEdit" parent="AddSection"]
+[node name="AddNodeNameLineEdit" type="LineEdit" parent="VBoxContainer/AddSection"]
unique_name_in_owner = true
layout_mode = 2
placeholder_text = "Name"
@@ -42,14 +46,14 @@ select_all_on_focus = true
caret_blink = true
caret_blink_interval = 0.5
-[node name="AddGridContainer" type="HFlowContainer" parent="AddSection"]
+[node name="AddGridContainer" type="HFlowContainer" parent="VBoxContainer/AddSection"]
unique_name_in_owner = true
layout_mode = 2
theme_override_constants/h_separation = 5
theme_override_constants/v_separation = 5
alignment = 1
-[node name="CompoundState" type="Button" parent="AddSection/AddGridContainer" groups=["statebutton"]]
+[node name="CompoundState" type="Button" parent="VBoxContainer/AddSection/AddGridContainer" groups=["statebutton"]]
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 0
@@ -57,7 +61,7 @@ tooltip_text = "CompoundState"
icon = ExtResource("3_b4okj")
icon_alignment = 1
-[node name="ParallelState" type="Button" parent="AddSection/AddGridContainer" groups=["statebutton"]]
+[node name="ParallelState" type="Button" parent="VBoxContainer/AddSection/AddGridContainer" groups=["statebutton"]]
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 0
@@ -65,7 +69,7 @@ tooltip_text = "ParallelState"
icon = ExtResource("4_lmfic")
icon_alignment = 1
-[node name="AtomicState" type="Button" parent="AddSection/AddGridContainer" groups=["statebutton"]]
+[node name="AtomicState" type="Button" parent="VBoxContainer/AddSection/AddGridContainer" groups=["statebutton"]]
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 0
@@ -73,7 +77,7 @@ tooltip_text = "AtomicState"
icon = ExtResource("2_0k4pg")
icon_alignment = 1
-[node name="HistoryState" type="Button" parent="AddSection/AddGridContainer" groups=["statebutton"]]
+[node name="HistoryState" type="Button" parent="VBoxContainer/AddSection/AddGridContainer" groups=["statebutton"]]
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 0
@@ -81,7 +85,7 @@ tooltip_text = "HistoryState"
icon = ExtResource("5_oj1t0")
icon_alignment = 1
-[node name="Transition" type="Button" parent="AddSection/AddGridContainer"]
+[node name="Transition" type="Button" parent="VBoxContainer/AddSection/AddGridContainer"]
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 0
@@ -89,7 +93,7 @@ tooltip_text = "Transition"
icon = ExtResource("6_72e5q")
icon_alignment = 1
-[node name="AnimationTreeState" type="Button" parent="AddSection/AddGridContainer" groups=["statebutton"]]
+[node name="AnimationTreeState" type="Button" parent="VBoxContainer/AddSection/AddGridContainer" groups=["statebutton"]]
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 0
@@ -97,7 +101,7 @@ tooltip_text = "AnimationTreeState"
icon = ExtResource("6_8npp8")
icon_alignment = 1
-[node name="AnimationPlayerState" type="Button" parent="AddSection/AddGridContainer" groups=["statebutton"]]
+[node name="AnimationPlayerState" type="Button" parent="VBoxContainer/AddSection/AddGridContainer" groups=["statebutton"]]
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 0
@@ -105,7 +109,7 @@ tooltip_text = "AnimationPlayerState"
icon = ExtResource("8_ci7iy")
icon_alignment = 1
-[node name="NoOptionsLabel" type="Label" parent="."]
+[node name="NoOptionsLabel" type="Label" parent="VBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(100, 0)
layout_mode = 2
@@ -114,10 +118,21 @@ text = "This node cannot have further child nodes."
horizontal_alignment = 1
autowrap_mode = 2
-[connection signal="pressed" from="AddSection/AddGridContainer/CompoundState" to="." method="_on_compound_state_pressed"]
-[connection signal="pressed" from="AddSection/AddGridContainer/ParallelState" to="." method="_on_parallel_state_pressed"]
-[connection signal="pressed" from="AddSection/AddGridContainer/AtomicState" to="." method="_on_atomic_state_pressed"]
-[connection signal="pressed" from="AddSection/AddGridContainer/HistoryState" to="." method="_on_history_state_pressed"]
-[connection signal="pressed" from="AddSection/AddGridContainer/Transition" to="." method="_on_transition_pressed"]
-[connection signal="pressed" from="AddSection/AddGridContainer/AnimationTreeState" to="." method="_on_animation_tree_state_pressed"]
-[connection signal="pressed" from="AddSection/AddGridContainer/AnimationPlayerState" to="." method="_on_animation_player_state_pressed"]
+[node name="Spacer" type="Control" parent="VBoxContainer"]
+layout_mode = 2
+size_flags_vertical = 3
+
+[node name="ToggleSidebarButton" type="Button" parent="VBoxContainer"]
+layout_mode = 2
+size_flags_horizontal = 4
+tooltip_text = "Toggle sidebar location"
+icon = ExtResource("9_dqcj0")
+
+[connection signal="pressed" from="VBoxContainer/AddSection/AddGridContainer/CompoundState" to="." method="_on_compound_state_pressed"]
+[connection signal="pressed" from="VBoxContainer/AddSection/AddGridContainer/ParallelState" to="." method="_on_parallel_state_pressed"]
+[connection signal="pressed" from="VBoxContainer/AddSection/AddGridContainer/AtomicState" to="." method="_on_atomic_state_pressed"]
+[connection signal="pressed" from="VBoxContainer/AddSection/AddGridContainer/HistoryState" to="." method="_on_history_state_pressed"]
+[connection signal="pressed" from="VBoxContainer/AddSection/AddGridContainer/Transition" to="." method="_on_transition_pressed"]
+[connection signal="pressed" from="VBoxContainer/AddSection/AddGridContainer/AnimationTreeState" to="." method="_on_animation_tree_state_pressed"]
+[connection signal="pressed" from="VBoxContainer/AddSection/AddGridContainer/AnimationPlayerState" to="." method="_on_animation_player_state_pressed"]
+[connection signal="pressed" from="VBoxContainer/ToggleSidebarButton" to="." method="_on_toggle_sidebar_button_pressed"]
diff --git a/manual/manual.md b/manual/manual.md
index d982a1e..b3bc205 100644
--- a/manual/manual.md
+++ b/manual/manual.md
@@ -39,7 +39,7 @@ Starting with version 0.2.0 there is also an improved UI to quickly add nodes an
If you hold down `Shift` while clicking the button for the node you want to add, the newly added node will be selected automatically. Otherwise the node will be added to the currently selected node but the currently selected node will stay selected.
-The new UI supports undo/redo, so you can undo the addition of a node or transition with `Ctrl+Z`.
+The new UI supports undo/redo, so you can undo the addition of a node or transition with `Ctrl+Z`. You can move the sidebar to the other side of the editor by clicking the icon at the bottom of the sidebar.
### Examples
diff --git a/raw_assets/icons.afdesign b/raw_assets/icons.afdesign
index 163e07f..83814fe 100644
Binary files a/raw_assets/icons.afdesign and b/raw_assets/icons.afdesign differ