Merge pull request #78005 from Sauermann/fix-some-simplifications

Some code simplifications
This commit is contained in:
Rémi Verschelde 2023-06-09 11:06:26 +02:00
commit b083c1dbf5
No known key found for this signature in database
GPG Key ID: C3336907360768E1
4 changed files with 9 additions and 22 deletions

View File

@ -820,9 +820,7 @@ void AnimationNodeBlendSpace2DEditor::_notification(int p_what) {
String error; String error;
if (!tree) { if (!tree->is_active()) {
error = TTR("BlendSpace2D does not belong to an AnimationTree node.");
} else if (!tree->is_active()) {
error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails."); error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails.");
} else if (tree->is_state_invalid()) { } else if (tree->is_state_invalid()) {
error = tree->get_invalid_state_reason(); error = tree->get_invalid_state_reason();

View File

@ -860,7 +860,7 @@ void CurveEdit::_redraw() {
const Color selected_point_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); const Color selected_point_color = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
// Draw tangents if not dragging a point, or if holding a point without having moved it yet. // Draw tangents if not dragging a point, or if holding a point without having moved it yet.
if (grabbing == GRAB_NONE || (grabbing != GRAB_NONE && (initial_grab_pos == point_pos || selected_tangent_index != TANGENT_NONE))) { if (grabbing == GRAB_NONE || initial_grab_pos == point_pos || selected_tangent_index != TANGENT_NONE) {
const Color selected_tangent_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")).darkened(0.25); const Color selected_tangent_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")).darkened(0.25);
const Color tangent_color = get_theme_color(SNAME("font_color"), SNAME("Editor")).darkened(0.25); const Color tangent_color = get_theme_color(SNAME("font_color"), SNAME("Editor")).darkened(0.25);

View File

@ -213,8 +213,8 @@ void GradientTexture2DEdit::_draw() {
// Draw handles. // Draw handles.
const Color focus_modulate = Color(0.5, 1, 2); const Color focus_modulate = Color(0.5, 1, 2);
bool modulate_handle_from = grabbed == HANDLE_FROM || (grabbed != HANDLE_FROM && hovered == HANDLE_FROM); bool modulate_handle_from = grabbed == HANDLE_FROM || hovered == HANDLE_FROM;
bool modulate_handle_to = grabbed == HANDLE_TO || (grabbed != HANDLE_TO && hovered == HANDLE_TO); bool modulate_handle_to = grabbed == HANDLE_TO || hovered == HANDLE_TO;
draw_texture(fill_from_icon, (_get_handle_pos(HANDLE_FROM) - handle_size / 2).round(), modulate_handle_from ? focus_modulate : Color(1, 1, 1)); draw_texture(fill_from_icon, (_get_handle_pos(HANDLE_FROM) - handle_size / 2).round(), modulate_handle_from ? focus_modulate : Color(1, 1, 1));
draw_texture(fill_to_icon, (_get_handle_pos(HANDLE_TO) - handle_size / 2).round(), modulate_handle_to ? focus_modulate : Color(1, 1, 1)); draw_texture(fill_to_icon, (_get_handle_pos(HANDLE_TO) - handle_size / 2).round(), modulate_handle_to ? focus_modulate : Color(1, 1, 1));
} }

View File

@ -370,7 +370,6 @@ void Viewport::_sub_window_grab_focus(Window *p_window) {
SubWindow sw = gui.sub_windows[index]; SubWindow sw = gui.sub_windows[index];
gui.sub_windows.remove_at(index); gui.sub_windows.remove_at(index);
gui.sub_windows.push_back(sw); gui.sub_windows.push_back(sw);
index = gui.sub_windows.size() - 1;
_sub_window_update_order(); _sub_window_update_order();
return; return;
} }
@ -1758,6 +1757,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
gui.drag_attempted = false; gui.drag_attempted = false;
} }
} }
DEV_ASSERT(gui.mouse_focus);
mb = mb->xformed_by(Transform2D()); // Make a copy of the event. mb = mb->xformed_by(Transform2D()); // Make a copy of the event.
@ -1765,7 +1765,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
mb->set_position(pos); mb->set_position(pos);
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (EngineDebugger::get_singleton() && gui.mouse_focus) { if (EngineDebugger::get_singleton()) {
Array arr; Array arr;
arr.push_back(gui.mouse_focus->get_path()); arr.push_back(gui.mouse_focus->get_path());
arr.push_back(gui.mouse_focus->get_class()); arr.push_back(gui.mouse_focus->get_class());
@ -1798,10 +1798,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
} }
} }
bool stopped = false; bool stopped = gui.mouse_focus->can_process() && _gui_call_input(gui.mouse_focus, mb);
if (gui.mouse_focus && gui.mouse_focus->can_process()) {
stopped = _gui_call_input(gui.mouse_focus, mb);
}
if (stopped) { if (stopped) {
set_input_as_handled(); set_input_as_handled();
@ -1839,11 +1836,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
gui.forced_mouse_focus = false; gui.forced_mouse_focus = false;
} }
bool stopped = false; bool stopped = mouse_focus && mouse_focus->can_process() && _gui_call_input(mouse_focus, mb);
if (mouse_focus && mouse_focus->can_process()) {
stopped = _gui_call_input(mouse_focus, mb);
}
if (stopped) { if (stopped) {
set_input_as_handled(); set_input_as_handled();
} }
@ -2002,11 +1995,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
ds_cursor_shape = (DisplayServer::CursorShape)cursor_shape; ds_cursor_shape = (DisplayServer::CursorShape)cursor_shape;
bool stopped = false; bool stopped = over->can_process() && _gui_call_input(over, mm);
if (over && over->can_process()) {
stopped = _gui_call_input(over, mm);
}
if (stopped) { if (stopped) {
set_input_as_handled(); set_input_as_handled();
} }