summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/abstract_polygon_2d_editor.cpp12
-rw-r--r--editor/plugins/animation_blend_space_1d_editor.cpp12
-rw-r--r--editor/plugins/animation_blend_space_2d_editor.cpp16
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp2
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp6
-rw-r--r--editor/plugins/animation_state_machine_editor.cpp12
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp22
-rw-r--r--editor/plugins/audio_stream_editor_plugin.cpp9
-rw-r--r--editor/plugins/audio_stream_editor_plugin.h19
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp88
-rw-r--r--editor/plugins/collision_polygon_3d_editor_plugin.cpp10
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.cpp2
-rw-r--r--editor/plugins/curve_editor_plugin.cpp8
-rw-r--r--editor/plugins/editor_preview_plugins.cpp4
-rw-r--r--editor/plugins/mesh_editor_plugin.cpp4
-rw-r--r--editor/plugins/mesh_library_editor_plugin.cpp2
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp84
-rw-r--r--editor/plugins/node_3d_editor_plugin.h2
-rw-r--r--editor/plugins/path_2d_editor_plugin.cpp10
-rw-r--r--editor/plugins/path_3d_editor_plugin.cpp4
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.cpp10
-rw-r--r--editor/plugins/script_editor_plugin.cpp6
-rw-r--r--editor/plugins/script_text_editor.cpp10
-rw-r--r--editor/plugins/shader_editor_plugin.cpp6
-rw-r--r--editor/plugins/skeleton_3d_editor_plugin.cpp59
-rw-r--r--editor/plugins/sprite_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp10
-rw-r--r--editor/plugins/text_editor.cpp2
-rw-r--r--editor/plugins/texture_layered_editor_plugin.cpp4
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp14
-rw-r--r--editor/plugins/theme_editor_plugin.cpp1141
-rw-r--r--editor/plugins/theme_editor_plugin.h108
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp14
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp40
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp274
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h37
36 files changed, 1388 insertions, 679 deletions
diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp
index c90f87de56..80d0a7db60 100644
--- a/editor/plugins/abstract_polygon_2d_editor.cpp
+++ b/editor/plugins/abstract_polygon_2d_editor.cpp
@@ -264,7 +264,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
Vector2 cpoint = _get_node()->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mb->get_position())));
if (mode == MODE_EDIT || (_is_line() && mode == MODE_CREATE)) {
- if (mb->get_button_index() == BUTTON_LEFT) {
+ if (mb->get_button_index() == MOUSE_BUTTON_LEFT) {
if (mb->is_pressed()) {
if (mb->get_control() || mb->get_shift() || mb->get_alt()) {
return false;
@@ -326,7 +326,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
return true;
}
}
- } else if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed() && !edited_point.valid()) {
+ } else if (mb->get_button_index() == MOUSE_BUTTON_RIGHT && mb->is_pressed() && !edited_point.valid()) {
const PosVertex closest = closest_point(gpoint);
if (closest.valid()) {
@@ -335,7 +335,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
}
}
} else if (mode == MODE_DELETE) {
- if (mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
+ if (mb->get_button_index() == MOUSE_BUTTON_LEFT && mb->is_pressed()) {
const PosVertex closest = closest_point(gpoint);
if (closest.valid()) {
@@ -346,7 +346,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
}
if (mode == MODE_CREATE) {
- if (mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
+ if (mb->get_button_index() == MOUSE_BUTTON_LEFT && mb->is_pressed()) {
if (_is_line()) {
// for lines, we don't have a wip mode, and we can undo each single add point.
Vector<Vector2> vertices = _get_polygon(0);
@@ -384,7 +384,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
return true;
}
}
- } else if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed() && wip_active) {
+ } else if (mb->get_button_index() == MOUSE_BUTTON_RIGHT && mb->is_pressed() && wip_active) {
_wip_cancel();
}
}
@@ -395,7 +395,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
if (mm.is_valid()) {
Vector2 gpoint = mm->get_position();
- if (edited_point.valid() && (wip_active || (mm->get_button_mask() & BUTTON_MASK_LEFT))) {
+ if (edited_point.valid() && (wip_active || (mm->get_button_mask() & MOUSE_BUTTON_MASK_LEFT))) {
Vector2 cpoint = _get_node()->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint)));
//Move the point in a single axis. Should only work when editing a polygon and while holding shift.
diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp
index d69913cc46..f7c0ebcfaf 100644
--- a/editor/plugins/animation_blend_space_1d_editor.cpp
+++ b/editor/plugins/animation_blend_space_1d_editor.cpp
@@ -51,7 +51,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid() && mb->is_pressed() && ((tool_select->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) || (mb->get_button_index() == BUTTON_LEFT && tool_create->is_pressed()))) {
+ if (mb.is_valid() && mb->is_pressed() && ((tool_select->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_RIGHT) || (mb->get_button_index() == MOUSE_BUTTON_LEFT && tool_create->is_pressed()))) {
menu->clear();
animations_menu->clear();
animations_to_add.clear();
@@ -110,7 +110,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
}
}
- if (mb.is_valid() && mb->is_pressed() && tool_select->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+ if (mb.is_valid() && mb->is_pressed() && tool_select->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
blend_space_draw->update(); // why not
// try to see if a point can be selected
@@ -132,7 +132,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
}
}
- if (mb.is_valid() && !mb->is_pressed() && dragging_selected_attempt && mb->get_button_index() == BUTTON_LEFT) {
+ if (mb.is_valid() && !mb->is_pressed() && dragging_selected_attempt && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
if (dragging_selected) {
// move
float point = blend_space->get_blend_point_position(selected_point);
@@ -161,7 +161,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
}
// *set* the blend
- if (mb.is_valid() && !mb->is_pressed() && tool_blend->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+ if (mb.is_valid() && !mb->is_pressed() && tool_blend->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
float blend_pos = mb->get_position().x / blend_space_draw->get_size().x;
blend_pos *= blend_space->get_max_space() - blend_space->get_min_space();
blend_pos += blend_space->get_min_space();
@@ -184,7 +184,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
_update_edited_point_pos();
}
- if (mm.is_valid() && tool_blend->is_pressed() && mm->get_button_mask() & BUTTON_MASK_LEFT) {
+ if (mm.is_valid() && tool_blend->is_pressed() && mm->get_button_mask() & MOUSE_BUTTON_MASK_LEFT) {
float blend_pos = mm->get_position().x / blend_space_draw->get_size().x;
blend_pos *= blend_space->get_max_space() - blend_space->get_min_space();
blend_pos += blend_space->get_min_space();
@@ -698,7 +698,7 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
max_value->set_step(0.01);
label_value = memnew(LineEdit);
- label_value->set_expand_to_text_length(true);
+ label_value->set_expand_to_text_length_enabled(true);
// now add
diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp
index 6a57463dbc..e719df53d5 100644
--- a/editor/plugins/animation_blend_space_2d_editor.cpp
+++ b/editor/plugins/animation_blend_space_2d_editor.cpp
@@ -79,7 +79,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid() && mb->is_pressed() && ((tool_select->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) || (mb->get_button_index() == BUTTON_LEFT && tool_create->is_pressed()))) {
+ if (mb.is_valid() && mb->is_pressed() && ((tool_select->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_RIGHT) || (mb->get_button_index() == MOUSE_BUTTON_LEFT && tool_create->is_pressed()))) {
menu->clear();
animations_menu->clear();
animations_to_add.clear();
@@ -134,7 +134,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
}
}
- if (mb.is_valid() && mb->is_pressed() && tool_select->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+ if (mb.is_valid() && mb->is_pressed() && tool_select->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
blend_space_draw->update(); //update anyway
//try to see if a point can be selected
selected_point = -1;
@@ -174,7 +174,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
}
}
- if (mb.is_valid() && mb->is_pressed() && tool_triangle->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+ if (mb.is_valid() && mb->is_pressed() && tool_triangle->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
blend_space_draw->update(); //update anyway
//try to see if a point can be selected
selected_point = -1;
@@ -209,7 +209,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
}
}
- if (mb.is_valid() && !mb->is_pressed() && dragging_selected_attempt && mb->get_button_index() == BUTTON_LEFT) {
+ if (mb.is_valid() && !mb->is_pressed() && dragging_selected_attempt && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
if (dragging_selected) {
//move
Vector2 point = blend_space->get_blend_point_position(selected_point);
@@ -236,7 +236,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
blend_space_draw->update();
}
- if (mb.is_valid() && mb->is_pressed() && tool_blend->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+ if (mb.is_valid() && mb->is_pressed() && tool_blend->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
Vector2 blend_pos = (mb->get_position() / blend_space_draw->get_size());
blend_pos.y = 1.0 - blend_pos.y;
blend_pos *= (blend_space->get_max_space() - blend_space->get_min_space());
@@ -270,7 +270,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
blend_space_draw->update();
}
- if (mm.is_valid() && tool_blend->is_pressed() && mm->get_button_mask() & BUTTON_MASK_LEFT) {
+ if (mm.is_valid() && tool_blend->is_pressed() && mm->get_button_mask() & MOUSE_BUTTON_MASK_LEFT) {
Vector2 blend_pos = (mm->get_position() / blend_space_draw->get_size());
blend_pos.y = 1.0 - blend_pos.y;
blend_pos *= (blend_space->get_max_space() - blend_space->get_min_space());
@@ -942,7 +942,7 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {
left_vbox->add_spacer();
label_y = memnew(LineEdit);
left_vbox->add_child(label_y);
- label_y->set_expand_to_text_length(true);
+ label_y->set_expand_to_text_length_enabled(true);
left_vbox->add_spacer();
min_y_value = memnew(SpinBox);
left_vbox->add_child(min_y_value);
@@ -978,7 +978,7 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {
bottom_vbox->add_spacer();
label_x = memnew(LineEdit);
bottom_vbox->add_child(label_x);
- label_x->set_expand_to_text_length(true);
+ label_x->set_expand_to_text_length_enabled(true);
bottom_vbox->add_spacer();
max_x_value = memnew(SpinBox);
bottom_vbox->add_child(max_x_value);
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index fdbbe5184b..48fb507bb1 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -136,7 +136,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
if (String(E->get()) != "output") {
LineEdit *name = memnew(LineEdit);
name->set_text(E->get());
- name->set_expand_to_text_length(true);
+ name->set_expand_to_text_length_enabled(true);
node->add_child(name);
node->set_slot(0, false, 0, Color(), true, 0, get_theme_color("font_color", "Label"));
name->connect("text_entered", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_renamed), varray(agnode), CONNECT_DEFERRED);
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 7c623505b5..612a8f30a4 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -117,8 +117,8 @@ void AnimationPlayerEditor::_notification(int p_what) {
autoplay_icon = get_theme_icon("AutoPlay", "EditorIcons");
reset_icon = get_theme_icon("Reload", "EditorIcons");
{
- Ref<Image> autoplay_img = autoplay_icon->get_data();
- Ref<Image> reset_img = reset_icon->get_data();
+ Ref<Image> autoplay_img = autoplay_icon->get_image();
+ Ref<Image> reset_img = reset_icon->get_image();
Ref<Image> autoplay_reset_img;
Size2 icon_size = Size2(autoplay_img->get_width(), autoplay_img->get_height());
autoplay_reset_img.instance();
@@ -1219,6 +1219,8 @@ void AnimationPlayerEditor::_onion_skinning_menu(int p_option) {
}
void AnimationPlayerEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
+ ERR_FAIL_COND(p_ev.is_null());
+
Ref<InputEventKey> k = p_ev;
if (is_visible_in_tree() && k.is_valid() && k->is_pressed() && !k->is_echo() && !k->get_alt() && !k->get_control() && !k->get_metakey()) {
switch (k->get_keycode()) {
diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp
index c6d2faf849..a9709bbb16 100644
--- a/editor/plugins/animation_state_machine_editor.cpp
+++ b/editor/plugins/animation_state_machine_editor.cpp
@@ -76,7 +76,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
Ref<InputEventMouseButton> mb = p_event;
//Add new node
- if (mb.is_valid() && mb->is_pressed() && ((tool_select->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) || (tool_create->is_pressed() && mb->get_button_index() == BUTTON_LEFT))) {
+ if (mb.is_valid() && mb->is_pressed() && ((tool_select->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_RIGHT) || (tool_create->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT))) {
menu->clear();
animations_menu->clear();
animations_to_add.clear();
@@ -124,7 +124,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
}
// select node or push a field inside
- if (mb.is_valid() && !mb->get_shift() && mb->is_pressed() && tool_select->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+ if (mb.is_valid() && !mb->get_shift() && mb->is_pressed() && tool_select->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
selected_transition_from = StringName();
selected_transition_to = StringName();
selected_node = StringName();
@@ -216,7 +216,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
}
//end moving node
- if (mb.is_valid() && dragging_selected_attempt && mb->get_button_index() == BUTTON_LEFT && !mb->is_pressed()) {
+ if (mb.is_valid() && dragging_selected_attempt && mb->get_button_index() == MOUSE_BUTTON_LEFT && !mb->is_pressed()) {
if (dragging_selected) {
Ref<AnimationNode> an = state_machine->get_node(selected_node);
updating = true;
@@ -237,7 +237,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
}
//connect nodes
- if (mb.is_valid() && ((tool_select->is_pressed() && mb->get_shift()) || tool_connect->is_pressed()) && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
+ if (mb.is_valid() && ((tool_select->is_pressed() && mb->get_shift()) || tool_connect->is_pressed()) && mb->get_button_index() == MOUSE_BUTTON_LEFT && mb->is_pressed()) {
for (int i = node_rects.size() - 1; i >= 0; i--) { //inverse to draw order
if (node_rects[i].node.has_point(mb->get_position())) { //select node since nothing else was selected
connecting = true;
@@ -250,7 +250,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
}
//end connecting nodes
- if (mb.is_valid() && connecting && mb->get_button_index() == BUTTON_LEFT && !mb->is_pressed()) {
+ if (mb.is_valid() && connecting && mb->get_button_index() == MOUSE_BUTTON_LEFT && !mb->is_pressed()) {
if (connecting_to_node != StringName()) {
if (state_machine->has_transition(connecting_from, connecting_to_node)) {
EditorNode::get_singleton()->show_warning(TTR("Transition exists!"));
@@ -284,7 +284,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
Ref<InputEventMouseMotion> mm = p_event;
//pan window
- if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_MIDDLE) {
+ if (mm.is_valid() && mm->get_button_mask() & MOUSE_BUTTON_MASK_MIDDLE) {
h_scroll->set_value(h_scroll->get_value() - mm->get_relative().x);
v_scroll->set_value(v_scroll->get_value() - mm->get_relative().y);
}
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index b7484aa748..fd47d9964e 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -144,8 +144,8 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const
for (int i = 0; i < preview_images.size(); i++) {
if (preview_images[i].id == p_index) {
if (preview_images[i].is_video) {
- Ref<Image> overlay = previews->get_theme_icon("PlayOverlay", "EditorIcons")->get_data();
- Ref<Image> thumbnail = p_image->get_data();
+ Ref<Image> overlay = previews->get_theme_icon("PlayOverlay", "EditorIcons")->get_image();
+ Ref<Image> thumbnail = p_image->get_image();
thumbnail = thumbnail->duplicate();
Point2 overlay_pos = Point2((thumbnail->get_width() - overlay->get_width()) / 2, (thumbnail->get_height() - overlay->get_height()) / 2);
@@ -557,8 +557,15 @@ void EditorAssetLibrary::_notification(int p_what) {
error_label->raise();
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
- if (is_visible() && initial_loading) {
- _repository_changed(0); // Update when shown for the first time.
+ if (is_visible()) {
+ // Focus the search box automatically when switching to the Templates tab (in the Project Manager)
+ // or switching to the AssetLib tab (in the editor).
+ // The Project Manager's project filter box is automatically focused in the project manager code.
+ filter->grab_focus();
+
+ if (initial_loading) {
+ _repository_changed(0); // Update when shown for the first time.
+ }
}
} break;
case NOTIFICATION_PROCESS: {
@@ -606,6 +613,8 @@ void EditorAssetLibrary::_update_repository_options() {
}
void EditorAssetLibrary::_unhandled_key_input(const Ref<InputEvent> &p_event) {
+ ERR_FAIL_COND(p_event.is_null());
+
const Ref<InputEventKey> key = p_event;
if (key.is_valid() && key->is_pressed()) {
@@ -1332,6 +1341,11 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
library_main->add_theme_constant_override("separation", 10 * EDSCALE);
filter = memnew(LineEdit);
+ if (templates_only) {
+ filter->set_placeholder(TTR("Search templates, projects, and demos"));
+ } else {
+ filter->set_placeholder(TTR("Search assets (excluding templates, projects, and demos)"));
+ }
search_hb->add_child(filter);
filter->set_h_size_flags(Control::SIZE_EXPAND_FILL);
filter->connect("text_changed", callable_mp(this, &EditorAssetLibrary::_search_text_changed));
diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp
index 5963092860..3553450672 100644
--- a/editor/plugins/audio_stream_editor_plugin.cpp
+++ b/editor/plugins/audio_stream_editor_plugin.cpp
@@ -105,6 +105,8 @@ void AudioStreamEditor::_audio_changed() {
void AudioStreamEditor::_play() {
if (_player->is_playing()) {
+ // '_pausing' variable indicates that we want to pause the audio player, not stop it. See '_on_finished()'.
+ _pausing = true;
_player->stop();
_play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons"));
set_process(false);
@@ -125,10 +127,13 @@ void AudioStreamEditor::_stop() {
void AudioStreamEditor::_on_finished() {
_play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons"));
- if (_current == _player->get_stream()->get_length()) {
+ if (!_pausing) {
_current = 0;
_indicator->update();
+ } else {
+ _pausing = false;
}
+ set_process(false);
}
void AudioStreamEditor::_draw_indicator() {
@@ -194,8 +199,6 @@ void AudioStreamEditor::_bind_methods() {
AudioStreamEditor::AudioStreamEditor() {
set_custom_minimum_size(Size2(1, 100) * EDSCALE);
- _current = 0;
- _dragging = false;
_player = memnew(AudioStreamPlayer);
_player->connect("finished", callable_mp(this, &AudioStreamEditor::_on_finished));
diff --git a/editor/plugins/audio_stream_editor_plugin.h b/editor/plugins/audio_stream_editor_plugin.h
index aa906a6a05..14e829d025 100644
--- a/editor/plugins/audio_stream_editor_plugin.h
+++ b/editor/plugins/audio_stream_editor_plugin.h
@@ -41,17 +41,18 @@ class AudioStreamEditor : public ColorRect {
GDCLASS(AudioStreamEditor, ColorRect);
Ref<AudioStream> stream;
- AudioStreamPlayer *_player;
- ColorRect *_preview;
- Control *_indicator;
- Label *_current_label;
- Label *_duration_label;
+ AudioStreamPlayer *_player = nullptr;
+ ColorRect *_preview = nullptr;
+ Control *_indicator = nullptr;
+ Label *_current_label = nullptr;
+ Label *_duration_label = nullptr;
- Button *_play_button;
- Button *_stop_button;
+ Button *_play_button = nullptr;
+ Button *_stop_button = nullptr;
- float _current;
- bool _dragging;
+ float _current = 0;
+ bool _dragging = false;
+ bool _pausing = false;
void _audio_changed();
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 23467c8377..fc3e15aa52 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -472,6 +472,8 @@ float CanvasItemEditor::snap_angle(float p_target, float p_start) const {
}
void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
+ ERR_FAIL_COND(p_ev.is_null());
+
Ref<InputEventKey> k = p_ev;
if (!is_visible_in_tree()) {
@@ -802,11 +804,15 @@ void CanvasItemEditor::_find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_n
bool CanvasItemEditor::_select_click_on_item(CanvasItem *item, Point2 p_click_pos, bool p_append) {
bool still_selected = true;
- if (p_append) {
+ if (p_append && !editor_selection->get_selected_node_list().is_empty()) {
if (editor_selection->is_selected(item)) {
// Already in the selection, remove it from the selected nodes
editor_selection->remove_node(item);
still_selected = false;
+
+ if (editor_selection->get_selected_node_list().size() == 1) {
+ editor->push_item(editor_selection->get_selected_node_list()[0]);
+ }
} else {
// Add the item to the selection
editor_selection->add_node(item);
@@ -1095,7 +1101,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve
}
// Start dragging a guide
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed()) {
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && b->is_pressed()) {
// Press button
if (b->get_position().x < RULER_WIDTH && b->get_position().y < RULER_WIDTH) {
// Drag a new double guide
@@ -1154,7 +1160,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve
}
// Release confirms the guide move
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && !b->is_pressed()) {
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && !b->is_pressed()) {
if (show_guides && EditorNode::get_singleton()->get_edited_scene()) {
Transform2D xform = viewport_scrollable->get_transform() * transform;
@@ -1268,7 +1274,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
if (pan_on_scroll) {
// Perform horizontal scrolling first so we can check for Shift being held.
if (b->is_pressed() &&
- (b->get_button_index() == BUTTON_WHEEL_LEFT || (b->get_shift() && b->get_button_index() == BUTTON_WHEEL_UP))) {
+ (b->get_button_index() == MOUSE_BUTTON_WHEEL_LEFT || (b->get_shift() && b->get_button_index() == MOUSE_BUTTON_WHEEL_UP))) {
// Pan left
view_offset.x -= int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor();
update_viewport();
@@ -1276,7 +1282,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
}
if (b->is_pressed() &&
- (b->get_button_index() == BUTTON_WHEEL_RIGHT || (b->get_shift() && b->get_button_index() == BUTTON_WHEEL_DOWN))) {
+ (b->get_button_index() == MOUSE_BUTTON_WHEEL_RIGHT || (b->get_shift() && b->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN))) {
// Pan right
view_offset.x += int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor();
update_viewport();
@@ -1284,7 +1290,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
}
}
- if (b->is_pressed() && b->get_button_index() == BUTTON_WHEEL_DOWN) {
+ if (b->is_pressed() && b->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN) {
// Scroll or pan down
if (pan_on_scroll) {
view_offset.y += int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor();
@@ -1299,7 +1305,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
return true;
}
- if (b->is_pressed() && b->get_button_index() == BUTTON_WHEEL_UP) {
+ if (b->is_pressed() && b->get_button_index() == MOUSE_BUTTON_WHEEL_UP) {
// Scroll or pan up
if (pan_on_scroll) {
view_offset.y -= int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor();
@@ -1316,17 +1322,17 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
if (!panning) {
if (b->is_pressed() &&
- (b->get_button_index() == BUTTON_MIDDLE ||
- b->get_button_index() == BUTTON_RIGHT ||
- (b->get_button_index() == BUTTON_LEFT && tool == TOOL_PAN) ||
- (b->get_button_index() == BUTTON_LEFT && !EditorSettings::get_singleton()->get("editors/2d/simple_panning") && pan_pressed))) {
+ (b->get_button_index() == MOUSE_BUTTON_MIDDLE ||
+ b->get_button_index() == MOUSE_BUTTON_RIGHT ||
+ (b->get_button_index() == MOUSE_BUTTON_LEFT && tool == TOOL_PAN) ||
+ (b->get_button_index() == MOUSE_BUTTON_LEFT && !EditorSettings::get_singleton()->get("editors/2d/simple_panning") && pan_pressed))) {
// Pan the viewport
panning = true;
}
}
if (panning) {
- if (!b->is_pressed() && (pan_on_scroll || (b->get_button_index() != BUTTON_WHEEL_DOWN && b->get_button_index() != BUTTON_WHEEL_UP))) {
+ if (!b->is_pressed() && (pan_on_scroll || (b->get_button_index() != MOUSE_BUTTON_WHEEL_DOWN && b->get_button_index() != MOUSE_BUTTON_WHEEL_UP))) {
// Stop panning the viewport (for any mouse button press except zooming)
panning = false;
}
@@ -1412,7 +1418,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) {
// Drag the pivot (in pivot mode / with V key)
if (drag_type == DRAG_NONE) {
- if ((b.is_valid() && b->is_pressed() && b->get_button_index() == BUTTON_LEFT && tool == TOOL_EDIT_PIVOT) ||
+ if ((b.is_valid() && b->is_pressed() && b->get_button_index() == MOUSE_BUTTON_LEFT && tool == TOOL_EDIT_PIVOT) ||
(k.is_valid() && k->is_pressed() && !k->is_echo() && k->get_keycode() == KEY_V)) {
List<CanvasItem *> selection = _get_edited_canvas_items();
@@ -1466,7 +1472,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) {
// Confirm the pivot move
if (drag_selection.size() >= 1 &&
- ((b.is_valid() && !b->is_pressed() && b->get_button_index() == BUTTON_LEFT && tool == TOOL_EDIT_PIVOT) ||
+ ((b.is_valid() && !b->is_pressed() && b->get_button_index() == MOUSE_BUTTON_LEFT && tool == TOOL_EDIT_PIVOT) ||
(k.is_valid() && !k->is_pressed() && k->get_keycode() == KEY_V))) {
_commit_canvas_item_state(
drag_selection,
@@ -1480,7 +1486,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) {
}
// Cancel a drag
- if (b.is_valid() && b->get_button_index() == BUTTON_RIGHT && b->is_pressed()) {
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_RIGHT && b->is_pressed()) {
_restore_canvas_item_state(drag_selection);
drag_type = DRAG_NONE;
viewport->update();
@@ -1566,7 +1572,7 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) {
// Start rotation
if (drag_type == DRAG_NONE) {
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed()) {
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && b->is_pressed()) {
if ((b->get_command() && !b->get_alt() && tool == TOOL_SELECT) || tool == TOOL_ROTATE) {
List<CanvasItem *> selection = _get_edited_canvas_items();
@@ -1610,7 +1616,7 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) {
}
// Confirms the node rotation
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && !b->is_pressed()) {
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && !b->is_pressed()) {
if (drag_selection.size() != 1) {
_commit_canvas_item_state(
drag_selection,
@@ -1634,7 +1640,7 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) {
}
// Cancel a drag
- if (b.is_valid() && b->get_button_index() == BUTTON_RIGHT && b->is_pressed()) {
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_RIGHT && b->is_pressed()) {
_restore_canvas_item_state(drag_selection);
drag_type = DRAG_NONE;
viewport->update();
@@ -1648,7 +1654,7 @@ bool CanvasItemEditor::_gui_input_open_scene_on_double_click(const Ref<InputEven
Ref<InputEventMouseButton> b = p_event;
// Open a sub-scene on double-click
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed() && b->is_doubleclick() && tool == TOOL_SELECT) {
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && b->is_pressed() && b->is_doubleclick() && tool == TOOL_SELECT) {
List<CanvasItem *> selection = _get_edited_canvas_items();
if (selection.size() == 1) {
CanvasItem *canvas_item = selection[0];
@@ -1667,7 +1673,7 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref<InputEvent> &p_event) {
// Starts anchor dragging if needed
if (drag_type == DRAG_NONE) {
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed() && tool == TOOL_SELECT) {
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && b->is_pressed() && tool == TOOL_SELECT) {
List<CanvasItem *> selection = _get_edited_canvas_items();
if (selection.size() == 1) {
Control *control = Object::cast_to<Control>(selection[0]);
@@ -1787,7 +1793,7 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref<InputEvent> &p_event) {
}
// Confirms new anchor position
- if (drag_selection.size() >= 1 && b.is_valid() && b->get_button_index() == BUTTON_LEFT && !b->is_pressed()) {
+ if (drag_selection.size() >= 1 && b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && !b->is_pressed()) {
_commit_canvas_item_state(
drag_selection,
vformat(TTR("Move CanvasItem \"%s\" Anchor"), drag_selection[0]->get_name()));
@@ -1796,7 +1802,7 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref<InputEvent> &p_event) {
}
// Cancel a drag
- if (b.is_valid() && b->get_button_index() == BUTTON_RIGHT && b->is_pressed()) {
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_RIGHT && b->is_pressed()) {
_restore_canvas_item_state(drag_selection);
drag_type = DRAG_NONE;
viewport->update();
@@ -1812,7 +1818,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
// Drag resize handles
if (drag_type == DRAG_NONE) {
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed() && tool == TOOL_SELECT) {
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && b->is_pressed() && tool == TOOL_SELECT) {
List<CanvasItem *> selection = _get_edited_canvas_items();
if (selection.size() == 1) {
CanvasItem *canvas_item = selection[0];
@@ -1966,7 +1972,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
}
// Confirm resize
- if (drag_selection.size() >= 1 && b.is_valid() && b->get_button_index() == BUTTON_LEFT && !b->is_pressed()) {
+ if (drag_selection.size() >= 1 && b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && !b->is_pressed()) {
const Node2D *node2d = Object::cast_to<Node2D>(drag_selection[0]);
if (node2d) {
// Extends from Node2D.
@@ -2003,7 +2009,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
}
// Cancel a drag
- if (b.is_valid() && b->get_button_index() == BUTTON_RIGHT && b->is_pressed()) {
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_RIGHT && b->is_pressed()) {
_restore_canvas_item_state(drag_selection);
snap_target[0] = SNAP_TARGET_NONE;
snap_target[1] = SNAP_TARGET_NONE;
@@ -2021,7 +2027,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
// Drag resize handles
if (drag_type == DRAG_NONE) {
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed() && ((b->get_alt() && b->get_control()) || tool == TOOL_SCALE)) {
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && b->is_pressed() && ((b->get_alt() && b->get_control()) || tool == TOOL_SCALE)) {
List<CanvasItem *> selection = _get_edited_canvas_items();
if (selection.size() == 1) {
CanvasItem *canvas_item = selection[0];
@@ -2117,7 +2123,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
}
// Confirm resize
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && !b->is_pressed()) {
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && !b->is_pressed()) {
if (drag_selection.size() != 1) {
_commit_canvas_item_state(
drag_selection,
@@ -2142,7 +2148,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
}
// Cancel a drag
- if (b.is_valid() && b->get_button_index() == BUTTON_RIGHT && b->is_pressed()) {
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_RIGHT && b->is_pressed()) {
_restore_canvas_item_state(drag_selection);
drag_type = DRAG_NONE;
viewport->update();
@@ -2159,7 +2165,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
if (drag_type == DRAG_NONE) {
//Start moving the nodes
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed()) {
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && b->is_pressed()) {
if ((b->get_alt() && !b->get_control()) || tool == TOOL_MOVE) {
List<CanvasItem *> selection = _get_edited_canvas_items();
@@ -2262,7 +2268,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
}
// Confirm the move (only if it was moved)
- if (b.is_valid() && !b->is_pressed() && b->get_button_index() == BUTTON_LEFT) {
+ if (b.is_valid() && !b->is_pressed() && b->get_button_index() == MOUSE_BUTTON_LEFT) {
if (transform.affine_inverse().xform(b->get_position()) != drag_from) {
if (drag_selection.size() != 1) {
_commit_canvas_item_state(
@@ -2295,7 +2301,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
}
// Cancel a drag
- if (b.is_valid() && b->get_button_index() == BUTTON_RIGHT && b->is_pressed()) {
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_RIGHT && b->is_pressed()) {
_restore_canvas_item_state(drag_selection, true);
snap_target[0] = SNAP_TARGET_NONE;
snap_target[1] = SNAP_TARGET_NONE;
@@ -2435,8 +2441,8 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
if (drag_type == DRAG_NONE) {
if (b.is_valid() &&
- ((b->get_button_index() == BUTTON_RIGHT && b->get_alt() && tool == TOOL_SELECT) ||
- (b->get_button_index() == BUTTON_LEFT && tool == TOOL_LIST_SELECT))) {
+ ((b->get_button_index() == MOUSE_BUTTON_RIGHT && b->get_alt() && tool == TOOL_SELECT) ||
+ (b->get_button_index() == MOUSE_BUTTON_LEFT && tool == TOOL_LIST_SELECT))) {
// Popup the selection menu list
Point2 click = transform.affine_inverse().xform(b->get_position());
@@ -2497,7 +2503,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
}
}
- if (b.is_valid() && b->is_pressed() && b->get_button_index() == BUTTON_RIGHT && b->get_control()) {
+ if (b.is_valid() && b->is_pressed() && b->get_button_index() == MOUSE_BUTTON_RIGHT && b->get_control()) {
add_node_menu->set_position(get_global_transform().xform(get_local_mouse_position()));
add_node_menu->set_size(Vector2(1, 1));
add_node_menu->popup();
@@ -2505,7 +2511,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
return true;
}
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed() && tool == TOOL_SELECT) {
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT && b->is_pressed() && tool == TOOL_SELECT) {
// Single item selection
Point2 click = transform.affine_inverse().xform(b->get_position());
@@ -2571,7 +2577,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
}
if (drag_type == DRAG_BOX_SELECTION) {
- if (b.is_valid() && !b->is_pressed() && b->get_button_index() == BUTTON_LEFT) {
+ if (b.is_valid() && !b->is_pressed() && b->get_button_index() == MOUSE_BUTTON_LEFT) {
// Confirms box selection
Node *scene = editor->get_edited_scene();
if (scene) {
@@ -2587,6 +2593,9 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
}
_find_canvas_items_in_rect(Rect2(bsfrom, bsto - bsfrom), scene, &selitems);
+ if (selitems.size() == 1 && editor_selection->get_selected_node_list().is_empty()) {
+ editor->push_item(selitems[0]);
+ }
for (List<CanvasItem *>::Element *E = selitems.front(); E; E = E->next()) {
editor_selection->add_node(E->get());
}
@@ -2597,7 +2606,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
return true;
}
- if (b.is_valid() && b->is_pressed() && b->get_button_index() == BUTTON_RIGHT) {
+ if (b.is_valid() && b->is_pressed() && b->get_button_index() == MOUSE_BUTTON_RIGHT) {
// Cancel box selection
drag_type = DRAG_NONE;
viewport->update();
@@ -2634,7 +2643,7 @@ bool CanvasItemEditor::_gui_input_ruler_tool(const Ref<InputEvent> &p_event) {
ruler_tool_origin = snap_point(viewport->get_local_mouse_position() / zoom + view_offset);
}
- if (b.is_valid() && b->get_button_index() == BUTTON_LEFT) {
+ if (b.is_valid() && b->get_button_index() == MOUSE_BUTTON_LEFT) {
if (b->is_pressed()) {
ruler_tool_active = true;
} else {
@@ -5376,9 +5385,6 @@ void CanvasItemEditor::_focus_selection(int p_op) {
rect = rect.merge(canvas_item_rect);
}
};
- if (count == 0) {
- return;
- }
if (p_op == VIEW_CENTER_TO_SELECTION) {
center = rect.position + rect.size / 2;
diff --git a/editor/plugins/collision_polygon_3d_editor_plugin.cpp b/editor/plugins/collision_polygon_3d_editor_plugin.cpp
index 0c18975258..b50a497ccf 100644
--- a/editor/plugins/collision_polygon_3d_editor_plugin.cpp
+++ b/editor/plugins/collision_polygon_3d_editor_plugin.cpp
@@ -142,7 +142,7 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con
switch (mode) {
case MODE_CREATE: {
- if (mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
+ if (mb->get_button_index() == MOUSE_BUTTON_LEFT && mb->is_pressed()) {
if (!wip_active) {
wip.clear();
wip.push_back(cpoint);
@@ -166,14 +166,14 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con
return true;
}
}
- } else if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed() && wip_active) {
+ } else if (mb->get_button_index() == MOUSE_BUTTON_RIGHT && mb->is_pressed() && wip_active) {
_wip_close();
}
} break;
case MODE_EDIT: {
- if (mb->get_button_index() == BUTTON_LEFT) {
+ if (mb->get_button_index() == MOUSE_BUTTON_LEFT) {
if (mb->is_pressed()) {
if (mb->get_control()) {
if (poly.size() < 3) {
@@ -267,7 +267,7 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con
}
}
}
- if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed() && edited_point == -1) {
+ if (mb->get_button_index() == MOUSE_BUTTON_RIGHT && mb->is_pressed() && edited_point == -1) {
int closest_idx = -1;
Vector2 closest_pos;
real_t closest_dist = 1e10;
@@ -301,7 +301,7 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
- if (edited_point != -1 && (wip_active || mm->get_button_mask() & BUTTON_MASK_LEFT)) {
+ if (edited_point != -1 && (wip_active || mm->get_button_mask() & MOUSE_BUTTON_MASK_LEFT)) {
Vector2 gpoint = mm->get_position();
Vector3 ray_from = p_camera->project_ray_origin(gpoint);
diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp
index 141ee35cdb..c38458c37f 100644
--- a/editor/plugins/collision_shape_2d_editor_plugin.cpp
+++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp
@@ -325,7 +325,7 @@ bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e
if (mb.is_valid()) {
Vector2 gpoint = mb->get_position();
- if (mb->get_button_index() == BUTTON_LEFT) {
+ if (mb->get_button_index() == MOUSE_BUTTON_LEFT) {
if (mb->is_pressed()) {
for (int i = 0; i < handles.size(); i++) {
if (xform.xform(handles[i]).distance_to(gpoint) < 8) {
diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp
index bff5cb8d2a..db999f50ab 100644
--- a/editor/plugins/curve_editor_plugin.cpp
+++ b/editor/plugins/curve_editor_plugin.cpp
@@ -115,22 +115,22 @@ void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) {
}
switch (mb.get_button_index()) {
- case BUTTON_RIGHT:
+ case MOUSE_BUTTON_RIGHT:
_context_click_pos = mpos;
open_context_menu(get_global_transform().xform(mpos));
break;
- case BUTTON_MIDDLE:
+ case MOUSE_BUTTON_MIDDLE:
remove_point(_hover_point);
break;
- case BUTTON_LEFT:
+ case MOUSE_BUTTON_LEFT:
_dragging = true;
break;
}
}
- if (!mb.is_pressed() && _dragging && mb.get_button_index() == BUTTON_LEFT) {
+ if (!mb.is_pressed() && _dragging && mb.get_button_index() == MOUSE_BUTTON_LEFT) {
_dragging = false;
if (_has_undo_data) {
UndoRedo &ur = *EditorNode::get_singleton()->get_undo_redo();
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index eb3c06fba1..d3e5854786 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -88,7 +88,7 @@ Ref<Texture2D> EditorTexturePreviewPlugin::generate(const RES &p_from, const Siz
return Ref<Texture2D>();
}
- Ref<Image> atlas = tex->get_data();
+ Ref<Image> atlas = tex->get_image();
if (!atlas.is_valid()) {
return Ref<Texture2D>();
}
@@ -99,7 +99,7 @@ Ref<Texture2D> EditorTexturePreviewPlugin::generate(const RES &p_from, const Siz
} else {
Ref<Texture2D> tex = p_from;
if (tex.is_valid()) {
- img = tex->get_data();
+ img = tex->get_image();
if (img.is_valid()) {
img = img->duplicate();
}
diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp
index 1e4553a967..9d29c31522 100644
--- a/editor/plugins/mesh_editor_plugin.cpp
+++ b/editor/plugins/mesh_editor_plugin.cpp
@@ -33,8 +33,10 @@
#include "editor/editor_scale.h"
void MeshEditor::_gui_input(Ref<InputEvent> p_event) {
+ ERR_FAIL_COND(p_event.is_null());
+
Ref<InputEventMouseMotion> mm = p_event;
- if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT) {
+ if (mm.is_valid() && mm->get_button_mask() & MOUSE_BUTTON_MASK_LEFT) {
rot_x -= mm->get_relative().y * 0.01;
rot_y -= mm->get_relative().x * 0.01;
if (rot_x < -Math_PI / 2) {
diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp
index f8932cd534..6f1f243444 100644
--- a/editor/plugins/mesh_library_editor_plugin.cpp
+++ b/editor/plugins/mesh_library_editor_plugin.cpp
@@ -93,7 +93,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
mesh = mesh->duplicate();
for (int j = 0; j < mesh->get_surface_count(); ++j) {
- Ref<Material> mat = mi->get_surface_material(j);
+ Ref<Material> mat = mi->get_surface_override_material(j);
if (mat.is_valid()) {
mesh->surface_set_material(j, mat);
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 1d08a7821d..13c7814dac 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -185,8 +185,10 @@ void ViewportRotationControl::_get_sorted_axis(Vector<Axis2D> &r_axis) {
}
void ViewportRotationControl::_gui_input(Ref<InputEvent> p_event) {
+ ERR_FAIL_COND(p_event.is_null());
+
const Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT) {
+ if (mb.is_valid() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
Vector2 pos = mb->get_position();
if (mb->is_pressed()) {
if (pos.distance_to(get_size() / 2.0) < get_size().x / 2.0) {
@@ -1123,23 +1125,21 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
float zoom_factor = 1 + (ZOOM_FREELOOK_MULTIPLIER - 1) * b->get_factor();
switch (b->get_button_index()) {
- case BUTTON_WHEEL_UP: {
+ case MOUSE_BUTTON_WHEEL_UP: {
if (is_freelook_active()) {
scale_freelook_speed(zoom_factor);
} else {
scale_cursor_distance(1.0 / zoom_factor);
}
} break;
-
- case BUTTON_WHEEL_DOWN: {
+ case MOUSE_BUTTON_WHEEL_DOWN: {
if (is_freelook_active()) {
scale_freelook_speed(1.0 / zoom_factor);
} else {
scale_cursor_distance(zoom_factor);
}
} break;
-
- case BUTTON_RIGHT: {
+ case MOUSE_BUTTON_RIGHT: {
NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int();
if (b->is_pressed() && _edit.gizmo.is_valid()) {
@@ -1200,7 +1200,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
} break;
- case BUTTON_MIDDLE: {
+ case MOUSE_BUTTON_MIDDLE: {
if (b->is_pressed() && _edit.mode != TRANSFORM_NONE) {
switch (_edit.plane) {
case TRANSFORM_VIEW: {
@@ -1231,7 +1231,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
}
} break;
- case BUTTON_LEFT: {
+ case MOUSE_BUTTON_LEFT: {
if (b->is_pressed()) {
NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int();
if ((nav_scheme == NAVIGATION_MAYA || nav_scheme == NAVIGATION_MODO) && b->get_alt()) {
@@ -1279,7 +1279,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
clicked = ObjectID();
clicked_includes_current = false;
- if ((spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT && b->get_control()) || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE) {
+ if ((spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT && b->get_command()) || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE) {
/* HANDLE ROTATION */
if (get_selected_count() == 0) {
break; //bye
@@ -1440,7 +1440,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
String n = _edit.gizmo->get_handle_name(_edit.gizmo_handle);
set_message(n + ": " + String(v));
- } else if (m->get_button_mask() & BUTTON_MASK_LEFT) {
+ } else if (m->get_button_mask() & MOUSE_BUTTON_MASK_LEFT) {
if (nav_scheme == NAVIGATION_MAYA && m->get_alt()) {
nav_mode = NAVIGATION_ORBIT;
} else if (nav_scheme == NAVIGATION_MODO && m->get_alt() && m->get_shift()) {
@@ -1474,7 +1474,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
Vector3 ray_pos = _get_ray_pos(m->get_position());
Vector3 ray = _get_ray(m->get_position());
- float snap = EDITOR_GET("interface/inspector/default_float_step");
+ double snap = EDITOR_GET("interface/inspector/default_float_step");
int snap_step_decimals = Math::range_step_decimals(snap);
switch (_edit.mode) {
@@ -1768,7 +1768,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
Vector3 y_axis = (click - _edit.center).normalized();
Vector3 x_axis = plane.normal.cross(y_axis).normalized();
- float angle = Math::atan2(x_axis.dot(intersection - _edit.center), y_axis.dot(intersection - _edit.center));
+ double angle = Math::atan2(x_axis.dot(intersection - _edit.center), y_axis.dot(intersection - _edit.center));
if (_edit.snap || spatial_editor->is_snap_enabled()) {
snap = spatial_editor->get_rotate_snap();
@@ -1830,8 +1830,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
}
}
-
- } else if ((m->get_button_mask() & BUTTON_MASK_RIGHT) || freelook_active) {
+ } else if ((m->get_button_mask() & MOUSE_BUTTON_MASK_RIGHT) || freelook_active) {
if (nav_scheme == NAVIGATION_MAYA && m->get_alt()) {
nav_mode = NAVIGATION_ZOOM;
} else if (freelook_active) {
@@ -1840,7 +1839,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
nav_mode = NAVIGATION_PAN;
}
- } else if (m->get_button_mask() & BUTTON_MASK_MIDDLE) {
+ } else if (m->get_button_mask() & MOUSE_BUTTON_MASK_MIDDLE) {
const int mod = _get_key_modifier(m);
if (nav_scheme == NAVIGATION_GODOT) {
if (mod == _get_key_modifier_setting("editors/3d/navigation/pan_modifier")) {
@@ -1851,13 +1850,11 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
// Always allow Alt as a modifier to better support graphic tablets.
nav_mode = NAVIGATION_ORBIT;
}
-
} else if (nav_scheme == NAVIGATION_MAYA) {
if (mod == _get_key_modifier_setting("editors/3d/navigation/pan_modifier")) {
nav_mode = NAVIGATION_PAN;
}
}
-
} else if (EditorSettings::get_singleton()->get("editors/3d/navigation/emulate_3_button_mouse")) {
// Handle trackpad (no external mouse) use case
const int mod = _get_key_modifier(m);
@@ -2218,6 +2215,12 @@ void Node3DEditorViewport::scale_cursor_distance(real_t scale) {
cursor.distance = CLAMP(cursor.distance * scale, min_distance, max_distance);
}
+ if (cursor.distance == max_distance || cursor.distance == min_distance) {
+ zoom_failed_attempts_count++;
+ } else {
+ zoom_failed_attempts_count = 0;
+ }
+
zoom_indicator_delay = ZOOM_FREELOOK_INDICATOR_DELAY_S;
surface->update();
}
@@ -2399,6 +2402,7 @@ void Node3DEditorViewport::_notification(int p_what) {
zoom_indicator_delay -= delta;
if (zoom_indicator_delay <= 0) {
surface->update();
+ zoom_limit_label->hide();
}
}
@@ -2538,6 +2542,8 @@ void Node3DEditorViewport::_notification(int p_what) {
cpu_time += cpu_time_history[i];
}
cpu_time /= FRAME_TIME_HISTORY;
+ // Prevent unrealistically low values.
+ cpu_time = MAX(0.01, cpu_time);
gpu_time_history[gpu_time_history_index] = RS::get_singleton()->viewport_get_measured_render_time_gpu(viewport->get_viewport_rid());
gpu_time_history_index = (gpu_time_history_index + 1) % FRAME_TIME_HISTORY;
@@ -2546,16 +2552,19 @@ void Node3DEditorViewport::_notification(int p_what) {
gpu_time += gpu_time_history[i];
}
gpu_time /= FRAME_TIME_HISTORY;
+ // Prevent division by zero for the FPS counter (and unrealistically low values).
+ // This limits the reported FPS to 100000.
+ gpu_time = MAX(0.01, gpu_time);
// Color labels depending on performance level ("good" = green, "OK" = yellow, "bad" = red).
// Middle point is at 15 ms.
- cpu_time_label->set_text(vformat(TTR("CPU Time: %s ms"), String::num(cpu_time, 1)));
+ cpu_time_label->set_text(vformat(TTR("CPU Time: %s ms"), rtos(cpu_time).pad_decimals(1)));
cpu_time_label->add_theme_color_override(
"font_color",
frame_time_gradient->get_color_at_offset(
Math::range_lerp(cpu_time, 0, 30, 0, 1)));
- gpu_time_label->set_text(vformat(TTR("GPU Time: %s ms"), String::num(gpu_time, 1)));
+ gpu_time_label->set_text(vformat(TTR("GPU Time: %s ms"), rtos(gpu_time).pad_decimals(1)));
// Middle point is at 15 ms.
gpu_time_label->add_theme_color_override(
"font_color",
@@ -2773,6 +2782,7 @@ void Node3DEditorViewport::_draw() {
} else {
// Show zoom
+ zoom_limit_label->set_visible(zoom_failed_attempts_count > 15);
real_t min_distance = MAX(camera->get_near() * 4, ZOOM_FREELOOK_MIN);
real_t max_distance = MIN(camera->get_far() / 4, ZOOM_FREELOOK_MAX);
@@ -3550,10 +3560,6 @@ void Node3DEditorViewport::reset() {
}
void Node3DEditorViewport::focus_selection() {
- if (!get_selected_count()) {
- return;
- }
-
Vector3 center;
int count = 0;
@@ -3650,9 +3656,9 @@ Vector3 Node3DEditorViewport::_get_instance_position(const Point2 &p_pos) const
AABB Node3DEditorViewport::_calculate_spatial_bounds(const Node3D *p_parent, bool p_exclude_top_level_transform) {
AABB bounds;
- const MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(p_parent);
- if (mesh_instance) {
- bounds = mesh_instance->get_aabb();
+ const VisualInstance3D *visual_instance = Object::cast_to<VisualInstance3D>(p_parent);
+ if (visual_instance) {
+ bounds = visual_instance->get_aabb();
}
for (int i = 0; i < p_parent->get_child_count(); i++) {
@@ -4135,6 +4141,15 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
locked_label->set_text(TTR("View Rotation Locked"));
locked_label->hide();
+ zoom_limit_label = memnew(Label);
+ zoom_limit_label->set_anchors_and_offsets_preset(LayoutPreset::PRESET_BOTTOM_LEFT);
+ zoom_limit_label->set_offset(Side::SIDE_TOP, -28 * EDSCALE);
+ zoom_limit_label->set_text(TTR("To zoom further, change the camera's clipping planes (View -> Settings...)"));
+ zoom_limit_label->set_name("ZoomLimitMessageLabel");
+ zoom_limit_label->add_theme_color_override("font_color", Color(1, 1, 1, 1));
+ zoom_limit_label->hide();
+ surface->add_child(zoom_limit_label);
+
frame_time_gradient = memnew(Gradient);
// The color is set when the theme changes.
frame_time_gradient->add_point(0.5, Color());
@@ -4197,9 +4212,11 @@ Node3DEditorViewport::~Node3DEditorViewport() {
//////////////////////////////////////////////////////////////
void Node3DEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event) {
+ ERR_FAIL_COND(p_event.is_null());
+
Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT) {
+ if (mb.is_valid() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
if (mb->is_pressed()) {
Vector2 size = get_size();
@@ -4582,7 +4599,12 @@ void _update_all_gizmos(Node *p_node) {
void Node3DEditor::update_all_gizmos(Node *p_node) {
if (!p_node) {
- p_node = SceneTree::get_singleton()->get_root();
+ if (SceneTree::get_singleton()) {
+ p_node = SceneTree::get_singleton()->get_root();
+ } else {
+ // No scene tree, so nothing to update.
+ return;
+ }
}
_update_all_gizmos(p_node);
}
@@ -5820,7 +5842,7 @@ void Node3DEditor::_init_grid() {
// Offsets division_level for bigger or smaller grids.
// Default value is -0.2. -1.0 gives Blender-like behavior, 0.5 gives huge grids.
real_t division_level_bias = EditorSettings::get_singleton()->get("editors/3d/grid_division_level_bias");
- // Default largest grid size is 100m, 10^2 (default value is 2).
+ // Default largest grid size is 8^2 when primary_grid_steps is 8 (64m apart, so primary grid lines are 512m apart).
int division_level_max = EditorSettings::get_singleton()->get("editors/3d/grid_division_level_max");
// Default smallest grid size is 1cm, 10^-2 (default value is -2).
int division_level_min = EditorSettings::get_singleton()->get("editors/3d/grid_division_level_min");
@@ -6159,6 +6181,8 @@ void Node3DEditor::snap_selected_nodes_to_floor() {
}
void Node3DEditor::_unhandled_key_input(Ref<InputEvent> p_event) {
+ ERR_FAIL_COND(p_event.is_null());
+
if (!is_visible_in_tree()) {
return;
}
@@ -6611,7 +6635,7 @@ void Node3DEditor::_update_preview_environment() {
void Node3DEditor::_sun_direction_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> mm = p_event;
- if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT) {
+ if (mm.is_valid() && mm->get_button_mask() & MOUSE_BUTTON_MASK_LEFT) {
float x = -mm->get_relative().y * 0.02 * EDSCALE;
float y = mm->get_relative().x * 0.02 * EDSCALE;
diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h
index ff4a941b06..70329f90c7 100644
--- a/editor/plugins/node_3d_editor_plugin.h
+++ b/editor/plugins/node_3d_editor_plugin.h
@@ -295,6 +295,7 @@ private:
Label *info_label;
Label *cinema_label;
Label *locked_label;
+ Label *zoom_limit_label;
VBoxContainer *top_right_vbox;
ViewportRotationControl *rotation_control;
@@ -418,6 +419,7 @@ private:
void scale_freelook_speed(real_t scale);
real_t zoom_indicator_delay;
+ int zoom_failed_attempts_count = 0;
RID move_gizmo_instance[3], move_plane_gizmo_instance[3], rotate_gizmo_instance[4], scale_gizmo_instance[3], scale_plane_gizmo_instance[3];
diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp
index 908235f89f..84b4516452 100644
--- a/editor/plugins/path_2d_editor_plugin.cpp
+++ b/editor/plugins/path_2d_editor_plugin.cpp
@@ -88,7 +88,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
real_t dist_to_p_in = gpoint.distance_to(xform.xform(curve->get_point_position(i) + curve->get_point_in(i)));
// Check for point movement start (for point + in/out controls).
- if (mb->get_button_index() == BUTTON_LEFT) {
+ if (mb->get_button_index() == MOUSE_BUTTON_LEFT) {
if (mode == MODE_EDIT && !mb->get_shift() && dist_to_p < grab_threshold) {
// Points can only be moved in edit mode.
@@ -118,7 +118,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
}
// Check for point deletion.
- if ((mb->get_button_index() == BUTTON_RIGHT && mode == MODE_EDIT) || (mb->get_button_index() == BUTTON_LEFT && mode == MODE_DELETE)) {
+ if ((mb->get_button_index() == MOUSE_BUTTON_RIGHT && mode == MODE_EDIT) || (mb->get_button_index() == MOUSE_BUTTON_LEFT && mode == MODE_DELETE)) {
if (dist_to_p < grab_threshold) {
undo_redo->create_action(TTR("Remove Point from Curve"));
undo_redo->add_do_method(curve.ptr(), "remove_point", i);
@@ -149,7 +149,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
}
// Check for point creation.
- if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && ((mb->get_command() && mode == MODE_EDIT) || mode == MODE_CREATE)) {
+ if (mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT && ((mb->get_command() && mode == MODE_EDIT) || mode == MODE_CREATE)) {
Ref<Curve2D> curve = node->get_curve();
undo_redo->create_action(TTR("Add Point to Curve"));
@@ -170,7 +170,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
}
// Check for segment split.
- if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && mode == MODE_EDIT && on_edge) {
+ if (mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT && mode == MODE_EDIT && on_edge) {
Vector2 gpoint2 = mb->get_position();
Ref<Curve2D> curve = node->get_curve();
@@ -207,7 +207,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
}
// Check for point movement completion.
- if (!mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && action != ACTION_NONE) {
+ if (!mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT && action != ACTION_NONE) {
Ref<Curve2D> curve = node->get_curve();
Vector2 new_pos = moving_from + xform.affine_inverse().basis_xform(gpoint - moving_screen_from);
diff --git a/editor/plugins/path_3d_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp
index 3783af8fc6..47bd1114d2 100644
--- a/editor/plugins/path_3d_editor_plugin.cpp
+++ b/editor/plugins/path_3d_editor_plugin.cpp
@@ -316,7 +316,7 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
set_handle_clicked(false);
}
- if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && (curve_create->is_pressed() || (curve_edit->is_pressed() && mb->get_control()))) {
+ if (mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT && (curve_create->is_pressed() || (curve_edit->is_pressed() && mb->get_control()))) {
//click into curve, break it down
Vector<Vector3> v3a = c->tessellate();
int idx = 0;
@@ -411,7 +411,7 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
//add new at pos
}
- } else if (mb->is_pressed() && ((mb->get_button_index() == BUTTON_LEFT && curve_del->is_pressed()) || (mb->get_button_index() == BUTTON_RIGHT && curve_edit->is_pressed()))) {
+ } else if (mb->is_pressed() && ((mb->get_button_index() == MOUSE_BUTTON_LEFT && curve_del->is_pressed()) || (mb->get_button_index() == MOUSE_BUTTON_RIGHT && curve_edit->is_pressed()))) {
for (int i = 0; i < c->get_point_count(); i++) {
real_t dist_to_p = p_camera->unproject_position(gt.xform(c->get_point_position(i))).distance_to(mbpos);
real_t dist_to_p_out = p_camera->unproject_position(gt.xform(c->get_point_position(i) + c->get_point_out(i))).distance_to(mbpos);
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp
index 3d7b01c149..470d897dcc 100644
--- a/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -447,7 +447,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
Ref<InputEventMouseButton> mb = p_input;
if (mb.is_valid()) {
- if (mb->get_button_index() == BUTTON_LEFT) {
+ if (mb->get_button_index() == MOUSE_BUTTON_LEFT) {
if (mb->is_pressed()) {
uv_drag_from = snap_point(Vector2(mb->get_position().x, mb->get_position().y));
uv_drag = true;
@@ -759,7 +759,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
bone_painting = false;
}
}
- } else if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) {
+ } else if (mb->get_button_index() == MOUSE_BUTTON_RIGHT && mb->is_pressed()) {
_cancel_editing();
if (bone_painting) {
@@ -768,9 +768,9 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
uv_edit_draw->update();
- } else if (mb->get_button_index() == BUTTON_WHEEL_UP && mb->is_pressed()) {
+ } else if (mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP && mb->is_pressed()) {
uv_zoom->set_value(uv_zoom->get_value() / (1 - (0.1 * mb->get_factor())));
- } else if (mb->get_button_index() == BUTTON_WHEEL_DOWN && mb->is_pressed()) {
+ } else if (mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN && mb->is_pressed()) {
uv_zoom->set_value(uv_zoom->get_value() * (1 - (0.1 * mb->get_factor())));
}
}
@@ -778,7 +778,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
Ref<InputEventMouseMotion> mm = p_input;
if (mm.is_valid()) {
- if ((mm->get_button_mask() & BUTTON_MASK_MIDDLE) || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
+ if ((mm->get_button_mask() & MOUSE_BUTTON_MASK_MIDDLE) || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
Vector2 drag(mm->get_relative().x, mm->get_relative().y);
uv_hscroll->set_value(uv_hscroll->get_value() - drag.x);
uv_vscroll->set_value(uv_vscroll->get_value() - drag.y);
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 8bf5d0611d..58e6717a3d 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -2706,6 +2706,8 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co
}
void ScriptEditor::_unhandled_key_input(const Ref<InputEvent> &p_event) {
+ ERR_FAIL_COND(p_event.is_null());
+
if (!is_visible_in_tree() || !p_event->is_pressed() || p_event->is_echo()) {
return;
}
@@ -2737,7 +2739,7 @@ void ScriptEditor::_script_list_gui_input(const Ref<InputEvent> &ev) {
Ref<InputEventMouseButton> mb = ev;
if (mb.is_valid() && mb->is_pressed()) {
switch (mb->get_button_index()) {
- case BUTTON_MIDDLE: {
+ case MOUSE_BUTTON_MIDDLE: {
// Right-click selects automatically; middle-click does not.
int idx = script_list->get_item_at_position(mb->get_position(), true);
if (idx >= 0) {
@@ -2747,7 +2749,7 @@ void ScriptEditor::_script_list_gui_input(const Ref<InputEvent> &ev) {
}
} break;
- case BUTTON_RIGHT: {
+ case MOUSE_BUTTON_RIGHT: {
_make_script_list_context_menu();
} break;
}
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index b6df66b8af..c982207224 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -601,8 +601,7 @@ void ScriptTextEditor::_bookmark_item_pressed(int p_idx) {
if (p_idx < 4) { // Any item before the separator.
_edit_option(bookmarks_menu->get_item_id(p_idx));
} else {
- code_editor->goto_line(bookmarks_menu->get_item_metadata(p_idx));
- code_editor->get_text_editor()->call_deferred("center_viewport_to_cursor"); //Need to be deferred, because goto uses call_deferred().
+ code_editor->goto_line_centered(bookmarks_menu->get_item_metadata(p_idx));
}
}
@@ -791,7 +790,7 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c
emit_signal("request_open_script_at_line", result.script, result.location - 1);
} else {
emit_signal("request_save_history");
- _goto_line(result.location - 1);
+ goto_line_centered(result.location - 1);
}
} break;
case ScriptLanguage::LookupResult::RESULT_CLASS: {
@@ -1517,7 +1516,7 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
bool create_menu = false;
CodeEdit *tx = code_editor->get_text_editor();
- if (mb.is_valid() && mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) {
+ if (mb.is_valid() && mb->get_button_index() == MOUSE_BUTTON_RIGHT && mb->is_pressed()) {
local_pos = mb->get_global_position() - tx->get_global_position();
create_menu = true;
} else if (k.is_valid() && k->get_keycode() == KEY_MENU) {
@@ -1722,6 +1721,9 @@ void ScriptTextEditor::_enable_code_editor() {
color_picker->set_raw_mode(true);
}
+ int picker_shape = EDITOR_GET("interface/inspector/default_color_picker_shape");
+ color_picker->set_picker_shape((ColorPicker::PickerShapeType)picker_shape);
+
quick_open = memnew(ScriptEditorQuickOpen);
quick_open->connect("goto_line", callable_mp(this, &ScriptTextEditor::_goto_line));
add_child(quick_open);
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index c8a46715ad..ed3b746678 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -205,7 +205,7 @@ void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptCo
ShaderLanguage sl;
String calltip;
- sl.complete(p_code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types(), _get_global_variable_type, r_options, calltip);
+ sl.complete(p_code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())), ShaderLanguage::VaryingFunctionNames(), ShaderTypes::get_singleton()->get_types(), _get_global_variable_type, r_options, calltip);
get_text_editor()->set_code_hint(calltip);
}
@@ -219,7 +219,7 @@ void ShaderTextEditor::_validate_script() {
ShaderLanguage sl;
- Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types(), _get_global_variable_type);
+ Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())), ShaderLanguage::VaryingFunctionNames(), ShaderTypes::get_singleton()->get_types(), _get_global_variable_type);
if (err != OK) {
String error_text = "error(" + itos(sl.get_error_line()) + "): " + sl.get_error_text();
@@ -460,7 +460,7 @@ void ShaderEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
Ref<InputEventMouseButton> mb = ev;
if (mb.is_valid()) {
- if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) {
+ if (mb->get_button_index() == MOUSE_BUTTON_RIGHT && mb->is_pressed()) {
int col, row;
CodeEdit *tx = shader_editor->get_text_editor();
tx->_get_mouse_pos(mb->get_global_position() - tx->get_global_position(), row, col);
diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp
index 121ccfa417..404ef62eca 100644
--- a/editor/plugins/skeleton_3d_editor_plugin.cpp
+++ b/editor/plugins/skeleton_3d_editor_plugin.cpp
@@ -167,16 +167,18 @@ void BoneTransformEditor::_notification(int p_what) {
}
void BoneTransformEditor::_value_changed(const double p_value) {
- if (updating)
+ if (updating) {
return;
+ }
Transform tform = compute_transform_from_vector3s();
_change_transform(tform);
}
void BoneTransformEditor::_value_changed_vector3(const String p_property_name, const Vector3 p_vector, const StringName p_edited_property_name, const bool p_boolean) {
- if (updating)
+ if (updating) {
return;
+ }
Transform tform = compute_transform_from_vector3s();
_change_transform(tform);
}
@@ -194,8 +196,9 @@ Transform BoneTransformEditor::compute_transform_from_vector3s() const {
}
void BoneTransformEditor::_value_changed_transform(const String p_property_name, const Transform p_transform, const StringName p_edited_property_name, const bool p_boolean) {
- if (updating)
+ if (updating) {
return;
+ }
_change_transform(p_transform);
}
@@ -222,11 +225,13 @@ void BoneTransformEditor::update_enabled_checkbox() {
}
void BoneTransformEditor::_update_properties() {
- if (updating)
+ if (updating) {
return;
+ }
- if (skeleton == nullptr)
+ if (skeleton == nullptr) {
return;
+ }
updating = true;
@@ -235,11 +240,13 @@ void BoneTransformEditor::_update_properties() {
}
void BoneTransformEditor::_update_custom_pose_properties() {
- if (updating)
+ if (updating) {
return;
+ }
- if (skeleton == nullptr)
+ if (skeleton == nullptr) {
return;
+ }
updating = true;
@@ -287,14 +294,16 @@ void BoneTransformEditor::set_toggle_enabled(const bool p_enabled) {
}
void BoneTransformEditor::_key_button_pressed() {
- if (skeleton == nullptr)
+ if (skeleton == nullptr) {
return;
+ }
const BoneId bone_id = property.get_slicec('/', 1).to_int();
const String name = skeleton->get_bone_name(bone_id);
- if (name.is_empty())
+ if (name.is_empty()) {
return;
+ }
// Need to normalize the basis before you key it
Transform tform = compute_transform_from_vector3s();
@@ -405,8 +414,9 @@ PhysicalBone3D *Skeleton3DEditor::create_physical_bone(int bone_id, int bone_chi
Variant Skeleton3DEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
TreeItem *selected = joint_tree->get_selected();
- if (!selected)
+ if (!selected) {
return Variant();
+ }
Ref<Texture> icon = selected->get_icon(0);
@@ -431,27 +441,32 @@ Variant Skeleton3DEditor::get_drag_data_fw(const Point2 &p_point, Control *p_fro
bool Skeleton3DEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
TreeItem *target = joint_tree->get_item_at_position(p_point);
- if (!target)
+ if (!target) {
return false;
+ }
const String path = target->get_metadata(0);
- if (!path.begins_with("bones/"))
+ if (!path.begins_with("bones/")) {
return false;
+ }
TreeItem *selected = Object::cast_to<TreeItem>(Dictionary(p_data)["node"]);
- if (target == selected)
+ if (target == selected) {
return false;
+ }
const String path2 = target->get_metadata(0);
- if (!path2.begins_with("bones/"))
+ if (!path2.begins_with("bones/")) {
return false;
+ }
return true;
}
void Skeleton3DEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
- if (!can_drop_data_fw(p_point, p_data, p_from))
+ if (!can_drop_data_fw(p_point, p_data, p_from)) {
return;
+ }
TreeItem *target = joint_tree->get_item_at_position(p_point);
TreeItem *selected = Object::cast_to<TreeItem>(Dictionary(p_data)["node"]);
@@ -500,6 +515,8 @@ void Skeleton3DEditor::_joint_tree_selection_changed() {
rest_editor->set_target(bone_path + "rest");
custom_pose_editor->set_target(bone_path + "custom_pose");
+ _update_properties();
+
pose_editor->set_visible(true);
rest_editor->set_visible(true);
custom_pose_editor->set_visible(true);
@@ -510,19 +527,23 @@ void Skeleton3DEditor::_joint_tree_rmb_select(const Vector2 &p_pos) {
}
void Skeleton3DEditor::_update_properties() {
- if (rest_editor)
+ if (rest_editor) {
rest_editor->_update_properties();
- if (pose_editor)
+ }
+ if (pose_editor) {
pose_editor->_update_properties();
- if (custom_pose_editor)
+ }
+ if (custom_pose_editor) {
custom_pose_editor->_update_custom_pose_properties();
+ }
}
void Skeleton3DEditor::update_joint_tree() {
joint_tree->clear();
- if (skeleton == nullptr)
+ if (skeleton == nullptr) {
return;
+ }
TreeItem *root = joint_tree->create_item();
diff --git a/editor/plugins/sprite_2d_editor_plugin.cpp b/editor/plugins/sprite_2d_editor_plugin.cpp
index 4949d2b9b7..4a7f6c0f7e 100644
--- a/editor/plugins/sprite_2d_editor_plugin.cpp
+++ b/editor/plugins/sprite_2d_editor_plugin.cpp
@@ -171,7 +171,7 @@ void Sprite2DEditor::_update_mesh_data() {
return;
}
- Ref<Image> image = texture->get_data();
+ Ref<Image> image = texture->get_image();
ERR_FAIL_COND(image.is_null());
if (image->is_compressed()) {
@@ -179,7 +179,7 @@ void Sprite2DEditor::_update_mesh_data() {
}
Rect2 rect;
- if (node->is_region()) {
+ if (node->is_region_enabled()) {
rect = node->get_region_rect();
} else {
rect.size = Size2(image->get_width(), image->get_height());
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index a6949c873e..bd6dac7490 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -105,7 +105,7 @@ void SpriteFramesEditor::_sheet_preview_draw() {
void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+ if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
Size2i size = split_sheet_preview->get_size();
int h = split_sheet_h->get_value();
int v = split_sheet_v->get_value();
@@ -150,11 +150,11 @@ void SpriteFramesEditor::_sheet_scroll_input(const Ref<InputEvent> &p_event) {
// Zoom in/out using Ctrl + mouse wheel. This is done on the ScrollContainer
// to allow performing this action anywhere, even if the cursor isn't
// hovering the texture in the workspace.
- if (mb->get_button_index() == BUTTON_WHEEL_UP && mb->is_pressed() && mb->get_control()) {
+ if (mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP && mb->is_pressed() && mb->get_control()) {
_sheet_zoom_in();
// Don't scroll up after zooming in.
accept_event();
- } else if (mb->get_button_index() == BUTTON_WHEEL_DOWN && mb->is_pressed() && mb->get_control()) {
+ } else if (mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN && mb->is_pressed() && mb->get_control()) {
_sheet_zoom_out();
// Don't scroll down after zooming out.
accept_event();
@@ -694,11 +694,11 @@ void SpriteFramesEditor::_tree_input(const Ref<InputEvent> &p_event) {
const Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
- if (mb->get_button_index() == BUTTON_WHEEL_UP && mb->is_pressed() && mb->get_control()) {
+ if (mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP && mb->is_pressed() && mb->get_control()) {
_zoom_in();
// Don't scroll up after zooming in.
accept_event();
- } else if (mb->get_button_index() == BUTTON_WHEEL_DOWN && mb->is_pressed() && mb->get_control()) {
+ } else if (mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN && mb->is_pressed() && mb->get_control()) {
_zoom_out();
// Don't scroll down after zooming out.
accept_event();
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index b88f1c91e6..2b8bfe067d 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -469,7 +469,7 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
Ref<InputEventMouseButton> mb = ev;
if (mb.is_valid()) {
- if (mb->get_button_index() == BUTTON_RIGHT) {
+ if (mb->get_button_index() == MOUSE_BUTTON_RIGHT) {
int col, row;
CodeEdit *tx = code_editor->get_text_editor();
tx->_get_mouse_pos(mb->get_global_position() - tx->get_global_position(), row, col);
diff --git a/editor/plugins/texture_layered_editor_plugin.cpp b/editor/plugins/texture_layered_editor_plugin.cpp
index 254ad3d56e..89ed98d53e 100644
--- a/editor/plugins/texture_layered_editor_plugin.cpp
+++ b/editor/plugins/texture_layered_editor_plugin.cpp
@@ -35,8 +35,10 @@
#include "editor/editor_settings.h"
void TextureLayeredEditor::_gui_input(Ref<InputEvent> p_event) {
+ ERR_FAIL_COND(p_event.is_null());
+
Ref<InputEventMouseMotion> mm = p_event;
- if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT) {
+ if (mm.is_valid() && mm->get_button_mask() & MOUSE_BUTTON_MASK_LEFT) {
y_rot += -mm->get_relative().x * 0.01;
x_rot += mm->get_relative().y * 0.01;
_update_material();
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index 63255e6547..7b927ad98b 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -285,7 +285,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
Ref<InputEventMouseButton> mb = p_input;
if (mb.is_valid()) {
- if (mb->get_button_index() == BUTTON_LEFT) {
+ if (mb->get_button_index() == MOUSE_BUTTON_LEFT) {
if (mb->is_pressed()) {
if (node_ninepatch || obj_styleBox.is_valid()) {
edited_margin = -1;
@@ -447,7 +447,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
creating = false;
}
- } else if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) {
+ } else if (mb->get_button_index() == MOUSE_BUTTON_RIGHT && mb->is_pressed()) {
if (drag) {
drag = false;
if (edited_margin >= 0) {
@@ -466,9 +466,9 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
drag_index = -1;
}
}
- } else if (mb->get_button_index() == BUTTON_WHEEL_UP && mb->is_pressed()) {
+ } else if (mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP && mb->is_pressed()) {
_zoom_on_position(draw_zoom * ((0.95 + (0.05 * mb->get_factor())) / 0.95), mb->get_position());
- } else if (mb->get_button_index() == BUTTON_WHEEL_DOWN && mb->is_pressed()) {
+ } else if (mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN && mb->is_pressed()) {
_zoom_on_position(draw_zoom * (1 - (0.05 * mb->get_factor())), mb->get_position());
}
}
@@ -476,7 +476,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
Ref<InputEventMouseMotion> mm = p_input;
if (mm.is_valid()) {
- if (mm->get_button_mask() & BUTTON_MASK_MIDDLE || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
+ if (mm->get_button_mask() & MOUSE_BUTTON_MASK_MIDDLE || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
Vector2 dragged(mm->get_relative().x / draw_zoom, mm->get_relative().y / draw_zoom);
hscroll->set_value(hscroll->get_value() - dragged.x);
vscroll->set_value(vscroll->get_value() - dragged.y);
@@ -897,7 +897,7 @@ void TextureRegionEditor::edit(Object *p_obj) {
atlas_tex = Ref<AtlasTexture>(nullptr);
}
edit_draw->update();
- if ((node_sprite && !node_sprite->is_region()) || (node_sprite_3d && !node_sprite_3d->is_region())) {
+ if ((node_sprite && !node_sprite->is_region_enabled()) || (node_sprite_3d && !node_sprite_3d->is_region_enabled())) {
set_process(true);
}
if (!p_obj) {
@@ -1115,7 +1115,7 @@ void TextureRegionEditorPlugin::_editor_visiblity_changed() {
void TextureRegionEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
texture_region_button->show();
- bool is_node_configured = region_editor->is_stylebox() || region_editor->is_atlas_texture() || region_editor->is_ninepatch() || (region_editor->get_sprite() && region_editor->get_sprite()->is_region()) || (region_editor->get_sprite_3d() && region_editor->get_sprite_3d()->is_region());
+ bool is_node_configured = region_editor->is_stylebox() || region_editor->is_atlas_texture() || region_editor->is_ninepatch() || (region_editor->get_sprite() && region_editor->get_sprite()->is_region_enabled()) || (region_editor->get_sprite_3d() && region_editor->get_sprite_3d()->is_region_enabled());
if ((is_node_configured && !manually_hidden) || texture_region_button->is_pressed()) {
editor->make_bottom_panel_item_visible(region_editor);
}
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index dfa8c04145..c765aa0319 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -31,12 +31,696 @@
#include "theme_editor_plugin.h"
#include "core/os/file_access.h"
+#include "core/os/keyboard.h"
#include "core/version.h"
#include "editor/editor_scale.h"
#include "scene/gui/progress_bar.h"
+void ThemeItemEditorDialog::_dialog_about_to_show() {
+ ERR_FAIL_COND(edited_theme.is_null());
+
+ _update_edit_types();
+}
+
+void ThemeItemEditorDialog::_update_edit_types() {
+ Ref<Theme> base_theme = Theme::get_default();
+
+ List<StringName> theme_types;
+ edited_theme->get_type_list(&theme_types);
+ theme_types.sort_custom<StringName::AlphCompare>();
+
+ bool item_reselected = false;
+ edit_type_list->clear();
+ int e_idx = 0;
+ for (List<StringName>::Element *E = theme_types.front(); E; E = E->next()) {
+ Ref<Texture2D> item_icon;
+ if (E->get() == "") {
+ item_icon = get_theme_icon("NodeDisabled", "EditorIcons");
+ } else {
+ item_icon = EditorNode::get_singleton()->get_class_icon(E->get(), "NodeDisabled");
+ }
+ edit_type_list->add_item(E->get(), item_icon);
+
+ if (E->get() == edited_item_type) {
+ edit_type_list->select(e_idx);
+ item_reselected = true;
+ }
+ e_idx++;
+ }
+ if (!item_reselected) {
+ edited_item_type = "";
+
+ if (edit_type_list->get_item_count() > 0) {
+ edit_type_list->select(0);
+ }
+ }
+
+ List<StringName> default_types;
+ base_theme->get_type_list(&default_types);
+ default_types.sort_custom<StringName::AlphCompare>();
+
+ edit_add_class_options->clear();
+ for (List<StringName>::Element *E = default_types.front(); E; E = E->next()) {
+ edit_add_class_options->add_item(E->get());
+ }
+
+ String selected_type = "";
+ Vector<int> selected_ids = edit_type_list->get_selected_items();
+ if (selected_ids.size() > 0) {
+ selected_type = edit_type_list->get_item_text(selected_ids[0]);
+
+ edit_items_add_color->set_disabled(false);
+ edit_items_add_constant->set_disabled(false);
+ edit_items_add_font->set_disabled(false);
+ edit_items_add_font_size->set_disabled(false);
+ edit_items_add_icon->set_disabled(false);
+ edit_items_add_stylebox->set_disabled(false);
+
+ edit_items_remove_class->set_disabled(false);
+ edit_items_remove_custom->set_disabled(false);
+ edit_items_remove_all->set_disabled(false);
+ } else {
+ edit_items_add_color->set_disabled(true);
+ edit_items_add_constant->set_disabled(true);
+ edit_items_add_font->set_disabled(true);
+ edit_items_add_font_size->set_disabled(true);
+ edit_items_add_icon->set_disabled(true);
+ edit_items_add_stylebox->set_disabled(true);
+
+ edit_items_remove_class->set_disabled(true);
+ edit_items_remove_custom->set_disabled(true);
+ edit_items_remove_all->set_disabled(true);
+ }
+ _update_edit_item_tree(selected_type);
+}
+
+void ThemeItemEditorDialog::_edited_type_selected(int p_item_idx) {
+ String selected_type = edit_type_list->get_item_text(p_item_idx);
+ _update_edit_item_tree(selected_type);
+}
+
+void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) {
+ edited_item_type = p_item_type;
+
+ edit_items_tree->clear();
+ TreeItem *root = edit_items_tree->create_item();
+
+ List<StringName> names;
+
+ {
+ names.clear();
+ edited_theme->get_color_list(p_item_type, &names);
+
+ if (names.size() > 0) {
+ TreeItem *color_root = edit_items_tree->create_item(root);
+ color_root->set_metadata(0, Theme::DATA_TYPE_COLOR);
+ color_root->set_icon(0, get_theme_icon("Color", "EditorIcons"));
+ color_root->set_text(0, TTR("Colors"));
+ color_root->add_button(0, get_theme_icon("Clear", "EditorIcons"), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Color Items"));
+
+ names.sort_custom<StringName::AlphCompare>();
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ TreeItem *item = edit_items_tree->create_item(color_root);
+ item->set_text(0, E->get());
+ item->add_button(0, get_theme_icon("Edit", "EditorIcons"), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item"));
+ item->add_button(0, get_theme_icon("Remove", "EditorIcons"), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item"));
+ }
+ }
+ }
+
+ {
+ names.clear();
+ edited_theme->get_constant_list(p_item_type, &names);
+
+ if (names.size() > 0) {
+ TreeItem *constant_root = edit_items_tree->create_item(root);
+ constant_root->set_metadata(0, Theme::DATA_TYPE_CONSTANT);
+ constant_root->set_icon(0, get_theme_icon("MemberConstant", "EditorIcons"));
+ constant_root->set_text(0, TTR("Constants"));
+ constant_root->add_button(0, get_theme_icon("Clear", "EditorIcons"), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Constant Items"));
+
+ names.sort_custom<StringName::AlphCompare>();
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ TreeItem *item = edit_items_tree->create_item(constant_root);
+ item->set_text(0, E->get());
+ item->add_button(0, get_theme_icon("Edit", "EditorIcons"), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item"));
+ item->add_button(0, get_theme_icon("Remove", "EditorIcons"), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item"));
+ }
+ }
+ }
+
+ {
+ names.clear();
+ edited_theme->get_font_list(p_item_type, &names);
+
+ if (names.size() > 0) {
+ TreeItem *font_root = edit_items_tree->create_item(root);
+ font_root->set_metadata(0, Theme::DATA_TYPE_FONT);
+ font_root->set_icon(0, get_theme_icon("Font", "EditorIcons"));
+ font_root->set_text(0, TTR("Fonts"));
+ font_root->add_button(0, get_theme_icon("Clear", "EditorIcons"), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Font Items"));
+
+ names.sort_custom<StringName::AlphCompare>();
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ TreeItem *item = edit_items_tree->create_item(font_root);
+ item->set_text(0, E->get());
+ item->add_button(0, get_theme_icon("Edit", "EditorIcons"), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item"));
+ item->add_button(0, get_theme_icon("Remove", "EditorIcons"), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item"));
+ }
+ }
+ }
+
+ {
+ names.clear();
+ edited_theme->get_font_size_list(p_item_type, &names);
+
+ if (names.size() > 0) {
+ TreeItem *font_size_root = edit_items_tree->create_item(root);
+ font_size_root->set_metadata(0, Theme::DATA_TYPE_FONT_SIZE);
+ font_size_root->set_icon(0, get_theme_icon("FontSize", "EditorIcons"));
+ font_size_root->set_text(0, TTR("Font Sizes"));
+ font_size_root->add_button(0, get_theme_icon("Clear", "EditorIcons"), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Font Size Items"));
+
+ names.sort_custom<StringName::AlphCompare>();
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ TreeItem *item = edit_items_tree->create_item(font_size_root);
+ item->set_text(0, E->get());
+ item->add_button(0, get_theme_icon("Edit", "EditorIcons"), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item"));
+ item->add_button(0, get_theme_icon("Remove", "EditorIcons"), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item"));
+ }
+ }
+ }
+
+ {
+ names.clear();
+ edited_theme->get_icon_list(p_item_type, &names);
+
+ if (names.size() > 0) {
+ TreeItem *icon_root = edit_items_tree->create_item(root);
+ icon_root->set_metadata(0, Theme::DATA_TYPE_ICON);
+ icon_root->set_icon(0, get_theme_icon("ImageTexture", "EditorIcons"));
+ icon_root->set_text(0, TTR("Icons"));
+ icon_root->add_button(0, get_theme_icon("Clear", "EditorIcons"), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Icon Items"));
+
+ names.sort_custom<StringName::AlphCompare>();
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ TreeItem *item = edit_items_tree->create_item(icon_root);
+ item->set_text(0, E->get());
+ item->add_button(0, get_theme_icon("Edit", "EditorIcons"), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item"));
+ item->add_button(0, get_theme_icon("Remove", "EditorIcons"), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item"));
+ }
+ }
+ }
+
+ {
+ names.clear();
+ edited_theme->get_stylebox_list(p_item_type, &names);
+
+ if (names.size() > 0) {
+ TreeItem *stylebox_root = edit_items_tree->create_item(root);
+ stylebox_root->set_metadata(0, Theme::DATA_TYPE_STYLEBOX);
+ stylebox_root->set_icon(0, get_theme_icon("StyleBoxFlat", "EditorIcons"));
+ stylebox_root->set_text(0, TTR("Styleboxes"));
+ stylebox_root->add_button(0, get_theme_icon("Clear", "EditorIcons"), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All StyleBox Items"));
+
+ names.sort_custom<StringName::AlphCompare>();
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ TreeItem *item = edit_items_tree->create_item(stylebox_root);
+ item->set_text(0, E->get());
+ item->add_button(0, get_theme_icon("Edit", "EditorIcons"), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item"));
+ item->add_button(0, get_theme_icon("Remove", "EditorIcons"), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item"));
+ }
+ }
+ }
+}
+
+void ThemeItemEditorDialog::_item_tree_button_pressed(Object *p_item, int p_column, int p_id) {
+ TreeItem *item = Object::cast_to<TreeItem>(p_item);
+ if (!item) {
+ return;
+ }
+
+ switch (p_id) {
+ case ITEMS_TREE_RENAME_ITEM: {
+ String item_name = item->get_text(0);
+ int data_type = item->get_parent()->get_metadata(0);
+ _open_rename_theme_item_dialog((Theme::DataType)data_type, item_name);
+ } break;
+ case ITEMS_TREE_REMOVE_ITEM: {
+ String item_name = item->get_text(0);
+ int data_type = item->get_parent()->get_metadata(0);
+ edited_theme->clear_theme_item((Theme::DataType)data_type, item_name, edited_item_type);
+ } break;
+ case ITEMS_TREE_REMOVE_DATA_TYPE: {
+ int data_type = item->get_metadata(0);
+ _remove_data_type_items((Theme::DataType)data_type, edited_item_type);
+ } break;
+ }
+
+ _update_edit_item_tree(edited_item_type);
+}
+
+void ThemeItemEditorDialog::_add_class_type_items() {
+ int selected_idx = edit_add_class_options->get_selected();
+ String type_name = edit_add_class_options->get_item_text(selected_idx);
+ List<StringName> names;
+
+ {
+ names.clear();
+ Theme::get_default()->get_icon_list(type_name, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ edited_theme->set_icon(E->get(), type_name, Ref<Texture2D>());
+ }
+ }
+ {
+ names.clear();
+ Theme::get_default()->get_stylebox_list(type_name, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ edited_theme->set_stylebox(E->get(), type_name, Ref<StyleBox>());
+ }
+ }
+ {
+ names.clear();
+ Theme::get_default()->get_font_list(type_name, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ edited_theme->set_font(E->get(), type_name, Ref<Font>());
+ }
+ }
+ {
+ names.clear();
+ Theme::get_default()->get_font_size_list(type_name, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ edited_theme->set_font_size(E->get(), type_name, Theme::get_default()->get_font_size(E->get(), type_name));
+ }
+ }
+ {
+ names.clear();
+ Theme::get_default()->get_color_list(type_name, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ edited_theme->set_color(E->get(), type_name, Theme::get_default()->get_color(E->get(), type_name));
+ }
+ }
+ {
+ names.clear();
+ Theme::get_default()->get_constant_list(type_name, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ edited_theme->set_constant(E->get(), type_name, Theme::get_default()->get_constant(E->get(), type_name));
+ }
+ }
+
+ _update_edit_types();
+}
+
+void ThemeItemEditorDialog::_add_custom_type() {
+ edited_theme->add_icon_type(edit_add_custom_value->get_text());
+ edited_theme->add_stylebox_type(edit_add_custom_value->get_text());
+ edited_theme->add_font_type(edit_add_custom_value->get_text());
+ edited_theme->add_font_size_type(edit_add_custom_value->get_text());
+ edited_theme->add_color_type(edit_add_custom_value->get_text());
+ edited_theme->add_constant_type(edit_add_custom_value->get_text());
+ _update_edit_types();
+}
+
+void ThemeItemEditorDialog::_add_theme_item(Theme::DataType p_data_type, String p_item_name, String p_item_type) {
+ switch (p_data_type) {
+ case Theme::DATA_TYPE_ICON:
+ edited_theme->set_icon(p_item_name, p_item_type, Ref<Texture2D>());
+ break;
+ case Theme::DATA_TYPE_STYLEBOX:
+ edited_theme->set_stylebox(p_item_name, p_item_type, Ref<StyleBox>());
+ break;
+ case Theme::DATA_TYPE_FONT:
+ edited_theme->set_font(p_item_name, p_item_type, Ref<Font>());
+ break;
+ case Theme::DATA_TYPE_FONT_SIZE:
+ edited_theme->set_font_size(p_item_name, p_item_type, -1);
+ break;
+ case Theme::DATA_TYPE_COLOR:
+ edited_theme->set_color(p_item_name, p_item_type, Color());
+ break;
+ case Theme::DATA_TYPE_CONSTANT:
+ edited_theme->set_constant(p_item_name, p_item_type, 0);
+ break;
+ case Theme::DATA_TYPE_MAX:
+ break; // Can't happen, but silences warning.
+ }
+}
+
+void ThemeItemEditorDialog::_remove_data_type_items(Theme::DataType p_data_type, String p_item_type) {
+ List<StringName> names;
+
+ edited_theme->get_theme_item_list(p_data_type, p_item_type, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ edited_theme->clear_theme_item(p_data_type, E->get(), p_item_type);
+ }
+}
+
+void ThemeItemEditorDialog::_remove_class_items() {
+ List<StringName> names;
+
+ for (int dt = 0; dt < Theme::DATA_TYPE_MAX; dt++) {
+ Theme::DataType data_type = (Theme::DataType)dt;
+
+ names.clear();
+ Theme::get_default()->get_theme_item_list(data_type, edited_item_type, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ if (edited_theme->has_theme_item_nocheck(data_type, E->get(), edited_item_type)) {
+ edited_theme->clear_theme_item(data_type, E->get(), edited_item_type);
+ }
+ }
+ }
+
+ _update_edit_item_tree(edited_item_type);
+}
+
+void ThemeItemEditorDialog::_remove_custom_items() {
+ List<StringName> names;
+
+ for (int dt = 0; dt < Theme::DATA_TYPE_MAX; dt++) {
+ Theme::DataType data_type = (Theme::DataType)dt;
+
+ names.clear();
+ edited_theme->get_theme_item_list(data_type, edited_item_type, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ if (!Theme::get_default()->has_theme_item_nocheck(data_type, E->get(), edited_item_type)) {
+ edited_theme->clear_theme_item(data_type, E->get(), edited_item_type);
+ }
+ }
+ }
+
+ _update_edit_item_tree(edited_item_type);
+}
+
+void ThemeItemEditorDialog::_remove_all_items() {
+ List<StringName> names;
+
+ for (int dt = 0; dt < Theme::DATA_TYPE_MAX; dt++) {
+ Theme::DataType data_type = (Theme::DataType)dt;
+
+ names.clear();
+ edited_theme->get_theme_item_list(data_type, edited_item_type, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ edited_theme->clear_theme_item(data_type, E->get(), edited_item_type);
+ }
+ }
+
+ _update_edit_item_tree(edited_item_type);
+}
+
+void ThemeItemEditorDialog::_open_add_theme_item_dialog(int p_data_type) {
+ ERR_FAIL_INDEX_MSG(p_data_type, Theme::DATA_TYPE_MAX, "Theme item data type is out of bounds.");
+
+ item_popup_mode = CREATE_THEME_ITEM;
+ edit_item_data_type = (Theme::DataType)p_data_type;
+
+ switch (edit_item_data_type) {
+ case Theme::DATA_TYPE_COLOR:
+ edit_theme_item_dialog->set_title(TTR("Add Color Item"));
+ break;
+ case Theme::DATA_TYPE_CONSTANT:
+ edit_theme_item_dialog->set_title(TTR("Add Constant Item"));
+ break;
+ case Theme::DATA_TYPE_FONT:
+ edit_theme_item_dialog->set_title(TTR("Add Font Item"));
+ break;
+ case Theme::DATA_TYPE_FONT_SIZE:
+ edit_theme_item_dialog->set_title(TTR("Add Font Size Item"));
+ break;
+ case Theme::DATA_TYPE_ICON:
+ edit_theme_item_dialog->set_title(TTR("Add Icon Item"));
+ break;
+ case Theme::DATA_TYPE_STYLEBOX:
+ edit_theme_item_dialog->set_title(TTR("Add Stylebox Item"));
+ break;
+ case Theme::DATA_TYPE_MAX:
+ break; // Can't happen, but silences warning.
+ }
+
+ edit_theme_item_old_vb->hide();
+ theme_item_name->clear();
+ edit_theme_item_dialog->popup_centered(Size2(380, 110) * EDSCALE);
+ theme_item_name->grab_focus();
+}
+
+void ThemeItemEditorDialog::_open_rename_theme_item_dialog(Theme::DataType p_data_type, String p_item_name) {
+ ERR_FAIL_INDEX_MSG(p_data_type, Theme::DATA_TYPE_MAX, "Theme item data type is out of bounds.");
+
+ item_popup_mode = RENAME_THEME_ITEM;
+ edit_item_data_type = p_data_type;
+ edit_item_old_name = p_item_name;
+
+ switch (edit_item_data_type) {
+ case Theme::DATA_TYPE_COLOR:
+ edit_theme_item_dialog->set_title(TTR("Rename Color Item"));
+ break;
+ case Theme::DATA_TYPE_CONSTANT:
+ edit_theme_item_dialog->set_title(TTR("Rename Constant Item"));
+ break;
+ case Theme::DATA_TYPE_FONT:
+ edit_theme_item_dialog->set_title(TTR("Rename Font Item"));
+ break;
+ case Theme::DATA_TYPE_FONT_SIZE:
+ edit_theme_item_dialog->set_title(TTR("Rename Font Size Item"));
+ break;
+ case Theme::DATA_TYPE_ICON:
+ edit_theme_item_dialog->set_title(TTR("Rename Icon Item"));
+ break;
+ case Theme::DATA_TYPE_STYLEBOX:
+ edit_theme_item_dialog->set_title(TTR("Rename Stylebox Item"));
+ break;
+ case Theme::DATA_TYPE_MAX:
+ break; // Can't happen, but silences warning.
+ }
+
+ edit_theme_item_old_vb->show();
+ theme_item_old_name->set_text(p_item_name);
+ theme_item_name->set_text(p_item_name);
+ edit_theme_item_dialog->popup_centered(Size2(380, 140) * EDSCALE);
+ theme_item_name->grab_focus();
+}
+
+void ThemeItemEditorDialog::_confirm_edit_theme_item() {
+ if (item_popup_mode == CREATE_THEME_ITEM) {
+ _add_theme_item(edit_item_data_type, theme_item_name->get_text(), edited_item_type);
+ } else if (item_popup_mode == RENAME_THEME_ITEM) {
+ edited_theme->rename_theme_item(edit_item_data_type, edit_item_old_name, theme_item_name->get_text(), edited_item_type);
+ }
+
+ item_popup_mode = ITEM_POPUP_MODE_MAX;
+ edit_item_data_type = Theme::DATA_TYPE_MAX;
+ edit_item_old_name = "";
+
+ _update_edit_item_tree(edited_item_type);
+}
+
+void ThemeItemEditorDialog::_edit_theme_item_gui_input(const Ref<InputEvent> &p_event) {
+ Ref<InputEventKey> k = p_event;
+
+ if (k.is_valid()) {
+ if (!k->is_pressed()) {
+ return;
+ }
+
+ switch (k->get_keycode()) {
+ case KEY_KP_ENTER:
+ case KEY_ENTER: {
+ _confirm_edit_theme_item();
+ edit_theme_item_dialog->hide();
+ edit_theme_item_dialog->set_input_as_handled();
+ } break;
+ case KEY_ESCAPE: {
+ edit_theme_item_dialog->hide();
+ edit_theme_item_dialog->set_input_as_handled();
+ } break;
+ }
+ }
+}
+
+void ThemeItemEditorDialog::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ connect("about_to_popup", callable_mp(this, &ThemeItemEditorDialog::_dialog_about_to_show));
+ [[fallthrough]];
+ }
+ case NOTIFICATION_THEME_CHANGED: {
+ edit_items_add_color->set_icon(get_theme_icon("Color", "EditorIcons"));
+ edit_items_add_constant->set_icon(get_theme_icon("MemberConstant", "EditorIcons"));
+ edit_items_add_font->set_icon(get_theme_icon("Font", "EditorIcons"));
+ edit_items_add_font_size->set_icon(get_theme_icon("FontSize", "EditorIcons"));
+ edit_items_add_icon->set_icon(get_theme_icon("ImageTexture", "EditorIcons"));
+ edit_items_add_stylebox->set_icon(get_theme_icon("StyleBoxFlat", "EditorIcons"));
+
+ edit_items_remove_class->set_icon(get_theme_icon("Control", "EditorIcons"));
+ edit_items_remove_custom->set_icon(get_theme_icon("ThemeRemoveCustomItems", "EditorIcons"));
+ edit_items_remove_all->set_icon(get_theme_icon("ThemeRemoveAllItems", "EditorIcons"));
+ } break;
+ }
+}
+
+void ThemeItemEditorDialog::set_edited_theme(const Ref<Theme> &p_theme) {
+ edited_theme = p_theme;
+}
+
+ThemeItemEditorDialog::ThemeItemEditorDialog() {
+ set_title(TTR("Edit Theme Items"));
+
+ HSplitContainer *edit_dialog_hs = memnew(HSplitContainer);
+ add_child(edit_dialog_hs);
+
+ VBoxContainer *edit_dialog_side_vb = memnew(VBoxContainer);
+ edit_dialog_side_vb->set_custom_minimum_size(Size2(200.0, 0.0) * EDSCALE);
+ edit_dialog_hs->add_child(edit_dialog_side_vb);
+
+ Label *edit_type_label = memnew(Label);
+ edit_type_label->set_text(TTR("Types:"));
+ edit_dialog_side_vb->add_child(edit_type_label);
+
+ edit_type_list = memnew(ItemList);
+ edit_type_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ edit_dialog_side_vb->add_child(edit_type_list);
+ edit_type_list->connect("item_selected", callable_mp(this, &ThemeItemEditorDialog::_edited_type_selected));
+
+ Label *edit_add_class_label = memnew(Label);
+ edit_add_class_label->set_text(TTR("Add Type from Class:"));
+ edit_dialog_side_vb->add_child(edit_add_class_label);
+
+ HBoxContainer *edit_add_class = memnew(HBoxContainer);
+ edit_dialog_side_vb->add_child(edit_add_class);
+ edit_add_class_options = memnew(OptionButton);
+ edit_add_class_options->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ edit_add_class->add_child(edit_add_class_options);
+ Button *edit_add_class_button = memnew(Button);
+ edit_add_class_button->set_text(TTR("Add"));
+ edit_add_class->add_child(edit_add_class_button);
+ edit_add_class_button->connect("pressed", callable_mp(this, &ThemeItemEditorDialog::_add_class_type_items));
+
+ Label *edit_add_custom_label = memnew(Label);
+ edit_add_custom_label->set_text(TTR("Add Custom Type:"));
+ edit_dialog_side_vb->add_child(edit_add_custom_label);
+
+ HBoxContainer *edit_add_custom = memnew(HBoxContainer);
+ edit_dialog_side_vb->add_child(edit_add_custom);
+ edit_add_custom_value = memnew(LineEdit);
+ edit_add_custom_value->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ edit_add_custom->add_child(edit_add_custom_value);
+ Button *edit_add_custom_button = memnew(Button);
+ edit_add_custom_button->set_text(TTR("Add"));
+ edit_add_custom->add_child(edit_add_custom_button);
+ edit_add_custom_button->connect("pressed", callable_mp(this, &ThemeItemEditorDialog::_add_custom_type));
+
+ VBoxContainer *edit_items_vb = memnew(VBoxContainer);
+ edit_items_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ edit_dialog_hs->add_child(edit_items_vb);
+
+ HBoxContainer *edit_items_toolbar = memnew(HBoxContainer);
+ edit_items_vb->add_child(edit_items_toolbar);
+
+ Label *edit_items_toolbar_add_label = memnew(Label);
+ edit_items_toolbar_add_label->set_text(TTR("Add:"));
+ edit_items_toolbar->add_child(edit_items_toolbar_add_label);
+
+ edit_items_add_color = memnew(Button);
+ edit_items_add_color->set_tooltip(TTR("Add Color Item"));
+ edit_items_add_color->set_flat(true);
+ edit_items_add_color->set_disabled(true);
+ edit_items_toolbar->add_child(edit_items_add_color);
+ edit_items_add_color->connect("pressed", callable_mp(this, &ThemeItemEditorDialog::_open_add_theme_item_dialog), varray(Theme::DATA_TYPE_COLOR));
+
+ edit_items_add_constant = memnew(Button);
+ edit_items_add_constant->set_tooltip(TTR("Add Constant Item"));
+ edit_items_add_constant->set_flat(true);
+ edit_items_add_constant->set_disabled(true);
+ edit_items_toolbar->add_child(edit_items_add_constant);
+ edit_items_add_constant->connect("pressed", callable_mp(this, &ThemeItemEditorDialog::_open_add_theme_item_dialog), varray(Theme::DATA_TYPE_CONSTANT));
+
+ edit_items_add_font = memnew(Button);
+ edit_items_add_font->set_tooltip(TTR("Add Font Item"));
+ edit_items_add_font->set_flat(true);
+ edit_items_add_font->set_disabled(true);
+ edit_items_toolbar->add_child(edit_items_add_font);
+ edit_items_add_font->connect("pressed", callable_mp(this, &ThemeItemEditorDialog::_open_add_theme_item_dialog), varray(Theme::DATA_TYPE_FONT));
+
+ edit_items_add_font_size = memnew(Button);
+ edit_items_add_font_size->set_tooltip(TTR("Add Font Size Item"));
+ edit_items_add_font_size->set_flat(true);
+ edit_items_add_font_size->set_disabled(true);
+ edit_items_toolbar->add_child(edit_items_add_font_size);
+ edit_items_add_font_size->connect("pressed", callable_mp(this, &ThemeItemEditorDialog::_open_add_theme_item_dialog), varray(Theme::DATA_TYPE_FONT_SIZE));
+
+ edit_items_add_icon = memnew(Button);
+ edit_items_add_icon->set_tooltip(TTR("Add Icon Item"));
+ edit_items_add_icon->set_flat(true);
+ edit_items_add_icon->set_disabled(true);
+ edit_items_toolbar->add_child(edit_items_add_icon);
+ edit_items_add_icon->connect("pressed", callable_mp(this, &ThemeItemEditorDialog::_open_add_theme_item_dialog), varray(Theme::DATA_TYPE_ICON));
+
+ edit_items_add_stylebox = memnew(Button);
+ edit_items_add_stylebox->set_tooltip(TTR("Add StyleBox Item"));
+ edit_items_add_stylebox->set_flat(true);
+ edit_items_add_stylebox->set_disabled(true);
+ edit_items_toolbar->add_child(edit_items_add_stylebox);
+ edit_items_add_stylebox->connect("pressed", callable_mp(this, &ThemeItemEditorDialog::_open_add_theme_item_dialog), varray(Theme::DATA_TYPE_STYLEBOX));
+
+ edit_items_toolbar->add_child(memnew(VSeparator));
+
+ Label *edit_items_toolbar_remove_label = memnew(Label);
+ edit_items_toolbar_remove_label->set_text(TTR("Remove:"));
+ edit_items_toolbar->add_child(edit_items_toolbar_remove_label);
+
+ edit_items_remove_class = memnew(Button);
+ edit_items_remove_class->set_tooltip(TTR("Remove Class Items"));
+ edit_items_remove_class->set_flat(true);
+ edit_items_remove_class->set_disabled(true);
+ edit_items_toolbar->add_child(edit_items_remove_class);
+ edit_items_remove_class->connect("pressed", callable_mp(this, &ThemeItemEditorDialog::_remove_class_items));
+
+ edit_items_remove_custom = memnew(Button);
+ edit_items_remove_custom->set_tooltip(TTR("Remove Custom Items"));
+ edit_items_remove_custom->set_flat(true);
+ edit_items_remove_custom->set_disabled(true);
+ edit_items_toolbar->add_child(edit_items_remove_custom);
+ edit_items_remove_custom->connect("pressed", callable_mp(this, &ThemeItemEditorDialog::_remove_custom_items));
+
+ edit_items_remove_all = memnew(Button);
+ edit_items_remove_all->set_tooltip(TTR("Remove All Items"));
+ edit_items_remove_all->set_flat(true);
+ edit_items_remove_all->set_disabled(true);
+ edit_items_toolbar->add_child(edit_items_remove_all);
+ edit_items_remove_all->connect("pressed", callable_mp(this, &ThemeItemEditorDialog::_remove_all_items));
+
+ edit_items_tree = memnew(Tree);
+ edit_items_tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ edit_items_tree->set_hide_root(true);
+ edit_items_tree->set_columns(1);
+ edit_items_vb->add_child(edit_items_tree);
+ edit_items_tree->connect("button_pressed", callable_mp(this, &ThemeItemEditorDialog::_item_tree_button_pressed));
+
+ edit_theme_item_dialog = memnew(ConfirmationDialog);
+ edit_theme_item_dialog->set_title(TTR("Add Theme Item"));
+ add_child(edit_theme_item_dialog);
+ VBoxContainer *edit_theme_item_vb = memnew(VBoxContainer);
+ edit_theme_item_dialog->add_child(edit_theme_item_vb);
+
+ edit_theme_item_old_vb = memnew(VBoxContainer);
+ edit_theme_item_vb->add_child(edit_theme_item_old_vb);
+ Label *edit_theme_item_old = memnew(Label);
+ edit_theme_item_old->set_text(TTR("Old Name:"));
+ edit_theme_item_old_vb->add_child(edit_theme_item_old);
+ theme_item_old_name = memnew(Label);
+ edit_theme_item_old_vb->add_child(theme_item_old_name);
+
+ Label *edit_theme_item_label = memnew(Label);
+ edit_theme_item_label->set_text(TTR("Name:"));
+ edit_theme_item_vb->add_child(edit_theme_item_label);
+ theme_item_name = memnew(LineEdit);
+ edit_theme_item_vb->add_child(theme_item_name);
+ theme_item_name->connect("gui_input", callable_mp(this, &ThemeItemEditorDialog::_edit_theme_item_gui_input));
+ edit_theme_item_dialog->connect("confirmed", callable_mp(this, &ThemeItemEditorDialog::_confirm_edit_theme_item));
+}
+
void ThemeEditor::edit(const Ref<Theme> &p_theme) {
theme = p_theme;
+ theme_edit_dialog->set_edited_theme(p_theme);
main_panel->set_theme(p_theme);
main_container->set_theme(p_theme);
}
@@ -58,55 +742,6 @@ void ThemeEditor::_refresh_interval() {
_propagate_redraw(main_container);
}
-void ThemeEditor::_type_menu_cbk(int p_option) {
- type_edit->set_text(type_menu->get_popup()->get_item_text(p_option));
-}
-
-void ThemeEditor::_name_menu_about_to_show() {
- String fromtype = type_edit->get_text();
- List<StringName> names;
-
- if (popup_mode == POPUP_ADD) {
- switch (type_select->get_selected()) {
- case 0:
- Theme::get_default()->get_icon_list(fromtype, &names);
- break;
- case 1:
- Theme::get_default()->get_stylebox_list(fromtype, &names);
- break;
- case 2:
- Theme::get_default()->get_font_list(fromtype, &names);
- break;
- case 3:
- 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;
- }
- } else if (popup_mode == POPUP_REMOVE) {
- 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);
- }
-
- name_menu->get_popup()->clear();
- name_menu->get_popup()->set_size(Size2());
- for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
- name_menu->get_popup()->add_item(E->get());
- }
-}
-
-void ThemeEditor::_name_menu_cbk(int p_option) {
- name_edit->set_text(name_menu->get_popup()->get_item_text(p_option));
-}
-
struct _TECategory {
template <class T>
struct RefItem {
@@ -335,296 +970,71 @@ void ThemeEditor::_save_template_cbk(String fname) {
memdelete(file);
}
-void ThemeEditor::_dialog_cbk() {
- switch (popup_mode) {
- case POPUP_ADD: {
- switch (type_select->get_selected()) {
- case 0:
- theme->set_icon(name_edit->get_text(), type_edit->get_text(), Ref<Texture2D>());
- break;
- case 1:
- theme->set_stylebox(name_edit->get_text(), type_edit->get_text(), Ref<StyleBox>());
- break;
- case 2:
- theme->set_font(name_edit->get_text(), type_edit->get_text(), Ref<Font>());
- break;
- case 3:
- 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;
- }
-
- } break;
- case POPUP_CLASS_ADD: {
- StringName fromtype = type_edit->get_text();
- List<StringName> names;
-
- {
- names.clear();
- Theme::get_default()->get_icon_list(fromtype, &names);
- for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
- theme->set_icon(E->get(), fromtype, Ref<Texture2D>());
- }
- }
- {
- names.clear();
- Theme::get_default()->get_stylebox_list(fromtype, &names);
- for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
- theme->set_stylebox(E->get(), fromtype, Ref<StyleBox>());
- }
- }
- {
- names.clear();
- Theme::get_default()->get_font_list(fromtype, &names);
- for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
- theme->set_font(E->get(), fromtype, Ref<Font>());
- }
- }
- {
- 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));
- }
- }
- {
- names.clear();
- Theme::get_default()->get_constant_list(fromtype, &names);
- for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
- theme->set_constant(E->get(), fromtype, Theme::get_default()->get_constant(E->get(), fromtype));
- }
- }
- } break;
- case POPUP_REMOVE: {
- switch (type_select->get_selected()) {
- case 0:
- theme->clear_icon(name_edit->get_text(), type_edit->get_text());
- break;
- case 1:
- theme->clear_stylebox(name_edit->get_text(), type_edit->get_text());
- break;
- case 2:
- theme->clear_font(name_edit->get_text(), type_edit->get_text());
- break;
- case 3:
- 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;
- }
-
- } break;
- case POPUP_CLASS_REMOVE: {
- StringName fromtype = type_edit->get_text();
- List<StringName> names;
-
- {
- names.clear();
- Theme::get_default()->get_icon_list(fromtype, &names);
- for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
- theme->clear_icon(E->get(), fromtype);
- }
- }
- {
- names.clear();
- Theme::get_default()->get_stylebox_list(fromtype, &names);
- for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
- theme->clear_stylebox(E->get(), fromtype);
- }
- }
- {
- names.clear();
- Theme::get_default()->get_font_list(fromtype, &names);
- for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
- theme->clear_font(E->get(), fromtype);
- }
- }
- {
- 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);
- }
- }
- {
- names.clear();
- Theme::get_default()->get_constant_list(fromtype, &names);
- for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
- theme->clear_constant(E->get(), fromtype);
- }
- }
-
- } break;
- }
-}
-
-void ThemeEditor::_theme_menu_cbk(int p_option) {
- if (p_option == POPUP_CREATE_EMPTY || p_option == POPUP_CREATE_EDITOR_EMPTY || p_option == POPUP_IMPORT_EDITOR_THEME) {
- bool import = (p_option == POPUP_IMPORT_EDITOR_THEME);
-
- Ref<Theme> base_theme;
-
- if (p_option == POPUP_CREATE_EMPTY) {
- base_theme = Theme::get_default();
- } else {
- base_theme = EditorNode::get_singleton()->get_theme_base()->get_theme();
- }
-
- {
- List<StringName> types;
- base_theme->get_type_list(&types);
-
- for (List<StringName>::Element *T = types.front(); T; T = T->next()) {
- StringName type = T->get();
-
- List<StringName> icons;
- base_theme->get_icon_list(type, &icons);
-
- for (List<StringName>::Element *E = icons.front(); E; E = E->next()) {
- theme->set_icon(E->get(), type, import ? base_theme->get_icon(E->get(), type) : Ref<Texture2D>());
- }
-
- List<StringName> styleboxs;
- base_theme->get_stylebox_list(type, &styleboxs);
-
- for (List<StringName>::Element *E = styleboxs.front(); E; E = E->next()) {
- theme->set_stylebox(E->get(), type, import ? base_theme->get_stylebox(E->get(), type) : Ref<StyleBox>());
- }
-
- List<StringName> fonts;
- base_theme->get_font_list(type, &fonts);
-
- for (List<StringName>::Element *E = fonts.front(); E; E = E->next()) {
- 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);
-
- for (List<StringName>::Element *E = colors.front(); E; E = E->next()) {
- theme->set_color(E->get(), type, import ? base_theme->get_color(E->get(), type) : Color());
- }
-
- List<StringName> constants;
- base_theme->get_constant_list(type, &constants);
-
- for (List<StringName>::Element *E = constants.front(); E; E = E->next()) {
- theme->set_constant(E->get(), type, base_theme->get_constant(E->get(), type));
- }
- }
- }
- return;
- }
+void ThemeEditor::_theme_create_menu_cbk(int p_option) {
+ bool import = (p_option == POPUP_IMPORT_EDITOR_THEME);
Ref<Theme> base_theme;
- name_select_label->show();
- name_hbc->show();
- type_select_label->show();
- type_select->show();
-
- if (p_option == POPUP_ADD) { // Add.
-
- add_del_dialog->set_title(TTR("Add Item"));
- add_del_dialog->get_ok_button()->set_text(TTR("Add"));
- add_del_dialog->popup_centered(Size2(490, 85) * EDSCALE);
-
+ if (p_option == POPUP_CREATE_EMPTY) {
base_theme = Theme::get_default();
+ } else {
+ base_theme = EditorNode::get_singleton()->get_theme_base()->get_theme();
+ }
- } else if (p_option == POPUP_CLASS_ADD) { // Add.
-
- add_del_dialog->set_title(TTR("Add All Items"));
- add_del_dialog->get_ok_button()->set_text(TTR("Add All"));
- add_del_dialog->popup_centered(Size2(240, 85) * EDSCALE);
-
- base_theme = Theme::get_default();
+ {
+ List<StringName> types;
+ base_theme->get_type_list(&types);
- name_select_label->hide();
- name_hbc->hide();
- type_select_label->hide();
- type_select->hide();
+ for (List<StringName>::Element *T = types.front(); T; T = T->next()) {
+ StringName type = T->get();
- } else if (p_option == POPUP_REMOVE) {
- add_del_dialog->set_title(TTR("Remove Item"));
- add_del_dialog->get_ok_button()->set_text(TTR("Remove"));
- add_del_dialog->popup_centered(Size2(490, 85) * EDSCALE);
+ List<StringName> icons;
+ base_theme->get_icon_list(type, &icons);
- base_theme = theme;
+ for (List<StringName>::Element *E = icons.front(); E; E = E->next()) {
+ theme->set_icon(E->get(), type, import ? base_theme->get_icon(E->get(), type) : Ref<Texture2D>());
+ }
- } else if (p_option == POPUP_CLASS_REMOVE) {
- add_del_dialog->set_title(TTR("Remove All Items"));
- add_del_dialog->get_ok_button()->set_text(TTR("Remove All"));
- add_del_dialog->popup_centered(Size2(240, 85) * EDSCALE);
+ List<StringName> styleboxs;
+ base_theme->get_stylebox_list(type, &styleboxs);
- base_theme = Theme::get_default();
+ for (List<StringName>::Element *E = styleboxs.front(); E; E = E->next()) {
+ theme->set_stylebox(E->get(), type, import ? base_theme->get_stylebox(E->get(), type) : Ref<StyleBox>());
+ }
- name_select_label->hide();
- name_hbc->hide();
- type_select_label->hide();
- type_select->hide();
- }
- popup_mode = p_option;
+ List<StringName> fonts;
+ base_theme->get_font_list(type, &fonts);
- ERR_FAIL_COND(theme.is_null());
+ for (List<StringName>::Element *E = fonts.front(); E; E = E->next()) {
+ theme->set_font(E->get(), type, Ref<Font>());
+ }
- List<StringName> types;
- base_theme->get_type_list(&types);
+ List<StringName> font_sizes;
+ base_theme->get_font_size_list(type, &font_sizes);
- type_menu->get_popup()->clear();
+ 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));
+ }
- if (p_option == 0 || p_option == 1) { // Add.
+ List<StringName> colors;
+ base_theme->get_color_list(type, &colors);
- List<StringName> new_types;
- theme->get_type_list(&new_types);
- for (List<StringName>::Element *F = new_types.front(); F; F = F->next()) {
- bool found = false;
- for (List<StringName>::Element *E = types.front(); E; E = E->next()) {
- if (E->get() == F->get()) {
- found = true;
- break;
- }
+ for (List<StringName>::Element *E = colors.front(); E; E = E->next()) {
+ theme->set_color(E->get(), type, import ? base_theme->get_color(E->get(), type) : Color());
}
- if (!found) {
- types.push_back(F->get());
+ List<StringName> constants;
+ base_theme->get_constant_list(type, &constants);
+
+ for (List<StringName>::Element *E = constants.front(); E; E = E->next()) {
+ theme->set_constant(E->get(), type, base_theme->get_constant(E->get(), type));
}
}
}
+}
- types.sort_custom<StringName::AlphCompare>();
- for (List<StringName>::Element *E = types.front(); E; E = E->next()) {
- type_menu->get_popup()->add_item(E->get());
- }
+void ThemeEditor::_theme_edit_button_cbk() {
+ theme_edit_dialog->popup_centered(Size2(800, 640) * EDSCALE);
}
void ThemeEditor::_notification(int p_what) {
@@ -636,9 +1046,6 @@ void ThemeEditor::_notification(int p_what) {
_refresh_interval();
}
} break;
- case NOTIFICATION_THEME_CHANGED: {
- theme_menu->set_icon(get_theme_icon("Theme", "EditorIcons"));
- } break;
}
}
@@ -646,27 +1053,28 @@ void ThemeEditor::_bind_methods() {
}
ThemeEditor::ThemeEditor() {
- time_left = 0;
-
HBoxContainer *top_menu = memnew(HBoxContainer);
add_child(top_menu);
top_menu->add_child(memnew(Label(TTR("Preview:"))));
top_menu->add_spacer(false);
- theme_menu = memnew(MenuButton);
- theme_menu->set_text(TTR("Edit Theme"));
- theme_menu->set_tooltip(TTR("Theme editing menu."));
- theme_menu->get_popup()->add_item(TTR("Add Item"), POPUP_ADD);
- theme_menu->get_popup()->add_item(TTR("Add Class Items"), POPUP_CLASS_ADD);
- theme_menu->get_popup()->add_item(TTR("Remove Item"), POPUP_REMOVE);
- theme_menu->get_popup()->add_item(TTR("Remove Class Items"), POPUP_CLASS_REMOVE);
- theme_menu->get_popup()->add_separator();
- theme_menu->get_popup()->add_item(TTR("Create Empty Template"), POPUP_CREATE_EMPTY);
- theme_menu->get_popup()->add_item(TTR("Create Empty Editor Template"), POPUP_CREATE_EDITOR_EMPTY);
- theme_menu->get_popup()->add_item(TTR("Create From Current Editor Theme"), POPUP_IMPORT_EDITOR_THEME);
- top_menu->add_child(theme_menu);
- theme_menu->get_popup()->connect("id_pressed", callable_mp(this, &ThemeEditor::_theme_menu_cbk));
+ theme_create_menu = memnew(MenuButton);
+ theme_create_menu->set_text(TTR("Create Theme..."));
+ theme_create_menu->set_tooltip(TTR("Create a new Theme."));
+ theme_create_menu->get_popup()->add_item(TTR("Empty Template"), POPUP_CREATE_EMPTY);
+ theme_create_menu->get_popup()->add_separator();
+ theme_create_menu->get_popup()->add_item(TTR("Empty Editor Template"), POPUP_CREATE_EDITOR_EMPTY);
+ theme_create_menu->get_popup()->add_item(TTR("From Current Editor Theme"), POPUP_IMPORT_EDITOR_THEME);
+ top_menu->add_child(theme_create_menu);
+ theme_create_menu->get_popup()->connect("id_pressed", callable_mp(this, &ThemeEditor::_theme_create_menu_cbk));
+
+ theme_edit_button = memnew(Button);
+ theme_edit_button->set_text(TTR("Edit Theme Items"));
+ theme_edit_button->set_tooltip(TTR("Customize Theme items."));
+ theme_edit_button->set_flat(true);
+ theme_edit_button->connect("pressed", callable_mp(this, &ThemeEditor::_theme_edit_button_cbk));
+ top_menu->add_child(theme_edit_button);
ScrollContainer *scroll = memnew(ScrollContainer);
add_child(scroll);
@@ -849,66 +1257,9 @@ ThemeEditor::ThemeEditor() {
main_hb->add_theme_constant_override("separation", 20 * EDSCALE);
- ////////
-
- add_del_dialog = memnew(ConfirmationDialog);
- add_del_dialog->hide();
- add_child(add_del_dialog);
-
- VBoxContainer *dialog_vbc = memnew(VBoxContainer);
- add_del_dialog->add_child(dialog_vbc);
-
- Label *l = memnew(Label);
- l->set_text(TTR("Type:"));
- dialog_vbc->add_child(l);
-
- type_hbc = memnew(HBoxContainer);
- dialog_vbc->add_child(type_hbc);
-
- type_edit = memnew(LineEdit);
- type_edit->set_h_size_flags(SIZE_EXPAND_FILL);
- type_hbc->add_child(type_edit);
- type_menu = memnew(MenuButton);
- type_menu->set_flat(false);
- type_menu->set_text("...");
- type_hbc->add_child(type_menu);
-
- type_menu->get_popup()->connect("id_pressed", callable_mp(this, &ThemeEditor::_type_menu_cbk));
-
- l = memnew(Label);
- l->set_text(TTR("Name:"));
- dialog_vbc->add_child(l);
- name_select_label = l;
-
- name_hbc = memnew(HBoxContainer);
- dialog_vbc->add_child(name_hbc);
-
- name_edit = memnew(LineEdit);
- name_edit->set_h_size_flags(SIZE_EXPAND_FILL);
- name_hbc->add_child(name_edit);
- name_menu = memnew(MenuButton);
- type_menu->set_flat(false);
- name_menu->set_text("...");
- name_hbc->add_child(name_menu);
-
- name_menu->get_popup()->connect("about_to_popup", callable_mp(this, &ThemeEditor::_name_menu_about_to_show));
- name_menu->get_popup()->connect("id_pressed", callable_mp(this, &ThemeEditor::_name_menu_cbk));
-
- type_select_label = memnew(Label);
- type_select_label->set_text(TTR("Data Type:"));
- dialog_vbc->add_child(type_select_label);
-
- type_select = memnew(OptionButton);
- 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"));
-
- dialog_vbc->add_child(type_select);
-
- add_del_dialog->get_ok_button()->connect("pressed", callable_mp(this, &ThemeEditor::_dialog_cbk));
+ theme_edit_dialog = memnew(ThemeItemEditorDialog);
+ theme_edit_dialog->hide();
+ add_child(theme_edit_dialog);
file_dialog = memnew(EditorFileDialog);
file_dialog->add_filter("*.theme ; " + TTR("Theme File"));
diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h
index ab199f8e51..0a840aecd7 100644
--- a/editor/plugins/theme_editor_plugin.h
+++ b/editor/plugins/theme_editor_plugin.h
@@ -41,6 +41,77 @@
#include "editor/editor_node.h"
+class ThemeItemEditorDialog : public AcceptDialog {
+ GDCLASS(ThemeItemEditorDialog, AcceptDialog);
+
+ Ref<Theme> edited_theme;
+
+ ItemList *edit_type_list;
+ OptionButton *edit_add_class_options;
+ LineEdit *edit_add_custom_value;
+ String edited_item_type;
+
+ Button *edit_items_add_color;
+ Button *edit_items_add_constant;
+ Button *edit_items_add_font;
+ Button *edit_items_add_font_size;
+ Button *edit_items_add_icon;
+ Button *edit_items_add_stylebox;
+ Button *edit_items_remove_class;
+ Button *edit_items_remove_custom;
+ Button *edit_items_remove_all;
+ Tree *edit_items_tree;
+
+ enum ItemsTreeAction {
+ ITEMS_TREE_RENAME_ITEM,
+ ITEMS_TREE_REMOVE_ITEM,
+ ITEMS_TREE_REMOVE_DATA_TYPE,
+ };
+
+ ConfirmationDialog *edit_theme_item_dialog;
+ VBoxContainer *edit_theme_item_old_vb;
+ Label *theme_item_old_name;
+ LineEdit *theme_item_name;
+
+ enum ItemPopupMode {
+ CREATE_THEME_ITEM,
+ RENAME_THEME_ITEM,
+ ITEM_POPUP_MODE_MAX
+ };
+
+ ItemPopupMode item_popup_mode = ITEM_POPUP_MODE_MAX;
+ String edit_item_old_name;
+ Theme::DataType edit_item_data_type = Theme::DATA_TYPE_MAX;
+
+ void _dialog_about_to_show();
+ void _update_edit_types();
+ void _edited_type_selected(int p_item_idx);
+
+ void _update_edit_item_tree(String p_item_type);
+ void _item_tree_button_pressed(Object *p_item, int p_column, int p_id);
+
+ void _add_class_type_items();
+ void _add_custom_type();
+ void _add_theme_item(Theme::DataType p_data_type, String p_item_name, String p_item_type);
+ void _remove_data_type_items(Theme::DataType p_data_type, String p_item_type);
+ void _remove_class_items();
+ void _remove_custom_items();
+ void _remove_all_items();
+
+ void _open_add_theme_item_dialog(int p_data_type);
+ void _open_rename_theme_item_dialog(Theme::DataType p_data_type, String p_item_name);
+ void _confirm_edit_theme_item();
+ void _edit_theme_item_gui_input(const Ref<InputEvent> &p_event);
+
+protected:
+ void _notification(int p_what);
+
+public:
+ void set_edited_theme(const Ref<Theme> &p_theme);
+
+ ThemeItemEditorDialog();
+};
+
class ThemeEditor : public VBoxContainer {
GDCLASS(ThemeEditor, VBoxContainer);
@@ -50,40 +121,23 @@ class ThemeEditor : public VBoxContainer {
EditorFileDialog *file_dialog;
- double time_left;
-
- MenuButton *theme_menu;
- ConfirmationDialog *add_del_dialog;
- HBoxContainer *type_hbc;
- MenuButton *type_menu;
- LineEdit *type_edit;
- HBoxContainer *name_hbc;
- MenuButton *name_menu;
- LineEdit *name_edit;
- OptionButton *type_select;
- Label *type_select_label;
- Label *name_select_label;
-
- enum PopupMode {
- POPUP_ADD,
- POPUP_CLASS_ADD,
- POPUP_REMOVE,
- POPUP_CLASS_REMOVE,
+ double time_left = 0;
+
+ Button *theme_edit_button;
+ MenuButton *theme_create_menu;
+ ThemeItemEditorDialog *theme_edit_dialog;
+
+ enum CreatePopupMode {
POPUP_CREATE_EMPTY,
POPUP_CREATE_EDITOR_EMPTY,
- POPUP_IMPORT_EDITOR_THEME
+ POPUP_IMPORT_EDITOR_THEME,
};
- int popup_mode;
-
Tree *test_tree;
void _save_template_cbk(String fname);
- void _dialog_cbk();
- void _type_menu_cbk(int p_option);
- void _name_menu_about_to_show();
- void _name_menu_cbk(int p_option);
- void _theme_menu_cbk(int p_option);
+ void _theme_edit_button_cbk();
+ void _theme_create_menu_cbk(int p_option);
void _propagate_redraw(Control *p_at);
void _refresh_interval();
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index 74b01b3c36..bd721244ea 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -233,11 +233,11 @@ void TileMapEditor::_palette_input(const Ref<InputEvent> &p_event) {
// Zoom in/out using Ctrl + mouse wheel.
if (mb.is_valid() && mb->is_pressed() && mb->get_command()) {
- if (mb->is_pressed() && mb->get_button_index() == BUTTON_WHEEL_UP) {
+ if (mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP) {
size_slider->set_value(size_slider->get_value() + 0.2);
}
- if (mb->is_pressed() && mb->get_button_index() == BUTTON_WHEEL_DOWN) {
+ if (mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN) {
size_slider->set_value(size_slider->get_value() - 0.2);
}
}
@@ -966,9 +966,9 @@ void TileMapEditor::_update_copydata() {
tcd.flip_v = node->is_cell_y_flipped(j, i);
tcd.transpose = node->is_cell_transposed(j, i);
tcd.autotile_coord = node->get_cell_autotile_coord(j, i);
- }
- copydata.push_back(tcd);
+ copydata.push_back(tcd);
+ }
}
}
}
@@ -1027,7 +1027,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
- if (mb->get_button_index() == BUTTON_LEFT) {
+ if (mb->get_button_index() == MOUSE_BUTTON_LEFT) {
if (mb->is_pressed()) {
if (Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
return false; // Drag.
@@ -1177,7 +1177,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
return true;
}
}
- } else if (mb->get_button_index() == BUTTON_RIGHT) {
+ } else if (mb->get_button_index() == MOUSE_BUTTON_RIGHT) {
if (mb->is_pressed()) {
if (tool == TOOL_SELECTING || selection_active) {
tool = TOOL_NONE;
@@ -1462,7 +1462,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
return true;
}
- if (tool == TOOL_PICKING && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
+ if (tool == TOOL_PICKING && Input::get_singleton()->is_mouse_button_pressed(MOUSE_BUTTON_LEFT)) {
_pick_tile(over_tile);
return true;
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index c628fe8367..feaf609557 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -80,7 +80,7 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
Vector2 phys_offset;
Size2 s;
- if (mi->is_region()) {
+ if (mi->is_region_enabled()) {
s = mi->get_region_rect().size;
p_library->tile_set_region(id, mi->get_region_rect());
} else {
@@ -1246,12 +1246,12 @@ void TileSetEditor::_on_scroll_container_input(const Ref<InputEvent> &p_event) {
// Zoom in/out using Ctrl + mouse wheel. This is done on the ScrollContainer
// to allow performing this action anywhere, even if the cursor isn't
// hovering the texture in the workspace.
- if (mb->get_button_index() == BUTTON_WHEEL_UP && mb->is_pressed() && mb->get_control()) {
+ if (mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP && mb->is_pressed() && mb->get_control()) {
print_line("zooming in");
_zoom_in();
// Don't scroll up after zooming in.
accept_event();
- } else if (mb->get_button_index() == BUTTON_WHEEL_DOWN && mb->is_pressed() && mb->get_control()) {
+ } else if (mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN && mb->is_pressed() && mb->get_control()) {
print_line("zooming out");
_zoom_out();
// Don't scroll down after zooming out.
@@ -1280,7 +1280,7 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
const Ref<InputEventMouseMotion> mm = p_ie;
if (mb.is_valid()) {
- if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && !creating_shape) {
+ if (mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT && !creating_shape) {
if (!current_tile_region.has_point(mb->get_position())) {
List<int> *tiles = new List<int>();
tileset->get_tile_list(tiles);
@@ -1304,7 +1304,7 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
}
// Drag Middle Mouse
if (mm.is_valid()) {
- if (mm->get_button_mask() & BUTTON_MASK_MIDDLE) {
+ if (mm->get_button_mask() & MOUSE_BUTTON_MASK_MIDDLE) {
Vector2 dragged(mm->get_relative().x, mm->get_relative().y);
scroll->set_h_scroll(scroll->get_h_scroll() - dragged.x * workspace->get_scale().x);
scroll->set_v_scroll(scroll->get_v_scroll() - dragged.y * workspace->get_scale().x);
@@ -1313,7 +1313,7 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
if (edit_mode == EDITMODE_REGION) {
if (mb.is_valid()) {
- if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+ if (mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
if (get_current_tile() >= 0 || workspace_mode != WORKSPACE_EDIT) {
dragging = true;
region_from = mb->get_position();
@@ -1322,13 +1322,13 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
workspace_overlay->update();
return;
}
- } else if (dragging && mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) {
+ } else if (dragging && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_RIGHT) {
dragging = false;
edited_region = Rect2();
workspace->update();
workspace_overlay->update();
return;
- } else if (dragging && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+ } else if (dragging && !mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
dragging = false;
update_edited_region(mb->get_position());
edited_region.position -= WORKSPACE_MARGIN;
@@ -1428,7 +1428,7 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
switch (edit_mode) {
case EDITMODE_ICON: {
if (mb.is_valid()) {
- if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && current_tile_region.has_point(mb->get_position())) {
+ if (mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT && current_tile_region.has_point(mb->get_position())) {
Vector2 coord((int)((mb->get_position().x - current_tile_region.position.x) / (spacing + size.x)), (int)((mb->get_position().y - current_tile_region.position.y) / (spacing + size.y)));
undo_redo->create_action(TTR("Set Tile Icon"));
undo_redo->add_do_method(tileset.ptr(), "autotile_set_icon_coordinate", get_current_tile(), coord);
@@ -1445,9 +1445,9 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
if (dragging) {
return;
}
- if ((mb->get_button_index() == BUTTON_RIGHT || mb->get_button_index() == BUTTON_LEFT) && current_tile_region.has_point(mb->get_position())) {
+ if ((mb->get_button_index() == MOUSE_BUTTON_RIGHT || mb->get_button_index() == MOUSE_BUTTON_LEFT) && current_tile_region.has_point(mb->get_position())) {
dragging = true;
- erasing = (mb->get_button_index() == BUTTON_RIGHT);
+ erasing = (mb->get_button_index() == MOUSE_BUTTON_RIGHT);
alternative = Input::get_singleton()->is_key_pressed(KEY_SHIFT);
Vector2 coord((int)((mb->get_position().x - current_tile_region.position.x) / (spacing + size.x)), (int)((mb->get_position().y - current_tile_region.position.y) / (spacing + size.y)));
Vector2 pos(coord.x * (spacing + size.x), coord.y * (spacing + size.y));
@@ -1518,7 +1518,7 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
}
}
} else {
- if ((erasing && mb->get_button_index() == BUTTON_RIGHT) || (!erasing && mb->get_button_index() == BUTTON_LEFT)) {
+ if ((erasing && mb->get_button_index() == MOUSE_BUTTON_RIGHT) || (!erasing && mb->get_button_index() == MOUSE_BUTTON_LEFT)) {
dragging = false;
erasing = false;
alternative = false;
@@ -1612,7 +1612,7 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
shape_anchor += current_tile_region.position;
if (tools[TOOL_SELECT]->is_pressed()) {
if (mb.is_valid()) {
- if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+ if (mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
if (edit_mode != EDITMODE_PRIORITY && current_shape.size() > 0) {
int grabbed_point = get_grabbed_point(mb->get_position(), grab_threshold);
@@ -1630,7 +1630,7 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
}
}
workspace->update();
- } else if (!mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+ } else if (!mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
if (edit_mode == EDITMODE_COLLISION) {
if (dragging_point >= 0) {
dragging_point = -1;
@@ -1705,7 +1705,7 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
}
} else if (tools[SHAPE_NEW_POLYGON]->is_pressed()) {
if (mb.is_valid()) {
- if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+ if (mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
Vector2 pos = mb->get_position();
pos = snap_point(pos);
if (creating_shape) {
@@ -1725,7 +1725,7 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
current_shape.push_back(snap_point(pos));
workspace->update();
}
- } else if (mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) {
+ } else if (mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_RIGHT) {
if (creating_shape) {
creating_shape = false;
_select_edited_shape_coord();
@@ -1739,7 +1739,7 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
}
} else if (tools[SHAPE_NEW_RECTANGLE]->is_pressed()) {
if (mb.is_valid()) {
- if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+ if (mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
_set_edited_collision_shape(Ref<ConvexPolygonShape2D>());
current_shape.resize(0);
Vector2 pos = mb->get_position();
@@ -1751,13 +1751,13 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
creating_shape = true;
workspace->update();
return;
- } else if (mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) {
+ } else if (mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_RIGHT) {
if (creating_shape) {
creating_shape = false;
_select_edited_shape_coord();
workspace->update();
}
- } else if (!mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+ } else if (!mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
if (creating_shape) {
// if the first two corners are within grabbing distance of one another, expand the rect to fill the tile
if (is_within_grabbing_distance_of_first_point(current_shape[1], grab_threshold)) {
@@ -2928,7 +2928,7 @@ void TileSetEditor::close_shape(const Vector2 &shape_anchor) {
}
if (p_total < 0) {
- points.invert();
+ points.reverse();
}
shape->set_points(points);
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index a63e641c2b..dea85e8799 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -384,6 +384,20 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
port_offset += 2;
}
+ if (is_resizable) {
+ Ref<VisualShaderNodeComment> comment_node = Object::cast_to<VisualShaderNodeComment>(vsnode.ptr());
+ if (comment_node.is_valid()) {
+ node->set_comment(true);
+
+ Label *comment_label = memnew(Label);
+ node->add_child(comment_label);
+ comment_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ comment_label->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ comment_label->set_mouse_filter(Control::MouseFilter::MOUSE_FILTER_STOP);
+ comment_label->set_text(comment_node->get_description());
+ }
+ }
+
Ref<VisualShaderNodeUniform> uniform = vsnode;
if (uniform.is_valid()) {
VisualShaderEditor::get_singleton()->graph->add_child(node);
@@ -1119,16 +1133,24 @@ void VisualShaderEditor::_update_options_menu() {
}
void VisualShaderEditor::_set_mode(int p_which) {
- if (p_which == VisualShader::MODE_PARTICLES) {
+ if (p_which == VisualShader::MODE_SKY) {
+ edit_type_standart->set_visible(false);
+ edit_type_particles->set_visible(false);
+ edit_type_sky->set_visible(true);
+ edit_type = edit_type_sky;
+ mode = MODE_FLAGS_SKY;
+ } else if (p_which == VisualShader::MODE_PARTICLES) {
edit_type_standart->set_visible(false);
edit_type_particles->set_visible(true);
+ edit_type_sky->set_visible(false);
edit_type = edit_type_particles;
- particles_mode = true;
+ mode = MODE_FLAGS_PARTICLES;
} else {
edit_type_particles->set_visible(false);
edit_type_standart->set_visible(true);
+ edit_type_sky->set_visible(false);
edit_type = edit_type_standart;
- particles_mode = false;
+ mode = MODE_FLAGS_SPATIAL_CANVASITEM;
}
visual_shader->set_shader_type(get_current_shader_type());
}
@@ -1289,8 +1311,10 @@ void VisualShaderEditor::_update_graph() {
VisualShader::Type VisualShaderEditor::get_current_shader_type() const {
VisualShader::Type type;
- if (particles_mode) {
+ if (mode & MODE_FLAGS_PARTICLES) {
type = VisualShader::Type(edit_type->get_selected() + 3);
+ } else if (mode & MODE_FLAGS_SKY) {
+ type = VisualShader::Type(edit_type->get_selected() + 6);
} else {
type = VisualShader::Type(edit_type->get_selected());
}
@@ -1624,6 +1648,92 @@ void VisualShaderEditor::_preview_select_port(int p_node, int p_port) {
undo_redo->commit_action();
}
+void VisualShaderEditor::_comment_title_popup_show(const Point2 &p_position, int p_node_id) {
+ VisualShader::Type type = get_current_shader_type();
+ Ref<VisualShaderNodeComment> node = visual_shader->get_node(type, p_node_id);
+ if (node.is_null()) {
+ return;
+ }
+ comment_title_change_edit->set_text(node->get_title());
+ comment_title_change_popup->set_meta("id", p_node_id);
+ comment_title_change_popup->popup();
+ comment_title_change_popup->set_position(p_position);
+}
+
+void VisualShaderEditor::_comment_title_text_changed(const String &p_new_text) {
+ comment_title_change_edit->set_size(Size2(-1, -1));
+ comment_title_change_popup->set_size(Size2(-1, -1));
+}
+
+void VisualShaderEditor::_comment_title_text_entered(const String &p_new_text) {
+ comment_title_change_popup->hide();
+}
+
+void VisualShaderEditor::_comment_title_popup_focus_out() {
+ comment_title_change_popup->hide();
+}
+
+void VisualShaderEditor::_comment_title_popup_hide() {
+ ERR_FAIL_COND(!comment_title_change_popup->has_meta("id"));
+ int node_id = (int)comment_title_change_popup->get_meta("id");
+
+ VisualShader::Type type = get_current_shader_type();
+ Ref<VisualShaderNodeComment> node = visual_shader->get_node(type, node_id);
+
+ ERR_FAIL_COND(node.is_null());
+
+ if (node->get_title() == comment_title_change_edit->get_text()) {
+ return; // nothing changed - ignored
+ }
+ undo_redo->create_action(TTR("Set Comment Node Title"));
+ undo_redo->add_do_method(node.ptr(), "set_title", comment_title_change_edit->get_text());
+ undo_redo->add_undo_method(node.ptr(), "set_title", node->get_title());
+ undo_redo->add_do_method(graph_plugin.ptr(), "update_node", (int)type, node_id);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", (int)type, node_id);
+ undo_redo->commit_action();
+}
+
+void VisualShaderEditor::_comment_desc_popup_show(const Point2 &p_position, int p_node_id) {
+ VisualShader::Type type = get_current_shader_type();
+ Ref<VisualShaderNodeComment> node = visual_shader->get_node(type, p_node_id);
+ if (node.is_null()) {
+ return;
+ }
+ comment_desc_change_edit->set_text(node->get_description());
+ comment_desc_change_popup->set_meta("id", p_node_id);
+ comment_desc_change_popup->popup();
+ comment_desc_change_popup->set_position(p_position);
+}
+
+void VisualShaderEditor::_comment_desc_text_changed() {
+ comment_desc_change_edit->set_size(Size2(-1, -1));
+ comment_desc_change_popup->set_size(Size2(-1, -1));
+}
+
+void VisualShaderEditor::_comment_desc_confirm() {
+ comment_desc_change_popup->hide();
+}
+
+void VisualShaderEditor::_comment_desc_popup_hide() {
+ ERR_FAIL_COND(!comment_desc_change_popup->has_meta("id"));
+ int node_id = (int)comment_desc_change_popup->get_meta("id");
+
+ VisualShader::Type type = get_current_shader_type();
+ Ref<VisualShaderNodeComment> node = visual_shader->get_node(type, node_id);
+
+ ERR_FAIL_COND(node.is_null());
+
+ if (node->get_description() == comment_desc_change_edit->get_text()) {
+ return; // nothing changed - ignored
+ }
+ undo_redo->create_action(TTR("Set Comment Node Description"));
+ undo_redo->add_do_method(node.ptr(), "set_description", comment_desc_change_edit->get_text());
+ undo_redo->add_undo_method(node.ptr(), "set_description", node->get_title());
+ undo_redo->add_do_method(graph_plugin.ptr(), "update_node", (int)type, node_id);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", (int)type, node_id);
+ undo_redo->commit_action();
+}
+
void VisualShaderEditor::_uniform_line_edit_changed(const String &p_text, int p_node_id) {
VisualShader::Type type = get_current_shader_type();
@@ -2504,9 +2614,10 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
VisualShader::Type type = get_current_shader_type();
- if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) {
+ if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_RIGHT) {
selected_constants.clear();
selected_uniforms.clear();
+ selected_comment = -1;
List<int> to_change;
for (int i = 0; i < graph->get_child_count(); i++) {
@@ -2517,17 +2628,27 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
to_change.push_back(id);
Ref<VisualShaderNode> node = visual_shader->get_node(type, id);
- VisualShaderNodeConstant *cnode = Object::cast_to<VisualShaderNodeConstant>(node.ptr());
- if (cnode != nullptr) {
+
+ VisualShaderNodeComment *comment_node = Object::cast_to<VisualShaderNodeComment>(node.ptr());
+ if (comment_node != nullptr) {
+ selected_comment = id;
+ }
+ VisualShaderNodeConstant *constant_node = Object::cast_to<VisualShaderNodeConstant>(node.ptr());
+ if (constant_node != nullptr) {
selected_constants.insert(id);
}
- VisualShaderNodeUniform *unode = Object::cast_to<VisualShaderNodeUniform>(node.ptr());
- if (unode != nullptr) {
+ VisualShaderNodeUniform *uniform_node = Object::cast_to<VisualShaderNodeUniform>(node.ptr());
+ if (uniform_node != nullptr && uniform_node->is_convertible_to_constant()) {
selected_uniforms.insert(id);
}
}
}
}
+
+ if (to_change.size() > 1) {
+ selected_comment = -1;
+ }
+
if (to_change.is_empty() && copy_nodes_buffer.is_empty()) {
_show_members_dialog(true);
} else {
@@ -2548,16 +2669,34 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
if (temp != -1) {
popup_menu->remove_item(temp);
}
+ temp = popup_menu->get_item_index(NodeMenuOptions::SEPARATOR3);
+ if (temp != -1) {
+ popup_menu->remove_item(temp);
+ }
+ temp = popup_menu->get_item_index(NodeMenuOptions::SET_COMMENT_TITLE);
+ if (temp != -1) {
+ popup_menu->remove_item(temp);
+ }
+ temp = popup_menu->get_item_index(NodeMenuOptions::SET_COMMENT_DESCRIPTION);
+ if (temp != -1) {
+ popup_menu->remove_item(temp);
+ }
- if (selected_constants.size() > 0 || selected_uniforms.size() > 0) {
+ if (selected_comment != -1) {
popup_menu->add_separator("", NodeMenuOptions::SEPARATOR2);
+ popup_menu->add_item(TTR("Set Comment Title"), NodeMenuOptions::SET_COMMENT_TITLE);
+ popup_menu->add_item(TTR("Set Comment Description"), NodeMenuOptions::SET_COMMENT_DESCRIPTION);
+ }
+
+ if (selected_constants.size() > 0 || selected_uniforms.size() > 0) {
+ popup_menu->add_separator("", NodeMenuOptions::SEPARATOR3);
if (selected_constants.size() > 0) {
popup_menu->add_item(TTR("Convert Constant(s) to Uniform(s)"), NodeMenuOptions::CONVERT_CONSTANTS_TO_UNIFORMS);
}
if (selected_uniforms.size() > 0) {
- popup_menu->add_item(TTR("Convert Uniforms(s) to Constant(s)"), NodeMenuOptions::CONVERT_UNIFORMS_TO_CONSTANTS);
+ popup_menu->add_item(TTR("Convert Uniform(s) to Constant(s)"), NodeMenuOptions::CONVERT_UNIFORMS_TO_CONSTANTS);
}
}
@@ -2896,7 +3035,14 @@ void VisualShaderEditor::_paste_nodes(bool p_use_custom_position, const Vector2
}
void VisualShaderEditor::_mode_selected(int p_id) {
- visual_shader->set_shader_type(particles_mode ? VisualShader::Type(p_id + 3) : VisualShader::Type(p_id));
+ int offset = 0;
+ if (mode & MODE_FLAGS_PARTICLES) {
+ offset = 3;
+ } else if (mode & MODE_FLAGS_SKY) {
+ offset = 6;
+ }
+
+ visual_shader->set_shader_type(VisualShader::Type(p_id + offset));
_update_options_menu();
_update_graph();
}
@@ -3111,6 +3257,12 @@ void VisualShaderEditor::_node_menu_id_pressed(int p_idx) {
case NodeMenuOptions::CONVERT_UNIFORMS_TO_CONSTANTS:
_convert_constants_to_uniforms(true);
break;
+ case NodeMenuOptions::SET_COMMENT_TITLE:
+ _comment_title_popup_show(get_global_mouse_position(), selected_comment);
+ break;
+ case NodeMenuOptions::SET_COMMENT_DESCRIPTION:
+ _comment_desc_popup_show(get_global_mouse_position(), selected_comment);
+ break;
default:
break;
}
@@ -3263,7 +3415,7 @@ void VisualShaderEditor::_update_preview() {
ShaderLanguage sl;
- Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_types(), _get_global_variable_type);
+ Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(visual_shader->get_mode())), ShaderLanguage::VaryingFunctionNames(), ShaderTypes::get_singleton()->get_types(), _get_global_variable_type);
for (int i = 0; i < preview_text->get_line_count(); i++) {
preview_text->set_line_as_marked(i, false);
@@ -3396,10 +3548,17 @@ VisualShaderEditor::VisualShaderEditor() {
edit_type_particles->select(0);
edit_type_particles->connect("item_selected", callable_mp(this, &VisualShaderEditor::_mode_selected));
+ edit_type_sky = memnew(OptionButton);
+ edit_type_sky->add_item(TTR("Sky"));
+ edit_type_sky->select(0);
+ edit_type_sky->connect("item_selected", callable_mp(this, &VisualShaderEditor::_mode_selected));
+
edit_type = edit_type_standart;
graph->get_zoom_hbox()->add_child(edit_type_particles);
graph->get_zoom_hbox()->move_child(edit_type_particles, 0);
+ graph->get_zoom_hbox()->add_child(edit_type_sky);
+ graph->get_zoom_hbox()->move_child(edit_type_sky, 0);
graph->get_zoom_hbox()->add_child(edit_type_standart);
graph->get_zoom_hbox()->move_child(edit_type_standart, 0);
@@ -3534,6 +3693,35 @@ VisualShaderEditor::VisualShaderEditor() {
alert->get_label()->set_custom_minimum_size(Size2(400, 60) * EDSCALE);
add_child(alert);
+ comment_title_change_popup = memnew(PopupPanel);
+ comment_title_change_edit = memnew(LineEdit);
+ comment_title_change_edit->set_expand_to_text_length_enabled(true);
+ comment_title_change_edit->connect("text_changed", callable_mp(this, &VisualShaderEditor::_comment_title_text_changed));
+ comment_title_change_edit->connect("text_entered", callable_mp(this, &VisualShaderEditor::_comment_title_text_entered));
+ comment_title_change_popup->add_child(comment_title_change_edit);
+ comment_title_change_edit->set_size(Size2(-1, -1));
+ comment_title_change_popup->set_size(Size2(-1, -1));
+ comment_title_change_popup->connect("focus_exited", callable_mp(this, &VisualShaderEditor::_comment_title_popup_focus_out));
+ comment_title_change_popup->connect("popup_hide", callable_mp(this, &VisualShaderEditor::_comment_title_popup_hide));
+ add_child(comment_title_change_popup);
+
+ comment_desc_change_popup = memnew(PopupPanel);
+ VBoxContainer *comment_desc_vbox = memnew(VBoxContainer);
+ comment_desc_change_popup->add_child(comment_desc_vbox);
+ comment_desc_change_edit = memnew(TextEdit);
+ comment_desc_change_edit->connect("text_changed", callable_mp(this, &VisualShaderEditor::_comment_desc_text_changed));
+ comment_desc_vbox->add_child(comment_desc_change_edit);
+ comment_desc_change_edit->set_custom_minimum_size(Size2(300 * EDSCALE, 150 * EDSCALE));
+ comment_desc_change_edit->set_size(Size2(-1, -1));
+ comment_desc_change_popup->set_size(Size2(-1, -1));
+ comment_desc_change_popup->connect("focus_exited", callable_mp(this, &VisualShaderEditor::_comment_desc_confirm));
+ comment_desc_change_popup->connect("popup_hide", callable_mp(this, &VisualShaderEditor::_comment_desc_popup_hide));
+ Button *comment_desc_confirm_button = memnew(Button);
+ comment_desc_confirm_button->set_text(TTR("OK"));
+ comment_desc_vbox->add_child(comment_desc_confirm_button);
+ comment_desc_confirm_button->connect("pressed", callable_mp(this, &VisualShaderEditor::_comment_desc_confirm));
+ add_child(comment_desc_change_popup);
+
///////////////////////////////////////
// SHADER NODES TREE OPTIONS
///////////////////////////////////////
@@ -3618,6 +3806,7 @@ VisualShaderEditor::VisualShaderEditor() {
const String input_param_for_vertex_and_fragment_shader_modes = TTR("'%s' input parameter for vertex and fragment shader modes.");
const String input_param_for_fragment_and_light_shader_modes = TTR("'%s' input parameter for fragment and light shader modes.");
const String input_param_for_fragment_shader_mode = TTR("'%s' input parameter for fragment shader mode.");
+ const String input_param_for_sky_shader_mode = TTR("'%s' input parameter for sky shader mode.");
const String input_param_for_light_shader_mode = TTR("'%s' input parameter for light shader mode.");
const String input_param_for_vertex_shader_mode = TTR("'%s' input parameter for vertex shader mode.");
const String input_param_for_emit_shader_mode = TTR("'%s' input parameter for emit shader mode.");
@@ -3747,35 +3936,35 @@ VisualShaderEditor::VisualShaderEditor() {
// SKY INPUTS
- add_options.push_back(AddOption("AtCubeMapPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "at_cubemap_pass"), "at_cubemap_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("AtHalfResPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "at_half_res_pass"), "at_half_res_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("AtQuarterResPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "at_quarter_res_pass"), "at_quarter_res_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("EyeDir", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "eyedir"), "eyedir", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("HalfResColor", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "half_res_color"), "half_res_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("HalfResAlpha", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "half_res_alpha"), "half_res_alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light0Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_color"), "light0_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light0Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_direction"), "light0_direction", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light0Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_enabled"), "light0_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light0Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_energy"), "light0_energy", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light1Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_color"), "light1_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light1Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_direction"), "light1_direction", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light1Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_enabled"), "light1_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light1Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_energy"), "light1_energy", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light2Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_color"), "light2_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light2Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_direction"), "light2_direction", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light2Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_enabled"), "light2_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light2Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_energy"), "light2_energy", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light3Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_color"), "light3_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light3Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_direction"), "light3_direction", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light3Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_enabled"), "light3_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light3Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_energy"), "light3_energy", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Position", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "position"), "position", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("QuarterResColor", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "quarter_res_color"), "quarter_res_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("QuarterResAlpha", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "quarter_res_alpha"), "quarter_res_alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Radiance", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "radiance"), "radiance", VisualShaderNode::PORT_TYPE_SAMPLER, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("ScreenUV", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "screen_uv"), "screen_uv", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("SkyCoords", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "sky_coords"), "sky_coords", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Time", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "time"), "time", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("AtCubeMapPass", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "at_cubemap_pass"), "at_cubemap_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("AtHalfResPass", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "at_half_res_pass"), "at_half_res_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("AtQuarterResPass", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "at_quarter_res_pass"), "at_quarter_res_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("EyeDir", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "eyedir"), "eyedir", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("HalfResColor", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "half_res_color"), "half_res_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("HalfResAlpha", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "half_res_alpha"), "half_res_alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light0Color", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "light0_color"), "light0_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light0Direction", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "light0_direction"), "light0_direction", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light0Enabled", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "light0_enabled"), "light0_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light0Energy", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "light0_energy"), "light0_energy", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light1Color", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "light1_color"), "light1_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light1Direction", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "light1_direction"), "light1_direction", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light1Enabled", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "light1_enabled"), "light1_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light1Energy", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "light1_energy"), "light1_energy", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light2Color", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "light2_color"), "light2_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light2Direction", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "light2_direction"), "light2_direction", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light2Enabled", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "light2_enabled"), "light2_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light2Energy", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "light2_energy"), "light2_energy", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light3Color", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "light3_color"), "light3_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light3Direction", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "light3_direction"), "light3_direction", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light3Enabled", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "light3_enabled"), "light3_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light3Energy", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "light3_energy"), "light3_energy", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Position", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "position"), "position", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("QuarterResColor", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "quarter_res_color"), "quarter_res_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("QuarterResAlpha", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "quarter_res_alpha"), "quarter_res_alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Radiance", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "radiance"), "radiance", VisualShaderNode::PORT_TYPE_SAMPLER, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("ScreenUV", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "screen_uv"), "screen_uv", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("SkyCoords", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "sky_coords"), "sky_coords", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_SKY, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Time", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "time"), "time", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_SKY, Shader::MODE_SKY));
// SCALAR
@@ -3971,6 +4160,7 @@ VisualShaderEditor::VisualShaderEditor() {
// SPECIAL
+ add_options.push_back(AddOption("Comment", "Special", "", "VisualShaderNodeComment", TTR("A rectangular area with a description string for better graph organization.")));
add_options.push_back(AddOption("Expression", "Special", "", "VisualShaderNodeExpression", TTR("Custom Godot Shader Language expression, with custom amount of input and output ports. This is a direct injection of code into the vertex/fragment/light function, do not use it to write the function declarations inside.")));
add_options.push_back(AddOption("Fresnel", "Special", "", "VisualShaderNodeFresnel", TTR("Returns falloff based on the dot product of surface normal and view direction of camera (pass associated inputs to it)."), -1, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("GlobalExpression", "Special", "", "VisualShaderNodeGlobalExpression", TTR("Custom Godot Shader Language expression, which is placed on top of the resulted shader. You can place various function definitions inside and call it later in the Expressions. You can also declare varyings, uniforms and constants.")));
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index 182bed6ba6..6d57d38cab 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -67,7 +67,7 @@ private:
VisualShader::Type type = VisualShader::Type::TYPE_MAX;
VisualShaderNode *visual_node = nullptr;
GraphNode *graph_node = nullptr;
- bool preview_visible = 0;
+ bool preview_visible = false;
int preview_pos = 0;
Map<int, InputPort> input_ports;
Map<int, Port> output_ports;
@@ -141,6 +141,7 @@ class VisualShaderEditor : public VBoxContainer {
OptionButton *edit_type = nullptr;
OptionButton *edit_type_standart;
OptionButton *edit_type_particles;
+ OptionButton *edit_type_sky;
PanelContainer *error_panel;
Label *error_label;
@@ -161,9 +162,22 @@ class VisualShaderEditor : public VBoxContainer {
PopupMenu *popup_menu;
MenuButton *tools;
+ PopupPanel *comment_title_change_popup = nullptr;
+ LineEdit *comment_title_change_edit = nullptr;
+
+ PopupPanel *comment_desc_change_popup = nullptr;
+ TextEdit *comment_desc_change_edit = nullptr;
+
bool preview_first = true;
bool preview_showed = false;
- bool particles_mode;
+
+ enum ShaderModeFlags {
+ MODE_FLAGS_SPATIAL_CANVASITEM = 1,
+ MODE_FLAGS_SKY = 2,
+ MODE_FLAGS_PARTICLES = 4
+ };
+
+ int mode = MODE_FLAGS_SPATIAL_CANVASITEM;
enum TypeFlags {
TYPE_FLAGS_VERTEX = 1,
@@ -177,6 +191,10 @@ class VisualShaderEditor : public VBoxContainer {
TYPE_FLAGS_END = 4
};
+ enum SkyTypeFlags {
+ TYPE_FLAGS_SKY = 1,
+ };
+
enum ToolsMenuOptions {
EXPAND_ALL,
COLLAPSE_ALL
@@ -192,6 +210,9 @@ class VisualShaderEditor : public VBoxContainer {
SEPARATOR2, // ignore
CONVERT_CONSTANTS_TO_UNIFORMS,
CONVERT_UNIFORMS_TO_CONSTANTS,
+ SEPARATOR3, // ignore
+ SET_COMMENT_TITLE,
+ SET_COMMENT_DESCRIPTION,
};
Tree *members;
@@ -325,6 +346,7 @@ class VisualShaderEditor : public VBoxContainer {
Set<int> selected_constants;
Set<int> selected_uniforms;
+ int selected_comment = -1;
void _convert_constants_to_uniforms(bool p_vice_versa);
void _replace_node(VisualShader::Type p_type_id, int p_node_id, const StringName &p_from, const StringName &p_to);
@@ -334,6 +356,17 @@ class VisualShaderEditor : public VBoxContainer {
void _connection_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_position);
void _connection_from_empty(const String &p_to, int p_to_slot, const Vector2 &p_release_position);
+ void _comment_title_popup_show(const Point2 &p_position, int p_node_id);
+ void _comment_title_popup_hide();
+ void _comment_title_popup_focus_out();
+ void _comment_title_text_changed(const String &p_new_text);
+ void _comment_title_text_entered(const String &p_new_text);
+
+ void _comment_desc_popup_show(const Point2 &p_position, int p_node_id);
+ void _comment_desc_popup_hide();
+ void _comment_desc_confirm();
+ void _comment_desc_text_changed();
+
void _uniform_line_edit_changed(const String &p_text, int p_node_id);
void _uniform_line_edit_focus_out(Object *line_edit, int p_node_id);