summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/Godot.app/Contents/Info.plist4
-rw-r--r--tools/editor/editor_data.cpp10
-rw-r--r--tools/editor/editor_data.h1
-rw-r--r--tools/editor/editor_node.cpp116
-rw-r--r--tools/editor/editor_node.h36
-rw-r--r--tools/editor/editor_settings.cpp4
-rw-r--r--tools/editor/plugins/canvas_item_editor_plugin.cpp20
-rw-r--r--tools/editor/plugins/canvas_item_editor_plugin.h1
-rw-r--r--tools/editor/plugins/script_editor_plugin.cpp52
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.cpp102
-rw-r--r--tools/editor/scene_tree_dock.cpp3
11 files changed, 248 insertions, 101 deletions
diff --git a/tools/Godot.app/Contents/Info.plist b/tools/Godot.app/Contents/Info.plist
index e2a6489782..2b58162ae8 100755
--- a/tools/Godot.app/Contents/Info.plist
+++ b/tools/Godot.app/Contents/Info.plist
@@ -19,11 +19,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
- <string>2.0.1</string>
+ <string>2.1-dev</string>
<key>CFBundleSignature</key>
<string>godot</string>
<key>CFBundleVersion</key>
- <string>2.0.1</string>
+ <string>2.1-dev</string>
<key>NSHumanReadableCopyright</key>
<string>© 2007-2016 Juan Linietsky, Ariel Manzur</string>
<key>LSMinimumSystemVersion</key>
diff --git a/tools/editor/editor_data.cpp b/tools/editor/editor_data.cpp
index f78ab93c30..8bb2d60cab 100644
--- a/tools/editor/editor_data.cpp
+++ b/tools/editor/editor_data.cpp
@@ -260,6 +260,16 @@ EditorPlugin* EditorData::get_subeditor(Object *p_object) {
return NULL;
}
+Vector<EditorPlugin*> EditorData::get_subeditors(Object* p_object) {
+ Vector<EditorPlugin*> sub_plugins;
+ for (int i = 0; i < editor_plugins.size(); i++) {
+ if (!editor_plugins[i]->has_main_screen() && editor_plugins[i]->handles(p_object)) {
+ sub_plugins.push_back(editor_plugins[i]);
+ }
+ }
+ return sub_plugins;
+}
+
EditorPlugin* EditorData::get_editor(String p_name) {
for(int i=0;i<editor_plugins.size();i++) {
diff --git a/tools/editor/editor_data.h b/tools/editor/editor_data.h
index 5814ae8f5c..79843c4df5 100644
--- a/tools/editor/editor_data.h
+++ b/tools/editor/editor_data.h
@@ -150,6 +150,7 @@ public:
EditorPlugin* get_editor(Object *p_object);
EditorPlugin* get_subeditor(Object *p_object);
+ Vector<EditorPlugin*> get_subeditors(Object *p_object);
EditorPlugin* get_editor(String p_name);
void copy_object_params(Object *p_object);
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index 6d033a5c25..aa47e97622 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -1571,15 +1571,27 @@ void EditorNode::_imported(Node *p_node) {
}
+void EditorNode::_hide_top_editors() {
+ _display_top_editors(false);
-void EditorNode::_hide_top_editors() {
+ editor_plugins_over->clear();
+}
+
+void EditorNode::_display_top_editors(bool p_display) {
+ editor_plugins_over->make_visible(p_display);
+}
+
+void EditorNode::_set_top_editors(Vector<EditorPlugin*> p_editor_plugins_over) {
+ editor_plugins_over->set_plugins_list(p_editor_plugins_over);
+}
- if (editor_plugin_over)
- editor_plugin_over->make_visible(false);
- editor_plugin_over=NULL;
+void EditorNode::_set_editing_top_editors(Object* p_current_object) {
+ editor_plugins_over->edit(p_current_object);
}
+
+
void EditorNode::_edit_current() {
uint32_t current = editor_history.get_current();
@@ -1598,8 +1610,7 @@ void EditorNode::_edit_current() {
property_editor->edit( NULL );
object_menu->set_disabled(true);
- if (editor_plugin_over)
- editor_plugin_over->make_visible(false);
+ _display_top_editors(false);
return;
}
@@ -1679,20 +1690,18 @@ void EditorNode::_edit_current() {
}
- EditorPlugin *sub_plugin = editor_data.get_subeditor(current_obj);
-
- if (sub_plugin) {
+ Vector<EditorPlugin*> sub_plugins = editor_data.get_subeditors(current_obj);
+ if (!sub_plugins.empty()) {
+ _display_top_editors(false);
- if (editor_plugin_over)
- editor_plugin_over->make_visible(false);
- editor_plugin_over=sub_plugin;
- editor_plugin_over->edit(current_obj);
- editor_plugin_over->make_visible(true);
- } else if (editor_plugin_over) {
+ _set_top_editors(sub_plugins);
+ _set_editing_top_editors(current_obj);
+ _display_top_editors(true);
+
+ } else if (!editor_plugins_over->get_plugins_list().empty()) {
- editor_plugin_over->make_visible(false);
- editor_plugin_over=NULL;
+ _hide_top_editors();
}
/*
@@ -2583,10 +2592,9 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
}
editor_data.get_undo_redo().clear_history();
- if (editor_plugin_over) { //reload editor plugin
- editor_plugin_over->edit(NULL);
- editor_plugin_over->edit(current);
- }
+
+ _set_editing_top_editors(NULL);
+ _set_editing_top_editors(current);
} break;
case OBJECT_CALL_METHOD: {
@@ -6138,7 +6146,7 @@ EditorNode::EditorNode() {
_rebuild_import_menu();
editor_plugin_screen=NULL;
- editor_plugin_over=NULL;
+ editor_plugins_over = memnew(EditorPluginList);
// force_top_viewport(true);
_edit_current();
@@ -6270,12 +6278,72 @@ EditorNode::EditorNode() {
EditorNode::~EditorNode() {
-
-
+
memdelete( EditorHelp::get_doc_data() );
memdelete(editor_selection);
+ memdelete(editor_plugins_over);
memdelete(file_server);
EditorSettings::destroy();
}
+/*
+ * EDITOR PLUGIN LIST
+ */
+
+
+void EditorPluginList::make_visible(bool p_visible) {
+ if (!plugins_list.empty()) {
+ for (int i = 0; i < plugins_list.size(); i++) {
+ plugins_list[i]->make_visible(p_visible);
+ }
+ }
+}
+
+void EditorPluginList::edit(Object* p_object) {
+ if (!plugins_list.empty()) {
+ for (int i = 0; i < plugins_list.size(); i++) {
+ plugins_list[i]->edit(p_object);
+ }
+ }
+}
+
+bool EditorPluginList::forward_input_event(const InputEvent& p_event) {
+ bool discard = false;
+ if (!plugins_list.empty()) {
+ for (int i = 0; i < plugins_list.size(); i++) {
+ if (plugins_list[i]->forward_input_event(p_event)) {
+ discard = true;
+ }
+ }
+ }
+ return discard;
+}
+
+bool EditorPluginList::forward_spatial_input_event(Camera* p_camera, const InputEvent& p_event) {
+ bool discard = false;
+ if (!plugins_list.empty()) {
+ for (int i = 0; i < plugins_list.size(); i++) {
+ if (plugins_list[i]->forward_spatial_input_event(p_camera, p_event)) {
+ discard = true;
+ }
+ }
+ }
+ return discard;
+}
+
+bool EditorPluginList::empty() {
+ return plugins_list.empty();
+}
+
+void EditorPluginList::clear() {
+ plugins_list.clear();
+}
+
+EditorPluginList::EditorPluginList() {
+}
+
+EditorPluginList::~EditorPluginList() {
+}
+
+
diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h
index b8fabb4c55..e4939afd34 100644
--- a/tools/editor/editor_node.h
+++ b/tools/editor/editor_node.h
@@ -95,7 +95,7 @@
typedef void (*EditorNodeInitCallback)();
-
+class EditorPluginList;
class EditorNode : public Node {
@@ -372,7 +372,7 @@ private:
Vector<EditorPlugin*> editor_plugins;
EditorPlugin *editor_plugin_screen;
- EditorPlugin *editor_plugin_over;
+ EditorPluginList *editor_plugins_over;
EditorHistory editor_history;
EditorData editor_data;
@@ -449,6 +449,10 @@ private:
void _transform_keyed(Object *sp,const String& p_sub,const Transform& p_key);
void _hide_top_editors();
+ void _display_top_editors(bool p_display);
+ void _set_top_editors(Vector<EditorPlugin*> p_editor_plugins_over);
+ void _set_editing_top_editors(Object * p_current_object);
+
void _quick_opened();
void _quick_run();
@@ -575,7 +579,7 @@ public:
EditorPlugin *get_editor_plugin_screen() { return editor_plugin_screen; }
- EditorPlugin *get_editor_plugin_over() { return editor_plugin_over; }
+ EditorPluginList *get_editor_plugins_over() { return editor_plugins_over; }
PropertyEditor *get_property_editor() { return property_editor; }
static void add_editor_plugin(EditorPlugin *p_editor);
@@ -710,6 +714,32 @@ struct EditorProgress {
~EditorProgress() { EditorNode::progress_end_task(task); }
};
+class EditorPluginList : public Object {
+private:
+ Vector<EditorPlugin*> plugins_list;
+
+public:
+
+ void set_plugins_list(Vector<EditorPlugin*> p_plugins_list) {
+ plugins_list = p_plugins_list;
+ }
+
+ Vector<EditorPlugin*> get_plugins_list() {
+ return plugins_list;
+ }
+
+ void make_visible(bool p_visible);
+ void edit(Object *p_object);
+ bool forward_input_event(const InputEvent& p_event);
+ bool forward_spatial_input_event(Camera* p_camera, const InputEvent& p_event);
+ void clear();
+ bool empty();
+
+ EditorPluginList();
+ ~EditorPluginList();
+
+} ;
+
struct EditorProgressBG {
String task;
diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp
index a7c01e0f6f..255ad40bce 100644
--- a/tools/editor/editor_settings.cpp
+++ b/tools/editor/editor_settings.cpp
@@ -392,12 +392,14 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
hints["global/default_project_export_path"]=PropertyInfo(Variant::STRING,"global/default_project_export_path",PROPERTY_HINT_GLOBAL_DIR);
set("global/show_script_in_scene_tabs",false);
set("text_editor/background_color",Color::html("3b000000"));
+ set("text_editor/caret_color",Color::html("aaaaaa"));
set("text_editor/text_color",Color::html("aaaaaa"));
set("text_editor/text_selected_color",Color::html("000000"));
set("text_editor/keyword_color",Color::html("ffffb3"));
set("text_editor/base_type_color",Color::html("a4ffd4"));
set("text_editor/engine_type_color",Color::html("83d3ff"));
set("text_editor/function_color",Color::html("66a2ce"));
+ set("text_editor/member_variable_color",Color::html("e64e59"));
set("text_editor/comment_color",Color::html("983d1b"));
set("text_editor/string_color",Color::html("ef6ebe"));
set("text_editor/number_color",Color::html("EB9532"));
@@ -407,6 +409,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("text_editor/current_line_color",Color(0.3,0.5,0.8,0.15));
set("text_editor/word_highlighted_color",Color(0.8,0.9,0.9,0.15));
+ set("text_editor/syntax_highlighting", true);
+
set("text_editor/highlight_all_occurrences", true);
set("text_editor/scroll_past_end_of_file", false);
diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp
index 6eb26542be..91c26d9d59 100644
--- a/tools/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp
@@ -39,6 +39,7 @@
#include "scene/gui/grid_container.h"
#include "tools/editor/animation_editor.h"
#include "tools/editor/plugins/animation_player_editor_plugin.h"
+#include "scene/resources/packed_scene.h"
class SnapDialog : public ConfirmationDialog {
@@ -415,6 +416,14 @@ void CanvasItemEditor::_keying_changed() {
animation_hb->hide();
}
+bool CanvasItemEditor::_is_part_of_subscene(CanvasItem *p_item) {
+
+ Node* scene_node = get_tree()->get_edited_scene_root();
+ Node* item_owner = p_item->get_owner();
+
+ return item_owner && item_owner!=scene_node && p_item!=scene_node && item_owner->get_filename()!="";
+}
+
// slow but modern computers should have no problem
CanvasItem* CanvasItemEditor::_select_canvas_item_at_pos(const Point2& p_pos,Node* p_node,const Matrix32& p_parent_xform,const Matrix32& p_canvas_xform) {
@@ -441,8 +450,7 @@ CanvasItem* CanvasItemEditor::_select_canvas_item_at_pos(const Point2& p_pos,Nod
return r;
}
-
- if (c && c->is_visible() && !c->has_meta("_edit_lock_") && !c->cast_to<CanvasLayer>()) {
+ if (c && c->is_visible() && !c->has_meta("_edit_lock_") && !_is_part_of_subscene(c) && !c->cast_to<CanvasLayer>()) {
Rect2 rect = c->get_item_rect();
Point2 local_pos = (p_parent_xform * p_canvas_xform * c->get_transform()).affine_inverse().xform(p_pos);
@@ -1037,10 +1045,10 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) {
{
EditorNode *en = editor;
- EditorPlugin *over_plugin = en->get_editor_plugin_over();
+ EditorPluginList *over_plugin_list = en->get_editor_plugins_over();
- if (over_plugin) {
- bool discard = over_plugin->forward_input_event(p_event);
+ if (!over_plugin_list->empty()) {
+ bool discard = over_plugin_list->forward_input_event(p_event);
if (discard) {
accept_event();
return;
@@ -3345,7 +3353,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
PopupMenu *p2 = memnew(PopupMenu);
p->add_child(p2);
p2->set_name("skeleton");
- p2->add_item("Make Bones",SKELETON_MAKE_BONES,KEY_MASK_CMD|KEY_SHIFT|KEY_B);
+ p2->add_item("Make Bones",SKELETON_MAKE_BONES,KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_B);
p2->add_item("Clear Bones",SKELETON_CLEAR_BONES);
p2->add_separator();
p2->add_item("Make IK Chain",SKELETON_SET_IK_CHAIN);
diff --git a/tools/editor/plugins/canvas_item_editor_plugin.h b/tools/editor/plugins/canvas_item_editor_plugin.h
index 301c67756c..22acfceed0 100644
--- a/tools/editor/plugins/canvas_item_editor_plugin.h
+++ b/tools/editor/plugins/canvas_item_editor_plugin.h
@@ -295,6 +295,7 @@ class CanvasItemEditor : public VBoxContainer {
int handle_len;
+ bool _is_part_of_subscene(CanvasItem *p_item);
CanvasItem* _select_canvas_item_at_pos(const Point2 &p_pos,Node* p_node,const Matrix32& p_parent_xform,const Matrix32& p_canvas_xform);
void _find_canvas_items_at_pos(const Point2 &p_pos,Node* p_node,const Matrix32& p_parent_xform,const Matrix32& p_canvas_xform, Vector<_SelectResult> &r_items);
void _find_canvas_items_at_rect(const Rect2& p_rect,Node* p_node,const Matrix32& p_parent_xform,const Matrix32& p_canvas_xform,List<CanvasItem*> *r_items);
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp
index 96dd03d111..5f2efc8f03 100644
--- a/tools/editor/plugins/script_editor_plugin.cpp
+++ b/tools/editor/plugins/script_editor_plugin.cpp
@@ -288,6 +288,7 @@ void ScriptTextEditor::_load_theme_settings() {
get_text_edit()->set_custom_bg_color(EDITOR_DEF("text_editor/background_color",Color(0,0,0,0)));
get_text_edit()->add_color_override("font_color",EDITOR_DEF("text_editor/text_color",Color(0,0,0)));
+ get_text_edit()->add_color_override("caret_color",EDITOR_DEF("text_editor/caret_color",Color(0,0,0)));
get_text_edit()->add_color_override("font_selected_color",EDITOR_DEF("text_editor/text_selected_color",Color(1,1,1)));
get_text_edit()->add_color_override("selection_color",EDITOR_DEF("text_editor/selection_color",Color(0.2,0.2,1)));
get_text_edit()->add_color_override("brace_mismatch_color",EDITOR_DEF("text_editor/brace_mismatch_color",Color(1,0.2,0.2)));
@@ -295,10 +296,10 @@ void ScriptTextEditor::_load_theme_settings() {
get_text_edit()->add_color_override("word_highlighted_color",EDITOR_DEF("text_editor/word_highlighted_color",Color(0.8,0.9,0.9,0.15)));
get_text_edit()->add_color_override("number_color",EDITOR_DEF("text_editor/number_color",Color(0.9,0.6,0.0,2)));
get_text_edit()->add_color_override("function_color",EDITOR_DEF("text_editor/function_color",Color(0.4,0.6,0.8)));
+ get_text_edit()->add_color_override("member_variable_color",EDITOR_DEF("text_editor/member_variable_color",Color(0.9,0.3,0.3)));
Color keyword_color= EDITOR_DEF("text_editor/keyword_color",Color(0.5,0.0,0.2));
- get_text_edit()->set_syntax_coloring(true);
List<String> keywords;
script->get_language()->get_reserved_words(&keywords);
for(List<String>::Element *E=keywords.front();E;E=E->next()) {
@@ -1071,6 +1072,7 @@ void ScriptEditor::_menu_option(int p_option) {
if (scr.is_null())
return;
+ tx->begin_complex_operation();
if (tx->is_selection_active())
{
int from_line = tx->get_selection_from_line();
@@ -1102,6 +1104,7 @@ void ScriptEditor::_menu_option(int p_option) {
swap_lines(tx, line_id, next_id);
}
+ tx->end_complex_operation();
tx->update();
} break;
@@ -1112,6 +1115,7 @@ void ScriptEditor::_menu_option(int p_option) {
if (scr.is_null())
return;
+ tx->begin_complex_operation();
if (tx->is_selection_active())
{
int from_line = tx->get_selection_from_line();
@@ -1143,6 +1147,7 @@ void ScriptEditor::_menu_option(int p_option) {
swap_lines(tx, line_id, next_id);
}
+ tx->end_complex_operation();
tx->update();
} break;
@@ -1153,27 +1158,10 @@ void ScriptEditor::_menu_option(int p_option) {
if (scr.is_null())
return;
-
+ tx->begin_complex_operation();
if (tx->is_selection_active())
{
- int begin = tx->get_selection_from_line();
- int end = tx->get_selection_to_line();
- for (int i = begin; i <= end; i++)
- {
- String line_text = tx->get_line(i);
- // begins with tab
- if (line_text.begins_with("\t"))
- {
- line_text = line_text.substr(1, line_text.length());
- tx->set_line(i, line_text);
- }
- // begins with 4 spaces
- else if (line_text.begins_with(" "))
- {
- line_text = line_text.substr(4, line_text.length());
- tx->set_line(i, line_text);
- }
- }
+ tx->indent_selection_left();
}
else
{
@@ -1192,6 +1180,7 @@ void ScriptEditor::_menu_option(int p_option) {
tx->set_line(begin, line_text);
}
}
+ tx->end_complex_operation();
tx->update();
//tx->deselect();
@@ -1203,16 +1192,10 @@ void ScriptEditor::_menu_option(int p_option) {
if (scr.is_null())
return;
+ tx->begin_complex_operation();
if (tx->is_selection_active())
{
- int begin = tx->get_selection_from_line();
- int end = tx->get_selection_to_line();
- for (int i = begin; i <= end; i++)
- {
- String line_text = tx->get_line(i);
- line_text = '\t' + line_text;
- tx->set_line(i, line_text);
- }
+ tx->indent_selection_right();
}
else
{
@@ -1221,6 +1204,7 @@ void ScriptEditor::_menu_option(int p_option) {
line_text = '\t' + line_text;
tx->set_line(begin, line_text);
}
+ tx->end_complex_operation();
tx->update();
//tx->deselect();
@@ -1252,11 +1236,16 @@ void ScriptEditor::_menu_option(int p_option) {
return;
-
+ tx->begin_complex_operation();
if (tx->is_selection_active())
{
int begin = tx->get_selection_from_line();
int end = tx->get_selection_to_line();
+
+ // End of selection ends on the first column of the last line, ignore it.
+ if(tx->get_selection_to_column() == 0)
+ end -= 1;
+
for (int i = begin; i <= end; i++)
{
String line_text = tx->get_line(i);
@@ -1279,6 +1268,7 @@ void ScriptEditor::_menu_option(int p_option) {
line_text = "#" + line_text;
tx->set_line(begin, line_text);
}
+ tx->end_complex_operation();
tx->update();
//tx->deselect();
@@ -1935,6 +1925,7 @@ void ScriptEditor::edit(const Ref<Script>& p_script) {
ste->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/tab_size"));
ste->get_text_edit()->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/draw_tabs"));
ste->get_text_edit()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/show_line_numbers"));
+ ste->get_text_edit()->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/syntax_highlighting"));
ste->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlight_all_occurrences"));
ste->get_text_edit()->set_callhint_settings(
EditorSettings::get_singleton()->get("text_editor/put_callhint_tooltip_below_current_line"),
@@ -2076,6 +2067,7 @@ void ScriptEditor::_editor_settings_changed() {
ste->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/tab_size"));
ste->get_text_edit()->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/draw_tabs"));
ste->get_text_edit()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/show_line_numbers"));
+ ste->get_text_edit()->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/syntax_highlighting"));
ste->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlight_all_occurrences"));
}
@@ -2705,7 +2697,7 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) {
EDITOR_DEF("text_editor/script_temperature_history_size",15);
EDITOR_DEF("text_editor/script_temperature_hot_color",Color(1,0,0,0.3));
EDITOR_DEF("text_editor/script_temperature_cold_color",Color(0,0,1,0.3));
- EDITOR_DEF("text_editor/group_help_pages",false);
+ EDITOR_DEF("text_editor/group_help_pages",true);
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"external_editor/exec_path",PROPERTY_HINT_GLOBAL_FILE));
EDITOR_DEF("external_editor/exec_flags","");
diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp
index 79ff78ca0d..9ab7aafeb2 100644
--- a/tools/editor/plugins/spatial_editor_plugin.cpp
+++ b/tools/editor/plugins/spatial_editor_plugin.cpp
@@ -51,7 +51,31 @@
#define GIZMO_SCALE_DEFAULT 0.15
-//void SpatialEditorViewport::_update_camera();
+void SpatialEditorViewport::_update_camera() {
+ if (orthogonal) {
+ Size2 size = get_size();
+ Size2 vpsize = Point2(cursor.distance*size.get_aspect(), cursor.distance / size.get_aspect());
+ //camera->set_orthogonal(size.width*cursor.distance,get_znear(),get_zfar());
+ camera->set_orthogonal(2 * cursor.distance, 0.1, 8192);
+ }
+ else
+ camera->set_perspective(get_fov(), get_znear(), get_zfar());
+
+ Transform camera_transform;
+ camera_transform.translate(cursor.pos);
+ camera_transform.basis.rotate(Vector3(0, 1, 0), cursor.y_rot);
+ camera_transform.basis.rotate(Vector3(1, 0, 0), cursor.x_rot);
+
+ if (orthogonal)
+ camera_transform.translate(0, 0, 4096);
+ else
+ camera_transform.translate(0, 0, cursor.distance);
+
+ if (camera->get_global_transform() != camera_transform) {
+ camera->set_global_transform(camera_transform);
+ update_transform_gizmo_view();
+ }
+}
String SpatialEditorGizmo::get_handle_name(int p_idx) const {
@@ -810,16 +834,15 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
{
EditorNode *en = editor;
- EditorPlugin *over_plugin = en->get_editor_plugin_over();
+ EditorPluginList *over_plugin_list = en->get_editor_plugins_over();
- if (over_plugin) {
- bool discard = over_plugin->forward_spatial_input_event(camera,p_event);
+ if (!over_plugin_list->empty()) {
+ bool discard = over_plugin_list->forward_spatial_input_event(camera,p_event);
if (discard)
return;
}
}
-
switch(p_event.type) {
case InputEvent::MOUSE_BUTTON: {
@@ -1204,11 +1227,9 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
}
} break;
case InputEvent::MOUSE_MOTION: {
-
const InputEventMouseMotion &m=p_event.mouse_motion;
_edit.mouse_pos=Point2(p_event.mouse_motion.x,p_event.mouse_motion.y);
-
-
+
if (spatial_editor->get_selected()) {
@@ -1244,7 +1265,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
NavigationScheme nav_scheme = _get_navigation_schema("3d_editor/navigation_scheme");
NavigationMode nav_mode = NAVIGATION_NONE;
-
+
if (_edit.gizmo.is_valid()) {
Plane plane=Plane(_edit.gizmo_initial_pos,_get_camera_normal());
@@ -1558,6 +1579,26 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
if (m.mod.alt)
nav_mode = NAVIGATION_PAN;
}
+ }else{
+ // Handle trackpad (no external mouse) use case
+ int mod = 0;
+ if (m.mod.shift)
+ mod=KEY_SHIFT;
+ if (m.mod.alt)
+ mod=KEY_ALT;
+ if (m.mod.control)
+ mod=KEY_CONTROL;
+ if (m.mod.meta)
+ mod=KEY_META;
+
+ if(mod){
+ if (mod == _get_key_modifier("3d_editor/pan_modifier"))
+ nav_mode = NAVIGATION_PAN;
+ else if (mod == _get_key_modifier("3d_editor/zoom_modifier"))
+ nav_mode = NAVIGATION_ZOOM;
+ else if (mod == _get_key_modifier("3d_editor/orbit_modifier"))
+ nav_mode = NAVIGATION_ORBIT;
+ }
}
switch(nav_mode) {
@@ -1770,6 +1811,10 @@ void SpatialEditorViewport::_notification(int p_what) {
bool visible=is_visible();
set_process(visible);
+
+ if (visible)
+ _update_camera();
+
call_deferred("update_transform_gizmo_view");
}
@@ -1791,28 +1836,7 @@ void SpatialEditorViewport::_notification(int p_what) {
}
*/
- if (orthogonal) {
- Size2 size=get_size();
- Size2 vpsize = Point2(cursor.distance*size.get_aspect(),cursor.distance/size.get_aspect());
- //camera->set_orthogonal(size.width*cursor.distance,get_znear(),get_zfar());
- camera->set_orthogonal(2*cursor.distance,0.1,8192);
- } else
- camera->set_perspective(get_fov(),get_znear(),get_zfar());
-
- Transform camera_transform;
- camera_transform.translate( cursor.pos );
- camera_transform.basis.rotate(Vector3(0,1,0),cursor.y_rot);
- camera_transform.basis.rotate(Vector3(1,0,0),cursor.x_rot);
-
- if (orthogonal)
- camera_transform.translate(0,0,4096);
- else
- camera_transform.translate(0,0,cursor.distance);
-
- if (camera->get_global_transform()!=camera_transform) {
- camera->set_global_transform( camera_transform );
- update_transform_gizmo_view();
- }
+ _update_camera();
Map<Node*,Object*> &selection = editor_selection->get_selection();
@@ -1915,7 +1939,6 @@ void SpatialEditorViewport::_notification(int p_what) {
surface->connect("mouse_enter",this,"_smouseenter");
preview_camera->set_icon(get_icon("Camera","EditorIcons"));
_init_gizmo_instance(index);
-
}
if (p_what==NOTIFICATION_EXIT_TREE) {
@@ -3553,9 +3576,9 @@ void SpatialEditor::_unhandled_key_input(InputEvent p_event) {
{
EditorNode *en = editor;
- EditorPlugin *over_plugin = en->get_editor_plugin_over();
+ EditorPluginList *over_plugin_list = en->get_editor_plugins_over();
- if (over_plugin && over_plugin->forward_input_event(p_event)) {
+ if (!over_plugin_list->empty() && over_plugin_list->forward_input_event(p_event)) {
return; //ate the over input event
}
@@ -3579,6 +3602,17 @@ void SpatialEditor::_unhandled_key_input(InputEvent p_event) {
case KEY_E: _menu_item_pressed(MENU_TOOL_ROTATE); break;
case KEY_R: _menu_item_pressed(MENU_TOOL_SCALE); break;
+ case KEY_Z: {
+ if (k.mod.shift || k.mod.control || k.mod.command)
+ break;
+
+ if (view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_WIREFRAME))) {
+ _menu_item_pressed(MENU_VIEW_DISPLAY_NORMAL);
+ } else {
+ _menu_item_pressed(MENU_VIEW_DISPLAY_WIREFRAME);
+ }
+ } break;
+
#if 0
#endif
}
diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp
index 5877ce1a43..6b2961ea72 100644
--- a/tools/editor/scene_tree_dock.cpp
+++ b/tools/editor/scene_tree_dock.cpp
@@ -1098,8 +1098,7 @@ void SceneTreeDock::_delete_confirm() {
return;
- if (editor->get_editor_plugin_over())
- editor->get_editor_plugin_over()->make_visible(false);
+ editor->get_editor_plugins_over()->make_visible(false);
editor_data->get_undo_redo().create_action("Remove Node(s)");