Skip to content

Commit

Permalink
Merge pull request #83966 from kitbdev/fix-tabcontainer-drag
Browse files Browse the repository at this point in the history
Fix `TabContainer` drag to rearrange issue
  • Loading branch information
akien-mga committed Oct 26, 2023
2 parents 53a894e + b788487 commit 71bef69
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 11 additions & 2 deletions scene/gui/tab_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,14 +330,23 @@ Vector<Control *> TabContainer::_get_tab_controls() const {
}

Variant TabContainer::_get_drag_data_fw(const Point2 &p_point, Control *p_from_control) {
if (!drag_to_rearrange_enabled) {
return Variant();
}
return tab_bar->_handle_get_drag_data("tab_container_tab", p_point);
}

bool TabContainer::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from_control) const {
if (!drag_to_rearrange_enabled) {
return false;
}
return tab_bar->_handle_can_drop_data("tab_container_tab", p_point, p_data);
}

void TabContainer::_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from_control) {
if (!drag_to_rearrange_enabled) {
return;
}
return tab_bar->_handle_drop_data("tab_container_tab", p_point, p_data, callable_mp(this, &TabContainer::_drag_move_tab), callable_mp(this, &TabContainer::_drag_move_tab_from));
}

Expand Down Expand Up @@ -815,11 +824,11 @@ Popup *TabContainer::get_popup() const {
}

void TabContainer::set_drag_to_rearrange_enabled(bool p_enabled) {
tab_bar->set_drag_to_rearrange_enabled(p_enabled);
drag_to_rearrange_enabled = p_enabled;
}

bool TabContainer::get_drag_to_rearrange_enabled() const {
return tab_bar->get_drag_to_rearrange_enabled();
return drag_to_rearrange_enabled;
}

void TabContainer::set_tabs_rearrange_group(int p_group_id) {
Expand Down
1 change: 1 addition & 0 deletions scene/gui/tab_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class TabContainer : public Container {
bool use_hidden_tabs_for_min_size = false;
bool theme_changing = false;
Vector<Control *> children_removing;
bool drag_to_rearrange_enabled = false;

struct ThemeCache {
int side_margin = 0;
Expand Down

0 comments on commit 71bef69

Please sign in to comment.