summaryrefslogtreecommitdiff
path: root/editor/editor_node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r--editor/editor_node.cpp85
1 files changed, 79 insertions, 6 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index c1f46ee950..56b62cdf6e 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -73,10 +73,10 @@
#include "plugins/collision_polygon_2d_editor_plugin.h"
#include "plugins/collision_polygon_editor_plugin.h"
#include "plugins/collision_shape_2d_editor_plugin.h"
-#include "plugins/color_ramp_editor_plugin.h"
#include "plugins/cube_grid_theme_editor_plugin.h"
#include "plugins/curve_editor_plugin.h"
#include "plugins/gi_probe_editor_plugin.h"
+#include "plugins/gradient_editor_plugin.h"
#include "plugins/gradient_texture_editor_plugin.h"
#include "plugins/item_list_editor_plugin.h"
#include "plugins/light_occluder_2d_editor_plugin.h"
@@ -272,6 +272,8 @@ void EditorNode::_notification(int p_what) {
}
editor_selection->update();
+ scene_root->set_size_override(true, Size2(GlobalConfig::get_singleton()->get("display/window/width"), GlobalConfig::get_singleton()->get("display/window/height")));
+
ResourceImporterTexture::get_singleton()->update_imports();
}
if (p_what == NOTIFICATION_ENTER_TREE) {
@@ -340,6 +342,14 @@ void EditorNode::_notification(int p_what) {
play_button_panel->add_style_override("panel", gui_base->get_stylebox("PlayButtonPanel", "EditorStyles"));
scene_root_parent->add_style_override("panel", gui_base->get_stylebox("Content", "EditorStyles"));
bottom_panel->add_style_override("panel", gui_base->get_stylebox("Content", "EditorStyles"));
+ scene_tabs->add_style_override("tab_fg", gui_base->get_stylebox("SceneTabFG", "EditorStyles"));
+ scene_tabs->add_style_override("tab_bg", gui_base->get_stylebox("SceneTabBG", "EditorStyles"));
+ if (bool(EDITOR_DEF("interface/scene_tabs/resize_if_many_tabs", true))) {
+ scene_tabs->set_min_width(int(EDITOR_DEF("interface/scene_tabs/minimum_width", 50)) * EDSCALE);
+ } else {
+ scene_tabs->set_min_width(0);
+ }
+ _update_scene_tabs();
}
}
@@ -1975,9 +1985,10 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case FILE_SAVE_BEFORE_RUN: {
if (!p_confirmed) {
- accept->get_ok()->set_text(TTR("Yes"));
- accept->set_text(TTR("This scene has never been saved. Save before running?"));
- accept->popup_centered_minsize();
+ confirmation->get_cancel()->set_text(TTR("No"));
+ confirmation->get_ok()->set_text(TTR("Yes"));
+ confirmation->set_text(TTR("This scene has never been saved. Save before running?"));
+ confirmation->popup_centered_minsize();
break;
}
@@ -4267,7 +4278,47 @@ void EditorNode::_scene_tab_closed(int p_tab) {
}
}
+void EditorNode::_scene_tab_hover(int p_tab) {
+ if (bool(EDITOR_DEF("interface/scene_tabs/show_thumbnail_on_hover", true)) == false) {
+ return;
+ }
+ int current_tab = scene_tabs->get_current_tab();
+
+ if (p_tab == current_tab || p_tab < 0) {
+ tab_preview_panel->hide();
+ } else {
+ String path = editor_data.get_scene_path(p_tab);
+ EditorResourcePreview::get_singleton()->queue_resource_preview(path, this, "_thumbnail_done", p_tab);
+ }
+}
+
+void EditorNode::_scene_tab_exit() {
+ tab_preview_panel->hide();
+}
+
+void EditorNode::_scene_tab_input(const Ref<InputEvent> &p_input) {
+ Ref<InputEventMouseButton> mb = p_input;
+
+ if (mb.is_valid()) {
+ if (mb->get_button_index() == BUTTON_MIDDLE && mb->is_pressed() && scene_tabs->get_hovered_tab() >= 0) {
+ _scene_tab_closed(scene_tabs->get_hovered_tab());
+ }
+ }
+}
+
+void EditorNode::_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Variant &p_udata) {
+ int p_tab = p_udata.operator signed int();
+ if (p_preview.is_valid()) {
+ Rect2 rect = scene_tabs->get_tab_rect(p_tab);
+ rect.position += scene_tabs->get_global_position();
+ tab_preview->set_texture(p_preview);
+ tab_preview_panel->set_position(rect.position + Vector2(0, rect.size.height));
+ tab_preview_panel->show();
+ }
+}
+
void EditorNode::_scene_tab_changed(int p_tab) {
+ tab_preview_panel->hide();
//print_line("set current 1 ");
bool unsaved = (saved_version != editor_data.get_undo_redo().get_version());
@@ -4758,7 +4809,6 @@ void EditorNode::_dim_timeout() {
}
void EditorNode::_check_gui_base_size() {
- print_line(itos(int(gui_base->get_size().width)));
if (gui_base->get_size().width > 1200 * EDSCALE) {
for (int i = 0; i < singleton->main_editor_button_vb->get_child_count(); i++) {
ToolButton *btn = singleton->main_editor_button_vb->get_child(i)->cast_to<ToolButton>();
@@ -4835,6 +4885,10 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method("set_current_version", &EditorNode::set_current_version);
ClassDB::bind_method("_scene_tab_changed", &EditorNode::_scene_tab_changed);
ClassDB::bind_method("_scene_tab_closed", &EditorNode::_scene_tab_closed);
+ ClassDB::bind_method("_scene_tab_hover", &EditorNode::_scene_tab_hover);
+ ClassDB::bind_method("_scene_tab_exit", &EditorNode::_scene_tab_exit);
+ ClassDB::bind_method("_scene_tab_input", &EditorNode::_scene_tab_input);
+ ClassDB::bind_method("_thumbnail_done", &EditorNode::_thumbnail_done);
ClassDB::bind_method("_scene_tab_script_edited", &EditorNode::_scene_tab_script_edited);
ClassDB::bind_method("_set_main_scene_state", &EditorNode::_set_main_scene_state);
ClassDB::bind_method("_update_scene_tabs", &EditorNode::_update_scene_tabs);
@@ -4878,6 +4932,7 @@ EditorNode::EditorNode() {
Resource::_get_local_scene_func = _resource_get_edited_scene;
VisualServer::get_singleton()->textures_keep_original(true);
+ VisualServer::get_singleton()->set_debug_generate_wireframes(true);
EditorHelp::generate_doc(); //before any editor classes are crated
SceneState::set_disable_placeholders(true);
@@ -5178,13 +5233,31 @@ EditorNode::EditorNode() {
main_editor_tabs->connect("tab_changed",this,"_editor_select");
main_editor_tabs->set_tab_close_display_policy(Tabs::SHOW_NEVER);
*/
+ tab_preview_panel = memnew(Panel);
+ tab_preview_panel->set_size(Size2(100, 100) * EDSCALE);
+ tab_preview_panel->hide();
+ tab_preview_panel->set_self_modulate(Color(1, 1, 1, 0.7));
+ gui_base->add_child(tab_preview_panel);
+
+ tab_preview = memnew(TextureRect);
+ tab_preview->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED);
+ tab_preview->set_size(Size2(96, 96) * EDSCALE);
+ tab_preview->set_position(Point2(2, 2) * EDSCALE);
+ tab_preview_panel->add_child(tab_preview);
+
scene_tabs = memnew(Tabs);
+ scene_tabs->add_style_override("tab_fg", gui_base->get_stylebox("SceneTabFG", "EditorStyles"));
+ scene_tabs->add_style_override("tab_bg", gui_base->get_stylebox("SceneTabBG", "EditorStyles"));
scene_tabs->add_tab("unsaved");
scene_tabs->set_tab_align(Tabs::ALIGN_LEFT);
scene_tabs->set_tab_close_display_policy((bool(EDITOR_DEF("interface/always_show_close_button_in_scene_tabs", false)) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY));
+ scene_tabs->set_min_width(int(EDITOR_DEF("interface/scene_tabs/minimum_width", 50)) * EDSCALE);
scene_tabs->connect("tab_changed", this, "_scene_tab_changed");
scene_tabs->connect("right_button_pressed", this, "_scene_tab_script_edited");
scene_tabs->connect("tab_close", this, "_scene_tab_closed");
+ scene_tabs->connect("tab_hover", this, "_scene_tab_hover");
+ scene_tabs->connect("mouse_exited", this, "_scene_tab_exit");
+ scene_tabs->connect("gui_input", this, "_scene_tab_input");
HBoxContainer *tabbar_container = memnew(HBoxContainer);
scene_tabs->set_h_size_flags(Control::SIZE_EXPAND_FILL);
@@ -6039,7 +6112,7 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(Polygon2DEditorPlugin(this)));
add_editor_plugin(memnew(LightOccluder2DEditorPlugin(this)));
add_editor_plugin(memnew(NavigationPolygonEditorPlugin(this)));
- add_editor_plugin(memnew(ColorRampEditorPlugin(this)));
+ add_editor_plugin(memnew(GradientEditorPlugin(this)));
add_editor_plugin(memnew(GradientTextureEditorPlugin(this)));
add_editor_plugin(memnew(CollisionShape2DEditorPlugin(this)));
add_editor_plugin(memnew(CurveTextureEditorPlugin(this)));