Replace DockSlot with DockTabContainer
This commit is contained in:
parent
5ad8b27d8d
commit
4274f8b543
10 changed files with 646 additions and 458 deletions
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "core/input/shortcut.h"
|
||||
#include "core/io/config_file.h"
|
||||
#include "editor/docks/dock_tab_container.h"
|
||||
#include "editor/docks/editor_dock_manager.h"
|
||||
|
||||
void EditorDock::_set_default_slot_bind(DockSlot p_slot) {
|
||||
|
|
@ -49,6 +50,14 @@ void EditorDock::_notification(int p_what) {
|
|||
set_accessibility_region(true);
|
||||
set_accessibility_name(get_display_title());
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_PARENTED: {
|
||||
parent_dock_container = Object::cast_to<DockTabContainer>(get_parent());
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_UNPARENTED: {
|
||||
parent_dock_container = nullptr;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -140,6 +149,10 @@ void EditorDock::make_visible() {
|
|||
EditorDockManager::get_singleton()->open_dock(this, true);
|
||||
}
|
||||
|
||||
void EditorDock::make_floating() {
|
||||
EditorDockManager::get_singleton()->make_dock_floating(this);
|
||||
}
|
||||
|
||||
void EditorDock::close() {
|
||||
if (is_open) {
|
||||
EditorDockManager::get_singleton()->close_dock(this);
|
||||
|
|
@ -242,3 +255,62 @@ String EditorDock::get_display_title() const {
|
|||
String EditorDock::get_effective_layout_key() const {
|
||||
return layout_key.is_empty() ? get_display_title() : layout_key;
|
||||
}
|
||||
|
||||
void EditorDock::set_tab_index(int p_index, bool p_set_current) {
|
||||
parent_dock_container->move_dock_index(this, p_index, p_set_current);
|
||||
previous_tab_index = parent_dock_container->get_tab_idx_from_control(this);
|
||||
}
|
||||
|
||||
void EditorDock::update_tab_style() {
|
||||
if (!enabled || !is_open) {
|
||||
return; // Disabled by feature profile or manually closed by user.
|
||||
}
|
||||
if (dock_window) {
|
||||
return; // Floating.
|
||||
}
|
||||
|
||||
ERR_FAIL_NULL(parent_dock_container);
|
||||
|
||||
int index = parent_dock_container->get_tab_idx_from_control(this);
|
||||
ERR_FAIL_COND(index == -1);
|
||||
|
||||
parent_dock_container->get_tab_bar()->set_font_color_override_all(index, title_color);
|
||||
|
||||
const Ref<Texture2D> icon = get_effective_icon(callable_mp((Control *)this, &Control::get_editor_theme_icon));
|
||||
bool assign_icon = force_show_icon;
|
||||
String tooltip;
|
||||
switch (parent_dock_container->get_tab_style()) {
|
||||
case DockTabContainer::TabStyle::TEXT_ONLY: {
|
||||
parent_dock_container->set_tab_title(index, get_display_title());
|
||||
} break;
|
||||
case DockTabContainer::TabStyle::ICON_ONLY: {
|
||||
parent_dock_container->set_tab_title(index, icon.is_valid() ? String() : get_display_title());
|
||||
tooltip = TTR(get_display_title());
|
||||
assign_icon = true;
|
||||
} break;
|
||||
case DockTabContainer::TabStyle::TEXT_AND_ICON: {
|
||||
parent_dock_container->set_tab_title(index, get_display_title());
|
||||
parent_dock_container->set_tab_tooltip(index, String());
|
||||
assign_icon = true;
|
||||
} break;
|
||||
}
|
||||
|
||||
if (shortcut.is_valid() && shortcut->has_valid_event()) {
|
||||
tooltip += (tooltip.is_empty() ? "" : "\n") + TTR(shortcut->get_name()) + " (" + shortcut->get_as_text() + ")";
|
||||
}
|
||||
parent_dock_container->set_tab_tooltip(index, tooltip);
|
||||
|
||||
if (assign_icon) {
|
||||
parent_dock_container->set_tab_icon(index, icon);
|
||||
} else {
|
||||
parent_dock_container->set_tab_icon(index, Ref<Texture2D>());
|
||||
}
|
||||
}
|
||||
|
||||
Ref<Texture2D> EditorDock::get_effective_icon(const Callable &p_icon_fetch) {
|
||||
Ref<Texture2D> icon = dock_icon;
|
||||
if (icon.is_null() && !icon_name.is_empty()) {
|
||||
icon = p_icon_fetch.call(icon_name);
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue