Skip to content

Commit

Permalink
Add signal for when the active project changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SamTheBlow committed Aug 28, 2024
1 parent 7f3ba0e commit 2fe0034
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 0 additions & 4 deletions lorien/Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,12 @@ func _on_files_dropped(files: PackedStringArray) -> void:

# -------------------------------------------------------------------------------------------------
func _make_project_active(project: Project) -> void:
var previous_project: Project = ProjectManager.get_active_project()

ProjectManager.make_project_active(project)
_canvas.use_project(project)

if !_menubar.has_tab(project):
_menubar.make_tab(project)
_menubar.set_tab_active(project)

_toolbar._on_active_project_changed(previous_project, project)

# -------------------------------------------------------------------------------------------------
func _is_mouse_on_ui() -> bool:
Expand Down
11 changes: 10 additions & 1 deletion lorien/ProjectManager/ProjectManager.gd
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
extends Node

# -------------------------------------------------------------------------------------------------
signal active_project_changed(previous_project: Project, current_project: Project)

var _open_projects: Array[Project]
var _active_project: Project

var _active_project: Project:
set(value):
if _active_project == value:
return
var previous_project: Project = _active_project
_active_project = value
active_project_changed.emit(previous_project, _active_project)

# -------------------------------------------------------------------------------------------------
func read_project_list() -> void:
Expand Down
1 change: 1 addition & 0 deletions lorien/UI/Toolbar.gd
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func _ready():
_tool_btn_line.pressed.connect(_on_LineToolButton_pressed)
_tool_btn_eraser.pressed.connect(_on_EraserToolButton_pressed)
_tool_btn_selection.pressed.connect(_on_SelectToolButton_pressed)
ProjectManager.active_project_changed.connect(_on_active_project_changed)

# Button clicked callbacks
# -------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 2fe0034

Please sign in to comment.