Merge pull request #83966 from kitbdev/fix-tabcontainer-drag

Fix `TabContainer` drag to rearrange issue
This commit is contained in:
Rémi Verschelde 2023-10-26 09:01:09 +02:00
commit 71bef69318
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 12 additions and 2 deletions

View File

@ -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));
}
@ -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) {

View File

@ -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;