diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-11-20 09:11:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-20 09:11:31 +0100 |
commit | 6d105aba9a9a966ceb506f1bebd4f61bce792115 (patch) | |
tree | f1faffcd45414570013a89f9850b8cd8c961d8af /editor | |
parent | d6dc909ebe9b72fc603ee523bed7c8f6d307fd06 (diff) | |
parent | f8e8b7d1a231bb5e54abd3c7ed26a76fcb8a89cd (diff) |
Merge pull request #12983 from ianb96/scene_add_tab
Add Scene button and tab scrolling
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_node.cpp | 38 | ||||
-rw-r--r-- | editor/editor_node.h | 3 |
2 files changed, 38 insertions, 3 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 7627fecc43..6559048172 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -141,7 +141,25 @@ void EditorNode::_update_scene_tabs() { } scene_tabs->set_current_tab(editor_data.get_edited_scene()); - scene_tabs->ensure_tab_visible(editor_data.get_edited_scene()); + + int current = editor_data.get_edited_scene(); + if (scene_tabs->get_offset_buttons_visible()) { + // move add button to fixed position on the tabbar + if (scene_tab_add->get_parent() == scene_tabs) { + scene_tab_add->set_position(Point2(0, 0)); + scene_tabs->remove_child(scene_tab_add); + tabbar_container->add_child(scene_tab_add); + tabbar_container->move_child(scene_tab_add, 1); + } + } else { + // move add button to after last tab + if (scene_tab_add->get_parent() == tabbar_container) { + tabbar_container->remove_child(scene_tab_add); + scene_tabs->add_child(scene_tab_add); + } + Rect2 last_tab = scene_tabs->get_tab_rect(scene_tabs->get_tab_count() - 1); + scene_tab_add->set_position(Point2(last_tab.get_position().x + last_tab.get_size().x + 3, last_tab.get_position().y)); + } } void EditorNode::_update_title() { @@ -327,6 +345,7 @@ void EditorNode::_notification(int p_what) { prev_scene->set_icon(gui_base->get_icon("PrevScene", "EditorIcons")); distraction_free->set_icon(gui_base->get_icon("DistractionFree", "EditorIcons")); + scene_tab_add->set_icon(gui_base->get_icon("Add", "EditorIcons")); resource_new_button->set_icon(gui_base->get_icon("New", "EditorIcons")); resource_load_button->set_icon(gui_base->get_icon("Load", "EditorIcons")); @@ -344,6 +363,9 @@ void EditorNode::_notification(int p_what) { dock_tab_move_right->set_icon(theme->get_icon("Forward", "EditorIcons")); update_menu->set_icon(gui_base->get_icon("Progress1", "EditorIcons")); } + if (p_what = Control::NOTIFICATION_RESIZED) { + _update_scene_tabs(); + } } void EditorNode::_fs_changed() { @@ -1765,6 +1787,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { int idx = editor_data.add_edited_scene(-1); _scene_tab_changed(idx); editor_data.clear_editor_states(); + _update_scene_tabs(); } break; case FILE_NEW_INHERITED_SCENE: @@ -3903,6 +3926,7 @@ void EditorNode::_scene_tab_closed(int p_tab) { } else { _discard_changes(); } + _update_scene_tabs(); } void EditorNode::_scene_tab_hover(int p_tab) { @@ -4881,20 +4905,28 @@ EditorNode::EditorNode() { scene_tabs->connect("mouse_exited", this, "_scene_tab_exit"); scene_tabs->connect("gui_input", this, "_scene_tab_input"); scene_tabs->connect("reposition_active_tab_request", this, "_reposition_active_tab"); + scene_tabs->connect("resized", this, "_update_scene_tabs"); - HBoxContainer *tabbar_container = memnew(HBoxContainer); + tabbar_container = memnew(HBoxContainer); scene_tabs->set_h_size_flags(Control::SIZE_EXPAND_FILL); srt->add_child(tabbar_container); tabbar_container->add_child(scene_tabs); distraction_free = memnew(ToolButton); - tabbar_container->add_child(distraction_free); distraction_free->set_shortcut(ED_SHORTCUT("editor/distraction_free_mode", TTR("Distraction Free Mode"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F11)); distraction_free->set_tooltip(TTR("Toggle distraction-free mode.")); distraction_free->connect("pressed", this, "_toggle_distraction_free_mode"); distraction_free->set_icon(gui_base->get_icon("DistractionFree", "EditorIcons")); distraction_free->set_toggle_mode(true); + scene_tab_add = memnew(ToolButton); + tabbar_container->add_child(scene_tab_add); + tabbar_container->add_child(distraction_free); + scene_tab_add->set_tooltip(TTR("Add a new scene.")); + scene_tab_add->set_icon(gui_base->get_icon("Add", "EditorIcons")); + scene_tab_add->add_color_override("icon_color_normal", Color(0.6f, 0.6f, 0.6f, 0.8f)); + scene_tab_add->connect("pressed", this, "_menu_option", make_binds(FILE_NEW_SCENE)); + scene_root_parent = memnew(PanelContainer); scene_root_parent->set_custom_minimum_size(Size2(0, 80) * EDSCALE); scene_root_parent->add_style_override("panel", gui_base->get_stylebox("Content", "EditorStyles")); diff --git a/editor/editor_node.h b/editor/editor_node.h index 54cb414835..a2b4a0a049 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -344,7 +344,10 @@ private: int dock_popup_selected; Timer *dock_drag_timer; bool docks_visible; + + HBoxContainer *tabbar_container; ToolButton *distraction_free; + ToolButton *scene_tab_add; bool scene_distraction; bool script_distraction; |