summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/animation_bezier_editor.cpp44
-rw-r--r--editor/animation_track_editor.cpp41
-rw-r--r--editor/animation_track_editor_plugins.cpp68
-rw-r--r--editor/code_editor.cpp111
-rw-r--r--editor/connections_dialog.cpp4
-rw-r--r--editor/debugger/editor_performance_profiler.cpp25
-rw-r--r--editor/debugger/editor_profiler.cpp10
-rw-r--r--editor/debugger/editor_visual_profiler.cpp21
-rw-r--r--editor/doc_tools.cpp (renamed from editor/doc_data.cpp)214
-rw-r--r--editor/doc_tools.h (renamed from editor/doc_data.h)111
-rw-r--r--editor/editor_about.cpp13
-rw-r--r--editor/editor_audio_buses.cpp39
-rw-r--r--editor/editor_audio_buses.h2
-rw-r--r--editor/editor_export.cpp15
-rw-r--r--editor/editor_file_dialog.cpp23
-rw-r--r--editor/editor_file_system.cpp30
-rw-r--r--editor/editor_fonts.cpp264
-rw-r--r--editor/editor_help.cpp235
-rw-r--r--editor/editor_help.h9
-rw-r--r--editor/editor_inspector.cpp125
-rw-r--r--editor/editor_inspector.h8
-rw-r--r--editor/editor_log.cpp8
-rw-r--r--editor/editor_node.cpp38
-rw-r--r--editor/editor_properties.cpp24
-rw-r--r--editor/editor_settings.cpp30
-rw-r--r--editor/editor_spin_slider.cpp20
-rw-r--r--editor/editor_themes.cpp27
-rw-r--r--editor/filesystem_dock.cpp43
-rw-r--r--editor/find_in_files.cpp7
-rw-r--r--editor/groups_editor.cpp11
-rw-r--r--editor/icons/AutoEndBackwards.svg1
-rw-r--r--editor/icons/AutoPlayBackwards.svg1
-rw-r--r--editor/icons/BitmapFont.svg1
-rw-r--r--editor/icons/DynamicFont.svg1
-rw-r--r--editor/icons/FontData.svg (renamed from editor/icons/DynamicFontData.svg)0
-rw-r--r--editor/icons/GuiResizerMirrored.svg1
-rw-r--r--editor/icons/GuiTabMirrored.svg1
-rw-r--r--editor/icons/GuiToggleOffMirrored.svg1
-rw-r--r--editor/icons/GuiToggleOnMirrored.svg1
-rw-r--r--editor/icons/GuiTreeArrowLeft.svg1
-rw-r--r--editor/import/editor_import_collada.cpp16
-rw-r--r--editor/import/editor_scene_importer_gltf.cpp3
-rw-r--r--editor/import/resource_importer_obj.cpp10
-rw-r--r--editor/import/resource_importer_obj.h1
-rw-r--r--editor/import/resource_importer_scene.cpp4
-rw-r--r--editor/import/resource_importer_scene.h1
-rw-r--r--editor/input_map_editor.cpp111
-rw-r--r--editor/input_map_editor.h2
-rw-r--r--editor/inspector_dock.cpp24
-rw-r--r--editor/localization_editor.cpp71
-rw-r--r--editor/localization_editor.h7
-rw-r--r--editor/node_3d_editor_gizmos.cpp48
-rw-r--r--editor/plugins/abstract_polygon_2d_editor.cpp5
-rw-r--r--editor/plugins/animation_blend_space_1d_editor.cpp3
-rw-r--r--editor/plugins/animation_blend_space_2d_editor.cpp5
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp6
-rw-r--r--editor/plugins/animation_state_machine_editor.cpp21
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp6
-rw-r--r--editor/plugins/asset_library_editor_plugin.h2
-rw-r--r--editor/plugins/audio_stream_editor_plugin.cpp2
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp163
-rw-r--r--editor/plugins/curve_editor_plugin.cpp27
-rw-r--r--editor/plugins/editor_preview_plugins.cpp82
-rw-r--r--editor/plugins/font_editor_plugin.cpp331
-rw-r--r--editor/plugins/font_editor_plugin.h111
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp109
-rw-r--r--editor/plugins/node_3d_editor_plugin.h1
-rw-r--r--editor/plugins/ot_features_plugin.cpp213
-rw-r--r--editor/plugins/ot_features_plugin.h105
-rw-r--r--editor/plugins/script_editor_plugin.cpp99
-rw-r--r--editor/plugins/script_editor_plugin.h3
-rw-r--r--editor/plugins/script_text_editor.cpp9
-rw-r--r--editor/plugins/shader_editor_plugin.cpp3
-rw-r--r--editor/plugins/skeleton_3d_editor_plugin.cpp3
-rw-r--r--editor/plugins/text_editor.cpp3
-rw-r--r--editor/plugins/texture_editor_plugin.cpp11
-rw-r--r--editor/plugins/theme_editor_plugin.cpp56
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp14
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp28
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp162
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h4
-rw-r--r--editor/project_manager.cpp38
-rw-r--r--editor/project_manager.h4
-rw-r--r--editor/property_editor.cpp9
-rw-r--r--editor/property_selector.cpp3
-rw-r--r--editor/scene_tree_dock.cpp9
-rw-r--r--editor/shader_globals_editor.cpp3
87 files changed, 2579 insertions, 1001 deletions
diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp
index 17b03fd479..22adf4f267 100644
--- a/editor/animation_bezier_editor.cpp
+++ b/editor/animation_bezier_editor.cpp
@@ -32,6 +32,7 @@
#include "editor/editor_node.h"
#include "editor_scale.h"
+#include "scene/resources/text_line.h"
float AnimationBezierTrackEdit::_bezier_h_to_pixel(float p_h) {
float h = p_h;
@@ -247,6 +248,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
}
Ref<Font> font = get_theme_font("font", "Label");
+ int font_size = get_theme_font_size("font_size", "Label");
Color color = get_theme_color("font_color", "Label");
int hsep = get_theme_constant("hseparation", "ItemList");
int vsep = get_theme_constant("vseparation", "ItemList");
@@ -286,26 +288,27 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
String text;
- int h = font->get_height();
-
if (node) {
int ofs = 0;
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(node, "Node");
- h = MAX(h, icon->get_height());
+ text = node->get_name();
+ ofs += hsep;
+ ofs += icon->get_width();
+
+ TextLine text_buf = TextLine(text, font, font_size);
+ text_buf.set_width(limit - ofs - hsep);
+
+ int h = MAX(text_buf.get_size().y, icon->get_height());
draw_texture(icon, Point2(ofs, vofs + int(h - icon->get_height()) / 2));
margin = icon->get_width();
- text = node->get_name();
- ofs += hsep;
- ofs += icon->get_width();
-
- Vector2 string_pos = Point2(ofs, vofs + (h - font->get_height()) / 2 + font->get_ascent());
+ Vector2 string_pos = Point2(ofs, vofs + (h - text_buf.get_size().y) / 2 + text_buf.get_line_ascent());
string_pos = string_pos.floor();
- draw_string(font, string_pos, text, color, limit - ofs - hsep);
+ text_buf.draw(get_canvas_item(), string_pos, color);
vofs += h + vsep;
}
@@ -327,7 +330,10 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
path = path.replace_first(base_path, "");
Color cc = color;
- Rect2 rect = Rect2(margin, vofs, limit - margin - hsep, font->get_height() + vsep);
+ TextLine text_buf = TextLine(path, font, font_size);
+ text_buf.set_width(limit - margin - hsep);
+
+ Rect2 rect = Rect2(margin, vofs, limit - margin - hsep, text_buf.get_size().y + vsep);
if (i != track) {
cc.a *= 0.7;
uint32_t hash = path.hash();
@@ -338,7 +344,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
Color subcolor;
subcolor.set_hsv(h, 0.2, 0.8);
subcolor.a = 0.5;
- draw_rect(Rect2(0, vofs + font->get_height() * 0.1, margin - hsep, font->get_height() * 0.8), subcolor);
+ draw_rect(Rect2(0, vofs + text_buf.get_size().y * 0.1, margin - hsep, text_buf.get_size().y * 0.8), subcolor);
subtrack_colors[i] = subcolor;
subtracks[i] = rect;
@@ -347,15 +353,17 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
ac.a = 0.5;
draw_rect(rect, ac);
}
- draw_string(font, Point2(margin, vofs + font->get_ascent()), path, cc, limit - margin - hsep);
- vofs += font->get_height() + vsep;
+ Vector2 string_pos = Point2(margin, vofs + text_buf.get_line_ascent());
+ text_buf.draw(get_canvas_item(), string_pos, cc);
+
+ vofs += text_buf.get_size().y + vsep;
}
Color accent = get_theme_color("accent_color", "Editor");
{ //guides
- float min_left_scale = font->get_height() + vsep;
+ float min_left_scale = font->get_height(font_size) + vsep;
float scale = (min_left_scale * 2) * v_zoom;
float step = Math::pow(10.0, Math::round(Math::log(scale / 5.0) / Math::log(10.0))) * 5.0;
@@ -367,7 +375,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
bool first = true;
int prev_iv = 0;
- for (int i = font->get_height(); i < get_size().height; i++) {
+ for (int i = font->get_height(font_size); i < get_size().height; i++) {
float ofs = get_size().height / 2 - i;
ofs *= v_zoom;
ofs += v_scroll;
@@ -382,7 +390,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
draw_line(Point2(limit, i), Point2(right_limit, i), lc);
Color c = color;
c.a *= 0.5;
- draw_string(font, Point2(limit + 8, i - 2), rtos(Math::stepify((iv + 1) * scale, step)), c);
+ draw_string(font, Point2(limit + 8, i - 2), TS->format_number(rtos(Math::stepify((iv + 1) * scale, step))), HALIGN_LEFT, -1, font_size, c);
}
first = false;
@@ -453,8 +461,8 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
ep.point_rect.size = bezier_icon->get_size();
if (selection.has(i)) {
draw_texture(selected_icon, ep.point_rect.position);
- draw_string(font, ep.point_rect.position + Vector2(8, -font->get_height() - 4), TTR("Time:") + " " + rtos(Math::stepify(offset, 0.001)), accent);
- draw_string(font, ep.point_rect.position + Vector2(8, -8), TTR("Value:") + " " + rtos(Math::stepify(value, 0.001)), accent);
+ draw_string(font, ep.point_rect.position + Vector2(8, -font->get_height(font_size) - 4), TTR("Time:") + " " + TS->format_number(rtos(Math::stepify(offset, 0.001))), HALIGN_LEFT, -1, font_size, accent);
+ draw_string(font, ep.point_rect.position + Vector2(8, -8), TTR("Value:") + " " + TS->format_number(rtos(Math::stepify(value, 0.001))), HALIGN_LEFT, -1, font_size, accent);
} else {
draw_texture(bezier_icon, ep.point_rect.position);
}
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 6f30d5a492..b1ffb1dc52 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -1397,6 +1397,7 @@ void AnimationTimelineEdit::_notification(int p_what) {
}
Ref<Font> font = get_theme_font("font", "Label");
+ int font_size = get_theme_font_size("font_size", "Label");
Color color = get_theme_color("font_color", "Label");
int zoomw = key_range;
@@ -1488,10 +1489,10 @@ void AnimationTimelineEdit::_notification(int p_what) {
int decimals = 2;
bool step_found = false;
- const int period_width = font->get_char_size('.').width;
- int max_digit_width = font->get_char_size('0').width;
+ const int period_width = font->get_char_size('.', 0, font_size).width;
+ int max_digit_width = font->get_char_size('0', 0, font_size).width;
for (int i = 1; i <= 9; i++) {
- const int digit_width = font->get_char_size('0' + i).width;
+ const int digit_width = font->get_char_size('0' + i, 0, font_size).width;
max_digit_width = MAX(digit_width, max_digit_width);
}
const int max_sc = int(Math::ceil(zoomw / scale));
@@ -1538,8 +1539,8 @@ void AnimationTimelineEdit::_notification(int p_what) {
if (frame != prev_frame && i >= prev_frame_ofs) {
draw_line(Point2(get_name_limit() + i, 0), Point2(get_name_limit() + i, h), linecolor, Math::round(EDSCALE));
- draw_string(font, Point2(get_name_limit() + i + 3 * EDSCALE, (h - font->get_height()) / 2 + font->get_ascent()).floor(), itos(frame), sub ? color_time_dec : color_time_sec, zoomw - i);
- prev_frame_ofs = i + font->get_string_size(itos(frame)).x + 5 * EDSCALE;
+ draw_string(font, Point2(get_name_limit() + i + 3 * EDSCALE, (h - font->get_height(font_size)) / 2 + font->get_ascent(font_size)).floor(), itos(frame), HALIGN_LEFT, zoomw - i, font_size, sub ? color_time_dec : color_time_sec);
+ prev_frame_ofs = i + font->get_string_size(itos(frame), font_size).x + 5 * EDSCALE;
}
}
}
@@ -1556,7 +1557,7 @@ void AnimationTimelineEdit::_notification(int p_what) {
if ((sc / step) != (prev_sc / step) || (prev_sc < 0 && sc >= 0)) {
int scd = sc < 0 ? prev_sc : sc;
draw_line(Point2(get_name_limit() + i, 0), Point2(get_name_limit() + i, h), linecolor, Math::round(EDSCALE));
- draw_string(font, Point2(get_name_limit() + i + 3, (h - font->get_height()) / 2 + font->get_ascent()).floor(), String::num((scd - (scd % step)) / double(SC_ADJ), decimals), sub ? color_time_dec : color_time_sec, zoomw - i);
+ draw_string(font, Point2(get_name_limit() + i + 3, (h - font->get_height(font_size)) / 2 + font->get_ascent(font_size)).floor(), String::num((scd - (scd % step)) / double(SC_ADJ), decimals), HALIGN_LEFT, zoomw - i, font_size, sub ? color_time_dec : color_time_sec);
}
}
}
@@ -1583,7 +1584,8 @@ void AnimationTimelineEdit::set_animation(const Ref<Animation> &p_animation) {
Size2 AnimationTimelineEdit::get_minimum_size() const {
Size2 ms = add_track->get_minimum_size();
Ref<Font> font = get_theme_font("font", "Label");
- ms.height = MAX(ms.height, font->get_height());
+ int font_size = get_theme_font_size("font_size", "Label");
+ ms.height = MAX(ms.height, font->get_height(font_size));
ms.width = get_buttons_width() + add_track->get_minimum_size().width + get_theme_icon("Hsize", "EditorIcons")->get_width() + 2;
return ms;
}
@@ -1798,6 +1800,8 @@ AnimationTimelineEdit::AnimationTimelineEdit() {
panning_timeline = false;
dragging_timeline = false;
dragging_hsize = false;
+
+ set_layout_direction(Control::LAYOUT_DIRECTION_LTR);
}
////////////////////////////////////
@@ -1819,6 +1823,7 @@ void AnimationTrackEdit::_notification(int p_what) {
}
Ref<Font> font = get_theme_font("font", "Label");
+ int font_size = get_theme_font_size("font_size", "Label");
Color color = get_theme_color("font_color", "Label");
Ref<Texture2D> type_icons[6] = {
get_theme_icon("KeyValue", "EditorIcons"),
@@ -1890,9 +1895,9 @@ void AnimationTrackEdit::_notification(int p_what) {
path_rect = Rect2(ofs, 0, limit - ofs - hsep, get_size().height);
- Vector2 string_pos = Point2(ofs, (get_size().height - font->get_height()) / 2 + font->get_ascent());
+ Vector2 string_pos = Point2(ofs, (get_size().height - font->get_height(font_size)) / 2 + font->get_ascent(font_size));
string_pos = string_pos.floor();
- draw_string(font, string_pos, text, text_color, limit - ofs - hsep);
+ draw_string(font, string_pos, text, HALIGN_LEFT, limit - ofs - hsep, font_size, text_color);
draw_line(Point2(limit, 0), Point2(limit, get_size().height), linecolor, Math::round(EDSCALE));
}
@@ -2173,6 +2178,7 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool
if (animation->track_get_type(track) == Animation::TYPE_METHOD) {
Ref<Font> font = get_theme_font("font", "Label");
+ int font_size = get_theme_font_size("font_size", "Label");
Color color = get_theme_color("font_color", "Label");
color.a = 0.5;
@@ -2197,7 +2203,7 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool
int limit = MAX(0, p_clip_right - p_x - icon_to_draw->get_width());
if (limit > 0) {
- draw_string(font, Vector2(p_x + icon_to_draw->get_width(), int(get_size().height - font->get_height()) / 2 + font->get_ascent()), text, color, limit);
+ draw_string(font, Vector2(p_x + icon_to_draw->get_width(), int(get_size().height - font->get_height(font_size)) / 2 + font->get_ascent(font_size)), text, HALIGN_LEFT, limit, font_size, color);
}
}
@@ -2302,9 +2308,10 @@ NodePath AnimationTrackEdit::get_path() const {
Size2 AnimationTrackEdit::get_minimum_size() const {
Ref<Texture2D> texture = get_theme_icon("Object", "EditorIcons");
Ref<Font> font = get_theme_font("font", "Label");
+ int font_size = get_theme_font_size("font_size", "Label");
int separation = get_theme_constant("vseparation", "ItemList");
- int max_h = MAX(texture->get_height(), font->get_height());
+ int max_h = MAX(texture->get_height(), font->get_height(font_size));
max_h = MAX(max_h, get_key_height());
return Vector2(1, max_h + separation);
@@ -3036,6 +3043,7 @@ AnimationTrackEdit *AnimationTrackEditPlugin::create_animation_track_edit(Object
void AnimationTrackEditGroup::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
Ref<Font> font = get_theme_font("font", "Label");
+ int font_size = get_theme_font_size("font_size", "Label");
int separation = get_theme_constant("hseparation", "ItemList");
Color color = get_theme_color("font_color", "Label");
@@ -3059,7 +3067,7 @@ void AnimationTrackEditGroup::_notification(int p_what) {
int ofs = 0;
draw_texture(icon, Point2(ofs, int(get_size().height - icon->get_height()) / 2));
ofs += separation + icon->get_width();
- draw_string(font, Point2(ofs, int(get_size().height - font->get_height()) / 2 + font->get_ascent()), node_name, color, timeline->get_name_limit() - ofs);
+ draw_string(font, Point2(ofs, int(get_size().height - font->get_height(font_size)) / 2 + font->get_ascent(font_size)), node_name, HALIGN_LEFT, timeline->get_name_limit() - ofs, font_size, color);
int px = (-timeline->get_value() + timeline->get_play_position()) * timeline->get_zoom_scale() + timeline->get_name_limit();
@@ -3080,9 +3088,10 @@ void AnimationTrackEditGroup::set_type_and_name(const Ref<Texture2D> &p_type, co
Size2 AnimationTrackEditGroup::get_minimum_size() const {
Ref<Font> font = get_theme_font("font", "Label");
+ int font_size = get_theme_font_size("font_size", "Label");
int separation = get_theme_constant("vseparation", "ItemList");
- return Vector2(0, MAX(font->get_height(), icon->get_height()) + separation);
+ return Vector2(0, MAX(font->get_height(font_size), icon->get_height()) + separation);
}
void AnimationTrackEditGroup::set_timeline(AnimationTimelineEdit *p_timeline) {
@@ -5565,6 +5574,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
undo_redo = EditorNode::get_singleton()->get_undo_redo();
main_panel = memnew(PanelContainer);
+ main_panel->set_focus_mode(FOCUS_ALL); // allow panel to have focus so that shortcuts work as expected.
add_child(main_panel);
main_panel->set_v_size_flags(SIZE_EXPAND_FILL);
HBoxContainer *timeline_scroll = memnew(HBoxContainer);
@@ -5698,6 +5708,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
timeline->set_zoom(zoom);
edit = memnew(MenuButton);
+ edit->set_shortcut_context(this);
edit->set_text(TTR("Edit"));
edit->set_flat(false);
edit->set_disabled(true);
@@ -5710,12 +5721,8 @@ AnimationTrackEditor::AnimationTrackEditor() {
edit->get_popup()->add_separator();
edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/duplicate_selection", TTR("Duplicate Selection"), KEY_MASK_CMD | KEY_D), EDIT_DUPLICATE_SELECTION);
edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/duplicate_selection_transposed", TTR("Duplicate Transposed"), KEY_MASK_SHIFT | KEY_MASK_CMD | KEY_D), EDIT_DUPLICATE_TRANSPOSED);
- edit->get_popup()->set_item_shortcut_disabled(edit->get_popup()->get_item_index(EDIT_DUPLICATE_SELECTION), true);
- edit->get_popup()->set_item_shortcut_disabled(edit->get_popup()->get_item_index(EDIT_DUPLICATE_TRANSPOSED), true);
edit->get_popup()->add_separator();
edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/delete_selection", TTR("Delete Selection"), KEY_DELETE), EDIT_DELETE_SELECTION);
- edit->get_popup()->set_item_shortcut_disabled(edit->get_popup()->get_item_index(EDIT_DELETE_SELECTION), true);
- //this shortcut will be checked from the track itself. so no need to enable it here (will conflict with scenetree dock)
edit->get_popup()->add_separator();
edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/goto_next_step", TTR("Go to Next Step"), KEY_MASK_CMD | KEY_RIGHT), EDIT_GOTO_NEXT_STEP);
diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp
index 9fc67000f9..4d96289343 100644
--- a/editor/animation_track_editor_plugins.cpp
+++ b/editor/animation_track_editor_plugins.cpp
@@ -37,6 +37,7 @@
#include "scene/2d/sprite_2d.h"
#include "scene/3d/sprite_3d.h"
#include "scene/animation/animation_player.h"
+#include "scene/resources/text_line.h"
#include "servers/audio/audio_stream.h"
/// BOOL ///
@@ -80,12 +81,14 @@ void AnimationTrackEditBool::draw_key(int p_index, float p_pixels_sec, int p_x,
int AnimationTrackEditColor::get_key_height() const {
Ref<Font> font = get_theme_font("font", "Label");
- return font->get_height() * 0.8;
+ int font_size = get_theme_font_size("font_size", "Label");
+ return font->get_height(font_size) * 0.8;
}
Rect2 AnimationTrackEditColor::get_key_rect(int p_index, float p_pixels_sec) {
Ref<Font> font = get_theme_font("font", "Label");
- int fh = font->get_height() * 0.8;
+ int font_size = get_theme_font_size("font_size", "Label");
+ int fh = font->get_height(font_size) * 0.8;
return Rect2(-fh / 2, 0, fh, get_size().height);
}
@@ -95,7 +98,8 @@ bool AnimationTrackEditColor::is_key_selectable_by_distance() const {
void AnimationTrackEditColor::draw_key_link(int p_index, float p_pixels_sec, int p_x, int p_next_x, int p_clip_left, int p_clip_right) {
Ref<Font> font = get_theme_font("font", "Label");
- int fh = (font->get_height() * 0.8);
+ int font_size = get_theme_font_size("font_size", "Label");
+ int fh = (font->get_height(font_size) * 0.8);
int x_from = p_x + fh / 2 - 1;
int x_to = p_next_x - fh / 2 + 1;
@@ -144,7 +148,8 @@ void AnimationTrackEditColor::draw_key(int p_index, float p_pixels_sec, int p_x,
Color color = get_animation()->track_get_key_value(get_track(), p_index);
Ref<Font> font = get_theme_font("font", "Label");
- int fh = font->get_height() * 0.8;
+ int font_size = get_theme_font_size("font_size", "Label");
+ int fh = font->get_height(font_size) * 0.8;
Rect2 rect(Vector2(p_x - fh / 2, int(get_size().height - fh) / 2), Size2(fh, fh));
@@ -182,7 +187,8 @@ int AnimationTrackEditAudio::get_key_height() const {
}
Ref<Font> font = get_theme_font("font", "Label");
- return int(font->get_height() * 1.5);
+ int font_size = get_theme_font_size("font_size", "Label");
+ return int(font->get_height(font_size) * 1.5);
}
Rect2 AnimationTrackEditAudio::get_key_rect(int p_index, float p_pixels_sec) {
@@ -214,7 +220,8 @@ Rect2 AnimationTrackEditAudio::get_key_rect(int p_index, float p_pixels_sec) {
return Rect2(0, 0, len * p_pixels_sec, get_size().height);
} else {
Ref<Font> font = get_theme_font("font", "Label");
- int fh = font->get_height() * 0.8;
+ int font_size = get_theme_font_size("font_size", "Label");
+ int fh = font->get_height(font_size) * 0.8;
return Rect2(0, 0, fh, get_size().height);
}
}
@@ -277,7 +284,8 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x,
}
Ref<Font> font = get_theme_font("font", "Label");
- float fh = int(font->get_height() * 1.5);
+ int font_size = get_theme_font_size("font_size", "Label");
+ float fh = int(font->get_height(font_size) * 1.5);
Rect2 rect = Rect2(from_x, (get_size().height - fh) / 2, to_x - from_x, fh);
draw_rect(rect, Color(0.25, 0.25, 0.25));
@@ -307,7 +315,8 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x,
}
} else {
Ref<Font> font = get_theme_font("font", "Label");
- int fh = font->get_height() * 0.8;
+ int font_size = get_theme_font_size("font_size", "Label");
+ int fh = font->get_height(font_size) * 0.8;
Rect2 rect(Vector2(p_x, int(get_size().height - fh) / 2), Size2(fh, fh));
Color color = get_theme_color("font_color", "Label");
@@ -339,7 +348,8 @@ int AnimationTrackEditSpriteFrame::get_key_height() const {
}
Ref<Font> font = get_theme_font("font", "Label");
- return int(font->get_height() * 2);
+ int font_size = get_theme_font_size("font_size", "Label");
+ return int(font->get_height(font_size) * 2);
}
Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_sec) {
@@ -406,7 +416,8 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se
size = size.floor();
Ref<Font> font = get_theme_font("font", "Label");
- int height = int(font->get_height() * 2);
+ int font_size = get_theme_font_size("font_size", "Label");
+ int height = int(font->get_height(font_size) * 2);
int width = height * size.width / size.height;
return Rect2(0, 0, width, get_size().height);
@@ -496,7 +507,8 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
}
Ref<Font> font = get_theme_font("font", "Label");
- int height = int(font->get_height() * 2);
+ int font_size = get_theme_font_size("font_size", "Label");
+ int height = int(font->get_height(font_size) * 2);
int width = height * region.size.width / region.size.height;
@@ -539,7 +551,8 @@ int AnimationTrackEditSubAnim::get_key_height() const {
}
Ref<Font> font = get_theme_font("font", "Label");
- return int(font->get_height() * 1.5);
+ int font_size = get_theme_font_size("font_size", "Label");
+ return int(font->get_height(font_size) * 1.5);
}
Rect2 AnimationTrackEditSubAnim::get_key_rect(int p_index, float p_pixels_sec) {
@@ -567,7 +580,8 @@ Rect2 AnimationTrackEditSubAnim::get_key_rect(int p_index, float p_pixels_sec) {
return Rect2(0, 0, len * p_pixels_sec, get_size().height);
} else {
Ref<Font> font = get_theme_font("font", "Label");
- int fh = font->get_height() * 0.8;
+ int font_size = get_theme_font_size("font_size", "Label");
+ int fh = font->get_height(font_size) * 0.8;
return Rect2(0, 0, fh, get_size().height);
}
}
@@ -621,7 +635,8 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_
}
Ref<Font> font = get_theme_font("font", "Label");
- int fh = font->get_height() * 1.5;
+ int font_size = get_theme_font_size("font_size", "Label");
+ int fh = font->get_height(font_size) * 1.5;
Rect2 rect(from_x, int(get_size().height - fh) / 2, to_x - from_x, fh);
@@ -664,7 +679,7 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_
int limit = to_x - from_x - 4;
if (limit > 0) {
- draw_string(font, Point2(from_x + 2, int(get_size().height - font->get_height()) / 2 + font->get_ascent()), anim, color);
+ draw_string(font, Point2(from_x + 2, int(get_size().height - font->get_height(font_size)) / 2 + font->get_ascent(font_size)), anim, HALIGN_LEFT, -1, font_size, color);
}
if (p_selected) {
@@ -673,7 +688,8 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_
}
} else {
Ref<Font> font = get_theme_font("font", "Label");
- int fh = font->get_height() * 0.8;
+ int font_size = get_theme_font_size("font_size", "Label");
+ int fh = font->get_height(font_size) * 0.8;
Rect2 rect(Vector2(p_x, int(get_size().height - fh) / 2), Size2(fh, fh));
Color color = get_theme_color("font_color", "Label");
@@ -771,7 +787,8 @@ void AnimationTrackEditTypeAudio::_preview_changed(ObjectID p_which) {
int AnimationTrackEditTypeAudio::get_key_height() const {
Ref<Font> font = get_theme_font("font", "Label");
- return int(font->get_height() * 1.5);
+ int font_size = get_theme_font_size("font_size", "Label");
+ return int(font->get_height(font_size) * 1.5);
}
Rect2 AnimationTrackEditTypeAudio::get_key_rect(int p_index, float p_pixels_sec) {
@@ -835,7 +852,8 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int
}
Ref<Font> font = get_theme_font("font", "Label");
- float fh = int(font->get_height() * 1.5);
+ int font_size = get_theme_font_size("font_size", "Label");
+ float fh = int(font->get_height(font_size) * 1.5);
float len = stream->get_length();
@@ -1104,7 +1122,8 @@ int AnimationTrackEditTypeAnimation::get_key_height() const {
}
Ref<Font> font = get_theme_font("font", "Label");
- return int(font->get_height() * 1.5);
+ int font_size = get_theme_font_size("font_size", "Label");
+ return int(font->get_height(font_size) * 1.5);
}
Rect2 AnimationTrackEditTypeAnimation::get_key_rect(int p_index, float p_pixels_sec) {
@@ -1132,7 +1151,8 @@ Rect2 AnimationTrackEditTypeAnimation::get_key_rect(int p_index, float p_pixels_
return Rect2(0, 0, len * p_pixels_sec, get_size().height);
} else {
Ref<Font> font = get_theme_font("font", "Label");
- int fh = font->get_height() * 0.8;
+ int font_size = get_theme_font_size("font_size", "Label");
+ int fh = font->get_height(font_size) * 0.8;
return Rect2(0, 0, fh, get_size().height);
}
}
@@ -1186,7 +1206,8 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec,
}
Ref<Font> font = get_theme_font("font", "Label");
- int fh = font->get_height() * 1.5;
+ int font_size = get_theme_font_size("font_size", "Label");
+ int fh = font->get_height(font_size) * 1.5;
Rect2 rect(from_x, int(get_size().height - fh) / 2, to_x - from_x, fh);
@@ -1229,7 +1250,7 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec,
int limit = to_x - from_x - 4;
if (limit > 0) {
- draw_string(font, Point2(from_x + 2, int(get_size().height - font->get_height()) / 2 + font->get_ascent()), anim, color);
+ draw_string(font, Point2(from_x + 2, int(get_size().height - font->get_height(font_size)) / 2 + font->get_ascent(font_size)), anim, HALIGN_LEFT, -1, font_size, color);
}
if (p_selected) {
@@ -1238,7 +1259,8 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec,
}
} else {
Ref<Font> font = get_theme_font("font", "Label");
- int fh = font->get_height() * 0.8;
+ int font_size = get_theme_font_size("font_size", "Label");
+ int fh = font->get_height(font_size) * 0.8;
Rect2 rect(Vector2(p_x, int(get_size().height - fh) / 2), Size2(fh, fh));
Color color = get_theme_color("font_color", "Label");
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 3182bca0eb..823fd7e852 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -38,7 +38,7 @@
#include "editor_settings.h"
#include "scene/gui/margin_container.h"
#include "scene/gui/separator.h"
-#include "scene/resources/dynamic_font.h"
+#include "scene/resources/font.h"
void GotoLineDialog::popup_find_line(CodeEdit *p_edit) {
text_editor = p_edit;
@@ -731,17 +731,10 @@ void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMagnifyGesture> magnify_gesture = p_event;
if (magnify_gesture.is_valid()) {
- Ref<DynamicFont> font = text_editor->get_theme_font("font");
+ font_size = text_editor->get_theme_font_size("font_size");
+ font_size *= powf(magnify_gesture->get_factor(), 0.25);
- if (font.is_valid()) {
- if (font->get_size() != (int)font_size) {
- font_size = font->get_size();
- }
-
- font_size *= powf(magnify_gesture->get_factor(), 0.25);
-
- _add_font_size((int)font_size - font->get_size());
- }
+ _add_font_size((int)font_size - text_editor->get_theme_font_size("font_size"));
return;
}
@@ -779,12 +772,8 @@ void CodeTextEditor::_zoom_changed() {
}
void CodeTextEditor::_reset_zoom() {
- Ref<DynamicFont> font = text_editor->get_theme_font("font"); // Reset source font size to default.
-
- if (font.is_valid()) {
- EditorSettings::get_singleton()->set("interface/editor/code_font_size", 14);
- font->set_size(14);
- }
+ EditorSettings::get_singleton()->set("interface/editor/code_font_size", 14);
+ text_editor->add_theme_font_size_override("font_size", 14 * EDSCALE);
}
void CodeTextEditor::_line_col_changed() {
@@ -900,20 +889,15 @@ void CodeTextEditor::_font_resize_timeout() {
}
bool CodeTextEditor::_add_font_size(int p_delta) {
- Ref<DynamicFont> font = text_editor->get_theme_font("font");
+ int old_size = text_editor->get_theme_font_size("font_size");
+ int new_size = CLAMP(old_size + p_delta, 8 * EDSCALE, 96 * EDSCALE);
- if (font.is_valid()) {
- int new_size = CLAMP(font->get_size() + p_delta, 8 * EDSCALE, 96 * EDSCALE);
-
- if (new_size != font->get_size()) {
- EditorSettings::get_singleton()->set("interface/editor/code_font_size", new_size / EDSCALE);
- font->set_size(new_size);
- }
-
- return true;
- } else {
- return false;
+ if (new_size != old_size) {
+ EditorSettings::get_singleton()->set("interface/editor/code_font_size", new_size / EDSCALE);
+ text_editor->add_theme_font_size_override("font_size", new_size);
}
+
+ return true;
}
void CodeTextEditor::update_editor_settings() {
@@ -1486,17 +1470,22 @@ void CodeTextEditor::goto_error() {
void CodeTextEditor::_update_font() {
text_editor->add_theme_font_override("font", get_theme_font("source", "EditorFonts"));
+ text_editor->add_theme_font_size_override("font_size", get_theme_font_size("source_size", "EditorFonts"));
error->add_theme_font_override("font", get_theme_font("status_source", "EditorFonts"));
+ error->add_theme_font_size_override("font_size", get_theme_font_size("status_source_size", "EditorFonts"));
error->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
Ref<Font> status_bar_font = get_theme_font("status_source", "EditorFonts");
+ int status_bar_font_size = get_theme_font_size("status_source_size", "EditorFonts");
error->add_theme_font_override("font", status_bar_font);
+ error->add_theme_font_size_override("font_size", status_bar_font_size);
int count = status_bar->get_child_count();
for (int i = 0; i < count; i++) {
Control *n = Object::cast_to<Control>(status_bar->get_child(i));
if (n) {
n->add_theme_font_override("font", status_bar_font);
+ n->add_theme_font_size_override("font_size", status_bar_font_size);
}
}
}
@@ -1506,6 +1495,31 @@ void CodeTextEditor::_on_settings_change() {
font_size = EditorSettings::get_singleton()->get("interface/editor/code_font_size");
+ int ot_mode = EditorSettings::get_singleton()->get("interface/editor/code_font_contextual_ligatures");
+ switch (ot_mode) {
+ case 1: { // Disable ligatures.
+ text_editor->clear_opentype_features();
+ text_editor->set_opentype_feature("calt", 0);
+ } break;
+ case 2: { // Custom.
+ text_editor->clear_opentype_features();
+ Vector<String> subtag = String(EditorSettings::get_singleton()->get("interface/editor/code_font_custom_opentype_features")).split(",");
+ Dictionary ftrs;
+ for (int i = 0; i < subtag.size(); i++) {
+ Vector<String> subtag_a = subtag[i].split("=");
+ if (subtag_a.size() == 2) {
+ text_editor->set_opentype_feature(subtag_a[0], subtag_a[1].to_int());
+ } else if (subtag_a.size() == 1) {
+ text_editor->set_opentype_feature(subtag_a[0], 1);
+ }
+ }
+ } break;
+ default: { // Default.
+ text_editor->clear_opentype_features();
+ text_editor->set_opentype_feature("calt", 1);
+ } break;
+ }
+
// Auto brace completion.
text_editor->set_auto_brace_completion(
EDITOR_GET("text_editor/completion/auto_brace_complete"));
@@ -1547,7 +1561,11 @@ void CodeTextEditor::_set_show_warnings_panel(bool p_show) {
}
void CodeTextEditor::_toggle_scripts_pressed() {
- toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->toggle_scripts_panel() ? get_theme_icon("Back", "EditorIcons") : get_theme_icon("Forward", "EditorIcons"));
+ if (is_layout_rtl()) {
+ toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->toggle_scripts_panel() ? get_theme_icon("Forward", "EditorIcons") : get_theme_icon("Back", "EditorIcons"));
+ } else {
+ toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->toggle_scripts_panel() ? get_theme_icon("Back", "EditorIcons") : get_theme_icon("Forward", "EditorIcons"));
+ }
}
void CodeTextEditor::_error_pressed(const Ref<InputEvent> &p_event) {
@@ -1668,7 +1686,11 @@ void CodeTextEditor::show_toggle_scripts_button() {
}
void CodeTextEditor::update_toggle_scripts_button() {
- toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? get_theme_icon("Back", "EditorIcons") : get_theme_icon("Forward", "EditorIcons"));
+ if (is_layout_rtl()) {
+ toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? get_theme_icon("Forward", "EditorIcons") : get_theme_icon("Back", "EditorIcons"));
+ } else {
+ toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? get_theme_icon("Back", "EditorIcons") : get_theme_icon("Forward", "EditorIcons"));
+ }
toggle_scripts_button->set_tooltip(TTR("Toggle Scripts Panel") + " (" + ED_GET_SHORTCUT("script_editor/toggle_scripts_panel")->get_as_text() + ")");
}
@@ -1682,6 +1704,31 @@ CodeTextEditor::CodeTextEditor() {
add_child(text_editor);
text_editor->set_v_size_flags(SIZE_EXPAND_FILL);
+ int ot_mode = EditorSettings::get_singleton()->get("interface/editor/code_font_contextual_ligatures");
+ switch (ot_mode) {
+ case 1: { // Disable ligatures.
+ text_editor->clear_opentype_features();
+ text_editor->set_opentype_feature("calt", 0);
+ } break;
+ case 2: { // Custom.
+ text_editor->clear_opentype_features();
+ Vector<String> subtag = String(EditorSettings::get_singleton()->get("interface/editor/code_font_custom_opentype_features")).split(",");
+ Dictionary ftrs;
+ for (int i = 0; i < subtag.size(); i++) {
+ Vector<String> subtag_a = subtag[i].split("=");
+ if (subtag_a.size() == 2) {
+ text_editor->set_opentype_feature(subtag_a[0], subtag_a[1].to_int());
+ } else if (subtag_a.size() == 1) {
+ text_editor->set_opentype_feature(subtag_a[0], 1);
+ }
+ }
+ } break;
+ default: { // Default.
+ text_editor->clear_opentype_features();
+ text_editor->set_opentype_feature("calt", 1);
+ } break;
+ }
+
// Added second so it opens at the bottom, so it won't shift the entire text editor when opening.
find_replace_bar = memnew(FindReplaceBar);
add_child(find_replace_bar);
@@ -1750,6 +1797,7 @@ CodeTextEditor::CodeTextEditor() {
warning_count_label->set_tooltip(TTR("Warnings"));
warning_count_label->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("warning_color", "Editor"));
warning_count_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts"));
+ warning_count_label->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("status_source_size", "EditorFonts"));
warning_count_label->connect("gui_input", callable_mp(this, &CodeTextEditor::_warning_label_gui_input));
is_warnings_panel_opened = false;
@@ -1760,6 +1808,7 @@ CodeTextEditor::CodeTextEditor() {
status_bar->add_child(line_and_col_txt);
line_and_col_txt->set_v_size_flags(SIZE_EXPAND | SIZE_SHRINK_CENTER);
line_and_col_txt->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts"));
+ line_and_col_txt->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("status_source_size", "EditorFonts"));
line_and_col_txt->set_tooltip(TTR("Line and column numbers."));
line_and_col_txt->set_mouse_filter(MOUSE_FILTER_STOP);
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp
index 320e5d8510..2630589912 100644
--- a/editor/connections_dialog.cpp
+++ b/editor/connections_dialog.cpp
@@ -31,6 +31,7 @@
#include "connections_dialog.h"
#include "core/string/print_string.h"
+#include "editor/doc_tools.h"
#include "editor_node.h"
#include "editor_scale.h"
#include "editor_settings.h"
@@ -410,6 +411,7 @@ ConnectDialog::ConnectDialog() {
tree = memnew(SceneTreeEditor(false));
tree->set_connecting_signal(true);
+ tree->set_show_enabled_subscene(true);
tree->get_scene_tree()->connect("item_activated", callable_mp(this, &ConnectDialog::_item_activated));
tree->connect("node_selected", callable_mp(this, &ConnectDialog::_tree_node_selected));
tree->set_connect_to_script_mode(true);
@@ -997,7 +999,7 @@ void ConnectionsDock::update_tree() {
}
if (!found) {
- DocData *dd = EditorHelp::get_doc_data();
+ DocTools *dd = EditorHelp::get_doc_data();
Map<String, DocData::ClassDoc>::Element *F = dd->class_list.find(base);
while (F && descr == String()) {
for (int i = 0; i < F->get().signals.size(); i++) {
diff --git a/editor/debugger/editor_performance_profiler.cpp b/editor/debugger/editor_performance_profiler.cpp
index 47fe282758..44c5f83e9a 100644
--- a/editor/debugger/editor_performance_profiler.cpp
+++ b/editor/debugger/editor_performance_profiler.cpp
@@ -82,10 +82,10 @@ String EditorPerformanceProfiler::_create_label(float p_value, Performance::Moni
return String::humanize_size(p_value);
}
case Performance::MONITOR_TYPE_TIME: {
- return rtos(p_value * 1000).pad_decimals(2) + " ms";
+ return TS->format_number(rtos(p_value * 1000).pad_decimals(2)) + " " + RTR("ms");
}
default: {
- return rtos(p_value);
+ return TS->format_number(rtos(p_value));
}
}
}
@@ -111,6 +111,7 @@ void EditorPerformanceProfiler::_monitor_draw() {
Ref<StyleBox> graph_style_box = get_theme_stylebox("normal", "TextEdit");
Ref<Font> graph_font = get_theme_font("font", "TextEdit");
+ int font_size = get_theme_font_size("font_size", "TextEdit");
int columns = int(Math::ceil(Math::sqrt(float(active.size()))));
int rows = int(Math::ceil(float(active.size()) / float(columns)));
@@ -131,19 +132,19 @@ void EditorPerformanceProfiler::_monitor_draw() {
rect.size -= graph_style_box->get_minimum_size();
Color draw_color = get_theme_color("accent_color", "Editor");
draw_color.set_hsv(Math::fmod(hue_shift * float(current.frame_index), 0.9f), draw_color.get_s() * 0.9f, draw_color.get_v() * value_multiplier, 0.6f);
- monitor_draw->draw_string(graph_font, rect.position + Point2(0, graph_font->get_ascent()), current.item->get_text(0), draw_color, rect.size.x);
+ monitor_draw->draw_string(graph_font, rect.position + Point2(0, graph_font->get_ascent(font_size)), current.item->get_text(0), HALIGN_LEFT, rect.size.x, font_size, draw_color);
draw_color.a = 0.9f;
- float value_position = rect.size.width - graph_font->get_string_size(current.item->get_text(1)).width;
+ float value_position = rect.size.width - graph_font->get_string_size(current.item->get_text(1), font_size).width;
if (value_position < 0) {
value_position = 0;
}
- monitor_draw->draw_string(graph_font, rect.position + Point2(value_position, graph_font->get_ascent()), current.item->get_text(1), draw_color, rect.size.x);
+ monitor_draw->draw_string(graph_font, rect.position + Point2(value_position, graph_font->get_ascent(font_size)), current.item->get_text(1), HALIGN_LEFT, rect.size.x, font_size, draw_color);
- rect.position.y += graph_font->get_height();
- rect.size.height -= graph_font->get_height();
+ rect.position.y += graph_font->get_height(font_size);
+ rect.size.height -= graph_font->get_height(font_size);
- int line_count = rect.size.height / (graph_font->get_height() * 2);
+ int line_count = rect.size.height / (graph_font->get_height(font_size) * 2);
if (line_count > 5) {
line_count = 5;
}
@@ -151,12 +152,12 @@ void EditorPerformanceProfiler::_monitor_draw() {
Color horizontal_line_color;
horizontal_line_color.set_hsv(draw_color.get_h(), draw_color.get_s() * 0.5f, draw_color.get_v() * 0.5f, 0.3f);
monitor_draw->draw_line(rect.position, rect.position + Vector2(rect.size.width, 0), horizontal_line_color, Math::round(EDSCALE));
- monitor_draw->draw_string(graph_font, rect.position + Vector2(0, graph_font->get_ascent()), _create_label(current.max, current.type), horizontal_line_color, rect.size.width);
+ monitor_draw->draw_string(graph_font, rect.position + Vector2(0, graph_font->get_ascent(font_size)), _create_label(current.max, current.type), HALIGN_LEFT, rect.size.width, font_size, horizontal_line_color);
for (int j = 0; j < line_count; j++) {
Vector2 y_offset = Vector2(0, rect.size.height * (1.0f - float(j) / float(line_count)));
monitor_draw->draw_line(rect.position + y_offset, rect.position + Vector2(rect.size.width, 0) + y_offset, horizontal_line_color, Math::round(EDSCALE));
- monitor_draw->draw_string(graph_font, rect.position - Vector2(0, graph_font->get_descent()) + y_offset, _create_label(current.max * float(j) / float(line_count), current.type), horizontal_line_color, rect.size.width);
+ monitor_draw->draw_string(graph_font, rect.position - Vector2(0, graph_font->get_descent(font_size)) + y_offset, _create_label(current.max * float(j) / float(line_count), current.type), HALIGN_LEFT, rect.size.width, font_size, horizontal_line_color);
}
}
@@ -182,7 +183,7 @@ void EditorPerformanceProfiler::_monitor_draw() {
monitor_draw->draw_line(rect.position + Point2(from, 0), rect.position + Point2(from, rect.size.y), line_color, Math::round(EDSCALE));
String label = _create_label(e->get(), current.type);
- Size2 size = graph_font->get_string_size(label);
+ Size2 size = graph_font->get_string_size(label, font_size);
Vector2 text_top_left_position = Vector2(from, h2) - (size + Vector2(MARKER_MARGIN, MARKER_MARGIN));
if (text_top_left_position.x < 0) {
text_top_left_position.x = from + MARKER_MARGIN;
@@ -190,7 +191,7 @@ void EditorPerformanceProfiler::_monitor_draw() {
if (text_top_left_position.y < 0) {
text_top_left_position.y = h2 + MARKER_MARGIN;
}
- monitor_draw->draw_string(graph_font, rect.position + text_top_left_position + Point2(0, graph_font->get_ascent()), label, line_color, rect.size.x);
+ monitor_draw->draw_string(graph_font, rect.position + text_top_left_position + Point2(0, graph_font->get_ascent(font_size)), label, HALIGN_LEFT, rect.size.x, font_size, line_color);
}
prev = h2;
e = e->next();
diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp
index 8bd21fff5c..930aca6e5a 100644
--- a/editor/debugger/editor_profiler.cpp
+++ b/editor/debugger/editor_profiler.cpp
@@ -103,19 +103,19 @@ static String _get_percent_txt(float p_value, float p_total) {
p_total = 0.00001;
}
- return String::num((p_value / p_total) * 100, 1) + "%";
+ return TS->format_number(String::num((p_value / p_total) * 100, 1)) + TS->percent_sign();
}
String EditorProfiler::_get_time_as_text(const Metric &m, float p_time, int p_calls) {
const int dmode = display_mode->get_selected();
if (dmode == DISPLAY_FRAME_TIME) {
- return rtos(p_time * 1000).pad_decimals(2) + " ms";
+ return TS->format_number(rtos(p_time * 1000).pad_decimals(2)) + " " + RTR("ms");
} else if (dmode == DISPLAY_AVERAGE_TIME) {
if (p_calls == 0) {
- return "0.00 ms";
+ return TS->format_number("0.00") + " " + RTR("ms");
} else {
- return rtos((p_time / p_calls) * 1000).pad_decimals(2) + " ms";
+ return TS->format_number(rtos((p_time / p_calls) * 1000).pad_decimals(2)) + " " + RTR("ms");
}
} else if (dmode == DISPLAY_FRAME_PERCENT) {
return _get_percent_txt(p_time, m.frame_time);
@@ -423,7 +423,7 @@ void EditorProfiler::_clear_pressed() {
}
void EditorProfiler::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) {
activate->set_icon(get_theme_icon("Play", "EditorIcons"));
clear_button->set_icon(get_theme_icon("Clear", "EditorIcons"));
}
diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp
index baeb06794a..d7a09d6b0c 100644
--- a/editor/debugger/editor_visual_profiler.cpp
+++ b/editor/debugger/editor_visual_profiler.cpp
@@ -114,9 +114,9 @@ String EditorVisualProfiler::_get_time_as_text(float p_time) {
int dmode = display_mode->get_selected();
if (dmode == DISPLAY_FRAME_TIME) {
- return rtos(p_time) + "ms";
+ return TS->format_number(rtos(p_time)) + " " + RTR("ms");
} else if (dmode == DISPLAY_FRAME_PERCENT) {
- return String::num(p_time * 100 / graph_limit, 2) + "%";
+ return TS->format_number(String::num(p_time * 100 / graph_limit, 2)) + " " + TS->percent_sign();
}
return "err";
@@ -423,8 +423,12 @@ void EditorVisualProfiler::_clear_pressed() {
}
void EditorVisualProfiler::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
- activate->set_icon(get_theme_icon("Play", "EditorIcons"));
+ if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) {
+ if (is_layout_rtl()) {
+ activate->set_icon(get_theme_icon("PlayBackwards", "EditorIcons"));
+ } else {
+ activate->set_icon(get_theme_icon("Play", "EditorIcons"));
+ }
clear_button->set_icon(get_theme_icon("Clear", "EditorIcons"));
}
}
@@ -434,6 +438,7 @@ void EditorVisualProfiler::_graph_tex_draw() {
return;
}
Ref<Font> font = get_theme_font("font", "Label");
+ int font_size = get_theme_font_size("font_size", "Label");
if (seeking) {
int max_frames = frame_metrics.size();
int frame = cursor_metric_edit->get_value() - (frame_metrics[last_metric].frame_number - max_frames + 1);
@@ -457,7 +462,7 @@ void EditorVisualProfiler::_graph_tex_draw() {
graph->draw_line(Vector2(0, frame_y), Vector2(half_width, frame_y), Color(1, 1, 1, 0.3));
String limit_str = String::num(graph_limit, 2);
- graph->draw_string(font, Vector2(half_width - font->get_string_size(limit_str).x - 2, frame_y - 2), limit_str, Color(1, 1, 1, 0.6));
+ graph->draw_string(font, Vector2(half_width - font->get_string_size(limit_str, font_size).x - 2, frame_y - 2), limit_str, HALIGN_LEFT, -1, font_size, Color(1, 1, 1, 0.6));
}
if (graph_height_gpu > 0) {
@@ -468,11 +473,11 @@ void EditorVisualProfiler::_graph_tex_draw() {
graph->draw_line(Vector2(half_width, frame_y), Vector2(graph->get_size().x, frame_y), Color(1, 1, 1, 0.3));
String limit_str = String::num(graph_limit, 2);
- graph->draw_string(font, Vector2(half_width * 2 - font->get_string_size(limit_str).x - 2, frame_y - 2), limit_str, Color(1, 1, 1, 0.6));
+ graph->draw_string(font, Vector2(half_width * 2 - font->get_string_size(limit_str, font_size).x - 2, frame_y - 2), limit_str, HALIGN_LEFT, -1, font_size, Color(1, 1, 1, 0.6));
}
- graph->draw_string(font, Vector2(font->get_string_size("X").x, font->get_ascent() + 2), "CPU:", Color(1, 1, 1, 0.8));
- graph->draw_string(font, Vector2(font->get_string_size("X").x + graph->get_size().width / 2, font->get_ascent() + 2), "GPU:", Color(1, 1, 1, 0.8));
+ graph->draw_string(font, Vector2(font->get_string_size("X", font_size).x, font->get_ascent(font_size) + 2), "CPU:", HALIGN_LEFT, -1, font_size, Color(1, 1, 1, 0.8));
+ graph->draw_string(font, Vector2(font->get_string_size("X", font_size).x + graph->get_size().width / 2, font->get_ascent(font_size) + 2), "GPU:", HALIGN_LEFT, -1, font_size, Color(1, 1, 1, 0.8));
/*
if (hover_metric != -1 && frame_metrics[hover_metric].valid) {
diff --git a/editor/doc_data.cpp b/editor/doc_tools.cpp
index 8504d61d2f..5ee9abb183 100644
--- a/editor/doc_data.cpp
+++ b/editor/doc_tools.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* doc_data.cpp */
+/* doc_tools.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "doc_data.h"
+#include "doc_tools.h"
#include "core/config/engine.h"
#include "core/config/project_settings.h"
@@ -43,22 +43,22 @@
// Used for a hack preserving Mono properties on non-Mono builds.
#include "modules/modules_enabled.gen.h"
-void DocData::merge_from(const DocData &p_data) {
- for (Map<String, ClassDoc>::Element *E = class_list.front(); E; E = E->next()) {
- ClassDoc &c = E->get();
+void DocTools::merge_from(const DocTools &p_data) {
+ for (Map<String, DocData::ClassDoc>::Element *E = class_list.front(); E; E = E->next()) {
+ DocData::ClassDoc &c = E->get();
if (!p_data.class_list.has(c.name)) {
continue;
}
- const ClassDoc &cf = p_data.class_list[c.name];
+ const DocData::ClassDoc &cf = p_data.class_list[c.name];
c.description = cf.description;
c.brief_description = cf.brief_description;
c.tutorials = cf.tutorials;
for (int i = 0; i < c.methods.size(); i++) {
- MethodDoc &m = c.methods.write[i];
+ DocData::MethodDoc &m = c.methods.write[i];
for (int j = 0; j < cf.methods.size(); j++) {
if (cf.methods[j].name != m.name) {
@@ -95,7 +95,7 @@ void DocData::merge_from(const DocData &p_data) {
continue;
}
- const MethodDoc &mf = cf.methods[j];
+ const DocData::MethodDoc &mf = cf.methods[j];
m.description = mf.description;
break;
@@ -103,13 +103,13 @@ void DocData::merge_from(const DocData &p_data) {
}
for (int i = 0; i < c.signals.size(); i++) {
- MethodDoc &m = c.signals.write[i];
+ DocData::MethodDoc &m = c.signals.write[i];
for (int j = 0; j < cf.signals.size(); j++) {
if (cf.signals[j].name != m.name) {
continue;
}
- const MethodDoc &mf = cf.signals[j];
+ const DocData::MethodDoc &mf = cf.signals[j];
m.description = mf.description;
break;
@@ -117,13 +117,13 @@ void DocData::merge_from(const DocData &p_data) {
}
for (int i = 0; i < c.constants.size(); i++) {
- ConstantDoc &m = c.constants.write[i];
+ DocData::ConstantDoc &m = c.constants.write[i];
for (int j = 0; j < cf.constants.size(); j++) {
if (cf.constants[j].name != m.name) {
continue;
}
- const ConstantDoc &mf = cf.constants[j];
+ const DocData::ConstantDoc &mf = cf.constants[j];
m.description = mf.description;
break;
@@ -131,13 +131,13 @@ void DocData::merge_from(const DocData &p_data) {
}
for (int i = 0; i < c.properties.size(); i++) {
- PropertyDoc &p = c.properties.write[i];
+ DocData::PropertyDoc &p = c.properties.write[i];
for (int j = 0; j < cf.properties.size(); j++) {
if (cf.properties[j].name != p.name) {
continue;
}
- const PropertyDoc &pf = cf.properties[j];
+ const DocData::PropertyDoc &pf = cf.properties[j];
p.description = pf.description;
break;
@@ -145,13 +145,13 @@ void DocData::merge_from(const DocData &p_data) {
}
for (int i = 0; i < c.theme_properties.size(); i++) {
- PropertyDoc &p = c.theme_properties.write[i];
+ DocData::PropertyDoc &p = c.theme_properties.write[i];
for (int j = 0; j < cf.theme_properties.size(); j++) {
if (cf.theme_properties[j].name != p.name) {
continue;
}
- const PropertyDoc &pf = cf.theme_properties[j];
+ const DocData::PropertyDoc &pf = cf.theme_properties[j];
p.description = pf.description;
break;
@@ -177,57 +177,29 @@ void DocData::merge_from(const DocData &p_data) {
}
}
-void DocData::remove_from(const DocData &p_data) {
- for (Map<String, ClassDoc>::Element *E = p_data.class_list.front(); E; E = E->next()) {
+void DocTools::remove_from(const DocTools &p_data) {
+ for (Map<String, DocData::ClassDoc>::Element *E = p_data.class_list.front(); E; E = E->next()) {
if (class_list.has(E->key())) {
class_list.erase(E->key());
}
}
}
-static void return_doc_from_retinfo(DocData::MethodDoc &p_method, const PropertyInfo &p_retinfo) {
- if (p_retinfo.type == Variant::INT && p_retinfo.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
- p_method.return_enum = p_retinfo.class_name;
- if (p_method.return_enum.begins_with("_")) { //proxy class
- p_method.return_enum = p_method.return_enum.substr(1, p_method.return_enum.length());
- }
- p_method.return_type = "int";
- } else if (p_retinfo.class_name != StringName()) {
- p_method.return_type = p_retinfo.class_name;
- } else if (p_retinfo.type == Variant::ARRAY && p_retinfo.hint == PROPERTY_HINT_ARRAY_TYPE) {
- p_method.return_type = p_retinfo.hint_string + "[]";
- } else if (p_retinfo.hint == PROPERTY_HINT_RESOURCE_TYPE) {
- p_method.return_type = p_retinfo.hint_string;
- } else if (p_retinfo.type == Variant::NIL && p_retinfo.usage & PROPERTY_USAGE_NIL_IS_VARIANT) {
- p_method.return_type = "Variant";
- } else if (p_retinfo.type == Variant::NIL) {
- p_method.return_type = "void";
- } else {
- p_method.return_type = Variant::get_type_name(p_retinfo.type);
- }
+void DocTools::add_doc(const DocData::ClassDoc &p_class_doc) {
+ ERR_FAIL_COND(p_class_doc.name == "");
+ class_list[p_class_doc.name] = p_class_doc;
}
-static void argument_doc_from_arginfo(DocData::ArgumentDoc &p_argument, const PropertyInfo &p_arginfo) {
- p_argument.name = p_arginfo.name;
+void DocTools::remove_doc(const String &p_class_name) {
+ ERR_FAIL_COND(p_class_name == "" || !class_list.has(p_class_name));
+ class_list.erase(p_class_name);
+}
- if (p_arginfo.type == Variant::INT && p_arginfo.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
- p_argument.enumeration = p_arginfo.class_name;
- if (p_argument.enumeration.begins_with("_")) { //proxy class
- p_argument.enumeration = p_argument.enumeration.substr(1, p_argument.enumeration.length());
- }
- p_argument.type = "int";
- } else if (p_arginfo.class_name != StringName()) {
- p_argument.type = p_arginfo.class_name;
- } else if (p_arginfo.type == Variant::ARRAY && p_arginfo.hint == PROPERTY_HINT_ARRAY_TYPE) {
- p_argument.type = p_arginfo.hint_string + "[]";
- } else if (p_arginfo.hint == PROPERTY_HINT_RESOURCE_TYPE) {
- p_argument.type = p_arginfo.hint_string;
- } else if (p_arginfo.type == Variant::NIL) {
- // Parameters cannot be void, so PROPERTY_USAGE_NIL_IS_VARIANT is not necessary
- p_argument.type = "Variant";
- } else {
- p_argument.type = Variant::get_type_name(p_arginfo.type);
+bool DocTools::has_doc(const String &p_class_name) {
+ if (p_class_name == "") {
+ return false;
}
+ return class_list.has(p_class_name);
}
static Variant get_documentation_default_value(const StringName &p_class_name, const StringName &p_property_name, bool &r_default_value_valid) {
@@ -253,7 +225,7 @@ static Variant get_documentation_default_value(const StringName &p_class_name, c
return default_value;
}
-void DocData::generate(bool p_basic_types) {
+void DocTools::generate(bool p_basic_types) {
List<StringName> classes;
ClassDB::get_class_list(&classes);
classes.sort_custom<StringName::AlphCompare>();
@@ -277,8 +249,8 @@ void DocData::generate(bool p_basic_types) {
cname = cname.substr(1, name.length());
}
- class_list[cname] = ClassDoc();
- ClassDoc &c = class_list[cname];
+ class_list[cname] = DocData::ClassDoc();
+ DocData::ClassDoc &c = class_list[cname];
c.name = cname;
c.inherits = ClassDB::get_parent_class(name);
@@ -305,7 +277,7 @@ void DocData::generate(bool p_basic_types) {
continue;
}
- PropertyDoc prop;
+ DocData::PropertyDoc prop;
prop.name = E->get().name;
@@ -409,7 +381,7 @@ void DocData::generate(bool p_basic_types) {
}
}
- MethodDoc method;
+ DocData::MethodDoc method;
method.name = E->get().name;
@@ -432,12 +404,12 @@ void DocData::generate(bool p_basic_types) {
for (int i = -1; i < E->get().arguments.size(); i++) {
if (i == -1) {
#ifdef DEBUG_METHODS_ENABLED
- return_doc_from_retinfo(method, E->get().return_val);
+ DocData::return_doc_from_retinfo(method, E->get().return_val);
#endif
} else {
const PropertyInfo &arginfo = E->get().arguments[i];
- ArgumentDoc argument;
- argument_doc_from_arginfo(argument, arginfo);
+ DocData::ArgumentDoc argument;
+ DocData::argument_doc_from_arginfo(argument, arginfo);
int darg_idx = i - (E->get().arguments.size() - E->get().default_arguments.size());
if (darg_idx >= 0) {
@@ -457,12 +429,12 @@ void DocData::generate(bool p_basic_types) {
if (signal_list.size()) {
for (List<MethodInfo>::Element *EV = signal_list.front(); EV; EV = EV->next()) {
- MethodDoc signal;
+ DocData::MethodDoc signal;
signal.name = EV->get().name;
for (int i = 0; i < EV->get().arguments.size(); i++) {
const PropertyInfo &arginfo = EV->get().arguments[i];
- ArgumentDoc argument;
- argument_doc_from_arginfo(argument, arginfo);
+ DocData::ArgumentDoc argument;
+ DocData::argument_doc_from_arginfo(argument, arginfo);
signal.arguments.push_back(argument);
}
@@ -475,7 +447,7 @@ void DocData::generate(bool p_basic_types) {
ClassDB::get_integer_constant_list(name, &constant_list, true);
for (List<String>::Element *E = constant_list.front(); E; E = E->next()) {
- ConstantDoc constant;
+ DocData::ConstantDoc constant;
constant.name = E->get();
constant.value = itos(ClassDB::get_integer_constant(name, E->get()));
constant.is_value_valid = true;
@@ -489,7 +461,7 @@ void DocData::generate(bool p_basic_types) {
List<StringName> l;
Theme::get_default()->get_constant_list(cname, &l);
for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
- PropertyDoc pd;
+ DocData::PropertyDoc pd;
pd.name = E->get();
pd.type = "int";
pd.default_value = itos(Theme::get_default()->get_constant(E->get(), cname));
@@ -499,7 +471,7 @@ void DocData::generate(bool p_basic_types) {
l.clear();
Theme::get_default()->get_color_list(cname, &l);
for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
- PropertyDoc pd;
+ DocData::PropertyDoc pd;
pd.name = E->get();
pd.type = "Color";
pd.default_value = Variant(Theme::get_default()->get_color(E->get(), cname)).get_construct_string();
@@ -509,7 +481,7 @@ void DocData::generate(bool p_basic_types) {
l.clear();
Theme::get_default()->get_icon_list(cname, &l);
for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
- PropertyDoc pd;
+ DocData::PropertyDoc pd;
pd.name = E->get();
pd.type = "Texture2D";
c.theme_properties.push_back(pd);
@@ -517,15 +489,23 @@ void DocData::generate(bool p_basic_types) {
l.clear();
Theme::get_default()->get_font_list(cname, &l);
for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
- PropertyDoc pd;
+ DocData::PropertyDoc pd;
pd.name = E->get();
pd.type = "Font";
c.theme_properties.push_back(pd);
}
l.clear();
+ Theme::get_default()->get_font_size_list(cname, &l);
+ for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
+ DocData::PropertyDoc pd;
+ pd.name = E->get();
+ pd.type = "int";
+ c.theme_properties.push_back(pd);
+ }
+ l.clear();
Theme::get_default()->get_stylebox_list(cname, &l);
for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
- PropertyDoc pd;
+ DocData::PropertyDoc pd;
pd.name = E->get();
pd.type = "StyleBox";
c.theme_properties.push_back(pd);
@@ -537,7 +517,7 @@ void DocData::generate(bool p_basic_types) {
{
// So we can document the concept of Variant even if it's not a usable class per se.
- class_list["Variant"] = ClassDoc();
+ class_list["Variant"] = DocData::ClassDoc();
class_list["Variant"].name = "Variant";
}
@@ -556,8 +536,8 @@ void DocData::generate(bool p_basic_types) {
String cname = Variant::get_type_name(Variant::Type(i));
- class_list[cname] = ClassDoc();
- ClassDoc &c = class_list[cname];
+ class_list[cname] = DocData::ClassDoc();
+ DocData::ClassDoc &c = class_list[cname];
c.name = cname;
Callable::CallError cerror;
@@ -634,7 +614,7 @@ void DocData::generate(bool p_basic_types) {
for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) {
MethodInfo &mi = E->get();
- MethodDoc method;
+ DocData::MethodDoc method;
method.name = mi.name;
if (method.name == cname) {
@@ -645,8 +625,8 @@ void DocData::generate(bool p_basic_types) {
for (int j = 0; j < mi.arguments.size(); j++) {
PropertyInfo arginfo = mi.arguments[j];
- ArgumentDoc ad;
- argument_doc_from_arginfo(ad, mi.arguments[j]);
+ DocData::ArgumentDoc ad;
+ DocData::argument_doc_from_arginfo(ad, mi.arguments[j]);
ad.name = arginfo.name;
int darg_idx = mi.default_arguments.size() - mi.arguments.size() + j;
@@ -658,7 +638,7 @@ void DocData::generate(bool p_basic_types) {
method.arguments.push_back(ad);
}
- return_doc_from_retinfo(method, mi.return_val);
+ DocData::return_doc_from_retinfo(method, mi.return_val);
if (mi.flags & METHOD_FLAG_VARARG) {
if (method.qualifiers != "") {
@@ -674,7 +654,7 @@ void DocData::generate(bool p_basic_types) {
v.get_property_list(&properties);
for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
PropertyInfo pi = E->get();
- PropertyDoc property;
+ DocData::PropertyDoc property;
property.name = pi.name;
property.type = Variant::get_type_name(pi.type);
property.default_value = v.get(pi.name).get_construct_string();
@@ -686,7 +666,7 @@ void DocData::generate(bool p_basic_types) {
Variant::get_constants_for_type(Variant::Type(i), &constants);
for (List<StringName>::Element *E = constants.front(); E; E = E->next()) {
- ConstantDoc constant;
+ DocData::ConstantDoc constant;
constant.name = E->get();
Variant value = Variant::get_constant_value(Variant::Type(i), E->get());
constant.value = value.get_type() == Variant::INT ? itos(value) : value.get_construct_string();
@@ -699,12 +679,12 @@ void DocData::generate(bool p_basic_types) {
{
String cname = "@GlobalScope";
- class_list[cname] = ClassDoc();
- ClassDoc &c = class_list[cname];
+ class_list[cname] = DocData::ClassDoc();
+ DocData::ClassDoc &c = class_list[cname];
c.name = cname;
for (int i = 0; i < CoreConstants::get_global_constant_count(); i++) {
- ConstantDoc cd;
+ DocData::ConstantDoc cd;
cd.name = CoreConstants::get_global_constant_name(i);
if (!CoreConstants::get_ignore_value_in_docs(i)) {
cd.value = itos(CoreConstants::get_global_constant_value(i));
@@ -721,7 +701,7 @@ void DocData::generate(bool p_basic_types) {
//servers (this is kind of hackish)
for (List<Engine::Singleton>::Element *E = singletons.front(); E; E = E->next()) {
- PropertyDoc pd;
+ DocData::PropertyDoc pd;
Engine::Singleton &s = E->get();
if (!s.ptr) {
continue;
@@ -741,7 +721,7 @@ void DocData::generate(bool p_basic_types) {
Variant::get_utility_function_list(&utility_functions);
utility_functions.sort_custom<StringName::AlphCompare>();
for (List<StringName>::Element *E = utility_functions.front(); E; E = E->next()) {
- MethodDoc md;
+ DocData::MethodDoc md;
md.name = E->get();
//return
if (Variant::has_utility_function_return_value(E->get())) {
@@ -751,7 +731,7 @@ void DocData::generate(bool p_basic_types) {
pi.usage = PROPERTY_USAGE_NIL_IS_VARIANT;
}
DocData::ArgumentDoc ad;
- argument_doc_from_arginfo(ad, pi);
+ DocData::argument_doc_from_arginfo(ad, pi);
md.return_type = ad.type;
}
@@ -766,7 +746,7 @@ void DocData::generate(bool p_basic_types) {
pi.usage = PROPERTY_USAGE_NIL_IS_VARIANT;
}
DocData::ArgumentDoc ad;
- argument_doc_from_arginfo(ad, pi);
+ DocData::argument_doc_from_arginfo(ad, pi);
md.arguments.push_back(ad);
}
}
@@ -783,7 +763,7 @@ void DocData::generate(bool p_basic_types) {
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
ScriptLanguage *lang = ScriptServer::get_language(i);
String cname = "@" + lang->get_name();
- ClassDoc c;
+ DocData::ClassDoc c;
c.name = cname;
// Get functions.
@@ -792,7 +772,7 @@ void DocData::generate(bool p_basic_types) {
for (List<MethodInfo>::Element *E = minfo.front(); E; E = E->next()) {
MethodInfo &mi = E->get();
- MethodDoc md;
+ DocData::MethodDoc md;
md.name = mi.name;
if (mi.flags & METHOD_FLAG_VARARG) {
@@ -802,11 +782,11 @@ void DocData::generate(bool p_basic_types) {
md.qualifiers += "vararg";
}
- return_doc_from_retinfo(md, mi.return_val);
+ DocData::return_doc_from_retinfo(md, mi.return_val);
for (int j = 0; j < mi.arguments.size(); j++) {
- ArgumentDoc ad;
- argument_doc_from_arginfo(ad, mi.arguments[j]);
+ DocData::ArgumentDoc ad;
+ DocData::argument_doc_from_arginfo(ad, mi.arguments[j]);
int darg_idx = j - (mi.arguments.size() - mi.default_arguments.size());
if (darg_idx >= 0) {
@@ -825,7 +805,7 @@ void DocData::generate(bool p_basic_types) {
lang->get_public_constants(&cinfo);
for (List<Pair<String, Variant>>::Element *E = cinfo.front(); E; E = E->next()) {
- ConstantDoc cd;
+ DocData::ConstantDoc cd;
cd.name = E->get().first;
cd.value = E->get().second;
cd.is_value_valid = true;
@@ -903,7 +883,7 @@ static Error _parse_methods(Ref<XMLParser> &parser, Vector<DocData::MethodDoc> &
return OK;
}
-Error DocData::load_classes(const String &p_dir) {
+Error DocTools::load_classes(const String &p_dir) {
Error err;
DirAccessRef da = DirAccess::open(p_dir, &err);
if (!da) {
@@ -931,7 +911,7 @@ Error DocData::load_classes(const String &p_dir) {
return OK;
}
-Error DocData::erase_classes(const String &p_dir) {
+Error DocTools::erase_classes(const String &p_dir) {
Error err;
DirAccessRef da = DirAccess::open(p_dir, &err);
if (!da) {
@@ -959,7 +939,7 @@ Error DocData::erase_classes(const String &p_dir) {
return OK;
}
-Error DocData::_load(Ref<XMLParser> parser) {
+Error DocTools::_load(Ref<XMLParser> parser) {
Error err = OK;
while ((err = parser->read()) == OK) {
@@ -975,8 +955,8 @@ Error DocData::_load(Ref<XMLParser> parser) {
ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT);
String name = parser->get_attribute_value("name");
- class_list[name] = ClassDoc();
- ClassDoc &c = class_list[name];
+ class_list[name] = DocData::ClassDoc();
+ DocData::ClassDoc &c = class_list[name];
c.name = name;
if (parser->has_attribute("inherits")) {
@@ -1004,7 +984,7 @@ Error DocData::_load(Ref<XMLParser> parser) {
String name3 = parser->get_node_name();
if (name3 == "link") {
- TutorialDoc tutorial;
+ DocData::TutorialDoc tutorial;
if (parser->has_attribute("title")) {
tutorial.title = parser->get_attribute_value("title");
}
@@ -1033,7 +1013,7 @@ Error DocData::_load(Ref<XMLParser> parser) {
String name3 = parser->get_node_name();
if (name3 == "member") {
- PropertyDoc prop2;
+ DocData::PropertyDoc prop2;
ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT);
prop2.name = parser->get_attribute_value("name");
@@ -1070,7 +1050,7 @@ Error DocData::_load(Ref<XMLParser> parser) {
String name3 = parser->get_node_name();
if (name3 == "theme_item") {
- PropertyDoc prop2;
+ DocData::PropertyDoc prop2;
ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT);
prop2.name = parser->get_attribute_value("name");
@@ -1098,7 +1078,7 @@ Error DocData::_load(Ref<XMLParser> parser) {
String name3 = parser->get_node_name();
if (name3 == "constant") {
- ConstantDoc constant2;
+ DocData::ConstantDoc constant2;
ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT);
constant2.name = parser->get_attribute_value("name");
ERR_FAIL_COND_V(!parser->has_attribute("value"), ERR_FILE_CORRUPT);
@@ -1147,9 +1127,9 @@ static void _write_string(FileAccess *f, int p_tablevel, const String &p_string)
f->store_string(tab + p_string + "\n");
}
-Error DocData::save_classes(const String &p_default_path, const Map<String, String> &p_class_path) {
- for (Map<String, ClassDoc>::Element *E = class_list.front(); E; E = E->next()) {
- ClassDoc &c = E->get();
+Error DocTools::save_classes(const String &p_default_path, const Map<String, String> &p_class_path) {
+ for (Map<String, DocData::ClassDoc>::Element *E = class_list.front(); E; E = E->next()) {
+ DocData::ClassDoc &c = E->get();
String save_path;
if (p_class_path.has(c.name)) {
@@ -1184,7 +1164,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
_write_string(f, 1, "<tutorials>");
for (int i = 0; i < c.tutorials.size(); i++) {
- TutorialDoc tutorial = c.tutorials.get(i);
+ DocData::TutorialDoc tutorial = c.tutorials.get(i);
String title_attribute = (!tutorial.title.empty()) ? " title=\"" + tutorial.title.xml_escape() + "\"" : "";
_write_string(f, 2, "<link" + title_attribute + ">" + tutorial.link.xml_escape() + "</link>");
}
@@ -1195,7 +1175,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
c.methods.sort();
for (int i = 0; i < c.methods.size(); i++) {
- const MethodDoc &m = c.methods[i];
+ const DocData::MethodDoc &m = c.methods[i];
String qualifiers;
if (m.qualifiers != "") {
@@ -1214,7 +1194,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
}
for (int j = 0; j < m.arguments.size(); j++) {
- const ArgumentDoc &a = m.arguments[j];
+ const DocData::ArgumentDoc &a = m.arguments[j];
String enum_text;
if (a.enumeration != String()) {
@@ -1253,7 +1233,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
additional_attributes += " default=\"" + c.properties[i].default_value.xml_escape(true) + "\"";
}
- const PropertyDoc &p = c.properties[i];
+ const DocData::PropertyDoc &p = c.properties[i];
if (c.properties[i].overridden) {
_write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\" override=\"true\"" + additional_attributes + " />");
@@ -1271,10 +1251,10 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
_write_string(f, 1, "<signals>");
for (int i = 0; i < c.signals.size(); i++) {
- const MethodDoc &m = c.signals[i];
+ const DocData::MethodDoc &m = c.signals[i];
_write_string(f, 2, "<signal name=\"" + m.name + "\">");
for (int j = 0; j < m.arguments.size(); j++) {
- const ArgumentDoc &a = m.arguments[j];
+ const DocData::ArgumentDoc &a = m.arguments[j];
_write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\">");
_write_string(f, 3, "</argument>");
}
@@ -1292,7 +1272,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
_write_string(f, 1, "<constants>");
for (int i = 0; i < c.constants.size(); i++) {
- const ConstantDoc &k = c.constants[i];
+ const DocData::ConstantDoc &k = c.constants[i];
if (k.is_value_valid) {
if (k.enumeration != String()) {
_write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\" enum=\"" + k.enumeration + "\">");
@@ -1317,7 +1297,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
_write_string(f, 1, "<theme_items>");
for (int i = 0; i < c.theme_properties.size(); i++) {
- const PropertyDoc &p = c.theme_properties[i];
+ const DocData::PropertyDoc &p = c.theme_properties[i];
if (p.default_value != "") {
_write_string(f, 2, "<theme_item name=\"" + p.name + "\" type=\"" + p.type + "\" default=\"" + p.default_value.xml_escape(true) + "\">");
@@ -1338,7 +1318,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
return OK;
}
-Error DocData::load_compressed(const uint8_t *p_data, int p_compressed_size, int p_uncompressed_size) {
+Error DocTools::load_compressed(const uint8_t *p_data, int p_compressed_size, int p_uncompressed_size) {
Vector<uint8_t> data;
data.resize(p_uncompressed_size);
Compression::decompress(data.ptrw(), p_uncompressed_size, p_data, p_compressed_size, Compression::MODE_DEFLATE);
diff --git a/editor/doc_data.h b/editor/doc_tools.h
index 2cb475d137..db27e38c8b 100644
--- a/editor/doc_data.h
+++ b/editor/doc_tools.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* doc_data.h */
+/* doc_tools.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,113 +28,28 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef DOC_DATA_H
-#define DOC_DATA_H
+#ifndef DOC_TOOLS_H
+#define DOC_TOOLS_H
-#include "core/io/xml_parser.h"
-#include "core/templates/map.h"
-#include "core/variant/variant.h"
+#include "core/doc_data.h"
-class DocData {
+class DocTools {
public:
- struct ArgumentDoc {
- String name;
- String type;
- String enumeration;
- String default_value;
- bool operator<(const ArgumentDoc &p_arg) const {
- if (name == p_arg.name) {
- return type < p_arg.type;
- }
- return name < p_arg.name;
- }
- };
-
- struct MethodDoc {
- String name;
- String return_type;
- String return_enum;
- String qualifiers;
- String description;
- Vector<ArgumentDoc> arguments;
- bool operator<(const MethodDoc &p_method) const {
- if (name == p_method.name) {
- // Must be a constructor since there is no overloading.
- // We want this arbitrary order for a class "Foo":
- // - 1. Default constructor: Foo()
- // - 2. Copy constructor: Foo(Foo)
- // - 3+. Other constructors Foo(Bar, ...) based on first argument's name
- if (arguments.size() == 0 || p_method.arguments.size() == 0) { // 1.
- return arguments.size() < p_method.arguments.size();
- }
- if (arguments[0].type == return_type || p_method.arguments[0].type == p_method.return_type) { // 2.
- return (arguments[0].type == return_type) || (p_method.arguments[0].type != p_method.return_type);
- }
- return arguments[0] < p_method.arguments[0];
- }
- return name < p_method.name;
- }
- };
-
- struct ConstantDoc {
- String name;
- String value;
- bool is_value_valid;
- String enumeration;
- String description;
- bool operator<(const ConstantDoc &p_const) const {
- return name < p_const.name;
- }
- };
-
- struct PropertyDoc {
- String name;
- String type;
- String enumeration;
- String description;
- String setter, getter;
- String default_value;
- bool overridden = false;
- bool operator<(const PropertyDoc &p_prop) const {
- return name < p_prop.name;
- }
- };
-
- struct TutorialDoc {
- String link;
- String title;
- };
-
- struct ClassDoc {
- String name;
- String inherits;
- String category;
- String brief_description;
- String description;
- Vector<TutorialDoc> tutorials;
- Vector<MethodDoc> methods;
- Vector<MethodDoc> signals;
- Vector<ConstantDoc> constants;
- Vector<PropertyDoc> properties;
- Vector<PropertyDoc> theme_properties;
- bool operator<(const ClassDoc &p_class) const {
- return name < p_class.name;
- }
- };
-
String version;
+ Map<String, DocData::ClassDoc> class_list;
- Map<String, ClassDoc> class_list;
- Error _load(Ref<XMLParser> parser);
+ static Error erase_classes(const String &p_dir);
-public:
- void merge_from(const DocData &p_data);
- void remove_from(const DocData &p_data);
+ void merge_from(const DocTools &p_data);
+ void remove_from(const DocTools &p_data);
+ void add_doc(const DocData::ClassDoc &p_class_doc);
+ void remove_doc(const String &p_class_name);
+ bool has_doc(const String &p_class_name);
void generate(bool p_basic_types = false);
Error load_classes(const String &p_dir);
- static Error erase_classes(const String &p_dir);
Error save_classes(const String &p_default_path, const Map<String, String> &p_class_path);
+ Error _load(Ref<XMLParser> parser);
Error load_compressed(const uint8_t *p_data, int p_compressed_size, int p_uncompressed_size);
};
diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp
index cbde7d593a..95802a0b9c 100644
--- a/editor/editor_about.cpp
+++ b/editor/editor_about.cpp
@@ -40,9 +40,12 @@
void EditorAbout::_theme_changed() {
Control *base = EditorNode::get_singleton()->get_gui_base();
Ref<Font> font = base->get_theme_font("source", "EditorFonts");
+ int font_size = base->get_theme_font_size("source_size", "EditorFonts");
_tpl_text->add_theme_font_override("normal_font", font);
+ _tpl_text->add_theme_font_size_override("normal_font_size", font_size);
_tpl_text->add_theme_constant_override("line_separation", 6 * EDSCALE);
_license_text->add_theme_font_override("normal_font", font);
+ _license_text->add_theme_font_size_override("normal_font_size", font_size);
_license_text->add_theme_constant_override("line_separation", 6 * EDSCALE);
_logo->set_texture(base->get_theme_icon("Logo", "EditorIcons"));
}
@@ -213,7 +216,7 @@ EditorAbout::EditorAbout() {
for (int component_index = 0; component_index < COPYRIGHT_INFO_COUNT; component_index++) {
const ComponentCopyright &component = COPYRIGHT_INFO[component_index];
TreeItem *ti = _tpl_tree->create_item(tpl_ti_tp);
- String component_name = component.name;
+ String component_name = String::utf8(component.name);
ti->set_text(0, component_name);
String text = component_name + "\n";
long_text += "- " + component_name + "\n";
@@ -221,7 +224,7 @@ EditorAbout::EditorAbout() {
const ComponentCopyrightPart &part = component.parts[part_index];
text += "\n Files:";
for (int file_num = 0; file_num < part.file_count; file_num++) {
- text += "\n " + String(part.files[file_num]);
+ text += "\n " + String::utf8(part.files[file_num]);
}
String copyright;
for (int copyright_index = 0; copyright_index < part.copyright_count; copyright_index++) {
@@ -229,7 +232,7 @@ EditorAbout::EditorAbout() {
}
text += copyright;
long_text += copyright;
- String license = "\n License: " + String(part.license) + "\n";
+ String license = "\n License: " + String::utf8(part.license) + "\n";
text += license;
long_text += license + "\n";
}
@@ -237,10 +240,10 @@ EditorAbout::EditorAbout() {
}
for (int i = 0; i < LICENSE_COUNT; i++) {
TreeItem *ti = _tpl_tree->create_item(tpl_ti_lc);
- String licensename = String(LICENSE_NAMES[i]);
+ String licensename = String::utf8(LICENSE_NAMES[i]);
ti->set_text(0, licensename);
long_text += "- " + licensename + "\n\n";
- String licensebody = String(LICENSE_BODIES[i]);
+ String licensebody = String::utf8(LICENSE_BODIES[i]);
ti->set_metadata(0, licensebody);
long_text += " " + licensebody.replace("\n", "\n ") + "\n\n";
}
diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp
index a3deb95130..0888fecc67 100644
--- a/editor/editor_audio_buses.cpp
+++ b/editor/editor_audio_buses.cpp
@@ -531,21 +531,15 @@ void EditorAudioBus::_effect_add(int p_which) {
}
void EditorAudioBus::_gui_input(const Ref<InputEvent> &p_event) {
- Ref<InputEventKey> k = p_event;
- if (k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_DELETE && !k->is_echo()) {
- accept_event();
- emit_signal("delete_request");
- }
-
Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid() && mb->get_button_index() == 2 && mb->is_pressed()) {
+ if (mb.is_valid() && mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) {
Vector2 pos = Vector2(mb->get_position().x, mb->get_position().y);
bus_popup->set_position(get_global_position() + pos);
bus_popup->popup();
}
}
-void EditorAudioBus::_unhandled_key_input(Ref<InputEvent> p_event) {
+void EditorAudioBus::_effects_gui_input(Ref<InputEvent> p_event) {
Ref<InputEventKey> k = p_event;
if (k.is_valid() && k->is_pressed() && !k->is_echo() && k->get_keycode() == KEY_DELETE) {
TreeItem *current_effect = effects->get_selected();
@@ -749,7 +743,6 @@ void EditorAudioBus::_bind_methods() {
ClassDB::bind_method("update_bus", &EditorAudioBus::update_bus);
ClassDB::bind_method("update_send", &EditorAudioBus::update_send);
ClassDB::bind_method("_gui_input", &EditorAudioBus::_gui_input);
- ClassDB::bind_method("_unhandled_key_input", &EditorAudioBus::_unhandled_key_input);
ClassDB::bind_method("get_drag_data_fw", &EditorAudioBus::get_drag_data_fw);
ClassDB::bind_method("can_drop_data_fw", &EditorAudioBus::can_drop_data_fw);
ClassDB::bind_method("drop_data_fw", &EditorAudioBus::drop_data_fw);
@@ -773,7 +766,6 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
add_child(vb);
set_v_size_flags(SIZE_EXPAND_FILL);
- set_process_unhandled_key_input(true);
track_name = memnew(LineEdit);
track_name->connect("text_entered", callable_mp(this, &EditorAudioBus::_name_changed));
@@ -805,12 +797,6 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
hbc->add_child(bypass);
hbc->add_spacer();
- bus_options = memnew(MenuButton);
- bus_options->set_h_size_flags(SIZE_SHRINK_END);
- bus_options->set_anchor(MARGIN_RIGHT, 0.0);
- bus_options->set_tooltip(TTR("Bus options"));
- hbc->add_child(bus_options);
-
Ref<StyleBoxEmpty> sbempty = memnew(StyleBoxEmpty);
for (int i = 0; i < hbc->get_child_count(); i++) {
Control *child = Object::cast_to<Control>(hbc->get_child(i));
@@ -906,6 +892,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
effects->set_allow_rmb_select(true);
effects->set_focus_mode(FOCUS_CLICK);
effects->set_allow_reselect(true);
+ effects->connect("gui_input", callable_mp(this, &EditorAudioBus::_effects_gui_input));
send = memnew(OptionButton);
send->set_clip_text(true);
@@ -932,9 +919,16 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
effect_options->set_item_icon(effect_options->get_item_count() - 1, icon);
}
+ bus_options = memnew(MenuButton);
+ bus_options->set_shortcut_context(this);
+ bus_options->set_h_size_flags(SIZE_SHRINK_END);
+ bus_options->set_anchor(MARGIN_RIGHT, 0.0);
+ bus_options->set_tooltip(TTR("Bus options"));
+ hbc->add_child(bus_options);
+
bus_popup = bus_options->get_popup();
- bus_popup->add_item(TTR("Duplicate"));
- bus_popup->add_item(TTR("Delete"));
+ bus_popup->add_shortcut(ED_SHORTCUT("audio_bus_editor/duplicate_selected_bus", TTR("Duplicate Bus"), KEY_MASK_CMD | KEY_D));
+ bus_popup->add_shortcut(ED_SHORTCUT("audio_bus_editor/delete_selected_bus", TTR("Delete Bus"), KEY_DELETE));
bus_popup->set_item_disabled(1, is_master);
bus_popup->add_item(TTR("Reset Volume"));
bus_popup->connect("index_pressed", callable_mp(this, &EditorAudioBus::_bus_popup_pressed));
@@ -1379,14 +1373,15 @@ void EditorAudioMeterNotches::add_notch(float p_normalized_offset, float p_db_va
Size2 EditorAudioMeterNotches::get_minimum_size() const {
Ref<Font> font = get_theme_font("font", "Label");
- float font_height = font->get_height();
+ int font_size = get_theme_font_size("font_size", "Label");
+ float font_height = font->get_height(font_size);
float width = 0;
float height = top_padding + btm_padding;
for (int i = 0; i < notches.size(); i++) {
if (notches[i].render_db_value) {
- width = MAX(width, font->get_string_size(String::num(Math::abs(notches[i].db_value)) + "dB").x);
+ width = MAX(width, font->get_string_size(String::num(Math::abs(notches[i].db_value)) + "dB", font_size).x);
height += font_height;
}
}
@@ -1413,7 +1408,8 @@ void EditorAudioMeterNotches::_notification(int p_what) {
void EditorAudioMeterNotches::_draw_audio_notches() {
Ref<Font> font = get_theme_font("font", "Label");
- float font_height = font->get_height();
+ int font_size = get_theme_font_size("font_size", "Label");
+ float font_height = font->get_height(font_size);
for (int i = 0; i < notches.size(); i++) {
AudioNotch n = notches[i];
@@ -1427,6 +1423,7 @@ void EditorAudioMeterNotches::_draw_audio_notches() {
Vector2(line_length + label_space,
(1.0f - n.relative_position) * (get_size().y - btm_padding - top_padding) + (font_height / 4) + top_padding),
String::num(Math::abs(n.db_value)) + "dB",
+ HALIGN_LEFT, -1, font_size,
notch_color);
}
}
diff --git a/editor/editor_audio_buses.h b/editor/editor_audio_buses.h
index b6cf1183b5..01221ad6ef 100644
--- a/editor/editor_audio_buses.h
+++ b/editor/editor_audio_buses.h
@@ -91,7 +91,7 @@ class EditorAudioBus : public PanelContainer {
mutable bool hovering_drop;
void _gui_input(const Ref<InputEvent> &p_event);
- void _unhandled_key_input(Ref<InputEvent> p_event);
+ void _effects_gui_input(Ref<InputEvent> p_event);
void _bus_popup_pressed(int p_option);
void _name_changed(const String &p_new_name);
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp
index 69edefd75c..f7cb5428ce 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -398,7 +398,11 @@ Error EditorExportPlatform::_save_zip_file(void *p_userdata, const String &p_pat
Ref<ImageTexture> EditorExportPlatform::get_option_icon(int p_index) const {
Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme();
ERR_FAIL_COND_V(theme.is_null(), Ref<ImageTexture>());
- return theme->get_icon("Play", "EditorIcons");
+ if (EditorNode::get_singleton()->get_viewport()->is_layout_rtl()) {
+ return theme->get_icon("PlayBackwards", "EditorIcons");
+ } else {
+ return theme->get_icon("Play", "EditorIcons");
+ }
}
String EditorExportPlatform::find_export_template(String template_file_name, String *err) const {
@@ -972,6 +976,15 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
p_func(p_udata, splash, array, idx, total, enc_in_filters, enc_ex_filters, key);
}
+ // Store text server data if exists.
+ if (TS->has_feature(TextServer::FEATURE_USE_SUPPORT_DATA)) {
+ String ts_data = "res://" + TS->get_support_data_filename();
+ if (FileAccess::exists(ts_data)) {
+ Vector<uint8_t> array = FileAccess::get_file_as_array(ts_data);
+ p_func(p_udata, ts_data, array, idx, total, enc_in_filters, enc_ex_filters, key);
+ }
+ }
+
String config_file = "project.binary";
String engine_cfb = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp" + config_file);
ProjectSettings::get_singleton()->save_custom(engine_cfb, custom_map, custom_list);
diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp
index e3923a48c5..ffdd7c7fa8 100644
--- a/editor/editor_file_dialog.cpp
+++ b/editor/editor_file_dialog.cpp
@@ -59,12 +59,17 @@ VBoxContainer *EditorFileDialog::get_vbox() {
}
void EditorFileDialog::_notification(int p_what) {
- if (p_what == NOTIFICATION_READY || p_what == NOTIFICATION_THEME_CHANGED) {
+ if (p_what == NOTIFICATION_READY || p_what == NOTIFICATION_THEME_CHANGED || p_what == Control::NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) {
// Update icons.
mode_thumbnails->set_icon(item_list->get_theme_icon("FileThumbnail", "EditorIcons"));
mode_list->set_icon(item_list->get_theme_icon("FileList", "EditorIcons"));
- dir_prev->set_icon(item_list->get_theme_icon("Back", "EditorIcons"));
- dir_next->set_icon(item_list->get_theme_icon("Forward", "EditorIcons"));
+ if (is_layout_rtl()) {
+ dir_prev->set_icon(item_list->get_theme_icon("Forward", "EditorIcons"));
+ dir_next->set_icon(item_list->get_theme_icon("Back", "EditorIcons"));
+ } else {
+ dir_prev->set_icon(item_list->get_theme_icon("Back", "EditorIcons"));
+ dir_next->set_icon(item_list->get_theme_icon("Forward", "EditorIcons"));
+ }
dir_up->set_icon(item_list->get_theme_icon("ArrowUp", "EditorIcons"));
refresh->set_icon(item_list->get_theme_icon("Reload", "EditorIcons"));
favorite->set_icon(item_list->get_theme_icon("Favorites", "EditorIcons"));
@@ -97,8 +102,13 @@ void EditorFileDialog::_notification(int p_what) {
// Update icons.
mode_thumbnails->set_icon(item_list->get_theme_icon("FileThumbnail", "EditorIcons"));
mode_list->set_icon(item_list->get_theme_icon("FileList", "EditorIcons"));
- dir_prev->set_icon(item_list->get_theme_icon("Back", "EditorIcons"));
- dir_next->set_icon(item_list->get_theme_icon("Forward", "EditorIcons"));
+ if (is_layout_rtl()) {
+ dir_prev->set_icon(item_list->get_theme_icon("Forward", "EditorIcons"));
+ dir_next->set_icon(item_list->get_theme_icon("Back", "EditorIcons"));
+ } else {
+ dir_prev->set_icon(item_list->get_theme_icon("Back", "EditorIcons"));
+ dir_next->set_icon(item_list->get_theme_icon("Forward", "EditorIcons"));
+ }
dir_up->set_icon(item_list->get_theme_icon("ArrowUp", "EditorIcons"));
refresh->set_icon(item_list->get_theme_icon("Reload", "EditorIcons"));
favorite->set_icon(item_list->get_theme_icon("Favorites", "EditorIcons"));
@@ -1486,6 +1496,7 @@ EditorFileDialog::EditorFileDialog() {
pathhb->add_child(drives_container);
dir = memnew(LineEdit);
+ dir->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE);
pathhb->add_child(dir);
dir->set_h_size_flags(Control::SIZE_EXPAND_FILL);
@@ -1624,6 +1635,7 @@ EditorFileDialog::EditorFileDialog() {
file_box = memnew(HBoxContainer);
file_box->add_child(memnew(Label(TTR("File:"))));
file = memnew(LineEdit);
+ file->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE);
file->set_stretch_ratio(4);
file->set_h_size_flags(Control::SIZE_EXPAND_FILL);
file_box->add_child(file);
@@ -1662,6 +1674,7 @@ EditorFileDialog::EditorFileDialog() {
makedialog->add_child(makevb);
makedirname = memnew(LineEdit);
+ makedirname->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE);
makevb->add_margin_child(TTR("Name:"), makedirname);
add_child(makedialog);
makedialog->register_text_enter(makedirname);
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index c66bc9b3fa..738b88a86b 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -357,10 +357,12 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
List<String> to_check;
+ String importer_name;
String source_file = "";
String source_md5 = "";
Vector<String> dest_files;
String dest_md5 = "";
+ int version = 0;
while (true) {
assign = Variant();
@@ -384,6 +386,10 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
for (int i = 0; i < fa.size(); i++) {
to_check.push_back(fa[i]);
}
+ } else if (assign == "importer_version") {
+ version = value;
+ } else if (assign == "importer") {
+ importer_name = value;
} else if (!p_only_imported_files) {
if (assign == "source_file") {
source_file = value;
@@ -399,6 +405,12 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
memdelete(f);
+ Ref<ResourceImporter> importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(importer_name);
+
+ if (importer->get_format_version() > version) {
+ return true; // version changed, reimport
+ }
+
// Read the md5's from a separate file (so the import parameters aren't dependent on the file version
String base_path = ResourceFormatImporter::get_singleton()->get_import_base_path(p_path);
FileAccess *md5s = FileAccess::open(base_path + ".md5", FileAccess::READ, &err);
@@ -799,6 +811,20 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
}
}
+ for (int i = 0; i < ScriptServer::get_language_count(); i++) {
+ ScriptLanguage *lang = ScriptServer::get_language(i);
+ if (lang->supports_documentation() && fi->type == lang->get_type()) {
+ Ref<Script> script = ResourceLoader::load(path);
+ if (script == nullptr) {
+ continue;
+ }
+ const Vector<DocData::ClassDoc> &docs = script->get_documentation();
+ for (int j = 0; j < docs.size(); j++) {
+ EditorHelp::get_doc_data()->add_doc(docs[j]);
+ }
+ }
+ }
+
p_dir->files.push_back(fi);
p_progress.update(idx, total);
}
@@ -1562,6 +1588,10 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector
f->store_line("[remap]");
f->store_line("");
f->store_line("importer=\"" + importer->get_importer_name() + "\"");
+ int version = importer->get_format_version();
+ if (version > 0) {
+ f->store_line("importer_version=" + itos(importer->get_format_version()));
+ }
if (importer->get_resource_type() != "") {
f->store_line("type=\"" + importer->get_resource_type() + "\"");
}
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp
index 100c76c32b..f5bb4921d4 100644
--- a/editor/editor_fonts.cpp
+++ b/editor/editor_fonts.cpp
@@ -35,57 +35,61 @@
#include "editor_scale.h"
#include "editor_settings.h"
#include "scene/resources/default_theme/default_theme.h"
-#include "scene/resources/dynamic_font.h"
-
-#define MAKE_FALLBACKS(m_name) \
- m_name->add_fallback(FontArabic); \
- m_name->add_fallback(FontHebrew); \
- m_name->add_fallback(FontThai); \
- m_name->add_fallback(FontHindi); \
- m_name->add_fallback(FontJapanese); \
- m_name->add_fallback(FontFallback);
+#include "scene/resources/font.h"
+
+#define MAKE_FALLBACKS(m_name) \
+ m_name->add_data(FontArabic); \
+ m_name->add_data(FontBengali); \
+ m_name->add_data(FontGeorgian); \
+ m_name->add_data(FontMalayalam); \
+ m_name->add_data(FontOriya); \
+ m_name->add_data(FontSinhala); \
+ m_name->add_data(FontTamil); \
+ m_name->add_data(FontTelugu); \
+ m_name->add_data(FontHebrew); \
+ m_name->add_data(FontThai); \
+ m_name->add_data(FontHindi); \
+ m_name->add_data(FontJapanese); \
+ m_name->add_data(FontFallback);
// the custom spacings might only work with Noto Sans
-#define MAKE_DEFAULT_FONT(m_name, m_size) \
- Ref<DynamicFont> m_name; \
- m_name.instance(); \
- m_name->set_size(m_size); \
- if (CustomFont.is_valid()) { \
- m_name->set_font_data(CustomFont); \
- m_name->add_fallback(DefaultFont); \
- } else { \
- m_name->set_font_data(DefaultFont); \
- } \
- m_name->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); \
- m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); \
+#define MAKE_DEFAULT_FONT(m_name) \
+ Ref<Font> m_name; \
+ m_name.instance(); \
+ if (CustomFont.is_valid()) { \
+ m_name->add_data(CustomFont); \
+ m_name->add_data(DefaultFont); \
+ } else { \
+ m_name->add_data(DefaultFont); \
+ } \
+ m_name->set_spacing(Font::SPACING_TOP, -EDSCALE); \
+ m_name->set_spacing(Font::SPACING_BOTTOM, -EDSCALE); \
MAKE_FALLBACKS(m_name);
-#define MAKE_BOLD_FONT(m_name, m_size) \
- Ref<DynamicFont> m_name; \
- m_name.instance(); \
- m_name->set_size(m_size); \
- if (CustomFontBold.is_valid()) { \
- m_name->set_font_data(CustomFontBold); \
- m_name->add_fallback(DefaultFontBold); \
- } else { \
- m_name->set_font_data(DefaultFontBold); \
- } \
- m_name->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); \
- m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); \
+#define MAKE_BOLD_FONT(m_name) \
+ Ref<Font> m_name; \
+ m_name.instance(); \
+ if (CustomFontBold.is_valid()) { \
+ m_name->add_data(CustomFontBold); \
+ m_name->add_data(DefaultFontBold); \
+ } else { \
+ m_name->add_data(DefaultFontBold); \
+ } \
+ m_name->set_spacing(Font::SPACING_TOP, -EDSCALE); \
+ m_name->set_spacing(Font::SPACING_BOTTOM, -EDSCALE); \
MAKE_FALLBACKS(m_name);
-#define MAKE_SOURCE_FONT(m_name, m_size) \
- Ref<DynamicFont> m_name; \
- m_name.instance(); \
- m_name->set_size(m_size); \
- if (CustomFontSource.is_valid()) { \
- m_name->set_font_data(CustomFontSource); \
- m_name->add_fallback(dfmono); \
- } else { \
- m_name->set_font_data(dfmono); \
- } \
- m_name->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); \
- m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); \
+#define MAKE_SOURCE_FONT(m_name) \
+ Ref<Font> m_name; \
+ m_name.instance(); \
+ if (CustomFontSource.is_valid()) { \
+ m_name->add_data(CustomFontSource); \
+ m_name->add_data(dfmono); \
+ } else { \
+ m_name->add_data(dfmono); \
+ } \
+ m_name->set_spacing(Font::SPACING_TOP, -EDSCALE); \
+ m_name->set_spacing(Font::SPACING_BOTTOM, -EDSCALE); \
MAKE_FALLBACKS(m_name);
void editor_register_fonts(Ref<Theme> p_theme) {
@@ -96,7 +100,7 @@ void editor_register_fonts(Ref<Theme> p_theme) {
bool font_antialiased = (bool)EditorSettings::get_singleton()->get("interface/editor/font_antialiased");
int font_hinting_setting = (int)EditorSettings::get_singleton()->get("interface/editor/font_hinting");
- DynamicFontData::Hinting font_hinting;
+ TextServer::Hinting font_hinting;
switch (font_hinting_setting) {
case 0:
// The "Auto" setting uses the setting that best matches the OS' font rendering:
@@ -104,29 +108,31 @@ void editor_register_fonts(Ref<Theme> p_theme) {
// - Windows uses ClearType, which is in between "Light" and "Normal" hinting.
// - Linux has configurable font hinting, but most distributions including Ubuntu default to "Light".
#ifdef OSX_ENABLED
- font_hinting = DynamicFontData::HINTING_NONE;
+ font_hinting = TextServer::HINTING_NONE;
#else
- font_hinting = DynamicFontData::HINTING_LIGHT;
+ font_hinting = TextServer::HINTING_LIGHT;
#endif
break;
case 1:
- font_hinting = DynamicFontData::HINTING_NONE;
+ font_hinting = TextServer::HINTING_NONE;
break;
case 2:
- font_hinting = DynamicFontData::HINTING_LIGHT;
+ font_hinting = TextServer::HINTING_LIGHT;
break;
default:
- font_hinting = DynamicFontData::HINTING_NORMAL;
+ font_hinting = TextServer::HINTING_NORMAL;
break;
}
+ int default_font_size = int(EDITOR_GET("interface/editor/main_font_size")) * EDSCALE;
+
String custom_font_path = EditorSettings::get_singleton()->get("interface/editor/main_font");
- Ref<DynamicFontData> CustomFont;
+ Ref<FontData> CustomFont;
if (custom_font_path.length() > 0 && dir->file_exists(custom_font_path)) {
CustomFont.instance();
+ CustomFont->load_resource(custom_font_path, default_font_size);
CustomFont->set_antialiased(font_antialiased);
CustomFont->set_hinting(font_hinting);
- CustomFont->set_font_path(custom_font_path);
CustomFont->set_force_autohinter(true); //just looks better..i think?
} else {
EditorSettings::get_singleton()->set_manually("interface/editor/main_font", "");
@@ -135,12 +141,12 @@ void editor_register_fonts(Ref<Theme> p_theme) {
/* Custom Bold font */
String custom_font_path_bold = EditorSettings::get_singleton()->get("interface/editor/main_font_bold");
- Ref<DynamicFontData> CustomFontBold;
+ Ref<FontData> CustomFontBold;
if (custom_font_path_bold.length() > 0 && dir->file_exists(custom_font_path_bold)) {
CustomFontBold.instance();
+ CustomFontBold->load_resource(custom_font_path_bold, default_font_size);
CustomFontBold->set_antialiased(font_antialiased);
CustomFontBold->set_hinting(font_hinting);
- CustomFontBold->set_font_path(custom_font_path_bold);
CustomFontBold->set_force_autohinter(true); //just looks better..i think?
} else {
EditorSettings::get_singleton()->set_manually("interface/editor/main_font_bold", "");
@@ -149,12 +155,12 @@ void editor_register_fonts(Ref<Theme> p_theme) {
/* Custom source code font */
String custom_font_path_source = EditorSettings::get_singleton()->get("interface/editor/code_font");
- Ref<DynamicFontData> CustomFontSource;
+ Ref<FontData> CustomFontSource;
if (custom_font_path_source.length() > 0 && dir->file_exists(custom_font_path_source)) {
CustomFontSource.instance();
+ CustomFontSource->load_resource(custom_font_path_source, default_font_size);
CustomFontSource->set_antialiased(font_antialiased);
CustomFontSource->set_hinting(font_hinting);
- CustomFontSource->set_font_path(custom_font_path_source);
} else {
EditorSettings::get_singleton()->set_manually("interface/editor/code_font", "");
}
@@ -163,115 +169,167 @@ void editor_register_fonts(Ref<Theme> p_theme) {
/* Droid Sans */
- Ref<DynamicFontData> DefaultFont;
+ Ref<FontData> DefaultFont;
DefaultFont.instance();
+ DefaultFont->load_memory(_font_NotoSansUI_Regular, _font_NotoSansUI_Regular_size, "ttf", default_font_size);
DefaultFont->set_antialiased(font_antialiased);
DefaultFont->set_hinting(font_hinting);
- DefaultFont->set_font_ptr(_font_NotoSansUI_Regular, _font_NotoSansUI_Regular_size);
DefaultFont->set_force_autohinter(true); //just looks better..i think?
- Ref<DynamicFontData> DefaultFontBold;
+ Ref<FontData> DefaultFontBold;
DefaultFontBold.instance();
+ DefaultFontBold->load_memory(_font_NotoSansUI_Bold, _font_NotoSansUI_Bold_size, "ttf", default_font_size);
DefaultFontBold->set_antialiased(font_antialiased);
DefaultFontBold->set_hinting(font_hinting);
- DefaultFontBold->set_font_ptr(_font_NotoSansUI_Bold, _font_NotoSansUI_Bold_size);
DefaultFontBold->set_force_autohinter(true); // just looks better..i think?
- Ref<DynamicFontData> FontFallback;
+ Ref<FontData> FontFallback;
FontFallback.instance();
+ FontFallback->load_memory(_font_DroidSansFallback, _font_DroidSansFallback_size, "ttf", default_font_size);
FontFallback->set_antialiased(font_antialiased);
FontFallback->set_hinting(font_hinting);
- FontFallback->set_font_ptr(_font_DroidSansFallback, _font_DroidSansFallback_size);
FontFallback->set_force_autohinter(true); //just looks better..i think?
- Ref<DynamicFontData> FontJapanese;
+ Ref<FontData> FontJapanese;
FontJapanese.instance();
+ FontJapanese->load_memory(_font_DroidSansJapanese, _font_DroidSansJapanese_size, "ttf", default_font_size);
FontJapanese->set_antialiased(font_antialiased);
FontJapanese->set_hinting(font_hinting);
- FontJapanese->set_font_ptr(_font_DroidSansJapanese, _font_DroidSansJapanese_size);
FontJapanese->set_force_autohinter(true); //just looks better..i think?
- Ref<DynamicFontData> FontArabic;
+ Ref<FontData> FontArabic;
FontArabic.instance();
+ FontArabic->load_memory(_font_NotoNaskhArabicUI_Regular, _font_NotoNaskhArabicUI_Regular_size, "ttf", default_font_size);
FontArabic->set_antialiased(font_antialiased);
FontArabic->set_hinting(font_hinting);
- FontArabic->set_font_ptr(_font_NotoNaskhArabicUI_Regular, _font_NotoNaskhArabicUI_Regular_size);
FontArabic->set_force_autohinter(true); //just looks better..i think?
- Ref<DynamicFontData> FontHebrew;
+ Ref<FontData> FontBengali;
+ FontBengali.instance();
+ FontBengali->load_memory(_font_NotoSansBengali_Regular, _font_NotoSansBengali_Regular_size, "ttf", default_font_size);
+ FontBengali->set_antialiased(font_antialiased);
+ FontBengali->set_hinting(font_hinting);
+ FontBengali->set_force_autohinter(true); //just looks better..i think?
+
+ Ref<FontData> FontGeorgian;
+ FontGeorgian.instance();
+ FontGeorgian->load_memory(_font_NotoSansGeorgian_Regular, _font_NotoSansGeorgian_Regular_size, "ttf", default_font_size);
+ FontGeorgian->set_antialiased(font_antialiased);
+ FontGeorgian->set_hinting(font_hinting);
+ FontGeorgian->set_force_autohinter(true); //just looks better..i think?
+
+ Ref<FontData> FontHebrew;
FontHebrew.instance();
+ FontHebrew->load_memory(_font_NotoSansHebrew_Regular, _font_NotoSansHebrew_Regular_size, "ttf", default_font_size);
FontHebrew->set_antialiased(font_antialiased);
FontHebrew->set_hinting(font_hinting);
- FontHebrew->set_font_ptr(_font_NotoSansHebrew_Regular, _font_NotoSansHebrew_Regular_size);
FontHebrew->set_force_autohinter(true); //just looks better..i think?
- Ref<DynamicFontData> FontThai;
+ Ref<FontData> FontMalayalam;
+ FontMalayalam.instance();
+ FontMalayalam->load_memory(_font_NotoSansMalayalamUI_Regular, _font_NotoSansMalayalamUI_Regular_size, "ttf", default_font_size);
+ FontMalayalam->set_antialiased(font_antialiased);
+ FontMalayalam->set_hinting(font_hinting);
+ FontMalayalam->set_force_autohinter(true); //just looks better..i think?
+
+ Ref<FontData> FontOriya;
+ FontOriya.instance();
+ FontOriya->load_memory(_font_NotoSansOriyaUI_Regular, _font_NotoSansOriyaUI_Regular_size, "ttf", default_font_size);
+ FontOriya->set_antialiased(font_antialiased);
+ FontOriya->set_hinting(font_hinting);
+ FontOriya->set_force_autohinter(true); //just looks better..i think?
+
+ Ref<FontData> FontSinhala;
+ FontSinhala.instance();
+ FontSinhala->load_memory(_font_NotoSansSinhalaUI_Regular, _font_NotoSansSinhalaUI_Regular_size, "ttf", default_font_size);
+ FontSinhala->set_antialiased(font_antialiased);
+ FontSinhala->set_hinting(font_hinting);
+ FontSinhala->set_force_autohinter(true); //just looks better..i think?
+
+ Ref<FontData> FontTamil;
+ FontTamil.instance();
+ FontTamil->load_memory(_font_NotoSansTamilUI_Regular, _font_NotoSansTamilUI_Regular_size, "ttf", default_font_size);
+ FontTamil->set_antialiased(font_antialiased);
+ FontTamil->set_hinting(font_hinting);
+ FontTamil->set_force_autohinter(true); //just looks better..i think?
+
+ Ref<FontData> FontTelugu;
+ FontTelugu.instance();
+ FontTelugu->load_memory(_font_NotoSansTeluguUI_Regular, _font_NotoSansTeluguUI_Regular_size, "ttf", default_font_size);
+ FontTelugu->set_antialiased(font_antialiased);
+ FontTelugu->set_hinting(font_hinting);
+ FontTelugu->set_force_autohinter(true); //just looks better..i think?
+
+ Ref<FontData> FontThai;
FontThai.instance();
+ FontThai->load_memory(_font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size, "ttf", default_font_size);
FontThai->set_antialiased(font_antialiased);
FontThai->set_hinting(font_hinting);
- FontThai->set_font_ptr(_font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size);
FontThai->set_force_autohinter(true); //just looks better..i think?
- Ref<DynamicFontData> FontHindi;
+ Ref<FontData> FontHindi;
FontHindi.instance();
+ FontHindi->load_memory(_font_NotoSansDevanagariUI_Regular, _font_NotoSansDevanagariUI_Regular_size, "ttf", default_font_size);
FontHindi->set_antialiased(font_antialiased);
FontHindi->set_hinting(font_hinting);
- FontHindi->set_font_ptr(_font_NotoSansDevanagariUI_Regular, _font_NotoSansDevanagariUI_Regular_size);
FontHindi->set_force_autohinter(true); //just looks better..i think?
/* Hack */
- Ref<DynamicFontData> dfmono;
+ Ref<FontData> dfmono;
dfmono.instance();
+ dfmono->load_memory(_font_Hack_Regular, _font_Hack_Regular_size, "ttf", default_font_size);
dfmono->set_antialiased(font_antialiased);
dfmono->set_hinting(font_hinting);
- dfmono->set_font_ptr(_font_Hack_Regular, _font_Hack_Regular_size);
-
- int default_font_size = int(EDITOR_GET("interface/editor/main_font_size")) * EDSCALE;
// Default font
- MAKE_DEFAULT_FONT(df, default_font_size);
- p_theme->set_default_font(df); // Default theme font
+ MAKE_DEFAULT_FONT(df);
+ p_theme->set_default_theme_font(df); // Default theme font
+ p_theme->set_default_theme_font_size(default_font_size);
+
+ p_theme->set_font_size("main_size", "EditorFonts", default_font_size);
p_theme->set_font("main", "EditorFonts", df);
// Bold font
- MAKE_BOLD_FONT(df_bold, default_font_size);
+ MAKE_BOLD_FONT(df_bold);
+ p_theme->set_font_size("bold_size", "EditorFonts", default_font_size);
p_theme->set_font("bold", "EditorFonts", df_bold);
// Title font
- MAKE_BOLD_FONT(df_title, default_font_size + 2 * EDSCALE);
- p_theme->set_font("title", "EditorFonts", df_title);
+ p_theme->set_font_size("title_size", "EditorFonts", default_font_size + 2 * EDSCALE);
+ p_theme->set_font("title", "EditorFonts", df_bold);
// Documentation fonts
- MAKE_DEFAULT_FONT(df_doc, int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE);
- MAKE_BOLD_FONT(df_doc_bold, int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE);
- MAKE_BOLD_FONT(df_doc_title, int(EDITOR_GET("text_editor/help/help_title_font_size")) * EDSCALE);
- MAKE_SOURCE_FONT(df_doc_code, int(EDITOR_GET("text_editor/help/help_source_font_size")) * EDSCALE);
- MAKE_SOURCE_FONT(df_doc_kbd, (int(EDITOR_GET("text_editor/help/help_source_font_size")) - 1) * EDSCALE);
- p_theme->set_font("doc", "EditorFonts", df_doc);
- p_theme->set_font("doc_bold", "EditorFonts", df_doc_bold);
- p_theme->set_font("doc_title", "EditorFonts", df_doc_title);
- p_theme->set_font("doc_source", "EditorFonts", df_doc_code);
- p_theme->set_font("doc_keyboard", "EditorFonts", df_doc_kbd);
+ MAKE_SOURCE_FONT(df_code);
+ p_theme->set_font_size("doc_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE);
+ p_theme->set_font("doc", "EditorFonts", df);
+ p_theme->set_font_size("doc_bold_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE);
+ p_theme->set_font("doc_bold", "EditorFonts", df_bold);
+ p_theme->set_font_size("doc_title_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_title_font_size")) * EDSCALE);
+ p_theme->set_font("doc_title", "EditorFonts", df_bold);
+ p_theme->set_font_size("doc_source_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_source_font_size")) * EDSCALE);
+ p_theme->set_font("doc_source", "EditorFonts", df_code);
+ p_theme->set_font_size("doc_keyboard_size", "EditorFonts", (int(EDITOR_GET("text_editor/help/help_source_font_size")) - 1) * EDSCALE);
+ p_theme->set_font("doc_keyboard", "EditorFonts", df_code);
// Ruler font
- MAKE_DEFAULT_FONT(df_rulers, 8 * EDSCALE);
- p_theme->set_font("rulers", "EditorFonts", df_rulers);
+ p_theme->set_font_size("rulers_size", "EditorFonts", 8 * EDSCALE);
+ p_theme->set_font("rulers", "EditorFonts", df);
// Rotation widget font
- MAKE_DEFAULT_FONT(df_rotation_control, 14 * EDSCALE);
- p_theme->set_font("rotation_control", "EditorFonts", df_rotation_control);
+ p_theme->set_font_size("rotation_control_size", "EditorFonts", 14 * EDSCALE);
+ p_theme->set_font("rotation_control", "EditorFonts", df);
// Code font
- MAKE_SOURCE_FONT(df_code, int(EDITOR_GET("interface/editor/code_font_size")) * EDSCALE);
+ p_theme->set_font_size("source_size", "EditorFonts", int(EDITOR_GET("interface/editor/code_font_size")) * EDSCALE);
p_theme->set_font("source", "EditorFonts", df_code);
- MAKE_SOURCE_FONT(df_expression, (int(EDITOR_GET("interface/editor/code_font_size")) - 1) * EDSCALE);
- p_theme->set_font("expression", "EditorFonts", df_expression);
+ p_theme->set_font_size("expression_size", "EditorFonts", (int(EDITOR_GET("interface/editor/code_font_size")) - 1) * EDSCALE);
+ p_theme->set_font("expression", "EditorFonts", df_code);
- MAKE_SOURCE_FONT(df_output_code, int(EDITOR_GET("run/output/font_size")) * EDSCALE);
- p_theme->set_font("output_source", "EditorFonts", df_output_code);
+ p_theme->set_font_size("output_source_size", "EditorFonts", int(EDITOR_GET("run/output/font_size")) * EDSCALE);
+ p_theme->set_font("output_source", "EditorFonts", df_code);
- MAKE_SOURCE_FONT(df_text_editor_status_code, default_font_size);
- p_theme->set_font("status_source", "EditorFonts", df_text_editor_status_code);
+ p_theme->set_font_size("status_source_size", "EditorFonts", default_font_size);
+ p_theme->set_font("status_source", "EditorFonts", df_code);
}
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 30aebd2b1f..4c553950a7 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -40,7 +40,7 @@
#define CONTRIBUTE_URL "https://docs.godotengine.org/en/latest/community/contributing/updating_the_class_reference.html"
-DocData *EditorHelp::doc = nullptr;
+DocTools *EditorHelp::doc = nullptr;
void EditorHelp::_init_colors() {
title_color = get_theme_color("accent_color", "Editor");
@@ -56,19 +56,6 @@ void EditorHelp::_init_colors() {
class_desc->add_theme_constant_override("line_separation", Math::round(5 * EDSCALE));
}
-void EditorHelp::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
- if (!is_visible_in_tree()) {
- return;
- }
-
- Ref<InputEventKey> k = p_ev;
-
- if (k.is_valid() && k->get_control() && k->get_keycode() == KEY_F) {
- search->grab_focus();
- search->select_all();
- }
-}
-
void EditorHelp::_search(bool p_search_previous) {
if (p_search_previous) {
find_bar->search_prev();
@@ -168,7 +155,8 @@ void EditorHelp::_class_desc_resized() {
// Add extra horizontal margins for better readability.
// The margins increase as the width of the editor help container increases.
Ref<Font> doc_code_font = get_theme_font("doc_source", "EditorFonts");
- real_t char_width = doc_code_font->get_char_size('x').width;
+ int font_size = get_theme_font_size("doc_source_size", "EditorFonts");
+ real_t char_width = doc_code_font->get_char_size('x', 0, font_size).width;
const int display_margin = MAX(30 * EDSCALE, get_parent_anchorable_rect().size.width - char_width * 120 * EDSCALE) * 0.5;
Ref<StyleBox> class_desc_stylebox = EditorNode::get_singleton()->get_theme_base()->get_theme_stylebox("normal", "RichTextLabel")->duplicate();
@@ -400,7 +388,7 @@ void EditorHelp::_update_doc() {
}
// Descendents
- if (ClassDB::class_exists(cd.name)) {
+ if (cd.is_script_doc || ClassDB::class_exists(cd.name)) {
bool found = false;
bool prev = false;
@@ -506,7 +494,19 @@ void EditorHelp::_update_doc() {
Set<String> skip_methods;
bool property_descr = false;
- if (cd.properties.size()) {
+ bool has_properties = cd.properties.size() != 0;
+ if (cd.is_script_doc) {
+ has_properties = false;
+ for (int i = 0; i < cd.properties.size(); i++) {
+ if (cd.properties[i].name.begins_with("_") && cd.properties[i].description.empty()) {
+ continue;
+ }
+ has_properties = true;
+ break;
+ }
+ }
+
+ if (has_properties) {
section_line.push_back(Pair<String, int>(TTR("Properties"), class_desc->get_line_count() - 2));
class_desc->push_color(title_color);
class_desc->push_font(doc_title_font);
@@ -521,6 +521,10 @@ void EditorHelp::_update_doc() {
class_desc->set_table_column_expand(1, true);
for (int i = 0; i < cd.properties.size(); i++) {
+ // Ignore undocumented private.
+ if (cd.properties[i].name.begins_with("_") && cd.properties[i].description.empty()) {
+ continue;
+ }
property_line[cd.properties[i].name] = class_desc->get_line_count() - 2; //gets overridden if description
class_desc->push_cell();
@@ -577,6 +581,32 @@ void EditorHelp::_update_doc() {
class_desc->pop();
}
+ if (cd.is_script_doc && (cd.properties[i].setter != "" || cd.properties[i].getter != "")) {
+ class_desc->push_color(symbol_color);
+ class_desc->add_text(" [" + TTR("property:") + " ");
+ class_desc->pop(); // color
+
+ if (cd.properties[i].setter != "") {
+ class_desc->push_color(value_color);
+ class_desc->add_text("setter");
+ class_desc->pop(); // color
+ }
+ if (cd.properties[i].getter != "") {
+ if (cd.properties[i].setter != "") {
+ class_desc->push_color(symbol_color);
+ class_desc->add_text(", ");
+ class_desc->pop(); // color
+ }
+ class_desc->push_color(value_color);
+ class_desc->add_text("getter");
+ class_desc->pop(); // color
+ }
+
+ class_desc->push_color(symbol_color);
+ class_desc->add_text("]");
+ class_desc->pop(); // color
+ }
+
class_desc->pop();
class_desc->pop();
@@ -602,6 +632,10 @@ void EditorHelp::_update_doc() {
continue;
}
}
+ // Ignore undocumented private.
+ if (cd.methods[i].name.begins_with("_") && cd.methods[i].description.empty()) {
+ continue;
+ }
methods.push_back(cd.methods[i]);
}
@@ -814,13 +848,17 @@ void EditorHelp::_update_doc() {
Vector<DocData::ConstantDoc> constants;
for (int i = 0; i < cd.constants.size(); i++) {
- if (cd.constants[i].enumeration != String()) {
+ if (!cd.constants[i].enumeration.empty()) {
if (!enums.has(cd.constants[i].enumeration)) {
enums[cd.constants[i].enumeration] = Vector<DocData::ConstantDoc>();
}
enums[cd.constants[i].enumeration].push_back(cd.constants[i]);
} else {
+ // Ignore undocumented private.
+ if (cd.constants[i].name.begins_with("_") && cd.constants[i].description.empty()) {
+ continue;
+ }
constants.push_back(cd.constants[i]);
}
}
@@ -860,6 +898,19 @@ void EditorHelp::_update_doc() {
class_desc->add_newline();
class_desc->add_newline();
+ // Enum description.
+ if (e != "@unnamed_enums" && cd.enums.has(e)) {
+ class_desc->push_color(text_color);
+ class_desc->push_font(doc_font);
+ class_desc->push_indent(1);
+ _add_text(cd.enums[e]);
+ class_desc->pop();
+ class_desc->pop();
+ class_desc->pop();
+ class_desc->add_newline();
+ class_desc->add_newline();
+ }
+
class_desc->push_indent(1);
Vector<DocData::ConstantDoc> enum_list = E->get();
@@ -1030,60 +1081,89 @@ void EditorHelp::_update_doc() {
class_desc->pop(); // color
}
+ if (cd.is_script_doc && (cd.properties[i].setter != "" || cd.properties[i].getter != "")) {
+ class_desc->push_color(symbol_color);
+ class_desc->add_text(" [" + TTR("property:") + " ");
+ class_desc->pop(); // color
+
+ if (cd.properties[i].setter != "") {
+ class_desc->push_color(value_color);
+ class_desc->add_text("setter");
+ class_desc->pop(); // color
+ }
+ if (cd.properties[i].getter != "") {
+ if (cd.properties[i].setter != "") {
+ class_desc->push_color(symbol_color);
+ class_desc->add_text(", ");
+ class_desc->pop(); // color
+ }
+ class_desc->push_color(value_color);
+ class_desc->add_text("getter");
+ class_desc->pop(); // color
+ }
+
+ class_desc->push_color(symbol_color);
+ class_desc->add_text("]");
+ class_desc->pop(); // color
+ }
+
class_desc->pop(); // font
class_desc->pop(); // cell
- Map<String, DocData::MethodDoc> method_map;
- for (int j = 0; j < methods.size(); j++) {
- method_map[methods[j].name] = methods[j];
- }
+ // Script doc doesn't have setter, getter.
+ if (!cd.is_script_doc) {
+ Map<String, DocData::MethodDoc> method_map;
+ for (int j = 0; j < methods.size(); j++) {
+ method_map[methods[j].name] = methods[j];
+ }
- if (cd.properties[i].setter != "") {
- class_desc->push_cell();
- class_desc->pop(); // cell
+ if (cd.properties[i].setter != "") {
+ class_desc->push_cell();
+ class_desc->pop(); // cell
- class_desc->push_cell();
- class_desc->push_font(doc_code_font);
- class_desc->push_color(text_color);
- if (method_map[cd.properties[i].setter].arguments.size() > 1) {
- // Setters with additional arguments are exposed in the method list, so we link them here for quick access.
- class_desc->push_meta("@method " + cd.properties[i].setter);
- class_desc->add_text(cd.properties[i].setter + TTR("(value)"));
- class_desc->pop();
- } else {
- class_desc->add_text(cd.properties[i].setter + TTR("(value)"));
+ class_desc->push_cell();
+ class_desc->push_font(doc_code_font);
+ class_desc->push_color(text_color);
+ if (method_map[cd.properties[i].setter].arguments.size() > 1) {
+ // Setters with additional arguments are exposed in the method list, so we link them here for quick access.
+ class_desc->push_meta("@method " + cd.properties[i].setter);
+ class_desc->add_text(cd.properties[i].setter + TTR("(value)"));
+ class_desc->pop();
+ } else {
+ class_desc->add_text(cd.properties[i].setter + TTR("(value)"));
+ }
+ class_desc->pop(); // color
+ class_desc->push_color(comment_color);
+ class_desc->add_text(" setter");
+ class_desc->pop(); // color
+ class_desc->pop(); // font
+ class_desc->pop(); // cell
+ method_line[cd.properties[i].setter] = property_line[cd.properties[i].name];
}
- class_desc->pop(); // color
- class_desc->push_color(comment_color);
- class_desc->add_text(" setter");
- class_desc->pop(); // color
- class_desc->pop(); // font
- class_desc->pop(); // cell
- method_line[cd.properties[i].setter] = property_line[cd.properties[i].name];
- }
- if (cd.properties[i].getter != "") {
- class_desc->push_cell();
- class_desc->pop(); // cell
+ if (cd.properties[i].getter != "") {
+ class_desc->push_cell();
+ class_desc->pop(); // cell
- class_desc->push_cell();
- class_desc->push_font(doc_code_font);
- class_desc->push_color(text_color);
- if (method_map[cd.properties[i].getter].arguments.size() > 0) {
- // Getters with additional arguments are exposed in the method list, so we link them here for quick access.
- class_desc->push_meta("@method " + cd.properties[i].getter);
- class_desc->add_text(cd.properties[i].getter + "()");
- class_desc->pop();
- } else {
- class_desc->add_text(cd.properties[i].getter + "()");
+ class_desc->push_cell();
+ class_desc->push_font(doc_code_font);
+ class_desc->push_color(text_color);
+ if (method_map[cd.properties[i].getter].arguments.size() > 0) {
+ // Getters with additional arguments are exposed in the method list, so we link them here for quick access.
+ class_desc->push_meta("@method " + cd.properties[i].getter);
+ class_desc->add_text(cd.properties[i].getter + "()");
+ class_desc->pop();
+ } else {
+ class_desc->add_text(cd.properties[i].getter + "()");
+ }
+ class_desc->pop(); //color
+ class_desc->push_color(comment_color);
+ class_desc->add_text(" getter");
+ class_desc->pop(); //color
+ class_desc->pop(); //font
+ class_desc->pop(); //cell
+ method_line[cd.properties[i].getter] = property_line[cd.properties[i].name];
}
- class_desc->pop(); //color
- class_desc->push_color(comment_color);
- class_desc->add_text(" getter");
- class_desc->pop(); //color
- class_desc->pop(); //font
- class_desc->pop(); //cell
- method_line[cd.properties[i].getter] = property_line[cd.properties[i].name];
}
class_desc->pop(); // table
@@ -1094,13 +1174,17 @@ void EditorHelp::_update_doc() {
class_desc->push_color(text_color);
class_desc->push_font(doc_font);
class_desc->push_indent(1);
- if (cd.properties[i].description.strip_edges() != String()) {
+ if (!cd.properties[i].description.strip_edges().empty()) {
_add_text(DTR(cd.properties[i].description));
} else {
class_desc->add_image(get_theme_icon("Error", "EditorIcons"));
class_desc->add_text(" ");
class_desc->push_color(comment_color);
- class_desc->append_bbcode(TTR("There is currently no description for this property. Please help us by [color=$color][url=$url]contributing one[/url][/color]!").replace("$url", CONTRIBUTE_URL).replace("$color", link_color_text));
+ if (cd.is_script_doc) {
+ class_desc->append_bbcode(TTR("There is currently no description for this property."));
+ } else {
+ class_desc->append_bbcode(TTR("There is currently no description for this property. Please help us by [color=$color][url=$url]contributing one[/url][/color]!").replace("$url", CONTRIBUTE_URL).replace("$color", link_color_text));
+ }
class_desc->pop();
}
class_desc->pop();
@@ -1145,13 +1229,17 @@ void EditorHelp::_update_doc() {
class_desc->push_color(text_color);
class_desc->push_font(doc_font);
class_desc->push_indent(1);
- if (methods_filtered[i].description.strip_edges() != String()) {
+ if (!methods_filtered[i].description.strip_edges().empty()) {
_add_text(DTR(methods_filtered[i].description));
} else {
class_desc->add_image(get_theme_icon("Error", "EditorIcons"));
class_desc->add_text(" ");
class_desc->push_color(comment_color);
- class_desc->append_bbcode(TTR("There is currently no description for this method. Please help us by [color=$color][url=$url]contributing one[/url][/color]!").replace("$url", CONTRIBUTE_URL).replace("$color", link_color_text));
+ if (cd.is_script_doc) {
+ class_desc->append_bbcode(TTR("There is currently no description for this method."));
+ } else {
+ class_desc->append_bbcode(TTR("There is currently no description for this method. Please help us by [color=$color][url=$url]contributing one[/url][/color]!").replace("$url", CONTRIBUTE_URL).replace("$color", link_color_text));
+ }
class_desc->pop();
}
@@ -1235,7 +1323,7 @@ void EditorHelp::_help_callback(const String &p_topic) {
}
static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
- DocData *doc = EditorHelp::get_doc_data();
+ DocTools *doc = EditorHelp::get_doc_data();
String base_path;
Ref<Font> doc_font = p_rt->get_theme_font("doc", "EditorFonts");
@@ -1530,9 +1618,9 @@ void EditorHelp::_add_text(const String &p_bbcode) {
}
void EditorHelp::generate_doc() {
- doc = memnew(DocData);
+ doc = memnew(DocTools);
doc->generate(true);
- DocData compdoc;
+ DocTools compdoc;
compdoc.load_compressed(_doc_data_compressed, _doc_data_compressed_size, _doc_data_uncompressed_size);
doc->merge_from(compdoc); //ensure all is up to date
}
@@ -1561,6 +1649,12 @@ void EditorHelp::go_to_class(const String &p_class, int p_scroll) {
_goto_desc(p_class, p_scroll);
}
+void EditorHelp::update_doc() {
+ ERR_FAIL_COND(!doc->class_list.has(edited_class));
+ ERR_FAIL_COND(!doc->class_list[edited_class].is_script_doc);
+ _update_doc();
+}
+
Vector<Pair<String, int>> EditorHelp::get_sections() {
Vector<Pair<String, int>> sections;
@@ -1598,7 +1692,6 @@ void EditorHelp::set_scroll(int p_scroll) {
void EditorHelp::_bind_methods() {
ClassDB::bind_method("_class_list_select", &EditorHelp::_class_list_select);
ClassDB::bind_method("_request_help", &EditorHelp::_request_help);
- ClassDB::bind_method("_unhandled_key_input", &EditorHelp::_unhandled_key_input);
ClassDB::bind_method("_search", &EditorHelp::_search);
ClassDB::bind_method("_help_callback", &EditorHelp::_help_callback);
diff --git a/editor/editor_help.h b/editor/editor_help.h
index b69b6d7401..737f841d30 100644
--- a/editor/editor_help.h
+++ b/editor/editor_help.h
@@ -32,7 +32,7 @@
#define EDITOR_HELP_H
#include "editor/code_editor.h"
-#include "editor/doc_data.h"
+#include "editor/doc_tools.h"
#include "editor/editor_plugin.h"
#include "scene/gui/margin_container.h"
#include "scene/gui/menu_button.h"
@@ -118,7 +118,7 @@ class EditorHelp : public VBoxContainer {
RichTextLabel *class_desc;
HSplitContainer *h_split;
- static DocData *doc;
+ static DocTools *doc;
ConfirmationDialog *search_dialog;
LineEdit *search;
@@ -158,8 +158,6 @@ class EditorHelp : public VBoxContainer {
void _request_help(const String &p_string);
void _search(bool p_search_previous = false);
- void _unhandled_key_input(const Ref<InputEvent> &p_ev);
-
String _fix_constant(const String &p_constant) const;
protected:
@@ -168,10 +166,11 @@ protected:
public:
static void generate_doc();
- static DocData *get_doc_data() { return doc; }
+ static DocTools *get_doc_data() { return doc; }
void go_to_help(const String &p_help);
void go_to_class(const String &p_class, int p_scroll = 0);
+ void update_doc();
Vector<Pair<String, int>> get_sections();
void scroll_to_section(int p_section_index);
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 371100652f..d88a0e3ff8 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -32,6 +32,7 @@
#include "array_property_edit.h"
#include "dictionary_property_edit.h"
+#include "editor/doc_tools.h"
#include "editor_feature_profile.h"
#include "editor_node.h"
#include "editor_scale.h"
@@ -41,7 +42,8 @@
Size2 EditorProperty::get_minimum_size() const {
Size2 ms;
Ref<Font> font = get_theme_font("font", "Tree");
- ms.height = font->get_height();
+ int font_size = get_theme_font_size("font_size", "Tree");
+ ms.height = font->get_height(font_size);
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
@@ -108,7 +110,8 @@ void EditorProperty::_notification(int p_what) {
{
int child_room = size.width * (1.0 - split_ratio);
Ref<Font> font = get_theme_font("font", "Tree");
- int height = font->get_height();
+ int font_size = get_theme_font_size("font_size", "Tree");
+ int height = font->get_height(font_size);
bool no_children = true;
//compute room needed
@@ -135,7 +138,11 @@ void EditorProperty::_notification(int p_what) {
rect = Rect2(size.width - 1, 0, 1, height);
} else {
text_size = MAX(0, size.width - (child_room + 4 * EDSCALE));
- rect = Rect2(size.width - child_room, 0, child_room, height);
+ if (is_layout_rtl()) {
+ rect = Rect2(1, 0, child_room, height);
+ } else {
+ rect = Rect2(size.width - child_room, 0, child_room, height);
+ }
}
if (bottom_editor) {
@@ -154,6 +161,9 @@ void EditorProperty::_notification(int p_what) {
}
rect.size.x -= key->get_width() + get_theme_constant("hseparator", "Tree");
+ if (is_layout_rtl()) {
+ rect.position.x += key->get_width() + get_theme_constant("hseparator", "Tree");
+ }
if (no_children) {
text_size -= key->get_width() + 4 * EDSCALE;
@@ -167,6 +177,10 @@ void EditorProperty::_notification(int p_what) {
rect.size.x -= close->get_width() + get_theme_constant("hseparator", "Tree");
+ if (is_layout_rtl()) {
+ rect.position.x += close->get_width() + get_theme_constant("hseparator", "Tree");
+ }
+
if (no_children) {
text_size -= close->get_width() + 4 * EDSCALE;
}
@@ -200,7 +214,9 @@ void EditorProperty::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
Ref<Font> font = get_theme_font("font", "Tree");
+ int font_size = get_theme_font_size("font_size", "Tree");
Color dark_color = get_theme_color("dark_color_2", "Editor");
+ bool rtl = is_layout_rtl();
Size2 size = get_size();
if (bottom_editor) {
@@ -249,7 +265,11 @@ void EditorProperty::_notification(int p_what) {
color2.b *= 1.2;
}
check_rect = Rect2(ofs, ((size.height - checkbox->get_height()) / 2), checkbox->get_width(), checkbox->get_height());
- draw_texture(checkbox, check_rect.position, color2);
+ if (rtl) {
+ draw_texture(checkbox, Vector2(size.width - check_rect.position.x - checkbox->get_width(), check_rect.position.y), color2);
+ } else {
+ draw_texture(checkbox, check_rect.position, color2);
+ }
ofs += get_theme_constant("hseparator", "Tree") + checkbox->get_width() + get_theme_constant("hseparation", "CheckBox");
text_limit -= ofs;
} else {
@@ -267,14 +287,21 @@ void EditorProperty::_notification(int p_what) {
color2.g *= 1.2;
color2.b *= 1.2;
}
-
- draw_texture(reload_icon, revert_rect.position, color2);
+ if (rtl) {
+ draw_texture(reload_icon, Vector2(size.width - revert_rect.position.x - reload_icon->get_width(), revert_rect.position.y), color2);
+ } else {
+ draw_texture(reload_icon, revert_rect.position, color2);
+ }
} else {
revert_rect = Rect2();
}
- int v_ofs = (size.height - font->get_height()) / 2;
- draw_string(font, Point2(ofs, v_ofs + font->get_ascent()), label, color, text_limit);
+ int v_ofs = (size.height - font->get_height(font_size)) / 2;
+ if (rtl) {
+ draw_string(font, Point2(size.width - ofs - text_limit, v_ofs + font->get_ascent(font_size)), label, HALIGN_RIGHT, text_limit, font_size, color);
+ } else {
+ draw_string(font, Point2(ofs, v_ofs + font->get_ascent(font_size)), label, HALIGN_LEFT, text_limit, font_size, color);
+ }
if (keying) {
Ref<Texture2D> key;
@@ -294,7 +321,12 @@ void EditorProperty::_notification(int p_what) {
color2.b *= 1.2;
}
keying_rect = Rect2(ofs, ((size.height - key->get_height()) / 2), key->get_width(), key->get_height());
- draw_texture(key, keying_rect.position, color2);
+ if (rtl) {
+ draw_texture(key, Vector2(size.width - keying_rect.position.x - key->get_width(), keying_rect.position.y), color2);
+ } else {
+ draw_texture(key, keying_rect.position, color2);
+ }
+
} else {
keying_rect = Rect2();
}
@@ -313,7 +345,11 @@ void EditorProperty::_notification(int p_what) {
color2.b *= 1.2;
}
delete_rect = Rect2(ofs, ((size.height - close->get_height()) / 2), close->get_width(), close->get_height());
- draw_texture(close, delete_rect.position, color2);
+ if (rtl) {
+ draw_texture(close, Vector2(size.width - delete_rect.position.x - close->get_width(), delete_rect.position.y), color2);
+ } else {
+ draw_texture(close, delete_rect.position, color2);
+ }
} else {
delete_rect = Rect2();
}
@@ -648,27 +684,31 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouse> me = p_event;
if (me.is_valid()) {
+ Vector2 mpos = me->get_position();
+ if (is_layout_rtl()) {
+ mpos.x = get_size().x - mpos.x;
+ }
bool button_left = me->get_button_mask() & BUTTON_MASK_LEFT;
- bool new_keying_hover = keying_rect.has_point(me->get_position()) && !button_left;
+ bool new_keying_hover = keying_rect.has_point(mpos) && !button_left;
if (new_keying_hover != keying_hover) {
keying_hover = new_keying_hover;
update();
}
- bool new_delete_hover = delete_rect.has_point(me->get_position()) && !button_left;
+ bool new_delete_hover = delete_rect.has_point(mpos) && !button_left;
if (new_delete_hover != delete_hover) {
delete_hover = new_delete_hover;
update();
}
- bool new_revert_hover = revert_rect.has_point(me->get_position()) && !button_left;
+ bool new_revert_hover = revert_rect.has_point(mpos) && !button_left;
if (new_revert_hover != revert_hover) {
revert_hover = new_revert_hover;
update();
}
- bool new_check_hover = check_rect.has_point(me->get_position()) && !button_left;
+ bool new_check_hover = check_rect.has_point(mpos) && !button_left;
if (new_check_hover != check_hover) {
check_hover = new_check_hover;
update();
@@ -678,13 +718,18 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+ Vector2 mpos = mb->get_position();
+ if (is_layout_rtl()) {
+ mpos.x = get_size().x - mpos.x;
+ }
+
if (!selected && selectable) {
selected = true;
emit_signal("selected", property, -1);
update();
}
- if (keying_rect.has_point(mb->get_position())) {
+ if (keying_rect.has_point(mpos)) {
emit_signal("property_keyed", property, use_keying_next());
if (use_keying_next()) {
@@ -704,11 +749,11 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
call_deferred("update_property");
}
}
- if (delete_rect.has_point(mb->get_position())) {
+ if (delete_rect.has_point(mpos)) {
emit_signal("property_deleted", property);
}
- if (revert_rect.has_point(mb->get_position())) {
+ if (revert_rect.has_point(mpos)) {
Variant vorig;
Node *node = Object::cast_to<Node>(object);
@@ -744,7 +789,7 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
return;
}
}
- if (check_rect.has_point(mb->get_position())) {
+ if (check_rect.has_point(mpos)) {
checked = !checked;
update();
emit_signal("property_checked", property, checked);
@@ -1024,10 +1069,11 @@ void EditorInspectorCategory::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
draw_rect(Rect2(Vector2(), get_size()), bg_color);
Ref<Font> font = get_theme_font("font", "Tree");
+ int font_size = get_theme_font_size("font_size", "Tree");
int hs = get_theme_constant("hseparation", "Tree");
- int w = font->get_string_size(label).width;
+ int w = font->get_string_size(label, font_size).width;
if (icon.is_valid()) {
w += hs + icon->get_width();
}
@@ -1040,7 +1086,7 @@ void EditorInspectorCategory::_notification(int p_what) {
}
Color color = get_theme_color("font_color", "Tree");
- draw_string(font, Point2(ofs, font->get_ascent() + (get_size().height - font->get_height()) / 2).floor(), label, color, get_size().width);
+ draw_string(font, Point2(ofs, font->get_ascent(font_size) + (get_size().height - font->get_height(font_size)) / 2).floor(), label, HALIGN_LEFT, get_size().width, font_size, color);
}
}
@@ -1069,10 +1115,11 @@ Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) cons
Size2 EditorInspectorCategory::get_minimum_size() const {
Ref<Font> font = get_theme_font("font", "Tree");
+ int font_size = get_theme_font_size("font_size", "Tree");
Size2 ms;
ms.width = 1;
- ms.height = font->get_height();
+ ms.height = font->get_height(font_size);
if (icon.is_valid()) {
ms.height = MAX(icon->get_height(), ms.height);
}
@@ -1105,19 +1152,24 @@ void EditorInspectorSection::_test_unfold() {
void EditorInspectorSection::_notification(int p_what) {
if (p_what == NOTIFICATION_SORT_CHILDREN) {
Ref<Font> font = get_theme_font("font", "Tree");
+ int font_size = get_theme_font_size("font_size", "Tree");
Ref<Texture2D> arrow;
if (foldable) {
if (object->editor_is_section_unfolded(section)) {
arrow = get_theme_icon("arrow", "Tree");
} else {
- arrow = get_theme_icon("arrow_collapsed", "Tree");
+ if (is_layout_rtl()) {
+ arrow = get_theme_icon("arrow_collapsed_mirrored", "Tree");
+ } else {
+ arrow = get_theme_icon("arrow_collapsed", "Tree");
+ }
}
}
Size2 size = get_size();
Point2 offset;
- offset.y = font->get_height();
+ offset.y = font->get_height(font_size);
if (arrow.is_valid()) {
offset.y = MAX(offset.y, arrow->get_height());
}
@@ -1148,18 +1200,20 @@ void EditorInspectorSection::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
Ref<Texture2D> arrow;
+ bool rtl = is_layout_rtl();
if (foldable) {
- if (object->editor_is_section_unfolded(section)) {
- arrow = get_theme_icon("arrow", "Tree");
+ if (rtl) {
+ arrow = get_theme_icon("arrow_collapsed_mirrored", "Tree");
} else {
arrow = get_theme_icon("arrow_collapsed", "Tree");
}
}
Ref<Font> font = get_theme_font("font", "Tree");
+ int font_size = get_theme_font_size("font_size", "Tree");
- int h = font->get_height();
+ int h = font->get_height(font_size);
if (arrow.is_valid()) {
h = MAX(h, arrow->get_height());
}
@@ -1169,10 +1223,15 @@ void EditorInspectorSection::_notification(int p_what) {
const int arrow_margin = 3;
Color color = get_theme_color("font_color", "Tree");
- draw_string(font, Point2(Math::round((16 + arrow_margin) * EDSCALE), font->get_ascent() + (h - font->get_height()) / 2).floor(), label, color, get_size().width);
+ float text_width = get_size().width - Math::round((16 + arrow_margin) * EDSCALE);
+ draw_string(font, Point2(rtl ? 0 : Math::round((16 + arrow_margin) * EDSCALE), font->get_ascent(font_size) + (h - font->get_height(font_size)) / 2).floor(), label, rtl ? HALIGN_RIGHT : HALIGN_LEFT, text_width, font_size, color);
if (arrow.is_valid()) {
- draw_texture(arrow, Point2(Math::round(arrow_margin * EDSCALE), (h - arrow->get_height()) / 2).floor());
+ if (rtl) {
+ draw_texture(arrow, Point2(get_size().width - arrow->get_width() - Math::round(arrow_margin * EDSCALE), (h - arrow->get_height()) / 2).floor());
+ } else {
+ draw_texture(arrow, Point2(Math::round(arrow_margin * EDSCALE), (h - arrow->get_height()) / 2).floor());
+ }
}
if (dropping && !vbox->is_visible_in_tree()) {
@@ -1237,7 +1296,8 @@ Size2 EditorInspectorSection::get_minimum_size() const {
}
Ref<Font> font = get_theme_font("font", "Tree");
- ms.height += font->get_height() + get_theme_constant("vseparation", "Tree");
+ int font_size = get_theme_font_size("font_size", "Tree");
+ ms.height += font->get_height(font_size) + get_theme_constant("vseparation", "Tree");
ms.width += get_theme_constant("inspector_margin", "Editor");
return ms;
@@ -1273,7 +1333,8 @@ void EditorInspectorSection::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
Ref<Font> font = get_theme_font("font", "Tree");
- if (mb->get_position().y > font->get_height()) { //clicked outside
+ int font_size = get_theme_font_size("font_size", "Tree");
+ if (mb->get_position().y > font->get_height(font_size)) { //clicked outside
return;
}
@@ -1648,7 +1709,7 @@ void EditorInspector::update_tree() {
StringName type2 = p.name;
if (!class_descr_cache.has(type2)) {
String descr;
- DocData *dd = EditorHelp::get_doc_data();
+ DocTools *dd = EditorHelp::get_doc_data();
Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(type2);
if (E) {
descr = DTR(E->get().brief_description);
@@ -1818,7 +1879,7 @@ void EditorInspector::update_tree() {
}
if (!found) {
- DocData *dd = EditorHelp::get_doc_data();
+ DocTools *dd = EditorHelp::get_doc_data();
Map<String, DocData::ClassDoc>::Element *F = dd->class_list.find(classname);
while (F && descr == String()) {
for (int i = 0; i < F->get().properties.size(); i++) {
diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h
index 36b80a7dd4..10b1013486 100644
--- a/editor/editor_inspector.h
+++ b/editor/editor_inspector.h
@@ -69,13 +69,13 @@ private:
Rect2 bottom_child_rect;
Rect2 keying_rect;
- bool keying_hover;
+ bool keying_hover = false;
Rect2 revert_rect;
- bool revert_hover;
+ bool revert_hover = false;
Rect2 check_rect;
- bool check_hover;
+ bool check_hover = false;
Rect2 delete_rect;
- bool delete_hover;
+ bool delete_hover = false;
bool can_revert;
diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp
index 6fbafc7ff3..371cabfe3d 100644
--- a/editor/editor_log.cpp
+++ b/editor/editor_log.cpp
@@ -35,7 +35,7 @@
#include "editor_node.h"
#include "editor_scale.h"
#include "scene/gui/center_container.h"
-#include "scene/resources/dynamic_font.h"
+#include "scene/resources/font.h"
void EditorLog::_error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, ErrorHandlerType p_type) {
EditorLog *self = (EditorLog *)p_self;
@@ -61,12 +61,14 @@ void EditorLog::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
//button->set_icon(get_icon("Console","EditorIcons"));
log->add_theme_font_override("normal_font", get_theme_font("output_source", "EditorFonts"));
+ log->add_theme_font_size_override("normal_font_size", get_theme_font_size("output_source_size", "EditorFonts"));
log->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
} else if (p_what == NOTIFICATION_THEME_CHANGED) {
- Ref<DynamicFont> df_output_code = get_theme_font("output_source", "EditorFonts");
+ Ref<Font> df_output_code = get_theme_font("output_source", "EditorFonts");
if (df_output_code.is_valid()) {
if (log != nullptr) {
log->add_theme_font_override("normal_font", get_theme_font("output_source", "EditorFonts"));
+ log->add_theme_font_size_override("normal_font_size", get_theme_font_size("output_source_size", "EditorFonts"));
log->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
}
}
@@ -160,12 +162,14 @@ EditorLog::EditorLog() {
hb->add_child(copybutton);
copybutton->set_text(TTR("Copy"));
copybutton->set_shortcut(ED_SHORTCUT("editor/copy_output", TTR("Copy Selection"), KEY_MASK_CMD | KEY_C));
+ copybutton->set_shortcut_context(this);
copybutton->connect("pressed", callable_mp(this, &EditorLog::_copy_request));
clearbutton = memnew(Button);
hb->add_child(clearbutton);
clearbutton->set_text(TTR("Clear"));
clearbutton->set_shortcut(ED_SHORTCUT("editor/clear_output", TTR("Clear Output"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_K));
+ clearbutton->set_shortcut_context(this);
clearbutton->connect("pressed", callable_mp(this, &EditorLog::_clear_request));
log = memnew(RichTextLabel);
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 977bb4b813..27be3bcc14 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -125,6 +125,7 @@
#include "editor/plugins/debugger_editor_plugin.h"
#include "editor/plugins/editor_debugger_plugin.h"
#include "editor/plugins/editor_preview_plugins.h"
+#include "editor/plugins/font_editor_plugin.h"
#include "editor/plugins/gi_probe_editor_plugin.h"
#include "editor/plugins/gpu_particles_2d_editor_plugin.h"
#include "editor/plugins/gpu_particles_3d_editor_plugin.h"
@@ -140,6 +141,7 @@
#include "editor/plugins/multimesh_editor_plugin.h"
#include "editor/plugins/navigation_polygon_editor_plugin.h"
#include "editor/plugins/node_3d_editor_plugin.h"
+#include "editor/plugins/ot_features_plugin.h"
#include "editor/plugins/packed_scene_translation_parser_plugin.h"
#include "editor/plugins/path_2d_editor_plugin.h"
#include "editor/plugins/path_3d_editor_plugin.h"
@@ -336,7 +338,11 @@ void EditorNode::_update_scene_tabs() {
if (scene_tabs->get_offset_buttons_visible()) {
// move add button to fixed position on the tabbar
if (scene_tab_add->get_parent() == scene_tabs) {
- scene_tab_add->set_position(Point2(0, 0));
+ if (scene_tabs->is_layout_rtl()) {
+ scene_tab_add->set_position(Point2(tabbar_container->get_size().x - scene_tab_add->get_size().x, 0));
+ } else {
+ scene_tab_add->set_position(Point2(0, 0));
+ }
scene_tabs->remove_child(scene_tab_add);
tabbar_container->add_child(scene_tab_add);
tabbar_container->move_child(scene_tab_add, 1);
@@ -351,7 +357,11 @@ void EditorNode::_update_scene_tabs() {
if (scene_tabs->get_tab_count() != 0) {
last_tab = scene_tabs->get_tab_rect(scene_tabs->get_tab_count() - 1);
}
- scene_tab_add->set_position(Point2(last_tab.get_position().x + last_tab.get_size().x + 3, last_tab.get_position().y));
+ if (scene_tabs->is_layout_rtl()) {
+ scene_tab_add->set_position(Point2(last_tab.get_position().x - scene_tab_add->get_size().x - 3, last_tab.get_position().y));
+ } else {
+ scene_tab_add->set_position(Point2(last_tab.get_position().x + last_tab.get_size().x + 3, last_tab.get_position().y));
+ }
}
}
@@ -652,8 +662,13 @@ void EditorNode::_notification(int p_what) {
bottom_panel_raise->set_icon(gui_base->get_theme_icon("ExpandBottomDock", "EditorIcons"));
// clear_button->set_icon(gui_base->get_icon("Close", "EditorIcons")); don't have access to that node. needs to become a class property
- dock_tab_move_left->set_icon(theme->get_icon("Back", "EditorIcons"));
- dock_tab_move_right->set_icon(theme->get_icon("Forward", "EditorIcons"));
+ if (gui_base->is_layout_rtl()) {
+ dock_tab_move_left->set_icon(theme->get_icon("Forward", "EditorIcons"));
+ dock_tab_move_right->set_icon(theme->get_icon("Back", "EditorIcons"));
+ } else {
+ dock_tab_move_left->set_icon(theme->get_icon("Back", "EditorIcons"));
+ dock_tab_move_right->set_icon(theme->get_icon("Forward", "EditorIcons"));
+ }
PopupMenu *p = help_menu->get_popup();
p->set_item_icon(p->get_item_index(HELP_SEARCH), gui_base->get_theme_icon("HelpSearch", "EditorIcons"));
@@ -5883,7 +5898,11 @@ EditorNode::EditorNode() {
HBoxContainer *dock_hb = memnew(HBoxContainer);
dock_tab_move_left = memnew(Button);
dock_tab_move_left->set_flat(true);
- dock_tab_move_left->set_icon(theme->get_icon("Back", "EditorIcons"));
+ if (gui_base->is_layout_rtl()) {
+ dock_tab_move_left->set_icon(theme->get_icon("Forward", "EditorIcons"));
+ } else {
+ dock_tab_move_left->set_icon(theme->get_icon("Back", "EditorIcons"));
+ }
dock_tab_move_left->set_focus_mode(Control::FOCUS_NONE);
dock_tab_move_left->connect("pressed", callable_mp(this, &EditorNode::_dock_move_left));
dock_hb->add_child(dock_tab_move_left);
@@ -5896,7 +5915,11 @@ EditorNode::EditorNode() {
dock_tab_move_right = memnew(Button);
dock_tab_move_right->set_flat(true);
- dock_tab_move_right->set_icon(theme->get_icon("Forward", "EditorIcons"));
+ if (gui_base->is_layout_rtl()) {
+ dock_tab_move_right->set_icon(theme->get_icon("Forward", "EditorIcons"));
+ } else {
+ dock_tab_move_right->set_icon(theme->get_icon("Back", "EditorIcons"));
+ }
dock_tab_move_right->set_focus_mode(Control::FOCUS_NONE);
dock_tab_move_right->connect("pressed", callable_mp(this, &EditorNode::_dock_move_right));
@@ -6354,6 +6377,7 @@ EditorNode::EditorNode() {
video_driver->set_focus_mode(Control::FOCUS_NONE);
video_driver->connect("item_selected", callable_mp(this, &EditorNode::_video_driver_selected));
video_driver->add_theme_font_override("font", gui_base->get_theme_font("bold", "EditorFonts"));
+ video_driver->add_theme_font_size_override("font_size", gui_base->get_theme_font_size("bold_size", "EditorFonts"));
// TODO re-enable when GLES2 is ported
video_driver->set_disabled(true);
right_menu_hb->add_child(video_driver);
@@ -6653,6 +6677,8 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(GradientEditorPlugin(this)));
add_editor_plugin(memnew(CollisionShape2DEditorPlugin(this)));
add_editor_plugin(memnew(CurveEditorPlugin(this)));
+ add_editor_plugin(memnew(FontEditorPlugin(this)));
+ add_editor_plugin(memnew(OpenTypeFeaturesEditorPlugin(this)));
add_editor_plugin(memnew(TextureEditorPlugin(this)));
add_editor_plugin(memnew(TextureLayeredEditorPlugin(this)));
add_editor_plugin(memnew(Texture3DEditorPlugin(this)));
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 1443302f3f..2c4e403a81 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -36,7 +36,7 @@
#include "editor_properties_array_dict.h"
#include "editor_scale.h"
#include "scene/main/window.h"
-#include "scene/resources/dynamic_font.h"
+#include "scene/resources/font.h"
///////////////////// NULL /////////////////////////
@@ -146,7 +146,8 @@ void EditorPropertyMultilineText::_notification(int p_what) {
Ref<Texture2D> df = get_theme_icon("DistractionFree", "EditorIcons");
open_big_text->set_icon(df);
Ref<Font> font = get_theme_font("font", "Label");
- text->set_custom_minimum_size(Vector2(0, font->get_height() * 6));
+ int font_size = get_theme_font_size("font_size", "Label");
+ text->set_custom_minimum_size(Vector2(0, font->get_height(font_size) * 6));
} break;
}
@@ -290,6 +291,7 @@ EditorPropertyPath::EditorPropertyPath() {
HBoxContainer *path_hb = memnew(HBoxContainer);
add_child(path_hb);
path = memnew(LineEdit);
+ path->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE);
path_hb->add_child(path);
path->connect("text_entered", callable_mp(this, &EditorPropertyPath::_path_selected));
path->connect("focus_exited", callable_mp(this, &EditorPropertyPath::_path_focus_exited));
@@ -587,7 +589,8 @@ public:
virtual Size2 get_minimum_size() const override {
Ref<Font> font = get_theme_font("font", "Label");
- return Vector2(0, font->get_height() * 2);
+ int font_size = get_theme_font_size("font_size", "Label");
+ return Vector2(0, font->get_height(font_size) * 2);
}
virtual String get_tooltip(const Point2 &p_pos) const override {
@@ -985,6 +988,7 @@ void EditorPropertyEasing::_draw_easing() {
const float exp = get_edited_object()->get(get_edited_property());
const Ref<Font> f = get_theme_font("font", "Label");
+ int font_size = get_theme_font_size("font_size", "Label");
const Color font_color = get_theme_color("font_color", "Label");
Color line_color;
if (dragging) {
@@ -1022,7 +1026,7 @@ void EditorPropertyEasing::_draw_easing() {
} else {
decimals = 1;
}
- f->draw(ci, Point2(10, 10 + f->get_ascent()), rtos(exp).pad_decimals(decimals), font_color);
+ f->draw_string(ci, Point2(10, 10 + f->get_ascent(font_size)), TS->format_number(rtos(exp).pad_decimals(decimals)), HALIGN_LEFT, -1, font_size, font_color);
}
void EditorPropertyEasing::update_property() {
@@ -1039,7 +1043,7 @@ void EditorPropertyEasing::_set_preset(int p_preset) {
void EditorPropertyEasing::_setup_spin() {
setting = true;
spin->setup_and_show();
- spin->get_line_edit()->set_text(rtos(get_edited_object()->get(get_edited_property())));
+ spin->get_line_edit()->set_text(TS->format_number(rtos(get_edited_object()->get(get_edited_property()))));
setting = false;
spin->show();
}
@@ -1088,7 +1092,7 @@ void EditorPropertyEasing::_notification(int p_what) {
preset->add_icon_item(get_theme_icon("CurveInOut", "EditorIcons"), "In-Out", EASING_IN_OUT);
preset->add_icon_item(get_theme_icon("CurveOutIn", "EditorIcons"), "Out-In", EASING_OUT_IN);
}
- easing_draw->set_custom_minimum_size(Size2(0, get_theme_font("font", "Label")->get_height() * 2));
+ easing_draw->set_custom_minimum_size(Size2(0, get_theme_font("font", "Label")->get_height(get_theme_font_size("font_size", "Label")) * 2));
} break;
}
}
@@ -3016,7 +3020,7 @@ bool EditorPropertyResource::_is_drop_valid(const Dictionary &p_drag_data) const
} else if (at == "ShaderMaterial") {
allowed_types.append("Shader");
} else if (at == "Font") {
- allowed_types.append("DynamicFontData");
+ allowed_types.append("FontData");
}
}
@@ -3115,9 +3119,9 @@ void EditorPropertyResource::drop_data_fw(const Point2 &p_point, const Variant &
break;
}
- if (at == "Font" && ClassDB::is_parent_class(res->get_class(), "DynamicFontData")) {
- Ref<DynamicFont> font = memnew(DynamicFont);
- font->set_font_data(res);
+ if (at == "Font" && ClassDB::is_parent_class(res->get_class(), "FontData")) {
+ Ref<Font> font = memnew(Font);
+ font->add_data(res);
res = font;
break;
}
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 2cf0bed7d0..0ea112d48c 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -262,13 +262,30 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
String host_lang = OS::get_singleton()->get_locale();
host_lang = TranslationServer::standardize_locale(host_lang);
- // Some locales are not properly supported currently in Godot due to lack of font shaping
- // (e.g. Arabic or Hindi), so even though we have work in progress translations for them,
- // we skip them as they don't render properly. (GH-28577)
- const Vector<String> locales_to_skip = String("ar,bn,fa,he,hi,ml,si,ta,te,ur").split(",");
+ // Skip locales if Text server lack required features.
+ Vector<String> locales_to_skip;
+ if (!TS->has_feature(TextServer::FEATURE_BIDI_LAYOUT) || !TS->has_feature(TextServer::FEATURE_SHAPING)) {
+ locales_to_skip.push_back("ar"); // Arabic
+ locales_to_skip.push_back("fa"); // Persian
+ locales_to_skip.push_back("ur"); // Urdu
+ }
+ if (!TS->has_feature(TextServer::FEATURE_BIDI_LAYOUT)) {
+ locales_to_skip.push_back("he"); // Hebrew
+ }
+ if (!TS->has_feature(TextServer::FEATURE_SHAPING)) {
+ locales_to_skip.push_back("bn"); // Bengali
+ locales_to_skip.push_back("hi"); // Hindi
+ locales_to_skip.push_back("ml"); // Malayalam
+ locales_to_skip.push_back("si"); // Sinhala
+ locales_to_skip.push_back("ta"); // Tamil
+ locales_to_skip.push_back("te"); // Telugu
+ }
- String best;
+ if (!locales_to_skip.empty()) {
+ WARN_PRINT("Some locales are not properly supported by selected Text Server and are disabled.");
+ }
+ String best;
EditorTranslationList *etl = _editor_translations;
while (etl->data) {
@@ -316,6 +333,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
hints["interface/editor/main_font_size"] = PropertyInfo(Variant::INT, "interface/editor/main_font_size", PROPERTY_HINT_RANGE, "8,48,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
_initial_set("interface/editor/code_font_size", 14);
hints["interface/editor/code_font_size"] = PropertyInfo(Variant::INT, "interface/editor/code_font_size", PROPERTY_HINT_RANGE, "8,48,1", PROPERTY_USAGE_DEFAULT);
+ _initial_set("interface/editor/code_font_contextual_ligatures", 0);
+ hints["interface/editor/code_font_contextual_ligatures"] = PropertyInfo(Variant::INT, "interface/editor/code_font_contextual_ligatures", PROPERTY_HINT_ENUM, "Default,Disable contextual alternates (coding ligatures),Use custom OpenType feature set", PROPERTY_USAGE_DEFAULT);
+ _initial_set("interface/editor/code_font_custom_opentype_features", "");
_initial_set("interface/editor/font_antialiased", true);
_initial_set("interface/editor/font_hinting", 0);
hints["interface/editor/font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/font_hinting", PROPERTY_HINT_ENUM, "Auto,None,Light,Normal", PROPERTY_USAGE_DEFAULT);
diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp
index efc966c6c4..d72510d40d 100644
--- a/editor/editor_spin_slider.cpp
+++ b/editor/editor_spin_slider.cpp
@@ -37,13 +37,13 @@
String EditorSpinSlider::get_tooltip(const Point2 &p_pos) const {
if (grabber->is_visible()) {
- return rtos(get_value()) + "\n\n" + TTR("Hold Ctrl to round to integers. Hold Shift for more precise changes.");
+ return TS->format_number(rtos(get_value())) + "\n\n" + TTR("Hold Ctrl to round to integers. Hold Shift for more precise changes.");
}
- return rtos(get_value());
+ return TS->format_number(rtos(get_value()));
}
String EditorSpinSlider::get_text_value() const {
- return String::num(get_value(), Math::range_step_decimals(get_step()));
+ return TS->format_number(String::num(get_value(), Math::range_step_decimals(get_step())));
}
void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) {
@@ -214,10 +214,11 @@ void EditorSpinSlider::_notification(int p_what) {
draw_style_box(sb, Rect2(Vector2(), get_size()));
}
Ref<Font> font = get_theme_font("font", "LineEdit");
+ int font_size = get_theme_font_size("font_size", "LineEdit");
int sep_base = 4 * EDSCALE;
int sep = sep_base + sb->get_offset().x; //make it have the same margin on both sides, looks better
- int string_width = font->get_string_size(label).width;
+ int string_width = font->get_string_size(label, font_size).width;
int number_width = get_size().width - sb->get_minimum_size().width - string_width - sep;
Ref<Texture2D> updown = get_theme_icon("updown", "SpinBox");
@@ -228,7 +229,7 @@ void EditorSpinSlider::_notification(int p_what) {
String numstr = get_text_value();
- int vofs = (get_size().height - font->get_height()) / 2 + font->get_ascent();
+ int vofs = (get_size().height - font->get_height(font_size)) / 2 + font->get_ascent(font_size);
Color fc = get_theme_color("font_color", "LineEdit");
Color lc;
@@ -248,9 +249,9 @@ void EditorSpinSlider::_notification(int p_what) {
draw_style_box(focus, Rect2(Vector2(), get_size()));
}
- draw_string(font, Vector2(Math::round(sb->get_offset().x), vofs), label, lc * Color(1, 1, 1, 0.5));
+ draw_string(font, Vector2(Math::round(sb->get_offset().x), vofs), label, HALIGN_LEFT, -1, font_size, lc * Color(1, 1, 1, 0.5));
- draw_string(font, Vector2(Math::round(sb->get_offset().x + string_width + sep), vofs), numstr, fc, number_width);
+ draw_string(font, Vector2(Math::round(sb->get_offset().x + string_width + sep), vofs), numstr, HALIGN_LEFT, number_width, font_size, fc);
if (get_step() == 1) {
Ref<Texture2D> updown2 = get_theme_icon("updown", "SpinBox");
@@ -330,9 +331,10 @@ void EditorSpinSlider::_notification(int p_what) {
Size2 EditorSpinSlider::get_minimum_size() const {
Ref<StyleBox> sb = get_theme_stylebox("normal", "LineEdit");
Ref<Font> font = get_theme_font("font", "LineEdit");
+ int font_size = get_theme_font_size("font_size", "LineEdit");
Size2 ms = sb->get_minimum_size();
- ms.height += font->get_height();
+ ms.height += font->get_height(font_size);
return ms;
}
@@ -360,7 +362,7 @@ void EditorSpinSlider::_evaluate_input_text() {
// This prevents using functions like `pow()`, but using functions
// in EditorSpinSlider is a barely known (and barely used) feature.
// Instead, we'd rather support German/French keyboard layouts out of the box.
- const String text = value_input->get_text().replace(",", ".");
+ const String text = TS->parse_number(value_input->get_text().replace(",", "."));
Ref<Expression> expr;
expr.instance();
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 768e5bccbc..c589a3c042 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -600,12 +600,18 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_color("icon_color_pressed", "Button", icon_color_pressed);
// OptionButton
+ theme->set_stylebox("focus", "OptionButton", style_widget_focus);
+
theme->set_stylebox("normal", "OptionButton", style_widget);
theme->set_stylebox("hover", "OptionButton", style_widget_hover);
theme->set_stylebox("pressed", "OptionButton", style_widget_pressed);
- theme->set_stylebox("focus", "OptionButton", style_widget_focus);
theme->set_stylebox("disabled", "OptionButton", style_widget_disabled);
+ theme->set_stylebox("normal_mirrored", "OptionButton", style_widget);
+ theme->set_stylebox("hover_mirrored", "OptionButton", style_widget_hover);
+ theme->set_stylebox("pressed_mirrored", "OptionButton", style_widget_pressed);
+ theme->set_stylebox("disabled_mirrored", "OptionButton", style_widget_disabled);
+
theme->set_color("font_color", "OptionButton", font_color);
theme->set_color("font_color_hover", "OptionButton", font_color_hl);
theme->set_color("font_color_pressed", "OptionButton", accent_color);
@@ -627,6 +633,11 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_icon("off", "CheckButton", theme->get_icon("GuiToggleOff", "EditorIcons"));
theme->set_icon("off_disabled", "CheckButton", theme->get_icon("GuiToggleOffDisabled", "EditorIcons"));
+ theme->set_icon("on_mirrored", "CheckButton", theme->get_icon("GuiToggleOnMirrored", "EditorIcons"));
+ theme->set_icon("on_disabled_mirrored", "CheckButton", theme->get_icon("GuiToggleOnDisabledMirrored", "EditorIcons"));
+ theme->set_icon("off_mirrored", "CheckButton", theme->get_icon("GuiToggleOffMirrored", "EditorIcons"));
+ theme->set_icon("off_disabled_mirrored", "CheckButton", theme->get_icon("GuiToggleOffDisabledMirrored", "EditorIcons"));
+
theme->set_color("font_color", "CheckButton", font_color);
theme->set_color("font_color_hover", "CheckButton", font_color_hl);
theme->set_color("font_color_pressed", "CheckButton", accent_color);
@@ -665,7 +676,14 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_stylebox("panel", "PopupDialog", style_popup);
// PopupMenu
- theme->set_stylebox("panel", "PopupMenu", style_popup);
+ const int popup_menu_margin_size = default_margin_size * 1.5 * EDSCALE;
+ Ref<StyleBoxFlat> style_popup_menu = style_popup->duplicate();
+ style_popup_menu->set_default_margin(MARGIN_LEFT, popup_menu_margin_size);
+ style_popup_menu->set_default_margin(MARGIN_TOP, popup_menu_margin_size);
+ style_popup_menu->set_default_margin(MARGIN_RIGHT, popup_menu_margin_size);
+ style_popup_menu->set_default_margin(MARGIN_BOTTOM, popup_menu_margin_size);
+
+ theme->set_stylebox("panel", "PopupMenu", style_popup_menu);
theme->set_stylebox("separator", "PopupMenu", style_popup_separator);
theme->set_stylebox("labeled_separator_left", "PopupMenu", style_popup_labeled_separator_left);
theme->set_stylebox("labeled_separator_right", "PopupMenu", style_popup_labeled_separator_right);
@@ -679,6 +697,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_icon("radio_checked", "PopupMenu", theme->get_icon("GuiRadioChecked", "EditorIcons"));
theme->set_icon("radio_unchecked", "PopupMenu", theme->get_icon("GuiRadioUnchecked", "EditorIcons"));
theme->set_icon("submenu", "PopupMenu", theme->get_icon("ArrowRight", "EditorIcons"));
+ theme->set_icon("submenu_mirrored", "PopupMenu", theme->get_icon("ArrowLeft", "EditorIcons"));
theme->set_icon("visibility_hidden", "PopupMenu", theme->get_icon("GuiVisibilityHidden", "EditorIcons"));
theme->set_icon("visibility_visible", "PopupMenu", theme->get_icon("GuiVisibilityVisible", "EditorIcons"));
theme->set_icon("visibility_xray", "PopupMenu", theme->get_icon("GuiVisibilityXray", "EditorIcons"));
@@ -707,6 +726,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_icon("unchecked", "Tree", theme->get_icon("GuiUnchecked", "EditorIcons"));
theme->set_icon("arrow", "Tree", theme->get_icon("GuiTreeArrowDown", "EditorIcons"));
theme->set_icon("arrow_collapsed", "Tree", theme->get_icon("GuiTreeArrowRight", "EditorIcons"));
+ theme->set_icon("arrow_collapsed_mirrored", "Tree", theme->get_icon("GuiTreeArrowLeft", "EditorIcons"));
theme->set_icon("updown", "Tree", theme->get_icon("GuiTreeUpdown", "EditorIcons"));
theme->set_icon("select_arrow", "Tree", theme->get_icon("GuiDropdown", "EditorIcons"));
theme->set_stylebox("bg_focus", "Tree", style_focus);
@@ -851,7 +871,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_stylebox("DebuggerPanel", "EditorStyles", style_panel_debugger);
Ref<StyleBoxFlat> style_panel_invisible_top = style_content_panel->duplicate();
- int stylebox_offset = theme->get_font("tab_fg", "TabContainer")->get_height() + theme->get_stylebox("tab_fg", "TabContainer")->get_minimum_size().height + theme->get_stylebox("panel", "TabContainer")->get_default_margin(MARGIN_TOP);
+ int stylebox_offset = theme->get_font("tab_fg", "TabContainer")->get_height(theme->get_font_size("tab_fg", "TabContainer")) + theme->get_stylebox("tab_fg", "TabContainer")->get_minimum_size().height + theme->get_stylebox("panel", "TabContainer")->get_default_margin(MARGIN_TOP);
style_panel_invisible_top->set_expand_margin_size(MARGIN_TOP, -stylebox_offset);
style_panel_invisible_top->set_default_margin(MARGIN_TOP, 0);
theme->set_stylebox("BottomPanelDebuggerOverride", "EditorStyles", style_panel_invisible_top);
@@ -931,6 +951,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_constant("title_height", "Window", 24 * EDSCALE);
theme->set_constant("resize_margin", "Window", 4 * EDSCALE);
theme->set_font("title_font", "Window", theme->get_font("title", "EditorFonts"));
+ theme->set_font_size("title_font_size", "Window", theme->get_font_size("title_size", "EditorFonts"));
// complex window, for now only Editor settings and Project settings
Ref<StyleBoxFlat> style_complex_window = style_window->duplicate();
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 543546b152..aa19bdf342 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -68,6 +68,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory
}
subdirectory_item->set_text(0, dname);
+ subdirectory_item->set_structured_text_bidi_override(0, STRUCTURED_TEXT_FILE);
subdirectory_item->set_icon(0, get_theme_icon("Folder", "EditorIcons"));
subdirectory_item->set_icon_modulate(0, get_theme_color("folder_icon_modulate", "FileDialog"));
subdirectory_item->set_selectable(0, true);
@@ -136,6 +137,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory
TreeItem *file_item = tree->create_item(subdirectory_item);
file_item->set_text(0, fi.name);
+ file_item->set_structured_text_bidi_override(0, STRUCTURED_TEXT_FILE);
file_item->set_icon(0, _get_tree_item_icon(!fi.import_broken, fi.type));
String file_metadata = lpath.plus_file(fi.name);
file_item->set_metadata(0, file_metadata);
@@ -320,6 +322,8 @@ void FileSystemDock::_update_display_mode(bool p_force) {
void FileSystemDock::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_TRANSLATION_CHANGED:
+ case NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
case NOTIFICATION_ENTER_TREE: {
if (initialized) {
return;
@@ -348,8 +352,13 @@ void FileSystemDock::_notification(int p_what) {
file_list_search_box->set_clear_button_enabled(true);
file_list_button_sort->set_icon(get_theme_icon("Sort", ei));
- button_hist_next->set_icon(get_theme_icon("Forward", ei));
- button_hist_prev->set_icon(get_theme_icon("Back", ei));
+ if (is_layout_rtl()) {
+ button_hist_next->set_icon(get_theme_icon("Back", ei));
+ button_hist_prev->set_icon(get_theme_icon("Forward", ei));
+ } else {
+ button_hist_next->set_icon(get_theme_icon("Forward", ei));
+ button_hist_prev->set_icon(get_theme_icon("Back", ei));
+ }
file_list_popup->connect("id_pressed", callable_mp(this, &FileSystemDock::_file_list_rmb_option));
tree_popup->connect("id_pressed", callable_mp(this, &FileSystemDock::_tree_rmb_option));
@@ -402,8 +411,13 @@ void FileSystemDock::_notification(int p_what) {
String ei = "EditorIcons";
button_reload->set_icon(get_theme_icon("Reload", ei));
button_toggle_display_mode->set_icon(get_theme_icon("Panels2", ei));
- button_hist_next->set_icon(get_theme_icon("Forward", ei));
- button_hist_prev->set_icon(get_theme_icon("Back", ei));
+ if (is_layout_rtl()) {
+ button_hist_next->set_icon(get_theme_icon("Back", ei));
+ button_hist_prev->set_icon(get_theme_icon("Forward", ei));
+ } else {
+ button_hist_next->set_icon(get_theme_icon("Forward", ei));
+ button_hist_prev->set_icon(get_theme_icon("Back", ei));
+ }
if (file_list_display_mode == FILE_LIST_DISPLAY_LIST) {
button_file_list_display_mode->set_icon(get_theme_icon("FileThumbnail", "EditorIcons"));
} else {
@@ -2354,16 +2368,16 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str
}
if (p_paths.size() == 1) {
- p_popup->add_icon_item(get_theme_icon("ActionCopy", "EditorIcons"), TTR("Copy Path"), FILE_COPY_PATH);
+ p_popup->add_icon_shortcut(get_theme_icon("ActionCopy", "EditorIcons"), ED_GET_SHORTCUT("filesystem_dock/copy_path"), FILE_COPY_PATH);
if (p_paths[0] != "res://") {
- p_popup->add_icon_item(get_theme_icon("Rename", "EditorIcons"), TTR("Rename..."), FILE_RENAME);
- p_popup->add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), TTR("Duplicate..."), FILE_DUPLICATE);
+ p_popup->add_icon_shortcut(get_theme_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("filesystem_dock/rename"), FILE_RENAME);
+ p_popup->add_icon_shortcut(get_theme_icon("Duplicate", "EditorIcons"), ED_GET_SHORTCUT("filesystem_dock/duplicate"), FILE_DUPLICATE);
}
}
if (p_paths.size() > 1 || p_paths[0] != "res://") {
p_popup->add_icon_item(get_theme_icon("MoveUp", "EditorIcons"), TTR("Move To..."), FILE_MOVE);
- p_popup->add_icon_item(get_theme_icon("Remove", "EditorIcons"), TTR("Move to Trash"), FILE_REMOVE);
+ p_popup->add_icon_shortcut(get_theme_icon("Remove", "EditorIcons"), ED_GET_SHORTCUT("filesystem_dock/delete"), FILE_REMOVE);
}
if (p_paths.size() == 1) {
@@ -2497,7 +2511,11 @@ void FileSystemDock::_tree_gui_input(Ref<InputEvent> p_event) {
_tree_rmb_option(FILE_REMOVE);
} else if (ED_IS_SHORTCUT("filesystem_dock/rename", p_event)) {
_tree_rmb_option(FILE_RENAME);
+ } else {
+ return;
}
+
+ accept_event();
}
}
@@ -2512,7 +2530,11 @@ void FileSystemDock::_file_list_gui_input(Ref<InputEvent> p_event) {
_file_list_rmb_option(FILE_REMOVE);
} else if (ED_IS_SHORTCUT("filesystem_dock/rename", p_event)) {
_file_list_rmb_option(FILE_RENAME);
+ } else {
+ return;
}
+
+ accept_event();
}
}
@@ -2668,8 +2690,8 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
// `KEY_MASK_CMD | KEY_C` conflicts with other editor shortcuts.
ED_SHORTCUT("filesystem_dock/copy_path", TTR("Copy Path"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_C);
ED_SHORTCUT("filesystem_dock/duplicate", TTR("Duplicate..."), KEY_MASK_CMD | KEY_D);
- ED_SHORTCUT("filesystem_dock/delete", TTR("Delete"), KEY_DELETE);
- ED_SHORTCUT("filesystem_dock/rename", TTR("Rename"));
+ ED_SHORTCUT("filesystem_dock/delete", TTR("Move to Trash"), KEY_DELETE);
+ ED_SHORTCUT("filesystem_dock/rename", TTR("Rename..."), KEY_F2);
VBoxContainer *top_vbc = memnew(VBoxContainer);
add_child(top_vbc);
@@ -2693,6 +2715,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
toolbar_hbc->add_child(button_hist_next);
current_path = memnew(LineEdit);
+ current_path->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE);
current_path->set_h_size_flags(SIZE_EXPAND_FILL);
_set_current_path_text(path);
toolbar_hbc->add_child(current_path);
diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp
index c2ccbdb08c..8d3f0eb21f 100644
--- a/editor/find_in_files.cpp
+++ b/editor/find_in_files.cpp
@@ -571,6 +571,7 @@ FindInFilesPanel::FindInFilesPanel() {
_search_text_label = memnew(Label);
_search_text_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("source", "EditorFonts"));
+ _search_text_label->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("source_size", "EditorFonts"));
hbc->add_child(_search_text_label);
_progress_bar = memnew(ProgressBar);
@@ -599,6 +600,7 @@ FindInFilesPanel::FindInFilesPanel() {
_results_display = memnew(Tree);
_results_display->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("source", "EditorFonts"));
+ _results_display->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("source_size", "EditorFonts"));
_results_display->set_v_size_flags(SIZE_EXPAND_FILL);
_results_display->connect("item_selected", callable_mp(this, &FindInFilesPanel::_on_result_selected));
_results_display->connect("item_edited", callable_mp(this, &FindInFilesPanel::_on_item_edited));
@@ -755,10 +757,11 @@ void FindInFilesPanel::draw_result_text(Object *item_obj, Rect2 rect) {
Result r = E->value();
String item_text = item->get_text(_with_replace ? 1 : 0);
Ref<Font> font = _results_display->get_theme_font("font");
+ int font_size = _results_display->get_theme_font_size("font_size");
Rect2 match_rect = rect;
- match_rect.position.x += font->get_string_size(item_text.left(r.begin_trimmed)).x;
- match_rect.size.x = font->get_string_size(_search_text_label->get_text()).x;
+ match_rect.position.x += font->get_string_size(item_text.left(r.begin_trimmed), font_size).x;
+ match_rect.size.x = font->get_string_size(_search_text_label->get_text(), font_size).x;
match_rect.position.y += 1 * EDSCALE;
match_rect.size.y -= 2 * EDSCALE;
diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp
index 4e6e2d0237..f3bad8d86d 100644
--- a/editor/groups_editor.cpp
+++ b/editor/groups_editor.cpp
@@ -361,9 +361,16 @@ void GroupDialog::_delete_group_item(const String &p_name) {
void GroupDialog::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_TRANSLATION_CHANGED:
+ case Control::NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
case NOTIFICATION_ENTER_TREE: {
- add_button->set_icon(groups->get_theme_icon("Forward", "EditorIcons"));
- remove_button->set_icon(groups->get_theme_icon("Back", "EditorIcons"));
+ if (is_layout_rtl()) {
+ add_button->set_icon(groups->get_theme_icon("Back", "EditorIcons"));
+ remove_button->set_icon(groups->get_theme_icon("Forward", "EditorIcons"));
+ } else {
+ add_button->set_icon(groups->get_theme_icon("Forward", "EditorIcons"));
+ remove_button->set_icon(groups->get_theme_icon("Back", "EditorIcons"));
+ }
add_filter->set_right_icon(groups->get_theme_icon("Search", "EditorIcons"));
add_filter->set_clear_button_enabled(true);
diff --git a/editor/icons/AutoEndBackwards.svg b/editor/icons/AutoEndBackwards.svg
new file mode 100644
index 0000000000..c6de305069
--- /dev/null
+++ b/editor/icons/AutoEndBackwards.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#e0e0e0"><path d="m2 14c-.552262-.000055-.999945-.447738-1-1v-10c.000055-.5522619.447738-.9999448 1-1h8c.303863-.0001753.591325.1378063.78125.375l4 5c.291397.3649711.291397.8830289 0 1.248l-4 5c-.189538.237924-.477058.376652-.78125.37695h-8zm1-2h6.5195004l3.1991996-4-3.1991996-4h-6.5195004zm6.0000004-2v-4l1.9999996 2z" fill-rule="evenodd"/><path d="m3.8685125 4.9095434h4.1550816v1.1637426h-2.6154217v1.1117544h2.4594562v1.1637428h-2.4594562v1.3676976h2.7034024v1.1637432h-4.2430623z" stroke-width=".204755"/></g></svg>
diff --git a/editor/icons/AutoPlayBackwards.svg b/editor/icons/AutoPlayBackwards.svg
new file mode 100644
index 0000000000..20602ba348
--- /dev/null
+++ b/editor/icons/AutoPlayBackwards.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m13.999798 2a-1.0001 1.0001 0 0 1 1 1v10a-1.0001 1.0001 0 0 1 -1 1h-8.0000003a-1.0001 1.0001 0 0 1 -.78125-.375l-4-5a-1.0001 1.0001 0 0 1 0-1.248l4-5a-1.0001 1.0001 0 0 1 .78125-.37695h8.0000003zm-1 2h-6.5195003l-3.1992 4 3.1992 4h6.5195003zm-3.0000003 1c1.1046003 0 2.0000003.8954 2.0000003 2v4h-1v-2h-2.0000003v2h-1v-4c0-1.1046.89543-2 2-2zm0 1a-1 1 0 0 0 -1 1v1h2.0000003v-1a-1 1 0 0 0 -1.0000003-1zm-3 0v4l-2-2z" fill="#e0e0e0" fill-rule="evenodd"/></svg>
diff --git a/editor/icons/BitmapFont.svg b/editor/icons/BitmapFont.svg
deleted file mode 100644
index d3ab5f7dd7..0000000000
--- a/editor/icons/BitmapFont.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m1 1037.4v4h1v-1h1v-1h4v10h-1v1h-1v1h6v-1h-1v-1h-1v-10h4v1h1v1h1v-4z" fill="#84c2ff" transform="translate(0 -1036.4)"/></svg>
diff --git a/editor/icons/DynamicFont.svg b/editor/icons/DynamicFont.svg
deleted file mode 100644
index bbaa12ea1b..0000000000
--- a/editor/icons/DynamicFont.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g transform="translate(0 -1036.4)"><path d="m1 1037.4v2 1h1a1 1 0 0 1 1-1h2v6a1 1 0 0 1 -1 1v1h1 2 1v-1a1 1 0 0 1 -1-1v-6h2a1 1 0 0 1 1 1h1v-1-2h-4-2z" fill="#e0e0e0"/><path d="m4 5v2 1h1a1 1 0 0 1 1-1h2v6a1 1 0 0 1 -1 1v1h1 2 1v-1a1 1 0 0 1 -1-1v-6h2a1 1 0 0 1 1 1h1v-1-2h-4-2z" fill="#84c2ff" transform="translate(0 1036.4)"/></g></svg>
diff --git a/editor/icons/DynamicFontData.svg b/editor/icons/FontData.svg
index 7ee88582a5..7ee88582a5 100644
--- a/editor/icons/DynamicFontData.svg
+++ b/editor/icons/FontData.svg
diff --git a/editor/icons/GuiResizerMirrored.svg b/editor/icons/GuiResizerMirrored.svg
new file mode 100644
index 0000000000..8227f5b648
--- /dev/null
+++ b/editor/icons/GuiResizerMirrored.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill-opacity=".588" fill="#fff" d="M4 3a1 1 0 0 1 1 1v6h6a1 1 0 0 1 0 2H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z"/></svg>
diff --git a/editor/icons/GuiTabMirrored.svg b/editor/icons/GuiTabMirrored.svg
new file mode 100644
index 0000000000..a0011a5b2d
--- /dev/null
+++ b/editor/icons/GuiTabMirrored.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8"><path fill-opacity=".196" fill="#fff" d="M2 0v8H0V0zm5.014.002a-1 1 0 0 1 .693.291-1 1 0 0 1 0 1.414L5.414 4l2.293 2.293a-1 1 0 0 1 0 1.414-1 1 0 0 1-1.414 0l-3-3a-1 1 0 0 1 0-1.414l3-3a-1 1 0 0 1 .72-.29z"/></svg>
diff --git a/editor/icons/GuiToggleOffMirrored.svg b/editor/icons/GuiToggleOffMirrored.svg
new file mode 100644
index 0000000000..d650de9cda
--- /dev/null
+++ b/editor/icons/GuiToggleOffMirrored.svg
@@ -0,0 +1 @@
+<svg height="26" width="42" xmlns="http://www.w3.org/2000/svg"><g fill="#e0e0e0" transform="matrix(-1 0 0 1 42 0)"><rect fill-opacity=".188" height="16" rx="9" width="38" x="2" y="5"/><circle cx="10" cy="13" r="5"/></g></svg>
diff --git a/editor/icons/GuiToggleOnMirrored.svg b/editor/icons/GuiToggleOnMirrored.svg
new file mode 100644
index 0000000000..7339b6efd2
--- /dev/null
+++ b/editor/icons/GuiToggleOnMirrored.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="42" height="26"><path fill="#e0e0e0" d="M31 5c4.986 0 9 3.568 9 8s-4.014 8-9 8H11c-4.986 0-9-3.568-9-8s4.014-8 9-8zM10 8a-5 5 0 0 0-5 5-5 5 0 0 0 5 5-5 5 0 0 0 5-5-5 5 0 0 0-5-5z"/></svg>
diff --git a/editor/icons/GuiTreeArrowLeft.svg b/editor/icons/GuiTreeArrowLeft.svg
new file mode 100644
index 0000000000..d0f7b36fab
--- /dev/null
+++ b/editor/icons/GuiTreeArrowLeft.svg
@@ -0,0 +1 @@
+<svg height="12" width="12" xmlns="http://www.w3.org/2000/svg"><path d="m7 9-3-3 3-3" style="fill:none;stroke:#fff;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:.392"/></svg>
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index 12cbaaa885..41099dc8ea 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -844,19 +844,19 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
for (int k = 0; k < vertex_array.size(); k++) {
if (normal_src) {
- surftool->add_normal(vertex_array[k].normal);
+ surftool->set_normal(vertex_array[k].normal);
if (binormal_src && tangent_src) {
- surftool->add_tangent(vertex_array[k].tangent);
+ surftool->set_tangent(vertex_array[k].tangent);
}
}
if (uv_src) {
- surftool->add_uv(Vector2(vertex_array[k].uv.x, vertex_array[k].uv.y));
+ surftool->set_uv(Vector2(vertex_array[k].uv.x, vertex_array[k].uv.y));
}
if (uv2_src) {
- surftool->add_uv2(Vector2(vertex_array[k].uv2.x, vertex_array[k].uv2.y));
+ surftool->set_uv2(Vector2(vertex_array[k].uv2.x, vertex_array[k].uv2.y));
}
if (color_src) {
- surftool->add_color(vertex_array[k].color);
+ surftool->set_color(vertex_array[k].color);
}
if (has_weights) {
@@ -876,8 +876,8 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
}
}
- surftool->add_bones(bones);
- surftool->add_weights(weights);
+ surftool->set_bones(bones);
+ surftool->set_weights(weights);
}
surftool->add_vertex(vertex_array[k].vertex);
@@ -923,7 +923,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
mr.push_back(a);
}
- p_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, d, mr, Dictionary(), p_use_compression ? Mesh::ARRAY_COMPRESS_DEFAULT : 0);
+ p_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, d, mr, Dictionary(), 0);
if (material.is_valid()) {
if (p_use_mesh_material) {
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp
index 0c860a8965..c1877895ce 100644
--- a/editor/import/editor_scene_importer_gltf.cpp
+++ b/editor/import/editor_scene_importer_gltf.cpp
@@ -970,8 +970,7 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
return OK;
}
- bool compress_vert_data = state.import_flags & IMPORT_USE_COMPRESSION;
- uint32_t mesh_flags = compress_vert_data ? Mesh::ARRAY_COMPRESS_DEFAULT : 0;
+ uint32_t mesh_flags = 0;
Array meshes = state.json["meshes"];
for (GLTFMeshIndex i = 0; i < meshes.size(); i++) {
diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp
index 49b47bf4be..d4560a2984 100644
--- a/editor/import/resource_importer_obj.cpp
+++ b/editor/import/resource_importer_obj.cpp
@@ -210,7 +210,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
bool generate_tangents = p_generate_tangents;
Vector3 scale_mesh = p_scale_mesh;
Vector3 offset_mesh = p_offset_mesh;
- int mesh_flags = p_optimize ? Mesh::ARRAY_COMPRESS_DEFAULT : 0;
+ int mesh_flags = 0;
Vector<Vector3> vertices;
Vector<Vector3> normals;
@@ -294,7 +294,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
norm += normals.size() + 1;
}
ERR_FAIL_INDEX_V(norm, normals.size(), ERR_FILE_CORRUPT);
- surf_tool->add_normal(normals[norm]);
+ surf_tool->set_normal(normals[norm]);
}
if (face[idx].size() >= 2 && face[idx][1] != String()) {
@@ -303,7 +303,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
uv += uvs.size() + 1;
}
ERR_FAIL_INDEX_V(uv, uvs.size(), ERR_FILE_CORRUPT);
- surf_tool->add_uv(uvs[uv]);
+ surf_tool->set_uv(uvs[uv]);
}
int vtx = face[idx][0].to_int() - 1;
@@ -473,6 +473,10 @@ String ResourceImporterOBJ::get_resource_type() const {
return "Mesh";
}
+int ResourceImporterOBJ::get_format_version() const {
+ return 1;
+}
+
int ResourceImporterOBJ::get_preset_count() const {
return 0;
}
diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h
index 4083bc7403..97f747b33c 100644
--- a/editor/import/resource_importer_obj.h
+++ b/editor/import/resource_importer_obj.h
@@ -54,6 +54,7 @@ public:
virtual void get_recognized_extensions(List<String> *p_extensions) const override;
virtual String get_save_extension() const override;
virtual String get_resource_type() const override;
+ virtual int get_format_version() const override;
virtual int get_preset_count() const override;
virtual String get_preset_name(int p_idx) const override;
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 5dcdf6bec4..fc4f673ec4 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -172,6 +172,10 @@ String ResourceImporterScene::get_resource_type() const {
return "PackedScene";
}
+int ResourceImporterScene::get_format_version() const {
+ return 1;
+}
+
bool ResourceImporterScene::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
if (p_option.begins_with("animation/")) {
if (p_option != "animation/import" && !bool(p_options["animation/import"])) {
diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h
index 465d11116b..cd61ec01f2 100644
--- a/editor/import/resource_importer_scene.h
+++ b/editor/import/resource_importer_scene.h
@@ -133,6 +133,7 @@ public:
virtual void get_recognized_extensions(List<String> *p_extensions) const override;
virtual String get_save_extension() const override;
virtual String get_resource_type() const override;
+ virtual int get_format_version() const override;
virtual int get_preset_count() const override;
virtual String get_preset_name(int p_idx) const override;
diff --git a/editor/input_map_editor.cpp b/editor/input_map_editor.cpp
index 5b6d850096..686fd4c08b 100644
--- a/editor/input_map_editor.cpp
+++ b/editor/input_map_editor.cpp
@@ -35,47 +35,6 @@
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
-static const char *_button_descriptions[JOY_BUTTON_SDL_MAX] = {
- TTRC("Bottom Action, Sony Cross, Xbox A, Nintendo B"),
- TTRC("Right Action, Sony Circle, Xbox B, Nintendo A"),
- TTRC("Left Action, Sony Square, Xbox X, Nintendo Y"),
- TTRC("Top Action, Sony Triangle, Xbox Y, Nintendo X"),
- TTRC("Back, Sony Select, Xbox Back, Nintendo -"),
- TTRC("Guide, Sony PS, Xbox Home"),
- TTRC("Start, Nintendo +"),
- TTRC("Left Stick, Sony L3, Xbox L/LS"),
- TTRC("Right Stick, Sony R3, Xbox R/RS"),
- TTRC("Left Shoulder, Sony L1, Xbox LB"),
- TTRC("Right Shoulder, Sony R1, Xbox RB"),
- TTRC("D-pad Up"),
- TTRC("D-pad Down"),
- TTRC("D-pad Left"),
- TTRC("D-pad Right"),
-};
-
-static const char *_axis_descriptions[JOY_AXIS_MAX * 2] = {
- TTRC("Left Stick Left, Joystick 0 Left"),
- TTRC("Left Stick Right, Joystick 0 Right"),
- TTRC("Left Stick Up, Joystick 0 Up"),
- TTRC("Left Stick Down, Joystick 0 Down"),
- TTRC("Right Stick Left, Joystick 1 Left"),
- TTRC("Right Stick Right, Joystick 1 Right"),
- TTRC("Right Stick Up, Joystick 1 Up"),
- TTRC("Right Stick Down, Joystick 1 Down"),
- TTRC("Joystick 2 Left"),
- TTRC("Left Trigger, L2, LT, Joystick 2 Right"),
- TTRC("Joystick 2 Up"),
- TTRC("Right Trigger, R2, RT, Joystick 2 Down"),
- TTRC("Joystick 3 Left"),
- TTRC("Joystick 3 Right"),
- TTRC("Joystick 3 Up"),
- TTRC("Joystick 3 Down"),
- TTRC("Joystick 4 Left"),
- TTRC("Joystick 4 Right"),
- TTRC("Joystick 4 Up"),
- TTRC("Joystick 4 Down"),
-};
-
void InputMapEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -395,6 +354,42 @@ void InputMapEditor::_show_last_added(const Ref<InputEvent> &p_event, const Stri
}
}
+// Maps to 2*axis if value is neg, or + 1 if value is pos.
+static const char *_joy_axis_descriptions[JOY_AXIS_MAX * 2] = {
+ TTRC("Left Stick Left, Joystick 0 Left"),
+ TTRC("Left Stick Right, Joystick 0 Right"),
+ TTRC("Left Stick Up, Joystick 0 Up"),
+ TTRC("Left Stick Down, Joystick 0 Down"),
+ TTRC("Right Stick Left, Joystick 1 Left"),
+ TTRC("Right Stick Right, Joystick 1 Right"),
+ TTRC("Right Stick Up, Joystick 1 Up"),
+ TTRC("Right Stick Down, Joystick 1 Down"),
+ TTRC("Joystick 2 Left"),
+ TTRC("Left Trigger, Sony L2, Xbox LT, Joystick 2 Right"),
+ TTRC("Joystick 2 Up"),
+ TTRC("Right Trigger, Sony R2, Xbox RT, Joystick 2 Down"),
+ TTRC("Joystick 3 Left"),
+ TTRC("Joystick 3 Right"),
+ TTRC("Joystick 3 Up"),
+ TTRC("Joystick 3 Down"),
+ TTRC("Joystick 4 Left"),
+ TTRC("Joystick 4 Right"),
+ TTRC("Joystick 4 Up"),
+ TTRC("Joystick 4 Down"),
+};
+
+// Separate from `InputEvent::as_text()` since the descriptions need to be different for the input map editor. See #43660.
+String InputMapEditor::_get_joypad_motion_event_text(const Ref<InputEventJoypadMotion> &p_event) {
+ ERR_FAIL_COND_V_MSG(p_event.is_null(), String(), "Provided event is not a valid instance of InputEventJoypadMotion");
+
+ String desc = TTR("Unknown Joypad Axis");
+ if (p_event->get_axis() < JOY_AXIS_MAX) {
+ desc = RTR(_joy_axis_descriptions[2 * p_event->get_axis() + (p_event->get_axis_value() < 0 ? 0 : 1)]);
+ }
+
+ return vformat("Joypad Axis %s %s (%s)", itos(p_event->get_axis()), p_event->get_axis_value() < 0 ? "-" : "+", desc);
+}
+
void InputMapEditor::_wait_for_key(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_event;
@@ -481,9 +476,11 @@ void InputMapEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_event) {
device_index_label->set_text(TTR("Joypad Axis Index:"));
device_index->clear();
for (int i = 0; i < JOY_AXIS_MAX * 2; i++) {
- String desc = TTR("Axis") + " " + itos(i / 2) + " " + ((i & 1) ? "+" : "-") +
- " (" + TTR(_axis_descriptions[i]) + ")";
- device_index->add_item(desc);
+ Ref<InputEventJoypadMotion> jm;
+ jm.instance();
+ jm->set_axis(i / 2);
+ jm->set_axis_value((i & 1) ? 1 : -1);
+ device_index->add_item(_get_joypad_motion_event_text(jm));
}
device_input->popup_centered(Size2(350, 95) * EDSCALE);
@@ -502,11 +499,10 @@ void InputMapEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_event) {
device_index_label->set_text(TTR("Joypad Button Index:"));
device_index->clear();
for (int i = 0; i < JOY_BUTTON_MAX; i++) {
- String desc = TTR("Button") + " " + itos(i);
- if (i < JOY_BUTTON_SDL_MAX) {
- desc += " (" + TTR(_button_descriptions[i]) + ")";
- }
- device_index->add_item(desc);
+ Ref<InputEventJoypadButton> jb;
+ jb.instance();
+ jb->set_button_index(i);
+ device_index->add_item(jb->as_text());
}
device_input->popup_centered(Size2(350, 95) * EDSCALE);
@@ -714,14 +710,7 @@ void InputMapEditor::_update_actions() {
Ref<InputEventJoypadButton> jb = event;
if (jb.is_valid()) {
- const int idx = jb->get_button_index();
- String str = _get_device_string(jb->get_device()) + ", " +
- TTR("Button") + " " + itos(idx);
- if (idx >= 0 && idx < JOY_BUTTON_SDL_MAX) {
- str += String() + " (" + TTR(_button_descriptions[jb->get_button_index()]) + ")";
- }
-
- action2->set_text(0, str);
+ action2->set_text(0, jb->as_text());
action2->set_icon(0, input_editor->get_theme_icon("JoyButton", "EditorIcons"));
}
@@ -754,12 +743,8 @@ void InputMapEditor::_update_actions() {
Ref<InputEventJoypadMotion> jm = event;
if (jm.is_valid()) {
- int ax = jm->get_axis();
- int n = 2 * ax + (jm->get_axis_value() < 0 ? 0 : 1);
- String str = _get_device_string(jm->get_device()) + ", " +
- TTR("Axis") + " " + itos(ax) + " " + (jm->get_axis_value() < 0 ? "-" : "+") +
- " (" + _axis_descriptions[n] + ")";
- action2->set_text(0, str);
+ device_index->add_item(_get_joypad_motion_event_text(jm));
+ action2->set_text(0, jm->as_text());
action2->set_icon(0, input_editor->get_theme_icon("JoyAxis", "EditorIcons"));
}
action2->set_metadata(0, i);
diff --git a/editor/input_map_editor.h b/editor/input_map_editor.h
index b9a3ce19d4..b59eb97e1d 100644
--- a/editor/input_map_editor.h
+++ b/editor/input_map_editor.h
@@ -88,6 +88,8 @@ class InputMapEditor : public Control {
void _press_a_key_confirm();
void _show_last_added(const Ref<InputEvent> &p_event, const String &p_name);
+ String _get_joypad_motion_event_text(const Ref<InputEventJoypadMotion> &p_event);
+
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp
index c88cd8ea5f..e0ba50fe4f 100644
--- a/editor/inspector_dock.cpp
+++ b/editor/inspector_dock.cpp
@@ -332,13 +332,20 @@ Container *InspectorDock::get_addon_area() {
void InspectorDock::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_TRANSLATION_CHANGED:
+ case NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
set_theme(editor->get_gui_base()->get_theme());
resource_new_button->set_icon(get_theme_icon("New", "EditorIcons"));
resource_load_button->set_icon(get_theme_icon("Load", "EditorIcons"));
resource_save_button->set_icon(get_theme_icon("Save", "EditorIcons"));
- backward_button->set_icon(get_theme_icon("Back", "EditorIcons"));
- forward_button->set_icon(get_theme_icon("Forward", "EditorIcons"));
+ if (is_layout_rtl()) {
+ backward_button->set_icon(get_theme_icon("Forward", "EditorIcons"));
+ forward_button->set_icon(get_theme_icon("Back", "EditorIcons"));
+ } else {
+ backward_button->set_icon(get_theme_icon("Back", "EditorIcons"));
+ forward_button->set_icon(get_theme_icon("Forward", "EditorIcons"));
+ }
history_menu->set_icon(get_theme_icon("History", "EditorIcons"));
object_menu->set_icon(get_theme_icon("Tools", "EditorIcons"));
warning->set_icon(get_theme_icon("NodeWarning", "EditorIcons"));
@@ -524,7 +531,11 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) {
backward_button = memnew(Button);
backward_button->set_flat(true);
general_options_hb->add_child(backward_button);
- backward_button->set_icon(get_theme_icon("Back", "EditorIcons"));
+ if (is_layout_rtl()) {
+ backward_button->set_icon(get_theme_icon("Forward", "EditorIcons"));
+ } else {
+ backward_button->set_icon(get_theme_icon("Back", "EditorIcons"));
+ }
backward_button->set_flat(true);
backward_button->set_tooltip(TTR("Go to the previous edited object in history."));
backward_button->set_disabled(true);
@@ -533,7 +544,11 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) {
forward_button = memnew(Button);
forward_button->set_flat(true);
general_options_hb->add_child(forward_button);
- forward_button->set_icon(get_theme_icon("Forward", "EditorIcons"));
+ if (is_layout_rtl()) {
+ forward_button->set_icon(get_theme_icon("Back", "EditorIcons"));
+ } else {
+ forward_button->set_icon(get_theme_icon("Forward", "EditorIcons"));
+ }
forward_button->set_flat(true);
forward_button->set_tooltip(TTR("Go to the next edited object in history."));
forward_button->set_disabled(true);
@@ -554,6 +569,7 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) {
node_info_hb->add_child(editor_path);
object_menu = memnew(MenuButton);
+ object_menu->set_shortcut_context(this);
object_menu->set_icon(get_theme_icon("Tools", "EditorIcons"));
node_info_hb->add_child(object_menu);
object_menu->set_tooltip(TTR("Object properties."));
diff --git a/editor/localization_editor.cpp b/editor/localization_editor.cpp
index e725ce482d..2a21885c4c 100644
--- a/editor/localization_editor.cpp
+++ b/editor/localization_editor.cpp
@@ -37,6 +37,24 @@
#include "scene/gui/control.h"
void LocalizationEditor::_notification(int p_what) {
+ if (p_what == NOTIFICATION_TEXT_SERVER_CHANGED) {
+ ts_name->set_text(TTR("Text server: ") + TS->get_name());
+
+ FileAccessRef file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES);
+ if (TS->has_feature(TextServer::FEATURE_USE_SUPPORT_DATA)) {
+ if (file_check->file_exists("res://" + TS->get_support_data_filename())) {
+ ts_data_status->set_text(TTR("Support data: ") + TTR("Installed"));
+ ts_install->set_disabled(true);
+ } else {
+ ts_data_status->set_text(TTR("Support data: ") + TTR("Not installed"));
+ ts_install->set_disabled(false);
+ }
+ } else {
+ ts_data_status->set_text(TTR("Support data: ") + TTR("Not supported"));
+ ts_install->set_disabled(false);
+ }
+ ts_data_info->set_text(TTR("Info: ") + TS->get_support_data_info());
+ }
if (p_what == NOTIFICATION_ENTER_TREE) {
translation_list->connect("button_pressed", callable_mp(this, &LocalizationEditor::_translation_delete));
translation_pot_list->connect("button_pressed", callable_mp(this, &LocalizationEditor::_pot_delete));
@@ -622,6 +640,26 @@ void LocalizationEditor::update_translations() {
updating_translations = false;
}
+void LocalizationEditor::_install_ts_data() {
+ if (TS->has_feature(TextServer::FEATURE_USE_SUPPORT_DATA)) {
+ TS->save_support_data("res://" + TS->get_support_data_filename());
+ }
+
+ FileAccessRef file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES);
+ if (TS->has_feature(TextServer::FEATURE_USE_SUPPORT_DATA)) {
+ if (file_check->file_exists("res://" + TS->get_support_data_filename())) {
+ ts_data_status->set_text(TTR("Support data: ") + TTR("Installed"));
+ ts_install->set_disabled(true);
+ } else {
+ ts_data_status->set_text(TTR("Support data: ") + TTR("Not installed"));
+ ts_install->set_disabled(false);
+ }
+ } else {
+ ts_data_status->set_text(TTR("Support data: ") + TTR("Not supported"));
+ ts_install->set_disabled(false);
+ }
+}
+
void LocalizationEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("update_translations"), &LocalizationEditor::update_translations);
@@ -791,4 +829,37 @@ LocalizationEditor::LocalizationEditor() {
pot_file_open_dialog->connect("file_selected", callable_mp(this, &LocalizationEditor::_pot_add));
add_child(pot_file_open_dialog);
}
+
+ {
+ VBoxContainer *tvb = memnew(VBoxContainer);
+ tvb->set_name(TTR("Text Server Data"));
+ translations->add_child(tvb);
+
+ ts_name = memnew(Label(TTR("Text server: ") + TS->get_name()));
+ tvb->add_child(ts_name);
+
+ ts_data_status = memnew(Label(TTR("Support data: ")));
+ tvb->add_child(ts_data_status);
+
+ ts_data_info = memnew(Label(TTR("Info: ") + TS->get_support_data_info()));
+ tvb->add_child(ts_data_info);
+
+ ts_install = memnew(Button(TTR("Install support data...")));
+ ts_install->connect("pressed", callable_mp(this, &LocalizationEditor::_install_ts_data));
+ tvb->add_child(ts_install);
+
+ FileAccessRef file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES);
+ if (TS->has_feature(TextServer::FEATURE_USE_SUPPORT_DATA)) {
+ if (file_check->file_exists("res://" + TS->get_support_data_filename())) {
+ ts_data_status->set_text(TTR("Support data: ") + TTR("Installed"));
+ ts_install->set_disabled(true);
+ } else {
+ ts_data_status->set_text(TTR("Support data: ") + TTR("Not installed"));
+ ts_install->set_disabled(false);
+ }
+ } else {
+ ts_data_status->set_text(TTR("Support data: ") + TTR("Not supported"));
+ ts_install->set_disabled(false);
+ }
+ }
}
diff --git a/editor/localization_editor.h b/editor/localization_editor.h
index 3c077d9c77..43b6bb60f6 100644
--- a/editor/localization_editor.h
+++ b/editor/localization_editor.h
@@ -58,6 +58,11 @@ class LocalizationEditor : public VBoxContainer {
Vector<TreeItem *> translation_filter_treeitems;
Vector<int> translation_locales_idxs_remap;
+ Label *ts_name;
+ Label *ts_data_status;
+ Label *ts_data_info;
+ Button *ts_install;
+
Tree *translation_pot_list;
EditorFileDialog *pot_file_open_dialog;
EditorFileDialog *pot_generate_dialog;
@@ -89,6 +94,8 @@ class LocalizationEditor : public VBoxContainer {
void _pot_generate(const String &p_file);
void _update_pot_file_extensions();
+ void _install_ts_data();
+
protected:
void _notification(int p_what);
static void _bind_methods();
diff --git a/editor/node_3d_editor_gizmos.cpp b/editor/node_3d_editor_gizmos.cpp
index b7f7d637d2..97bafdd167 100644
--- a/editor/node_3d_editor_gizmos.cpp
+++ b/editor/node_3d_editor_gizmos.cpp
@@ -1625,13 +1625,13 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
int pointidx = 0;
for (int j = 0; j < 3; j++) {
bones.write[0] = parent;
- surface_tool->add_bones(bones);
- surface_tool->add_weights(weights);
- surface_tool->add_color(rootcolor);
+ surface_tool->set_bones(bones);
+ surface_tool->set_weights(weights);
+ surface_tool->set_color(rootcolor);
surface_tool->add_vertex(v0 - grests[parent].basis[j].normalized() * dist * 0.05);
- surface_tool->add_bones(bones);
- surface_tool->add_weights(weights);
- surface_tool->add_color(rootcolor);
+ surface_tool->set_bones(bones);
+ surface_tool->set_weights(weights);
+ surface_tool->set_color(rootcolor);
surface_tool->add_vertex(v0 + grests[parent].basis[j].normalized() * dist * 0.05);
if (j == closest) {
@@ -1654,24 +1654,24 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
point += axis * dist * 0.1;
bones.write[0] = parent;
- surface_tool->add_bones(bones);
- surface_tool->add_weights(weights);
- surface_tool->add_color(bonecolor);
+ surface_tool->set_bones(bones);
+ surface_tool->set_weights(weights);
+ surface_tool->set_color(bonecolor);
surface_tool->add_vertex(v0);
- surface_tool->add_bones(bones);
- surface_tool->add_weights(weights);
- surface_tool->add_color(bonecolor);
+ surface_tool->set_bones(bones);
+ surface_tool->set_weights(weights);
+ surface_tool->set_color(bonecolor);
surface_tool->add_vertex(point);
bones.write[0] = parent;
- surface_tool->add_bones(bones);
- surface_tool->add_weights(weights);
- surface_tool->add_color(bonecolor);
+ surface_tool->set_bones(bones);
+ surface_tool->set_weights(weights);
+ surface_tool->set_color(bonecolor);
surface_tool->add_vertex(point);
bones.write[0] = i;
- surface_tool->add_bones(bones);
- surface_tool->add_weights(weights);
- surface_tool->add_color(bonecolor);
+ surface_tool->set_bones(bones);
+ surface_tool->set_weights(weights);
+ surface_tool->set_color(bonecolor);
surface_tool->add_vertex(v1);
points[pointidx++] = point;
}
@@ -1680,13 +1680,13 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
SWAP(points[1], points[2]);
for (int j = 0; j < 4; j++) {
bones.write[0] = parent;
- surface_tool->add_bones(bones);
- surface_tool->add_weights(weights);
- surface_tool->add_color(bonecolor);
+ surface_tool->set_bones(bones);
+ surface_tool->set_weights(weights);
+ surface_tool->set_color(bonecolor);
surface_tool->add_vertex(points[j]);
- surface_tool->add_bones(bones);
- surface_tool->add_weights(weights);
- surface_tool->add_color(bonecolor);
+ surface_tool->set_bones(bones);
+ surface_tool->set_weights(weights);
+ surface_tool->set_color(bonecolor);
surface_tool->add_vertex(points[(j + 1) % 4]);
}
diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp
index 7a3fb1ff52..0b61db6835 100644
--- a/editor/plugins/abstract_polygon_2d_editor.cpp
+++ b/editor/plugins/abstract_polygon_2d_editor.cpp
@@ -551,9 +551,10 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
if (vertex == hover_point) {
Ref<Font> font = get_theme_font("font", "Label");
+ int font_size = get_theme_font_size("font_size", "Label");
String num = String::num(vertex.vertex);
- Size2 num_size = font->get_string_size(num);
- p_overlay->draw_string(font, point - num_size * 0.5, num, Color(1.0, 1.0, 1.0, 0.5));
+ Size2 num_size = font->get_string_size(num, font_size);
+ p_overlay->draw_string(font, point - num_size * 0.5, num, HALIGN_LEFT, -1, font_size, Color(1.0, 1.0, 1.0, 0.5));
}
}
}
diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp
index d335b29c2f..223484044a 100644
--- a/editor/plugins/animation_blend_space_1d_editor.cpp
+++ b/editor/plugins/animation_blend_space_1d_editor.cpp
@@ -201,6 +201,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_draw() {
linecolor_soft.a *= 0.5;
Ref<Font> font = get_theme_font("font", "Label");
+ int font_size = get_theme_font_size("font_size", "Label");
Ref<Texture2D> icon = get_theme_icon("KeyValue", "EditorIcons");
Ref<Texture2D> icon_selected = get_theme_icon("KeySelected", "EditorIcons");
@@ -221,7 +222,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_draw() {
float x = point;
blend_space_draw->draw_line(Point2(x, s.height - 1), Point2(x, s.height - 5 * EDSCALE), linecolor);
- blend_space_draw->draw_string(font, Point2(x + 2 * EDSCALE, s.height - 2 * EDSCALE - font->get_height() + font->get_ascent()), "0", linecolor);
+ blend_space_draw->draw_string(font, Point2(x + 2 * EDSCALE, s.height - 2 * EDSCALE - font->get_height(font_size) + font->get_ascent(font_size)), "0", HALIGN_LEFT, -1, font_size, linecolor);
blend_space_draw->draw_line(Point2(x, s.height - 5 * EDSCALE), Point2(x, 0), linecolor_soft);
}
diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp
index 60a5188af7..94785a5422 100644
--- a/editor/plugins/animation_blend_space_2d_editor.cpp
+++ b/editor/plugins/animation_blend_space_2d_editor.cpp
@@ -396,6 +396,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
Color linecolor_soft = linecolor;
linecolor_soft.a *= 0.5;
Ref<Font> font = get_theme_font("font", "Label");
+ int font_size = get_theme_font_size("font_size", "Label");
Ref<Texture2D> icon = get_theme_icon("KeyValue", "EditorIcons");
Ref<Texture2D> icon_selected = get_theme_icon("KeySelected", "EditorIcons");
@@ -412,14 +413,14 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
if (blend_space->get_min_space().y < 0) {
int y = (blend_space->get_max_space().y / (blend_space->get_max_space().y - blend_space->get_min_space().y)) * s.height;
blend_space_draw->draw_line(Point2(0, y), Point2(5 * EDSCALE, y), linecolor);
- blend_space_draw->draw_string(font, Point2(2 * EDSCALE, y - font->get_height() + font->get_ascent()), "0", linecolor);
+ blend_space_draw->draw_string(font, Point2(2 * EDSCALE, y - font->get_height(font_size) + font->get_ascent(font_size)), "0", HALIGN_LEFT, -1, font_size, linecolor);
blend_space_draw->draw_line(Point2(5 * EDSCALE, y), Point2(s.width, y), linecolor_soft);
}
if (blend_space->get_min_space().x < 0) {
int x = (-blend_space->get_min_space().x / (blend_space->get_max_space().x - blend_space->get_min_space().x)) * s.width;
blend_space_draw->draw_line(Point2(x, s.height - 1), Point2(x, s.height - 5 * EDSCALE), linecolor);
- blend_space_draw->draw_string(font, Point2(x + 2 * EDSCALE, s.height - 2 * EDSCALE - font->get_height() + font->get_ascent()), "0", linecolor);
+ blend_space_draw->draw_string(font, Point2(x + 2 * EDSCALE, s.height - 2 * EDSCALE - font->get_height(font_size) + font->get_ascent(font_size)), "0", HALIGN_LEFT, -1, font_size, linecolor);
blend_space_draw->draw_line(Point2(x, s.height - 5 * EDSCALE), Point2(x, 0), linecolor_soft);
}
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 1e56e3d11f..17cfb5f5f3 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -105,6 +105,8 @@ void AnimationPlayerEditor::_notification(int p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("panel", "Panel"));
} break;
+ case NOTIFICATION_TRANSLATION_CHANGED:
+ case NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
case NOTIFICATION_THEME_CHANGED: {
autoplay->set_icon(get_theme_icon("AutoPlay", "EditorIcons"));
@@ -1210,9 +1212,11 @@ void AnimationPlayerEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
} else {
_play_bw_pressed();
}
+ accept_event();
} break;
case KEY_S: {
_stop_pressed();
+ accept_event();
} break;
case KEY_D: {
if (!k->get_shift()) {
@@ -1220,6 +1224,7 @@ void AnimationPlayerEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
} else {
_play_pressed();
}
+ accept_event();
} break;
}
}
@@ -1545,6 +1550,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
delete_dialog->connect("confirmed", callable_mp(this, &AnimationPlayerEditor::_animation_remove_confirmed));
tool_anim = memnew(MenuButton);
+ tool_anim->set_shortcut_context(this);
tool_anim->set_flat(false);
tool_anim->set_tooltip(TTR("Animation Tools"));
tool_anim->set_text(TTR("Animation"));
diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp
index 4634d15941..c59e056f4f 100644
--- a/editor/plugins/animation_state_machine_editor.cpp
+++ b/editor/plugins/animation_state_machine_editor.cpp
@@ -559,6 +559,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
Ref<StyleBox> style_selected = get_theme_stylebox("state_machine_selectedframe", "GraphNode");
Ref<Font> font = get_theme_font("title_font", "GraphNode");
+ int font_size = get_theme_font_size("title_font_size", "GraphNode");
Color font_color = get_theme_color("title_color", "GraphNode");
Ref<Texture2D> play = get_theme_icon("Play", "EditorIcons");
Ref<Texture2D> auto_play = get_theme_icon("AutoPlay", "EditorIcons");
@@ -612,9 +613,9 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
Ref<StyleBox> sb = E->get() == selected_node ? style_selected : style;
Size2 s = sb->get_minimum_size();
- int strsize = font->get_string_size(name).width;
+ int strsize = font->get_string_size(name, font_size).width;
s.width += strsize;
- s.height += MAX(font->get_height(), play->get_height());
+ s.height += MAX(font->get_height(font_size), play->get_height());
s.width += sep + play->get_width();
if (needs_editor) {
s.width += sep + edit->get_width();
@@ -741,7 +742,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
Ref<AnimationNode> anode = state_machine->get_node(name);
bool needs_editor = AnimationTreeEditor::get_singleton()->can_edit(anode);
Ref<StyleBox> sb = name == selected_node ? style_selected : style;
- int strsize = font->get_string_size(name).width;
+ int strsize = font->get_string_size(name, font_size).width;
NodeRect &nr = node_rects.write[i];
@@ -759,12 +760,12 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
bool onstart = state_machine->get_start_node() == name;
if (onstart) {
- state_machine_draw->draw_string(font, offset + Vector2(0, -font->get_height() - 3 * EDSCALE + font->get_ascent()), TTR("Start"), font_color);
+ state_machine_draw->draw_string(font, offset + Vector2(0, -font->get_height(font_size) - 3 * EDSCALE + font->get_ascent(font_size)), TTR("Start"), HALIGN_LEFT, -1, font_size, font_color);
}
if (state_machine->get_end_node() == name) {
- int endofs = nr.node.size.x - font->get_string_size(TTR("End")).x;
- state_machine_draw->draw_string(font, offset + Vector2(endofs, -font->get_height() - 3 * EDSCALE + font->get_ascent()), TTR("End"), font_color);
+ int endofs = nr.node.size.x - font->get_string_size(TTR("End"), font_size).x;
+ state_machine_draw->draw_string(font, offset + Vector2(endofs, -font->get_height(font_size) - 3 * EDSCALE + font->get_ascent(font_size)), TTR("End"), HALIGN_LEFT, -1, font_size, font_color);
}
offset.x += sb->get_offset().x;
@@ -781,10 +782,10 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
}
offset.x += sep + play->get_width();
- nr.name.position = offset + Vector2(0, (h - font->get_height()) / 2).floor();
- nr.name.size = Vector2(strsize, font->get_height());
+ nr.name.position = offset + Vector2(0, (h - font->get_height(font_size)) / 2).floor();
+ nr.name.size = Vector2(strsize, font->get_height(font_size));
- state_machine_draw->draw_string(font, nr.name.position + Vector2(0, font->get_ascent()), name, font_color);
+ state_machine_draw->draw_string(font, nr.name.position + Vector2(0, font->get_ascent(font_size)), name, HALIGN_LEFT, -1, font_size, font_color);
offset.x += strsize + sep;
if (needs_editor) {
@@ -880,7 +881,7 @@ void AnimationNodeStateMachineEditor::_update_graph() {
}
void AnimationNodeStateMachineEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
+ if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) {
error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index 5742becf3a..9ecf5193a2 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -580,7 +580,7 @@ void EditorAssetLibrary::_notification(int p_what) {
}
}
-void EditorAssetLibrary::_unhandled_input(const Ref<InputEvent> &p_event) {
+void EditorAssetLibrary::_unhandled_key_input(const Ref<InputEvent> &p_event) {
const Ref<InputEventKey> key = p_event;
if (key.is_valid() && key->is_pressed()) {
@@ -1281,7 +1281,7 @@ void EditorAssetLibrary::disable_community_support() {
}
void EditorAssetLibrary::_bind_methods() {
- ClassDB::bind_method("_unhandled_input", &EditorAssetLibrary::_unhandled_input);
+ ClassDB::bind_method("_unhandled_key_input", &EditorAssetLibrary::_unhandled_key_input);
ADD_SIGNAL(MethodInfo("install_asset", PropertyInfo(Variant::STRING, "zip_path"), PropertyInfo(Variant::STRING, "name")));
}
@@ -1454,7 +1454,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
description = nullptr;
set_process(true);
- set_process_unhandled_input(true);
+ set_process_unhandled_key_input(true); // Global shortcuts since there is no main element to be focused.
downloads_scroll = memnew(ScrollContainer);
downloads_scroll->set_enable_h_scroll(true);
diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h
index f7ad53f87b..9761dbba1e 100644
--- a/editor/plugins/asset_library_editor_plugin.h
+++ b/editor/plugins/asset_library_editor_plugin.h
@@ -298,7 +298,7 @@ class EditorAssetLibrary : public PanelContainer {
protected:
static void _bind_methods();
void _notification(int p_what);
- void _unhandled_input(const Ref<InputEvent> &p_event);
+ void _unhandled_key_input(const Ref<InputEvent> &p_event);
public:
void disable_community_support();
diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp
index e6f6b6f2e0..998916349c 100644
--- a/editor/plugins/audio_stream_editor_plugin.cpp
+++ b/editor/plugins/audio_stream_editor_plugin.cpp
@@ -236,11 +236,13 @@ AudioStreamEditor::AudioStreamEditor() {
_current_label->set_align(Label::ALIGN_RIGHT);
_current_label->set_h_size_flags(SIZE_EXPAND_FILL);
_current_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts"));
+ _current_label->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("status_source_size", "EditorFonts"));
_current_label->set_modulate(Color(1, 1, 1, 0.5));
hbox->add_child(_current_label);
_duration_label = memnew(Label);
_duration_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts"));
+ _duration_label->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("status_source_size", "EditorFonts"));
hbox->add_child(_duration_label);
}
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 6acf80a2c1..b1bac34f46 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -52,7 +52,6 @@
#include "scene/gui/subviewport_container.h"
#include "scene/main/canvas_layer.h"
#include "scene/main/window.h"
-#include "scene/resources/dynamic_font.h"
#include "scene/resources/packed_scene.h"
// Min and Max are power of two in order to play nicely with successive increment.
@@ -479,22 +478,24 @@ void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
return;
}
- if (k->get_keycode() == KEY_CONTROL || k->get_keycode() == KEY_ALT || k->get_keycode() == KEY_SHIFT) {
- viewport->update();
- }
-
- if (k->is_pressed() && !k->get_control() && !k->is_echo()) {
- if ((grid_snap_active || show_grid) && multiply_grid_step_shortcut.is_valid() && multiply_grid_step_shortcut->is_shortcut(p_ev)) {
- // Multiply the grid size
- grid_step_multiplier = MIN(grid_step_multiplier + 1, 12);
+ if (k.is_valid()) {
+ if (k->get_keycode() == KEY_CONTROL || k->get_keycode() == KEY_ALT || k->get_keycode() == KEY_SHIFT) {
viewport->update();
- } else if ((grid_snap_active || show_grid) && divide_grid_step_shortcut.is_valid() && divide_grid_step_shortcut->is_shortcut(p_ev)) {
- // Divide the grid size
- Point2 new_grid_step = grid_step * Math::pow(2.0, grid_step_multiplier - 1);
- if (new_grid_step.x >= 1.0 && new_grid_step.y >= 1.0) {
- grid_step_multiplier--;
+ }
+
+ if (k->is_pressed() && !k->get_control() && !k->is_echo()) {
+ if ((grid_snap_active || show_grid) && multiply_grid_step_shortcut.is_valid() && multiply_grid_step_shortcut->is_shortcut(p_ev)) {
+ // Multiply the grid size
+ grid_step_multiplier = MIN(grid_step_multiplier + 1, 12);
+ viewport->update();
+ } else if ((grid_snap_active || show_grid) && divide_grid_step_shortcut.is_valid() && divide_grid_step_shortcut->is_shortcut(p_ev)) {
+ // Divide the grid size
+ Point2 new_grid_step = grid_step * Math::pow(2.0, grid_step_multiplier - 1);
+ if (new_grid_step.x >= 1.0 && new_grid_step.y >= 1.0) {
+ grid_step_multiplier--;
+ }
+ viewport->update();
}
- viewport->update();
}
}
}
@@ -857,7 +858,11 @@ Vector2 CanvasItemEditor::_anchor_to_position(const Control *p_control, Vector2
Transform2D parent_transform = p_control->get_transform().affine_inverse();
Rect2 parent_rect = p_control->get_parent_anchorable_rect();
- return parent_transform.xform(parent_rect.position + Vector2(parent_rect.size.x * anchor.x, parent_rect.size.y * anchor.y));
+ if (p_control->is_layout_rtl()) {
+ return parent_transform.xform(parent_rect.position + Vector2(parent_rect.size.x - parent_rect.size.x * anchor.x, parent_rect.size.y * anchor.y));
+ } else {
+ return parent_transform.xform(parent_rect.position + Vector2(parent_rect.size.x * anchor.x, parent_rect.size.y * anchor.y));
+ }
}
Vector2 CanvasItemEditor::_position_to_anchor(const Control *p_control, Vector2 position) {
@@ -866,7 +871,11 @@ Vector2 CanvasItemEditor::_position_to_anchor(const Control *p_control, Vector2
Rect2 parent_rect = p_control->get_parent_anchorable_rect();
Vector2 output = Vector2();
- output.x = (parent_rect.size.x == 0) ? 0.0 : (p_control->get_transform().xform(position).x - parent_rect.position.x) / parent_rect.size.x;
+ if (p_control->is_layout_rtl()) {
+ output.x = (parent_rect.size.x == 0) ? 0.0 : (parent_rect.size.x - p_control->get_transform().xform(position).x - parent_rect.position.x) / parent_rect.size.x;
+ } else {
+ output.x = (parent_rect.size.x == 0) ? 0.0 : (p_control->get_transform().xform(position).x - parent_rect.position.x) / parent_rect.size.x;
+ }
output.y = (parent_rect.size.y == 0) ? 0.0 : (p_control->get_transform().xform(position).y - parent_rect.position.y) / parent_rect.size.y;
return output;
}
@@ -1628,7 +1637,11 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref<InputEvent> &p_event) {
for (int i = 0; i < 4; i++) {
anchor_pos[i] = (transform * control->get_global_transform_with_canvas()).xform(_anchor_to_position(control, anchor_pos[i]));
anchor_rects[i] = Rect2(anchor_pos[i], anchor_handle->get_size());
- anchor_rects[i].position -= anchor_handle->get_size() * Vector2(float(i == 0 || i == 3), float(i <= 1));
+ if (control->is_layout_rtl()) {
+ anchor_rects[i].position -= anchor_handle->get_size() * Vector2(float(i == 1 || i == 2), float(i <= 1));
+ } else {
+ anchor_rects[i].position -= anchor_handle->get_size() * Vector2(float(i == 0 || i == 3), float(i <= 1));
+ }
}
DragType dragger[] = {
@@ -2771,7 +2784,8 @@ void CanvasItemEditor::_draw_text_at_position(Point2 p_position, String p_string
Color color = get_theme_color("font_color", "Editor");
color.a = 0.8;
Ref<Font> font = get_theme_font("font", "Label");
- Size2 text_size = font->get_string_size(p_string);
+ int font_size = get_theme_font_size("font_size", "Label");
+ Size2 text_size = font->get_string_size(p_string, font_size);
switch (p_side) {
case MARGIN_LEFT:
p_position += Vector2(-text_size.x - 5, text_size.y / 2);
@@ -2786,18 +2800,18 @@ void CanvasItemEditor::_draw_text_at_position(Point2 p_position, String p_string
p_position += Vector2(-text_size.x / 2, text_size.y + 5);
break;
}
- viewport->draw_string(font, p_position, p_string, color);
+ viewport->draw_string(font, p_position, p_string, HALIGN_LEFT, -1, font_size, color);
}
void CanvasItemEditor::_draw_margin_at_position(int p_value, Point2 p_position, Margin p_side) {
- String str = vformat("%d px", p_value);
+ String str = TS->format_number(vformat("%d " + TTR("px"), p_value));
if (p_value != 0) {
_draw_text_at_position(p_position, str, p_side);
}
}
void CanvasItemEditor::_draw_percentage_at_position(float p_value, Point2 p_position, Margin p_side) {
- String str = vformat("%.1f %%", p_value * 100.0);
+ String str = TS->format_number(vformat("%.1f ", p_value * 100.0)) + TS->percent_sign();
if (p_value != 0) {
_draw_text_at_position(p_position, str, p_side);
}
@@ -2841,17 +2855,19 @@ void CanvasItemEditor::_draw_guides() {
Color text_color = get_theme_color("font_color", "Editor");
text_color.a = 0.5;
if (drag_type == DRAG_DOUBLE_GUIDE || drag_type == DRAG_V_GUIDE) {
- String str = vformat("%d px", Math::round(xform.affine_inverse().xform(dragged_guide_pos).x));
+ String str = TS->format_number(vformat("%d px", Math::round(xform.affine_inverse().xform(dragged_guide_pos).x)));
Ref<Font> font = get_theme_font("font", "Label");
- Size2 text_size = font->get_string_size(str);
- viewport->draw_string(font, Point2(dragged_guide_pos.x + 10, RULER_WIDTH + text_size.y / 2 + 10), str, text_color);
+ int font_size = get_theme_font_size("font_size", "Label");
+ Size2 text_size = font->get_string_size(str, font_size);
+ viewport->draw_string(font, Point2(dragged_guide_pos.x + 10, RULER_WIDTH + text_size.y / 2 + 10), str, HALIGN_LEFT, -1, font_size, text_color);
viewport->draw_line(Point2(dragged_guide_pos.x, 0), Point2(dragged_guide_pos.x, viewport->get_size().y), guide_color, Math::round(EDSCALE));
}
if (drag_type == DRAG_DOUBLE_GUIDE || drag_type == DRAG_H_GUIDE) {
- String str = vformat("%d px", Math::round(xform.affine_inverse().xform(dragged_guide_pos).y));
+ String str = TS->format_number(vformat("%d px", Math::round(xform.affine_inverse().xform(dragged_guide_pos).y)));
Ref<Font> font = get_theme_font("font", "Label");
- Size2 text_size = font->get_string_size(str);
- viewport->draw_string(font, Point2(RULER_WIDTH + 10, dragged_guide_pos.y + text_size.y / 2 + 10), str, text_color);
+ int font_size = get_theme_font_size("font_size", "Label");
+ Size2 text_size = font->get_string_size(str, font_size);
+ viewport->draw_string(font, Point2(RULER_WIDTH + 10, dragged_guide_pos.y + text_size.y / 2 + 10), str, HALIGN_LEFT, -1, font_size, text_color);
viewport->draw_line(Point2(0, dragged_guide_pos.y), Point2(viewport->get_size().x, dragged_guide_pos.y), guide_color, Math::round(EDSCALE));
}
}
@@ -2876,6 +2892,7 @@ void CanvasItemEditor::_draw_rulers() {
Color font_color = get_theme_color("font_color", "Editor");
font_color.a = 0.8;
Ref<Font> font = get_theme_font("rulers", "EditorFonts");
+ int font_size = get_theme_font_size("rulers_size", "EditorFonts");
// The rule transform
Transform2D ruler_transform = Transform2D();
@@ -2922,7 +2939,7 @@ void CanvasItemEditor::_draw_rulers() {
if (i % (major_subdivision * minor_subdivision) == 0) {
viewport->draw_line(Point2(position.x, 0), Point2(position.x, RULER_WIDTH), graduation_color, Math::round(EDSCALE));
float val = (ruler_transform * major_subdivide * minor_subdivide).xform(Point2(i, 0)).x;
- viewport->draw_string(font, Point2(position.x + 2, font->get_height()), vformat(((int)val == val) ? "%d" : "%.1f", val), font_color);
+ viewport->draw_string(font, Point2(position.x + 2, font->get_height(font_size)), TS->format_number(vformat(((int)val == val) ? "%d" : "%.1f", val)), HALIGN_LEFT, -1, font_size, font_color);
} else {
if (i % minor_subdivision == 0) {
viewport->draw_line(Point2(position.x, RULER_WIDTH * 0.33), Point2(position.x, RULER_WIDTH), graduation_color, Math::round(EDSCALE));
@@ -2940,9 +2957,9 @@ void CanvasItemEditor::_draw_rulers() {
viewport->draw_line(Point2(0, position.y), Point2(RULER_WIDTH, position.y), graduation_color, Math::round(EDSCALE));
float val = (ruler_transform * major_subdivide * minor_subdivide).xform(Point2(0, i)).y;
- Transform2D text_xform = Transform2D(-Math_PI / 2.0, Point2(font->get_height(), position.y - 2));
+ Transform2D text_xform = Transform2D(-Math_PI / 2.0, Point2(font->get_height(font_size), position.y - 2));
viewport->draw_set_transform_matrix(viewport->get_transform() * text_xform);
- viewport->draw_string(font, Point2(), vformat(((int)val == val) ? "%d" : "%.1f", val), font_color);
+ viewport->draw_string(font, Point2(), TS->format_number(vformat(((int)val == val) ? "%d" : "%.1f", val)), HALIGN_LEFT, -1, font_size, font_color);
viewport->draw_set_transform_matrix(viewport->get_transform());
} else {
@@ -3054,17 +3071,18 @@ void CanvasItemEditor::_draw_ruler_tool() {
}
Ref<Font> font = get_theme_font("bold", "EditorFonts");
+ int font_size = get_theme_font_size("bold_size", "EditorFonts");
Color font_color = get_theme_color("font_color", "Editor");
Color font_secondary_color = font_color;
font_secondary_color.a = 0.5;
- float text_height = font->get_height();
+ float text_height = font->get_height(font_size);
const float text_width = 76;
const float angle_text_width = 54;
Point2 text_pos = (begin + end) / 2 - Vector2(text_width / 2, text_height / 2);
text_pos.x = CLAMP(text_pos.x, text_width / 2, viewport->get_rect().size.x - text_width * 1.5);
text_pos.y = CLAMP(text_pos.y, text_height * 1.5, viewport->get_rect().size.y - text_height * 1.5);
- viewport->draw_string(font, text_pos, vformat("%.2f px", length_vector.length()), font_color);
+ viewport->draw_string(font, text_pos, TS->format_number(vformat("%.2f " + TTR("px"), length_vector.length())), HALIGN_LEFT, -1, font_size, font_color);
if (draw_secondary_lines) {
const float horizontal_angle_rad = atan2(length_vector.y, length_vector.x);
@@ -3074,16 +3092,16 @@ void CanvasItemEditor::_draw_ruler_tool() {
Point2 text_pos2 = text_pos;
text_pos2.x = begin.x < text_pos.x ? MIN(text_pos.x - text_width, begin.x - text_width / 2) : MAX(text_pos.x + text_width, begin.x - text_width / 2);
- viewport->draw_string(font, text_pos2, vformat("%.2f px", length_vector.y), font_secondary_color);
+ viewport->draw_string(font, text_pos2, TS->format_number(vformat("%.2f " + TTR("px"), length_vector.y)), HALIGN_LEFT, -1, font_size, font_secondary_color);
Point2 v_angle_text_pos = Point2();
v_angle_text_pos.x = CLAMP(begin.x - angle_text_width / 2, angle_text_width / 2, viewport->get_rect().size.x - angle_text_width);
v_angle_text_pos.y = begin.y < end.y ? MIN(text_pos2.y - 2 * text_height, begin.y - text_height * 0.5) : MAX(text_pos2.y + text_height * 3, begin.y + text_height * 1.5);
- viewport->draw_string(font, v_angle_text_pos, vformat("%d deg", vertical_angle), font_secondary_color);
+ viewport->draw_string(font, v_angle_text_pos, TS->format_number(vformat("%d " + TTR("deg"), vertical_angle)), HALIGN_LEFT, -1, font_size, font_secondary_color);
text_pos2 = text_pos;
text_pos2.y = end.y < text_pos.y ? MIN(text_pos.y - text_height * 2, end.y - text_height / 2) : MAX(text_pos.y + text_height * 2, end.y - text_height / 2);
- viewport->draw_string(font, text_pos2, vformat("%.2f px", length_vector.x), font_secondary_color);
+ viewport->draw_string(font, text_pos2, TS->format_number(vformat("%.2f " + TTR("px"), length_vector.x)), HALIGN_LEFT, -1, font_size, font_secondary_color);
Point2 h_angle_text_pos = Point2();
h_angle_text_pos.x = CLAMP(end.x - angle_text_width / 2, angle_text_width / 2, viewport->get_rect().size.x - angle_text_width);
@@ -3100,7 +3118,7 @@ void CanvasItemEditor::_draw_ruler_tool() {
h_angle_text_pos.y = MIN(text_pos.y - height_multiplier * text_height, MIN(end.y - text_height * 0.5, text_pos2.y - height_multiplier * text_height));
}
}
- viewport->draw_string(font, h_angle_text_pos, vformat("%d deg", horizontal_angle), font_secondary_color);
+ viewport->draw_string(font, h_angle_text_pos, TS->format_number(vformat("%d " + TTR("deg"), horizontal_angle)), HALIGN_LEFT, -1, font_size, font_secondary_color);
// Angle arcs
int arc_point_count = 8;
@@ -3137,17 +3155,17 @@ void CanvasItemEditor::_draw_ruler_tool() {
text_pos.y = CLAMP(text_pos.y, text_height * 2.5, viewport->get_rect().size.y - text_height / 2);
if (draw_secondary_lines) {
- viewport->draw_string(font, text_pos, vformat("%.2f units", (length_vector / grid_step).length()), font_color);
+ viewport->draw_string(font, text_pos, TS->format_number(vformat("%.2f " + TTR("units"), (length_vector / grid_step).length())), HALIGN_LEFT, -1, font_size, font_color);
Point2 text_pos2 = text_pos;
text_pos2.x = begin.x < text_pos.x ? MIN(text_pos.x - text_width, begin.x - text_width / 2) : MAX(text_pos.x + text_width, begin.x - text_width / 2);
- viewport->draw_string(font, text_pos2, vformat("%d units", roundf(length_vector.y / grid_step.y)), font_secondary_color);
+ viewport->draw_string(font, text_pos2, TS->format_number(vformat("%d " + TTR("units"), roundf(length_vector.y / grid_step.y))), HALIGN_LEFT, -1, font_size, font_secondary_color);
text_pos2 = text_pos;
text_pos2.y = end.y < text_pos.y ? MIN(text_pos.y - text_height * 2, end.y + text_height / 2) : MAX(text_pos.y + text_height * 2, end.y + text_height / 2);
- viewport->draw_string(font, text_pos2, vformat("%d units", roundf(length_vector.x / grid_step.x)), font_secondary_color);
+ viewport->draw_string(font, text_pos2, TS->format_number(vformat("%d " + TTR("units"), roundf(length_vector.x / grid_step.x))), HALIGN_LEFT, -1, font_size, font_secondary_color);
} else {
- viewport->draw_string(font, text_pos, vformat("%d units", roundf((length_vector / grid_step).length())), font_color);
+ viewport->draw_string(font, text_pos, TS->format_number(vformat("%d " + TTR("units"), roundf((length_vector / grid_step).length()))), HALIGN_LEFT, -1, font_size, font_color);
}
}
} else {
@@ -3177,10 +3195,17 @@ void CanvasItemEditor::_draw_control_anchors(Control *control) {
// Draw the anchors handles
Rect2 anchor_rects[4];
- anchor_rects[0] = Rect2(anchors_pos[0] - anchor_handle->get_size(), anchor_handle->get_size());
- anchor_rects[1] = Rect2(anchors_pos[1] - Vector2(0.0, anchor_handle->get_size().y), Point2(-anchor_handle->get_size().x, anchor_handle->get_size().y));
- anchor_rects[2] = Rect2(anchors_pos[2], -anchor_handle->get_size());
- anchor_rects[3] = Rect2(anchors_pos[3] - Vector2(anchor_handle->get_size().x, 0.0), Point2(anchor_handle->get_size().x, -anchor_handle->get_size().y));
+ if (control->is_layout_rtl()) {
+ anchor_rects[0] = Rect2(anchors_pos[0] - Vector2(0.0, anchor_handle->get_size().y), Point2(-anchor_handle->get_size().x, anchor_handle->get_size().y));
+ anchor_rects[1] = Rect2(anchors_pos[1] - anchor_handle->get_size(), anchor_handle->get_size());
+ anchor_rects[2] = Rect2(anchors_pos[2] - Vector2(anchor_handle->get_size().x, 0.0), Point2(anchor_handle->get_size().x, -anchor_handle->get_size().y));
+ anchor_rects[3] = Rect2(anchors_pos[3], -anchor_handle->get_size());
+ } else {
+ anchor_rects[0] = Rect2(anchors_pos[0] - anchor_handle->get_size(), anchor_handle->get_size());
+ anchor_rects[1] = Rect2(anchors_pos[1] - Vector2(0.0, anchor_handle->get_size().y), Point2(-anchor_handle->get_size().x, anchor_handle->get_size().y));
+ anchor_rects[2] = Rect2(anchors_pos[2], -anchor_handle->get_size());
+ anchor_rects[3] = Rect2(anchors_pos[3] - Vector2(anchor_handle->get_size().x, 0.0), Point2(anchor_handle->get_size().x, -anchor_handle->get_size().y));
+ }
for (int i = 0; i < 4; i++) {
anchor_handle->draw_rect(ci, anchor_rects[i]);
@@ -3744,6 +3769,7 @@ void CanvasItemEditor::_draw_hover() {
String node_name = hovering_results[i].name;
Ref<Font> font = get_theme_font("font", "Label");
+ int font_size = get_theme_font_size("font_size", "Label");
Size2 node_name_size = font->get_string_size(node_name);
Size2 item_size = Size2(node_icon->get_size().x + 4 + node_name_size.x, MAX(node_icon->get_size().y, node_name_size.y - 3));
@@ -3761,7 +3787,7 @@ void CanvasItemEditor::_draw_hover() {
viewport->draw_texture(node_icon, pos, Color(1.0, 1.0, 1.0, 0.5));
// Draw name
- viewport->draw_string(font, pos + Point2(node_icon->get_size().x + 4, item_size.y - 3), node_name, Color(1.0, 1.0, 1.0, 0.5));
+ viewport->draw_string(font, pos + Point2(node_icon->get_size().x + 4, item_size.y - 3), node_name, HALIGN_LEFT, -1, font_size, Color(1.0, 1.0, 1.0, 0.5));
}
}
@@ -4342,8 +4368,13 @@ void CanvasItemEditor::_update_scrollbars() {
}
// Move and resize the scrollbars, avoiding overlap.
- v_scroll->set_begin(Point2(size.width - vmin.width, (show_rulers) ? RULER_WIDTH : 0));
- v_scroll->set_end(Point2(size.width, size.height - (h_scroll->is_visible() ? hmin.height : 0)));
+ if (is_layout_rtl()) {
+ v_scroll->set_begin(Point2(0, (show_rulers) ? RULER_WIDTH : 0));
+ v_scroll->set_end(Point2(vmin.width, size.height - (h_scroll->is_visible() ? hmin.height : 0)));
+ } else {
+ v_scroll->set_begin(Point2(size.width - vmin.width, (show_rulers) ? RULER_WIDTH : 0));
+ v_scroll->set_end(Point2(size.width, size.height - (h_scroll->is_visible() ? hmin.height : 0)));
+ }
h_scroll->set_begin(Point2((show_rulers) ? RULER_WIDTH : 0, size.height - hmin.height));
h_scroll->set_end(Point2(size.width - (v_scroll->is_visible() ? vmin.width : 0), size.height));
@@ -4540,9 +4571,9 @@ void CanvasItemEditor::_update_zoom_label() {
// even if their display doesn't have a particularly low DPI.
if (zoom >= 10) {
// Don't show a decimal when the zoom level is higher than 1000 %.
- zoom_text = rtos(Math::round((zoom / MAX(1, EDSCALE)) * 100)) + " %";
+ zoom_text = TS->format_number(rtos(Math::round((zoom / MAX(1, EDSCALE)) * 100))) + " " + TS->percent_sign();
} else {
- zoom_text = rtos(Math::stepify((zoom / MAX(1, EDSCALE)) * 100, 0.1)) + " %";
+ zoom_text = TS->format_number(rtos(Math::stepify((zoom / MAX(1, EDSCALE)) * 100, 0.1))) + " " + TS->percent_sign();
}
zoom_reset->set_text(zoom_text);
@@ -5703,6 +5734,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
warning_child_of_container->set_text(TTR("Warning: Children of a container get their position and size determined only by their parent."));
warning_child_of_container->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("warning_color", "Editor"));
warning_child_of_container->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("main", "EditorFonts"));
+ warning_child_of_container->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("main_size", "EditorFonts"));
add_control_to_info_overlay(warning_child_of_container);
h_scroll = memnew(HScrollBar);
@@ -5722,18 +5754,18 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
zoom_hb->add_child(zoom_minus);
zoom_minus->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_zoom_minus));
zoom_minus->set_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_minus", TTR("Zoom Out"), KEY_MASK_CMD | KEY_MINUS));
+ zoom_minus->set_shortcut_context(this);
zoom_minus->set_focus_mode(FOCUS_NONE);
zoom_reset = memnew(Button);
zoom_reset->set_flat(true);
zoom_hb->add_child(zoom_reset);
- Ref<DynamicFont> font = zoom_reset->get_theme_font("font")->duplicate(false);
- font->set_outline_size(1);
- font->set_outline_color(Color(0, 0, 0));
- zoom_reset->add_theme_font_override("font", font);
+ zoom_reset->add_theme_constant_override("outline_size", 1);
+ zoom_reset->add_theme_color_override("font_outline_modulate", Color(0, 0, 0));
zoom_reset->add_theme_color_override("font_color", Color(1, 1, 1));
zoom_reset->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_zoom_reset));
zoom_reset->set_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_reset", TTR("Zoom Reset"), KEY_MASK_CMD | KEY_0));
+ zoom_reset->set_shortcut_context(this);
zoom_reset->set_focus_mode(FOCUS_NONE);
zoom_reset->set_text_align(Button::TextAlign::ALIGN_CENTER);
// Prevent the button's size from changing when the text size changes
@@ -5744,6 +5776,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
zoom_hb->add_child(zoom_plus);
zoom_plus->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_zoom_plus));
zoom_plus->set_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_plus", TTR("Zoom In"), KEY_MASK_CMD | KEY_EQUAL)); // Usually direct access key for PLUS
+ zoom_plus->set_shortcut_context(this);
zoom_plus->set_focus_mode(FOCUS_NONE);
updating_scroll = false;
@@ -5755,6 +5788,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
select_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_tool_select), make_binds(TOOL_SELECT));
select_button->set_pressed(true);
select_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/select_mode", TTR("Select Mode"), KEY_Q));
+ select_button->set_shortcut_context(this);
select_button->set_tooltip(keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate") + "\n" + TTR("Alt+Drag: Move") + "\n" + TTR("Press 'v' to Change Pivot, 'Shift+v' to Drag Pivot (while moving).") + "\n" + TTR("Alt+RMB: Depth list selection"));
hb->add_child(memnew(VSeparator));
@@ -5765,6 +5799,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
move_button->set_toggle_mode(true);
move_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_tool_select), make_binds(TOOL_MOVE));
move_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/move_mode", TTR("Move Mode"), KEY_W));
+ move_button->set_shortcut_context(this);
move_button->set_tooltip(TTR("Move Mode"));
rotate_button = memnew(Button);
@@ -5773,6 +5808,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
rotate_button->set_toggle_mode(true);
rotate_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_tool_select), make_binds(TOOL_ROTATE));
rotate_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/rotate_mode", TTR("Rotate Mode"), KEY_E));
+ rotate_button->set_shortcut_context(this);
rotate_button->set_tooltip(TTR("Rotate Mode"));
scale_button = memnew(Button);
@@ -5781,6 +5817,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
scale_button->set_toggle_mode(true);
scale_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_tool_select), make_binds(TOOL_SCALE));
scale_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/scale_mode", TTR("Scale Mode"), KEY_S));
+ scale_button->set_shortcut_context(this);
scale_button->set_tooltip(TTR("Scale Mode"));
hb->add_child(memnew(VSeparator));
@@ -5805,6 +5842,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
pan_button->set_toggle_mode(true);
pan_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_tool_select), make_binds(TOOL_PAN));
pan_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/pan_mode", TTR("Pan Mode"), KEY_G));
+ pan_button->set_shortcut_context(this);
pan_button->set_tooltip(TTR("Pan Mode"));
ruler_button = memnew(Button);
@@ -5813,6 +5851,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
ruler_button->set_toggle_mode(true);
ruler_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_tool_select), make_binds(TOOL_RULER));
ruler_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/ruler_mode", TTR("Ruler Mode"), KEY_R));
+ ruler_button->set_shortcut_context(this);
ruler_button->set_tooltip(TTR("Ruler Mode"));
hb->add_child(memnew(VSeparator));
@@ -5824,6 +5863,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
smart_snap_button->connect("toggled", callable_mp(this, &CanvasItemEditor::_button_toggle_smart_snap));
smart_snap_button->set_tooltip(TTR("Toggle smart snapping."));
smart_snap_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/use_smart_snap", TTR("Use Smart Snap"), KEY_MASK_SHIFT | KEY_S));
+ smart_snap_button->set_shortcut_context(this);
grid_snap_button = memnew(Button);
grid_snap_button->set_flat(true);
@@ -5832,8 +5872,10 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
grid_snap_button->connect("toggled", callable_mp(this, &CanvasItemEditor::_button_toggle_grid_snap));
grid_snap_button->set_tooltip(TTR("Toggle grid snapping."));
grid_snap_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/use_grid_snap", TTR("Use Grid Snap"), KEY_MASK_SHIFT | KEY_G));
+ grid_snap_button->set_shortcut_context(this);
snap_config_menu = memnew(MenuButton);
+ snap_config_menu->set_shortcut_context(this);
hb->add_child(snap_config_menu);
snap_config_menu->set_h_size_flags(SIZE_SHRINK_END);
snap_config_menu->set_tooltip(TTR("Snapping Options"));
@@ -5893,6 +5935,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
hb->add_child(memnew(VSeparator));
skeleton_menu = memnew(MenuButton);
+ skeleton_menu->set_shortcut_context(this);
hb->add_child(skeleton_menu);
skeleton_menu->set_tooltip(TTR("Skeleton Options"));
skeleton_menu->set_switch_on_hover(true);
@@ -5921,6 +5964,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
hb->add_child(memnew(VSeparator));
view_menu = memnew(MenuButton);
+ view_menu->set_shortcut_context(this);
view_menu->set_text(TTR("View"));
hb->add_child(view_menu);
view_menu->get_popup()->connect("id_pressed", callable_mp(this, &CanvasItemEditor::_popup_callback));
@@ -5928,7 +5972,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
p = view_menu->get_popup();
p->set_hide_on_checkable_item_selection(false);
- p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_grid", TTR("Always Show Grid"), KEY_G), SHOW_GRID);
+ p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_grid", TTR("Always Show Grid"), KEY_MASK_CTRL | KEY_G), SHOW_GRID);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_helpers", TTR("Show Helpers"), KEY_H), SHOW_HELPERS);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_rulers", TTR("Show Rulers")), SHOW_RULERS);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_guides", TTR("Show Guides"), KEY_Y), SHOW_GUIDES);
@@ -5945,6 +5989,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/preview_canvas_scale", TTR("Preview Canvas Scale"), KEY_MASK_SHIFT | KEY_MASK_CMD | KEY_P), PREVIEW_CANVAS_SCALE);
presets_menu = memnew(MenuButton);
+ presets_menu->set_shortcut_context(this);
presets_menu->set_text(TTR("Layout"));
hb->add_child(presets_menu);
presets_menu->hide();
@@ -5978,6 +6023,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
key_loc_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_popup_callback), varray(ANIM_INSERT_POS));
key_loc_button->set_tooltip(TTR("Translation mask for inserting keys."));
animation_hb->add_child(key_loc_button);
+
key_rot_button = memnew(Button);
key_rot_button->set_toggle_mode(true);
key_rot_button->set_flat(true);
@@ -5986,6 +6032,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
key_rot_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_popup_callback), varray(ANIM_INSERT_ROT));
key_rot_button->set_tooltip(TTR("Rotation mask for inserting keys."));
animation_hb->add_child(key_rot_button);
+
key_scale_button = memnew(Button);
key_scale_button->set_toggle_mode(true);
key_scale_button->set_flat(true);
@@ -5993,23 +6040,27 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
key_scale_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_popup_callback), varray(ANIM_INSERT_SCALE));
key_scale_button->set_tooltip(TTR("Scale mask for inserting keys."));
animation_hb->add_child(key_scale_button);
+
key_insert_button = memnew(Button);
key_insert_button->set_flat(true);
key_insert_button->set_focus_mode(FOCUS_NONE);
key_insert_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_popup_callback), varray(ANIM_INSERT_KEY));
key_insert_button->set_tooltip(TTR("Insert keys (based on mask)."));
key_insert_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/anim_insert_key", TTR("Insert Key"), KEY_INSERT));
+ key_insert_button->set_shortcut_context(this);
animation_hb->add_child(key_insert_button);
+
key_auto_insert_button = memnew(Button);
key_auto_insert_button->set_flat(true);
key_auto_insert_button->set_toggle_mode(true);
key_auto_insert_button->set_focus_mode(FOCUS_NONE);
- //key_auto_insert_button->connect("pressed", this, "_popup_callback", varray(ANIM_INSERT_KEY));
key_auto_insert_button->set_tooltip(TTR("Auto insert keys when objects are translated, rotated or scaled (based on mask).\nKeys are only added to existing tracks, no new tracks will be created.\nKeys must be inserted manually for the first time."));
key_auto_insert_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/anim_auto_insert_key", TTR("Auto Insert Key")));
+ key_auto_insert_button->set_shortcut_context(this);
animation_hb->add_child(key_auto_insert_button);
animation_menu = memnew(MenuButton);
+ animation_menu->set_shortcut_context(this);
animation_menu->set_tooltip(TTR("Animation Key and Pose Options"));
animation_hb->add_child(animation_menu);
animation_menu->get_popup()->connect("id_pressed", callable_mp(this, &CanvasItemEditor::_popup_callback));
diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp
index 539ab03f5b..4768cac217 100644
--- a/editor/plugins/curve_editor_plugin.cpp
+++ b/editor/plugins/curve_editor_plugin.cpp
@@ -518,7 +518,9 @@ void CurveEditor::set_hover_point_index(int index) {
void CurveEditor::update_view_transform() {
Ref<Font> font = get_theme_font("font", "Label");
- const real_t margin = font->get_height() + 2 * EDSCALE;
+ int font_size = get_theme_font_size("font_size", "Label");
+
+ const real_t margin = font->get_height(font_size) + 2 * EDSCALE;
float min_y = 0;
float max_y = 1;
@@ -662,18 +664,19 @@ void CurveEditor::_draw() {
draw_set_transform_matrix(Transform2D());
Ref<Font> font = get_theme_font("font", "Label");
- float font_height = font->get_height();
+ int font_size = get_theme_font_size("font_size", "Label");
+ float font_height = font->get_height(font_size);
Color text_color = get_theme_color("font_color", "Editor");
{
// X axis
float y = curve.get_min_value();
Vector2 off(0, font_height - 1);
- draw_string(font, get_view_pos(Vector2(0, y)) + off, "0.0", text_color);
- draw_string(font, get_view_pos(Vector2(0.25, y)) + off, "0.25", text_color);
- draw_string(font, get_view_pos(Vector2(0.5, y)) + off, "0.5", text_color);
- draw_string(font, get_view_pos(Vector2(0.75, y)) + off, "0.75", text_color);
- draw_string(font, get_view_pos(Vector2(1, y)) + off, "1.0", text_color);
+ draw_string(font, get_view_pos(Vector2(0, y)) + off, "0.0", HALIGN_LEFT, -1, font_size, text_color);
+ draw_string(font, get_view_pos(Vector2(0.25, y)) + off, "0.25", HALIGN_LEFT, -1, font_size, text_color);
+ draw_string(font, get_view_pos(Vector2(0.5, y)) + off, "0.5", HALIGN_LEFT, -1, font_size, text_color);
+ draw_string(font, get_view_pos(Vector2(0.75, y)) + off, "0.75", HALIGN_LEFT, -1, font_size, text_color);
+ draw_string(font, get_view_pos(Vector2(1, y)) + off, "1.0", HALIGN_LEFT, -1, font_size, text_color);
}
{
@@ -682,9 +685,9 @@ void CurveEditor::_draw() {
float m1 = 0.5 * (curve.get_min_value() + curve.get_max_value());
float m2 = curve.get_max_value();
Vector2 off(1, -1);
- draw_string(font, get_view_pos(Vector2(0, m0)) + off, String::num(m0, 2), text_color);
- draw_string(font, get_view_pos(Vector2(0, m1)) + off, String::num(m1, 2), text_color);
- draw_string(font, get_view_pos(Vector2(0, m2)) + off, String::num(m2, 3), text_color);
+ draw_string(font, get_view_pos(Vector2(0, m0)) + off, String::num(m0, 2), HALIGN_LEFT, -1, font_size, text_color);
+ draw_string(font, get_view_pos(Vector2(0, m1)) + off, String::num(m1, 2), HALIGN_LEFT, -1, font_size, text_color);
+ draw_string(font, get_view_pos(Vector2(0, m2)) + off, String::num(m2, 3), HALIGN_LEFT, -1, font_size, text_color);
}
// Draw tangents for current point
@@ -744,10 +747,10 @@ void CurveEditor::_draw() {
if (_selected_point > 0 && _selected_point + 1 < curve.get_point_count()) {
text_color.a *= 0.4;
- draw_string(font, Vector2(50 * EDSCALE, font_height), TTR("Hold Shift to edit tangents individually"), text_color);
+ draw_string(font, Vector2(50 * EDSCALE, font_height), TTR("Hold Shift to edit tangents individually"), HALIGN_LEFT, -1, font_size, text_color);
} else if (curve.get_point_count() == 0) {
text_color.a *= 0.4;
- draw_string(font, Vector2(50 * EDSCALE, font_height), TTR("Right click to add point"), text_color);
+ draw_string(font, Vector2(50 * EDSCALE, font_height), TTR("Right click to add point"), HALIGN_LEFT, -1, font_size, text_color);
}
}
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index 3cf4dc5ac8..2fc0e35f82 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -37,7 +37,7 @@
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "scene/resources/bit_map.h"
-#include "scene/resources/dynamic_font.h"
+#include "scene/resources/font.h"
#include "scene/resources/material.h"
#include "scene/resources/mesh.h"
#include "servers/audio/audio_stream.h"
@@ -798,25 +798,79 @@ void EditorFontPreviewPlugin::_bind_methods() {
}
bool EditorFontPreviewPlugin::handles(const String &p_type) const {
- return ClassDB::is_parent_class(p_type, "DynamicFontData") || ClassDB::is_parent_class(p_type, "DynamicFont");
-}
+ return ClassDB::is_parent_class(p_type, "FontData") || ClassDB::is_parent_class(p_type, "Font");
+}
+
+struct FSample {
+ String script;
+ String sample;
+};
+
+static FSample _samples[] = {
+ { "hani", U"漢語" },
+ { "armn", U"Աբ" },
+ { "copt", U"Αα" },
+ { "cyrl", U"Аб" },
+ { "grek", U"Αα" },
+ { "hebr", U"אב" },
+ { "arab", U"اب" },
+ { "syrc", U"ܐܒ" },
+ { "thaa", U"ހށ" },
+ { "deva", U"आ" },
+ { "beng", U"আ" },
+ { "guru", U"ਆ" },
+ { "gujr", U"આ" },
+ { "orya", U"ଆ" },
+ { "taml", U"ஆ" },
+ { "telu", U"ఆ" },
+ { "knda", U"ಆ" },
+ { "mylm", U"ആ" },
+ { "sinh", U"ආ" },
+ { "thai", U"กิ" },
+ { "laoo", U"ກິ" },
+ { "tibt", U"ༀ" },
+ { "mymr", U"က" },
+ { "geor", U"Ⴀა" },
+ { "hang", U"한글" },
+ { "ethi", U"ሀ" },
+ { "cher", U"Ꭳ" },
+ { "cans", U"ᐁ" },
+ { "ogam", U"ᚁ" },
+ { "runr", U"ᚠ" },
+ { "tglg", U"ᜀ" },
+ { "hano", U"ᜠ" },
+ { "buhd", U"ᝀ" },
+ { "tagb", U"ᝠ" },
+ { "khmr", U"ក" },
+ { "mong", U"ᠠ" },
+ { "limb", U"ᤁ" },
+ { "tale", U"ᥐ" },
+ { "latn", U"Ab" },
+ { "zyyy", U"😀" },
+ { "", U"" }
+};
Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const {
RES res = ResourceLoader::load(p_path);
- Ref<DynamicFont> sampled_font;
- if (res->is_class("DynamicFont")) {
+ Ref<Font> sampled_font;
+ if (res->is_class("Font")) {
sampled_font = res->duplicate();
- if (sampled_font->get_outline_color() == Color(1, 1, 1, 1)) {
- sampled_font->set_outline_color(Color(0, 0, 0, 1));
- }
- } else if (res->is_class("DynamicFontData")) {
+ } else if (res->is_class("FontData")) {
sampled_font.instance();
- sampled_font->set_font_data(res);
+ sampled_font->add_data(res->duplicate());
}
- sampled_font->set_size(50);
- String sampled_text = "Abg";
- Vector2 size = sampled_font->get_string_size(sampled_text);
+ String sample;
+ for (int j = 0; j < sampled_font->get_data_count(); j++) {
+ for (int i = 0; _samples[i].script != String(); i++) {
+ if (sampled_font->get_data(j)->is_script_supported(_samples[i].script)) {
+ if (sampled_font->get_data(j)->has_char(_samples[i].sample[0])) {
+ sample += _samples[i].sample;
+ }
+ }
+ }
+ }
+ Vector2 size = sampled_font->get_string_size(sample, 50);
Vector2 pos;
@@ -825,7 +879,7 @@ Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path,
Ref<Font> font = sampled_font;
- font->draw(canvas_item, pos, sampled_text);
+ font->draw_string(canvas_item, pos, sample, HALIGN_LEFT, -1.f, 50, Color(1, 1, 1));
preview_done = false;
RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ONCE); //once used for capture
diff --git a/editor/plugins/font_editor_plugin.cpp b/editor/plugins/font_editor_plugin.cpp
new file mode 100644
index 0000000000..a82547182c
--- /dev/null
+++ b/editor/plugins/font_editor_plugin.cpp
@@ -0,0 +1,331 @@
+/*************************************************************************/
+/* font_editor_plugin.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "font_editor_plugin.h"
+
+#include "editor/editor_scale.h"
+
+void FontDataPreview::_notification(int p_what) {
+ if (p_what == NOTIFICATION_DRAW) {
+ Color text_color = get_theme_color("font_color", "Label");
+ Color line_color = text_color;
+ line_color.a *= 0.6;
+ Vector2 pos = (get_size() - line->get_size()) / 2;
+ line->draw(get_canvas_item(), pos, text_color);
+ draw_line(Vector2(0, pos.y + line->get_line_ascent()), Vector2(pos.x - 5, pos.y + line->get_line_ascent()), line_color);
+ draw_line(Vector2(pos.x + line->get_size().x + 5, pos.y + line->get_line_ascent()), Vector2(get_size().x, pos.y + line->get_line_ascent()), line_color);
+ }
+}
+
+void FontDataPreview::_bind_methods() {}
+
+Size2 FontDataPreview::get_minimum_size() const {
+ return Vector2(64, 64) * EDSCALE;
+}
+
+struct FSample {
+ String script;
+ String sample;
+};
+
+static FSample _samples[] = {
+ { "hani", U"漢語" },
+ { "armn", U"Աբ" },
+ { "copt", U"Αα" },
+ { "cyrl", U"Аб" },
+ { "grek", U"Αα" },
+ { "hebr", U"אב" },
+ { "arab", U"اب" },
+ { "syrc", U"ܐܒ" },
+ { "thaa", U"ހށ" },
+ { "deva", U"आ" },
+ { "beng", U"আ" },
+ { "guru", U"ਆ" },
+ { "gujr", U"આ" },
+ { "orya", U"ଆ" },
+ { "taml", U"ஆ" },
+ { "telu", U"ఆ" },
+ { "knda", U"ಆ" },
+ { "mylm", U"ആ" },
+ { "sinh", U"ආ" },
+ { "thai", U"กิ" },
+ { "laoo", U"ກິ" },
+ { "tibt", U"ༀ" },
+ { "mymr", U"က" },
+ { "geor", U"Ⴀა" },
+ { "hang", U"한글" },
+ { "ethi", U"ሀ" },
+ { "cher", U"Ꭳ" },
+ { "cans", U"ᐁ" },
+ { "ogam", U"ᚁ" },
+ { "runr", U"ᚠ" },
+ { "tglg", U"ᜀ" },
+ { "hano", U"ᜠ" },
+ { "buhd", U"ᝀ" },
+ { "tagb", U"ᝠ" },
+ { "khmr", U"ក" },
+ { "mong", U"ᠠ" },
+ { "limb", U"ᤁ" },
+ { "tale", U"ᥐ" },
+ { "latn", U"Ab" },
+ { "zyyy", U"😀" },
+ { "", U"" }
+};
+
+void FontDataPreview::set_data(const Ref<FontData> &p_data) {
+ Ref<Font> f = memnew(Font);
+ f->add_data(p_data);
+
+ line->clear();
+
+ String sample;
+ for (int i = 0; _samples[i].script != String(); i++) {
+ if (p_data->is_script_supported(_samples[i].script)) {
+ if (p_data->has_char(_samples[i].sample[0])) {
+ sample += _samples[i].sample;
+ }
+ }
+ }
+ line->add_string(sample, f, 72);
+
+ update();
+}
+
+FontDataPreview::FontDataPreview() {
+ line.instance();
+}
+
+/*************************************************************************/
+
+void FontDataEditor::_notification(int p_what) {
+ if (p_what == NOTIFICATION_SORT_CHILDREN) {
+ int split_width = get_name_split_ratio() * get_size().width;
+ button->set_size(Size2(get_theme_icon("Add", "EditorIcons")->get_width(), get_size().height));
+ if (is_layout_rtl()) {
+ if (le != nullptr) {
+ fit_child_in_rect(le, Rect2(Vector2(split_width, 0), Size2(split_width, get_size().height)));
+ }
+ fit_child_in_rect(chk, Rect2(Vector2(split_width - chk->get_size().x, 0), Size2(chk->get_size().x, get_size().height)));
+ fit_child_in_rect(button, Rect2(Vector2(0, 0), Size2(button->get_size().width, get_size().height)));
+ } else {
+ if (le != nullptr) {
+ fit_child_in_rect(le, Rect2(Vector2(0, 0), Size2(split_width, get_size().height)));
+ }
+ fit_child_in_rect(chk, Rect2(Vector2(split_width, 0), Size2(chk->get_size().x, get_size().height)));
+ fit_child_in_rect(button, Rect2(Vector2(get_size().width - button->get_size().width, 0), Size2(button->get_size().width, get_size().height)));
+ }
+ update();
+ }
+ if (p_what == NOTIFICATION_DRAW) {
+ int split_width = get_name_split_ratio() * get_size().width;
+ Color dark_color = get_theme_color("dark_color_2", "Editor");
+ if (is_layout_rtl()) {
+ draw_rect(Rect2(Vector2(0, 0), Size2(split_width, get_size().height)), dark_color);
+ } else {
+ draw_rect(Rect2(Vector2(split_width, 0), Size2(split_width, get_size().height)), dark_color);
+ }
+ }
+ if (p_what == NOTIFICATION_THEME_CHANGED) {
+ if (le != nullptr) {
+ button->set_icon(get_theme_icon("Add", "EditorIcons"));
+ } else {
+ button->set_icon(get_theme_icon("Remove", "EditorIcons"));
+ }
+ queue_sort();
+ }
+ if (p_what == NOTIFICATION_RESIZED) {
+ queue_sort();
+ }
+}
+
+void FontDataEditor::update_property() {
+ if (le == nullptr) {
+ bool c = get_edited_object()->get(get_edited_property());
+ chk->set_pressed(c);
+ chk->set_disabled(is_read_only());
+ }
+}
+
+Size2 FontDataEditor::get_minimum_size() const {
+ return Size2(0, 60);
+}
+
+void FontDataEditor::_bind_methods() {
+}
+
+void FontDataEditor::init_lang_add() {
+ le = memnew(LineEdit);
+ le->set_placeholder("Language code");
+ le->set_custom_minimum_size(Size2(get_size().width / 2, 0));
+ le->set_editable(true);
+ add_child(le);
+
+ button->set_icon(get_theme_icon("Add", "EditorIcons"));
+ button->connect("pressed", callable_mp(this, &FontDataEditor::add_lang));
+}
+
+void FontDataEditor::init_lang_edit() {
+ button->set_icon(get_theme_icon("Remove", "EditorIcons"));
+ button->connect("pressed", callable_mp(this, &FontDataEditor::remove_lang));
+ chk->connect("toggled", callable_mp(this, &FontDataEditor::toggle_lang));
+}
+
+void FontDataEditor::init_script_add() {
+ le = memnew(LineEdit);
+ le->set_placeholder("Script code");
+ le->set_custom_minimum_size(Size2(get_size().width / 2, 0));
+ le->set_editable(true);
+ add_child(le);
+
+ button->set_icon(get_theme_icon("Add", "EditorIcons"));
+ button->connect("pressed", callable_mp(this, &FontDataEditor::add_script));
+}
+
+void FontDataEditor::init_script_edit() {
+ button->set_icon(get_theme_icon("Remove", "EditorIcons"));
+ button->connect("pressed", callable_mp(this, &FontDataEditor::remove_script));
+ chk->connect("toggled", callable_mp(this, &FontDataEditor::toggle_script));
+}
+
+void FontDataEditor::add_lang() {
+ FontData *fd = Object::cast_to<FontData>(get_edited_object());
+ if (fd != nullptr && !le->get_text().empty()) {
+ fd->set_language_support_override(le->get_text(), chk->is_pressed());
+ le->set_text("");
+ chk->set_pressed(false);
+ }
+}
+
+void FontDataEditor::add_script() {
+ FontData *fd = Object::cast_to<FontData>(get_edited_object());
+ if (fd != nullptr && le->get_text().length() == 4) {
+ fd->set_script_support_override(le->get_text(), chk->is_pressed());
+ le->set_text("");
+ chk->set_pressed(false);
+ }
+}
+
+void FontDataEditor::toggle_lang(bool p_pressed) {
+ FontData *fd = Object::cast_to<FontData>(get_edited_object());
+ if (fd != nullptr) {
+ String lang = String(get_edited_property()).replace("language_support_override/", "");
+ fd->set_language_support_override(lang, p_pressed);
+ }
+}
+
+void FontDataEditor::toggle_script(bool p_pressed) {
+ FontData *fd = Object::cast_to<FontData>(get_edited_object());
+ if (fd != nullptr) {
+ String script = String(get_edited_property()).replace("script_support_override/", "");
+ fd->set_script_support_override(script, p_pressed);
+ }
+}
+
+void FontDataEditor::remove_lang() {
+ FontData *fd = Object::cast_to<FontData>(get_edited_object());
+ if (fd != nullptr) {
+ String lang = String(get_edited_property()).replace("language_support_override/", "");
+ fd->remove_language_support_override(lang);
+ }
+}
+
+void FontDataEditor::remove_script() {
+ FontData *fd = Object::cast_to<FontData>(get_edited_object());
+ if (fd != nullptr) {
+ String script = String(get_edited_property()).replace("script_support_override/", "");
+ fd->remove_script_support_override(script);
+ }
+}
+
+FontDataEditor::FontDataEditor() {
+ chk = memnew(CheckBox);
+ chk->set_text(TTR("On"));
+ chk->set_flat(true);
+ add_child(chk);
+
+ button = memnew(Button);
+ button->set_flat(true);
+ add_child(button);
+}
+
+/*************************************************************************/
+
+bool EditorInspectorPluginFont::can_handle(Object *p_object) {
+ return Object::cast_to<FontData>(p_object) != nullptr;
+}
+
+void EditorInspectorPluginFont::parse_begin(Object *p_object) {
+ FontData *fd = Object::cast_to<FontData>(p_object);
+ ERR_FAIL_COND(!fd);
+
+ FontDataPreview *editor = memnew(FontDataPreview);
+ editor->set_data(fd);
+ add_custom_control(editor);
+}
+
+bool EditorInspectorPluginFont::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) {
+ if (p_path.begins_with("language_support_override/") && p_object->is_class("FontData")) {
+ String lang = p_path.replace("language_support_override/", "");
+
+ FontDataEditor *editor = memnew(FontDataEditor);
+ if (lang != "_new") {
+ editor->init_lang_edit();
+ } else {
+ editor->init_lang_add();
+ }
+ add_property_editor(p_path, editor);
+
+ return true;
+ }
+
+ if (p_path.begins_with("script_support_override/") && p_object->is_class("FontData")) {
+ String script = p_path.replace("script_support_override/", "");
+
+ FontDataEditor *editor = memnew(FontDataEditor);
+ if (script != "_new") {
+ editor->init_script_edit();
+ } else {
+ editor->init_script_add();
+ }
+ add_property_editor(p_path, editor);
+
+ return true;
+ }
+
+ return false;
+}
+
+/*************************************************************************/
+
+FontEditorPlugin::FontEditorPlugin(EditorNode *p_node) {
+ Ref<EditorInspectorPluginFont> fd_plugin;
+ fd_plugin.instance();
+ EditorInspector::add_inspector_plugin(fd_plugin);
+}
diff --git a/editor/plugins/font_editor_plugin.h b/editor/plugins/font_editor_plugin.h
new file mode 100644
index 0000000000..1d3ffc8857
--- /dev/null
+++ b/editor/plugins/font_editor_plugin.h
@@ -0,0 +1,111 @@
+/*************************************************************************/
+/* font_editor_plugin.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef FONT_EDITOR_PLUGIN_H
+#define FONT_EDITOR_PLUGIN_H
+
+#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
+#include "scene/resources/font.h"
+#include "scene/resources/text_line.h"
+
+class FontDataPreview : public Control {
+ GDCLASS(FontDataPreview, Control);
+
+protected:
+ void _notification(int p_what);
+ static void _bind_methods();
+
+ Ref<TextLine> line;
+
+public:
+ virtual Size2 get_minimum_size() const override;
+
+ void set_data(const Ref<FontData> &p_data);
+
+ FontDataPreview();
+};
+
+/*************************************************************************/
+
+class FontDataEditor : public EditorProperty {
+ GDCLASS(FontDataEditor, EditorProperty);
+
+ LineEdit *le = nullptr;
+ CheckBox *chk = nullptr;
+ Button *button = nullptr;
+
+ void toggle_lang(bool p_pressed);
+ void toggle_script(bool p_pressed);
+ void add_lang();
+ void add_script();
+ void remove_lang();
+ void remove_script();
+
+protected:
+ void _notification(int p_what);
+
+ static void _bind_methods();
+
+public:
+ virtual Size2 get_minimum_size() const override;
+ virtual void update_property() override;
+
+ void init_lang_add();
+ void init_lang_edit();
+ void init_script_add();
+ void init_script_edit();
+
+ FontDataEditor();
+};
+
+/*************************************************************************/
+
+class EditorInspectorPluginFont : public EditorInspectorPlugin {
+ GDCLASS(EditorInspectorPluginFont, EditorInspectorPlugin);
+
+public:
+ virtual bool can_handle(Object *p_object) override;
+ virtual void parse_begin(Object *p_object) override;
+ virtual bool parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) override;
+};
+
+/*************************************************************************/
+
+class FontEditorPlugin : public EditorPlugin {
+ GDCLASS(FontEditorPlugin, EditorPlugin);
+
+public:
+ FontEditorPlugin(EditorNode *p_node);
+
+ virtual String get_name() const override { return "Font"; }
+};
+
+#endif // FONT_EDITOR_PLUGIN_H
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 8420faa302..2530b4ecfe 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -63,12 +63,15 @@
#define GIZMO_SCALE_OFFSET (GIZMO_CIRCLE_SIZE + 0.3)
#define GIZMO_ARROW_OFFSET (GIZMO_CIRCLE_SIZE + 0.3)
-#define ZOOM_MIN_DISTANCE 0.001
-#define ZOOM_MULTIPLIER 1.08
-#define ZOOM_INDICATOR_DELAY_S 1.5
-
-#define FREELOOK_MIN_SPEED 0.01
-#define FREELOOK_SPEED_MULTIPLIER 1.08
+#define ZOOM_FREELOOK_MIN 0.01
+#define ZOOM_FREELOOK_MULTIPLIER 1.08
+#define ZOOM_FREELOOK_INDICATOR_DELAY_S 1.5
+
+#ifdef REAL_T_IS_DOUBLE
+#define ZOOM_FREELOOK_MAX 1'000'000'000'000
+#else
+#define ZOOM_FREELOOK_MAX 10'000
+#endif
#define MIN_Z 0.01
#define MAX_Z 1000000.0
@@ -138,7 +141,7 @@ void ViewportRotationControl::_draw_axis(const Axis2D &p_axis) {
if (front) {
String axis_name = direction == 0 ? "X" : (direction == 1 ? "Y" : "Z");
draw_circle(p_axis.screen_point, AXIS_CIRCLE_RADIUS, c);
- draw_char(get_theme_font("rotation_control", "EditorFonts"), p_axis.screen_point + Vector2i(-4, 5) * EDSCALE, axis_name, "", Color(0.3, 0.3, 0.3));
+ draw_char(get_theme_font("rotation_control", "EditorFonts"), p_axis.screen_point + Vector2i(-4, 5) * EDSCALE, axis_name, "", get_theme_font_size("rotation_control_size", "EditorFonts"), Color(0.3, 0.3, 0.3));
} else {
draw_circle(p_axis.screen_point, AXIS_CIRCLE_RADIUS * (0.55 + (0.2 * (1.0 + p_axis.z_axis))), c);
}
@@ -1117,7 +1120,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
if (b.is_valid()) {
emit_signal("clicked", this);
- float zoom_factor = 1 + (ZOOM_MULTIPLIER - 1) * b->get_factor();
+ float zoom_factor = 1 + (ZOOM_FREELOOK_MULTIPLIER - 1) * b->get_factor();
switch (b->get_button_index()) {
case BUTTON_WHEEL_UP: {
if (is_freelook_active()) {
@@ -2207,34 +2210,28 @@ void Node3DEditorViewport::set_freelook_active(bool active_now) {
}
void Node3DEditorViewport::scale_cursor_distance(real_t scale) {
- // Prevents zero distance which would short-circuit any scaling
- if (cursor.distance < ZOOM_MIN_DISTANCE) {
- cursor.distance = ZOOM_MIN_DISTANCE;
- }
-
- cursor.distance *= scale;
-
- if (cursor.distance < ZOOM_MIN_DISTANCE) {
- cursor.distance = ZOOM_MIN_DISTANCE;
+ real_t min_distance = MAX(camera->get_znear() * 4, ZOOM_FREELOOK_MIN);
+ real_t max_distance = MIN(camera->get_zfar() / 4, ZOOM_FREELOOK_MAX);
+ if (unlikely(min_distance > max_distance)) {
+ cursor.distance = (min_distance + max_distance) / 2;
+ } else {
+ cursor.distance = CLAMP(cursor.distance * scale, min_distance, max_distance);
}
- zoom_indicator_delay = ZOOM_INDICATOR_DELAY_S;
+ zoom_indicator_delay = ZOOM_FREELOOK_INDICATOR_DELAY_S;
surface->update();
}
void Node3DEditorViewport::scale_freelook_speed(real_t scale) {
- // Prevents zero distance which would short-circuit any scaling
- if (freelook_speed < FREELOOK_MIN_SPEED) {
- freelook_speed = FREELOOK_MIN_SPEED;
- }
-
- freelook_speed *= scale;
-
- if (freelook_speed < FREELOOK_MIN_SPEED) {
- freelook_speed = FREELOOK_MIN_SPEED;
+ real_t min_speed = MAX(camera->get_znear() * 4, ZOOM_FREELOOK_MIN);
+ real_t max_speed = MIN(camera->get_zfar() / 4, ZOOM_FREELOOK_MAX);
+ if (unlikely(min_speed > max_speed)) {
+ freelook_speed = (min_speed + max_speed) / 2;
+ } else {
+ freelook_speed = CLAMP(freelook_speed * scale, min_speed, max_speed);
}
- zoom_indicator_delay = ZOOM_INDICATOR_DELAY_S;
+ zoom_indicator_delay = ZOOM_FREELOOK_INDICATOR_DELAY_S;
surface->update();
}
@@ -2593,7 +2590,7 @@ void Node3DEditorViewport::_notification(int p_what) {
}
}
-static void draw_indicator_bar(Control &surface, real_t fill, const Ref<Texture2D> icon, const Ref<Font> font, const String &text) {
+static void draw_indicator_bar(Control &surface, real_t fill, const Ref<Texture2D> icon, const Ref<Font> font, int font_size, const String &text) {
// Adjust bar size from control height
const Vector2 surface_size = surface.get_size();
const real_t h = surface_size.y / 2.0;
@@ -2613,7 +2610,7 @@ static void draw_indicator_bar(Control &surface, real_t fill, const Ref<Texture2
surface.draw_texture(icon, icon_pos);
// Draw text below the bar (for speed/zoom information).
- surface.draw_string(font, Vector2(icon_pos.x, icon_pos.y + icon_size.y + 16 * EDSCALE), text);
+ surface.draw_string(font, Vector2(icon_pos.x, icon_pos.y + icon_size.y + 16 * EDSCALE), text, HALIGN_LEFT, -1.f, font_size);
}
void Node3DEditorViewport::_draw() {
@@ -2651,10 +2648,11 @@ void Node3DEditorViewport::_draw() {
if (message_time > 0) {
Ref<Font> font = get_theme_font("font", "Label");
+ int font_size = get_theme_font_size("font_size", "Label");
Point2 msgpos = Point2(5, get_size().y - 20);
- font->draw(ci, msgpos + Point2(1, 1), message, Color(0, 0, 0, 0.8));
- font->draw(ci, msgpos + Point2(-1, -1), message, Color(0, 0, 0, 0.8));
- font->draw(ci, msgpos, message, Color(1, 1, 1, 1));
+ font->draw_string(ci, msgpos + Point2(1, 1), message, HALIGN_LEFT, -1, font_size, Color(0, 0, 0, 0.8));
+ font->draw_string(ci, msgpos + Point2(-1, -1), message, HALIGN_LEFT, -1, font_size, Color(0, 0, 0, 0.8));
+ font->draw_string(ci, msgpos, message, HALIGN_LEFT, -1, font_size, Color(1, 1, 1, 1));
}
if (_edit.mode == TRANSFORM_ROTATE) {
@@ -2697,19 +2695,13 @@ void Node3DEditorViewport::_draw() {
if (is_freelook_active()) {
// Show speed
- real_t min_speed = FREELOOK_MIN_SPEED;
- real_t max_speed = camera->get_zfar();
+ real_t min_speed = MAX(camera->get_znear() * 4, ZOOM_FREELOOK_MIN);
+ real_t max_speed = MIN(camera->get_zfar() / 4, ZOOM_FREELOOK_MAX);
real_t scale_length = (max_speed - min_speed);
if (!Math::is_zero_approx(scale_length)) {
real_t logscale_t = 1.0 - Math::log(1 + freelook_speed - min_speed) / Math::log(1 + scale_length);
- // There is no real maximum speed so that factor can become negative,
- // Let's make it look asymptotic instead (will decrease slower and slower).
- if (logscale_t < 0.25) {
- logscale_t = 0.25 * Math::exp(4.0 * logscale_t - 1.0);
- }
-
// Display the freelook speed to help the user get a better sense of scale.
const int precision = freelook_speed < 1.0 ? 2 : 1;
draw_indicator_bar(
@@ -2717,25 +2709,20 @@ void Node3DEditorViewport::_draw() {
1.0 - logscale_t,
get_theme_icon("ViewportSpeed", "EditorIcons"),
get_theme_font("font", "Label"),
+ get_theme_font_size("font_size", "Label"),
vformat("%s u/s", String::num(freelook_speed).pad_decimals(precision)));
}
} else {
// Show zoom
- real_t min_distance = ZOOM_MIN_DISTANCE; // TODO Why not pick znear to limit zoom?
- real_t max_distance = camera->get_zfar();
+ real_t min_distance = MAX(camera->get_znear() * 4, ZOOM_FREELOOK_MIN);
+ real_t max_distance = MIN(camera->get_zfar() / 4, ZOOM_FREELOOK_MAX);
real_t scale_length = (max_distance - min_distance);
if (!Math::is_zero_approx(scale_length)) {
real_t logscale_t = 1.0 - Math::log(1 + cursor.distance - min_distance) / Math::log(1 + scale_length);
- // There is no real maximum distance so that factor can become negative,
- // Let's make it look asymptotic instead (will decrease slower and slower).
- if (logscale_t < 0.25) {
- logscale_t = 0.25 * Math::exp(4.0 * logscale_t - 1.0);
- }
-
// Display the zoom center distance to help the user get a better sense of scale.
const int precision = cursor.distance < 1.0 ? 2 : 1;
draw_indicator_bar(
@@ -2743,6 +2730,7 @@ void Node3DEditorViewport::_draw() {
logscale_t,
get_theme_icon("ViewportZoom", "EditorIcons"),
get_theme_font("font", "Label"),
+ get_theme_font_size("font_size", "Label"),
vformat("%s u", String::num(cursor.distance).pad_decimals(precision)));
}
}
@@ -2967,11 +2955,11 @@ void Node3DEditorViewport::_menu_option(int p_option) {
int idx = view_menu->get_popup()->get_item_index(VIEW_GIZMOS);
bool current = view_menu->get_popup()->is_item_checked(idx);
current = !current;
+ uint32_t layers = ((1 << 20) - 1) | (1 << (GIZMO_BASE_LAYER + index)) | (1 << GIZMO_GRID_LAYER) | (1 << MISC_TOOL_LAYER);
if (current) {
- camera->set_cull_mask(((1 << 20) - 1) | (1 << (GIZMO_BASE_LAYER + index)) | (1 << GIZMO_EDIT_LAYER) | (1 << GIZMO_GRID_LAYER));
- } else {
- camera->set_cull_mask(((1 << 20) - 1) | (1 << (GIZMO_BASE_LAYER + index)) | (1 << GIZMO_GRID_LAYER));
+ layers |= (1 << GIZMO_EDIT_LAYER);
}
+ camera->set_cull_mask(layers);
view_menu->get_popup()->set_item_checked(idx, current);
} break;
@@ -3892,7 +3880,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
surface->set_clip_contents(true);
camera = memnew(Camera3D);
camera->set_disable_gizmo(true);
- camera->set_cull_mask(((1 << 20) - 1) | (1 << (GIZMO_BASE_LAYER + p_index)) | (1 << GIZMO_EDIT_LAYER) | (1 << GIZMO_GRID_LAYER));
+ camera->set_cull_mask(((1 << 20) - 1) | (1 << (GIZMO_BASE_LAYER + p_index)) | (1 << GIZMO_EDIT_LAYER) | (1 << GIZMO_GRID_LAYER) | (1 << MISC_TOOL_LAYER));
viewport->add_child(camera);
camera->make_current();
surface->set_focus_mode(FOCUS_ALL);
@@ -3903,8 +3891,9 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
view_menu = memnew(MenuButton);
view_menu->set_flat(false);
- vbox->add_child(view_menu);
view_menu->set_h_size_flags(0);
+ view_menu->set_shortcut_context(this);
+ vbox->add_child(view_menu);
display_submenu = memnew(PopupMenu);
view_menu->get_popup()->add_child(display_submenu);
@@ -4510,12 +4499,14 @@ Object *Node3DEditor::_get_editor_data(Object *p_what) {
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(
si->sbox_instance,
RS::SHADOW_CASTING_SETTING_OFF);
+ RS::get_singleton()->instance_set_layer_mask(si->sbox_instance, 1 << Node3DEditorViewport::MISC_TOOL_LAYER);
si->sbox_instance_xray = RenderingServer::get_singleton()->instance_create2(
selection_box_xray->get_rid(),
sp->get_world_3d()->get_scenario());
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(
si->sbox_instance_xray,
RS::SHADOW_CASTING_SETTING_OFF);
+ RS::get_singleton()->instance_set_layer_mask(si->sbox_instance_xray, 1 << Node3DEditorViewport::MISC_TOOL_LAYER);
return si;
}
@@ -5356,7 +5347,7 @@ void Node3DEditor::_init_indicators() {
Vector2 ofs = Vector2(Math::cos((Math_PI * 2.0 * k) / m), Math::sin((Math_PI * 2.0 * k) / m));
Vector3 normal = ivec * ofs.x + ivec2 * ofs.y;
- surftool->add_normal(basis.xform(normal));
+ surftool->set_normal(basis.xform(normal));
surftool->add_vertex(vertex);
}
}
@@ -6217,6 +6208,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) {
button_binds.write[0] = MENU_TOOL_SELECT;
tool_button[TOOL_MODE_SELECT]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds);
tool_button[TOOL_MODE_SELECT]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_select", TTR("Select Mode"), KEY_Q));
+ tool_button[TOOL_MODE_SELECT]->set_shortcut_context(this);
tool_button[TOOL_MODE_SELECT]->set_tooltip(keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate\nAlt+Drag: Move\nAlt+RMB: Depth list selection"));
hbc_menu->add_child(memnew(VSeparator));
@@ -6228,6 +6220,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) {
button_binds.write[0] = MENU_TOOL_MOVE;
tool_button[TOOL_MODE_MOVE]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds);
tool_button[TOOL_MODE_MOVE]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_move", TTR("Move Mode"), KEY_W));
+ tool_button[TOOL_MODE_MOVE]->set_shortcut_context(this);
tool_button[TOOL_MODE_ROTATE] = memnew(Button);
hbc_menu->add_child(tool_button[TOOL_MODE_ROTATE]);
@@ -6236,6 +6229,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) {
button_binds.write[0] = MENU_TOOL_ROTATE;
tool_button[TOOL_MODE_ROTATE]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds);
tool_button[TOOL_MODE_ROTATE]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_rotate", TTR("Rotate Mode"), KEY_E));
+ tool_button[TOOL_MODE_ROTATE]->set_shortcut_context(this);
tool_button[TOOL_MODE_SCALE] = memnew(Button);
hbc_menu->add_child(tool_button[TOOL_MODE_SCALE]);
@@ -6244,6 +6238,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) {
button_binds.write[0] = MENU_TOOL_SCALE;
tool_button[TOOL_MODE_SCALE]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds);
tool_button[TOOL_MODE_SCALE]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_scale", TTR("Scale Mode"), KEY_R));
+ tool_button[TOOL_MODE_SCALE]->set_shortcut_context(this);
hbc_menu->add_child(memnew(VSeparator));
@@ -6292,6 +6287,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) {
button_binds.write[0] = MENU_TOOL_LOCAL_COORDS;
tool_option_button[TOOL_OPT_LOCAL_COORDS]->connect("toggled", callable_mp(this, &Node3DEditor::_menu_item_toggled), button_binds);
tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_shortcut(ED_SHORTCUT("spatial_editor/local_coords", TTR("Use Local Space"), KEY_T));
+ tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_shortcut_context(this);
tool_option_button[TOOL_OPT_USE_SNAP] = memnew(Button);
hbc_menu->add_child(tool_option_button[TOOL_OPT_USE_SNAP]);
@@ -6300,6 +6296,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) {
button_binds.write[0] = MENU_TOOL_USE_SNAP;
tool_option_button[TOOL_OPT_USE_SNAP]->connect("toggled", callable_mp(this, &Node3DEditor::_menu_item_toggled), button_binds);
tool_option_button[TOOL_OPT_USE_SNAP]->set_shortcut(ED_SHORTCUT("spatial_editor/snap", TTR("Use Snap"), KEY_Y));
+ tool_option_button[TOOL_OPT_USE_SNAP]->set_shortcut_context(this);
hbc_menu->add_child(memnew(VSeparator));
@@ -6337,6 +6334,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) {
transform_menu = memnew(MenuButton);
transform_menu->set_text(TTR("Transform"));
transform_menu->set_switch_on_hover(true);
+ transform_menu->set_shortcut_context(this);
hbc_menu->add_child(transform_menu);
p = transform_menu->get_popup();
@@ -6351,6 +6349,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) {
view_menu = memnew(MenuButton);
view_menu->set_text(TTR("View"));
view_menu->set_switch_on_hover(true);
+ view_menu->set_shortcut_context(this);
hbc_menu->add_child(view_menu);
p = view_menu->get_popup();
diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h
index 2e98fcad4c..12080ea1f0 100644
--- a/editor/plugins/node_3d_editor_plugin.h
+++ b/editor/plugins/node_3d_editor_plugin.h
@@ -229,6 +229,7 @@ public:
GIZMO_BASE_LAYER = 27,
GIZMO_EDIT_LAYER = 26,
GIZMO_GRID_LAYER = 25,
+ MISC_TOOL_LAYER = 24,
FRAME_TIME_HISTORY = 20,
};
diff --git a/editor/plugins/ot_features_plugin.cpp b/editor/plugins/ot_features_plugin.cpp
new file mode 100644
index 0000000000..3478148521
--- /dev/null
+++ b/editor/plugins/ot_features_plugin.cpp
@@ -0,0 +1,213 @@
+/*************************************************************************/
+/* ot_features_plugin.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "ot_features_plugin.h"
+
+#include "editor/editor_scale.h"
+
+void OpenTypeFeaturesEditor::_value_changed(double val) {
+ if (setting) {
+ return;
+ }
+
+ emit_changed(get_edited_property(), spin->get_value());
+}
+
+void OpenTypeFeaturesEditor::update_property() {
+ double val = get_edited_object()->get(get_edited_property());
+ setting = true;
+ spin->set_value(val);
+ setting = false;
+}
+
+void OpenTypeFeaturesEditor::_notification(int p_what) {
+ if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
+ Color base = get_theme_color("accent_color", "Editor");
+
+ button->set_icon(get_theme_icon("Remove", "EditorIcons"));
+ button->set_size(get_theme_icon("Remove", "EditorIcons")->get_size());
+ spin->set_custom_label_color(true, base);
+ }
+}
+
+void OpenTypeFeaturesEditor::_remove_feature() {
+ get_edited_object()->set(get_edited_property(), -1);
+}
+
+void OpenTypeFeaturesEditor::_bind_methods() {
+}
+
+OpenTypeFeaturesEditor::OpenTypeFeaturesEditor() {
+ HBoxContainer *bc = memnew(HBoxContainer);
+ add_child(bc);
+
+ spin = memnew(EditorSpinSlider);
+ spin->set_flat(true);
+ bc->add_child(spin);
+ add_focusable(spin);
+ spin->connect("value_changed", callable_mp(this, &OpenTypeFeaturesEditor::_value_changed));
+ spin->set_h_size_flags(SIZE_EXPAND_FILL);
+
+ spin->set_min(0);
+ spin->set_max(65536);
+ spin->set_step(1);
+ spin->set_hide_slider(false);
+ spin->set_allow_greater(false);
+ spin->set_allow_lesser(false);
+
+ button = memnew(Button);
+ button->set_tooltip(RTR("Remove feature"));
+ button->set_flat(true);
+ bc->add_child(button);
+
+ button->connect("pressed", callable_mp(this, &OpenTypeFeaturesEditor::_remove_feature));
+
+ setting = false;
+}
+
+/*************************************************************************/
+
+void OpenTypeFeaturesAdd::_add_feature(int p_option) {
+ get_edited_object()->set("opentype_features/" + TS->tag_to_name(p_option), 1);
+}
+
+void OpenTypeFeaturesAdd::update_property() {
+ menu->clear();
+ menu_ss->clear();
+ menu_cv->clear();
+ menu_cu->clear();
+ bool have_ss = false;
+ bool have_cv = false;
+ bool have_cu = false;
+ Dictionary features = Object::cast_to<Control>(get_edited_object())->get_theme_font("font")->get_feature_list();
+ for (const Variant *ftr = features.next(nullptr); ftr != nullptr; ftr = features.next(ftr)) {
+ String ftr_name = TS->tag_to_name(*ftr);
+ if (ftr_name.begins_with("stylistic_set_")) {
+ menu_ss->add_item(ftr_name.capitalize(), (int32_t)*ftr);
+ have_ss = true;
+ } else if (ftr_name.begins_with("character_variant_")) {
+ menu_cv->add_item(ftr_name.capitalize(), (int32_t)*ftr);
+ have_cv = true;
+ } else if (ftr_name.begins_with("custom_")) {
+ menu_cu->add_item(ftr_name.replace("custom_", ""), (int32_t)*ftr);
+ have_cu = true;
+ } else {
+ menu->add_item(ftr_name.capitalize(), (int32_t)*ftr);
+ }
+ }
+ if (have_ss) {
+ menu->add_submenu_item(RTR("Stylistic Sets"), "SSMenu");
+ }
+ if (have_cv) {
+ menu->add_submenu_item(RTR("Character Variants"), "CVMenu");
+ }
+ if (have_cu) {
+ menu->add_submenu_item(RTR("Custom"), "CUMenu");
+ }
+}
+
+void OpenTypeFeaturesAdd::_features_menu() {
+ Size2 size = get_size();
+ menu->set_position(get_screen_position() + Size2(0, size.height * get_global_transform().get_scale().y));
+ menu->popup();
+}
+
+void OpenTypeFeaturesAdd::_notification(int p_what) {
+ if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) {
+ set_label("");
+ button->set_icon(get_theme_icon("Add", "EditorIcons"));
+ button->set_size(get_theme_icon("Add", "EditorIcons")->get_size());
+ }
+}
+
+void OpenTypeFeaturesAdd::_bind_methods() {
+}
+
+OpenTypeFeaturesAdd::OpenTypeFeaturesAdd() {
+ menu = memnew(PopupMenu);
+ add_child(menu);
+
+ menu_cv = memnew(PopupMenu);
+ menu_cv->set_name("CVMenu");
+ menu->add_child(menu_cv);
+
+ menu_ss = memnew(PopupMenu);
+ menu_ss->set_name("SSMenu");
+ menu->add_child(menu_ss);
+
+ menu_cu = memnew(PopupMenu);
+ menu_cu->set_name("CUMenu");
+ menu->add_child(menu_cu);
+
+ button = memnew(Button);
+ button->set_flat(true);
+ button->set_text(RTR("Add feature..."));
+ button->set_tooltip(RTR("Add feature..."));
+ add_child(button);
+
+ button->connect("pressed", callable_mp(this, &OpenTypeFeaturesAdd::_features_menu));
+ menu->connect("id_pressed", callable_mp(this, &OpenTypeFeaturesAdd::_add_feature));
+ menu_cv->connect("id_pressed", callable_mp(this, &OpenTypeFeaturesAdd::_add_feature));
+ menu_ss->connect("id_pressed", callable_mp(this, &OpenTypeFeaturesAdd::_add_feature));
+ menu_cu->connect("id_pressed", callable_mp(this, &OpenTypeFeaturesAdd::_add_feature));
+}
+
+/*************************************************************************/
+
+bool EditorInspectorPluginOpenTypeFeatures::can_handle(Object *p_object) {
+ return (Object::cast_to<Control>(p_object) != nullptr);
+}
+
+void EditorInspectorPluginOpenTypeFeatures::parse_begin(Object *p_object) {
+}
+
+void EditorInspectorPluginOpenTypeFeatures::parse_category(Object *p_object, const String &p_parse_category) {
+}
+
+bool EditorInspectorPluginOpenTypeFeatures::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) {
+ if (p_path == "opentype_features/_new") {
+ OpenTypeFeaturesAdd *editor = memnew(OpenTypeFeaturesAdd);
+ add_property_editor(p_path, editor);
+ return true;
+ } else if (p_path.begins_with("opentype_features")) {
+ OpenTypeFeaturesEditor *editor = memnew(OpenTypeFeaturesEditor);
+ add_property_editor(p_path, editor);
+ return true;
+ }
+ return false;
+}
+
+/*************************************************************************/
+
+OpenTypeFeaturesEditorPlugin::OpenTypeFeaturesEditorPlugin(EditorNode *p_node) {
+ Ref<EditorInspectorPluginOpenTypeFeatures> ftr_plugin;
+ ftr_plugin.instance();
+ EditorInspector::add_inspector_plugin(ftr_plugin);
+}
diff --git a/editor/plugins/ot_features_plugin.h b/editor/plugins/ot_features_plugin.h
new file mode 100644
index 0000000000..5b5f367b24
--- /dev/null
+++ b/editor/plugins/ot_features_plugin.h
@@ -0,0 +1,105 @@
+/*************************************************************************/
+/* ot_features_plugin.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef OT_FEATURES_PLUGIN_H
+#define OT_FEATURES_PLUGIN_H
+
+#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
+#include "editor/editor_properties.h"
+
+/*************************************************************************/
+
+class OpenTypeFeaturesEditor : public EditorProperty {
+ GDCLASS(OpenTypeFeaturesEditor, EditorProperty);
+ EditorSpinSlider *spin;
+ bool setting = true;
+ void _value_changed(double p_val);
+ Button *button = nullptr;
+
+ void _remove_feature();
+
+protected:
+ void _notification(int p_what);
+ static void _bind_methods();
+
+public:
+ virtual void update_property() override;
+ OpenTypeFeaturesEditor();
+};
+
+/*************************************************************************/
+
+class OpenTypeFeaturesAdd : public EditorProperty {
+ GDCLASS(OpenTypeFeaturesAdd, EditorProperty);
+
+ Button *button = nullptr;
+ PopupMenu *menu = nullptr;
+ PopupMenu *menu_ss = nullptr;
+ PopupMenu *menu_cv = nullptr;
+ PopupMenu *menu_cu = nullptr;
+
+ void _add_feature(int p_option);
+ void _features_menu();
+
+protected:
+ void _notification(int p_what);
+ static void _bind_methods();
+
+public:
+ virtual void update_property() override;
+
+ OpenTypeFeaturesAdd();
+};
+
+/*************************************************************************/
+
+class EditorInspectorPluginOpenTypeFeatures : public EditorInspectorPlugin {
+ GDCLASS(EditorInspectorPluginOpenTypeFeatures, EditorInspectorPlugin);
+
+public:
+ virtual bool can_handle(Object *p_object) override;
+ virtual void parse_begin(Object *p_object) override;
+ virtual void parse_category(Object *p_object, const String &p_parse_category) override;
+ virtual bool parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) override;
+};
+
+/*************************************************************************/
+
+class OpenTypeFeaturesEditorPlugin : public EditorPlugin {
+ GDCLASS(OpenTypeFeaturesEditorPlugin, EditorPlugin);
+
+public:
+ OpenTypeFeaturesEditorPlugin(EditorNode *p_node);
+
+ virtual String get_name() const override { return "OpenTypeFeatures"; }
+};
+
+#endif // OT_FEATURES_PLUGIN_H
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 8dd7d6d6e2..12790a6746 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -1249,13 +1249,35 @@ void ScriptEditor::_menu_option(int p_option) {
RES resource = current->get_edited_resource();
Ref<TextFile> text_file = resource;
+ Ref<Script> script = resource;
+
if (text_file != nullptr) {
current->apply_code();
_save_text_file(text_file, text_file->get_path());
break;
}
+
+ if (script != nullptr) {
+ const Vector<DocData::ClassDoc> &documentations = script->get_documentation();
+ for (int j = 0; j < documentations.size(); j++) {
+ const DocData::ClassDoc &doc = documentations.get(j);
+ if (EditorHelp::get_doc_data()->has_doc(doc.name)) {
+ EditorHelp::get_doc_data()->remove_doc(doc.name);
+ }
+ }
+ }
+
editor->save_resource(resource);
+ if (script != nullptr) {
+ const Vector<DocData::ClassDoc> &documentations = script->get_documentation();
+ for (int j = 0; j < documentations.size(); j++) {
+ const DocData::ClassDoc &doc = documentations.get(j);
+ EditorHelp::get_doc_data()->add_doc(doc);
+ update_doc(doc.name);
+ }
+ }
+
} break;
case FILE_SAVE_AS: {
if (trim_trailing_whitespace_on_save) {
@@ -1274,6 +1296,8 @@ void ScriptEditor::_menu_option(int p_option) {
RES resource = current->get_edited_resource();
Ref<TextFile> text_file = resource;
+ Ref<Script> script = resource;
+
if (text_file != nullptr) {
file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
@@ -1289,9 +1313,27 @@ void ScriptEditor::_menu_option(int p_option) {
break;
}
+ if (script != nullptr) {
+ const Vector<DocData::ClassDoc> &documentations = script->get_documentation();
+ for (int j = 0; j < documentations.size(); j++) {
+ const DocData::ClassDoc &doc = documentations.get(j);
+ if (EditorHelp::get_doc_data()->has_doc(doc.name)) {
+ EditorHelp::get_doc_data()->remove_doc(doc.name);
+ }
+ }
+ }
+
editor->push_item(resource.ptr());
editor->save_resource_as(resource);
+ if (script != nullptr) {
+ const Vector<DocData::ClassDoc> &documentations = script->get_documentation();
+ for (int j = 0; j < documentations.size(); j++) {
+ const DocData::ClassDoc &doc = documentations.get(j);
+ EditorHelp::get_doc_data()->add_doc(doc);
+ update_doc(doc.name);
+ }
+ }
} break;
case FILE_TOOL_RELOAD:
@@ -1485,12 +1527,19 @@ void ScriptEditor::_notification(int p_what) {
EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &ScriptEditor::_filesystem_changed));
[[fallthrough]];
}
+ case NOTIFICATION_TRANSLATION_CHANGED:
+ case NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
case NOTIFICATION_THEME_CHANGED: {
help_search->set_icon(get_theme_icon("HelpSearch", "EditorIcons"));
site_search->set_icon(get_theme_icon("Instance", "EditorIcons"));
- script_forward->set_icon(get_theme_icon("Forward", "EditorIcons"));
- script_back->set_icon(get_theme_icon("Back", "EditorIcons"));
+ if (is_layout_rtl()) {
+ script_forward->set_icon(get_theme_icon("Back", "EditorIcons"));
+ script_back->set_icon(get_theme_icon("Forward", "EditorIcons"));
+ } else {
+ script_forward->set_icon(get_theme_icon("Forward", "EditorIcons"));
+ script_back->set_icon(get_theme_icon("Back", "EditorIcons"));
+ }
members_overview_alphabeta_sort_button->set_icon(get_theme_icon("Sort", "EditorIcons"));
@@ -2311,11 +2360,33 @@ void ScriptEditor::save_all_scripts() {
if (edited_res->get_path() != "" && edited_res->get_path().find("local://") == -1 && edited_res->get_path().find("::") == -1) {
Ref<TextFile> text_file = edited_res;
+ Ref<Script> script = edited_res;
+
if (text_file != nullptr) {
_save_text_file(text_file, text_file->get_path());
continue;
}
+
+ if (script != nullptr) {
+ const Vector<DocData::ClassDoc> &documentations = script->get_documentation();
+ for (int j = 0; j < documentations.size(); j++) {
+ const DocData::ClassDoc &doc = documentations.get(j);
+ if (EditorHelp::get_doc_data()->has_doc(doc.name)) {
+ EditorHelp::get_doc_data()->remove_doc(doc.name);
+ }
+ }
+ }
+
editor->save_resource(edited_res); //external script, save it
+
+ if (script != nullptr) {
+ const Vector<DocData::ClassDoc> &documentations = script->get_documentation();
+ for (int j = 0; j < documentations.size(); j++) {
+ const DocData::ClassDoc &doc = documentations.get(j);
+ EditorHelp::get_doc_data()->add_doc(doc);
+ update_doc(doc.name);
+ }
+ }
}
}
@@ -2637,7 +2708,7 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co
}
}
-void ScriptEditor::_unhandled_input(const Ref<InputEvent> &p_event) {
+void ScriptEditor::_unhandled_key_input(const Ref<InputEvent> &p_event) {
if (!is_visible_in_tree() || !p_event->is_pressed() || p_event->is_echo()) {
return;
}
@@ -2893,6 +2964,18 @@ void ScriptEditor::_help_class_goto(const String &p_desc) {
_save_layout();
}
+void ScriptEditor::update_doc(const String &p_name) {
+ ERR_FAIL_COND(!EditorHelp::get_doc_data()->has_doc(p_name));
+
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
+ EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i));
+ if (eh && eh->get_class() == p_name) {
+ eh->update_doc();
+ return;
+ }
+ }
+}
+
void ScriptEditor::_update_selected_editor_menu() {
for (int i = 0; i < tab_container->get_child_count(); i++) {
bool current = tab_container->get_current_tab() == i;
@@ -3165,7 +3248,7 @@ void ScriptEditor::_bind_methods() {
ClassDB::bind_method("_update_script_connections", &ScriptEditor::_update_script_connections);
ClassDB::bind_method("_help_class_open", &ScriptEditor::_help_class_open);
ClassDB::bind_method("_live_auto_reload_running_scripts", &ScriptEditor::_live_auto_reload_running_scripts);
- ClassDB::bind_method("_unhandled_input", &ScriptEditor::_unhandled_input);
+ ClassDB::bind_method("_unhandled_key_input", &ScriptEditor::_unhandled_key_input);
ClassDB::bind_method("_update_members_overview", &ScriptEditor::_update_members_overview);
ClassDB::bind_method("_update_recent_scripts", &ScriptEditor::_update_recent_scripts);
@@ -3292,12 +3375,13 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
ED_SHORTCUT("script_editor/window_move_down", TTR("Move Down"), KEY_MASK_SHIFT | KEY_MASK_ALT | KEY_DOWN);
ED_SHORTCUT("script_editor/next_script", TTR("Next script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_PERIOD); // these should be KEY_GREATER and KEY_LESS but those don't work
ED_SHORTCUT("script_editor/prev_script", TTR("Previous script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_COMMA);
- set_process_unhandled_input(true);
+ set_process_unhandled_key_input(true);
file_menu = memnew(MenuButton);
- menu_hb->add_child(file_menu);
file_menu->set_text(TTR("File"));
file_menu->set_switch_on_hover(true);
+ file_menu->set_shortcut_context(this);
+ menu_hb->add_child(file_menu);
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/new", TTR("New Script...")), FILE_NEW);
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/new_textfile", TTR("New Text File...")), FILE_NEW_TEXTFILE);
@@ -3352,10 +3436,11 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
file_menu->get_popup()->connect("id_pressed", callable_mp(this, &ScriptEditor::_menu_option));
script_search_menu = memnew(MenuButton);
- menu_hb->add_child(script_search_menu);
script_search_menu->set_text(TTR("Search"));
script_search_menu->set_switch_on_hover(true);
+ script_search_menu->set_shortcut_context(this);
script_search_menu->get_popup()->connect("id_pressed", callable_mp(this, &ScriptEditor::_menu_option));
+ menu_hb->add_child(script_search_menu);
MenuButton *debug_menu = memnew(MenuButton);
menu_hb->add_child(debug_menu);
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index 32f47239ef..cc02a1ccbe 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -402,7 +402,7 @@ class ScriptEditor : public PanelContainer {
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
- void _unhandled_input(const Ref<InputEvent> &p_event);
+ void _unhandled_key_input(const Ref<InputEvent> &p_event);
void _script_list_gui_input(const Ref<InputEvent> &ev);
void _make_script_list_context_menu();
@@ -482,6 +482,7 @@ public:
void close_builtin_scripts_from_scene(const String &p_scene);
void goto_help(const String &p_desc) { _help_class_goto(p_desc); }
+ void update_doc(const String &p_name);
bool can_take_away_focus() const;
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 7feb7cb3d3..e854ed4fb3 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -912,6 +912,7 @@ void ScriptTextEditor::update_toggle_scripts_button() {
void ScriptTextEditor::_update_connected_methods() {
CodeEdit *text_edit = code_editor->get_text_editor();
+ text_edit->set_gutter_width(connection_gutter, text_edit->get_row_height());
for (int i = 0; i < text_edit->get_line_count(); i++) {
if (text_edit->get_line_gutter_metadata(i, connection_gutter) == "") {
continue;
@@ -1352,7 +1353,8 @@ void ScriptTextEditor::_change_syntax_highlighter(int p_idx) {
void ScriptTextEditor::_notification(int p_what) {
switch (p_what) {
- case NOTIFICATION_THEME_CHANGED: {
+ case NOTIFICATION_THEME_CHANGED:
+ case NOTIFICATION_ENTER_TREE: {
code_editor->get_text_editor()->set_gutter_width(connection_gutter, code_editor->get_text_editor()->get_row_height());
} break;
default:
@@ -1697,6 +1699,8 @@ void ScriptTextEditor::_enable_code_editor() {
editor_box->add_child(warnings_panel);
warnings_panel->add_theme_font_override(
"normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("main", "EditorFonts"));
+ warnings_panel->add_theme_font_size_override(
+ "normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("main_size", "EditorFonts"));
warnings_panel->connect("meta_clicked", callable_mp(this, &ScriptTextEditor::_warning_clicked));
add_child(context_menu);
@@ -1845,6 +1849,7 @@ ScriptTextEditor::ScriptTextEditor() {
edit_menu = memnew(MenuButton);
edit_menu->set_text(TTR("Edit"));
edit_menu->set_switch_on_hover(true);
+ edit_menu->set_shortcut_context(this);
convert_case = memnew(PopupMenu);
convert_case->set_name("convert_case");
@@ -1864,10 +1869,12 @@ ScriptTextEditor::ScriptTextEditor() {
search_menu = memnew(MenuButton);
search_menu->set_text(TTR("Search"));
search_menu->set_switch_on_hover(true);
+ search_menu->set_shortcut_context(this);
goto_menu = memnew(MenuButton);
goto_menu->set_text(TTR("Go To"));
goto_menu->set_switch_on_hover(true);
+ goto_menu->set_shortcut_context(this);
bookmarks_menu = memnew(PopupMenu);
bookmarks_menu->set_name("Bookmarks");
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 0063bec9de..5b0e1ce5b5 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -581,6 +581,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
HBoxContainer *hbc = memnew(HBoxContainer);
edit_menu = memnew(MenuButton);
+ edit_menu->set_shortcut_context(this);
edit_menu->set_text(TTR("Edit"));
edit_menu->set_switch_on_hover(true);
@@ -605,6 +606,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
edit_menu->get_popup()->connect("id_pressed", callable_mp(this, &ShaderEditor::_menu_option));
search_menu = memnew(MenuButton);
+ search_menu->set_shortcut_context(this);
search_menu->set_text(TTR("Search"));
search_menu->set_switch_on_hover(true);
@@ -615,6 +617,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
search_menu->get_popup()->connect("id_pressed", callable_mp(this, &ShaderEditor::_menu_option));
MenuButton *goto_menu = memnew(MenuButton);
+ goto_menu->set_shortcut_context(this);
goto_menu->set_text(TTR("Go To"));
goto_menu->set_switch_on_hover(true);
goto_menu->get_popup()->connect("id_pressed", callable_mp(this, &ShaderEditor::_menu_option));
diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp
index 52da8dea19..d662714752 100644
--- a/editor/plugins/skeleton_3d_editor_plugin.cpp
+++ b/editor/plugins/skeleton_3d_editor_plugin.cpp
@@ -114,10 +114,11 @@ void BoneTransformEditor::_notification(int p_what) {
}
case NOTIFICATION_SORT_CHILDREN: {
const Ref<Font> font = get_theme_font("font", "Tree");
+ int font_size = get_theme_font_size("font_size", "Tree");
Point2 buffer;
buffer.x += get_theme_constant("inspector_margin", "Editor");
- buffer.y += font->get_height();
+ buffer.y += font->get_height(font_size);
buffer.y += get_theme_constant("vseparation", "Tree");
const float vector_height = translation_property->get_size().y;
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index 8935b698b6..9894d0e1b0 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -563,6 +563,7 @@ TextEditor::TextEditor() {
edit_hb = memnew(HBoxContainer);
search_menu = memnew(MenuButton);
+ search_menu->set_shortcut_context(this);
edit_hb->add_child(search_menu);
search_menu->set_text(TTR("Search"));
search_menu->set_switch_on_hover(true);
@@ -577,6 +578,7 @@ TextEditor::TextEditor() {
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/replace_in_files"), REPLACE_IN_FILES);
edit_menu = memnew(MenuButton);
+ edit_menu->set_shortcut_context(this);
edit_hb->add_child(edit_menu);
edit_menu->set_text(TTR("Edit"));
edit_menu->set_switch_on_hover(true);
@@ -631,6 +633,7 @@ TextEditor::TextEditor() {
set_syntax_highlighter(plain_highlighter);
MenuButton *goto_menu = memnew(MenuButton);
+ goto_menu->set_shortcut_context(this);
edit_hb->add_child(goto_menu);
goto_menu->set_text(TTR("Go To"));
goto_menu->set_switch_on_hover(true);
diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp
index f8facb0fd5..9b760c0e50 100644
--- a/editor/plugins/texture_editor_plugin.cpp
+++ b/editor/plugins/texture_editor_plugin.cpp
@@ -79,6 +79,7 @@ void TextureEditor::_notification(int p_what) {
draw_texture_rect(texture, Rect2(ofs_x, ofs_y, tex_width, tex_height));
Ref<Font> font = get_theme_font("font", "Label");
+ int font_size = get_theme_font_size("font_size", "Label");
String format;
if (Object::cast_to<ImageTexture>(*texture)) {
@@ -90,16 +91,16 @@ void TextureEditor::_notification(int p_what) {
}
String text = itos(texture->get_width()) + "x" + itos(texture->get_height()) + " " + format;
- Size2 rect = font->get_string_size(text);
+ Size2 rect = font->get_string_size(text, font_size);
- Vector2 draw_from = size - rect + Size2(-2, font->get_ascent() - 2);
+ Vector2 draw_from = size - rect + Size2(-2, font->get_ascent(font_size) - 2);
if (draw_from.x < 0) {
draw_from.x = 0;
}
- draw_string(font, draw_from + Vector2(2, 2), text, Color(0, 0, 0, 0.5), size.width);
- draw_string(font, draw_from - Vector2(2, 2), text, Color(0, 0, 0, 0.5), size.width);
- draw_string(font, draw_from, text, Color(1, 1, 1, 1), size.width);
+ draw_string(font, draw_from + Vector2(2, 2), text, HALIGN_LEFT, size.width, font_size, Color(0, 0, 0, 0.5));
+ draw_string(font, draw_from - Vector2(2, 2), text, HALIGN_LEFT, size.width, font_size, Color(0, 0, 0, 0.5));
+ draw_string(font, draw_from, text, HALIGN_LEFT, size.width, font_size, Color(1, 1, 1, 1));
}
}
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index 932ded6938..8ab82b63c3 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -78,9 +78,12 @@ void ThemeEditor::_name_menu_about_to_show() {
Theme::get_default()->get_font_list(fromtype, &names);
break;
case 3:
- Theme::get_default()->get_color_list(fromtype, &names);
+ Theme::get_default()->get_font_size_list(fromtype, &names);
break;
case 4:
+ Theme::get_default()->get_color_list(fromtype, &names);
+ break;
+ case 5:
Theme::get_default()->get_constant_list(fromtype, &names);
break;
}
@@ -88,6 +91,7 @@ void ThemeEditor::_name_menu_about_to_show() {
theme->get_icon_list(fromtype, &names);
theme->get_stylebox_list(fromtype, &names);
theme->get_font_list(fromtype, &names);
+ theme->get_font_size_list(fromtype, &names);
theme->get_color_list(fromtype, &names);
theme->get_constant_list(fromtype, &names);
}
@@ -120,6 +124,7 @@ struct _TECategory {
Set<RefItem<StyleBox>> stylebox_items;
Set<RefItem<Font>> font_items;
+ Set<Item<int>> font_size_items;
Set<RefItem<Texture2D>> icon_items;
Set<Item<Color>> color_items;
@@ -160,6 +165,15 @@ void ThemeEditor::_save_template_cbk(String fname) {
tc.font_items.insert(it);
}
+ List<StringName> font_size_list;
+ Theme::get_default()->get_font_size_list(E->key(), &font_list);
+ for (List<StringName>::Element *F = font_size_list.front(); F; F = F->next()) {
+ _TECategory::Item<int> it;
+ it.name = F->get();
+ it.item = Theme::get_default()->get_font_size(F->get(), E->key());
+ tc.font_size_items.insert(it);
+ }
+
List<StringName> icon_list;
Theme::get_default()->get_icon_list(E->key(), &icon_list);
for (List<StringName>::Element *F = icon_list.front(); F; F = F->next()) {
@@ -284,6 +298,14 @@ void ThemeEditor::_save_template_cbk(String fname) {
file->store_line(E->key() + "." + F->get().name + " = default");
}
+ if (tc.font_size_items.size()) {
+ file->store_line("\n; Font Size Items:\n");
+ }
+
+ for (Set<_TECategory::Item<int>>::Element *F = tc.font_size_items.front(); F; F = F->next()) {
+ file->store_line(E->key() + "." + F->get().name + " = default");
+ }
+
if (tc.icon_items.size()) {
file->store_line("\n; Icon Items:\n");
}
@@ -327,9 +349,12 @@ void ThemeEditor::_dialog_cbk() {
theme->set_font(name_edit->get_text(), type_edit->get_text(), Ref<Font>());
break;
case 3:
- theme->set_color(name_edit->get_text(), type_edit->get_text(), Color());
+ theme->set_font_size(name_edit->get_text(), type_edit->get_text(), -1);
break;
case 4:
+ theme->set_color(name_edit->get_text(), type_edit->get_text(), Color());
+ break;
+ case 5:
theme->set_constant(name_edit->get_text(), type_edit->get_text(), 0);
break;
}
@@ -362,6 +387,13 @@ void ThemeEditor::_dialog_cbk() {
}
{
names.clear();
+ Theme::get_default()->get_font_size_list(fromtype, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ theme->set_font_size(E->get(), fromtype, Theme::get_default()->get_font_size(E->get(), fromtype));
+ }
+ }
+ {
+ names.clear();
Theme::get_default()->get_color_list(fromtype, &names);
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
theme->set_color(E->get(), fromtype, Theme::get_default()->get_color(E->get(), fromtype));
@@ -387,9 +419,12 @@ void ThemeEditor::_dialog_cbk() {
theme->clear_font(name_edit->get_text(), type_edit->get_text());
break;
case 3:
- theme->clear_color(name_edit->get_text(), type_edit->get_text());
+ theme->clear_font_size(name_edit->get_text(), type_edit->get_text());
break;
case 4:
+ theme->clear_color(name_edit->get_text(), type_edit->get_text());
+ break;
+ case 5:
theme->clear_constant(name_edit->get_text(), type_edit->get_text());
break;
}
@@ -422,6 +457,13 @@ void ThemeEditor::_dialog_cbk() {
}
{
names.clear();
+ Theme::get_default()->get_font_size_list(fromtype, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ theme->clear_font_size(E->get(), fromtype);
+ }
+ }
+ {
+ names.clear();
Theme::get_default()->get_color_list(fromtype, &names);
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
theme->clear_color(E->get(), fromtype);
@@ -486,6 +528,13 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
theme->set_font(E->get(), type, Ref<Font>());
}
+ List<StringName> font_sizes;
+ base_theme->get_font_size_list(type, &font_sizes);
+
+ for (List<StringName>::Element *E = font_sizes.front(); E; E = E->next()) {
+ theme->set_font_size(E->get(), type, base_theme->get_font_size(E->get(), type));
+ }
+
List<StringName> colors;
base_theme->get_color_list(type, &colors);
@@ -860,6 +909,7 @@ ThemeEditor::ThemeEditor() {
type_select->add_item(TTR("Icon"));
type_select->add_item(TTR("Style"));
type_select->add_item(TTR("Font"));
+ type_select->add_item(TTR("Font Size"));
type_select->add_item(TTR("Color"));
type_select->add_item(TTR("Constant"));
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index 7b516175b2..6c0efcb254 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -2109,6 +2109,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
paint_button = memnew(Button);
paint_button->set_flat(true);
paint_button->set_shortcut(ED_SHORTCUT("tile_map_editor/paint_tile", TTR("Paint Tile"), KEY_P));
+ paint_button->set_shortcut_context(this);
paint_button->set_tooltip(TTR("RMB: Erase"));
paint_button->connect("pressed", callable_mp(this, &TileMapEditor::_button_tool_select), make_binds(TOOL_NONE));
paint_button->set_toggle_mode(true);
@@ -2117,6 +2118,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
line_button = memnew(Button);
line_button->set_flat(true);
line_button->set_shortcut(ED_SHORTCUT("tile_map_editor/line_fill", TTR("Line Fill"), KEY_L));
+ line_button->set_shortcut_context(this);
line_button->set_tooltip(TTR("RMB: Erase"));
line_button->connect("pressed", callable_mp(this, &TileMapEditor::_button_tool_select), make_binds(TOOL_LINE_PAINT));
line_button->set_toggle_mode(true);
@@ -2125,6 +2127,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
rectangle_button = memnew(Button);
rectangle_button->set_flat(true);
rectangle_button->set_shortcut(ED_SHORTCUT("tile_map_editor/rectangle_fill", TTR("Rectangle Fill"), KEY_O));
+ rectangle_button->set_shortcut_context(this);
rectangle_button->set_tooltip(TTR("Shift+LMB: Keep 1:1 proporsions\nRMB: Erase"));
rectangle_button->connect("pressed", callable_mp(this, &TileMapEditor::_button_tool_select), make_binds(TOOL_RECTANGLE_PAINT));
rectangle_button->set_toggle_mode(true);
@@ -2133,6 +2136,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
bucket_fill_button = memnew(Button);
bucket_fill_button->set_flat(true);
bucket_fill_button->set_shortcut(ED_SHORTCUT("tile_map_editor/bucket_fill", TTR("Bucket Fill"), KEY_B));
+ bucket_fill_button->set_shortcut_context(this);
bucket_fill_button->connect("pressed", callable_mp(this, &TileMapEditor::_button_tool_select), make_binds(TOOL_BUCKET));
bucket_fill_button->set_toggle_mode(true);
toolbar->add_child(bucket_fill_button);
@@ -2140,6 +2144,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
picker_button = memnew(Button);
picker_button->set_flat(true);
picker_button->set_shortcut(ED_SHORTCUT("tile_map_editor/pick_tile", TTR("Pick Tile"), KEY_I));
+ picker_button->set_shortcut_context(this);
picker_button->connect("pressed", callable_mp(this, &TileMapEditor::_button_tool_select), make_binds(TOOL_PICKING));
picker_button->set_toggle_mode(true);
toolbar->add_child(picker_button);
@@ -2147,6 +2152,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
select_button = memnew(Button);
select_button->set_flat(true);
select_button->set_shortcut(ED_SHORTCUT("tile_map_editor/select", TTR("Select"), KEY_M));
+ select_button->set_shortcut_context(this);
select_button->connect("pressed", callable_mp(this, &TileMapEditor::_button_tool_select), make_binds(TOOL_SELECTING));
select_button->set_toggle_mode(true);
toolbar->add_child(select_button);
@@ -2165,15 +2171,16 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
tile_info->set_modulate(Color(1, 1, 1, 0.8));
tile_info->set_mouse_filter(MOUSE_FILTER_IGNORE);
tile_info->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("main", "EditorFonts"));
+ tile_info->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("main_size", "EditorFonts"));
// The tile info is only displayed after a tile has been hovered.
tile_info->hide();
CanvasItemEditor::get_singleton()->add_control_to_info_overlay(tile_info);
// Menu.
options = memnew(MenuButton);
+ options->set_shortcut_context(this);
options->set_text("TileMap");
options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("TileMap", "EditorIcons"));
- options->set_process_unhandled_key_input(false);
toolbar_right->add_child(options);
PopupMenu *p = options->get_popup();
@@ -2190,6 +2197,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
rotate_left_button->set_focus_mode(FOCUS_NONE);
rotate_left_button->connect("pressed", callable_mp(this, &TileMapEditor::_rotate), varray(-1));
rotate_left_button->set_shortcut(ED_SHORTCUT("tile_map_editor/rotate_left", TTR("Rotate Left"), KEY_A));
+ rotate_left_button->set_shortcut_context(this);
tool_hb->add_child(rotate_left_button);
rotate_right_button = memnew(Button);
@@ -2198,6 +2206,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
rotate_right_button->set_focus_mode(FOCUS_NONE);
rotate_right_button->connect("pressed", callable_mp(this, &TileMapEditor::_rotate), varray(1));
rotate_right_button->set_shortcut(ED_SHORTCUT("tile_map_editor/rotate_right", TTR("Rotate Right"), KEY_S));
+ rotate_right_button->set_shortcut_context(this);
tool_hb->add_child(rotate_right_button);
flip_horizontal_button = memnew(Button);
@@ -2206,6 +2215,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
flip_horizontal_button->set_focus_mode(FOCUS_NONE);
flip_horizontal_button->connect("pressed", callable_mp(this, &TileMapEditor::_flip_horizontal));
flip_horizontal_button->set_shortcut(ED_SHORTCUT("tile_map_editor/flip_horizontal", TTR("Flip Horizontally"), KEY_X));
+ flip_horizontal_button->set_shortcut_context(this);
tool_hb->add_child(flip_horizontal_button);
flip_vertical_button = memnew(Button);
@@ -2214,6 +2224,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
flip_vertical_button->set_focus_mode(FOCUS_NONE);
flip_vertical_button->connect("pressed", callable_mp(this, &TileMapEditor::_flip_vertical));
flip_vertical_button->set_shortcut(ED_SHORTCUT("tile_map_editor/flip_vertical", TTR("Flip Vertically"), KEY_Z));
+ flip_vertical_button->set_shortcut_context(this);
tool_hb->add_child(flip_vertical_button);
clear_transform_button = memnew(Button);
@@ -2222,6 +2233,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
clear_transform_button->set_focus_mode(FOCUS_NONE);
clear_transform_button->connect("pressed", callable_mp(this, &TileMapEditor::_clear_transform));
clear_transform_button->set_shortcut(ED_SHORTCUT("tile_map_editor/clear_transform", TTR("Clear Transform"), KEY_W));
+ clear_transform_button->set_shortcut_context(this);
tool_hb->add_child(clear_transform_button);
clear_transform_button->set_disabled(true);
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index 714f38bd56..6d2fd65dd6 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -279,6 +279,8 @@ void TileSetEditor::_notification(int p_what) {
case NOTIFICATION_READY: {
add_theme_constant_override("autohide", 1); // Fixes the dragger always showing up.
} break;
+ case NOTIFICATION_TRANSLATION_CHANGED:
+ case NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
tileset_toolbar_buttons[TOOL_TILESET_ADD_TEXTURE]->set_icon(get_theme_icon("ToolAddNode", "EditorIcons"));
@@ -296,8 +298,13 @@ void TileSetEditor::_notification(int p_what) {
tools[BITMASK_CLEAR]->set_icon(get_theme_icon("Clear", "EditorIcons"));
tools[SHAPE_NEW_POLYGON]->set_icon(get_theme_icon("CollisionPolygon2D", "EditorIcons"));
tools[SHAPE_NEW_RECTANGLE]->set_icon(get_theme_icon("CollisionShape2D", "EditorIcons"));
- tools[SELECT_PREVIOUS]->set_icon(get_theme_icon("ArrowLeft", "EditorIcons"));
- tools[SELECT_NEXT]->set_icon(get_theme_icon("ArrowRight", "EditorIcons"));
+ if (is_layout_rtl()) {
+ tools[SELECT_PREVIOUS]->set_icon(get_theme_icon("ArrowLeft", "EditorIcons"));
+ tools[SELECT_NEXT]->set_icon(get_theme_icon("ArrowRight", "EditorIcons"));
+ } else {
+ tools[SELECT_PREVIOUS]->set_icon(get_theme_icon("ArrowRight", "EditorIcons"));
+ tools[SELECT_NEXT]->set_icon(get_theme_icon("ArrowLeft", "EditorIcons"));
+ }
tools[SHAPE_DELETE]->set_icon(get_theme_icon("Remove", "EditorIcons"));
tools[SHAPE_KEEP_INSIDE_TILE]->set_icon(get_theme_icon("Snap", "EditorIcons"));
tools[TOOL_GRID_SNAP]->set_icon(get_theme_icon("SnapGrid", "EditorIcons"));
@@ -407,6 +414,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
tool_hb->move_child(tools[SELECT_NEXT], WORKSPACE_CREATE_SINGLE);
tools[SELECT_NEXT]->set_flat(true);
tools[SELECT_NEXT]->set_shortcut(ED_SHORTCUT("tileset_editor/next_shape", TTR("Next Coordinate"), KEY_PAGEDOWN));
+ tools[SELECT_NEXT]->set_shortcut_context(this);
tools[SELECT_NEXT]->connect("pressed", callable_mp(this, &TileSetEditor::_on_tool_clicked), varray(SELECT_NEXT));
tools[SELECT_NEXT]->set_tooltip(TTR("Select the next shape, subtile, or Tile."));
tools[SELECT_PREVIOUS] = memnew(Button);
@@ -414,6 +422,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
tool_hb->move_child(tools[SELECT_PREVIOUS], WORKSPACE_CREATE_SINGLE);
tools[SELECT_PREVIOUS]->set_flat(true);
tools[SELECT_PREVIOUS]->set_shortcut(ED_SHORTCUT("tileset_editor/previous_shape", TTR("Previous Coordinate"), KEY_PAGEUP));
+ tools[SELECT_PREVIOUS]->set_shortcut_context(this);
tools[SELECT_PREVIOUS]->set_tooltip(TTR("Select the previous shape, subtile, or Tile."));
tools[SELECT_PREVIOUS]->connect("pressed", callable_mp(this, &TileSetEditor::_on_tool_clicked), varray(SELECT_PREVIOUS));
@@ -460,6 +469,16 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
tool_editmode[EDITMODE_ICON]->set_shortcut(ED_SHORTCUT("tileset_editor/editmode_icon", TTR("Icon Mode"), KEY_7));
tool_editmode[EDITMODE_Z_INDEX]->set_shortcut(ED_SHORTCUT("tileset_editor/editmode_z_index", TTR("Z Index Mode"), KEY_8));
+ tool_editmode[EDITMODE_REGION]->set_shortcut_context(this);
+ tool_editmode[EDITMODE_REGION]->set_shortcut_context(this);
+ tool_editmode[EDITMODE_COLLISION]->set_shortcut_context(this);
+ tool_editmode[EDITMODE_OCCLUSION]->set_shortcut_context(this);
+ tool_editmode[EDITMODE_NAVIGATION]->set_shortcut_context(this);
+ tool_editmode[EDITMODE_BITMASK]->set_shortcut_context(this);
+ tool_editmode[EDITMODE_PRIORITY]->set_shortcut_context(this);
+ tool_editmode[EDITMODE_ICON]->set_shortcut_context(this);
+ tool_editmode[EDITMODE_Z_INDEX]->set_shortcut_context(this);
+
main_vb->add_child(tool_hb);
separator_editmode = memnew(HSeparator);
main_vb->add_child(separator_editmode);
@@ -1173,11 +1192,12 @@ void TileSetEditor::_on_workspace_overlay_draw() {
}
String tile_id_name = String::num(t_id, 0) + ": " + tileset->tile_get_name(t_id);
Ref<Font> font = get_theme_font("font", "Label");
- region.set_size(font->get_string_size(tile_id_name));
+ int font_size = get_theme_font_size("font_size", "Label");
+ region.set_size(font->get_string_size(tile_id_name, font_size));
workspace_overlay->draw_rect(region, c);
region.position.y += region.size.y - 2;
c = Color(0.1, 0.1, 0.1);
- workspace_overlay->draw_string(font, region.position, tile_id_name, c);
+ workspace_overlay->draw_string(font, region.position, tile_id_name, HALIGN_LEFT, -1, font_size, c);
}
delete tiles;
}
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 0b0231de64..6112e69299 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -120,9 +120,11 @@ void VisualShaderGraphPlugin::set_connections(List<VisualShader::Connection> &p_
}
void VisualShaderGraphPlugin::show_port_preview(VisualShader::Type p_type, int p_node_id, int p_port_id) {
- if (visual_shader->get_shader_type() == p_type && links.has(p_node_id)) {
+ if (visual_shader->get_shader_type() == p_type && links.has(p_node_id) && links[p_node_id].output_ports.has(p_port_id)) {
for (Map<int, Port>::Element *E = links[p_node_id].output_ports.front(); E; E = E->next()) {
- E->value().preview_button->set_pressed(false);
+ if (E->value().preview_button != nullptr) {
+ E->value().preview_button->set_pressed(false);
+ }
}
if (links[p_node_id].preview_visible && !is_dirty() && links[p_node_id].preview_box != nullptr) {
@@ -132,7 +134,7 @@ void VisualShaderGraphPlugin::show_port_preview(VisualShader::Type p_type, int p
links[p_node_id].preview_visible = false;
}
- if (p_port_id != -1) {
+ if (p_port_id != -1 && links[p_node_id].output_ports[p_port_id].preview_button != nullptr) {
if (is_dirty()) {
links[p_node_id].preview_pos = links[p_node_id].graph_node->get_child_count();
}
@@ -497,16 +499,32 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
if (group_node->is_editable()) {
HBoxContainer *hb2 = memnew(HBoxContainer);
+ String input_port_name = "input" + itos(group_node->get_free_input_port_id());
+ String output_port_name = "output" + itos(group_node->get_free_output_port_id());
+
+ for (int i = 0; i < MAX(vsnode->get_input_port_count(), vsnode->get_output_port_count()); i++) {
+ if (i < vsnode->get_input_port_count()) {
+ if (input_port_name == vsnode->get_input_port_name(i)) {
+ input_port_name = "_" + input_port_name;
+ }
+ }
+ if (i < vsnode->get_output_port_count()) {
+ if (output_port_name == vsnode->get_output_port_name(i)) {
+ output_port_name = "_" + output_port_name;
+ }
+ }
+ }
+
Button *add_input_btn = memnew(Button);
add_input_btn->set_text(TTR("Add Input"));
- add_input_btn->connect("pressed", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_add_input_port), varray(p_id, group_node->get_free_input_port_id(), VisualShaderNode::PORT_TYPE_VECTOR, "input" + itos(group_node->get_free_input_port_id())), CONNECT_DEFERRED);
+ add_input_btn->connect("pressed", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_add_input_port), varray(p_id, group_node->get_free_input_port_id(), VisualShaderNode::PORT_TYPE_VECTOR, input_port_name), CONNECT_DEFERRED);
hb2->add_child(add_input_btn);
hb2->add_spacer();
Button *add_output_btn = memnew(Button);
add_output_btn->set_text(TTR("Add Output"));
- add_output_btn->connect("pressed", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_add_output_port), varray(p_id, group_node->get_free_output_port_id(), VisualShaderNode::PORT_TYPE_VECTOR, "output" + itos(group_node->get_free_output_port_id())), CONNECT_DEFERRED);
+ add_output_btn->connect("pressed", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_add_output_port), varray(p_id, group_node->get_free_output_port_id(), VisualShaderNode::PORT_TYPE_VECTOR, output_port_name), CONNECT_DEFERRED);
hb2->add_child(add_output_btn);
node->add_child(hb2);
@@ -583,8 +601,8 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
name_box->set_custom_minimum_size(Size2(65 * EDSCALE, 0));
name_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
name_box->set_text(name_left);
- name_box->connect("text_entered", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_change_input_port_name), varray(name_box, p_id, i));
- name_box->connect("focus_exited", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_port_name_focus_out), varray(name_box, p_id, i, false));
+ name_box->connect("text_entered", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_change_input_port_name), varray(name_box, p_id, i), CONNECT_DEFERRED);
+ name_box->connect("focus_exited", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_port_name_focus_out), varray(name_box, p_id, i, false), CONNECT_DEFERRED);
Button *remove_btn = memnew(Button);
remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons"));
@@ -624,8 +642,8 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
name_box->set_custom_minimum_size(Size2(65 * EDSCALE, 0));
name_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
name_box->set_text(name_right);
- name_box->connect("text_entered", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_change_output_port_name), varray(name_box, p_id, i));
- name_box->connect("focus_exited", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_port_name_focus_out), varray(name_box, p_id, i, true));
+ name_box->connect("text_entered", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_change_output_port_name), varray(name_box, p_id, i), CONNECT_DEFERRED);
+ name_box->connect("focus_exited", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_port_name_focus_out), varray(name_box, p_id, i, true), CONNECT_DEFERRED);
OptionButton *type_box = memnew(OptionButton);
hb->add_child(type_box);
@@ -712,6 +730,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
}
expression_box->add_theme_font_override("font", VisualShaderEditor::get_singleton()->get_theme_font("expression", "EditorFonts"));
+ expression_box->add_theme_font_size_override("font_size", VisualShaderEditor::get_singleton()->get_theme_font_size("expression_size", "EditorFonts"));
expression_box->add_theme_color_override("font_color", text_color);
expression_syntax_highlighter->set_number_color(number_color);
expression_syntax_highlighter->set_symbol_color(symbol_color);
@@ -1334,29 +1353,57 @@ void VisualShaderEditor::_change_output_port_type(int p_type, int p_node, int p_
undo_redo->commit_action();
}
-void VisualShaderEditor::_change_input_port_name(const String &p_text, Object *line_edit, int p_node_id, int p_port_id) {
+void VisualShaderEditor::_change_input_port_name(const String &p_text, Object *p_line_edit, int p_node_id, int p_port_id) {
VisualShader::Type type = get_current_shader_type();
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node_id);
ERR_FAIL_COND(!node.is_valid());
+ String prev_name = node->get_input_port_name(p_port_id);
+ if (prev_name == p_text) {
+ return;
+ }
+
+ LineEdit *line_edit = Object::cast_to<LineEdit>(p_line_edit);
+ ERR_FAIL_COND(!line_edit);
+
+ String validated_name = visual_shader->validate_port_name(p_text, node.ptr(), p_port_id, false);
+ if (validated_name == String() || prev_name == validated_name) {
+ line_edit->set_text(node->get_input_port_name(p_port_id));
+ return;
+ }
+
undo_redo->create_action(TTR("Change Input Port Name"));
- undo_redo->add_do_method(node.ptr(), "set_input_port_name", p_port_id, p_text);
+ undo_redo->add_do_method(node.ptr(), "set_input_port_name", p_port_id, validated_name);
undo_redo->add_undo_method(node.ptr(), "set_input_port_name", p_port_id, node->get_input_port_name(p_port_id));
undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type, p_node_id);
undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type, p_node_id);
undo_redo->commit_action();
}
-void VisualShaderEditor::_change_output_port_name(const String &p_text, Object *line_edit, int p_node_id, int p_port_id) {
+void VisualShaderEditor::_change_output_port_name(const String &p_text, Object *p_line_edit, int p_node_id, int p_port_id) {
VisualShader::Type type = get_current_shader_type();
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node_id);
ERR_FAIL_COND(!node.is_valid());
+ String prev_name = node->get_output_port_name(p_port_id);
+ if (prev_name == p_text) {
+ return;
+ }
+
+ LineEdit *line_edit = Object::cast_to<LineEdit>(p_line_edit);
+ ERR_FAIL_COND(!line_edit);
+
+ String validated_name = visual_shader->validate_port_name(p_text, node.ptr(), p_port_id, true);
+ if (validated_name == String() || prev_name == validated_name) {
+ line_edit->set_text(node->get_output_port_name(p_port_id));
+ return;
+ }
+
undo_redo->create_action(TTR("Change Output Port Name"));
- undo_redo->add_do_method(node.ptr(), "set_output_port_name", p_port_id, p_text);
- undo_redo->add_undo_method(node.ptr(), "set_output_port_name", p_port_id, node->get_output_port_name(p_port_id));
+ undo_redo->add_do_method(node.ptr(), "set_output_port_name", p_port_id, validated_name);
+ undo_redo->add_undo_method(node.ptr(), "set_output_port_name", p_port_id, prev_name);
undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type, p_node_id);
undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type, p_node_id);
undo_redo->commit_action();
@@ -1451,6 +1498,17 @@ void VisualShaderEditor::_remove_output_port(int p_node, int p_port) {
}
}
+ int preview_port = node->get_output_port_for_preview();
+ if (preview_port != -1) {
+ if (preview_port == p_port) {
+ undo_redo->add_do_method(node.ptr(), "set_output_port_for_preview", -1);
+ undo_redo->add_undo_method(node.ptr(), "set_output_port_for_preview", preview_port);
+ } else if (preview_port > p_port) {
+ undo_redo->add_do_method(node.ptr(), "set_output_port_for_preview", preview_port - 1);
+ undo_redo->add_undo_method(node.ptr(), "set_output_port_for_preview", preview_port);
+ }
+ }
+
undo_redo->add_do_method(node.ptr(), "remove_output_port", p_port);
undo_redo->add_undo_method(node.ptr(), "add_output_port", p_port, (int)node->get_output_port_type(p_port), node->get_output_port_name(p_port));
@@ -1595,53 +1653,10 @@ void VisualShaderEditor::_uniform_line_edit_focus_out(Object *line_edit, int p_n
}
void VisualShaderEditor::_port_name_focus_out(Object *line_edit, int p_node_id, int p_port_id, bool p_output) {
- VisualShader::Type type = get_current_shader_type();
-
- Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node_id);
- ERR_FAIL_COND(!node.is_valid());
-
- String text = Object::cast_to<LineEdit>(line_edit)->get_text();
-
- if (!p_output) {
- if (node->get_input_port_name(p_port_id) == text) {
- return;
- }
- } else {
- if (node->get_output_port_name(p_port_id) == text) {
- return;
- }
- }
-
- List<String> input_names;
- List<String> output_names;
-
- for (int i = 0; i < node->get_input_port_count(); i++) {
- if (!p_output && i == p_port_id) {
- continue;
- }
- input_names.push_back(node->get_input_port_name(i));
- }
- for (int i = 0; i < node->get_output_port_count(); i++) {
- if (p_output && i == p_port_id) {
- continue;
- }
- output_names.push_back(node->get_output_port_name(i));
- }
-
- String validated_name = visual_shader->validate_port_name(text, input_names, output_names);
- if (validated_name == "") {
- if (!p_output) {
- Object::cast_to<LineEdit>(line_edit)->set_text(node->get_input_port_name(p_port_id));
- } else {
- Object::cast_to<LineEdit>(line_edit)->set_text(node->get_output_port_name(p_port_id));
- }
- return;
- }
-
if (!p_output) {
- _change_input_port_name(validated_name, line_edit, p_node_id, p_port_id);
+ _change_input_port_name(Object::cast_to<LineEdit>(line_edit)->get_text(), line_edit, p_node_id, p_port_id);
} else {
- _change_output_port_name(validated_name, line_edit, p_node_id, p_port_id);
+ _change_output_port_name(Object::cast_to<LineEdit>(line_edit)->get_text(), line_edit, p_node_id, p_port_id);
}
}
@@ -2240,6 +2255,7 @@ void VisualShaderEditor::_notification(int p_what) {
}
preview_text->add_theme_font_override("font", get_theme_font("expression", "EditorFonts"));
+ preview_text->add_theme_font_size_override("font_size", get_theme_font_size("expression_size", "EditorFonts"));
preview_text->add_theme_color_override("font_color", text_color);
syntax_highlighter->set_number_color(number_color);
syntax_highlighter->set_symbol_color(symbol_color);
@@ -2250,6 +2266,7 @@ void VisualShaderEditor::_notification(int p_what) {
syntax_highlighter->add_color_region("//", "", comment_color, true);
error_text->add_theme_font_override("font", get_theme_font("status_source", "EditorFonts"));
+ error_text->add_theme_font_size_override("font_size", get_theme_font_size("status_source_size", "EditorFonts"));
error_text->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
}
@@ -3123,7 +3140,7 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("InvProjection", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "inv_projection"), "inv_projection", VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("Normal", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "normal"), "normal", VisualShaderNode::PORT_TYPE_VECTOR, -1, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("OutputIsSRGB", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "output_is_srgb"), "output_is_srgb", VisualShaderNode::PORT_TYPE_BOOLEAN, -1, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Projection", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "camera"), "projection", VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Projection", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "projection"), "projection", VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("Time", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "time"), "time", VisualShaderNode::PORT_TYPE_SCALAR, -1, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("ViewportSize", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "viewport_size"), "viewport_size", VisualShaderNode::PORT_TYPE_VECTOR, -1, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("World", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "world"), "world", VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL));
@@ -3170,7 +3187,7 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("View", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "view"), "view", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("Albedo", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "albedo"), "albedo", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Attenuation", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "attenuation"), "attenuation", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Attenuation", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "attenuation"), "attenuation", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("Diffuse", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "diffuse"), "diffuse", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("FragCoord", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "fragcoord"), "fragcoord", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("Light", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light"), "light", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
@@ -3178,7 +3195,7 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("Metallic", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "metallic"), "metallic", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("Roughness", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "roughness"), "roughness", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("Specular", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "specular"), "specular", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Transmission", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "transmission"), "transmission", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Backlight", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "backlight"), "backlight", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("View", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "view"), "view", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("Alpha", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "alpha"), "alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL));
@@ -3193,33 +3210,38 @@ VisualShaderEditor::VisualShaderEditor() {
// CANVASITEM INPUTS
+ add_options.push_back(AddOption("AtLightPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "at_light_pass"), "at_light_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM));
add_options.push_back(AddOption("FragCoord", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "fragcoord"), "fragcoord", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("LightPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "light_pass"), "light_pass", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM));
add_options.push_back(AddOption("NormalTexture", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "normal_texture"), "normal_texture", VisualShaderNode::PORT_TYPE_SAMPLER, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM));
add_options.push_back(AddOption("PointCoord", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "point_coord"), "point_coord", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM));
add_options.push_back(AddOption("ScreenPixelSize", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "screen_pixel_size"), "screen_pixel_size", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM));
add_options.push_back(AddOption("ScreenTexture", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "screen_texture"), "screen_texture", VisualShaderNode::PORT_TYPE_SAMPLER, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM));
add_options.push_back(AddOption("ScreenUV", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "screen_uv"), "screen_uv", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("SpecularShininess", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "specular_shininess"), "specular_shininess", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("SpecularShininessAlpha", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "specular_shininess_alpha"), "specular_shininess_alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("SpecularShininessTexture", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "specular_shininess_texture"), "specular_shininess_texture", VisualShaderNode::PORT_TYPE_SAMPLER, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM));
add_options.push_back(AddOption("Texture", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "texture"), "texture", VisualShaderNode::PORT_TYPE_SAMPLER, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM));
add_options.push_back(AddOption("FragCoord", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "fragcoord"), "fragcoord", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("Light", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light"), "light", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
add_options.push_back(AddOption("LightAlpha", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light_alpha"), "light_alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
add_options.push_back(AddOption("LightColor", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light_color"), "light_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("LightHeight", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light_height"), "light_height", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("LightUV", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light_uv"), "light_uv", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("LightVector", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light_vec"), "light_vec", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("LightColorAlpha", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light_color_alpha"), "light_color_alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("LightPosition", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light_position"), "light_position", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("LightVertex", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light_vertex"), "light_vertex", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
add_options.push_back(AddOption("Normal", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "normal"), "normal", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
add_options.push_back(AddOption("PointCoord", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "point_coord"), "point_coord", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
add_options.push_back(AddOption("ScreenUV", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "screen_uv"), "screen_uv", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
add_options.push_back(AddOption("ShadowAlpha", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "shadow_alpha"), "shadow_alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
add_options.push_back(AddOption("ShadowColor", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "shadow_color"), "shadow_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("ShadowVec", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "shadow_vec"), "shadow_vec", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("SpecularShininess", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "specular_shininess"), "specular_shininess", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("SpecularShininessAlpha", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "specular_shininess_alpha"), "specular_shininess_alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
add_options.push_back(AddOption("Texture", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "texture"), "texture", VisualShaderNode::PORT_TYPE_SAMPLER, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("Extra", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "extra"), "extra", VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("LightPass", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "light_pass"), "light_pass", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("AtLightPass", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "at_light_pass"), "at_light_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("Canvas", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "canvas"), "canvas", VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM));
add_options.push_back(AddOption("PointSize", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "point_size"), "point_size", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("Projection", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "projection"), "projection", VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("Screen", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "screen"), "screen", VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM));
add_options.push_back(AddOption("Vertex", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "vertex"), "vertex", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM));
add_options.push_back(AddOption("World", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "world"), "world", VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM));
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index 73bebcd192..2e7e9a8898 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -354,12 +354,12 @@ class VisualShaderEditor : public VBoxContainer {
void _add_input_port(int p_node, int p_port, int p_port_type, const String &p_name);
void _remove_input_port(int p_node, int p_port);
void _change_input_port_type(int p_type, int p_node, int p_port);
- void _change_input_port_name(const String &p_text, Object *line_edit, int p_node, int p_port);
+ void _change_input_port_name(const String &p_text, Object *p_line_edit, int p_node, int p_port);
void _add_output_port(int p_node, int p_port, int p_port_type, const String &p_name);
void _remove_output_port(int p_node, int p_port);
void _change_output_port_type(int p_type, int p_node, int p_port);
- void _change_output_port_name(const String &p_text, Object *line_edit, int p_node, int p_port);
+ void _change_output_port_name(const String &p_text, Object *p_line_edit, int p_node, int p_port);
void _expression_focus_out(Object *code_edit, int p_node);
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index f26d44d75a..47b1135133 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -804,6 +804,7 @@ public:
project_path = memnew(LineEdit);
project_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ project_path->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE);
pphb->add_child(project_path);
install_path_container = memnew(VBoxContainer);
@@ -818,6 +819,7 @@ public:
install_path = memnew(LineEdit);
install_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ install_path->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE);
iphb->add_child(install_path);
// status icon
@@ -956,7 +958,7 @@ public:
} break;
case NOTIFICATION_DRAW: {
if (hover) {
- draw_style_box(get_theme_stylebox("hover", "Tree"), Rect2(Point2(), get_size() - Size2(10, 0) * EDSCALE));
+ draw_style_box(get_theme_stylebox("hover", "Tree"), Rect2(Point2(), get_size()));
}
} break;
}
@@ -1367,6 +1369,7 @@ void ProjectList::create_project_item_control(int p_index) {
vb->add_child(ec);
Label *title = memnew(Label(!item.missing ? item.project_name : TTR("Missing Project")));
title->add_theme_font_override("font", get_theme_font("title", "EditorFonts"));
+ title->add_theme_font_size_override("font_size", get_theme_font_size("title_size", "EditorFonts"));
title->add_theme_color_override("font_color", font_color);
title->set_clip_text(true);
vb->add_child(title);
@@ -1393,6 +1396,7 @@ void ProjectList::create_project_item_control(int p_index) {
}
Label *fpath = memnew(Label(item.path));
+ fpath->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE);
path_hb->add_child(fpath);
fpath->set_h_size_flags(Control::SIZE_EXPAND_FILL);
fpath->set_modulate(Color(1, 1, 1, 0.5));
@@ -1723,12 +1727,16 @@ void ProjectList::erase_selected_projects() {
void ProjectList::_panel_draw(Node *p_hb) {
Control *hb = Object::cast_to<Control>(p_hb);
- hb->draw_line(Point2(0, hb->get_size().y + 1), Point2(hb->get_size().x - 10, hb->get_size().y + 1), get_theme_color("guide_color", "Tree"));
+ if (is_layout_rtl() && get_v_scrollbar()->is_visible_in_tree()) {
+ hb->draw_line(Point2(get_v_scrollbar()->get_minimum_size().x, hb->get_size().y + 1), Point2(hb->get_size().x, hb->get_size().y + 1), get_theme_color("guide_color", "Tree"));
+ } else {
+ hb->draw_line(Point2(0, hb->get_size().y + 1), Point2(hb->get_size().x, hb->get_size().y + 1), get_theme_color("guide_color", "Tree"));
+ }
String key = _projects[p_hb->get_index()].project_key;
if (_selected_project_keys.has(key)) {
- hb->draw_style_box(get_theme_stylebox("selected", "Tree"), Rect2(Point2(), hb->get_size() - Size2(10, 0) * EDSCALE));
+ hb->draw_style_box(get_theme_stylebox("selected", "Tree"), Rect2(Point2(), hb->get_size()));
}
}
@@ -1814,6 +1822,11 @@ void ProjectList::_bind_methods() {
void ProjectManager::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_TRANSLATION_CHANGED:
+ case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: {
+ settings_hb->set_anchors_and_margins_preset(Control::PRESET_TOP_RIGHT);
+ update();
+ } break;
case NOTIFICATION_ENTER_TREE: {
search_box->set_right_icon(get_theme_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
@@ -1841,7 +1854,7 @@ void ProjectManager::_notification(int p_what) {
}
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
- set_process_unhandled_input(is_visible_in_tree());
+ set_process_unhandled_key_input(is_visible_in_tree());
} break;
case NOTIFICATION_WM_CLOSE_REQUEST: {
_dim_window();
@@ -1880,7 +1893,7 @@ void ProjectManager::_update_project_buttons() {
erase_missing_btn->set_disabled(!_project_list->is_any_project_missing());
}
-void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
+void ProjectManager::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
Ref<InputEventKey> k = p_ev;
if (k.is_valid()) {
@@ -2344,7 +2357,7 @@ void ProjectManager::_on_search_term_changed(const String &p_term) {
void ProjectManager::_bind_methods() {
ClassDB::bind_method("_exit_dialog", &ProjectManager::_exit_dialog);
- ClassDB::bind_method("_unhandled_input", &ProjectManager::_unhandled_input);
+ ClassDB::bind_method("_unhandled_key_input", &ProjectManager::_unhandled_key_input);
ClassDB::bind_method("_update_project_buttons", &ProjectManager::_update_project_buttons);
}
@@ -2417,10 +2430,13 @@ ProjectManager::ProjectManager() {
DisplayServer::get_singleton()->window_set_size(DisplayServer::get_singleton()->window_get_size() * MAX(1, EDSCALE));
}
- String cp;
- cp += 0xA9;
// TRANSLATORS: This refers to the application where users manage their Godot projects.
- DisplayServer::get_singleton()->window_set_title(VERSION_NAME + String(" - ") + TTR("Project Manager") + " - " + cp + " 2007-2020 Juan Linietsky, Ariel Manzur & Godot Contributors");
+ if (TS->is_locale_right_to_left(TranslationServer::get_singleton()->get_tool_locale())) {
+ // For RTL languages, embed translated part of the title (using control characters) to ensure correct order.
+ DisplayServer::get_singleton()->window_set_title(VERSION_NAME + String(" - ") + String::chr(0x202B) + TTR("Project Manager") + String::chr(0x202C) + String::chr(0x200E) + " - " + String::chr(0xA9) + " 2007-2020 Juan Linietsky, Ariel Manzur & Godot Contributors");
+ } else {
+ DisplayServer::get_singleton()->window_set_title(VERSION_NAME + String(" - ") + TTR("Project Manager") + " - " + String::chr(0xA9) + " 2007-2020 Juan Linietsky, Ariel Manzur & Godot Contributors");
+ }
FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files"));
@@ -2552,9 +2568,10 @@ ProjectManager::ProjectManager() {
{
// Version info and language options
- HBoxContainer *settings_hb = memnew(HBoxContainer);
+ settings_hb = memnew(HBoxContainer);
settings_hb->set_alignment(BoxContainer::ALIGN_END);
settings_hb->set_h_grow_direction(Control::GROW_DIRECTION_BEGIN);
+ settings_hb->set_anchors_and_margins_preset(Control::PRESET_TOP_RIGHT);
Label *version_label = memnew(Label);
String hash = String(VERSION_HASH);
@@ -2598,7 +2615,6 @@ ProjectManager::ProjectManager() {
settings_hb->add_child(language_btn);
center_box->add_child(settings_hb);
- settings_hb->set_anchors_and_margins_preset(Control::PRESET_TOP_RIGHT);
}
if (StreamPeerSSL::is_available()) {
diff --git a/editor/project_manager.h b/editor/project_manager.h
index 212d693f1d..0eb063e196 100644
--- a/editor/project_manager.h
+++ b/editor/project_manager.h
@@ -74,6 +74,8 @@ class ProjectManager : public Control {
ConfirmationDialog *ask_update_settings;
ConfirmationDialog *open_templates;
+ HBoxContainer *settings_hb;
+
AcceptDialog *run_error_diag;
AcceptDialog *dialog_error;
ProjectDialog *npdialog;
@@ -110,7 +112,7 @@ class ProjectManager : public Control {
void _install_project(const String &p_zip_path, const String &p_title);
void _dim_window();
- void _unhandled_input(const Ref<InputEvent> &p_ev);
+ void _unhandled_key_input(const Ref<InputEvent> &p_ev);
void _files_dropped(PackedStringArray p_files, int p_screen);
void _on_order_option_changed(int p_idx);
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 1e4ed0c552..847af0f2c2 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -501,7 +501,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
List<String> names;
names.push_back("value:");
config_value_editors(1, 1, 50, names);
- value_editor[0]->set_text(String::num(v));
+ value_editor[0]->set_text(TS->format_number(String::num(v)));
}
} break;
@@ -1389,6 +1389,7 @@ void CustomPropertyEditor::_draw_easing() {
bool flip = hint_text == "attenuation";
Ref<Font> f = easing_draw->get_theme_font("font", "Label");
+ int font_size = easing_draw->get_theme_font_size("font_size", "Label");
Color color = easing_draw->get_theme_color("font_color", "Label");
for (int i = 1; i <= points; i++) {
@@ -1406,7 +1407,7 @@ void CustomPropertyEditor::_draw_easing() {
prev = h;
}
- f->draw(ci, Point2(10, 10 + f->get_ascent()), String::num(exp, 2), color);
+ f->draw_string(ci, Point2(10, 10 + f->get_ascent(font_size)), String::num(exp, 2), HALIGN_LEFT, -1, font_size, color);
}
void CustomPropertyEditor::_text_edit_changed() {
@@ -1432,7 +1433,7 @@ void CustomPropertyEditor::_modified(String p_string) {
updating = true;
switch (type) {
case Variant::INT: {
- String text = value_editor[0]->get_text();
+ String text = TS->parse_number(value_editor[0]->get_text());
Ref<Expression> expr;
expr.instance();
Error err = expr->parse(text);
@@ -1447,7 +1448,7 @@ void CustomPropertyEditor::_modified(String p_string) {
} break;
case Variant::FLOAT: {
if (hint != PROPERTY_HINT_EXP_EASING) {
- String text = value_editor[0]->get_text();
+ String text = TS->parse_number(value_editor[0]->get_text());
v = _parse_real_expression(text);
emit_signal("variant_changed");
}
diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp
index 75420a1ef4..1ff73f25c5 100644
--- a/editor/property_selector.cpp
+++ b/editor/property_selector.cpp
@@ -31,6 +31,7 @@
#include "property_selector.h"
#include "core/os/keyboard.h"
+#include "editor/doc_tools.h"
#include "editor/editor_node.h"
#include "editor_scale.h"
@@ -349,7 +350,7 @@ void PropertySelector::_item_selected() {
class_type = base_type;
}
- DocData *dd = EditorHelp::get_doc_data();
+ DocTools *dd = EditorHelp::get_doc_data();
String text;
if (properties) {
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index ec225c3c38..fafb90e864 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -114,7 +114,12 @@ void SceneTreeDock::_unhandled_key_input(Ref<InputEvent> p_event) {
_tool_selected(TOOL_COPY_NODE_PATH);
} else if (ED_IS_SHORTCUT("scene_tree/delete", p_event)) {
_tool_selected(TOOL_ERASE);
+ } else {
+ return;
}
+
+ // Tool selection was successful, accept the event to stop propagation.
+ accept_event();
}
void SceneTreeDock::instance(const String &p_file) {
@@ -1990,6 +1995,9 @@ void SceneTreeDock::_do_create(Node *p_parent) {
if (ms.height < 4) {
ms.height = 40;
}
+ if (ct->is_layout_rtl()) {
+ ct->set_position(ct->get_position() - Vector2(ms.x, 0));
+ }
ct->set_size(ms);
}
}
@@ -2954,6 +2962,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
quick_open = memnew(EditorQuickOpen);
add_child(quick_open);
quick_open->connect("quick_open", callable_mp(this, &SceneTreeDock::_quick_open));
+
set_process_unhandled_key_input(true);
delete_dialog = memnew(ConfirmationDialog);
diff --git a/editor/shader_globals_editor.cpp b/editor/shader_globals_editor.cpp
index 915aec6d9a..8345c49a92 100644
--- a/editor/shader_globals_editor.cpp
+++ b/editor/shader_globals_editor.cpp
@@ -483,5 +483,8 @@ ShaderGlobalsEditor::ShaderGlobalsEditor() {
}
ShaderGlobalsEditor::~ShaderGlobalsEditor() {
+ if (is_visible_in_tree()) {
+ inspector->edit(nullptr);
+ }
memdelete(interface);
}