Merge pull request #53926 from YeldhamDev/i_am_tabbar_now

This commit is contained in:
Rémi Verschelde 2021-10-20 15:42:41 +02:00 committed by GitHub
commit c942d567eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 269 additions and 269 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="Tabs" inherits="Control" version="4.0">
<class name="TabBar" inherits="Control" version="4.0">
<brief_description>
Tabs control.
Tab bar control.
</brief_description>
<description>
Simple tabs control, similar to [TabContainer] but is only in charge of drawing tabs, not interacting with children.
@ -114,7 +114,7 @@
<method name="get_tabs_rearrange_group" qualifiers="const">
<return type="int" />
<description>
Returns the [Tabs]' rearrange group ID.
Returns the [TabBar]'s rearrange group ID.
</description>
</method>
<method name="move_tab">
@ -192,7 +192,7 @@
<return type="void" />
<argument index="0" name="group_id" type="int" />
<description>
Defines the rearrange group ID. Choose for each [Tabs] the same value to dragging tabs between [Tabs]. Enable drag with [member drag_to_rearrange_enabled].
Defines the rearrange group ID. Choose for each [TabBar] the same value to dragging tabs between [TabBar]. Enable drag with [member drag_to_rearrange_enabled].
</description>
</method>
</methods>
@ -209,10 +209,10 @@
<member name="scrolling_enabled" type="bool" setter="set_scrolling_enabled" getter="get_scrolling_enabled" default="true">
if [code]true[/code], the mouse's scroll wheel can be used to navigate the scroll view.
</member>
<member name="tab_align" type="int" setter="set_tab_align" getter="get_tab_align" enum="Tabs.TabAlign" default="1">
<member name="tab_align" type="int" setter="set_tab_align" getter="get_tab_align" enum="TabBar.TabAlign" default="1">
The alignment of all tabs. See [enum TabAlign] for details.
</member>
<member name="tab_close_display_policy" type="int" setter="set_tab_close_display_policy" getter="get_tab_close_display_policy" enum="Tabs.CloseButtonDisplayPolicy" default="0">
<member name="tab_close_display_policy" type="int" setter="set_tab_close_display_policy" getter="get_tab_close_display_policy" enum="TabBar.CloseButtonDisplayPolicy" default="0">
Sets when the close button will appear on the tabs. See [enum CloseButtonDisplayPolicy] for details.
</member>
</members>

View File

@ -59,8 +59,8 @@
#include "scene/gui/panel.h"
#include "scene/gui/panel_container.h"
#include "scene/gui/split_container.h"
#include "scene/gui/tab_bar.h"
#include "scene/gui/tab_container.h"
#include "scene/gui/tabs.h"
#include "scene/gui/texture_progress_bar.h"
#include "scene/main/window.h"
#include "scene/resources/packed_scene.h"
@ -658,7 +658,7 @@ void EditorNode::_notification(int p_what) {
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
scene_tabs->set_tab_close_display_policy((bool(EDITOR_GET("interface/scene_tabs/always_show_close_button")) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY));
scene_tabs->set_tab_close_display_policy((bool(EDITOR_GET("interface/scene_tabs/always_show_close_button")) ? TabBar::CLOSE_BUTTON_SHOW_ALWAYS : TabBar::CLOSE_BUTTON_SHOW_ACTIVE_ONLY));
theme = create_custom_theme(theme_base->get_theme());
theme_base->set_theme(theme);
@ -6217,13 +6217,13 @@ EditorNode::EditorNode() {
tab_preview->set_position(Point2(2, 2) * EDSCALE);
tab_preview_panel->add_child(tab_preview);
scene_tabs = memnew(Tabs);
scene_tabs = memnew(TabBar);
scene_tabs->add_theme_style_override("tab_selected", gui_base->get_theme_stylebox(SNAME("SceneTabFG"), SNAME("EditorStyles")));
scene_tabs->add_theme_style_override("tab_unselected", gui_base->get_theme_stylebox(SNAME("SceneTabBG"), SNAME("EditorStyles")));
scene_tabs->set_select_with_rmb(true);
scene_tabs->add_tab("unsaved");
scene_tabs->set_tab_align(Tabs::ALIGN_LEFT);
scene_tabs->set_tab_close_display_policy((bool(EDITOR_DEF("interface/scene_tabs/always_show_close_button", false)) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY));
scene_tabs->set_tab_align(TabBar::ALIGN_LEFT);
scene_tabs->set_tab_close_display_policy((bool(EDITOR_DEF("interface/scene_tabs/always_show_close_button", false)) ? TabBar::CLOSE_BUTTON_SHOW_ALWAYS : TabBar::CLOSE_BUTTON_SHOW_ACTIVE_ONLY));
scene_tabs->set_min_width(int(EDITOR_DEF("interface/scene_tabs/minimum_width", 50)) * EDSCALE);
scene_tabs->set_drag_to_rearrange_enabled(true);
scene_tabs->connect("tab_changed", callable_mp(this, &EditorNode::_scene_tab_changed));

View File

@ -85,7 +85,7 @@ class ProjectSettingsEditor;
class RunSettingsDialog;
class ScriptCreateDialog;
class TabContainer;
class Tabs;
class TabBar;
class TextureProgressBar;
class Button;
class VSplitContainer;
@ -250,7 +250,7 @@ private:
// Main tabs
Tabs *scene_tabs;
TabBar *scene_tabs;
PopupMenu *scene_tabs_context_menu;
Panel *tab_preview_panel;
TextureRect *tab_preview;

View File

@ -548,7 +548,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
Ref<StyleBoxEmpty> style_empty = make_empty_stylebox(default_margin_size, default_margin_size, default_margin_size, default_margin_size);
// Tabs
// TabBar
Ref<StyleBoxFlat> style_tab_selected = style_widget->duplicate();
@ -949,33 +949,33 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_constant("icon_margin", "ItemList", 6 * EDSCALE);
theme->set_constant("line_separation", "ItemList", 3 * EDSCALE);
// Tabs & TabContainer
// TabBar & TabContainer
theme->set_stylebox("tab_selected", "TabContainer", style_tab_selected);
theme->set_stylebox("tab_unselected", "TabContainer", style_tab_unselected);
theme->set_stylebox("tab_disabled", "TabContainer", style_tab_disabled);
theme->set_stylebox("tab_selected", "Tabs", style_tab_selected);
theme->set_stylebox("tab_unselected", "Tabs", style_tab_unselected);
theme->set_stylebox("tab_disabled", "Tabs", style_tab_disabled);
theme->set_stylebox("tab_selected", "TabBar", style_tab_selected);
theme->set_stylebox("tab_unselected", "TabBar", style_tab_unselected);
theme->set_stylebox("tab_disabled", "TabBar", style_tab_disabled);
theme->set_color("font_selected_color", "TabContainer", font_color);
theme->set_color("font_unselected_color", "TabContainer", font_disabled_color);
theme->set_color("font_selected_color", "Tabs", font_color);
theme->set_color("font_unselected_color", "Tabs", font_disabled_color);
theme->set_color("font_selected_color", "TabBar", font_color);
theme->set_color("font_unselected_color", "TabBar", font_disabled_color);
theme->set_icon("menu", "TabContainer", theme->get_icon("GuiTabMenu", "EditorIcons"));
theme->set_icon("menu_highlight", "TabContainer", theme->get_icon("GuiTabMenuHl", "EditorIcons"));
theme->set_stylebox("SceneTabFG", "EditorStyles", style_tab_selected);
theme->set_stylebox("SceneTabBG", "EditorStyles", style_tab_unselected);
theme->set_icon("close", "Tabs", theme->get_icon("GuiClose", "EditorIcons"));
theme->set_stylebox("close_bg_pressed", "Tabs", style_menu);
theme->set_stylebox("close_bg_highlight", "Tabs", style_menu);
theme->set_icon("close", "TabBar", theme->get_icon("GuiClose", "EditorIcons"));
theme->set_stylebox("close_bg_pressed", "TabBar", style_menu);
theme->set_stylebox("close_bg_highlight", "TabBar", style_menu);
theme->set_icon("increment", "TabContainer", theme->get_icon("GuiScrollArrowRight", "EditorIcons"));
theme->set_icon("decrement", "TabContainer", theme->get_icon("GuiScrollArrowLeft", "EditorIcons"));
theme->set_icon("increment", "Tabs", theme->get_icon("GuiScrollArrowRight", "EditorIcons"));
theme->set_icon("decrement", "Tabs", theme->get_icon("GuiScrollArrowLeft", "EditorIcons"));
theme->set_icon("increment_highlight", "Tabs", theme->get_icon("GuiScrollArrowRightHl", "EditorIcons"));
theme->set_icon("decrement_highlight", "Tabs", theme->get_icon("GuiScrollArrowLeftHl", "EditorIcons"));
theme->set_icon("increment", "TabBar", theme->get_icon("GuiScrollArrowRight", "EditorIcons"));
theme->set_icon("decrement", "TabBar", theme->get_icon("GuiScrollArrowLeft", "EditorIcons"));
theme->set_icon("increment_highlight", "TabBar", theme->get_icon("GuiScrollArrowRightHl", "EditorIcons"));
theme->set_icon("decrement_highlight", "TabBar", theme->get_icon("GuiScrollArrowLeftHl", "EditorIcons"));
theme->set_icon("increment_highlight", "TabContainer", theme->get_icon("GuiScrollArrowRightHl", "EditorIcons"));
theme->set_icon("decrement_highlight", "TabContainer", theme->get_icon("GuiScrollArrowLeftHl", "EditorIcons"));
theme->set_constant("hseparation", "Tabs", 4 * EDSCALE);
theme->set_constant("hseparation", "TabBar", 4 * EDSCALE);
// Content of each tab
Ref<StyleBoxFlat> style_content_panel = style_default->duplicate();

View File

Before

Width:  |  Height:  |  Size: 202 B

After

Width:  |  Height:  |  Size: 202 B

View File

@ -3204,7 +3204,7 @@ void ThemeEditor::_add_preview_tab(ThemeEditorPreview *p_preview_tab, const Stri
preview_tabs->add_tab(p_preview_name, p_icon);
preview_tabs_content->add_child(p_preview_tab);
preview_tabs->set_tab_right_button(preview_tabs->get_tab_count() - 1, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("close"), SNAME("Tabs")));
preview_tabs->set_tab_right_button(preview_tabs->get_tab_count() - 1, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("close"), SNAME("TabBar")));
p_preview_tab->connect("control_picked", callable_mp(this, &ThemeEditor::_preview_control_picked));
preview_tabs->set_current_tab(preview_tabs->get_tab_count() - 1);
@ -3328,8 +3328,8 @@ ThemeEditor::ThemeEditor() {
preview_tabs_content->set_draw_behind_parent(true);
preview_tabs_vb->add_child(preview_tabs_content);
preview_tabs = memnew(Tabs);
preview_tabs->set_tab_align(Tabs::ALIGN_LEFT);
preview_tabs = memnew(TabBar);
preview_tabs->set_tab_align(TabBar::ALIGN_LEFT);
preview_tabs->set_h_size_flags(SIZE_EXPAND_FILL);
preview_tabbar_hb->add_child(preview_tabs);
preview_tabs->connect("tab_changed", callable_mp(this, &ThemeEditor::_change_preview_tab));

View File

@ -34,7 +34,7 @@
#include "scene/gui/margin_container.h"
#include "scene/gui/option_button.h"
#include "scene/gui/scroll_container.h"
#include "scene/gui/tabs.h"
#include "scene/gui/tab_bar.h"
#include "scene/gui/texture_rect.h"
#include "scene/resources/theme.h"
#include "theme_editor_preview.h"
@ -391,7 +391,7 @@ class ThemeEditor : public VBoxContainer {
Ref<Theme> theme;
Tabs *preview_tabs;
TabBar *preview_tabs;
PanelContainer *preview_tabs_content;
Button *add_preview_button;
EditorFileDialog *preview_scene_dialog;

View File

@ -4049,8 +4049,8 @@ TileMapEditor::TileMapEditor() {
tile_map_editor_plugins.push_back(memnew(TileMapEditorTilesPlugin));
tile_map_editor_plugins.push_back(memnew(TileMapEditorTerrainsPlugin));
// Tabs.
tabs_bar = memnew(Tabs);
// TabBar.
tabs_bar = memnew(TabBar);
tabs_bar->set_clip_tabs(false);
for (int plugin_index = 0; plugin_index < tile_map_editor_plugins.size(); plugin_index++) {
Vector<TileMapEditorPlugin::TabData> tabs_vector = tile_map_editor_plugins[plugin_index]->get_tabs();

View File

@ -38,7 +38,7 @@
#include "editor/editor_node.h"
#include "scene/2d/tile_map.h"
#include "scene/gui/box_container.h"
#include "scene/gui/tabs.h"
#include "scene/gui/tab_bar.h"
class TileMapEditorPlugin : public Object {
public:
@ -351,7 +351,7 @@ private:
// Bottom panel.
Label *missing_tileset_label;
Tabs *tabs_bar;
TabBar *tabs_bar;
LocalVector<TileMapEditorPlugin::TabData> tabs_data;
LocalVector<TileMapEditorPlugin *> tabs_plugins;
void _update_bottom_panel();

View File

@ -642,8 +642,8 @@ TileSetEditor::TileSetEditor() {
set_process_internal(true);
// Tabs.
tabs_bar = memnew(Tabs);
// TabBar.
tabs_bar = memnew(TabBar);
tabs_bar->set_clip_tabs(false);
tabs_bar->add_tab(TTR("Tiles"));
tabs_bar->add_tab(TTR("Patterns"));

View File

@ -48,9 +48,9 @@ private:
bool tile_set_changed_needs_update = false;
HSplitContainer *split_container;
// Tabs.
// TabBar.
HBoxContainer *tile_set_toolbar;
Tabs *tabs_bar;
TabBar *tabs_bar;
// Tiles.
Label *no_source_selected_label;

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* tabs.cpp */
/* tab_bar.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "tabs.h"
#include "tab_bar.h"
#include "core/object/message_queue.h"
#include "core/string/translation.h"
@ -37,7 +37,7 @@
#include "scene/gui/label.h"
#include "scene/gui/texture_rect.h"
Size2 Tabs::get_minimum_size() const {
Size2 TabBar::get_minimum_size() const {
Ref<StyleBox> tab_unselected = get_theme_stylebox(SNAME("tab_unselected"));
Ref<StyleBox> tab_selected = get_theme_stylebox(SNAME("tab_selected"));
Ref<StyleBox> tab_disabled = get_theme_stylebox(SNAME("tab_disabled"));
@ -90,7 +90,7 @@ Size2 Tabs::get_minimum_size() const {
return ms;
}
void Tabs::gui_input(const Ref<InputEvent> &p_event) {
void TabBar::gui_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
Ref<InputEventMouseMotion> mm = p_event;
@ -252,7 +252,7 @@ void Tabs::gui_input(const Ref<InputEvent> &p_event) {
}
}
void Tabs::_shape(int p_tab) {
void TabBar::_shape(int p_tab) {
Ref<Font> font = get_theme_font(SNAME("font"));
int font_size = get_theme_font_size(SNAME("font_size"));
@ -268,7 +268,7 @@ void Tabs::_shape(int p_tab) {
tabs.write[p_tab].text_buf->add_string(tabs.write[p_tab].xl_text, font, font_size, tabs[p_tab].opentype_features, (tabs[p_tab].language != "") ? tabs[p_tab].language : TranslationServer::get_singleton()->get_tool_locale());
}
void Tabs::_notification(int p_what) {
void TabBar::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: {
_update_cache();
@ -505,11 +505,11 @@ void Tabs::_notification(int p_what) {
}
}
int Tabs::get_tab_count() const {
int TabBar::get_tab_count() const {
return tabs.size();
}
void Tabs::set_current_tab(int p_current) {
void TabBar::set_current_tab(int p_current) {
if (current == p_current) {
return;
}
@ -524,27 +524,27 @@ void Tabs::set_current_tab(int p_current) {
emit_signal(SNAME("tab_changed"), p_current);
}
int Tabs::get_current_tab() const {
int TabBar::get_current_tab() const {
return current;
}
int Tabs::get_previous_tab() const {
int TabBar::get_previous_tab() const {
return previous;
}
int Tabs::get_hovered_tab() const {
int TabBar::get_hovered_tab() const {
return hover;
}
int Tabs::get_tab_offset() const {
int TabBar::get_tab_offset() const {
return offset;
}
bool Tabs::get_offset_buttons_visible() const {
bool TabBar::get_offset_buttons_visible() const {
return buttons_visible;
}
void Tabs::set_tab_title(int p_tab, const String &p_title) {
void TabBar::set_tab_title(int p_tab, const String &p_title) {
ERR_FAIL_INDEX(p_tab, tabs.size());
tabs.write[p_tab].text = p_title;
_shape(p_tab);
@ -552,12 +552,12 @@ void Tabs::set_tab_title(int p_tab, const String &p_title) {
minimum_size_changed();
}
String Tabs::get_tab_title(int p_tab) const {
String TabBar::get_tab_title(int p_tab) const {
ERR_FAIL_INDEX_V(p_tab, tabs.size(), "");
return tabs[p_tab].text;
}
void Tabs::set_tab_text_direction(int p_tab, Control::TextDirection p_text_direction) {
void TabBar::set_tab_text_direction(int p_tab, Control::TextDirection p_text_direction) {
ERR_FAIL_INDEX(p_tab, tabs.size());
ERR_FAIL_COND((int)p_text_direction < -1 || (int)p_text_direction > 3);
if (tabs[p_tab].text_direction != p_text_direction) {
@ -567,19 +567,19 @@ void Tabs::set_tab_text_direction(int p_tab, Control::TextDirection p_text_direc
}
}
Control::TextDirection Tabs::get_tab_text_direction(int p_tab) const {
Control::TextDirection TabBar::get_tab_text_direction(int p_tab) const {
ERR_FAIL_INDEX_V(p_tab, tabs.size(), Control::TEXT_DIRECTION_INHERITED);
return tabs[p_tab].text_direction;
}
void Tabs::clear_tab_opentype_features(int p_tab) {
void TabBar::clear_tab_opentype_features(int p_tab) {
ERR_FAIL_INDEX(p_tab, tabs.size());
tabs.write[p_tab].opentype_features.clear();
_shape(p_tab);
update();
}
void Tabs::set_tab_opentype_feature(int p_tab, const String &p_name, int p_value) {
void TabBar::set_tab_opentype_feature(int p_tab, const String &p_name, int p_value) {
ERR_FAIL_INDEX(p_tab, tabs.size());
int32_t tag = TS->name_to_tag(p_name);
if (!tabs[p_tab].opentype_features.has(tag) || (int)tabs[p_tab].opentype_features[tag] != p_value) {
@ -589,7 +589,7 @@ void Tabs::set_tab_opentype_feature(int p_tab, const String &p_name, int p_value
}
}
int Tabs::get_tab_opentype_feature(int p_tab, const String &p_name) const {
int TabBar::get_tab_opentype_feature(int p_tab, const String &p_name) const {
ERR_FAIL_INDEX_V(p_tab, tabs.size(), -1);
int32_t tag = TS->name_to_tag(p_name);
if (!tabs[p_tab].opentype_features.has(tag)) {
@ -598,7 +598,7 @@ int Tabs::get_tab_opentype_feature(int p_tab, const String &p_name) const {
return tabs[p_tab].opentype_features[tag];
}
void Tabs::set_tab_language(int p_tab, const String &p_language) {
void TabBar::set_tab_language(int p_tab, const String &p_language) {
ERR_FAIL_INDEX(p_tab, tabs.size());
if (tabs[p_tab].language != p_language) {
tabs.write[p_tab].language = p_language;
@ -607,35 +607,35 @@ void Tabs::set_tab_language(int p_tab, const String &p_language) {
}
}
String Tabs::get_tab_language(int p_tab) const {
String TabBar::get_tab_language(int p_tab) const {
ERR_FAIL_INDEX_V(p_tab, tabs.size(), "");
return tabs[p_tab].language;
}
void Tabs::set_tab_icon(int p_tab, const Ref<Texture2D> &p_icon) {
void TabBar::set_tab_icon(int p_tab, const Ref<Texture2D> &p_icon) {
ERR_FAIL_INDEX(p_tab, tabs.size());
tabs.write[p_tab].icon = p_icon;
update();
minimum_size_changed();
}
Ref<Texture2D> Tabs::get_tab_icon(int p_tab) const {
Ref<Texture2D> TabBar::get_tab_icon(int p_tab) const {
ERR_FAIL_INDEX_V(p_tab, tabs.size(), Ref<Texture2D>());
return tabs[p_tab].icon;
}
void Tabs::set_tab_disabled(int p_tab, bool p_disabled) {
void TabBar::set_tab_disabled(int p_tab, bool p_disabled) {
ERR_FAIL_INDEX(p_tab, tabs.size());
tabs.write[p_tab].disabled = p_disabled;
update();
}
bool Tabs::get_tab_disabled(int p_tab) const {
bool TabBar::get_tab_disabled(int p_tab) const {
ERR_FAIL_INDEX_V(p_tab, tabs.size(), false);
return tabs[p_tab].disabled;
}
void Tabs::set_tab_right_button(int p_tab, const Ref<Texture2D> &p_right_button) {
void TabBar::set_tab_right_button(int p_tab, const Ref<Texture2D> &p_right_button) {
ERR_FAIL_INDEX(p_tab, tabs.size());
tabs.write[p_tab].right_button = p_right_button;
_update_cache();
@ -643,12 +643,12 @@ void Tabs::set_tab_right_button(int p_tab, const Ref<Texture2D> &p_right_button)
minimum_size_changed();
}
Ref<Texture2D> Tabs::get_tab_right_button(int p_tab) const {
Ref<Texture2D> TabBar::get_tab_right_button(int p_tab) const {
ERR_FAIL_INDEX_V(p_tab, tabs.size(), Ref<Texture2D>());
return tabs[p_tab].right_button;
}
void Tabs::_update_hover() {
void TabBar::_update_hover() {
if (!is_inside_tree()) {
return;
}
@ -685,7 +685,7 @@ void Tabs::_update_hover() {
}
}
void Tabs::_update_cache() {
void TabBar::_update_cache() {
Ref<StyleBox> tab_disabled = get_theme_stylebox(SNAME("tab_disabled"));
Ref<StyleBox> tab_unselected = get_theme_stylebox(SNAME("tab_unselected"));
Ref<StyleBox> tab_selected = get_theme_stylebox(SNAME("tab_selected"));
@ -748,7 +748,7 @@ void Tabs::_update_cache() {
}
}
void Tabs::_on_mouse_exited() {
void TabBar::_on_mouse_exited() {
rb_hover = -1;
cb_hover = -1;
hover = -1;
@ -756,7 +756,7 @@ void Tabs::_on_mouse_exited() {
update();
}
void Tabs::add_tab(const String &p_str, const Ref<Texture2D> &p_icon) {
void TabBar::add_tab(const String &p_str, const Ref<Texture2D> &p_icon) {
Tab t;
t.text = p_str;
t.xl_text = atr(p_str);
@ -775,7 +775,7 @@ void Tabs::add_tab(const String &p_str, const Ref<Texture2D> &p_icon) {
minimum_size_changed();
}
void Tabs::clear_tabs() {
void TabBar::clear_tabs() {
tabs.clear();
current = 0;
previous = 0;
@ -783,7 +783,7 @@ void Tabs::clear_tabs() {
update();
}
void Tabs::remove_tab(int p_idx) {
void TabBar::remove_tab(int p_idx) {
ERR_FAIL_INDEX(p_idx, tabs.size());
tabs.remove(p_idx);
if (current >= p_idx) {
@ -805,7 +805,7 @@ void Tabs::remove_tab(int p_idx) {
_ensure_no_over_offset();
}
Variant Tabs::get_drag_data(const Point2 &p_point) {
Variant TabBar::get_drag_data(const Point2 &p_point) {
if (!drag_to_rearrange_enabled) {
return Variant();
}
@ -839,7 +839,7 @@ Variant Tabs::get_drag_data(const Point2 &p_point) {
return drag_data;
}
bool Tabs::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
bool TabBar::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
if (!drag_to_rearrange_enabled) {
return false;
}
@ -855,9 +855,9 @@ bool Tabs::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
if (from_path == to_path) {
return true;
} else if (get_tabs_rearrange_group() != -1) {
// drag and drop between other Tabs
// drag and drop between other TabBars
Node *from_node = get_node(from_path);
Tabs *from_tabs = Object::cast_to<Tabs>(from_node);
TabBar *from_tabs = Object::cast_to<TabBar>(from_node);
if (from_tabs && from_tabs->get_tabs_rearrange_group() == get_tabs_rearrange_group()) {
return true;
}
@ -866,7 +866,7 @@ bool Tabs::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
return false;
}
void Tabs::drop_data(const Point2 &p_point, const Variant &p_data) {
void TabBar::drop_data(const Point2 &p_point, const Variant &p_data) {
if (!drag_to_rearrange_enabled) {
return;
}
@ -892,7 +892,7 @@ void Tabs::drop_data(const Point2 &p_point, const Variant &p_data) {
} else if (get_tabs_rearrange_group() != -1) {
// drag and drop between Tabs
Node *from_node = get_node(from_path);
Tabs *from_tabs = Object::cast_to<Tabs>(from_node);
TabBar *from_tabs = Object::cast_to<TabBar>(from_node);
if (from_tabs && from_tabs->get_tabs_rearrange_group() == get_tabs_rearrange_group()) {
if (tab_from_id >= from_tabs->get_tab_count()) {
return;
@ -912,7 +912,7 @@ void Tabs::drop_data(const Point2 &p_point, const Variant &p_data) {
update();
}
int Tabs::get_tab_idx_at_point(const Point2 &p_point) const {
int TabBar::get_tab_idx_at_point(const Point2 &p_point) const {
int hover_now = -1;
for (int i = offset; i <= max_drawn_tab; i++) {
Rect2 rect = get_tab_rect(i);
@ -924,17 +924,17 @@ int Tabs::get_tab_idx_at_point(const Point2 &p_point) const {
return hover_now;
}
void Tabs::set_tab_align(TabAlign p_align) {
void TabBar::set_tab_align(TabAlign p_align) {
ERR_FAIL_INDEX(p_align, ALIGN_MAX);
tab_align = p_align;
update();
}
Tabs::TabAlign Tabs::get_tab_align() const {
TabBar::TabAlign TabBar::get_tab_align() const {
return tab_align;
}
void Tabs::set_clip_tabs(bool p_clip_tabs) {
void TabBar::set_clip_tabs(bool p_clip_tabs) {
if (clip_tabs == p_clip_tabs) {
return;
}
@ -943,11 +943,11 @@ void Tabs::set_clip_tabs(bool p_clip_tabs) {
minimum_size_changed();
}
bool Tabs::get_clip_tabs() const {
bool TabBar::get_clip_tabs() const {
return clip_tabs;
}
void Tabs::move_tab(int from, int to) {
void TabBar::move_tab(int from, int to) {
if (from == to) {
return;
}
@ -963,7 +963,7 @@ void Tabs::move_tab(int from, int to) {
update();
}
int Tabs::get_tab_width(int p_idx) const {
int TabBar::get_tab_width(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, tabs.size(), 0);
Ref<StyleBox> tab_unselected = get_theme_stylebox(SNAME("tab_unselected"));
@ -1005,7 +1005,7 @@ int Tabs::get_tab_width(int p_idx) const {
return x;
}
void Tabs::_ensure_no_over_offset() {
void TabBar::_ensure_no_over_offset() {
if (!is_inside_tree()) {
return;
}
@ -1031,7 +1031,7 @@ void Tabs::_ensure_no_over_offset() {
}
}
void Tabs::ensure_tab_visible(int p_idx) {
void TabBar::ensure_tab_visible(int p_idx) {
if (!is_inside_tree()) {
return;
}
@ -1068,7 +1068,7 @@ void Tabs::ensure_tab_visible(int p_idx) {
}
}
Rect2 Tabs::get_tab_rect(int p_tab) const {
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);
@ -1077,93 +1077,93 @@ Rect2 Tabs::get_tab_rect(int p_tab) const {
}
}
void Tabs::set_tab_close_display_policy(CloseButtonDisplayPolicy p_policy) {
void TabBar::set_tab_close_display_policy(CloseButtonDisplayPolicy p_policy) {
ERR_FAIL_INDEX(p_policy, CLOSE_BUTTON_MAX);
cb_displaypolicy = p_policy;
update();
}
Tabs::CloseButtonDisplayPolicy Tabs::get_tab_close_display_policy() const {
TabBar::CloseButtonDisplayPolicy TabBar::get_tab_close_display_policy() const {
return cb_displaypolicy;
}
void Tabs::set_min_width(int p_width) {
void TabBar::set_min_width(int p_width) {
min_width = p_width;
}
void Tabs::set_scrolling_enabled(bool p_enabled) {
void TabBar::set_scrolling_enabled(bool p_enabled) {
scrolling_enabled = p_enabled;
}
bool Tabs::get_scrolling_enabled() const {
bool TabBar::get_scrolling_enabled() const {
return scrolling_enabled;
}
void Tabs::set_drag_to_rearrange_enabled(bool p_enabled) {
void TabBar::set_drag_to_rearrange_enabled(bool p_enabled) {
drag_to_rearrange_enabled = p_enabled;
}
bool Tabs::get_drag_to_rearrange_enabled() const {
bool TabBar::get_drag_to_rearrange_enabled() const {
return drag_to_rearrange_enabled;
}
void Tabs::set_tabs_rearrange_group(int p_group_id) {
void TabBar::set_tabs_rearrange_group(int p_group_id) {
tabs_rearrange_group = p_group_id;
}
int Tabs::get_tabs_rearrange_group() const {
int TabBar::get_tabs_rearrange_group() const {
return tabs_rearrange_group;
}
void Tabs::set_select_with_rmb(bool p_enabled) {
void TabBar::set_select_with_rmb(bool p_enabled) {
select_with_rmb = p_enabled;
}
bool Tabs::get_select_with_rmb() const {
bool TabBar::get_select_with_rmb() const {
return select_with_rmb;
}
void Tabs::_bind_methods() {
ClassDB::bind_method(D_METHOD("_update_hover"), &Tabs::_update_hover);
ClassDB::bind_method(D_METHOD("get_tab_count"), &Tabs::get_tab_count);
ClassDB::bind_method(D_METHOD("set_current_tab", "tab_idx"), &Tabs::set_current_tab);
ClassDB::bind_method(D_METHOD("get_current_tab"), &Tabs::get_current_tab);
ClassDB::bind_method(D_METHOD("get_previous_tab"), &Tabs::get_previous_tab);
ClassDB::bind_method(D_METHOD("set_tab_title", "tab_idx", "title"), &Tabs::set_tab_title);
ClassDB::bind_method(D_METHOD("get_tab_title", "tab_idx"), &Tabs::get_tab_title);
ClassDB::bind_method(D_METHOD("set_tab_text_direction", "tab_idx", "direction"), &Tabs::set_tab_text_direction);
ClassDB::bind_method(D_METHOD("get_tab_text_direction", "tab_idx"), &Tabs::get_tab_text_direction);
ClassDB::bind_method(D_METHOD("set_tab_opentype_feature", "tab_idx", "tag", "values"), &Tabs::set_tab_opentype_feature);
ClassDB::bind_method(D_METHOD("get_tab_opentype_feature", "tab_idx", "tag"), &Tabs::get_tab_opentype_feature);
ClassDB::bind_method(D_METHOD("clear_tab_opentype_features", "tab_idx"), &Tabs::clear_tab_opentype_features);
ClassDB::bind_method(D_METHOD("set_tab_language", "tab_idx", "language"), &Tabs::set_tab_language);
ClassDB::bind_method(D_METHOD("get_tab_language", "tab_idx"), &Tabs::get_tab_language);
ClassDB::bind_method(D_METHOD("set_tab_icon", "tab_idx", "icon"), &Tabs::set_tab_icon);
ClassDB::bind_method(D_METHOD("get_tab_icon", "tab_idx"), &Tabs::get_tab_icon);
ClassDB::bind_method(D_METHOD("set_tab_disabled", "tab_idx", "disabled"), &Tabs::set_tab_disabled);
ClassDB::bind_method(D_METHOD("get_tab_disabled", "tab_idx"), &Tabs::get_tab_disabled);
ClassDB::bind_method(D_METHOD("remove_tab", "tab_idx"), &Tabs::remove_tab);
ClassDB::bind_method(D_METHOD("add_tab", "title", "icon"), &Tabs::add_tab, DEFVAL(""), DEFVAL(Ref<Texture2D>()));
ClassDB::bind_method(D_METHOD("set_tab_align", "align"), &Tabs::set_tab_align);
ClassDB::bind_method(D_METHOD("get_tab_align"), &Tabs::get_tab_align);
ClassDB::bind_method(D_METHOD("set_clip_tabs", "clip_tabs"), &Tabs::set_clip_tabs);
ClassDB::bind_method(D_METHOD("get_clip_tabs"), &Tabs::get_clip_tabs);
ClassDB::bind_method(D_METHOD("get_tab_offset"), &Tabs::get_tab_offset);
ClassDB::bind_method(D_METHOD("get_offset_buttons_visible"), &Tabs::get_offset_buttons_visible);
ClassDB::bind_method(D_METHOD("ensure_tab_visible", "idx"), &Tabs::ensure_tab_visible);
ClassDB::bind_method(D_METHOD("get_tab_rect", "tab_idx"), &Tabs::get_tab_rect);
ClassDB::bind_method(D_METHOD("move_tab", "from", "to"), &Tabs::move_tab);
ClassDB::bind_method(D_METHOD("set_tab_close_display_policy", "policy"), &Tabs::set_tab_close_display_policy);
ClassDB::bind_method(D_METHOD("get_tab_close_display_policy"), &Tabs::get_tab_close_display_policy);
ClassDB::bind_method(D_METHOD("set_scrolling_enabled", "enabled"), &Tabs::set_scrolling_enabled);
ClassDB::bind_method(D_METHOD("get_scrolling_enabled"), &Tabs::get_scrolling_enabled);
ClassDB::bind_method(D_METHOD("set_drag_to_rearrange_enabled", "enabled"), &Tabs::set_drag_to_rearrange_enabled);
ClassDB::bind_method(D_METHOD("get_drag_to_rearrange_enabled"), &Tabs::get_drag_to_rearrange_enabled);
ClassDB::bind_method(D_METHOD("set_tabs_rearrange_group", "group_id"), &Tabs::set_tabs_rearrange_group);
ClassDB::bind_method(D_METHOD("get_tabs_rearrange_group"), &Tabs::get_tabs_rearrange_group);
void TabBar::_bind_methods() {
ClassDB::bind_method(D_METHOD("_update_hover"), &TabBar::_update_hover);
ClassDB::bind_method(D_METHOD("get_tab_count"), &TabBar::get_tab_count);
ClassDB::bind_method(D_METHOD("set_current_tab", "tab_idx"), &TabBar::set_current_tab);
ClassDB::bind_method(D_METHOD("get_current_tab"), &TabBar::get_current_tab);
ClassDB::bind_method(D_METHOD("get_previous_tab"), &TabBar::get_previous_tab);
ClassDB::bind_method(D_METHOD("set_tab_title", "tab_idx", "title"), &TabBar::set_tab_title);
ClassDB::bind_method(D_METHOD("get_tab_title", "tab_idx"), &TabBar::get_tab_title);
ClassDB::bind_method(D_METHOD("set_tab_text_direction", "tab_idx", "direction"), &TabBar::set_tab_text_direction);
ClassDB::bind_method(D_METHOD("get_tab_text_direction", "tab_idx"), &TabBar::get_tab_text_direction);
ClassDB::bind_method(D_METHOD("set_tab_opentype_feature", "tab_idx", "tag", "values"), &TabBar::set_tab_opentype_feature);
ClassDB::bind_method(D_METHOD("get_tab_opentype_feature", "tab_idx", "tag"), &TabBar::get_tab_opentype_feature);
ClassDB::bind_method(D_METHOD("clear_tab_opentype_features", "tab_idx"), &TabBar::clear_tab_opentype_features);
ClassDB::bind_method(D_METHOD("set_tab_language", "tab_idx", "language"), &TabBar::set_tab_language);
ClassDB::bind_method(D_METHOD("get_tab_language", "tab_idx"), &TabBar::get_tab_language);
ClassDB::bind_method(D_METHOD("set_tab_icon", "tab_idx", "icon"), &TabBar::set_tab_icon);
ClassDB::bind_method(D_METHOD("get_tab_icon", "tab_idx"), &TabBar::get_tab_icon);
ClassDB::bind_method(D_METHOD("set_tab_disabled", "tab_idx", "disabled"), &TabBar::set_tab_disabled);
ClassDB::bind_method(D_METHOD("get_tab_disabled", "tab_idx"), &TabBar::get_tab_disabled);
ClassDB::bind_method(D_METHOD("remove_tab", "tab_idx"), &TabBar::remove_tab);
ClassDB::bind_method(D_METHOD("add_tab", "title", "icon"), &TabBar::add_tab, DEFVAL(""), DEFVAL(Ref<Texture2D>()));
ClassDB::bind_method(D_METHOD("set_tab_align", "align"), &TabBar::set_tab_align);
ClassDB::bind_method(D_METHOD("get_tab_align"), &TabBar::get_tab_align);
ClassDB::bind_method(D_METHOD("set_clip_tabs", "clip_tabs"), &TabBar::set_clip_tabs);
ClassDB::bind_method(D_METHOD("get_clip_tabs"), &TabBar::get_clip_tabs);
ClassDB::bind_method(D_METHOD("get_tab_offset"), &TabBar::get_tab_offset);
ClassDB::bind_method(D_METHOD("get_offset_buttons_visible"), &TabBar::get_offset_buttons_visible);
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_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_scrolling_enabled", "enabled"), &TabBar::set_scrolling_enabled);
ClassDB::bind_method(D_METHOD("get_scrolling_enabled"), &TabBar::get_scrolling_enabled);
ClassDB::bind_method(D_METHOD("set_drag_to_rearrange_enabled", "enabled"), &TabBar::set_drag_to_rearrange_enabled);
ClassDB::bind_method(D_METHOD("get_drag_to_rearrange_enabled"), &TabBar::get_drag_to_rearrange_enabled);
ClassDB::bind_method(D_METHOD("set_tabs_rearrange_group", "group_id"), &TabBar::set_tabs_rearrange_group);
ClassDB::bind_method(D_METHOD("get_tabs_rearrange_group"), &TabBar::get_tabs_rearrange_group);
ClassDB::bind_method(D_METHOD("set_select_with_rmb", "enabled"), &Tabs::set_select_with_rmb);
ClassDB::bind_method(D_METHOD("get_select_with_rmb"), &Tabs::get_select_with_rmb);
ClassDB::bind_method(D_METHOD("set_select_with_rmb", "enabled"), &TabBar::set_select_with_rmb);
ClassDB::bind_method(D_METHOD("get_select_with_rmb"), &TabBar::get_select_with_rmb);
ADD_SIGNAL(MethodInfo("tab_changed", PropertyInfo(Variant::INT, "tab")));
ADD_SIGNAL(MethodInfo("tab_rmb_clicked", PropertyInfo(Variant::INT, "tab")));
@ -1190,6 +1190,6 @@ void Tabs::_bind_methods() {
BIND_ENUM_CONSTANT(CLOSE_BUTTON_MAX);
}
Tabs::Tabs() {
connect("mouse_exited", callable_mp(this, &Tabs::_on_mouse_exited));
TabBar::TabBar() {
connect("mouse_exited", callable_mp(this, &TabBar::_on_mouse_exited));
}

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* tabs.h */
/* tab_bar.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef TABS_H
#define TABS_H
#ifndef TAB_BAR_H
#define TAB_BAR_H
#include "scene/gui/control.h"
#include "scene/resources/text_line.h"
class Tabs : public Control {
GDCLASS(Tabs, Control);
class TabBar : public Control {
GDCLASS(TabBar, Control);
public:
enum TabAlign {
@ -187,10 +187,10 @@ public:
Rect2 get_tab_rect(int p_tab) const;
Size2 get_minimum_size() const override;
Tabs();
TabBar();
};
VARIANT_ENUM_CAST(Tabs::TabAlign);
VARIANT_ENUM_CAST(Tabs::CloseButtonDisplayPolicy);
VARIANT_ENUM_CAST(TabBar::TabAlign);
VARIANT_ENUM_CAST(TabBar::CloseButtonDisplayPolicy);
#endif // TABS_H
#endif // TAB_BAR_H

View File

@ -115,8 +115,8 @@
#include "scene/gui/spin_box.h"
#include "scene/gui/split_container.h"
#include "scene/gui/subviewport_container.h"
#include "scene/gui/tab_bar.h"
#include "scene/gui/tab_container.h"
#include "scene/gui/tabs.h"
#include "scene/gui/text_edit.h"
#include "scene/gui/texture_button.h"
#include "scene/gui/texture_progress_bar.h"
@ -338,7 +338,7 @@ void register_scene_types() {
GDREGISTER_CLASS(ReferenceRect);
GDREGISTER_CLASS(AspectRatioContainer);
GDREGISTER_CLASS(TabContainer);
GDREGISTER_CLASS(Tabs);
GDREGISTER_CLASS(TabBar);
GDREGISTER_VIRTUAL_CLASS(Separator);
GDREGISTER_CLASS(HSeparator);
GDREGISTER_CLASS(VSeparator);

View File

@ -785,30 +785,30 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_constant("icon_separation", "TabContainer", 4 * scale);
theme->set_constant("outline_size", "TabContainer", 0);
// Tabs
// TabBar
theme->set_stylebox("tab_selected", "Tabs", sb_expand(make_stylebox(tab_current_png, 4, 3, 4, 1, 16, 3, 16, 2), 2, 2, 2, 2));
theme->set_stylebox("tab_unselected", "Tabs", sb_expand(make_stylebox(tab_behind_png, 5, 4, 5, 1, 16, 5, 16, 2), 3, 3, 3, 3));
theme->set_stylebox("tab_disabled", "Tabs", sb_expand(make_stylebox(tab_disabled_png, 5, 5, 5, 1, 16, 6, 16, 4), 3, 0, 3, 3));
theme->set_stylebox("close_bg_pressed", "Tabs", make_stylebox(button_pressed_png, 4, 4, 4, 4));
theme->set_stylebox("close_bg_highlight", "Tabs", make_stylebox(button_normal_png, 4, 4, 4, 4));
theme->set_stylebox("tab_selected", "TabBar", sb_expand(make_stylebox(tab_current_png, 4, 3, 4, 1, 16, 3, 16, 2), 2, 2, 2, 2));
theme->set_stylebox("tab_unselected", "TabBar", sb_expand(make_stylebox(tab_behind_png, 5, 4, 5, 1, 16, 5, 16, 2), 3, 3, 3, 3));
theme->set_stylebox("tab_disabled", "TabBar", sb_expand(make_stylebox(tab_disabled_png, 5, 5, 5, 1, 16, 6, 16, 4), 3, 0, 3, 3));
theme->set_stylebox("close_bg_pressed", "TabBar", make_stylebox(button_pressed_png, 4, 4, 4, 4));
theme->set_stylebox("close_bg_highlight", "TabBar", make_stylebox(button_normal_png, 4, 4, 4, 4));
theme->set_icon("increment", "Tabs", make_icon(scroll_button_right_png));
theme->set_icon("increment_highlight", "Tabs", make_icon(scroll_button_right_hl_png));
theme->set_icon("decrement", "Tabs", make_icon(scroll_button_left_png));
theme->set_icon("decrement_highlight", "Tabs", make_icon(scroll_button_left_hl_png));
theme->set_icon("close", "Tabs", make_icon(tab_close_png));
theme->set_icon("increment", "TabBar", make_icon(scroll_button_right_png));
theme->set_icon("increment_highlight", "TabBar", make_icon(scroll_button_right_hl_png));
theme->set_icon("decrement", "TabBar", make_icon(scroll_button_left_png));
theme->set_icon("decrement_highlight", "TabBar", make_icon(scroll_button_left_hl_png));
theme->set_icon("close", "TabBar", make_icon(tab_close_png));
theme->set_font("font", "Tabs", Ref<Font>());
theme->set_font_size("font_size", "Tabs", -1);
theme->set_font("font", "TabBar", Ref<Font>());
theme->set_font_size("font_size", "TabBar", -1);
theme->set_color("font_selected_color", "Tabs", control_font_hover_color);
theme->set_color("font_unselected_color", "Tabs", control_font_low_color);
theme->set_color("font_disabled_color", "Tabs", control_font_disabled_color);
theme->set_color("font_outline_color", "Tabs", Color(1, 1, 1));
theme->set_color("font_selected_color", "TabBar", control_font_hover_color);
theme->set_color("font_unselected_color", "TabBar", control_font_low_color);
theme->set_color("font_disabled_color", "TabBar", control_font_disabled_color);
theme->set_color("font_outline_color", "TabBar", Color(1, 1, 1));
theme->set_constant("hseparation", "Tabs", 4 * scale);
theme->set_constant("outline_size", "Tabs", 0);
theme->set_constant("hseparation", "TabBar", 4 * scale);
theme->set_constant("outline_size", "TabBar", 0);
// Separators