diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_help.cpp | 255 | ||||
-rw-r--r-- | editor/editor_help.h | 12 | ||||
-rw-r--r-- | editor/editor_themes.cpp | 6 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 63 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.h | 4 |
5 files changed, 170 insertions, 170 deletions
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 676b168371..d20b55e268 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -522,6 +522,19 @@ EditorHelpIndex::EditorHelpIndex() { /// ///////////////////////////////// DocData *EditorHelp::doc = NULL; +void EditorHelp::_init_colors() { + + title_color = get_color("accent_color", "Editor"); + text_color = get_color("default_color", "RichTextLabel"); + headline_color = get_color("headline_color", "EditorHelp"); + base_type_color = title_color.linear_interpolate(text_color, 0.5); + comment_color = Color(text_color.r, text_color.g, text_color.b, 0.6); + symbol_color = comment_color; + value_color = Color(text_color.r, text_color.g, text_color.b, 0.4); + qualifier_color = Color(text_color.r, text_color.g, text_color.b, 0.8); + type_color = get_color("accent_color", "Editor").linear_interpolate(text_color, 0.5); +} + void EditorHelp::_unhandled_key_input(const Ref<InputEvent> &p_ev) { if (!is_visible_in_tree()) @@ -654,6 +667,86 @@ void EditorHelp::_add_type(const String &p_type, const String &p_enum) { class_desc->pop(); } +void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview) { + + method_line[p_method.name] = class_desc->get_line_count() - 2; //gets overridden if description + + const bool is_vararg = p_method.qualifiers.find("vararg") != -1; + + if (p_overview) { + class_desc->push_cell(); + class_desc->push_align(RichTextLabel::ALIGN_RIGHT); + } + + _add_type(p_method.return_type, p_method.return_enum); + + if (p_overview) { + class_desc->pop(); //align + class_desc->pop(); //cell + class_desc->push_cell(); + } else { + class_desc->add_text(" "); + } + + if (p_overview && p_method.description != "") { + class_desc->push_meta("@method" + p_method.name); + } + + class_desc->push_color(headline_color); + _add_text(p_method.name); + class_desc->pop(); + + if (p_overview && p_method.description != "") { + class_desc->pop(); //meta + } + + class_desc->push_color(symbol_color); + class_desc->add_text(p_method.arguments.size() || is_vararg ? "( " : "("); + class_desc->pop(); + + for (int j = 0; j < p_method.arguments.size(); j++) { + class_desc->push_color(text_color); + if (j > 0) + class_desc->add_text(", "); + _add_type(p_method.arguments[j].type, p_method.arguments[j].enumeration); + class_desc->add_text(" "); + _add_text(p_method.arguments[j].name); + if (p_method.arguments[j].default_value != "") { + + class_desc->push_color(symbol_color); + class_desc->add_text("="); + class_desc->pop(); + _add_text(p_method.arguments[j].default_value); + } + + class_desc->pop(); + } + + if (is_vararg) { + class_desc->push_color(text_color); + if (p_method.arguments.size()) + class_desc->add_text(", "); + class_desc->push_color(symbol_color); + class_desc->add_text("..."); + class_desc->pop(); + class_desc->pop(); + } + + class_desc->push_color(symbol_color); + class_desc->add_text(p_method.arguments.size() || is_vararg ? " )" : ")"); + class_desc->pop(); + if (p_method.qualifiers != "") { + + class_desc->push_color(qualifier_color); + class_desc->add_text(" "); + _add_text(p_method.qualifiers); + class_desc->pop(); + } + + if (p_overview) + class_desc->pop(); //cell +} + Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { //ERR_FAIL_COND(!doc->class_list.has(p_class)); @@ -679,15 +772,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { edited_class = p_class; //edited_class->show(); - // Colors - const Color title_color = get_color("accent_color", "Editor"); - const Color text_color = get_color("default_color", "RichTextLabel"); - const Color headline_color = get_color("headline_color", "EditorHelp"); - const Color base_type_color = title_color.linear_interpolate(text_color, 0.5); - const Color comment_color = Color(text_color.r, text_color.g, text_color.b, 0.6); - const Color symbol_color = comment_color; - const Color value_color = Color(text_color.r, text_color.g, text_color.b, 0.4); - const Color qualifier_color = Color(text_color.r, text_color.g, text_color.b, 0.8); + _init_colors(); DocData::ClassDoc cd = doc->class_list[p_class]; //make a copy, so we can sort without worrying @@ -892,78 +977,51 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->push_table(2); class_desc->set_table_column_expand(1, 1); - for (int i = 0; i < methods.size(); i++) { - - bool is_vararg = methods[i].qualifiers.find("vararg") != -1; - - method_line[methods[i].name] = class_desc->get_line_count() - 2; //gets overridden if description - - class_desc->push_cell(); - class_desc->push_align(RichTextLabel::ALIGN_RIGHT); - class_desc->push_font(doc_code_font); - _add_type(methods[i].return_type, methods[i].return_enum); - //class_desc->add_text(" "); - class_desc->pop(); //align - class_desc->pop(); //font - class_desc->pop(); //cell + bool any_previous = false; + for (int pass = 0; pass < 2; pass++) { + Vector<DocData::MethodDoc> m; - class_desc->push_cell(); - class_desc->push_font(doc_code_font); + for (int i = 0; i < methods.size(); i++) { + const String &q = methods[i].qualifiers; + if ((pass == 0 && q.find("virtual") != -1) || (pass == 1 && q.find("virtual") == -1)) { + m.push_back(methods[i]); + } + } - if (methods[i].description != "") { - method_descr = true; - class_desc->push_meta("@method" + methods[i].name); + if (any_previous && !m.empty()) { + class_desc->push_cell(); + class_desc->pop(); //cell + class_desc->push_cell(); + class_desc->pop(); //cell + any_previous = false; } - class_desc->push_color(headline_color); - _add_text(methods[i].name); - class_desc->pop(); - if (methods[i].description != "") - class_desc->pop(); // pop meta - class_desc->push_color(symbol_color); - class_desc->add_text(methods[i].arguments.size() || is_vararg ? "( " : "("); - class_desc->pop(); - for (int j = 0; j < methods[i].arguments.size(); j++) { - class_desc->push_color(text_color); - if (j > 0) - class_desc->add_text(", "); - _add_type(methods[i].arguments[j].type, methods[i].arguments[j].enumeration); - class_desc->add_text(" "); - _add_text(methods[i].arguments[j].name); - if (methods[i].arguments[j].default_value != "") { - class_desc->push_color(symbol_color); - class_desc->add_text("="); - class_desc->pop(); - _add_text(methods[i].arguments[j].default_value); + String group_prefix; + for (int i = 0; i < m.size(); i++) { + const String new_prefix = m[i].name.substr(0, 3); + bool is_new_group = false; + + if (i < m.size() - 1 && new_prefix == m[i + 1].name.substr(0, 3) && new_prefix != group_prefix) { + is_new_group = i > 0; + group_prefix = new_prefix; + } else if (group_prefix != "" && new_prefix != group_prefix) { + is_new_group = true; + group_prefix = ""; } - class_desc->pop(); - } + if (is_new_group && pass == 1) { + class_desc->push_cell(); + class_desc->pop(); //cell + class_desc->push_cell(); + class_desc->pop(); //cell + } - if (is_vararg) { - class_desc->push_color(text_color); - if (methods[i].arguments.size()) - class_desc->add_text(", "); - class_desc->push_color(symbol_color); - class_desc->add_text("..."); - class_desc->pop(); - class_desc->pop(); + _add_method(m[i], true); } - class_desc->push_color(symbol_color); - class_desc->add_text(methods[i].arguments.size() || is_vararg ? " )" : ")"); - class_desc->pop(); - if (methods[i].qualifiers != "") { - - class_desc->push_color(qualifier_color); - class_desc->add_text(" "); - _add_text(methods[i].qualifiers); - class_desc->pop(); - } - class_desc->pop(); //monofont - //class_desc->add_newline(); - class_desc->pop(); //cell + any_previous = !m.empty(); } + class_desc->pop(); //table class_desc->pop(); class_desc->add_newline(); @@ -1366,60 +1424,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { for (int i = 0; i < methods.size(); i++) { - bool is_vararg = methods[i].qualifiers.find("vararg") != -1; - - method_line[methods[i].name] = class_desc->get_line_count() - 2; - - class_desc->push_font(doc_code_font); - _add_type(methods[i].return_type, methods[i].return_enum); - - class_desc->add_text(" "); - class_desc->push_color(headline_color); - _add_text(methods[i].name); - class_desc->pop(); - class_desc->push_color(symbol_color); - class_desc->add_text(methods[i].arguments.size() || is_vararg ? "( " : "("); - class_desc->pop(); - for (int j = 0; j < methods[i].arguments.size(); j++) { - class_desc->push_color(text_color); - if (j > 0) - class_desc->add_text(", "); - _add_type(methods[i].arguments[j].type, methods[i].arguments[j].enumeration); - class_desc->add_text(" "); - _add_text(methods[i].arguments[j].name); - if (methods[i].arguments[j].default_value != "") { - - class_desc->push_color(symbol_color); - class_desc->add_text("="); - class_desc->pop(); - _add_text(methods[i].arguments[j].default_value); - } - - class_desc->pop(); - } - - if (is_vararg) { - class_desc->push_color(text_color); - if (methods[i].arguments.size()) - class_desc->add_text(", "); - class_desc->push_color(symbol_color); - class_desc->add_text("..."); - class_desc->pop(); - class_desc->pop(); - } - - class_desc->push_color(symbol_color); - class_desc->add_text(methods[i].arguments.size() || is_vararg ? " )" : ")"); - class_desc->pop(); - if (methods[i].qualifiers != "") { - - class_desc->push_color(qualifier_color); - class_desc->add_text(" "); - _add_text(methods[i].qualifiers); - class_desc->pop(); - } - - class_desc->pop(); + _add_method(methods[i], false); class_desc->add_newline(); class_desc->push_color(text_color); diff --git a/editor/editor_help.h b/editor/editor_help.h index a224c7f8ee..96a3309ca3 100644 --- a/editor/editor_help.h +++ b/editor/editor_help.h @@ -139,6 +139,17 @@ class EditorHelp : public VBoxContainer { String base_path; + Color title_color; + Color text_color; + Color headline_color; + Color base_type_color; + Color type_color; + Color comment_color; + Color symbol_color; + Color value_color; + Color qualifier_color; + + void _init_colors(); void _help_callback(const String &p_topic); void _add_text(const String &p_bbcode); @@ -146,6 +157,7 @@ class EditorHelp : public VBoxContainer { //void _button_pressed(int p_idx); void _add_type(const String &p_type, const String &p_enum = String()); + void _add_method(const DocData::MethodDoc &p_method, bool p_overview = true); void _class_list_select(const String &p_select); void _class_desc_select(const String &p_select); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 152eda7d91..cc0b292cc4 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -999,6 +999,12 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("bg", "ColorPickerButton", theme->get_icon("GuiMiniCheckerboard", "EditorIcons")); + // Information on 3D viewport + Ref<StyleBoxFlat> style_info_3d_viewport = style_default->duplicate(); + style_info_3d_viewport->set_bg_color(style_info_3d_viewport->get_bg_color() * Color(1, 1, 1, 0.5)); + style_info_3d_viewport->set_border_width_all(0); + theme->set_stylebox("Information3dViewport", "EditorStyles", style_info_3d_viewport); + // adaptive script theme constants // for comments and elements with lower relevance const Color dim_color = Color(font_color.r, font_color.g, font_color.b, 0.5); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 0f27310264..59da5112ae 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -2219,15 +2219,9 @@ void SpatialEditorViewport::_notification(int p_what) { viewport->set_hdr(hdr); bool show_info = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_INFORMATION)); - if (show_info != info->is_visible()) { - if (show_info) - info->show(); - else - info->hide(); - } + info_label->set_visible(show_info); if (show_info) { - String text; text += TTR("Objects Drawn") + ": " + itos(viewport->get_render_info(Viewport::RENDER_INFO_OBJECTS_IN_FRAME)) + "\n"; text += TTR("Material Changes") + ": " + itos(viewport->get_render_info(Viewport::RENDER_INFO_MATERIAL_CHANGES_IN_FRAME)) + "\n"; @@ -2235,38 +2229,19 @@ void SpatialEditorViewport::_notification(int p_what) { text += TTR("Surface Changes") + ": " + itos(viewport->get_render_info(Viewport::RENDER_INFO_SURFACE_CHANGES_IN_FRAME)) + "\n"; text += TTR("Draw Calls") + ": " + itos(viewport->get_render_info(Viewport::RENDER_INFO_DRAW_CALLS_IN_FRAME)) + "\n"; text += TTR("Vertices") + ": " + itos(viewport->get_render_info(Viewport::RENDER_INFO_VERTICES_IN_FRAME)); - - if (info_label->get_text() != text || surface->get_size() != prev_size) { - info_label->set_text(text); - Size2 ms = info->get_minimum_size(); - info->set_position(surface->get_size() - ms - Vector2(20, 20) * EDSCALE); - } + info_label->set_text(text); } // FPS Counter. bool show_fps = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_FPS)); - if (show_fps != fps->is_visible()) { - if (show_fps) - fps->show(); - else - fps->hide(); - } + fps_label->set_visible(show_fps); if (show_fps) { String text; const float temp_fps = Engine::get_singleton()->get_frames_per_second(); text += TTR("FPS") + ": " + itos(temp_fps) + " (" + String::num(1000.0f / temp_fps, 2) + " ms)"; - - if (fps_label->get_text() != text || surface->get_size() != prev_size) { - fps_label->set_text(text); - Size2 ms = fps->get_size(); - Size2 size = surface->get_size(); - size.y = ms.y + 20; - fps->set_position(size - ms - Vector2(20, 0) * EDSCALE); - } + fps_label->set_text(text); } - - prev_size = surface->get_size(); } if (p_what == NOTIFICATION_ENTER_TREE) { @@ -2275,8 +2250,8 @@ void SpatialEditorViewport::_notification(int p_what) { surface->connect("gui_input", this, "_sinput"); surface->connect("mouse_entered", this, "_smouseenter"); surface->connect("mouse_exited", this, "_smouseexit"); - info->add_style_override("panel", get_stylebox("panel", "Panel")); - fps->add_style_override("panel", get_stylebox("panel", "Panel")); + info_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); + fps_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); preview_camera->set_icon(get_icon("Camera", "EditorIcons")); _init_gizmo_instance(index); } @@ -2773,8 +2748,10 @@ void SpatialEditorViewport::set_can_preview(Camera *p_preview) { if (!preview_camera->is_pressed()) { if (p_preview) { + fps_label->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 15 * EDSCALE + preview_camera->get_size().height); preview_camera->show(); } else { + fps_label->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 10 * EDSCALE); preview_camera->hide(); } } @@ -3399,20 +3376,24 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed preview_node = NULL; - info = memnew(PanelContainer); - info->set_self_modulate(Color(1, 1, 1, 0.4)); - surface->add_child(info); info_label = memnew(Label); - info->add_child(info_label); - info->hide(); + info_label->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -90 * EDSCALE); + info_label->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, -90 * EDSCALE); + info_label->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -10 * EDSCALE); + info_label->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, -10 * EDSCALE); + info_label->set_h_grow_direction(GROW_DIRECTION_BEGIN); + info_label->set_v_grow_direction(GROW_DIRECTION_BEGIN); + surface->add_child(info_label); + info_label->hide(); // FPS Counter. - fps = memnew(PanelContainer); - fps->set_self_modulate(Color(1, 1, 1, 0.4)); - surface->add_child(fps); fps_label = memnew(Label); - fps->add_child(fps_label); - fps->hide(); + fps_label->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -90 * EDSCALE); + fps_label->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 10 * EDSCALE); + fps_label->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -10 * EDSCALE); + fps_label->set_h_grow_direction(GROW_DIRECTION_BEGIN); + surface->add_child(fps_label); + fps_label->hide(); accept = NULL; diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index 86b814ab8a..4aa1d9c0c1 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -106,7 +106,6 @@ private: int index; String name; void _menu_option(int p_option); - Size2 prev_size; Spatial *preview_node; AABB *preview_bounds; @@ -136,10 +135,7 @@ private: bool freelook_active; real_t freelook_speed; - PanelContainer *info; Label *info_label; - - PanelContainer *fps; Label *fps_label; struct _RayResult { |