Skip to content

Commit

Permalink
Merge pull request #24 from OverloadedOrama/godot-4.2
Browse files Browse the repository at this point in the history
Make tabs able to be dragged and dropped into panels in Godot 4.2
  • Loading branch information
gilzoide authored Nov 13, 2023
2 parents 9a93231 + a58fba7 commit c5d25d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions addons/dockable_container/dockable_container.gd
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,13 @@ func _can_drop_data(_position: Vector2, data) -> bool:


func _drop_data(_position: Vector2, data) -> void:
var from_node := get_node(data.from_path) as DockablePanel
var from_node := get_node(data.from_path)
if from_node is TabBar:
from_node = from_node.get_parent()
if from_node == _drag_panel and _drag_panel.get_child_count() == 1:
return

var moved_tab := from_node.get_tab_control(data.tabc_element)
var tab_index = data.tabc_element if data.has("tabc_element") else data.tab_index
var moved_tab = from_node.get_tab_control(tab_index)
if moved_tab is DockableReferenceControl:
moved_tab = moved_tab.reference_to
if not _is_managed_node(moved_tab):
Expand Down Expand Up @@ -234,7 +236,7 @@ func get_tab_count() -> int:


func _can_handle_drag_data(data) -> bool:
if data is Dictionary and data.get("type") == "tabc_element":
if data is Dictionary and data.get("type") in ["tab_container_tab", "tabc_element"]:
var tabc := get_node_or_null(data.get("from_path"))
return (
tabc
Expand Down
2 changes: 1 addition & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Layout information is stored in Resource objects, so they can be saved/loaded fr
This plugin also offers a replica of the Container layout to be edited directly in the inspector."
run/main_scene="res://addons/dockable_container/samples/TestScene.tscn"
config/features=PackedStringArray("4.1")
config/features=PackedStringArray("4.2")
config/icon="res://icon.svg"

[debug]
Expand Down

0 comments on commit c5d25d8

Please sign in to comment.