Commit Graph

814 Commits

Author SHA1 Message Date
Markus Sauermann d259f979f5 Fix mouse entered notifications
Make sure, that a windows initial state is `mouse_in_viewport = false`.
This makes sure, that the mouse entered notification is sent when the
mouse hovers a window for the first time.

For embedded Windows, `NOTIFICATION_WM_MOUSE_ENTER` is currently sent
twice in a row. Remove one of the places where it is sent.
`Window::_update_mouse_over()` is the correct one, because there it is
also called for native windows.
2024-02-29 00:57:31 +01:00
Michael Alexsander d70c45b5c8
Add option to add built-in strings in the POT generation 2024-02-28 11:34:26 -03:00
smix8 35dafc9fa8 Split monolithic physics class files
Splits monolithic physics class files.
2024-02-27 11:18:16 +01:00
stoofin b6c033fc39 Add all Viewport.debug_draw enum options to dropdown 2024-02-23 23:55:01 -08:00
A Thousand Ships 3a707b1f54
Fix some additional errors with 3D disabled
* Disabled 2D navigation tests as they do not work
* Disabled tests for primitive meshes
* Unbound some `Mesh` methods that rely on 3D resources
* Unexposed `World3D` as it depends on physics (and isn't useful)
* Unexposed some `Viewport` vrs related properties that had unexposed
  methods
2024-02-23 20:58:56 +01:00
Markus Sauermann 8de39911c8 Fix global position for `InputEventMouse` in `viewport::push_input`
Global position doesn't get adjusted within `InputEventMouse::xformed_by()`.
2024-02-18 03:26:09 +01:00
Rémi Verschelde 21f0529aa9
Revert "Update Node::get_configuration_warnings signature"
This reverts commit d3852deaa4.
2024-02-17 19:03:21 +01:00
Michael Alexsander 7b42c24550
Make auto translation inheritable 2024-02-15 16:51:19 -03:00
Silc Lizard (Tokage) Renew 67e38709fd Avoid unqualified-id "near" and "far" in Node3DEditor/Viewport 2024-02-13 18:53:21 +09:00
Rémi Verschelde 5306b917e6
Merge pull request #87164 from 0x0ACB/camera_fix
Rename camera `near` and `far` private members to avoid conflict with `Windows.h` defines
2024-02-12 23:29:22 +01:00
Rémi Verschelde 2b36dcf70a
Merge pull request #75688 from mnemoli/pickone
Add setting for picking only top-most overlapping collision object
2024-02-12 13:33:08 +01:00
RedMser d3852deaa4 Update Node::get_configuration_warnings signature 2024-02-08 23:05:20 +01:00
Markus Sauermann 36c2c4bf0d Remove unused Variable `Viewport::gui_input_group`
The gui input group is not needed during the gui input step.
2024-01-26 23:37:30 +01:00
Yuri Sizov 91ac53ec1b Merge pull request #87385 from Sauermann/fix-subviewport-physics-picking
Fix SubViewport physics picking
2024-01-25 16:27:02 +01:00
Yuri Sizov e0f8cf4acb Merge pull request #77730 from Jummit/fix-subviewport-1
Fix `push_input` events not going through after first pressed mouse event
2024-01-22 20:38:22 +01:00
Markus Sauermann 7b00c136a1 Fix SubViewport physics picking
Apply the logic of `handle_input_locally` for physics picking.
2024-01-19 21:42:41 +01:00
ACB 96b8016a35 Rename camera near and far private members to avoid conflict with Windows.h defines 2024-01-15 12:31:15 +01:00
mnemoli a407219693 Add Viewport setting for picking only first-encountered CanvasItem physics object 2024-01-11 14:18:37 +00:00
kobewi 0e8f90f4c8 Update deferred calls to use Callables 2024-01-09 16:11:47 +01:00
Rémi Verschelde 0d922f61e3
Merge pull request #86220 from Sauermann/fix-embed-subwindow
Fix changing `gui_embed_subwindows` while a child window is displayed
2024-01-03 10:13:03 +01:00
Markus Sauermann 62587d2d19 Fix changing `gui_embed_subwindows` while a child window is displayed
Changing `gui_embed_subwindows` while a child window is displayed can lead
to crashes or other unintended behavior.
This PR adds checks to prevent the change while child windows are
displayed.
2024-01-03 10:09:51 +01:00
Markus Sauermann 4b6516c843 Fix D&D viewport position calculation
It is necessary to transform screen position to viewport position.
2023-12-25 23:32:29 +01:00
Claire Blackshaw fe7725239e Expose a method to get hovered Control in Viewport 2023-12-18 14:53:52 +01:00
Jummit 7957354091 Fix push_input only working the first time
Subviewports didn't update their parent's local_input_handled correctly.

Fixes #76439.
2023-12-02 20:30:26 +01:00
kit 78e1702adb fix crash on hiding grandparent on mouse exit 2023-12-02 14:24:56 -05:00
Markus Sauermann 3de9afc4a9 Fix crash when hiding a Control during mouse-entering
gui.mouse_over can be set to `nullptr` in the `NOTIFICATION_MOUSE_ENTER`-
user-callback a few lines above. This case was previously not handled.
2023-11-23 23:25:00 +01:00
kit d24d73ba31 Make mouse-enter/exit notifications match mouse event propagation
`NOTIFICATION_MOUSE_ENTER` and `NOTIFICATION_MOUSE_EXIT` now includes
the areas of children control nodes if the mouse filters allow it.

In order to check if a Control node itself was entered/exited, the newly
introduced `NOTIFICATION_MOUSE_ENTER_SELF` and
`NOTIFICATION_MOUSE_EXIT_SELF` can be used.

Co-authored-by: Markus Sauermann <6299227+Sauermann@users.noreply.github.com>
2023-11-09 09:11:59 -05:00
clayjohn f672198f5e Revert "Add a Disable 2D property to Viewport"
This reverts commit f6cc2603a1.
2023-10-27 14:45:59 +02:00
Rémi Verschelde a1d7c62df7
Merge pull request #83003 from AThousandShips/null_check_extra
Replace `ERR_FAIL_COND` with `ERR_FAIL_NULL` where applicable
2023-10-09 15:37:14 +02:00
A Thousand Ships f18aa00e85 Replace `ERR_FAIL_COND` with `ERR_FAIL_NULL` where applicable 2023-10-08 17:23:33 +02:00
Hugo Locurcio f6cc2603a1
Add a Disable 2D property to Viewport
This is the 2D counterpart to the existing Disable 3D property.
Its functionality is already internally implemented and used,
but it wasn't exposed.
2023-10-07 17:19:15 +02:00
Michael Alexsander 9ee82ebe1d
Fix tooltips behaving incorrectly on `Tree` nodes 2023-09-28 11:18:15 -03:00
Marcel Admiraal 3a7eda8f87 Check if input marked handled before processing additional CollisionObjects 2023-09-26 20:42:15 +02:00
Dario 057367bf4f Add FidelityFX Super Resolution 2.2 (FSR 2.2.1) support.
Introduces support for FSR2 as a new upscaler option available from the project settings. Also introduces an specific render list for surfaces that require motion and the ability to derive motion vectors from depth buffer and camera motion.
2023-09-25 10:37:47 -03:00
Yuri Sizov dd3638d425 Merge pull request #81669 from kleonc/gui-tooltip-transparent-background
Enable transparent background for GUI tooltips
2023-09-15 19:48:37 +02:00
kleonc c66dfd2cfe Enable transparent background for GUI tooltips 2023-09-14 23:39:28 +02:00
Yuri Sizov fe000277ea Bind remaining theme properties to their respective classes
This adds binds for GraphEdit/GraphElement/GraphNode, which were
skipped before due to a rework. This also adds binds for Window,
which was skipped before due to a complicated code organization.

Also adds theme cache entries/direct cache access to a few places
that previously missed it. Some theme properties are now exposed
to other classes via friendships or public getters for convenience.

This removes all string-based theme access from scene/ classes.
2023-09-13 19:31:35 +02:00
Rémi Verschelde 8b8b6d1e87
Merge pull request #81006 from KurtBliss/Chance-of-crash-when-Control-overrides-mouse-input-on-Area2D-#79371
Fix possible crash when Control overrides mouse input on Area2D
2023-08-28 15:04:41 +02:00
KurtBliss dbb01bc451 Fixed, chance of crash when Control overrides mouse input on Area2D
Made Viewport::_cleanup_mouseover_colliders queue up mouse_exit and
mouse_shape_exit signals to emit and at the end of the function's
execution to avoid potential crashes.
2023-08-25 17:51:38 -04:00
Rémi Verschelde b24eb34669
Merge pull request #80780 from HolonProduction/sub-window-focus-crash
Fix crash when hiding subwindow during popup of new subwindow
2023-08-21 08:23:23 +02:00
HolonProduction e2cea458a3 Fix crash when hiding subwindow during popup of new subwindow 2023-08-20 17:51:54 +02:00
Rémi Verschelde e73a4a382e
Merge pull request #79201 from Rindbee/fix-setup-state-not-cleared
Clear the previously set state when configuring for a new scene root node
2023-08-17 15:43:38 +02:00
Michael Alexsander de27df5da3
Allow to get a list of visible embedded `Window`s 2023-08-16 10:42:08 -03:00
Markus Sauermann 59c13fea5d Fix nodes receiving mouse events in black bars of `Window`
Previously for InputEvents there was no distinction between
Window-area and Viewport-area.
This was problematic in cases where stretching was used and the Window
contained black bars at the sides of the Viewport.
This PR separates the area of Window and Viewport regarding InputEvents.
2023-08-09 12:34:22 +02:00
Rindbee 4795c3cdfa Clear the previously set state when configuring for a new scene root node
Saving a subscene causes the main scene to be re-instantiated. And the resource
instance in the main scene will be reused when the main scene is re-instantiated.
So for resources with `resource_local_to_scene` enabled, resetting state may be
necessary (at least for `ViewportTexture`).
2023-08-08 23:49:53 +08:00
Rémi Verschelde 46c9a1427d
Merge pull request #80364 from Calinou/control-escape-dismiss-tooltips
Dismiss currently visible or upcoming tooltips when pressing Escape
2023-08-08 16:57:59 +02:00
Rémi Verschelde 1163dac9e3
Merge pull request #80215 from clayjohn/HDR-2D
Add option to enable HDR rendering in 2D
2023-08-08 16:57:33 +02:00
Hugo Locurcio 6307b0be3c
Dismiss currently visible or upcoming tooltips when pressing Escape
This is standard UI behavior in most applications out there.
2023-08-08 07:40:39 +02:00
Rémi Verschelde faaf27f284
Fix various typos with codespell
Also includes typo fixes from #79993, #80068, #80276, and #80303.

Co-authored-by: betalars <contact@betalars.de>
Co-authored-by: spaceyjase <429978+spaceyjase@users.noreply.github.com>
Co-authored-by: Swarkin <102416174+Swarkin@users.noreply.github.com>
Co-authored-by: Raul Santos <raulsntos@gmail.com>
2023-08-07 13:09:47 +02:00
clayjohn 57eb762bae Add option to enable HDR rendering in 2D
This is needed to allow 2D to fully make use of 3D effects (e.g. glow), and can be used to substantially improve quality of 2D rendering at the cost of performance

Additionally, the 2D rendering pipeline is done in linear space (we skip linear_to_srgb conversion in 3D tonemapping) so the entire Viewport can be kept linear.
This is necessary for proper HDR screen support in the future.
2023-08-07 11:24:03 +02:00
Markus Sauermann 1e9d241809 Actually store safe-rect in embedder
`sw` is a copy and not a reference.
Add unit-test for this case.
2023-08-02 17:51:52 +02:00
Markus Sauermann 1c3c17c608 Refactor mouse_entered and mouse_exited notifications
The previous implementation for signals mouse_entered and mouse_exited
had shortcomings that relate to focused windows and pressed mouse buttons.
For example a Control can be hovered by mouse, even if it is occluded by
an embedded window.

This patch changes the behavior, so that Control and Viewport send
their mouse-enter/exit-notifications based solely on mouse position,
visible area, and input restrictions and not on which window has
focus or which mouse buttons are pressed. This implicitly also
changes when the mouse_entered and mouse_exited signals are sent.

This functionality can not be implemented as a part of
Viewport::_gui_input_event, because of its interplay with Windows and
because Viewport::_gui_input_event is based on input and not on
visibility.
2023-08-01 13:28:49 +02:00
Markus Sauermann 7fead979d6 Disable error condition for accessing safe rect
This PR removes the error-message, which is currently expected to happen.
The task of correctly fixing the underlying problem of window popup
closing is more complex, so this PR solves the immediate
error-notification-problem.
2023-07-26 20:21:30 +02:00
Yuri Sizov d50c52652f Merge pull request #79805 from kumikumi/fix-subviewport-cursor
Prevent SubViewportContainer overriding Subviewport's cursor with its own cursor
2023-07-26 18:40:30 +02:00
Yuri Sizov 712f49ec57 Merge pull request #79766 from Sauermann/fix-window-determinant-zero
Add determinant check for minimized windows
2023-07-26 18:40:26 +02:00
Yuri Sizov 1de9171c32 Merge pull request #79443 from Sauermann/fix-ingore-hovering
Fix physics passive hovering with `MOUSE_FILTER_IGNORE`
2023-07-26 18:40:14 +02:00
Yuri Sizov 67873d0d5d Merge pull request #79248 from Sauermann/fix-svc-focus-propagation
Make `SubViewportContainer` event propagation aware of focused Control
2023-07-26 18:39:57 +02:00
Mikko Ankkala 96b26574b9 Don't override SubViewport's cursor with SubViewportContainer's cursor
Add a warning for having a non-default value of `mouse_default_cursor_shape` in SubViewportContainer

Add test
2023-07-23 22:27:55 +03:00
Markus Sauermann e0bce0bd7f Add determinant check for minimized windows
When the Window is minimized, the transform-determinant can be 0.
Add a check to prevent this case.
2023-07-22 00:02:37 +02:00
Yuri Sizov 15c0e40375 Merge pull request #79546 from Sauermann/fix-input-handled-physics
Separate input-handled-state for different events during physics-picking
2023-07-21 17:15:36 +02:00
Markus Sauermann b408b05d7d Fix physics passive hovering for some cases
When the parent `SubViewportContainer` ignores mouse with
`MOUSE_FILTER_IGNORE` and also when the mouse is over a `Control`-node,
then the `SubViewport` shouldn't create mouse-move-events for passive
hovering.
2023-07-19 19:25:04 +02:00
Markus Sauermann e6386bc843 Make `SubViewportContainer` event propagation aware of focused Control
Propagate `InputEvents` without position either
- during the Input-stage, when it has focus or
- during the Unhandled-Input-stage, otherwise

This makes sure that Gui-Input happens in the correct order.

Move "Unhandled key Input" handling before "Unhandled Input" handling,
so that Unicode input with Alt / Ctrl modifiers are sent to the nodes
in the correct order.

Change the default focus mode of `SubViewportContainer` from
`FOCUS_NONE` to `FOCUS_CLICK`, to automatically remove focus from
other `Control`-nodes, when clicking inside a `SubViewport`.
2023-07-17 22:38:35 +02:00
kobewi de4a3fa151 Unify and streamline connecting to Resource changes 2023-07-17 19:35:57 +02:00
Markus Sauermann 95d294b97a Separate input-handled-state for different events during physics-picking
Currently the input-handled-state for different events can interfere with
each other.
This PR makes sure, that the input_handled_state is reset before
processing and InputEvent during physics-picking.
2023-07-16 14:36:18 +02:00
Markus Sauermann 576980f960 Add a default theme for unfocused Windows
At the moment it is impossible to distinguish between focused and
unfocused embedded Windows.
Add a new `theme_item` that is used for coloring the border of
unfocused Windows.
2023-07-12 22:35:03 +02:00
Yuri Sizov 223370cb64 Merge pull request #78383 from Sauermann/fix-physics-object-init
Fix Physics Picking captured Object initialization
2023-07-12 17:15:45 +02:00
Yuri Sizov 5dff3c4484 Merge pull request #78538 from Sauermann/fix-code-simplifications
Remove unnecessary value assignments throughout the codebase
2023-07-12 15:09:26 +02:00
Yuri Sizov 631d51c46c Merge pull request #78476 from Sauermann/fix-embedded-safe-area
Embedded Popups store their safe_rect in their embedder
2023-07-12 15:09:20 +02:00
Rémi Verschelde 7961bc6193
Merge pull request #78078 from Sauermann/fix-drop-physics-mouse-over
Ensure that `_drop_physics_mouseover` only happens when necessary
2023-07-07 16:02:13 +02:00
Rindbee fb1bcac271 Fix that `ViewportTexture` cannot be setup again after failed setup
`vp_pending` is a flag indicating to wait for `ViewportTexture::_setup_local_to_scene`
to be called. Once this method is called, no matter whether the setup will fail or not,
it needs to be reset to `false`.
2023-06-27 06:45:30 +08:00
ajreckof f745299c36 Fix crash when removing child during focus exit. 2023-06-23 21:31:18 +02:00
Markus Sauermann 60c261ba2d Re-add `mouse_focus`-nullcheck 2023-06-22 21:58:19 +02:00
Markus Sauermann 890fdd56df Code simplifications
CPPcheck found most of them.

no need to assign the variable twice:
- AnimationTrackEditTypeAudio
- SSEffects

variable is assigned in all if-else clauses:
- EditorHelp
- AndroidInputHandler
- MenuBar
- ShaderCompiler

same if clause:
- ItemList

clearing an empty bitfield has no effect:
- Viewport
2023-06-21 22:37:26 +02:00
Markus Sauermann a12627765f Embedded Popups store their safe_rect in their embedder
Storing it in the DisplayServer didn't make sense in this case,
because the embedded window is unknown to the DisplayServer.
2023-06-20 18:06:26 +02:00
Markus Sauermann 5b2a5cd2e0 Fix Physics Picking captured Object initialization
Initialize variables when a captured object is known.
2023-06-18 00:45:49 +02:00
Rémi Verschelde 9fca498647
Merge pull request #78110 from Sauermann/fix-nofocus-focus
Fix Tooltip getting removed instantly in embedded Window
2023-06-12 11:55:58 +02:00
Markus Sauermann 9d40f99290 Fix Tooltip getting removed instantly in embedded Window
Tooltips are unfocusable Windows. This case was not handled correctly in
`Viewport::_sub_window_register`.
2023-06-11 12:22:59 +02:00
Ninni Pipping 0c16082e1e Use `get_node_or_null` when null checks are present
Avoids duplicate or unnecessary errors
2023-06-10 13:22:56 +02:00
Markus Sauermann 37a96d3957 Fix that `_drop_physics_mouseover` only happens when necessary
Previously the call was executed every time, because in the
`_drop_mouse_over();` a few lines above, `gui.mouse_over = nullptr;`
was set.
2023-06-10 09:33:16 +02:00
Ninni Pipping dcd2b883eb Use NULL instead of COND checks when appropriate
Restricted to scene
2023-06-10 08:56:30 +02:00
Rémi Verschelde 8acf6b41a4
Merge pull request #77209 from Rindbee/ViewportTexture-not-change-RID
Don't change `RID` when changing `viewport_path` in `ViewportTexture`
2023-06-09 15:10:39 +02:00
Rindbee 7532b2d259 Don't change `RID` when changing `viewport_path` in `ViewportTexture`
When changing `viewport_path`, the `proxy`'s target is changed to a new placeholder.

Add a flag `vp_changed` to prevent calling `setup_local_to_scene` (mainly called by toggling `resource_local_to_scene`) when the target viewport has not changed.
2023-06-09 19:50:26 +08:00
Rémi Verschelde 2a8e83ccad
Merge pull request #78017 from Sauermann/fix-physics-passive-hovering
Fix passive mouse hovering for physics
2023-06-09 13:44:05 +02:00
Markus Sauermann 543fdc1490 Fix passive mouse hovering for physics
Currently mouse hovering doesn't update the state, when collision objects
or the camera move.
This PR fixes this problem by taking the mouse position from the viewport
and not from a nonexistent previous event.

Since previous events could potentially be a long time ago, their
modifier-key state might be outdated. This PR fetches the current
status of modifier-keys from `Input`.

These changes allow the removal of some class-variables and making
additional simplifications.
2023-06-09 12:51:10 +02:00
Rémi Verschelde 0cee1e0d4f
Merge pull request #77923 from Sauermann/fix-mouse-position-with-screen-transform
Fix mouse position with screen transform
2023-06-09 12:15:56 +02:00
Markus Sauermann d1fa284e65 Fix mouse position with screen transform
When a Viewport is not directly attached to the screen, the
function `Viewport::get_mouse_position` can't rely on
`get_screen_transform`, because that function is ambiguous in
these situations.
In these cases it is necessary to use the mouse position from
the most recent mouse IputEvent.
2023-06-09 11:29:43 +02:00
Rémi Verschelde b083c1dbf5
Merge pull request #78005 from Sauermann/fix-some-simplifications
Some code simplifications
2023-06-09 11:06:26 +02:00
Rémi Verschelde 3a19d81691
Merge pull request #77842 from Sauermann/fix-unfocusable-subwindow
Fix input handling for unfocusable embedded windows
2023-06-08 17:38:33 +02:00
Markus Sauermann 5ddab1f363 Some code simplifications
AnimationNodeBlendSpace2DEditor:
- `!tree` is always false, because it is checked a few lines above

CurveEdit:
- grabbing != GRAB_NONE is redundant

GradientTexture2DEdit:
- grabbed != HANDLE_FROM is redundant
- grabbed != HANDLE_TO is redundant

Viewport:
- index is not used afterwards
- In these cases `gui.mouse_focus` is always valid. Move check to a DEV_ASSERT
- simplify `stopped` calculation
2023-06-08 16:15:22 +02:00
Rémi Verschelde 27b402bf73
Merge pull request #77902 from dalexeev/doc-unify-deprecations
Documentation: Unify deprecations
2023-06-07 16:06:50 +02:00
Danil Alexeev b433020aa6
Documentation: Unify deprecations 2023-06-07 16:34:03 +03:00
kobewi 807431c49a Cancel tooltip when mouse leaves viewport 2023-06-07 00:56:36 +02:00
Markus Sauermann f00f4a0209 Fix input handling of unfocusable embedded Windows
InputEvents get in some cases sent to the wrong Window.
fix `Viewport::_sub_windows_forward_input`- console error spam
2023-06-06 17:51:19 +02:00
Yuri Sizov 2e728e02cc
Merge pull request #77763 from RedworkDE/warning-dialog-crash
Prevent crashes when removing Viewport from scene tree in event handler
2023-06-06 12:19:25 +02:00
RedworkDE c4db212870 Prevent crashes when removing Viewport from scene tree in event handler 2023-06-03 23:37:31 +02:00
Aaron Franke 8b42297d7c
Make `Viewport::gui_get_focus_owner` const 2023-06-02 12:36:10 -05:00
Markus Sauermann 6d490ce8de Deprecate push_unhandled_input
The functionality of `push_unhandled_input` has changed so that it no
longer propagates input events to SubViewports.
This makes it less predictable and it should be deprecated in favor of
`push_input` which provides the same functionality and more.

Also this deprecation simplifies the Viewport-API by reducing the methods
for pushing input events, so that users don't need to worry about when
to use which function in order to insert input events.
2023-05-31 19:07:04 +02:00
Yuri Sizov 6dd5ccdedd
Merge pull request #66625 from Sauermann/fix-move-child-update
Create a virtual mouse move event after moving child nodes in tree
2023-05-30 15:57:21 +02:00
Yuri Sizov 3a895eafc0
Merge pull request #77595 from Sauermann/fix-double-inputevent
Fix InputEvent being used twice
2023-05-30 15:25:36 +02:00
Markus Sauermann ce10ca6979 Create a virtual mouse move event after moving child nodes
This updates mouse cursor and mouse-over-states without the need
for additional mouse movements.
2023-05-29 22:46:19 +02:00