diff options
Diffstat (limited to 'tools/editor/plugins')
-rw-r--r-- | tools/editor/plugins/canvas_item_editor_plugin.cpp | 8 | ||||
-rw-r--r-- | tools/editor/plugins/script_editor_plugin.cpp | 52 | ||||
-rw-r--r-- | tools/editor/plugins/spatial_editor_plugin.cpp | 102 |
3 files changed, 94 insertions, 68 deletions
diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index 8fd025c3e3..91c26d9d59 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -1045,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; @@ -3353,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/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 } |