feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -98,6 +98,10 @@ Size2 TabBar::get_minimum_size() const {
|
|||
if (ms.width - ofs > style->get_minimum_size().width) {
|
||||
ms.width -= theme_cache.h_separation;
|
||||
}
|
||||
|
||||
if (i < tabs.size() - 1) {
|
||||
ms.width += theme_cache.tab_separation;
|
||||
}
|
||||
}
|
||||
|
||||
if (clip_tabs) {
|
||||
|
|
@ -203,6 +207,10 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) {
|
|||
queue_redraw();
|
||||
}
|
||||
|
||||
if (close_with_middle_mouse && mb->is_pressed() && mb->get_button_index() == MouseButton::MIDDLE) {
|
||||
emit_signal(SNAME("tab_close_pressed"), hover);
|
||||
}
|
||||
|
||||
if (mb->is_pressed() && (mb->get_button_index() == MouseButton::LEFT || (select_with_rmb && mb->get_button_index() == MouseButton::RIGHT))) {
|
||||
Point2 pos = mb->get_position();
|
||||
|
||||
|
|
@ -347,6 +355,35 @@ void TabBar::_shape(int p_tab) {
|
|||
tabs.write[p_tab].text_buf->add_string(atr(tabs[p_tab].text), theme_cache.font, theme_cache.font_size, tabs[p_tab].language);
|
||||
}
|
||||
|
||||
RID TabBar::get_tab_accessibility_element(int p_tab) const {
|
||||
RID ae = get_accessibility_element();
|
||||
ERR_FAIL_COND_V(ae.is_null(), RID());
|
||||
|
||||
const Tab &item = tabs[p_tab];
|
||||
if (item.accessibility_item_element.is_null()) {
|
||||
item.accessibility_item_element = DisplayServer::get_singleton()->accessibility_create_sub_element(ae, DisplayServer::AccessibilityRole::ROLE_TAB);
|
||||
item.accessibility_item_dirty = true;
|
||||
}
|
||||
return item.accessibility_item_element;
|
||||
}
|
||||
|
||||
RID TabBar::get_focused_accessibility_element() const {
|
||||
if (current == -1) {
|
||||
return get_accessibility_element();
|
||||
} else {
|
||||
const Tab &item = tabs[current];
|
||||
return item.accessibility_item_element;
|
||||
}
|
||||
}
|
||||
|
||||
void TabBar::_accessibility_action_scroll_into_view(const Variant &p_data, int p_index) {
|
||||
ensure_tab_visible(p_index);
|
||||
}
|
||||
|
||||
void TabBar::_accessibility_action_focus(const Variant &p_data, int p_index) {
|
||||
set_current_tab(p_index);
|
||||
}
|
||||
|
||||
void TabBar::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
|
|
@ -379,6 +416,46 @@ void TabBar::_notification(int p_what) {
|
|||
}
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_EXIT_TREE:
|
||||
case NOTIFICATION_ACCESSIBILITY_INVALIDATE: {
|
||||
for (int i = 0; i < tabs.size(); i++) {
|
||||
tabs.write[i].accessibility_item_element = RID();
|
||||
}
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_ACCESSIBILITY_UPDATE: {
|
||||
RID ae = get_accessibility_element();
|
||||
ERR_FAIL_COND(ae.is_null());
|
||||
|
||||
DisplayServer::get_singleton()->accessibility_update_set_role(ae, DisplayServer::AccessibilityRole::ROLE_TAB_BAR);
|
||||
DisplayServer::get_singleton()->accessibility_update_set_list_item_count(ae, tabs.size());
|
||||
|
||||
for (int i = 0; i < tabs.size(); i++) {
|
||||
const Tab &item = tabs[i];
|
||||
|
||||
if (item.accessibility_item_element.is_null()) {
|
||||
item.accessibility_item_element = DisplayServer::get_singleton()->accessibility_create_sub_element(ae, DisplayServer::AccessibilityRole::ROLE_TAB);
|
||||
item.accessibility_item_dirty = true;
|
||||
}
|
||||
|
||||
if (item.accessibility_item_dirty) {
|
||||
DisplayServer::get_singleton()->accessibility_update_add_action(item.accessibility_item_element, DisplayServer::AccessibilityAction::ACTION_SCROLL_INTO_VIEW, callable_mp(this, &TabBar::_accessibility_action_scroll_into_view).bind(i));
|
||||
DisplayServer::get_singleton()->accessibility_update_add_action(item.accessibility_item_element, DisplayServer::AccessibilityAction::ACTION_FOCUS, callable_mp(this, &TabBar::_accessibility_action_focus).bind(i));
|
||||
|
||||
DisplayServer::get_singleton()->accessibility_update_set_list_item_index(item.accessibility_item_element, i);
|
||||
DisplayServer::get_singleton()->accessibility_update_set_name(item.accessibility_item_element, atr(item.text));
|
||||
DisplayServer::get_singleton()->accessibility_update_set_list_item_selected(item.accessibility_item_element, i == current);
|
||||
DisplayServer::get_singleton()->accessibility_update_set_flag(item.accessibility_item_element, DisplayServer::AccessibilityFlags::FLAG_DISABLED, item.disabled);
|
||||
DisplayServer::get_singleton()->accessibility_update_set_flag(item.accessibility_item_element, DisplayServer::AccessibilityFlags::FLAG_HIDDEN, item.hidden);
|
||||
DisplayServer::get_singleton()->accessibility_update_set_tooltip(item.accessibility_item_element, item.tooltip);
|
||||
|
||||
DisplayServer::get_singleton()->accessibility_update_set_bounds(item.accessibility_item_element, Rect2(Point2(item.ofs_cache, 0), Size2(item.size_cache, get_size().height)));
|
||||
|
||||
item.accessibility_item_dirty = false;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: {
|
||||
queue_redraw();
|
||||
} break;
|
||||
|
|
@ -389,6 +466,7 @@ void TabBar::_notification(int p_what) {
|
|||
_shape(i);
|
||||
}
|
||||
|
||||
queue_accessibility_update();
|
||||
queue_redraw();
|
||||
update_minimum_size();
|
||||
|
||||
|
|
@ -430,9 +508,12 @@ void TabBar::_notification(int p_what) {
|
|||
int limit_minus_buttons = size.width - theme_cache.increment_icon->get_width() - theme_cache.decrement_icon->get_width();
|
||||
|
||||
int ofs = tabs[offset].ofs_cache;
|
||||
int tab_separation_offset = 0;
|
||||
|
||||
// Draw unselected tabs in the back.
|
||||
for (int i = offset; i <= max_drawn_tab; i++) {
|
||||
tab_separation_offset = (i - offset) * theme_cache.tab_separation;
|
||||
|
||||
if (tabs[i].hidden) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -452,7 +533,7 @@ void TabBar::_notification(int p_what) {
|
|||
col = theme_cache.font_unselected_color;
|
||||
}
|
||||
|
||||
_draw_tab(sb, col, i, rtl ? size.width - ofs - tabs[i].size_cache : ofs, false);
|
||||
_draw_tab(sb, col, i, rtl ? (size.width - ofs - tab_separation_offset - tabs[i].size_cache) : (ofs + tab_separation_offset), false);
|
||||
}
|
||||
|
||||
ofs += tabs[i].size_cache;
|
||||
|
|
@ -460,8 +541,13 @@ void TabBar::_notification(int p_what) {
|
|||
|
||||
// Draw selected tab in the front, but only if it's visible.
|
||||
if (current >= offset && current <= max_drawn_tab && !tabs[current].hidden) {
|
||||
tab_separation_offset = (current - offset) * theme_cache.tab_separation;
|
||||
if (tab_alignment == ALIGNMENT_LEFT && (current - offset) > 1) {
|
||||
tab_separation_offset = theme_cache.tab_separation;
|
||||
}
|
||||
|
||||
Ref<StyleBox> sb = tabs[current].disabled ? theme_cache.tab_disabled_style : theme_cache.tab_selected_style;
|
||||
float x = rtl ? size.width - tabs[current].ofs_cache - tabs[current].size_cache : tabs[current].ofs_cache;
|
||||
float x = rtl ? (size.width - tabs[current].ofs_cache - tab_separation_offset - tabs[current].size_cache) : (tabs[current].ofs_cache + tab_separation_offset);
|
||||
|
||||
_draw_tab(sb, theme_cache.font_selected_color, current, x, has_focus());
|
||||
}
|
||||
|
|
@ -499,13 +585,41 @@ void TabBar::_notification(int p_what) {
|
|||
if (dragging_valid_tab) {
|
||||
int x;
|
||||
|
||||
int tab_hover = get_hovered_tab();
|
||||
if (tab_hover != -1) {
|
||||
Rect2 tab_rect = get_tab_rect(tab_hover);
|
||||
int closest_tab = get_closest_tab_idx_to_point(get_local_mouse_position());
|
||||
if (closest_tab != -1) {
|
||||
Rect2 tab_rect = get_tab_rect(closest_tab);
|
||||
|
||||
x = tab_rect.position.x;
|
||||
if (get_local_mouse_position().x > x + tab_rect.size.width / 2) {
|
||||
x += tab_rect.size.width;
|
||||
// Calculate midpoint between tabs.
|
||||
if (rtl) {
|
||||
if (get_local_mouse_position().x > tab_rect.position.x + tab_rect.size.width / 2) {
|
||||
if (closest_tab > 0) { // On right side of closest_tab and not first tab.
|
||||
Rect2 next_tab_rect = get_tab_rect(closest_tab - 1);
|
||||
x = (tab_rect.position.x + tab_rect.size.width + next_tab_rect.position.x) / 2;
|
||||
} else { // First tab, will appear on right edge.
|
||||
x = tab_rect.position.x + tab_rect.size.width;
|
||||
}
|
||||
} else {
|
||||
if (closest_tab < max_drawn_tab) { // On left side of closest_tab and not last tab.
|
||||
Rect2 prev_tab_rect = get_tab_rect(closest_tab + 1);
|
||||
x = (tab_rect.position.x + prev_tab_rect.position.x + prev_tab_rect.size.width) / 2;
|
||||
} else { // Last tab, will appear on left edge.
|
||||
x = tab_rect.position.x;
|
||||
}
|
||||
}
|
||||
} else if (get_local_mouse_position().x > tab_rect.position.x + tab_rect.size.width / 2) {
|
||||
if (closest_tab < max_drawn_tab) { // On right side of closest_tab and not last tab.
|
||||
Rect2 next_tab_rect = get_tab_rect(closest_tab + 1);
|
||||
x = (tab_rect.position.x + tab_rect.size.width + next_tab_rect.position.x) / 2;
|
||||
} else { // Last tab, will appear on right edge.
|
||||
x = tab_rect.position.x + tab_rect.size.width;
|
||||
}
|
||||
} else {
|
||||
if (closest_tab > 0) { // On left side of closest_tab and not first tab.
|
||||
Rect2 prev_tab_rect = get_tab_rect(closest_tab - 1);
|
||||
x = (tab_rect.position.x + prev_tab_rect.position.x + prev_tab_rect.size.width) / 2;
|
||||
} else { // First tab, will appear on left edge.
|
||||
x = tab_rect.position.x;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (rtl ^ (get_local_mouse_position().x < get_tab_rect(0).position.x)) {
|
||||
|
|
@ -632,6 +746,15 @@ void TabBar::set_tab_count(int p_count) {
|
|||
}
|
||||
|
||||
ERR_FAIL_COND(p_count < 0);
|
||||
|
||||
if (tabs.size() > p_count) {
|
||||
for (int i = p_count; i < tabs.size(); i++) {
|
||||
if (tabs[i].accessibility_item_element.is_valid()) {
|
||||
DisplayServer::get_singleton()->accessibility_free_element(tabs.write[i].accessibility_item_element);
|
||||
tabs.write[i].accessibility_item_element = RID();
|
||||
}
|
||||
}
|
||||
}
|
||||
tabs.resize(p_count);
|
||||
|
||||
if (p_count == 0) {
|
||||
|
|
@ -662,6 +785,7 @@ void TabBar::set_tab_count(int p_count) {
|
|||
}
|
||||
}
|
||||
|
||||
queue_accessibility_update();
|
||||
queue_redraw();
|
||||
update_minimum_size();
|
||||
notify_property_list_changed();
|
||||
|
|
@ -697,6 +821,7 @@ void TabBar::set_current_tab(int p_current) {
|
|||
if (scroll_to_selected) {
|
||||
ensure_tab_visible(current);
|
||||
}
|
||||
queue_accessibility_update();
|
||||
queue_redraw();
|
||||
|
||||
emit_signal(SNAME("tab_changed"), p_current);
|
||||
|
|
@ -745,6 +870,7 @@ void TabBar::set_tab_offset(int p_offset) {
|
|||
ERR_FAIL_INDEX(p_offset, tabs.size());
|
||||
offset = p_offset;
|
||||
_update_cache();
|
||||
queue_accessibility_update();
|
||||
queue_redraw();
|
||||
}
|
||||
|
||||
|
|
@ -771,6 +897,7 @@ void TabBar::set_tab_title(int p_tab, const String &p_title) {
|
|||
if (scroll_to_selected) {
|
||||
ensure_tab_visible(current);
|
||||
}
|
||||
queue_accessibility_update();
|
||||
queue_redraw();
|
||||
update_minimum_size();
|
||||
}
|
||||
|
|
@ -783,6 +910,7 @@ String TabBar::get_tab_title(int p_tab) const {
|
|||
void TabBar::set_tab_tooltip(int p_tab, const String &p_tooltip) {
|
||||
ERR_FAIL_INDEX(p_tab, tabs.size());
|
||||
tabs.write[p_tab].tooltip = p_tooltip;
|
||||
queue_accessibility_update();
|
||||
}
|
||||
|
||||
String TabBar::get_tab_tooltip(int p_tab) const {
|
||||
|
|
@ -796,7 +924,9 @@ void TabBar::set_tab_text_direction(int p_tab, Control::TextDirection p_text_dir
|
|||
|
||||
if (tabs[p_tab].text_direction != p_text_direction) {
|
||||
tabs.write[p_tab].text_direction = p_text_direction;
|
||||
|
||||
_shape(p_tab);
|
||||
queue_accessibility_update();
|
||||
queue_redraw();
|
||||
}
|
||||
}
|
||||
|
|
@ -811,12 +941,14 @@ void TabBar::set_tab_language(int p_tab, const String &p_language) {
|
|||
|
||||
if (tabs[p_tab].language != p_language) {
|
||||
tabs.write[p_tab].language = p_language;
|
||||
|
||||
_shape(p_tab);
|
||||
_update_cache();
|
||||
_ensure_no_over_offset();
|
||||
if (scroll_to_selected) {
|
||||
ensure_tab_visible(current);
|
||||
}
|
||||
queue_accessibility_update();
|
||||
queue_redraw();
|
||||
update_minimum_size();
|
||||
}
|
||||
|
|
@ -887,6 +1019,7 @@ void TabBar::set_tab_disabled(int p_tab, bool p_disabled) {
|
|||
if (scroll_to_selected) {
|
||||
ensure_tab_visible(current);
|
||||
}
|
||||
queue_accessibility_update();
|
||||
queue_redraw();
|
||||
update_minimum_size();
|
||||
}
|
||||
|
|
@ -910,6 +1043,7 @@ void TabBar::set_tab_hidden(int p_tab, bool p_hidden) {
|
|||
if (scroll_to_selected) {
|
||||
ensure_tab_visible(current);
|
||||
}
|
||||
queue_accessibility_update();
|
||||
queue_redraw();
|
||||
update_minimum_size();
|
||||
}
|
||||
|
|
@ -1053,12 +1187,17 @@ void TabBar::_update_cache(bool p_update_hover) {
|
|||
}
|
||||
|
||||
w += tabs[i].size_cache;
|
||||
if ((i - offset) > 0) {
|
||||
w += theme_cache.tab_separation;
|
||||
}
|
||||
|
||||
// Check if all tabs would fit inside the area.
|
||||
if (clip_tabs && i > offset && (w > limit || (offset > 0 && w > limit_minus_buttons))) {
|
||||
tabs.write[i].ofs_cache = 0;
|
||||
|
||||
w -= tabs[i].size_cache;
|
||||
w -= theme_cache.tab_separation;
|
||||
|
||||
max_drawn_tab = i - 1;
|
||||
|
||||
while (w > limit_minus_buttons && max_drawn_tab > offset) {
|
||||
|
|
@ -1066,11 +1205,14 @@ void TabBar::_update_cache(bool p_update_hover) {
|
|||
|
||||
if (!tabs[max_drawn_tab].hidden) {
|
||||
w -= tabs[max_drawn_tab].size_cache;
|
||||
w -= theme_cache.tab_separation;
|
||||
}
|
||||
|
||||
max_drawn_tab--;
|
||||
}
|
||||
}
|
||||
|
||||
tabs.write[i].accessibility_item_dirty = true;
|
||||
}
|
||||
|
||||
missing_right = max_drawn_tab < tabs.size() - 1;
|
||||
|
|
@ -1125,6 +1267,7 @@ void TabBar::add_tab(const String &p_str, const Ref<Texture2D> &p_icon) {
|
|||
if (scroll_to_selected) {
|
||||
ensure_tab_visible(current);
|
||||
}
|
||||
queue_accessibility_update();
|
||||
queue_redraw();
|
||||
update_minimum_size();
|
||||
|
||||
|
|
@ -1143,12 +1286,19 @@ void TabBar::clear_tabs() {
|
|||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < tabs.size(); i++) {
|
||||
if (tabs[i].accessibility_item_element.is_valid()) {
|
||||
DisplayServer::get_singleton()->accessibility_free_element(tabs.write[i].accessibility_item_element);
|
||||
tabs.write[i].accessibility_item_element = RID();
|
||||
}
|
||||
}
|
||||
tabs.clear();
|
||||
offset = 0;
|
||||
max_drawn_tab = 0;
|
||||
current = -1;
|
||||
previous = -1;
|
||||
|
||||
queue_accessibility_update();
|
||||
queue_redraw();
|
||||
update_minimum_size();
|
||||
notify_property_list_changed();
|
||||
|
|
@ -1156,6 +1306,11 @@ void TabBar::clear_tabs() {
|
|||
|
||||
void TabBar::remove_tab(int p_idx) {
|
||||
ERR_FAIL_INDEX(p_idx, tabs.size());
|
||||
|
||||
if (tabs[p_idx].accessibility_item_element.is_valid()) {
|
||||
DisplayServer::get_singleton()->accessibility_free_element(tabs.write[p_idx].accessibility_item_element);
|
||||
tabs.write[p_idx].accessibility_item_element = RID();
|
||||
}
|
||||
tabs.remove_at(p_idx);
|
||||
|
||||
bool is_tab_changing = current == p_idx;
|
||||
|
|
@ -1205,6 +1360,7 @@ void TabBar::remove_tab(int p_idx) {
|
|||
}
|
||||
}
|
||||
|
||||
queue_accessibility_update();
|
||||
queue_redraw();
|
||||
update_minimum_size();
|
||||
notify_property_list_changed();
|
||||
|
|
@ -1238,7 +1394,7 @@ void TabBar::drop_data(const Point2 &p_point, const Variant &p_data) {
|
|||
}
|
||||
|
||||
Variant TabBar::_handle_get_drag_data(const String &p_type, const Point2 &p_point) {
|
||||
int tab_over = get_tab_idx_at_point(p_point);
|
||||
int tab_over = (p_point == Vector2(Math::INF, Math::INF)) ? current : get_tab_idx_at_point(p_point);
|
||||
if (tab_over < 0) {
|
||||
return Variant();
|
||||
}
|
||||
|
|
@ -1303,7 +1459,7 @@ void TabBar::_handle_drop_data(const String &p_type, const Point2 &p_point, cons
|
|||
|
||||
if (String(d["type"]) == p_type) {
|
||||
int tab_from_id = d["tab_index"];
|
||||
int hover_now = get_tab_idx_at_point(p_point);
|
||||
int hover_now = (p_point == Vector2(Math::INF, Math::INF)) ? current : get_closest_tab_idx_to_point(p_point);
|
||||
NodePath from_path = d["from_path"];
|
||||
NodePath to_path = get_path();
|
||||
|
||||
|
|
@ -1361,6 +1517,8 @@ void TabBar::_handle_drop_data(const String &p_type, const Point2 &p_point, cons
|
|||
|
||||
void TabBar::_move_tab_from(TabBar *p_from_tabbar, int p_from_index, int p_to_index) {
|
||||
Tab moving_tab = p_from_tabbar->tabs[p_from_index];
|
||||
moving_tab.accessibility_item_element = RID();
|
||||
moving_tab.accessibility_item_dirty = true;
|
||||
p_from_tabbar->remove_tab(p_from_index);
|
||||
tabs.insert(p_to_index, moving_tab);
|
||||
|
||||
|
|
@ -1380,6 +1538,7 @@ void TabBar::_move_tab_from(TabBar *p_from_tabbar, int p_from_index, int p_to_in
|
|||
queue_redraw();
|
||||
}
|
||||
|
||||
queue_accessibility_update();
|
||||
update_minimum_size();
|
||||
}
|
||||
|
||||
|
|
@ -1398,6 +1557,24 @@ int TabBar::get_tab_idx_at_point(const Point2 &p_point) const {
|
|||
return hover_now;
|
||||
}
|
||||
|
||||
int TabBar::get_closest_tab_idx_to_point(const Point2 &p_point) const {
|
||||
int closest_tab = get_tab_idx_at_point(p_point); // See if we're hovering over a tab first.
|
||||
|
||||
if (closest_tab == -1) { // Didn't find a tab, so get the closest one.
|
||||
float closest_distance = FLT_MAX;
|
||||
for (int i = offset; i <= max_drawn_tab; i++) {
|
||||
Vector2 center = get_tab_rect(i).get_center();
|
||||
float distance = center.distance_to(p_point);
|
||||
if (distance < closest_distance) {
|
||||
closest_distance = distance;
|
||||
closest_tab = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return closest_tab;
|
||||
}
|
||||
|
||||
void TabBar::set_tab_alignment(AlignmentMode p_alignment) {
|
||||
ERR_FAIL_INDEX(p_alignment, ALIGNMENT_MAX);
|
||||
|
||||
|
|
@ -1451,6 +1628,8 @@ void TabBar::move_tab(int p_from, int p_to) {
|
|||
ERR_FAIL_INDEX(p_to, tabs.size());
|
||||
|
||||
Tab tab_from = tabs[p_from];
|
||||
tab_from.accessibility_item_dirty = true;
|
||||
|
||||
tabs.remove_at(p_from);
|
||||
tabs.insert(p_to, tab_from);
|
||||
|
||||
|
|
@ -1475,6 +1654,7 @@ void TabBar::move_tab(int p_from, int p_to) {
|
|||
if (scroll_to_selected) {
|
||||
ensure_tab_visible(current);
|
||||
}
|
||||
queue_accessibility_update();
|
||||
queue_redraw();
|
||||
notify_property_list_changed();
|
||||
}
|
||||
|
|
@ -1647,11 +1827,23 @@ void TabBar::ensure_tab_visible(int p_idx) {
|
|||
|
||||
Rect2 TabBar::get_tab_rect(int p_tab) const {
|
||||
ERR_FAIL_INDEX_V(p_tab, tabs.size(), Rect2());
|
||||
if (is_layout_rtl()) {
|
||||
return Rect2(get_size().width - tabs[p_tab].ofs_cache - tabs[p_tab].size_cache, 0, tabs[p_tab].size_cache, get_size().height);
|
||||
} else {
|
||||
return Rect2(tabs[p_tab].ofs_cache, 0, tabs[p_tab].size_cache, get_size().height);
|
||||
int tab_separation_offset = (p_tab - offset) * theme_cache.tab_separation;
|
||||
if (tab_alignment == ALIGNMENT_LEFT && (p_tab - offset) > 1) {
|
||||
tab_separation_offset = theme_cache.tab_separation;
|
||||
}
|
||||
if (is_layout_rtl()) {
|
||||
return Rect2(get_size().width - tabs[p_tab].ofs_cache - tab_separation_offset - tabs[p_tab].size_cache, 0, tabs[p_tab].size_cache, get_size().height);
|
||||
} else {
|
||||
return Rect2(tabs[p_tab].ofs_cache + tab_separation_offset, 0, tabs[p_tab].size_cache, get_size().height);
|
||||
}
|
||||
}
|
||||
|
||||
void TabBar::set_close_with_middle_mouse(bool p_scroll_close) {
|
||||
close_with_middle_mouse = p_scroll_close;
|
||||
}
|
||||
|
||||
bool TabBar::get_close_with_middle_mouse() const {
|
||||
return close_with_middle_mouse;
|
||||
}
|
||||
|
||||
void TabBar::set_tab_close_display_policy(CloseButtonDisplayPolicy p_policy) {
|
||||
|
|
@ -1795,6 +1987,8 @@ void TabBar::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("ensure_tab_visible", "idx"), &TabBar::ensure_tab_visible);
|
||||
ClassDB::bind_method(D_METHOD("get_tab_rect", "tab_idx"), &TabBar::get_tab_rect);
|
||||
ClassDB::bind_method(D_METHOD("move_tab", "from", "to"), &TabBar::move_tab);
|
||||
ClassDB::bind_method(D_METHOD("set_close_with_middle_mouse", "enabled"), &TabBar::set_close_with_middle_mouse);
|
||||
ClassDB::bind_method(D_METHOD("get_close_with_middle_mouse"), &TabBar::get_close_with_middle_mouse);
|
||||
ClassDB::bind_method(D_METHOD("set_tab_close_display_policy", "policy"), &TabBar::set_tab_close_display_policy);
|
||||
ClassDB::bind_method(D_METHOD("get_tab_close_display_policy"), &TabBar::get_tab_close_display_policy);
|
||||
ClassDB::bind_method(D_METHOD("set_max_tab_width", "width"), &TabBar::set_max_tab_width);
|
||||
|
|
@ -1825,6 +2019,7 @@ void TabBar::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::INT, "current_tab", PROPERTY_HINT_RANGE, "-1,4096,1"), "set_current_tab", "get_current_tab");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "tab_alignment", PROPERTY_HINT_ENUM, "Left,Center,Right"), "set_tab_alignment", "get_tab_alignment");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "clip_tabs"), "set_clip_tabs", "get_clip_tabs");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "close_with_middle_mouse"), "set_close_with_middle_mouse", "get_close_with_middle_mouse");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "tab_close_display_policy", PROPERTY_HINT_ENUM, "Show Never,Show Active Only,Show Always"), "set_tab_close_display_policy", "get_tab_close_display_policy");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_tab_width", PROPERTY_HINT_RANGE, "0,99999,1,suffix:px"), "set_max_tab_width", "get_max_tab_width");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scrolling_enabled"), "set_scrolling_enabled", "get_scrolling_enabled");
|
||||
|
|
@ -1847,6 +2042,7 @@ void TabBar::_bind_methods() {
|
|||
BIND_ENUM_CONSTANT(CLOSE_BUTTON_MAX);
|
||||
|
||||
BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, TabBar, h_separation);
|
||||
BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, TabBar, tab_separation);
|
||||
BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, TabBar, icon_max_width);
|
||||
|
||||
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, TabBar, tab_unselected_style, "tab_unselected");
|
||||
|
|
@ -1888,6 +2084,7 @@ void TabBar::_bind_methods() {
|
|||
}
|
||||
|
||||
TabBar::TabBar() {
|
||||
set_focus_mode(FOCUS_ACCESSIBILITY);
|
||||
set_size(Size2(get_size().width, get_minimum_size().height));
|
||||
set_focus_mode(FOCUS_ALL);
|
||||
connect(SceneStringName(mouse_exited), callable_mp(this, &TabBar::_on_mouse_exited));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue