diff options
Diffstat (limited to 'editor')
87 files changed, 615 insertions, 378 deletions
diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp index c8ab98a80f..7cfedffcbf 100644 --- a/editor/action_map_editor.cpp +++ b/editor/action_map_editor.cpp @@ -577,6 +577,7 @@ String InputEventConfigurationDialog::_get_device_string(int p_device) const { void InputEventConfigurationDialog::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { input_list_search->set_right_icon(input_list_search->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); @@ -1057,6 +1058,7 @@ void ActionMapEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, void ActionMapEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { action_list_search->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); if (!actions_cache.is_empty()) { diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index c121ab42d3..9af8b907c4 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -216,8 +216,8 @@ void AnimationBezierTrackEdit::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning"))); - } break; - + [[fallthrough]]; + } case NOTIFICATION_THEME_CHANGED: { bezier_icon = get_theme_icon(SNAME("KeyBezierPoint"), SNAME("EditorIcons")); bezier_handle_icon = get_theme_icon(SNAME("KeyBezierHandle"), SNAME("EditorIcons")); diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 379e2cb510..aaaf3e6f04 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -1489,6 +1489,7 @@ int AnimationTimelineEdit::get_name_limit() const { void AnimationTimelineEdit::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning"))); add_track->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); @@ -3599,9 +3600,7 @@ void AnimationTrackEditor::cleanup() { } void AnimationTrackEditor::_name_limit_changed() { - for (int i = 0; i < track_edits.size(); i++) { - track_edits[i]->update(); - } + _redraw_tracks(); } void AnimationTrackEditor::_timeline_changed(float p_new_pos, bool p_drag, bool p_timeline_only) { @@ -3696,9 +3695,7 @@ void AnimationTrackEditor::set_anim_pos(float p_pos) { for (int i = 0; i < track_edits.size(); i++) { track_edits[i]->set_play_position(p_pos); } - for (int i = 0; i < groups.size(); i++) { - groups[i]->update(); - } + _redraw_groups(); bezier_edit->set_play_position(p_pos); } @@ -4646,6 +4643,18 @@ void AnimationTrackEditor::_update_tracks() { } } +void AnimationTrackEditor::_redraw_tracks() { + for (int i = 0; i < track_edits.size(); i++) { + track_edits[i]->update(); + } +} + +void AnimationTrackEditor::_redraw_groups() { + for (int i = 0; i < groups.size(); i++) { + groups[i]->update(); + } +} + void AnimationTrackEditor::_sync_animation_change() { bezier_edit->update(); } @@ -4727,12 +4736,8 @@ void AnimationTrackEditor::_animation_update() { } if (same) { - for (int i = 0; i < track_edits.size(); i++) { - track_edits[i]->update(); - } - for (int i = 0; i < groups.size(); i++) { - groups[i]->update(); - } + _redraw_tracks(); + _redraw_groups(); } else { _update_tracks(); } @@ -4758,8 +4763,8 @@ void AnimationTrackEditor::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning"))); - } break; - + [[fallthrough]]; + } case NOTIFICATION_THEME_CHANGED: { zoom_icon->set_texture(get_theme_icon(SNAME("Zoom"), SNAME("EditorIcons"))); bezier_edit_icon->set_icon(get_theme_icon(SNAME("EditBezier"), SNAME("EditorIcons"))); @@ -4782,12 +4787,8 @@ void AnimationTrackEditor::_notification(int p_what) { } void AnimationTrackEditor::_update_scroll(double) { - for (int i = 0; i < track_edits.size(); i++) { - track_edits[i]->update(); - } - for (int i = 0; i < groups.size(); i++) { - groups[i]->update(); - } + _redraw_tracks(); + _redraw_groups(); } void AnimationTrackEditor::_update_step(double p_new_step) { @@ -4815,7 +4816,7 @@ void AnimationTrackEditor::_dropped_track(int p_from_track, int p_to_track) { return; } - _clear_selection(); + _clear_selection(true); undo_redo->create_action(TTR("Rearrange Tracks")); undo_redo->add_do_method(animation.ptr(), "track_move_to", p_from_track, p_to_track); // Take into account that the position of the tracks that come after the one removed will change. @@ -4993,14 +4994,11 @@ void AnimationTrackEditor::_new_track_property_selected(String p_name) { void AnimationTrackEditor::_timeline_value_changed(double) { timeline->update_play_position(); + _redraw_tracks(); for (int i = 0; i < track_edits.size(); i++) { - track_edits[i]->update(); track_edits[i]->update_play_position(); } - - for (int i = 0; i < groups.size(); i++) { - groups[i]->update(); - } + _redraw_groups(); bezier_edit->update(); bezier_edit->update_play_position(); @@ -5211,10 +5209,7 @@ void AnimationTrackEditor::_key_selected(int p_key, bool p_single, int p_track) ki.pos = animation->track_get_key_time(p_track, p_key); selection[sk] = ki; - for (int i = 0; i < track_edits.size(); i++) { - track_edits[i]->update(); - } - + _redraw_tracks(); _update_key_edit(); } @@ -5228,10 +5223,7 @@ void AnimationTrackEditor::_key_deselected(int p_key, int p_track) { selection.erase(sk); - for (int i = 0; i < track_edits.size(); i++) { - track_edits[i]->update(); - } - + _redraw_tracks(); _update_key_edit(); } @@ -5242,10 +5234,7 @@ void AnimationTrackEditor::_move_selection_begin() { void AnimationTrackEditor::_move_selection(float p_offset) { moving_selection_offset = p_offset; - - for (int i = 0; i < track_edits.size(); i++) { - track_edits[i]->update(); - } + _redraw_tracks(); } struct _AnimMoveRestore { @@ -5282,9 +5271,7 @@ void AnimationTrackEditor::_clear_selection(bool p_update) { selection.clear(); if (p_update) { - for (int i = 0; i < track_edits.size(); i++) { - track_edits[i]->update(); - } + _redraw_tracks(); } _clear_key_edit(); @@ -5442,21 +5429,16 @@ void AnimationTrackEditor::_move_selection_commit() { undo_redo->add_undo_method(this, "_select_at_anim", animation, E->key().track, oldpos); } - undo_redo->commit_action(); - moving_selection = false; - for (int i = 0; i < track_edits.size(); i++) { - track_edits[i]->update(); - } - + undo_redo->add_do_method(this, "_redraw_tracks"); + undo_redo->add_undo_method(this, "_redraw_tracks"); + undo_redo->commit_action(); _update_key_edit(); } void AnimationTrackEditor::_move_selection_cancel() { moving_selection = false; - for (int i = 0; i < track_edits.size(); i++) { - track_edits[i]->update(); - } + _redraw_tracks(); } bool AnimationTrackEditor::is_moving_selection() const { @@ -5499,7 +5481,7 @@ void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) { track_edits[track_edits.size() - 1]->grab_focus(); } } else { - _clear_selection(); // Clear it. + _clear_selection(true); // Clear it. } box_selection->hide(); @@ -5519,7 +5501,7 @@ void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) { if (!box_selection->is_visible_in_tree()) { if (!mm->is_command_pressed() && !mm->is_shift_pressed()) { - _clear_selection(); + _clear_selection(true); } box_selection->show(); } @@ -5666,32 +5648,21 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) { } } - undo_redo->commit_action(); + undo_redo->add_do_method(this, "_clear_selection_for_anim", animation); + undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation); // Reselect duplicated. - RBMap<SelectedKey, KeyInfo> new_selection; for (const Pair<int, float> &E : new_selection_values) { - int track = E.first; - float time = E.second; - - int existing_idx = animation->track_find_key(track, time, true); - - if (existing_idx == -1) { - continue; - } - SelectedKey sk2; - sk2.track = track; - sk2.key = existing_idx; - - KeyInfo ki; - ki.pos = time; - - new_selection[sk2] = ki; + undo_redo->add_do_method(this, "_select_at_anim", animation, E.first, E.second); + } + for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { + undo_redo->add_undo_method(this, "_select_at_anim", animation, E->key().track, E->get().pos); } - selection = new_selection; - _update_tracks(); + undo_redo->add_do_method(this, "_redraw_tracks"); + undo_redo->add_undo_method(this, "_redraw_tracks"); + undo_redo->commit_action(); _update_key_edit(); } } @@ -6012,7 +5983,12 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { undo_redo->add_undo_method(this, "_select_at_anim", animation, E->key().track, oldpos); } #undef NEW_POS + + undo_redo->add_do_method(this, "_redraw_tracks"); + undo_redo->add_undo_method(this, "_redraw_tracks"); undo_redo->commit_action(); + _update_key_edit(); + } break; case EDIT_EASE_SELECTION: { @@ -6066,7 +6042,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { bool is_using_angle = animation->track_get_interpolation_type(track) == Animation::INTERPOLATION_LINEAR_ANGLE || animation->track_get_interpolation_type(track) == Animation::INTERPOLATION_CUBIC_ANGLE; // Make insert queue. - Vector<Pair<double, Variant>> insert_queue; + Vector<Pair<real_t, Variant>> insert_queue; for (int i = 0; i < len; i++) { // Check neighboring keys. if (keys[i] + 1 == keys[i + 1]) { @@ -6085,7 +6061,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { double duration = to_t - from_t; double fixed_duration = duration - 0.01; // Prevent to overwrap keys... for (double delta_t = dur_step; delta_t < fixed_duration; delta_t += dur_step) { - Pair<double, Variant> keydata; + Pair<real_t, Variant> keydata; keydata.first = from_t + delta_t; keydata.second = Tween::interpolate_variant(from_v, delta_v, delta_t, duration, transition_type, ease_type); insert_queue.append(keydata); @@ -6102,7 +6078,12 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { ++E; } + undo_redo->add_do_method(this, "_clear_selection_for_anim", animation); + undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation); + undo_redo->add_do_method(this, "_redraw_tracks"); + undo_redo->add_undo_method(this, "_redraw_tracks"); undo_redo->commit_action(); + _update_key_edit(); } break; @@ -6122,6 +6103,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } break; case EDIT_ADD_RESET_KEY: { undo_redo->create_action(TTR("Anim Add RESET Keys")); + Ref<Animation> reset = _create_and_get_reset_animation(); int reset_tracks = reset->get_track_count(); HashSet<int> tracks_added; @@ -6166,6 +6148,10 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } } + undo_redo->add_do_method(this, "_clear_selection_for_anim", animation); + undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation); + undo_redo->add_do_method(this, "_redraw_tracks"); + undo_redo->add_undo_method(this, "_redraw_tracks"); undo_redo->commit_action(); } break; @@ -6184,6 +6170,8 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } undo_redo->add_do_method(this, "_clear_selection_for_anim", animation); undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation); + undo_redo->add_do_method(this, "_redraw_tracks"); + undo_redo->add_undo_method(this, "_redraw_tracks"); undo_redo->commit_action(); _update_key_edit(); } @@ -6196,11 +6184,15 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { goto_prev_step(false); } break; - case EDIT_BAKE_TRACK: { + case EDIT_APPLY_RESET: { + AnimationPlayerEditor::get_singleton()->get_player()->apply_reset(true); + } break; + + case EDIT_BAKE_ANIMATION: { bake_dialog->popup_centered(Size2(200, 100) * EDSCALE); } break; - case EDIT_BAKE_TRACK_CONFIRM: { - undo_redo->create_action(TTR("Bake Track as Linear keys.")); + case EDIT_BAKE_ANIMATION_CONFIRM: { + undo_redo->create_action(TTR("Bake Animation as Linear keys.")); int track_len = animation->get_track_count(); bool b_trs = bake_trs->is_pressed(); @@ -6227,12 +6219,12 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { bool is_using_angle = it == Animation::INTERPOLATION_LINEAR_ANGLE || it == Animation::INTERPOLATION_CUBIC_ANGLE; // Make insert queue. - Vector<Pair<double, Variant>> insert_queue; + Vector<Pair<real_t, Variant>> insert_queue; switch (type) { case Animation::TYPE_POSITION_3D: { for (double delta_t = 0.0; delta_t <= anim_len; delta_t += dur_step) { - Pair<double, Variant> keydata; + Pair<real_t, Variant> keydata; keydata.first = delta_t; Vector3 v; animation->position_track_interpolate(i, delta_t, &v); @@ -6242,7 +6234,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } break; case Animation::TYPE_ROTATION_3D: { for (double delta_t = 0.0; delta_t <= anim_len; delta_t += dur_step) { - Pair<double, Variant> keydata; + Pair<real_t, Variant> keydata; keydata.first = delta_t; Quaternion v; animation->rotation_track_interpolate(i, delta_t, &v); @@ -6252,7 +6244,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } break; case Animation::TYPE_SCALE_3D: { for (double delta_t = 0.0; delta_t <= anim_len; delta_t += dur_step) { - Pair<double, Variant> keydata; + Pair<real_t, Variant> keydata; keydata.first = delta_t; Vector3 v; animation->scale_track_interpolate(i, delta_t, &v); @@ -6262,7 +6254,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } break; case Animation::TYPE_BLEND_SHAPE: { for (double delta_t = 0.0; delta_t <= anim_len; delta_t += dur_step) { - Pair<double, Variant> keydata; + Pair<real_t, Variant> keydata; keydata.first = delta_t; float v; animation->blend_shape_track_interpolate(i, delta_t, &v); @@ -6272,7 +6264,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } break; case Animation::TYPE_VALUE: { for (double delta_t = 0.0; delta_t < anim_len; delta_t += dur_step) { - Pair<double, Variant> keydata; + Pair<real_t, Variant> keydata; keydata.first = delta_t; keydata.second = animation->value_track_interpolate(i, delta_t); insert_queue.append(keydata); @@ -6292,7 +6284,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_type", i, is_using_angle ? Animation::INTERPOLATION_LINEAR_ANGLE : Animation::INTERPOLATION_LINEAR); for (int j = insert_queue.size() - 1; j >= 0; j--) { undo_redo->add_do_method(animation.ptr(), "track_insert_key", i, insert_queue[j].first, insert_queue[j].second); - undo_redo->add_undo_method(animation.ptr(), "track_remove_key", i, j); + undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", i, insert_queue[j].first); } // Undo methods. @@ -6303,23 +6295,25 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } } + undo_redo->add_do_method(this, "_clear_selection_for_anim", animation); + undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation); + undo_redo->add_do_method(this, "_redraw_tracks"); + undo_redo->add_undo_method(this, "_redraw_tracks"); undo_redo->commit_action(); + _update_key_edit(); } break; - case EDIT_APPLY_RESET: { - AnimationPlayerEditor::get_singleton()->get_player()->apply_reset(true); - } break; - case EDIT_OPTIMIZE_ANIMATION: { optimize_dialog->popup_centered(Size2(250, 180) * EDSCALE); } break; case EDIT_OPTIMIZE_ANIMATION_CONFIRM: { animation->optimize(optimize_velocity_error->get_value(), optimize_angular_error->get_value(), optimize_precision_error->get_value()); - _update_tracks(); - undo_redo->clear_history(true, undo_redo->get_history_for_object(animation.ptr()).id); - undo_redo->clear_history(true, undo_redo->get_history_for_object(this).id); + _redraw_tracks(); + _update_key_edit(); + undo_redo->clear_history(true, undo_redo->get_history_id_for_object(animation.ptr())); + undo_redo->clear_history(true, undo_redo->get_history_id_for_object(this)); } break; case EDIT_CLEAN_UP_ANIMATION: { @@ -6387,8 +6381,8 @@ void AnimationTrackEditor::_cleanup_animation(Ref<Animation> p_animation) { } } - undo_redo->clear_history(true, undo_redo->get_history_for_object(animation.ptr()).id); - undo_redo->clear_history(true, undo_redo->get_history_for_object(this).id); + undo_redo->clear_history(true, undo_redo->get_history_id_for_object(animation.ptr())); + undo_redo->clear_history(true, undo_redo->get_history_id_for_object(this)); _update_tracks(); } @@ -6410,13 +6404,8 @@ void AnimationTrackEditor::_selection_changed() { if (selected_filter->is_pressed()) { _update_tracks(); // Needs updatin. } else { - for (int i = 0; i < track_edits.size(); i++) { - track_edits[i]->update(); - } - - for (int i = 0; i < groups.size(); i++) { - groups[i]->update(); - } + _redraw_tracks(); + _redraw_groups(); } } @@ -6478,6 +6467,7 @@ void AnimationTrackEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_animation_update"), &AnimationTrackEditor::_animation_update); ClassDB::bind_method(D_METHOD("_track_grab_focus"), &AnimationTrackEditor::_track_grab_focus); ClassDB::bind_method(D_METHOD("_update_tracks"), &AnimationTrackEditor::_update_tracks); + ClassDB::bind_method(D_METHOD("_redraw_tracks"), &AnimationTrackEditor::_redraw_tracks); ClassDB::bind_method(D_METHOD("_clear_selection_for_anim"), &AnimationTrackEditor::_clear_selection_for_anim); ClassDB::bind_method(D_METHOD("_select_at_anim"), &AnimationTrackEditor::_select_at_anim); @@ -6734,10 +6724,9 @@ AnimationTrackEditor::AnimationTrackEditor() { edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/goto_next_step", TTR("Go to Next Step"), KeyModifierMask::CMD | Key::RIGHT), EDIT_GOTO_NEXT_STEP); edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/goto_prev_step", TTR("Go to Previous Step"), KeyModifierMask::CMD | Key::LEFT), EDIT_GOTO_PREV_STEP); edit->get_popup()->add_separator(); - edit->get_popup()->add_item(TTR("Bake Track"), EDIT_BAKE_TRACK); - edit->get_popup()->add_separator(); edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/apply_reset", TTR("Apply Reset")), EDIT_APPLY_RESET); edit->get_popup()->add_separator(); + edit->get_popup()->add_item(TTR("Bake Animation"), EDIT_BAKE_ANIMATION); edit->get_popup()->add_item(TTR("Optimize Animation (no undo)"), EDIT_OPTIMIZE_ANIMATION); edit->get_popup()->add_item(TTR("Clean-Up Animation (no undo)"), EDIT_CLEAN_UP_ANIMATION); @@ -6907,8 +6896,8 @@ AnimationTrackEditor::AnimationTrackEditor() { // bake_dialog = memnew(ConfirmationDialog); - bake_dialog->set_title(TTR("Track Baker")); - bake_dialog->connect("confirmed", callable_mp(this, &AnimationTrackEditor::_edit_menu_pressed).bind(EDIT_BAKE_TRACK_CONFIRM)); + bake_dialog->set_title(TTR("Anim. Baker")); + bake_dialog->connect("confirmed", callable_mp(this, &AnimationTrackEditor::_edit_menu_pressed).bind(EDIT_BAKE_ANIMATION_CONFIRM)); add_child(bake_dialog); GridContainer *bake_grid = memnew(GridContainer); bake_grid->set_columns(2); diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index a17ee65eab..ac69b88e99 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -330,6 +330,8 @@ class AnimationTrackEditor : public VBoxContainer { void _sync_animation_change(); void _animation_changed(); void _update_tracks(); + void _redraw_tracks(); + void _redraw_groups(); void _name_limit_changed(); void _timeline_changed(float p_new_pos, bool p_drag, bool p_timeline_only); @@ -545,9 +547,9 @@ public: EDIT_GOTO_NEXT_STEP, EDIT_GOTO_NEXT_STEP_TIMELINE_ONLY, // Next step without updating animation. EDIT_GOTO_PREV_STEP, - EDIT_BAKE_TRACK, - EDIT_BAKE_TRACK_CONFIRM, EDIT_APPLY_RESET, + EDIT_BAKE_ANIMATION, + EDIT_BAKE_ANIMATION_CONFIRM, EDIT_OPTIMIZE_ANIMATION, EDIT_OPTIMIZE_ANIMATION_CONFIRM, EDIT_CLEAN_UP_ANIMATION, diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 9dddcbbeba..2b1584b20c 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1740,6 +1740,10 @@ void CodeTextEditor::_update_status_bar_theme() { void CodeTextEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + _update_status_bar_theme(); + } break; + case NOTIFICATION_THEME_CHANGED: { _update_status_bar_theme(); if (toggle_scripts_button->is_visible()) { diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index bfa9081af2..587c16c229 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -230,8 +230,9 @@ void ConnectDialog::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { bind_editor->edit(cdbinds); - } break; + [[fallthrough]]; + } case NOTIFICATION_THEME_CHANGED: { for (int i = 0; i < type_list->get_item_count(); i++) { String type_name = Variant::get_type_name((Variant::Type)type_list->get_item_id(i)); @@ -912,6 +913,7 @@ void ConnectionsDock::_connect_pressed() { void ConnectionsDock::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); } break; diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 02ce081c02..03e636d43a 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -423,10 +423,16 @@ void CreateDialog::_sbox_input(const Ref<InputEvent> &p_ie) { } } +void CreateDialog::_update_theme() { + search_box->set_right_icon(search_options->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + favorite->set_icon(search_options->get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons"))); +} + void CreateDialog::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { connect("confirmed", callable_mp(this, &CreateDialog::_confirmed)); + _update_theme(); } break; case NOTIFICATION_EXIT_TREE: { @@ -443,8 +449,7 @@ void CreateDialog::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - search_box->set_right_icon(search_options->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - favorite->set_icon(search_options->get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons"))); + _update_theme(); } break; } } diff --git a/editor/create_dialog.h b/editor/create_dialog.h index 9a17993e11..f7731d2726 100644 --- a/editor/create_dialog.h +++ b/editor/create_dialog.h @@ -101,6 +101,8 @@ class CreateDialog : public ConfirmationDialog { bool _is_class_disabled_by_feature_profile(const StringName &p_class) const; void _load_favorites_and_history(); + void _update_theme(); + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.cpp b/editor/debugger/debug_adapter/debug_adapter_parser.cpp index 3c3e4faa6f..ac41306cde 100644 --- a/editor/debugger/debug_adapter/debug_adapter_parser.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_parser.cpp @@ -201,7 +201,7 @@ Dictionary DebugAdapterParser::req_launch(const Dictionary &p_params) const { } } else if (platform_string == "web") { for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) { - if (EditorExport::get_singleton()->get_export_platform(i)->get_name() == "HTML5") { + if (EditorExport::get_singleton()->get_export_platform(i)->get_name() == "Web") { idx = i; break; } diff --git a/editor/debugger/editor_network_profiler.cpp b/editor/debugger/editor_network_profiler.cpp index 185553cac0..8c18eba71d 100644 --- a/editor/debugger/editor_network_profiler.cpp +++ b/editor/debugger/editor_network_profiler.cpp @@ -40,6 +40,7 @@ void EditorNetworkProfiler::_bind_methods() { void EditorNetworkProfiler::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index 30197e6d8b..b49cab9df7 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -394,9 +394,10 @@ void EditorProfiler::_clear_pressed() { void EditorProfiler::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: - case NOTIFICATION_TRANSLATION_CHANGED: - case NOTIFICATION_THEME_CHANGED: { + case NOTIFICATION_THEME_CHANGED: + case NOTIFICATION_TRANSLATION_CHANGED: { activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); } break; diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index df1a59cc99..6f3dd1793c 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -424,9 +424,10 @@ void EditorVisualProfiler::_clear_pressed() { void EditorVisualProfiler::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: - case NOTIFICATION_TRANSLATION_CHANGED: - case NOTIFICATION_THEME_CHANGED: { + case NOTIFICATION_THEME_CHANGED: + case NOTIFICATION_TRANSLATION_CHANGED: { if (is_layout_rtl()) { activate->set_icon(get_theme_icon(SNAME("PlayBackwards"), SNAME("EditorIcons"))); } else { diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 1036561a47..fab211f18c 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -787,8 +787,8 @@ void ScriptEditorDebugger::_notification(int p_what) { error_tree->connect("item_selected", callable_mp(this, &ScriptEditorDebugger::_error_selected)); error_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_error_activated)); breakpoints_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_breakpoint_tree_clicked)); - } break; - + [[fallthrough]]; + } case NOTIFICATION_THEME_CHANGED: { skip_breakpoints->set_icon(get_theme_icon(skip_breakpoints_value ? SNAME("DebugSkipBreakpointsOn") : SNAME("DebugSkipBreakpointsOff"), SNAME("EditorIcons"))); copy->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index 864871bb7e..489a55ede0 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -41,6 +41,7 @@ #include "core/version.h" #include "editor/editor_settings.h" #include "scene/resources/theme.h" +#include "scene/theme/theme_db.h" // Used for a hack preserving Mono properties on non-Mono builds. #include "modules/modules_enabled.gen.h" // For mono. @@ -567,29 +568,29 @@ void DocTools::generate(bool p_basic_types) { { List<StringName> l; - Theme::get_default()->get_color_list(cname, &l); + ThemeDB::get_singleton()->get_default_theme()->get_color_list(cname, &l); for (const StringName &E : l) { DocData::ThemeItemDoc tid; tid.name = E; tid.type = "Color"; tid.data_type = "color"; - tid.default_value = Variant(Theme::get_default()->get_color(E, cname)).get_construct_string().replace("\n", " "); + tid.default_value = Variant(ThemeDB::get_singleton()->get_default_theme()->get_color(E, cname)).get_construct_string().replace("\n", " "); c.theme_properties.push_back(tid); } l.clear(); - Theme::get_default()->get_constant_list(cname, &l); + ThemeDB::get_singleton()->get_default_theme()->get_constant_list(cname, &l); for (const StringName &E : l) { DocData::ThemeItemDoc tid; tid.name = E; tid.type = "int"; tid.data_type = "constant"; - tid.default_value = itos(Theme::get_default()->get_constant(E, cname)); + tid.default_value = itos(ThemeDB::get_singleton()->get_default_theme()->get_constant(E, cname)); c.theme_properties.push_back(tid); } l.clear(); - Theme::get_default()->get_font_list(cname, &l); + ThemeDB::get_singleton()->get_default_theme()->get_font_list(cname, &l); for (const StringName &E : l) { DocData::ThemeItemDoc tid; tid.name = E; @@ -599,7 +600,7 @@ void DocTools::generate(bool p_basic_types) { } l.clear(); - Theme::get_default()->get_font_size_list(cname, &l); + ThemeDB::get_singleton()->get_default_theme()->get_font_size_list(cname, &l); for (const StringName &E : l) { DocData::ThemeItemDoc tid; tid.name = E; @@ -609,7 +610,7 @@ void DocTools::generate(bool p_basic_types) { } l.clear(); - Theme::get_default()->get_icon_list(cname, &l); + ThemeDB::get_singleton()->get_default_theme()->get_icon_list(cname, &l); for (const StringName &E : l) { DocData::ThemeItemDoc tid; tid.name = E; @@ -619,7 +620,7 @@ void DocTools::generate(bool p_basic_types) { } l.clear(); - Theme::get_default()->get_stylebox_list(cname, &l); + ThemeDB::get_singleton()->get_default_theme()->get_stylebox_list(cname, &l); for (const StringName &E : l) { DocData::ThemeItemDoc tid; tid.name = E; diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp index cdf300e288..7baaffb1be 100644 --- a/editor/editor_about.cpp +++ b/editor/editor_about.cpp @@ -38,18 +38,22 @@ // The metadata key used to store and retrieve the version text to copy to the clipboard. static const String META_TEXT_TO_COPY = "text_to_copy"; +void EditorAbout::_theme_changed() { + const Ref<Font> font = get_theme_font(SNAME("source"), SNAME("EditorFonts")); + const int font_size = get_theme_font_size(SNAME("source_size"), SNAME("EditorFonts")); + _tpl_text->add_theme_font_override("normal_font", font); + _tpl_text->add_theme_font_size_override("normal_font_size", font_size); + _tpl_text->add_theme_constant_override("line_separation", 4 * EDSCALE); + _license_text->add_theme_font_override("normal_font", font); + _license_text->add_theme_font_size_override("normal_font_size", font_size); + _license_text->add_theme_constant_override("line_separation", 4 * EDSCALE); + _logo->set_texture(get_theme_icon(SNAME("Logo"), SNAME("EditorIcons"))); +} + void EditorAbout::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_THEME_CHANGED: { - const Ref<Font> font = get_theme_font(SNAME("source"), SNAME("EditorFonts")); - const int font_size = get_theme_font_size(SNAME("source_size"), SNAME("EditorFonts")); - _tpl_text->add_theme_font_override("normal_font", font); - _tpl_text->add_theme_font_size_override("normal_font_size", font_size); - _tpl_text->add_theme_constant_override("line_separation", 4 * EDSCALE); - _license_text->add_theme_font_override("normal_font", font); - _license_text->add_theme_font_size_override("normal_font_size", font_size); - _license_text->add_theme_constant_override("line_separation", 4 * EDSCALE); - _logo->set_texture(get_theme_icon(SNAME("Logo"), SNAME("EditorIcons"))); + case NOTIFICATION_ENTER_TREE: { + _theme_changed(); } break; } } @@ -116,6 +120,7 @@ EditorAbout::EditorAbout() { set_hide_on_ok(true); VBoxContainer *vbc = memnew(VBoxContainer); + vbc->connect("theme_changed", callable_mp(this, &EditorAbout::_theme_changed)); HBoxContainer *hbc = memnew(HBoxContainer); hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL); hbc->set_alignment(BoxContainer::ALIGNMENT_CENTER); diff --git a/editor/editor_about.h b/editor/editor_about.h index b152f1b4d3..971843f6d2 100644 --- a/editor/editor_about.h +++ b/editor/editor_about.h @@ -62,6 +62,8 @@ private: RichTextLabel *_tpl_text = nullptr; TextureRect *_logo = nullptr; + void _theme_changed(); + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index cc65cddfb2..a95cc4981a 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -66,6 +66,7 @@ void EditorAudioBus::_update_visible_channels() { void EditorAudioBus::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { for (int i = 0; i < CHANNELS_MAX; i++) { channel[i].vu_l->set_under_texture(get_theme_icon(SNAME("BusVuEmpty"), SNAME("EditorIcons"))); @@ -1024,6 +1025,7 @@ EditorAudioBuses *EditorAudioBuses::register_editor() { void EditorAudioBuses::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { bus_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); } break; diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 7dff0d54f7..120ac5b984 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -59,6 +59,7 @@ void EditorAutoloadSettings::_notification(int p_what) { get_tree()->get_root()->call_deferred(SNAME("add_child"), info.node); } } + browse_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } break; case NOTIFICATION_THEME_CHANGED: { diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index cc0f60fee5..5d249b0fab 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -70,6 +70,7 @@ VBoxContainer *EditorFileDialog::get_vbox() { void EditorFileDialog::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_READY: case NOTIFICATION_THEME_CHANGED: case Control::NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case NOTIFICATION_TRANSLATION_CHANGED: { diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 29a0781e96..fe03166a01 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -44,6 +44,29 @@ DocTools *EditorHelp::doc = nullptr; +void EditorHelp::_update_theme() { + text_color = get_theme_color(SNAME("text_color"), SNAME("EditorHelp")); + title_color = get_theme_color(SNAME("title_color"), SNAME("EditorHelp")); + headline_color = get_theme_color(SNAME("headline_color"), SNAME("EditorHelp")); + comment_color = get_theme_color(SNAME("comment_color"), SNAME("EditorHelp")); + symbol_color = get_theme_color(SNAME("symbol_color"), SNAME("EditorHelp")); + value_color = get_theme_color(SNAME("value_color"), SNAME("EditorHelp")); + qualifier_color = get_theme_color(SNAME("qualifier_color"), SNAME("EditorHelp")); + type_color = get_theme_color(SNAME("type_color"), SNAME("EditorHelp")); + + class_desc->add_theme_color_override("selection_color", get_theme_color(SNAME("selection_color"), SNAME("EditorHelp"))); + class_desc->add_theme_constant_override("line_separation", get_theme_constant(SNAME("line_separation"), SNAME("EditorHelp"))); + class_desc->add_theme_constant_override("table_h_separation", get_theme_constant(SNAME("table_h_separation"), SNAME("EditorHelp"))); + class_desc->add_theme_constant_override("table_v_separation", get_theme_constant(SNAME("table_v_separation"), SNAME("EditorHelp"))); + + doc_font = get_theme_font(SNAME("doc"), SNAME("EditorFonts")); + doc_bold_font = get_theme_font(SNAME("doc_bold"), SNAME("EditorFonts")); + doc_title_font = get_theme_font(SNAME("doc_title"), SNAME("EditorFonts")); + doc_code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts")); + + doc_title_font_size = get_theme_font_size(SNAME("doc_title_size"), SNAME("EditorFonts")); +} + void EditorHelp::_search(bool p_search_previous) { if (p_search_previous) { find_bar->search_prev(); @@ -523,6 +546,7 @@ void EditorHelp::_update_doc() { method_line.clear(); section_line.clear(); + _update_theme(); String link_color_text = title_color.to_html(false); DocData::ClassDoc cd = doc->class_list[edited_class]; // Make a copy, so we can sort without worrying. @@ -1985,29 +2009,10 @@ void EditorHelp::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - _class_desc_resized(true); + if (is_inside_tree()) { + _class_desc_resized(true); + } update_toggle_scripts_button(); - - text_color = get_theme_color(SNAME("text_color"), SNAME("EditorHelp")); - title_color = get_theme_color(SNAME("title_color"), SNAME("EditorHelp")); - headline_color = get_theme_color(SNAME("headline_color"), SNAME("EditorHelp")); - comment_color = get_theme_color(SNAME("comment_color"), SNAME("EditorHelp")); - symbol_color = get_theme_color(SNAME("symbol_color"), SNAME("EditorHelp")); - value_color = get_theme_color(SNAME("value_color"), SNAME("EditorHelp")); - qualifier_color = get_theme_color(SNAME("qualifier_color"), SNAME("EditorHelp")); - type_color = get_theme_color(SNAME("type_color"), SNAME("EditorHelp")); - - class_desc->add_theme_color_override("selection_color", get_theme_color(SNAME("selection_color"), SNAME("EditorHelp"))); - class_desc->add_theme_constant_override("line_separation", get_theme_constant(SNAME("line_separation"), SNAME("EditorHelp"))); - class_desc->add_theme_constant_override("table_h_separation", get_theme_constant(SNAME("table_h_separation"), SNAME("EditorHelp"))); - class_desc->add_theme_constant_override("table_v_separation", get_theme_constant(SNAME("table_v_separation"), SNAME("EditorHelp"))); - - doc_font = get_theme_font(SNAME("doc"), SNAME("EditorFonts")); - doc_bold_font = get_theme_font(SNAME("doc_bold"), SNAME("EditorFonts")); - doc_title_font = get_theme_font(SNAME("doc_title"), SNAME("EditorFonts")); - doc_code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts")); - - doc_title_font_size = get_theme_font_size(SNAME("doc_title_size"), SNAME("EditorFonts")); } break; case NOTIFICATION_VISIBILITY_CHANGED: { @@ -2185,6 +2190,7 @@ void EditorHelpBit::_bind_methods() { void EditorHelpBit::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { rich_text->add_theme_color_override("selection_color", get_theme_color(SNAME("selection_color"), SNAME("EditorHelp"))); rich_text->clear(); @@ -2266,6 +2272,7 @@ void FindBar::popup_search() { void FindBar::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { find_prev->set_icon(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons"))); find_next->set_icon(get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons"))); diff --git a/editor/editor_help.h b/editor/editor_help.h index 20eb7f78fc..c9c1afb51b 100644 --- a/editor/editor_help.h +++ b/editor/editor_help.h @@ -145,6 +145,7 @@ class EditorHelp : public VBoxContainer { int scroll_to = -1; + void _update_theme(); void _help_callback(const String &p_topic); void _add_text(const String &p_bbcode); diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 21dbb5ab97..8716196658 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -2175,6 +2175,7 @@ bool EditorInspectorArray::can_drop_data_fw(const Point2 &p_point, const Variant void EditorInspectorArray::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { Color color = get_theme_color(SNAME("dark_color_1"), SNAME("Editor")); odd_style->set_bg_color(color.darkened(-0.08)); @@ -2368,6 +2369,7 @@ void EditorPaginator::update(int p_page, int p_max_page) { void EditorPaginator::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { first_page_button->set_icon(get_theme_icon(SNAME("PageFirst"), SNAME("EditorIcons"))); prev_page_button->set_icon(get_theme_icon(SNAME("PagePrevious"), SNAME("EditorIcons"))); diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index dbb6706cb3..86b0145240 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -64,48 +64,52 @@ void EditorLog::_error_handler(void *p_self, const char *p_func, const char *p_f } } +void EditorLog::_update_theme() { + Ref<Font> normal_font = get_theme_font(SNAME("output_source"), SNAME("EditorFonts")); + if (normal_font.is_valid()) { + log->add_theme_font_override("normal_font", normal_font); + } + + log->add_theme_font_size_override("normal_font_size", get_theme_font_size(SNAME("output_source_size"), SNAME("EditorFonts"))); + log->add_theme_color_override("selection_color", get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.4)); + + Ref<Font> bold_font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); + if (bold_font.is_valid()) { + log->add_theme_font_override("bold_font", bold_font); + } + + type_filter_map[MSG_TYPE_STD]->toggle_button->set_icon(get_theme_icon(SNAME("Popup"), SNAME("EditorIcons"))); + type_filter_map[MSG_TYPE_ERROR]->toggle_button->set_icon(get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))); + type_filter_map[MSG_TYPE_WARNING]->toggle_button->set_icon(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); + type_filter_map[MSG_TYPE_EDITOR]->toggle_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + + type_filter_map[MSG_TYPE_STD]->toggle_button->set_theme_type_variation("EditorLogFilterButton"); + type_filter_map[MSG_TYPE_ERROR]->toggle_button->set_theme_type_variation("EditorLogFilterButton"); + type_filter_map[MSG_TYPE_WARNING]->toggle_button->set_theme_type_variation("EditorLogFilterButton"); + type_filter_map[MSG_TYPE_EDITOR]->toggle_button->set_theme_type_variation("EditorLogFilterButton"); + + clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); + copy_button->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); + collapse_button->set_icon(get_theme_icon(SNAME("CombineLines"), SNAME("EditorIcons"))); + show_search_button->set_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + + theme_cache.error_color = get_theme_color(SNAME("error_color"), SNAME("Editor")); + theme_cache.error_icon = get_theme_icon(SNAME("Error"), SNAME("EditorIcons")); + theme_cache.warning_color = get_theme_color(SNAME("warning_color"), SNAME("Editor")); + theme_cache.warning_icon = get_theme_icon(SNAME("Warning"), SNAME("EditorIcons")); + theme_cache.message_color = get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, 0.6); +} + void EditorLog::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { + _update_theme(); _load_state(); } break; case NOTIFICATION_THEME_CHANGED: { - Ref<Font> normal_font = get_theme_font(SNAME("output_source"), SNAME("EditorFonts")); - if (normal_font.is_valid()) { - log->add_theme_font_override("normal_font", normal_font); - } - - log->add_theme_font_size_override("normal_font_size", get_theme_font_size(SNAME("output_source_size"), SNAME("EditorFonts"))); - log->add_theme_color_override("selection_color", get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.4)); - - Ref<Font> bold_font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); - if (bold_font.is_valid()) { - log->add_theme_font_override("bold_font", bold_font); - } - - type_filter_map[MSG_TYPE_STD]->toggle_button->set_icon(get_theme_icon(SNAME("Popup"), SNAME("EditorIcons"))); - type_filter_map[MSG_TYPE_ERROR]->toggle_button->set_icon(get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))); - type_filter_map[MSG_TYPE_WARNING]->toggle_button->set_icon(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); - type_filter_map[MSG_TYPE_EDITOR]->toggle_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); - - type_filter_map[MSG_TYPE_STD]->toggle_button->set_theme_type_variation("EditorLogFilterButton"); - type_filter_map[MSG_TYPE_ERROR]->toggle_button->set_theme_type_variation("EditorLogFilterButton"); - type_filter_map[MSG_TYPE_WARNING]->toggle_button->set_theme_type_variation("EditorLogFilterButton"); - type_filter_map[MSG_TYPE_EDITOR]->toggle_button->set_theme_type_variation("EditorLogFilterButton"); - - clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); - copy_button->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); - collapse_button->set_icon(get_theme_icon(SNAME("CombineLines"), SNAME("EditorIcons"))); - show_search_button->set_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - - theme_cache.error_color = get_theme_color(SNAME("error_color"), SNAME("Editor")); - theme_cache.error_icon = get_theme_icon(SNAME("Error"), SNAME("EditorIcons")); - theme_cache.warning_color = get_theme_color(SNAME("warning_color"), SNAME("Editor")); - theme_cache.warning_icon = get_theme_icon(SNAME("Warning"), SNAME("EditorIcons")); - theme_cache.message_color = get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, 0.6); - + _update_theme(); _rebuild_log(); } break; } diff --git a/editor/editor_log.h b/editor/editor_log.h index 0e17eb7949..43d7037414 100644 --- a/editor/editor_log.h +++ b/editor/editor_log.h @@ -175,6 +175,8 @@ private: void _save_state(); void _load_state(); + void _update_theme(); + protected: static void _bind_methods(); void _notification(int p_what); diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp index b8b6d57c08..a8f8f7ab97 100644 --- a/editor/editor_path.cpp +++ b/editor/editor_path.cpp @@ -182,6 +182,7 @@ void EditorPath::_id_pressed(int p_idx) { void EditorPath::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { update_path(); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index c3fd46c511..0e69c0e2f4 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -167,7 +167,8 @@ void EditorPropertyMultilineText::update_property() { void EditorPropertyMultilineText::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_THEME_CHANGED: { + case NOTIFICATION_THEME_CHANGED: + case NOTIFICATION_ENTER_TREE: { Ref<Texture2D> df = get_theme_icon(SNAME("DistractionFree"), SNAME("EditorIcons")); open_big_text->set_icon(df); @@ -321,6 +322,7 @@ void EditorPropertyTextEnum::_bind_methods() { void EditorPropertyTextEnum::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { edit_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); accept_button->set_icon(get_theme_icon(SNAME("ImportCheck"), SNAME("EditorIcons"))); @@ -402,6 +404,7 @@ void EditorPropertyLocale::setup(const String &p_hint_text) { void EditorPropertyLocale::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { locale_edit->set_icon(get_theme_icon(SNAME("Translation"), SNAME("EditorIcons"))); } break; @@ -497,6 +500,7 @@ void EditorPropertyPath::set_save_mode() { void EditorPropertyPath::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { path_edit->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } break; @@ -1149,6 +1153,7 @@ void EditorPropertyLayersGrid::_bind_methods() { void EditorPropertyLayers::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { button->set_normal_texture(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); button->set_pressed_texture(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); @@ -1672,7 +1677,8 @@ void EditorPropertyEasing::setup(bool p_positive_only, bool p_flip) { void EditorPropertyEasing::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_THEME_CHANGED: { + case NOTIFICATION_THEME_CHANGED: + case NOTIFICATION_ENTER_TREE: { preset->clear(); preset->add_icon_item(get_theme_icon(SNAME("CurveLinear"), SNAME("EditorIcons")), "Linear", EASING_LINEAR); preset->add_icon_item(get_theme_icon(SNAME("CurveIn"), SNAME("EditorIcons")), "Ease In", EASING_IN); @@ -1769,6 +1775,7 @@ void EditorPropertyVector2::_update_ratio() { void EditorPropertyVector2::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { linked->set_normal_texture(get_theme_icon(SNAME("Unlinked"), SNAME("EditorIcons"))); linked->set_pressed_texture(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); @@ -1878,6 +1885,7 @@ void EditorPropertyRect2::update_property() { void EditorPropertyRect2::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 4; i++) { @@ -2045,6 +2053,7 @@ Vector3 EditorPropertyVector3::get_vector() { void EditorPropertyVector3::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { linked->set_normal_texture(get_theme_icon(SNAME("Unlinked"), SNAME("EditorIcons"))); linked->set_pressed_texture(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); @@ -2179,6 +2188,7 @@ void EditorPropertyVector2i::_update_ratio() { void EditorPropertyVector2i::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { linked->set_normal_texture(get_theme_icon(SNAME("Unlinked"), SNAME("EditorIcons"))); linked->set_pressed_texture(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); @@ -2288,6 +2298,7 @@ void EditorPropertyRect2i::update_property() { void EditorPropertyRect2i::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 4; i++) { @@ -2428,6 +2439,7 @@ void EditorPropertyVector3i::_update_ratio() { void EditorPropertyVector3i::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { linked->set_normal_texture(get_theme_icon(SNAME("Unlinked"), SNAME("EditorIcons"))); linked->set_pressed_texture(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); @@ -2539,6 +2551,7 @@ void EditorPropertyPlane::update_property() { void EditorPropertyPlane::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 4; i++) { @@ -2692,6 +2705,7 @@ void EditorPropertyQuaternion::_warning_pressed() { void EditorPropertyQuaternion::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 4; i++) { @@ -2846,6 +2860,7 @@ void EditorPropertyVector4::update_property() { void EditorPropertyVector4::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 4; i++) { @@ -2937,6 +2952,7 @@ void EditorPropertyVector4i::update_property() { void EditorPropertyVector4i::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 4; i++) { @@ -3031,6 +3047,7 @@ void EditorPropertyAABB::update_property() { void EditorPropertyAABB::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 6; i++) { @@ -3113,6 +3130,7 @@ void EditorPropertyTransform2D::update_property() { void EditorPropertyTransform2D::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 6; i++) { @@ -3209,6 +3227,7 @@ void EditorPropertyBasis::update_property() { void EditorPropertyBasis::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 9; i++) { @@ -3306,6 +3325,7 @@ void EditorPropertyTransform3D::update_using_transform(Transform3D p_transform) void EditorPropertyTransform3D::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 12; i++) { @@ -3411,6 +3431,7 @@ void EditorPropertyProjection::update_using_transform(Projection p_transform) { void EditorPropertyProjection::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 16; i++) { @@ -3481,6 +3502,7 @@ void EditorPropertyColor::_picker_opening() { void EditorPropertyColor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { picker->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), SNAME("Editor")))); } break; @@ -3704,6 +3726,7 @@ void EditorPropertyNodePath::setup(const NodePath &p_base_hint, Vector<StringNam void EditorPropertyNodePath::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { Ref<Texture2D> t = get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")); clear->set_icon(t); @@ -4115,6 +4138,7 @@ void EditorPropertyResource::set_use_sub_inspector(bool p_enable) { void EditorPropertyResource::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { if (!updating_theme) { _update_property_bg(); diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index fa7e5cf4a9..f6953e8866 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -485,7 +485,8 @@ void EditorPropertyArray::drop_data_fw(const Point2 &p_point, const Variant &p_d void EditorPropertyArray::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_THEME_CHANGED: { + case NOTIFICATION_THEME_CHANGED: + case NOTIFICATION_ENTER_TREE: { change_type->clear(); for (int i = 0; i < Variant::VARIANT_MAX; i++) { if (i == Variant::CALLABLE || i == Variant::SIGNAL || i == Variant::RID) { @@ -1165,7 +1166,8 @@ void EditorPropertyDictionary::_object_id_selected(const StringName &p_property, void EditorPropertyDictionary::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_THEME_CHANGED: { + case NOTIFICATION_THEME_CHANGED: + case NOTIFICATION_ENTER_TREE: { change_type->clear(); for (int i = 0; i < Variant::VARIANT_MAX; i++) { if (i == Variant::CALLABLE || i == Variant::SIGNAL || i == Variant::RID) { @@ -1403,7 +1405,8 @@ void EditorPropertyLocalizableString::_object_id_selected(const StringName &p_pr void EditorPropertyLocalizableString::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_THEME_CHANGED: { + case NOTIFICATION_THEME_CHANGED: + case NOTIFICATION_ENTER_TREE: { if (Object::cast_to<Button>(button_add_item)) { button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); } diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 19c8ff2d9e..ce05026696 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -108,7 +108,7 @@ void EditorResourcePicker::_update_resource_preview(const String &p_path, const preview_rect->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED); int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size"); thumbnail_size *= EDSCALE; - assign_button->set_custom_minimum_size(Size2(MIN(1, assign_button_min_size.x), MIN(thumbnail_size, assign_button_min_size.y))); + assign_button->set_custom_minimum_size(Size2(MAX(1, assign_button_min_size.x), MAX(thumbnail_size, assign_button_min_size.y))); } preview_rect->set_texture(p_preview); @@ -762,8 +762,8 @@ void EditorResourcePicker::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { _update_resource(); - } break; - + [[fallthrough]]; + } case NOTIFICATION_THEME_CHANGED: { edit_button->set_icon(get_theme_icon(SNAME("select_arrow"), SNAME("Tree"))); } break; @@ -1038,6 +1038,7 @@ EditorShaderPicker::EditorShaderPicker() { void EditorAudioStreamPicker::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_READY: case NOTIFICATION_THEME_CHANGED: { _update_resource(); } break; diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index 128d90cd62..b9a3e9decf 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -431,6 +431,7 @@ void EditorSpinSlider::_draw_spin_slider() { void EditorSpinSlider::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { _update_value_input_stylebox(); } break; diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 827a657a31..d20caef51c 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -476,6 +476,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { const Color font_color = mono_color.lerp(base_color, 0.25); const Color font_hover_color = mono_color.lerp(base_color, 0.125); const Color font_focus_color = mono_color.lerp(base_color, 0.125); + const Color font_hover_pressed_color = font_hover_color.lerp(accent_color, 0.74); const Color font_disabled_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.3); const Color font_readonly_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.65); const Color font_placeholder_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.6); @@ -750,6 +751,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color", "MenuButton", font_color); theme->set_color("font_hover_color", "MenuButton", font_hover_color); + theme->set_color("font_hover_pressed_color", "MenuButton", font_hover_pressed_color); theme->set_color("font_focus_color", "MenuButton", font_focus_color); theme->set_stylebox("MenuHover", "EditorStyles", style_widget_hover); @@ -763,6 +765,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color", "Button", font_color); theme->set_color("font_hover_color", "Button", font_hover_color); + theme->set_color("font_hover_pressed_color", "Button", font_hover_pressed_color); theme->set_color("font_focus_color", "Button", font_focus_color); theme->set_color("font_pressed_color", "Button", accent_color); theme->set_color("font_disabled_color", "Button", font_disabled_color); @@ -815,6 +818,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color", "MenuBar", font_color); theme->set_color("font_hover_color", "MenuBar", font_hover_color); + theme->set_color("font_hover_pressed_color", "MenuBar", font_hover_pressed_color); theme->set_color("font_focus_color", "MenuBar", font_focus_color); theme->set_color("font_pressed_color", "MenuBar", accent_color); theme->set_color("font_disabled_color", "MenuBar", font_disabled_color); @@ -851,6 +855,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color", "OptionButton", font_color); theme->set_color("font_hover_color", "OptionButton", font_hover_color); + theme->set_color("font_hover_pressed_color", "OptionButton", font_hover_pressed_color); theme->set_color("font_focus_color", "OptionButton", font_focus_color); theme->set_color("font_pressed_color", "OptionButton", accent_color); theme->set_color("font_disabled_color", "OptionButton", font_disabled_color); @@ -885,6 +890,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color", "CheckButton", font_color); theme->set_color("font_hover_color", "CheckButton", font_hover_color); + theme->set_color("font_hover_pressed_color", "CheckButton", font_hover_pressed_color); theme->set_color("font_focus_color", "CheckButton", font_focus_color); theme->set_color("font_pressed_color", "CheckButton", accent_color); theme->set_color("font_disabled_color", "CheckButton", font_disabled_color); @@ -921,6 +927,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color", "CheckBox", font_color); theme->set_color("font_hover_color", "CheckBox", font_hover_color); + theme->set_color("font_hover_pressed_color", "CheckBox", font_hover_pressed_color); theme->set_color("font_focus_color", "CheckBox", font_focus_color); theme->set_color("font_pressed_color", "CheckBox", accent_color); theme->set_color("font_disabled_color", "CheckBox", font_disabled_color); @@ -1478,6 +1485,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("focus", "LinkButton", style_empty); theme->set_color("font_color", "LinkButton", font_color); theme->set_color("font_hover_color", "LinkButton", font_hover_color); + theme->set_color("font_hover_pressed_color", "LinkButton", font_hover_pressed_color); theme->set_color("font_focus_color", "LinkButton", font_focus_color); theme->set_color("font_pressed_color", "LinkButton", accent_color); theme->set_color("font_disabled_color", "LinkButton", font_disabled_color); @@ -1508,8 +1516,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { control_editor_popup_style->set_default_margin(SIDE_BOTTOM, default_margin_size * EDSCALE); control_editor_popup_style->set_border_width_all(0); - theme->set_stylebox("panel", "ControlEditorPopupButton", control_editor_popup_style); - theme->set_type_variation("ControlEditorPopupButton", "PopupPanel"); + theme->set_stylebox("panel", "ControlEditorPopupPanel", control_editor_popup_style); + theme->set_type_variation("ControlEditorPopupPanel", "PopupPanel"); // SpinBox theme->set_icon("updown", "SpinBox", theme->get_icon(SNAME("GuiSpinboxUpdown"), SNAME("EditorIcons"))); diff --git a/editor/editor_toaster.cpp b/editor/editor_toaster.cpp index 15a4464298..bb29b1c171 100644 --- a/editor/editor_toaster.cpp +++ b/editor/editor_toaster.cpp @@ -105,6 +105,7 @@ void EditorToaster::_notification(int p_what) { } } break; + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { if (vbox_container->is_visible()) { main_button->set_icon(get_theme_icon(SNAME("Notification"), SNAME("EditorIcons"))); diff --git a/editor/editor_zoom_widget.cpp b/editor/editor_zoom_widget.cpp index 512fa1c86c..e4beea5e5f 100644 --- a/editor/editor_zoom_widget.cpp +++ b/editor/editor_zoom_widget.cpp @@ -143,6 +143,7 @@ void EditorZoomWidget::set_zoom_by_increments(int p_increment_count, bool p_inte void EditorZoomWidget::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { zoom_minus->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); zoom_plus->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons"))); diff --git a/editor/export/export_template_manager.cpp b/editor/export/export_template_manager.cpp index ebcf60508a..a0afcf4237 100644 --- a/editor/export/export_template_manager.cpp +++ b/editor/export/export_template_manager.cpp @@ -754,6 +754,7 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_ void ExportTemplateManager::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { current_value->add_theme_font_override("font", get_theme_font(SNAME("main"), SNAME("EditorFonts"))); current_missing_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index 87721a2bbf..15add50fd4 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -380,6 +380,7 @@ void GroupDialog::_notification(int p_what) { switch (p_what) { case NOTIFICATION_TRANSLATION_CHANGED: case Control::NOTIFICATION_LAYOUT_DIRECTION_CHANGED: + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { if (is_layout_rtl()) { add_button->set_icon(groups->get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); diff --git a/editor/import/audio_stream_import_settings.cpp b/editor/import/audio_stream_import_settings.cpp index 843c076642..cc7c5809d6 100644 --- a/editor/import/audio_stream_import_settings.cpp +++ b/editor/import/audio_stream_import_settings.cpp @@ -42,7 +42,8 @@ void AudioStreamImportSettings::_notification(int p_what) { connect("confirmed", callable_mp(this, &AudioStreamImportSettings::_reimport)); } break; - case NOTIFICATION_THEME_CHANGED: { + case NOTIFICATION_THEME_CHANGED: + case NOTIFICATION_ENTER_TREE: { _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); _stop_button->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); _preview->set_color(get_theme_color(SNAME("dark_color_2"), SNAME("Editor"))); diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp index ad80ac1ca9..0575f3cbf3 100644 --- a/editor/import/dynamic_font_import_settings.cpp +++ b/editor/import/dynamic_font_import_settings.cpp @@ -876,6 +876,7 @@ void DynamicFontImportSettings::_notification(int p_what) { connect("confirmed", callable_mp(this, &DynamicFontImportSettings::_re_import)); } break; + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { add_var->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); } break; diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 02270e163f..4732268256 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -628,6 +628,9 @@ ImportDock::ImportDock() { content->add_margin_child(TTR("Import As:"), hb); import_as = memnew(OptionButton); import_as->set_disabled(true); + import_as->set_fit_to_longest_item(false); + import_as->set_text_overrun_behavior(TextServer::OVERRUN_TRIM_ELLIPSIS); + import_as->set_h_size_flags(SIZE_EXPAND_FILL); import_as->connect("item_selected", callable_mp(this, &ImportDock::_importer_selected)); hb->add_child(import_as); import_as->set_h_size_flags(SIZE_EXPAND_FILL); diff --git a/editor/node_dock.cpp b/editor/node_dock.cpp index e366f3ce3c..55fa2f22dd 100644 --- a/editor/node_dock.cpp +++ b/editor/node_dock.cpp @@ -53,6 +53,7 @@ void NodeDock::_bind_methods() { void NodeDock::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { connections_button->set_icon(get_theme_icon(SNAME("Signals"), SNAME("EditorIcons"))); groups_button->set_icon(get_theme_icon(SNAME("Groups"), SNAME("EditorIcons"))); diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index d17b88c2ce..c928b95642 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -151,6 +151,7 @@ void AbstractPolygon2DEditor::_menu_option(int p_option) { void AbstractPolygon2DEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { button_create->set_icon(get_theme_icon(SNAME("CurveCreate"), SNAME("EditorIcons"))); button_edit->set_icon(get_theme_icon(SNAME("CurveEdit"), SNAME("EditorIcons"))); diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index b8a1d2cb69..3b7829c37b 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -550,6 +550,7 @@ void AnimationNodeBlendSpace1DEditor::_open_editor() { void AnimationNodeBlendSpace1DEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index 918fca0e1c..d904ccb5e0 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -772,6 +772,7 @@ void AnimationNodeBlendSpace2DEditor::_edit_point_pos(double) { void AnimationNodeBlendSpace2DEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 11054ee11e..8dd3223b19 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -799,10 +799,16 @@ void AnimationNodeBlendTreeEditor::_update_editor_settings() { graph->set_warped_panning(bool(EditorSettings::get_singleton()->get("editors/panning/warped_mouse_panning"))); } +void AnimationNodeBlendTreeEditor::_update_theme() { + error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); +} + void AnimationNodeBlendTreeEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { _update_editor_settings(); + _update_theme(); } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { @@ -810,8 +816,7 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); - error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + _update_theme(); if (is_visible_in_tree()) { _update_graph(); diff --git a/editor/plugins/animation_blend_tree_editor_plugin.h b/editor/plugins/animation_blend_tree_editor_plugin.h index cdbf2975f2..30a54930a2 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.h +++ b/editor/plugins/animation_blend_tree_editor_plugin.h @@ -123,6 +123,7 @@ class AnimationNodeBlendTreeEditor : public AnimationTreeNodeEditorPlugin { void _removed_from_graph(); void _update_editor_settings(); + void _update_theme(); EditorFileDialog *open_file = nullptr; Ref<AnimationNode> file_loaded; diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index e47c5b1e4b..1ab60e8fc8 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -843,15 +843,16 @@ void AnimationPlayerEditor::_update_player() { animation->clear(); + tool_anim->set_disabled(player == nullptr); + pin->set_disabled(player == nullptr); + if (!player) { AnimationPlayerEditor::get_singleton()->get_track_editor()->update_keying(); return; } List<StringName> libraries; - if (player) { - player->get_animation_library_list(&libraries); - } + player->get_animation_library_list(&libraries); int active_idx = -1; bool no_anims_found = true; @@ -926,10 +927,8 @@ void AnimationPlayerEditor::_update_player() { frame->set_editable(!no_anims_found); animation->set_disabled(no_anims_found); autoplay->set_disabled(no_anims_found); - tool_anim->set_disabled(player == nullptr); onion_toggle->set_disabled(no_anims_found); onion_skinning->set_disabled(no_anims_found); - pin->set_disabled(player == nullptr); _update_animation_list_icons(); diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 07d132229d..be1e531cb8 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -1544,9 +1544,10 @@ void AnimationNodeStateMachineEditor::_update_graph() { void AnimationNodeStateMachineEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: - case NOTIFICATION_TRANSLATION_CHANGED: - case NOTIFICATION_THEME_CHANGED: { + case NOTIFICATION_TRANSLATION_CHANGED: { error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index bce4c9de8e..ed231c446b 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -59,10 +59,11 @@ void AnimationTreeEditor::edit(AnimationTree *p_tree) { Vector<String> path; if (tree && tree->has_meta("_tree_edit_path")) { path = tree->get_meta("_tree_edit_path"); - edit_path(path); } else { current_root = ObjectID(); } + + edit_path(path); } void AnimationTreeEditor::_path_button_pressed(int p_path) { @@ -129,6 +130,11 @@ void AnimationTreeEditor::edit_path(const Vector<String> &p_path) { } else { current_root = ObjectID(); edited_path = button_path; + + for (int i = 0; i < editors.size(); i++) { + editors[i]->edit(Ref<AnimationNode>()); + editors[i]->hide(); + } } _update_path(); diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 3c12d17c57..025312c38c 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -193,6 +193,7 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const void EditorAssetLibraryItemDescription::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { previews_bg->add_theme_style_override("panel", previews->get_theme_stylebox(SNAME("normal"), SNAME("TextEdit"))); } break; @@ -400,6 +401,7 @@ void EditorAssetLibraryItemDownload::configure(const String &p_title, int p_asse void EditorAssetLibraryItemDownload::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("AssetLib"))); status->add_theme_color_override("font_color", get_theme_color(SNAME("status_color"), SNAME("AssetLib"))); @@ -578,6 +580,7 @@ void EditorAssetLibrary::_notification(int p_what) { error_label->raise(); } break; + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { error_tr->set_texture(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); @@ -1592,7 +1595,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { /////// bool AssetLibraryEditorPlugin::is_available() { -#ifdef JAVASCRIPT_ENABLED +#ifdef WEB_ENABLED // Asset Library can't work on Web editor for now as most assets are sourced // directly from GitHub which does not set CORS. return false; diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 1ed37876f0..37c79d4974 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -5856,21 +5856,26 @@ Node *CanvasItemEditorViewport::_make_texture_node_type(String texture_node_type return node; } +void CanvasItemEditorViewport::_update_theme() { + List<BaseButton *> btn_list; + button_group->get_buttons(&btn_list); + + for (int i = 0; i < btn_list.size(); i++) { + CheckBox *check = Object::cast_to<CheckBox>(btn_list[i]); + check->set_icon(get_theme_icon(check->get_text(), SNAME("EditorIcons"))); + } + + label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); +} + void CanvasItemEditorViewport::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { - List<BaseButton *> btn_list; - button_group->get_buttons(&btn_list); - - for (int i = 0; i < btn_list.size(); i++) { - CheckBox *check = Object::cast_to<CheckBox>(btn_list[i]); - check->set_icon(get_theme_icon(check->get_text(), SNAME("EditorIcons"))); - } - - label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + _update_theme(); } break; case NOTIFICATION_ENTER_TREE: { + _update_theme(); connect("mouse_exited", callable_mp(this, &CanvasItemEditorViewport::_on_mouse_exit)); } break; diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index a4107c009e..0a840d6fd6 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -616,6 +616,7 @@ class CanvasItemEditorViewport : public Control { bool _create_instance(Node *parent, String &path, const Point2 &p_point); void _perform_drop_data(); void _show_resource_type_selector(); + void _update_theme(); static void _bind_methods(); diff --git a/editor/plugins/control_editor_plugin.cpp b/editor/plugins/control_editor_plugin.cpp index cee09edcc6..bb6092755e 100644 --- a/editor/plugins/control_editor_plugin.cpp +++ b/editor/plugins/control_editor_plugin.cpp @@ -102,6 +102,7 @@ void ControlPositioningWarning::gui_input(const Ref<InputEvent> &p_event) { void ControlPositioningWarning::_notification(int p_notification) { switch (p_notification) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: _update_warning(); _update_toggler(); @@ -491,6 +492,7 @@ void ControlEditorPopupButton::_popup_visibility_changed(bool p_visible) { void ControlEditorPopupButton::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { arrow_icon = get_theme_icon("select_arrow", "Tree"); } break; @@ -521,7 +523,7 @@ ControlEditorPopupButton::ControlEditorPopupButton() { set_focus_mode(FOCUS_NONE); popup_panel = memnew(PopupPanel); - popup_panel->set_theme_type_variation("ControlEditorPopupButton"); + popup_panel->set_theme_type_variation("ControlEditorPopupPanel"); add_child(popup_panel); popup_panel->connect("about_to_popup", callable_mp(this, &ControlEditorPopupButton::_popup_visibility_changed).bind(true)); popup_panel->connect("popup_hide", callable_mp(this, &ControlEditorPopupButton::_popup_visibility_changed).bind(false)); @@ -556,6 +558,7 @@ void AnchorPresetPicker::_preset_button_pressed(const int p_preset) { void AnchorPresetPicker::_notification(int p_notification) { switch (p_notification) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { preset_buttons[PRESET_TOP_LEFT]->set_icon(get_theme_icon(SNAME("ControlAlignTopLeft"), SNAME("EditorIcons"))); preset_buttons[PRESET_CENTER_TOP]->set_icon(get_theme_icon(SNAME("ControlAlignCenterTop"), SNAME("EditorIcons"))); @@ -664,6 +667,7 @@ void SizeFlagPresetPicker::set_allowed_flags(Vector<SizeFlags> &p_flags) { void SizeFlagPresetPicker::_notification(int p_notification) { switch (p_notification) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { if (vertical) { preset_buttons[SIZE_SHRINK_BEGIN]->set_icon(get_theme_icon(SNAME("ControlAlignCenterTop"), SNAME("EditorIcons"))); @@ -970,6 +974,7 @@ void ControlEditorToolbar::_selection_changed() { void ControlEditorToolbar::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { anchors_button->set_icon(get_theme_icon(SNAME("ControlLayout"), SNAME("EditorIcons"))); anchor_mode_button->set_icon(get_theme_icon(SNAME("Anchor"), SNAME("EditorIcons"))); diff --git a/editor/plugins/font_config_plugin.cpp b/editor/plugins/font_config_plugin.cpp index 9b03b3ae09..935b0a5501 100644 --- a/editor/plugins/font_config_plugin.cpp +++ b/editor/plugins/font_config_plugin.cpp @@ -152,6 +152,7 @@ bool EditorPropertyFontOTObject::_property_get_revert(const StringName &p_name, void EditorPropertyFontMetaOverride::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { if (Object::cast_to<Button>(button_add)) { button_add->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); @@ -379,6 +380,14 @@ EditorPropertyFontMetaOverride::EditorPropertyFontMetaOverride(bool p_script) { /* EditorPropertyOTVariation */ /*************************************************************************/ +void EditorPropertyOTVariation::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + } break; + } +} + void EditorPropertyOTVariation::_property_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing) { if (p_property.begins_with("keys")) { Dictionary dict = object->get_dict(); @@ -538,6 +547,7 @@ EditorPropertyOTVariation::EditorPropertyOTVariation() { void EditorPropertyOTFeatures::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { if (Object::cast_to<Button>(button_add)) { button_add->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); diff --git a/editor/plugins/font_config_plugin.h b/editor/plugins/font_config_plugin.h index ae138bab8f..41dde3cc59 100644 --- a/editor/plugins/font_config_plugin.h +++ b/editor/plugins/font_config_plugin.h @@ -139,6 +139,7 @@ class EditorPropertyOTVariation : public EditorProperty { EditorPaginator *paginator = nullptr; protected: + void _notification(int p_what); static void _bind_methods(){}; void _edit_pressed(); diff --git a/editor/plugins/gradient_texture_2d_editor_plugin.cpp b/editor/plugins/gradient_texture_2d_editor_plugin.cpp index 9ebca9fb31..5aaf450d3f 100644 --- a/editor/plugins/gradient_texture_2d_editor_plugin.cpp +++ b/editor/plugins/gradient_texture_2d_editor_plugin.cpp @@ -104,6 +104,7 @@ void GradientTexture2DEditorRect::set_snap_size(float p_snap_size) { void GradientTexture2DEditorRect::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { checkerboard->set_texture(get_theme_icon(SNAME("GuiMiniCheckerboard"), SNAME("EditorIcons"))); } break; @@ -213,6 +214,7 @@ void GradientTexture2DEditor::set_texture(Ref<GradientTexture2D> &p_texture) { void GradientTexture2DEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { reverse_button->set_icon(get_theme_icon(SNAME("ReverseGradient"), SNAME("EditorIcons"))); snap_button->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); diff --git a/editor/plugins/input_event_editor_plugin.cpp b/editor/plugins/input_event_editor_plugin.cpp index 6b323e0e57..153eab32d2 100644 --- a/editor/plugins/input_event_editor_plugin.cpp +++ b/editor/plugins/input_event_editor_plugin.cpp @@ -35,6 +35,7 @@ void InputEventConfigContainer::_bind_methods() { void InputEventConfigContainer::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { open_config_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); } break; diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index cc592e532c..f165b83999 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -7134,6 +7134,42 @@ void Node3DEditor::_add_environment_to_scene(bool p_already_added_sun) { undo_redo->commit_action(); } +void Node3DEditor::_update_theme() { + tool_button[TOOL_MODE_SELECT]->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + tool_button[TOOL_MODE_MOVE]->set_icon(get_theme_icon(SNAME("ToolMove"), SNAME("EditorIcons"))); + tool_button[TOOL_MODE_ROTATE]->set_icon(get_theme_icon(SNAME("ToolRotate"), SNAME("EditorIcons"))); + tool_button[TOOL_MODE_SCALE]->set_icon(get_theme_icon(SNAME("ToolScale"), SNAME("EditorIcons"))); + tool_button[TOOL_MODE_LIST_SELECT]->set_icon(get_theme_icon(SNAME("ListSelect"), SNAME("EditorIcons"))); + tool_button[TOOL_LOCK_SELECTED]->set_icon(get_theme_icon(SNAME("Lock"), SNAME("EditorIcons"))); + tool_button[TOOL_UNLOCK_SELECTED]->set_icon(get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons"))); + tool_button[TOOL_GROUP_SELECTED]->set_icon(get_theme_icon(SNAME("Group"), SNAME("EditorIcons"))); + tool_button[TOOL_UNGROUP_SELECTED]->set_icon(get_theme_icon(SNAME("Ungroup"), SNAME("EditorIcons"))); + + tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_icon(get_theme_icon(SNAME("Object"), SNAME("EditorIcons"))); + tool_option_button[TOOL_OPT_USE_SNAP]->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons"))); + tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_icon(get_theme_icon(SNAME("Camera3D"), SNAME("EditorIcons"))); + + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), get_theme_icon(SNAME("Panels1"), SNAME("EditorIcons"))); + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), get_theme_icon(SNAME("Panels2"), SNAME("EditorIcons"))); + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), get_theme_icon(SNAME("Panels2Alt"), SNAME("EditorIcons"))); + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), get_theme_icon(SNAME("Panels3"), SNAME("EditorIcons"))); + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), get_theme_icon(SNAME("Panels3Alt"), SNAME("EditorIcons"))); + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), get_theme_icon(SNAME("Panels4"), SNAME("EditorIcons"))); + + sun_button->set_icon(get_theme_icon(SNAME("DirectionalLight3D"), SNAME("EditorIcons"))); + environ_button->set_icon(get_theme_icon(SNAME("WorldEnvironment"), SNAME("EditorIcons"))); + sun_environ_settings->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + + sun_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window"))); + environ_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window"))); + + sun_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), SNAME("Editor")))); + environ_sky_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), SNAME("Editor")))); + environ_ground_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), SNAME("Editor")))); + + context_menu_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("ContextualToolbar"), SNAME("EditorStyles"))); +} + void Node3DEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { @@ -7156,6 +7192,7 @@ void Node3DEditor::_notification(int p_what) { } break; case NOTIFICATION_ENTER_TREE: { + _update_theme(); _register_all_gizmos(); _update_gizmos_menu(); _init_indicators(); @@ -7167,40 +7204,7 @@ void Node3DEditor::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - tool_button[TOOL_MODE_SELECT]->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); - tool_button[TOOL_MODE_MOVE]->set_icon(get_theme_icon(SNAME("ToolMove"), SNAME("EditorIcons"))); - tool_button[TOOL_MODE_ROTATE]->set_icon(get_theme_icon(SNAME("ToolRotate"), SNAME("EditorIcons"))); - tool_button[TOOL_MODE_SCALE]->set_icon(get_theme_icon(SNAME("ToolScale"), SNAME("EditorIcons"))); - tool_button[TOOL_MODE_LIST_SELECT]->set_icon(get_theme_icon(SNAME("ListSelect"), SNAME("EditorIcons"))); - tool_button[TOOL_LOCK_SELECTED]->set_icon(get_theme_icon(SNAME("Lock"), SNAME("EditorIcons"))); - tool_button[TOOL_UNLOCK_SELECTED]->set_icon(get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons"))); - tool_button[TOOL_GROUP_SELECTED]->set_icon(get_theme_icon(SNAME("Group"), SNAME("EditorIcons"))); - tool_button[TOOL_UNGROUP_SELECTED]->set_icon(get_theme_icon(SNAME("Ungroup"), SNAME("EditorIcons"))); - - tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_icon(get_theme_icon(SNAME("Object"), SNAME("EditorIcons"))); - tool_option_button[TOOL_OPT_USE_SNAP]->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons"))); - tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_icon(get_theme_icon(SNAME("Camera3D"), SNAME("EditorIcons"))); - - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), get_theme_icon(SNAME("Panels1"), SNAME("EditorIcons"))); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), get_theme_icon(SNAME("Panels2"), SNAME("EditorIcons"))); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), get_theme_icon(SNAME("Panels2Alt"), SNAME("EditorIcons"))); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), get_theme_icon(SNAME("Panels3"), SNAME("EditorIcons"))); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), get_theme_icon(SNAME("Panels3Alt"), SNAME("EditorIcons"))); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), get_theme_icon(SNAME("Panels4"), SNAME("EditorIcons"))); - - sun_button->set_icon(get_theme_icon(SNAME("DirectionalLight3D"), SNAME("EditorIcons"))); - environ_button->set_icon(get_theme_icon(SNAME("WorldEnvironment"), SNAME("EditorIcons"))); - sun_environ_settings->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); - - sun_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window"))); - environ_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window"))); - - sun_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), SNAME("Editor")))); - environ_sky_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), SNAME("Editor")))); - environ_ground_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), SNAME("Editor")))); - - context_menu_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("ContextualToolbar"), SNAME("EditorStyles"))); - + _update_theme(); _update_gizmos_menu_theme(); sun_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window"))); environ_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window"))); diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index e07374dd49..e0298ebd5f 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -778,6 +778,8 @@ private: void _add_sun_to_scene(bool p_already_added_environment = false); void _add_environment_to_scene(bool p_already_added_sun = false); + void _update_theme(); + protected: void _notification(int p_what); //void _gui_input(InputEvent p_event); diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp index 00b0a0b100..dc6dfd81c2 100644 --- a/editor/plugins/path_2d_editor_plugin.cpp +++ b/editor/plugins/path_2d_editor_plugin.cpp @@ -40,6 +40,7 @@ void Path2DEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { curve_edit->set_icon(get_theme_icon(SNAME("CurveEdit"), SNAME("EditorIcons"))); curve_edit_curve->set_icon(get_theme_icon(SNAME("CurveCurve"), SNAME("EditorIcons"))); diff --git a/editor/plugins/path_3d_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp index d5dbd24eac..1029b06638 100644 --- a/editor/plugins/path_3d_editor_plugin.cpp +++ b/editor/plugins/path_3d_editor_plugin.cpp @@ -563,6 +563,8 @@ void Path3DEditorPlugin::_notification(int p_what) { curve_edit->connect("pressed", callable_mp(this, &Path3DEditorPlugin::_mode_changed).bind(1)); curve_del->connect("pressed", callable_mp(this, &Path3DEditorPlugin::_mode_changed).bind(2)); curve_close->connect("pressed", callable_mp(this, &Path3DEditorPlugin::_close_curve)); + + _update_theme(); } break; case NOTIFICATION_READY: { diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index d414ff5143..b71cee8882 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -91,8 +91,8 @@ void Polygon2DEditor::_notification(int p_what) { uv_vscroll->set_anchors_and_offsets_preset(PRESET_RIGHT_WIDE); uv_hscroll->set_anchors_and_offsets_preset(PRESET_BOTTOM_WIDE); - } break; - + [[fallthrough]]; + } case NOTIFICATION_THEME_CHANGED: { uv_edit_draw->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); bone_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index 1d569b7c52..80566419b1 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -39,6 +39,7 @@ void ResourcePreloaderEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { load->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } break; diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp index 49196d6c79..de30c4100d 100644 --- a/editor/plugins/root_motion_editor_plugin.cpp +++ b/editor/plugins/root_motion_editor_plugin.cpp @@ -234,6 +234,7 @@ void EditorPropertyRootMotion::setup(const NodePath &p_base_hint) { void EditorPropertyRootMotion::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { Ref<Texture2D> t = get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")); clear->set_icon(t); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 1a692cffcc..98be34cb86 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -352,9 +352,9 @@ void ScriptEditorQuickOpen::_notification(int p_what) { connect("confirmed", callable_mp(this, &ScriptEditorQuickOpen::_confirmed)); search_box->set_clear_button_enabled(true); - } break; - - case NOTIFICATION_THEME_CHANGED: { + [[fallthrough]]; + } + case NOTIFICATION_VISIBILITY_CHANGED: { search_box->set_right_icon(search_options->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); } break; @@ -1613,8 +1613,8 @@ void ScriptEditor::_notification(int p_what) { EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &ScriptEditor::_editor_settings_changed)); EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &ScriptEditor::_filesystem_changed)); _editor_settings_changed(); - } break; - + [[fallthrough]]; + } case NOTIFICATION_TRANSLATION_CHANGED: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case NOTIFICATION_THEME_CHANGED: { diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 421b258f49..5e7db17edf 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1392,11 +1392,7 @@ void ScriptTextEditor::_change_syntax_highlighter(int p_idx) { void ScriptTextEditor::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - code_editor->get_text_editor()->set_gutter_width(connection_gutter, code_editor->get_text_editor()->get_line_height()); - } break; - - case NOTIFICATION_THEME_CHANGED: { + case NOTIFICATION_THEME_CHANGED: if (!editor_enabled) { break; } @@ -1404,6 +1400,9 @@ void ScriptTextEditor::_notification(int p_what) { _update_warnings(); _update_errors(); } + [[fallthrough]]; + case NOTIFICATION_ENTER_TREE: { + code_editor->get_text_editor()->set_gutter_width(connection_gutter, code_editor->get_text_editor()->get_line_height()); } break; } } diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index b4a0216e9f..53bc6fbdf4 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -712,6 +712,7 @@ void ShaderEditor::_menu_option(int p_option) { void ShaderEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { PopupMenu *popup = help_menu->get_popup(); popup->set_item_icon(popup->get_item_index(HELP_DOCS), get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons"))); diff --git a/editor/plugins/sprite_2d_editor_plugin.cpp b/editor/plugins/sprite_2d_editor_plugin.cpp index a493827d60..e45c907e86 100644 --- a/editor/plugins/sprite_2d_editor_plugin.cpp +++ b/editor/plugins/sprite_2d_editor_plugin.cpp @@ -506,6 +506,7 @@ void Sprite2DEditor::_debug_uv_draw() { void Sprite2DEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { options->set_icon(get_theme_icon(SNAME("Sprite2D"), SNAME("EditorIcons"))); diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 56da3c986e..87f0fc4ad0 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -408,6 +408,7 @@ void SpriteFramesEditor::_prepare_sprite_sheet(const String &p_file) { void SpriteFramesEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { load->set_icon(get_theme_icon(SNAME("Load"), SNAME("EditorIcons"))); load_sheet->set_icon(get_theme_icon(SNAME("SpriteSheet"), SNAME("EditorIcons"))); diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp index 6dbba3ced2..d4baff34e2 100644 --- a/editor/plugins/style_box_editor_plugin.cpp +++ b/editor/plugins/style_box_editor_plugin.cpp @@ -71,7 +71,15 @@ void StyleBoxPreview::_sb_changed() { void StyleBoxPreview::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { + if (!is_inside_tree()) { + // TODO: This is a workaround because `NOTIFICATION_THEME_CHANGED` + // is getting called for some reason when the `TexturePreview` is + // getting destroyed, which causes `get_theme_font()` to return `nullptr`. + // See https://github.com/godotengine/godot/issues/50743. + break; + } grid_preview->set_normal_texture(get_theme_icon(SNAME("StyleBoxGridInvisible"), SNAME("EditorIcons"))); grid_preview->set_pressed_texture(get_theme_icon(SNAME("StyleBoxGridVisible"), SNAME("EditorIcons"))); grid_preview->set_hover_texture(get_theme_icon(SNAME("StyleBoxGridVisible"), SNAME("EditorIcons"))); diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index 1b79527352..be382759f5 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -38,7 +38,16 @@ TextureRect *TexturePreview::get_texture_display() { void TexturePreview::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { + if (!is_inside_tree()) { + // TODO: This is a workaround because `NOTIFICATION_THEME_CHANGED` + // is getting called for some reason when the `TexturePreview` is + // getting destroyed, which causes `get_theme_font()` to return `nullptr`. + // See https://github.com/godotengine/godot/issues/50743. + break; + } + if (metadata_label) { Ref<Font> metadata_label_font = get_theme_font(SNAME("expression"), SNAME("EditorFonts")); metadata_label->add_theme_font_override("font", metadata_label_font); diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 1d0ae4d36f..50a7dc7f96 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -821,6 +821,7 @@ void TextureRegionEditor::_update_autoslice() { void TextureRegionEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { edit_draw->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); } break; diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index ac67965a6c..f6acd8ceda 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -38,6 +38,7 @@ #include "editor/editor_undo_redo_manager.h" #include "editor/progress_dialog.h" #include "scene/gui/color_picker.h" +#include "scene/theme/theme_db.h" void ThemeItemImportTree::_update_items_tree() { import_items_tree->clear(); @@ -839,6 +840,7 @@ bool ThemeItemImportTree::has_selected_items() const { void ThemeItemImportTree::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { select_icons_warning_icon->set_texture(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); select_icons_warning->add_theme_color_override("font_color", get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); @@ -1201,7 +1203,7 @@ void ThemeItemEditorDialog::_dialog_about_to_show() { _update_edit_types(); import_default_theme_items->set_edited_theme(edited_theme); - import_default_theme_items->set_base_theme(Theme::get_default()); + import_default_theme_items->set_base_theme(ThemeDB::get_singleton()->get_default_theme()); import_default_theme_items->reset_item_tree(); import_editor_theme_items->set_edited_theme(edited_theme); @@ -1213,7 +1215,7 @@ void ThemeItemEditorDialog::_dialog_about_to_show() { } void ThemeItemEditorDialog::_update_edit_types() { - Ref<Theme> base_theme = Theme::get_default(); + Ref<Theme> base_theme = ThemeDB::get_singleton()->get_default_theme(); List<StringName> theme_types; edited_theme->get_type_list(&theme_types); @@ -1629,7 +1631,7 @@ void ThemeItemEditorDialog::_remove_class_items() { Theme::DataType data_type = (Theme::DataType)dt; names.clear(); - Theme::get_default()->get_theme_item_list(data_type, edited_item_type, &names); + ThemeDB::get_singleton()->get_default_theme()->get_theme_item_list(data_type, edited_item_type, &names); for (const StringName &E : names) { if (new_snapshot->has_theme_item_nocheck(data_type, E, edited_item_type)) { new_snapshot->clear_theme_item(data_type, E, edited_item_type); @@ -1667,7 +1669,7 @@ void ThemeItemEditorDialog::_remove_custom_items() { names.clear(); new_snapshot->get_theme_item_list(data_type, edited_item_type, &names); for (const StringName &E : names) { - if (!Theme::get_default()->has_theme_item_nocheck(data_type, E, edited_item_type)) { + if (!ThemeDB::get_singleton()->get_default_theme()->has_theme_item_nocheck(data_type, E, edited_item_type)) { new_snapshot->clear_theme_item(data_type, E, edited_item_type); if (dt == Theme::DATA_TYPE_STYLEBOX && theme_type_editor->is_stylebox_pinned(edited_theme->get_stylebox(E, edited_item_type))) { @@ -1864,8 +1866,8 @@ 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)); - } break; - + [[fallthrough]]; + } case NOTIFICATION_THEME_CHANGED: { edit_items_add_color->set_icon(get_theme_icon(SNAME("Color"), SNAME("EditorIcons"))); edit_items_add_constant->set_icon(get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons"))); @@ -2128,7 +2130,7 @@ void ThemeTypeDialog::_update_add_type_options(const String &p_filter) { add_type_options->clear(); List<StringName> names; - Theme::get_default()->get_type_list(&names); + ThemeDB::get_singleton()->get_default_theme()->get_type_list(&names); if (include_own_types) { edited_theme->get_type_list(&names); } @@ -2193,8 +2195,8 @@ void ThemeTypeDialog::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { connect("about_to_popup", callable_mp(this, &ThemeTypeDialog::_dialog_about_to_show)); - } break; - + [[fallthrough]]; + } case NOTIFICATION_THEME_CHANGED: { _update_add_type_options(); } break; @@ -2369,7 +2371,7 @@ HashMap<StringName, bool> ThemeTypeEditor::_get_type_items(String p_type_name, v default_type = edited_theme->get_type_variation_base(p_type_name); } - (Theme::get_default().operator->()->*get_list_func)(default_type, &names); + (ThemeDB::get_singleton()->get_default_theme().operator->()->*get_list_func)(default_type, &names); names.sort_custom<StringName::AlphCompare>(); for (const StringName &E : names) { items[E] = false; @@ -2495,7 +2497,7 @@ void ThemeTypeEditor::_update_type_items() { item_editor->connect("color_changed", callable_mp(this, &ThemeTypeEditor::_color_item_changed).bind(E.key)); item_editor->get_popup()->connect("about_to_popup", callable_mp(EditorNode::get_singleton(), &EditorNode::setup_color_picker).bind(item_editor->get_picker())); } else { - item_editor->set_pick_color(Theme::get_default()->get_color(E.key, edited_type)); + item_editor->set_pick_color(ThemeDB::get_singleton()->get_default_theme()->get_color(E.key, edited_type)); item_editor->set_disabled(true); } @@ -2528,7 +2530,7 @@ void ThemeTypeEditor::_update_type_items() { item_editor->set_value(edited_theme->get_constant(E.key, edited_type)); item_editor->connect("value_changed", callable_mp(this, &ThemeTypeEditor::_constant_item_changed).bind(E.key)); } else { - item_editor->set_value(Theme::get_default()->get_constant(E.key, edited_type)); + item_editor->set_value(ThemeDB::get_singleton()->get_default_theme()->get_constant(E.key, edited_type)); item_editor->set_editable(false); } @@ -2562,8 +2564,8 @@ void ThemeTypeEditor::_update_type_items() { item_editor->connect("resource_selected", callable_mp(this, &ThemeTypeEditor::_edit_resource_item)); item_editor->connect("resource_changed", callable_mp(this, &ThemeTypeEditor::_font_item_changed).bind(E.key)); } else { - if (Theme::get_default()->has_font(E.key, edited_type)) { - item_editor->set_edited_resource(Theme::get_default()->get_font(E.key, edited_type)); + if (ThemeDB::get_singleton()->get_default_theme()->has_font(E.key, edited_type)) { + item_editor->set_edited_resource(ThemeDB::get_singleton()->get_default_theme()->get_font(E.key, edited_type)); } else { item_editor->set_edited_resource(Ref<Resource>()); } @@ -2599,7 +2601,7 @@ void ThemeTypeEditor::_update_type_items() { item_editor->set_value(edited_theme->get_font_size(E.key, edited_type)); item_editor->connect("value_changed", callable_mp(this, &ThemeTypeEditor::_font_size_item_changed).bind(E.key)); } else { - item_editor->set_value(Theme::get_default()->get_font_size(E.key, edited_type)); + item_editor->set_value(ThemeDB::get_singleton()->get_default_theme()->get_font_size(E.key, edited_type)); item_editor->set_editable(false); } @@ -2633,8 +2635,8 @@ void ThemeTypeEditor::_update_type_items() { item_editor->connect("resource_selected", callable_mp(this, &ThemeTypeEditor::_edit_resource_item)); item_editor->connect("resource_changed", callable_mp(this, &ThemeTypeEditor::_icon_item_changed).bind(E.key)); } else { - if (Theme::get_default()->has_icon(E.key, edited_type)) { - item_editor->set_edited_resource(Theme::get_default()->get_icon(E.key, edited_type)); + if (ThemeDB::get_singleton()->get_default_theme()->has_icon(E.key, edited_type)) { + item_editor->set_edited_resource(ThemeDB::get_singleton()->get_default_theme()->get_icon(E.key, edited_type)); } else { item_editor->set_edited_resource(Ref<Resource>()); } @@ -2713,8 +2715,8 @@ void ThemeTypeEditor::_update_type_items() { item_control->add_child(pin_leader_button); pin_leader_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_on_pin_leader_button_pressed).bind(item_editor, E.key)); } else { - if (Theme::get_default()->has_stylebox(E.key, edited_type)) { - item_editor->set_edited_resource(Theme::get_default()->get_stylebox(E.key, edited_type)); + if (ThemeDB::get_singleton()->get_default_theme()->has_stylebox(E.key, edited_type)) { + item_editor->set_edited_resource(ThemeDB::get_singleton()->get_default_theme()->get_stylebox(E.key, edited_type)); } else { item_editor->set_edited_resource(Ref<Resource>()); } @@ -2769,55 +2771,55 @@ void ThemeTypeEditor::_add_default_type_items() { { names.clear(); - Theme::get_default()->get_icon_list(default_type, &names); + ThemeDB::get_singleton()->get_default_theme()->get_icon_list(default_type, &names); for (const StringName &E : names) { if (!new_snapshot->has_icon(E, edited_type)) { - new_snapshot->set_icon(E, edited_type, Theme::get_default()->get_icon(E, edited_type)); + new_snapshot->set_icon(E, edited_type, ThemeDB::get_singleton()->get_default_theme()->get_icon(E, edited_type)); } } } { names.clear(); - Theme::get_default()->get_stylebox_list(default_type, &names); + ThemeDB::get_singleton()->get_default_theme()->get_stylebox_list(default_type, &names); for (const StringName &E : names) { if (!new_snapshot->has_stylebox(E, edited_type)) { - new_snapshot->set_stylebox(E, edited_type, Theme::get_default()->get_stylebox(E, edited_type)); + new_snapshot->set_stylebox(E, edited_type, ThemeDB::get_singleton()->get_default_theme()->get_stylebox(E, edited_type)); } } } { names.clear(); - Theme::get_default()->get_font_list(default_type, &names); + ThemeDB::get_singleton()->get_default_theme()->get_font_list(default_type, &names); for (const StringName &E : names) { if (!new_snapshot->has_font(E, edited_type)) { - new_snapshot->set_font(E, edited_type, Theme::get_default()->get_font(E, edited_type)); + new_snapshot->set_font(E, edited_type, ThemeDB::get_singleton()->get_default_theme()->get_font(E, edited_type)); } } } { names.clear(); - Theme::get_default()->get_font_size_list(default_type, &names); + ThemeDB::get_singleton()->get_default_theme()->get_font_size_list(default_type, &names); for (const StringName &E : names) { if (!new_snapshot->has_font_size(E, edited_type)) { - new_snapshot->set_font_size(E, edited_type, Theme::get_default()->get_font_size(E, edited_type)); + new_snapshot->set_font_size(E, edited_type, ThemeDB::get_singleton()->get_default_theme()->get_font_size(E, edited_type)); } } } { names.clear(); - Theme::get_default()->get_color_list(default_type, &names); + ThemeDB::get_singleton()->get_default_theme()->get_color_list(default_type, &names); for (const StringName &E : names) { if (!new_snapshot->has_color(E, edited_type)) { - new_snapshot->set_color(E, edited_type, Theme::get_default()->get_color(E, edited_type)); + new_snapshot->set_color(E, edited_type, ThemeDB::get_singleton()->get_default_theme()->get_color(E, edited_type)); } } } { names.clear(); - Theme::get_default()->get_constant_list(default_type, &names); + ThemeDB::get_singleton()->get_default_theme()->get_constant_list(default_type, &names); for (const StringName &E : names) { if (!new_snapshot->has_constant(E, edited_type)) { - new_snapshot->set_constant(E, edited_type, Theme::get_default()->get_constant(E, edited_type)); + new_snapshot->set_constant(E, edited_type, ThemeDB::get_singleton()->get_default_theme()->get_constant(E, edited_type)); } } } @@ -2894,11 +2896,11 @@ void ThemeTypeEditor::_item_override_cbk(int p_data_type, String p_item_name) { switch (p_data_type) { case Theme::DATA_TYPE_COLOR: { - ur->add_do_method(*edited_theme, "set_color", p_item_name, edited_type, Theme::get_default()->get_color(p_item_name, edited_type)); + ur->add_do_method(*edited_theme, "set_color", p_item_name, edited_type, ThemeDB::get_singleton()->get_default_theme()->get_color(p_item_name, edited_type)); ur->add_undo_method(*edited_theme, "clear_color", p_item_name, edited_type); } break; case Theme::DATA_TYPE_CONSTANT: { - ur->add_do_method(*edited_theme, "set_constant", p_item_name, edited_type, Theme::get_default()->get_constant(p_item_name, edited_type)); + ur->add_do_method(*edited_theme, "set_constant", p_item_name, edited_type, ThemeDB::get_singleton()->get_default_theme()->get_constant(p_item_name, edited_type)); ur->add_undo_method(*edited_theme, "clear_constant", p_item_name, edited_type); } break; case Theme::DATA_TYPE_FONT: { @@ -2906,7 +2908,7 @@ void ThemeTypeEditor::_item_override_cbk(int p_data_type, String p_item_name) { ur->add_undo_method(*edited_theme, "clear_font", p_item_name, edited_type); } break; case Theme::DATA_TYPE_FONT_SIZE: { - ur->add_do_method(*edited_theme, "set_font_size", p_item_name, edited_type, Theme::get_default()->get_font_size(p_item_name, edited_type)); + ur->add_do_method(*edited_theme, "set_font_size", p_item_name, edited_type, ThemeDB::get_singleton()->get_default_theme()->get_font_size(p_item_name, edited_type)); ur->add_undo_method(*edited_theme, "clear_font_size", p_item_name, edited_type); } break; case Theme::DATA_TYPE_ICON: { @@ -3301,6 +3303,7 @@ void ThemeTypeEditor::_add_type_dialog_selected(const String p_type_name) { void ThemeTypeEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { add_type_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); @@ -3593,6 +3596,7 @@ void ThemeEditor::_preview_control_picked(String p_class_name) { void ThemeEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { preview_tabs->add_theme_style_override("tab_selected", get_theme_stylebox(SNAME("ThemeEditorPreviewFG"), SNAME("EditorStyles"))); preview_tabs->add_theme_style_override("tab_unselected", get_theme_stylebox(SNAME("ThemeEditorPreviewBG"), SNAME("EditorStyles"))); diff --git a/editor/plugins/theme_editor_preview.cpp b/editor/plugins/theme_editor_preview.cpp index 41b4a4c407..ea8da1e86d 100644 --- a/editor/plugins/theme_editor_preview.cpp +++ b/editor/plugins/theme_editor_preview.cpp @@ -40,6 +40,7 @@ #include "scene/gui/color_picker.h" #include "scene/gui/progress_bar.h" #include "scene/resources/packed_scene.h" +#include "scene/theme/theme_db.h" constexpr double REFRESH_TIMER = 1.5; @@ -193,8 +194,8 @@ void ThemeEditorPreview::_notification(int p_what) { } connect("visibility_changed", callable_mp(this, &ThemeEditorPreview::_preview_visibility_changed)); - } break; - + [[fallthrough]]; + } case NOTIFICATION_THEME_CHANGED: { picker_button->set_icon(get_theme_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); @@ -240,7 +241,7 @@ ThemeEditorPreview::ThemeEditorPreview() { MarginContainer *preview_root = memnew(MarginContainer); preview_container->add_child(preview_root); - preview_root->set_theme(Theme::get_default()); + preview_root->set_theme(ThemeDB::get_singleton()->get_default_theme()); preview_root->set_clip_contents(true); preview_root->set_custom_minimum_size(Size2(450, 0) * EDSCALE); preview_root->set_v_size_flags(SIZE_EXPAND_FILL); @@ -272,6 +273,7 @@ ThemeEditorPreview::ThemeEditorPreview() { void DefaultThemeEditorPreview::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { test_color_picker_button->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), SNAME("Editor")))); } break; @@ -474,6 +476,7 @@ void SceneThemeEditorPreview::_reload_scene() { void SceneThemeEditorPreview::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { reload_scene_button->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); } break; diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index f6001e8972..73e07e6647 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -722,6 +722,7 @@ void GenericTilePolygonEditor::set_multiple_polygon_mode(bool p_multiple_polygon void GenericTilePolygonEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { button_create->set_icon(get_theme_icon(SNAME("CurveCreate"), SNAME("EditorIcons"))); button_edit->set_icon(get_theme_icon(SNAME("CurveEdit"), SNAME("EditorIcons"))); @@ -1167,6 +1168,7 @@ void TileDataDefaultEditor::setup_property_editor(Variant::Type p_type, String p void TileDataDefaultEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { picker_button->set_icon(get_theme_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); tile_bool_checked = get_theme_icon(SNAME("TileChecked"), SNAME("EditorIcons")); @@ -2565,6 +2567,7 @@ void TileDataTerrainsEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform void TileDataTerrainsEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { picker_button->set_icon(get_theme_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); } break; diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index 9e08d4cea7..556788f50c 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -2146,6 +2146,7 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() { // --- Bottom panel tiles --- tiles_bottom_panel = memnew(VBoxContainer); + tiles_bottom_panel->connect("tree_entered", callable_mp(this, &TileMapEditorTilesPlugin::_update_theme)); tiles_bottom_panel->connect("theme_changed", callable_mp(this, &TileMapEditorTilesPlugin::_update_theme)); tiles_bottom_panel->connect("visibility_changed", callable_mp(this, &TileMapEditorTilesPlugin::_stop_dragging)); tiles_bottom_panel->connect("visibility_changed", callable_mp(this, &TileMapEditorTilesPlugin::_tab_changed)); @@ -3310,6 +3311,7 @@ TileMapEditorTerrainsPlugin::TileMapEditorTerrainsPlugin() { undo_redo = EditorNode::get_undo_redo(); main_vbox_container = memnew(VBoxContainer); + main_vbox_container->connect("tree_entered", callable_mp(this, &TileMapEditorTerrainsPlugin::_update_theme)); main_vbox_container->connect("theme_changed", callable_mp(this, &TileMapEditorTerrainsPlugin::_update_theme)); main_vbox_container->set_name("Terrains"); @@ -3417,6 +3419,7 @@ TileMapEditorTerrainsPlugin::~TileMapEditorTerrainsPlugin() { void TileMapEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { missing_tile_texture = get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons")); warning_pattern_texture = get_theme_icon(SNAME("WarningPattern"), SNAME("EditorIcons")); diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index 098cf93721..46093469e3 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -2287,6 +2287,7 @@ void TileSetAtlasSourceEditor::_auto_remove_tiles() { void TileSetAtlasSourceEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { tool_setup_atlas_source_button->set_icon(get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); tool_select_button->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp index 302c34d8a5..dca17475e0 100644 --- a/editor/plugins/tiles/tile_set_editor.cpp +++ b/editor/plugins/tiles/tile_set_editor.cpp @@ -333,6 +333,7 @@ void TileSetEditor::_set_source_sort(int p_sort) { void TileSetEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { sources_delete_button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); sources_add_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); diff --git a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp index 40cdb243fe..9a4b14616f 100644 --- a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp @@ -329,6 +329,7 @@ void TileSetScenesCollectionSourceEditor::_update_scenes_list() { void TileSetScenesCollectionSourceEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { scene_tile_add_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); scene_tile_delete_button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 607f4a0db8..83341b3016 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -1716,6 +1716,7 @@ void VisualShaderEditor::_update_graph() { graph_plugin->clear_links(); graph_plugin->make_dirty(true); + graph_plugin->update_theme(); for (int n_i = 0; n_i < nodes.size(); n_i++) { graph_plugin->add_node(type, nodes[n_i]); @@ -3703,11 +3704,9 @@ void VisualShaderEditor::_notification(int p_what) { graph->get_panner()->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/sub_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning"))); graph->set_warped_panning(bool(EditorSettings::get_singleton()->get("editors/panning/warped_mouse_panning"))); - } break; - + [[fallthrough]]; + } case NOTIFICATION_THEME_CHANGED: { - graph_plugin->update_theme(); - highend_label->set_modulate(get_theme_color(SNAME("vulkan_color"), SNAME("Editor"))); node_filter->set_right_icon(Control::get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); @@ -3760,7 +3759,7 @@ void VisualShaderEditor::_notification(int p_what) { tools->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); - if (is_visible_in_tree()) { + if (p_what == NOTIFICATION_THEME_CHANGED && is_visible_in_tree()) { _update_graph(); } } break; @@ -5420,6 +5419,7 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("CurveTexture", "Textures", "Functions", "VisualShaderNodeCurveTexture", TTR("Perform the curve texture lookup."), {}, VisualShaderNode::PORT_TYPE_SCALAR)); curve_xyz_node_option_idx = add_options.size(); add_options.push_back(AddOption("CurveXYZTexture", "Textures", "Functions", "VisualShaderNodeCurveXYZTexture", TTR("Perform the three components curve texture lookup."), {}, VisualShaderNode::PORT_TYPE_VECTOR_3D)); + add_options.push_back(AddOption("LinearSceneDepth", "Textures", "Functions", "VisualShaderNodeLinearSceneDepth", TTR("Returns the depth value of the DEPTH_TEXTURE node in a linear space."), {}, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL)); texture2d_node_option_idx = add_options.size(); add_options.push_back(AddOption("Texture2D", "Textures", "Functions", "VisualShaderNodeTexture", TTR("Perform the 2D texture lookup."), {}, VisualShaderNode::PORT_TYPE_VECTOR_4D)); texture2d_array_node_option_idx = add_options.size(); @@ -5435,8 +5435,6 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("Texture2DArrayUniform", "Textures", "Variables", "VisualShaderNodeTexture2DArrayUniform", TTR("2D array of textures uniform lookup."), {}, VisualShaderNode::PORT_TYPE_SAMPLER)); add_options.push_back(AddOption("Texture3DUniform", "Textures", "Variables", "VisualShaderNodeTexture3DUniform", TTR("3D texture uniform lookup."), {}, VisualShaderNode::PORT_TYPE_SAMPLER)); - add_options.push_back(AddOption("LinearSceneDepth", "Textures", "Depth", "VisualShaderNodeLinearSceneDepth", TTR("Returns the depth value of the DEPTH_TEXTURE node in a linear space."), {}, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL)); - // TRANSFORM add_options.push_back(AddOption("TransformFunc", "Transform", "Common", "VisualShaderNodeTransformFunc", TTR("Transform function."), {}, VisualShaderNode::PORT_TYPE_TRANSFORM)); @@ -5461,6 +5459,13 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("TransformConstant", "Transform", "Variables", "VisualShaderNodeTransformConstant", TTR("Transform constant."), {}, VisualShaderNode::PORT_TYPE_TRANSFORM)); add_options.push_back(AddOption("TransformUniform", "Transform", "Variables", "VisualShaderNodeTransformUniform", TTR("Transform uniform."), {}, VisualShaderNode::PORT_TYPE_TRANSFORM)); + // UTILITY + + add_options.push_back(AddOption("DistanceFade", "Utility", "", "VisualShaderNodeDistanceFade", TTR("The distance fade effect fades out each pixel based on its distance to another object."), {}, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL)); + add_options.push_back(AddOption("ProximityFade", "Utility", "", "VisualShaderNodeProximityFade", TTR("The proximity fade effect fades out each pixel based on its distance to another object."), {}, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL)); + add_options.push_back(AddOption("RandomRange", "Utility", "", "VisualShaderNodeRandomRange", TTR("Returns a random value between the minimum and maximum input values."), {}, VisualShaderNode::PORT_TYPE_SCALAR)); + add_options.push_back(AddOption("Remap", "Utility", "", "VisualShaderNodeRemap", TTR("Remaps a given input from the input range to the output range."), {}, VisualShaderNode::PORT_TYPE_SCALAR)); + // VECTOR add_options.push_back(AddOption("VectorFunc", "Vector", "Common", "VisualShaderNodeVectorFunc", TTR("Vector function."), {}, VisualShaderNode::PORT_TYPE_VECTOR_3D)); @@ -5660,19 +5665,6 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("Vector4Constant", "Vector", "Variables", "VisualShaderNodeVec4Constant", TTR("4D vector constant."), {}, VisualShaderNode::PORT_TYPE_VECTOR_4D)); add_options.push_back(AddOption("Vector4Uniform", "Vector", "Variables", "VisualShaderNodeVec4Uniform", TTR("4D vector uniform."), {}, VisualShaderNode::PORT_TYPE_VECTOR_4D)); - // FADE - - add_options.push_back(AddOption("DistanceFace", "Fade", "Distance", "VisualShaderNodeDistanceFade", TTR(""), {}, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL)); - add_options.push_back(AddOption("ProximityFade", "Fade", "", "VisualShaderNodeProximityFade", TTR("The proximity fade effect fades out each pixel based on its distance to another object."), {}, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL)); - - // RANDOM - - add_options.push_back(AddOption("RandomRange", "Random", "", "VisualShaderNodeRandomRange", TTR("Returns a random value between the minimum and maximum input values."), {}, VisualShaderNode::PORT_TYPE_SCALAR)); - - // UTILITY - - add_options.push_back(AddOption("Remap", "Utility", "", "VisualShaderNodeRemap", TTR("Remaps a given input from the input range to the output range."), {}, VisualShaderNode::PORT_TYPE_SCALAR)); - // SPECIAL add_options.push_back(AddOption("Comment", "Special", "", "VisualShaderNodeComment", TTR("A rectangular area with a description string for better graph organization."))); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index a17a759c17..6623792fc0 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -2106,7 +2106,7 @@ void ProjectManager::_confirm_update_settings() { void ProjectManager::_open_selected_projects() { // Show loading text to tell the user that the project manager is busy loading. - // This is especially important for the HTML5 project manager. + // This is especially important for the Web project manager. loading_label->show(); const HashSet<String> &selected_list = _project_list->get_selected_project_keys(); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 279ed55a38..581315d512 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -518,6 +518,24 @@ void ProjectSettingsEditor::_update_action_map_editor() { action_map_editor->update_action_list(actions); } +void ProjectSettingsEditor::_update_theme() { + search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + restart_close_button->set_icon(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + restart_container->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + restart_icon->set_texture(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); + restart_label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + + type_box->clear(); + for (int i = 0; i < Variant::VARIANT_MAX; i++) { + if (i == Variant::NIL || i == Variant::OBJECT || i == Variant::CALLABLE || i == Variant::SIGNAL || i == Variant::RID) { + // These types can't be serialized properly, so skip them. + continue; + } + String type = Variant::get_type_name(Variant::Type(i)); + type_box->add_icon_item(get_theme_icon(type, SNAME("EditorIcons")), type, i); + } +} + void ProjectSettingsEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_VISIBILITY_CHANGED: { @@ -529,24 +547,11 @@ void ProjectSettingsEditor::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { general_settings_inspector->edit(ps); _update_action_map_editor(); + _update_theme(); } break; case NOTIFICATION_THEME_CHANGED: { - search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - restart_close_button->set_icon(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); - restart_container->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); - restart_icon->set_texture(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); - restart_label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); - - type_box->clear(); - for (int i = 0; i < Variant::VARIANT_MAX; i++) { - if (i == Variant::NIL || i == Variant::OBJECT || i == Variant::CALLABLE || i == Variant::SIGNAL || i == Variant::RID) { - // These types can't be serialized properly, so skip them. - continue; - } - String type = Variant::get_type_name(Variant::Type(i)); - type_box->add_icon_item(get_theme_icon(type, SNAME("EditorIcons")), type, i); - } + _update_theme(); } break; } } diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h index f01f5c1836..040d992e40 100644 --- a/editor/project_settings_editor.h +++ b/editor/project_settings_editor.h @@ -106,6 +106,7 @@ class ProjectSettingsEditor : public AcceptDialog { void _action_renamed(const String &p_old_name, const String &p_new_name); void _action_reordered(const String &p_action_name, const String &p_relative_to, bool p_before); void _update_action_map_editor(); + void _update_theme(); protected: void _notification(int p_what); diff --git a/editor/scene_create_dialog.cpp b/editor/scene_create_dialog.cpp index 30a41eea7a..94a5c07709 100644 --- a/editor/scene_create_dialog.cpp +++ b/editor/scene_create_dialog.cpp @@ -46,6 +46,7 @@ void SceneCreateDialog::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { select_node_button->set_icon(get_theme_icon(SNAME("ClassList"), SNAME("EditorIcons"))); node_type_2d->set_icon(get_theme_icon(SNAME("Node2D"), SNAME("EditorIcons"))); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index c7c713fc67..f6ecaad67b 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1068,24 +1068,61 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } } break; case TOOL_TOGGLE_SCENE_UNIQUE_NAME: { - List<Node *> selection = editor_selection->get_selected_node_list(); - List<Node *>::Element *e = selection.front(); - if (e) { - Ref<EditorUndoRedoManager> undo_redo = editor_data->get_undo_redo(); - Node *node = e->get(); - bool enabled = node->is_unique_name_in_owner(); - if (!enabled && get_tree()->get_edited_scene_root()->get_node_or_null(UNIQUE_NODE_PREFIX + String(node->get_name())) != nullptr) { - accept->set_text(TTR("Another node already uses this unique name in the scene.")); + // Enabling/disabling based on the same node based on which the checkbox in the menu is checked/unchecked. + List<Node *>::Element *first_selected = editor_selection->get_selected_node_list().front(); + if (first_selected == nullptr) { + return; + } + bool enabling = !first_selected->get()->is_unique_name_in_owner(); + + List<Node *> full_selection = editor_selection->get_full_selected_node_list(); + Ref<EditorUndoRedoManager> undo_redo = editor_data->get_undo_redo(); + + if (enabling) { + Vector<Node *> new_unique_nodes; + Vector<StringName> new_unique_names; + Vector<StringName> cant_be_set_unique_names; + + for (Node *node : full_selection) { + if (node->is_unique_name_in_owner()) { + continue; + } + StringName name = node->get_name(); + if (new_unique_names.find(name) != -1 || get_tree()->get_edited_scene_root()->get_node_or_null(UNIQUE_NODE_PREFIX + String(name)) != nullptr) { + cant_be_set_unique_names.push_back(name); + } else { + new_unique_nodes.push_back(node); + new_unique_names.push_back(name); + } + } + + if (new_unique_nodes.size()) { + undo_redo->create_action(TTR("Enable Scene Unique Name(s)")); + for (Node *node : new_unique_nodes) { + undo_redo->add_do_method(node, "set_unique_name_in_owner", true); + undo_redo->add_undo_method(node, "set_unique_name_in_owner", false); + } + undo_redo->commit_action(); + } + + if (cant_be_set_unique_names.size()) { + String popup_text = TTR("Unique names already used by another node in the scene:"); + popup_text += "\n"; + for (StringName name : cant_be_set_unique_names) { + popup_text += "\n" + String(name); + } + accept->set_text(popup_text); accept->popup_centered(); - return; } - if (!enabled) { - undo_redo->create_action(TTR("Enable Scene Unique Name")); - } else { - undo_redo->create_action(TTR("Disable Scene Unique Name")); + } else { // Disabling. + undo_redo->create_action(TTR("Disable Scene Unique Name(s)")); + for (Node *node : full_selection) { + if (!node->is_unique_name_in_owner()) { + continue; + } + undo_redo->add_do_method(node, "set_unique_name_in_owner", false); + undo_redo->add_undo_method(node, "set_unique_name_in_owner", true); } - undo_redo->add_do_method(node, "set_unique_name_in_owner", !enabled); - undo_redo->add_undo_method(node, "set_unique_name_in_owner", enabled); undo_redo->commit_action(); } } break; @@ -2821,14 +2858,26 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_separator(); menu->add_icon_shortcut(get_theme_icon(SNAME("CopyNodePath"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/copy_node_path"), TOOL_COPY_NODE_PATH); } + } - if (selection[0]->get_owner() == EditorNode::get_singleton()->get_edited_scene()) { - // Only for nodes owned by the edited scene root. + if (profile_allow_editing) { + // Allow multi-toggling scene unique names but only if all selected nodes are owned by the edited scene root. + bool all_owned = true; + for (Node *node : full_selection) { + if (node->get_owner() != EditorNode::get_singleton()->get_edited_scene()) { + all_owned = false; + break; + } + } + if (all_owned) { menu->add_separator(); menu->add_icon_check_item(get_theme_icon(SNAME("SceneUniqueName"), SNAME("EditorIcons")), TTR("Access as Scene Unique Name"), TOOL_TOGGLE_SCENE_UNIQUE_NAME); + // Checked based on `selection[0]` because `full_selection` has undesired ordering. menu->set_item_checked(menu->get_item_index(TOOL_TOGGLE_SCENE_UNIQUE_NAME), selection[0]->is_unique_name_in_owner()); } + } + if (selection.size() == 1) { bool is_external = (!selection[0]->get_scene_file_path().is_empty()); if (is_external) { bool is_inherited = selection[0]->get_scene_inherited_state() != nullptr; diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 7b0c68fb6b..00fd0c3aac 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -1345,6 +1345,10 @@ void SceneTreeDialog::popup_scenetree_dialog() { popup_centered_clamped(Size2(350, 700) * EDSCALE); } +void SceneTreeDialog::_update_theme() { + filter->set_right_icon(tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); +} + void SceneTreeDialog::_notification(int p_what) { switch (p_what) { case NOTIFICATION_VISIBILITY_CHANGED: { @@ -1355,10 +1359,11 @@ void SceneTreeDialog::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { connect("confirmed", callable_mp(this, &SceneTreeDialog::_select)); + _update_theme(); } break; case NOTIFICATION_THEME_CHANGED: { - filter->set_right_icon(tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + _update_theme(); } break; case NOTIFICATION_EXIT_TREE: { diff --git a/editor/scene_tree_editor.h b/editor/scene_tree_editor.h index f3ca0347ea..0c13ad96cd 100644 --- a/editor/scene_tree_editor.h +++ b/editor/scene_tree_editor.h @@ -179,6 +179,7 @@ class SceneTreeDialog : public ConfirmationDialog { void _cancel(); void _selected_changed(); void _filter_changed(const String &p_filter); + void _update_theme(); protected: void _notification(int p_what); diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 28790f2711..15e992ce18 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -120,8 +120,9 @@ void ScriptCreateDialog::_notification(int p_what) { } else { language_menu->select(default_language); } - } break; + [[fallthrough]]; + } case NOTIFICATION_THEME_CHANGED: { for (int i = 0; i < ScriptServer::get_language_count(); i++) { Ref<Texture2D> language_icon = get_theme_icon(ScriptServer::get_language(i)->get_type(), SNAME("EditorIcons")); diff --git a/editor/shader_create_dialog.cpp b/editor/shader_create_dialog.cpp index fc7fff325c..8c4a231e8a 100644 --- a/editor/shader_create_dialog.cpp +++ b/editor/shader_create_dialog.cpp @@ -47,6 +47,8 @@ enum ShaderType { void ShaderCreateDialog::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { + _update_theme(); + String last_lang = EditorSettings::get_singleton()->get_project_metadata("shader_setup", "last_selected_language", ""); if (!last_lang.is_empty()) { for (int i = 0; i < type_menu->get_item_count(); i++) { @@ -65,25 +67,29 @@ void ShaderCreateDialog::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - Ref<Texture2D> shader_icon = gc->get_theme_icon(SNAME("Shader"), SNAME("EditorIcons")); - if (shader_icon.is_valid()) { - type_menu->set_item_icon(0, shader_icon); - } + _update_theme(); + } break; + } +} - Ref<Texture2D> visual_shader_icon = gc->get_theme_icon(SNAME("VisualShader"), SNAME("EditorIcons")); - if (visual_shader_icon.is_valid()) { - type_menu->set_item_icon(1, visual_shader_icon); - } +void ShaderCreateDialog::_update_theme() { + Ref<Texture2D> shader_icon = gc->get_theme_icon(SNAME("Shader"), SNAME("EditorIcons")); + if (shader_icon.is_valid()) { + type_menu->set_item_icon(0, shader_icon); + } - Ref<Texture2D> include_icon = gc->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); - if (include_icon.is_valid()) { - type_menu->set_item_icon(2, include_icon); - } + Ref<Texture2D> visual_shader_icon = gc->get_theme_icon(SNAME("VisualShader"), SNAME("EditorIcons")); + if (visual_shader_icon.is_valid()) { + type_menu->set_item_icon(1, visual_shader_icon); + } - path_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); - status_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); - } break; + Ref<Texture2D> include_icon = gc->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); + if (include_icon.is_valid()) { + type_menu->set_item_icon(2, include_icon); } + + path_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); + status_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); } void ShaderCreateDialog::_update_language_info() { diff --git a/editor/shader_create_dialog.h b/editor/shader_create_dialog.h index 9496d0ce9e..9ba655369b 100644 --- a/editor/shader_create_dialog.h +++ b/editor/shader_create_dialog.h @@ -98,6 +98,7 @@ class ShaderCreateDialog : public ConfirmationDialog { void _update_dialog(); protected: + void _update_theme(); void _notification(int p_what); static void _bind_methods(); |