diff options
-rw-r--r-- | doc/classes/MarginContainer.xml | 14 | ||||
-rw-r--r-- | doc/classes/OS.xml | 2 | ||||
-rw-r--r-- | doc/classes/TextEdit.xml | 14 | ||||
-rw-r--r-- | editor/doc/doc_data.cpp | 1 | ||||
-rw-r--r-- | editor/editor_settings.cpp | 1 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 13 | ||||
-rw-r--r-- | modules/gdscript/doc_classes/@GDScript.xml | 16 | ||||
-rw-r--r-- | platform/iphone/export/export.cpp | 4 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 39 | ||||
-rw-r--r-- | scene/gui/line_edit.h | 3 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 19 | ||||
-rw-r--r-- | scene/gui/text_edit.h | 1 | ||||
-rw-r--r-- | scene/resources/default_theme/default_theme.cpp | 2 |
13 files changed, 89 insertions, 40 deletions
diff --git a/doc/classes/MarginContainer.xml b/doc/classes/MarginContainer.xml index 0993ed88ca..3ea3204e56 100644 --- a/doc/classes/MarginContainer.xml +++ b/doc/classes/MarginContainer.xml @@ -4,7 +4,15 @@ Simple margin container. </brief_description> <description> - Simple margin container. Adds a left margin to anything contained. + Adds a top, left, bottom, and right margin to all [Control] nodes that are direct children of the container. To control the [MarginContainer]'s margin, use the [code]margin_*[/code] theme properties listed below. + [b]Note:[/b] Be careful, [Control] margin values are different than the constant margin values. If you want to change the custom margin values of the [MarginContainer] by code you should use the following examples: + [codeblock] + var margin_value = 100 + set("custom_constants/margin_top", margin_value) + set("custom_constants/margin_left", margin_value) + set("custom_constants/margin_bottom", margin_value) + set("custom_constants/margin_right", margin_value) + [/codeblock] </description> <tutorials> </tutorials> @@ -14,12 +22,16 @@ </constants> <theme_items> <theme_item name="margin_bottom" type="int"> + All direct children of [MarginContainer] will have a bottom margin of [code]margin_bottom[/code] pixels. </theme_item> <theme_item name="margin_left" type="int"> + All direct children of [MarginContainer] will have a left margin of [code]margin_left[/code] pixels. </theme_item> <theme_item name="margin_right" type="int"> + All direct children of [MarginContainer] will have a right margin of [code]margin_right[/code] pixels. </theme_item> <theme_item name="margin_top" type="int"> + All direct children of [MarginContainer] will have a top margin of [code]margin_top[/code] pixels. </theme_item> </theme_items> </class> diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index 7b50021284..3292438851 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -4,7 +4,7 @@ Operating System functions. </brief_description> <description> - Operating System functions. OS Wraps the most common functionality to communicate with the host Operating System, such as: mouse grabbing, mouse cursors, clipboard, video mode, date and time, timers, environment variables, execution of binaries, command line, etc. + Operating System functions. OS Wraps the most common functionality to communicate with the host Operating System, such as: clipboard, video mode, date and time, timers, environment variables, execution of binaries, command line, etc. </description> <tutorials> </tutorials> diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml index e818d753d8..8c87a4f2e7 100644 --- a/doc/classes/TextEdit.xml +++ b/doc/classes/TextEdit.xml @@ -521,12 +521,15 @@ </constants> <theme_items> <theme_item name="background_color" type="Color"> + Sets the background [Color] of this [TextEdit]. [member syntax_highlighting] has to be enabled. </theme_item> <theme_item name="bookmark_color" type="Color"> + Sets the [Color] of the bookmark marker. [member syntax_highlighting] has to be enabled. </theme_item> <theme_item name="brace_mismatch_color" type="Color"> </theme_item> <theme_item name="breakpoint_color" type="Color"> + Sets the [Color] of the breakpoints. [member breakpoint_gutter] has to be enabled. </theme_item> <theme_item name="caret_background_color" type="Color"> </theme_item> @@ -553,6 +556,7 @@ <theme_item name="completion_selected_color" type="Color"> </theme_item> <theme_item name="current_line_color" type="Color"> + Sets the [Color] of the breakpoints. [member breakpoint_gutter] has to be enabled. </theme_item> <theme_item name="executing_line_color" type="Color"> </theme_item> @@ -563,38 +567,48 @@ <theme_item name="folded" type="Texture"> </theme_item> <theme_item name="font" type="Font"> + Sets the default [Font]. </theme_item> <theme_item name="font_color" type="Color"> + Sets the font [Color]. </theme_item> <theme_item name="font_color_selected" type="Color"> </theme_item> <theme_item name="function_color" type="Color"> </theme_item> <theme_item name="line_number_color" type="Color"> + Sets the [Color] of the line numbers. [member show_line_numbers] has to be enabled. </theme_item> <theme_item name="line_spacing" type="int"> + Sets the spacing between the lines. </theme_item> <theme_item name="mark_color" type="Color"> + Sets the [Color] of marked text. </theme_item> <theme_item name="member_variable_color" type="Color"> </theme_item> <theme_item name="normal" type="StyleBox"> + Sets the [StyleBox] of this [TextEdit]. </theme_item> <theme_item name="number_color" type="Color"> </theme_item> <theme_item name="read_only" type="StyleBox"> + Sets the [StyleBox] of this [TextEdit] when [member readonly] is enabled. </theme_item> <theme_item name="safe_line_number_color" type="Color"> </theme_item> <theme_item name="selection_color" type="Color"> + Sets the highlight [Color] of text selections. </theme_item> <theme_item name="space" type="Texture"> </theme_item> <theme_item name="symbol_color" type="Color"> </theme_item> <theme_item name="tab" type="Texture"> + Sets a custom [Texture] for tab text characters. </theme_item> <theme_item name="word_highlighted_color" type="Color"> + Sets the highlight [Color] of multiple occurrences. [member highlight_all_occurrences] has to be enabled. </theme_item> </theme_items> </class> diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp index 7d2159d365..041f81d063 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc/doc_data.cpp @@ -1126,6 +1126,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri const PropertyDoc &p = c.theme_properties[i]; _write_string(f, 2, "<theme_item name=\"" + p.name + "\" type=\"" + p.type + "\">"); + _write_string(f, 3, p.description.strip_edges().xml_escape()); _write_string(f, 2, "</theme_item>"); } _write_string(f, 1, "</theme_items>"); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 5e04bf4953..f05a75ed90 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -573,6 +573,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("editors/2d/bone_outline_color", Color(0.35, 0.35, 0.35)); _initial_set("editors/2d/bone_outline_size", 2); _initial_set("editors/2d/viewport_border_color", Color(0.4, 0.4, 1.0, 0.4)); + _initial_set("editors/2d/constrain_editor_view", true); _initial_set("editors/2d/warped_mouse_panning", true); _initial_set("editors/2d/simple_panning", false); _initial_set("editors/2d/scroll_to_pan", false); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 3c24fd19b6..6560a403e5 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -3615,18 +3615,19 @@ void CanvasItemEditor::_update_scrollbars() { // Constraints the view offset and updates the scrollbars Point2 begin = canvas_item_rect.position; Point2 end = canvas_item_rect.position + canvas_item_rect.size - local_rect.size / zoom; + bool constrain_editor_view = bool(EditorSettings::get_singleton()->get("editors/2d/constrain_editor_view")); if (canvas_item_rect.size.height <= (local_rect.size.y / zoom)) { - if (ABS(begin.y - previous_update_view_offset.y) < ABS(begin.y - view_offset.y)) { + if (constrain_editor_view && ABS(begin.y - previous_update_view_offset.y) < ABS(begin.y - view_offset.y)) { view_offset.y = previous_update_view_offset.y; } v_scroll->hide(); } else { - if (view_offset.y > end.y && view_offset.y > previous_update_view_offset.y) { + if (constrain_editor_view && view_offset.y > end.y && view_offset.y > previous_update_view_offset.y) { view_offset.y = MAX(end.y, previous_update_view_offset.y); } - if (view_offset.y < begin.y && view_offset.y < previous_update_view_offset.y) { + if (constrain_editor_view && view_offset.y < begin.y && view_offset.y < previous_update_view_offset.y) { view_offset.y = MIN(begin.y, previous_update_view_offset.y); } @@ -3637,16 +3638,16 @@ void CanvasItemEditor::_update_scrollbars() { } if (canvas_item_rect.size.width <= (local_rect.size.x / zoom)) { - if (ABS(begin.x - previous_update_view_offset.x) < ABS(begin.x - view_offset.x)) { + if (constrain_editor_view && ABS(begin.x - previous_update_view_offset.x) < ABS(begin.x - view_offset.x)) { view_offset.x = previous_update_view_offset.x; } h_scroll->hide(); } else { - if (view_offset.x > end.x && view_offset.x > previous_update_view_offset.x) { + if (constrain_editor_view && view_offset.x > end.x && view_offset.x > previous_update_view_offset.x) { view_offset.x = MAX(end.x, previous_update_view_offset.x); } - if (view_offset.x < begin.x && view_offset.x < previous_update_view_offset.x) { + if (constrain_editor_view && view_offset.x < begin.x && view_offset.x < previous_update_view_offset.x) { view_offset.x = MIN(begin.x, previous_update_view_offset.x); } diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index b6de5dbf62..3eaee53789 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -1241,6 +1241,16 @@ # infinite loop between 0.0 and 0.99 f = wrapf(f + 0.1, 0.0, 1.0) [/codeblock] + [codeblock] + # infinite rotation (in radians) + angle = wrapf(angle + 0.1, 0.0, TAU) + [/codeblock] + Note: If you just want to wrap between 0.0 and [code]n[/code] (where [code]n[/code] is a positive float value) then it's better for performance to use [method fmod] method like [code]fmod(number, n)[/code]. + The usage of [code]wrapf[/code] is more flexible than using the [method fmod] approach by giving the user a simple control over the minimum value. It also fully supports negative numbers, e.g. + [codeblock] + # infinite rotation (in radians) + angle = wrapf(angle + 0.1, -PI, PI) + [/codeblock] </description> </method> <method name="wrapi"> @@ -1267,6 +1277,12 @@ # infinite loop between 0 and 9 frame = wrapi(frame + 1, 0, 10) [/codeblock] + Note: If you just want to wrap between 0 and [code]n[/code] (where [code]n[/code] is a positive integer value) then it's better for performance to use modulo operator like [code]number % n[/code]. + The usage of [code]wrapi[/code] is more flexible than using the modulo approach by giving the user a simple control over the minimum value. It also fully supports negative numbers, e.g. + [codeblock] + # result is -2 + var result = wrapi(-6, -5, -1) + [/codeblock] </description> </method> <method name="yield"> diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index 7ca83320d0..b2064472e4 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/iphone/export/export.cpp @@ -125,7 +125,7 @@ class EditorExportPlatformIOS : public EditorExportPlatform { first = true; continue; } - if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_')) { + if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-')) { if (r_error) { *r_error = vformat(TTR("The character '%s' is not allowed in Identifier."), String::chr(c)); } @@ -137,7 +137,7 @@ class EditorExportPlatformIOS : public EditorExportPlatform { } return false; } - if (first && c == '_') { + if (first && c == '-') { if (r_error) { *r_error = vformat(TTR("The character '%s' cannot be the first character in a Identifier segment."), String::chr(c)); } diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index da6bff8ab8..960499c876 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -650,6 +650,11 @@ void LineEdit::_notification(int p_what) { set_cursor_position(get_cursor_position()); } break; + case NOTIFICATION_TRANSLATION_CHANGED: { + placeholder_translated = tr(placeholder); + update_placeholder_width(); + update(); + } break; case MainLoop::NOTIFICATION_WM_FOCUS_IN: { window_has_focus = true; draw_caret = true; @@ -675,10 +680,8 @@ void LineEdit::_notification(int p_what) { RID ci = get_canvas_item(); Ref<StyleBox> style = get_stylebox("normal"); - float disabled_alpha = 1.0; // used to set the disabled input text color if (!is_editable()) { style = get_stylebox("read_only"); - disabled_alpha = .5; draw_caret = false; } @@ -724,20 +727,19 @@ void LineEdit::_notification(int p_what) { int font_ascent = font->get_ascent(); Color selection_color = get_color("selection_color"); - Color font_color = get_color("font_color"); + Color font_color = is_editable() ? get_color("font_color") : get_color("font_color_uneditable"); Color font_color_selected = get_color("font_color_selected"); Color cursor_color = get_color("cursor_color"); - const String &t = using_placeholder ? placeholder : text; + const String &t = using_placeholder ? placeholder_translated : text; // draw placeholder color if (using_placeholder) font_color.a *= placeholder_alpha; - font_color.a *= disabled_alpha; bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled; if (right_icon.is_valid() || display_clear_icon) { Ref<Texture> r_icon = display_clear_icon ? Control::get_icon("clear") : right_icon; - Color color_icon(1, 1, 1, disabled_alpha * .9); + Color color_icon(1, 1, 1, !is_editable() ? .5 * .9 : .9); if (display_clear_icon) { if (clear_button_status.press_attempt && clear_button_status.pressing_inside) { color_icon = get_color("clear_button_color_pressed"); @@ -1148,16 +1150,9 @@ String LineEdit::get_text() const { void LineEdit::set_placeholder(String p_text) { - placeholder = tr(p_text); - if ((max_length <= 0) || (placeholder.length() <= max_length)) { - Ref<Font> font = get_font("font"); - cached_placeholder_width = 0; - if (font != NULL) { - for (int i = 0; i < placeholder.length(); i++) { - cached_placeholder_width += font->get_char_size(placeholder[i]).width; - } - } - } + placeholder = p_text; + placeholder_translated = tr(placeholder); + update_placeholder_width(); update(); } @@ -1546,6 +1541,18 @@ void LineEdit::_emit_text_change() { text_changed_dirty = false; } +void LineEdit::update_placeholder_width() { + if ((max_length <= 0) || (placeholder_translated.length() <= max_length)) { + Ref<Font> font = get_font("font"); + cached_placeholder_width = 0; + if (font != NULL) { + for (int i = 0; i < placeholder_translated.length(); i++) { + cached_placeholder_width += font->get_char_size(placeholder_translated[i]).width; + } + } + } +} + void LineEdit::_clear_redo() { _create_undo_state(); if (undo_stack_pos == NULL) { diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h index 3b29780dc0..3002f6f637 100644 --- a/scene/gui/line_edit.h +++ b/scene/gui/line_edit.h @@ -72,6 +72,7 @@ private: String undo_text; String text; String placeholder; + String placeholder_translated; String secret_character; float placeholder_alpha; String ime_text; @@ -126,6 +127,8 @@ private: void _emit_text_change(); bool expand_to_text_length; + void update_placeholder_width(); + bool caret_blink_enabled; bool draw_caret; bool window_has_focus; diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 4e86e4bb1e..9d457e989c 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -662,10 +662,8 @@ void TextEdit::_notification(int p_what) { int xmargin_end = size.width - cache.style_normal->get_margin(MARGIN_RIGHT); //let's do it easy for now: cache.style_normal->draw(ci, Rect2(Point2(), size)); - float readonly_alpha = 1.0; // used to set the input text color when in read-only mode if (readonly) { cache.style_readonly->draw(ci, Rect2(Point2(), size)); - readonly_alpha = .5; draw_caret = false; } if (has_focus()) @@ -675,8 +673,7 @@ void TextEdit::_notification(int p_what) { int visible_rows = get_visible_rows() + 1; - Color color = cache.font_color; - color.a *= readonly_alpha; + Color color = readonly ? cache.font_color_readonly : cache.font_color; if (syntax_coloring) { if (cache.background_color.a > 0.01) { @@ -871,10 +868,7 @@ void TextEdit::_notification(int p_what) { color_map = _get_line_syntax_highlighting(line); } // ensure we at least use the font color - Color current_color = cache.font_color; - if (readonly) { - current_color.a *= readonly_alpha; - } + Color current_color = readonly ? cache.font_color_readonly : cache.font_color; bool underlined = false; @@ -1061,10 +1055,7 @@ void TextEdit::_notification(int p_what) { if (syntax_coloring) { if (color_map.has(last_wrap_column + j)) { - current_color = color_map[last_wrap_column + j].color; - if (readonly) { - current_color.a *= readonly_alpha; - } + current_color = readonly ? cache.font_color_readonly : color_map[last_wrap_column + j].color; } color = current_color; } @@ -1252,8 +1243,7 @@ void TextEdit::_notification(int p_what) { if (cursor.column == last_wrap_column + j && cursor.line == line && cursor_wrap_index == line_wrap_index && block_caret && draw_caret && !insert_mode) { color = cache.caret_background_color; } else if (!syntax_coloring && block_caret) { - color = cache.font_color; - color.a *= readonly_alpha; + color = readonly ? cache.font_color_readonly : cache.font_color; } if (str[j] >= 32) { @@ -4555,6 +4545,7 @@ void TextEdit::_update_caches() { cache.safe_line_number_color = get_color("safe_line_number_color"); cache.font_color = get_color("font_color"); cache.font_color_selected = get_color("font_color_selected"); + cache.font_color_readonly = get_color("font_color_readonly"); cache.keyword_color = get_color("keyword_color"); cache.function_color = get_color("function_color"); cache.member_variable_color = get_color("member_variable_color"); diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index c721cf992e..30956ccb23 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -185,6 +185,7 @@ private: Color safe_line_number_color; Color font_color; Color font_color_selected; + Color font_color_readonly; Color keyword_color; Color number_color; Color function_color; diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 2c5dfc375c..4e2fe1f9b2 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -398,6 +398,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_color("font_color", "LineEdit", control_font_color); theme->set_color("font_color_selected", "LineEdit", Color(0, 0, 0)); + theme->set_color("font_color_uneditable", "LineEdit", Color(control_font_color.r, control_font_color.g, control_font_color.b, 0.5f)); theme->set_color("cursor_color", "LineEdit", control_font_color_hover); theme->set_color("selection_color", "LineEdit", font_color_selection); theme->set_color("clear_button_color", "LineEdit", control_font_color); @@ -439,6 +440,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_color("completion_font_color", "TextEdit", Color::html("aaaaaa")); theme->set_color("font_color", "TextEdit", control_font_color); theme->set_color("font_color_selected", "TextEdit", Color(0, 0, 0)); + theme->set_color("font_color_readonly", "TextEdit", Color(control_font_color.r, control_font_color.g, control_font_color.b, 0.5f)); theme->set_color("selection_color", "TextEdit", font_color_selection); theme->set_color("mark_color", "TextEdit", Color(1.0, 0.4, 0.4, 0.4)); theme->set_color("bookmark_color", "TextEdit", Color(0.08, 0.49, 0.98)); |