Commit Graph

33 Commits

Author SHA1 Message Date
Markus Sauermann 781cecdc23 Enable filtering `InputEvent`-sending in `SubViewportContainer`
Introduce an user overridable function, that allows filtering, if
an `InputEvent` should be sent to `SubViewport` children.
2023-10-02 19:51:49 +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
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
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 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
Markus Sauermann 8836f2160a Move call of `push_unhandled_input` from `Window` to `Viewport`
This solves the problem, that mouse events get sent to SubViewports
even if they are outside of the visible area of the SubViewport.

This changes makes SubViewportContainer::unhandled_input redundand.
Shortcut Events now need to be distributed via push_input, in order for
them to be able to reach SubViewports.
2023-03-17 19:22:24 +01:00
Markus Sauermann 34a7fc7447 Fix some ways to create inconsistent Viewport sizes
In the editor, it was possible to set the size of a `SubViewport` even
in cases where a parent `SubViewportContainer` had stretch enabled.

This PR disables editing a `SubViewport.size` while the parent disallows
it and it makes necessary adjustments during `NOTIFICATION_ENTER_TREE`.
2023-02-13 08:19:00 +01:00
Rémi Verschelde 51414fc987
Merge pull request #66906 from Sauermann/fix-prohibit-inconsistent-size-state
Prohibit inconsistent size state for SubViewport
2023-02-01 07:26:00 +01:00
Markus Sauermann decbda68d7 Prohibit inconsistent size state for SubViewport
Prohibit size changes of SubViewports with parent SubViewportContainers that have stretch mode enabled.
2023-01-31 22:53:43 +01:00
Rémi Verschelde 3e1925fd00
Merge pull request #58334 from Sauermann/fix-to-gui-or-not-to-gui
Fix SubViewportContainer processing Events before other Control-Nodes
2023-01-27 10:39:49 +01:00
Rémi Verschelde d95794ec8a
One Copyright Update to rule them all
As many open source projects have started doing it, we're removing the
current year from the copyright notice, so that we don't need to bump
it every year.

It seems like only the first year of publication is technically
relevant for copyright notices, and even that seems to be something
that many companies stopped listing altogether (in a version controlled
codebase, the commits are a much better source of date of publication
than a hardcoded copyright statement).

We also now list Godot Engine contributors first as we're collectively
the current maintainers of the project, and we clarify that the
"exclusive" copyright of the co-founders covers the timespan before
opensourcing (their further contributions are included as part of Godot
Engine contributors).

Also fixed "cf." Frenchism - it's meant as "refer to / see".
2023-01-05 13:25:55 +01:00
Markus Sauermann ebd1b0089a Fix Viewport being visible after leaving tree
When a SubViewport leaves the tree, it is still displayed in its parent
SubViewportContainer until the next redraw.
This PR makes sure, that the parent gets redrawn immediately.

This also fixes the visibility problem when a SubViewport is added as
child of a SubViewportContainer.
2022-11-23 16:04:07 +01:00
Markus Sauermann 56ddf89fac Adjust SubViewportContainer event handling
Change SubViewportContainer, so that it processes events with a position property no longer in 'input', but in 'gui_input'.
This fixes the issue, that Nodes within its SubViewport receive MouseButton events before other Control-Nodes.
2022-10-02 07:23:08 +02:00
Marc Gilleron aed3822a93 Change return type of `get_configuration_warnings` to `PackedStringArray` 2022-09-19 16:43:15 +01:00
Micky e31bb5ffeb Rename `CanvasItem.update()` to `queue_redraw()`
Affects a lot of classes. Very thoroughly checked signal connections and deferred calls to this method, add_do_method/add_undo_method calls, and so on.

Also renames the internal `_update_callback()` to `_redraw_callback()` for consistency.

Just a few comments have also been changed to say "redraw".

In CPUParticles2D, there was a private variable with the same name. It has been renamed to `do_redraw`.
2022-08-29 14:59:47 +02:00
风青山 e561c68256 Add some codes, returnes directly if the value is not changed.
Avoid executing the following value-changed logics if the value does not really change.
2022-08-23 23:25:22 +08:00
Markus Sauermann c8573ea3df Fix event transform in SubViewportContainer
The transform does not take the canvas transform into account.
2022-03-30 20:56:36 +02:00
Rémi Verschelde 7119d355eb String: Remove TTR and DTR defines in non-tools build
This ensures we don't use TTR in runtime code, as it's specifically meant
to source translations for the editor.
2022-03-28 20:26:35 +02:00
Markus Sauermann 356fac206d Add configuration warning for SubViewportContainer 2022-03-26 20:33:45 +01:00
Markus Sauermann 415042ac89 Connect notifications from Container to Viewport
mouse enter+exit
2022-02-15 22:41:30 +01:00
Rémi Verschelde 0f5455230c
Use `switch` consistently in `_notification` (`scene` folder) 2022-02-15 18:44:55 +01:00
Yuri Sizov 107b6f299c Reorganize inspector layout workflow for Control nodes 2022-02-10 20:29:34 +03:00
Tomasz Chabora e72adab511 Update the minimum size of ViewportContainer 2022-01-06 15:43:12 +01:00
Rémi Verschelde fe52458154
Update copyright statements to 2022
Happy new year to the wonderful Godot community!
2022-01-03 21:27:34 +01:00
reduz 5cecdfa8af Entirely removes BIND_VMETHOD in favor of GDVIRTUAL
* `_gui_input`, `_input`, `_unhandled_input` and `_unhandled_key_input` are now regular C++ virutal functions.
* Everything else converted to GDVIRTUAL
* BIND_VMETHOD is gone, always use the new syntax from now on.

Creating `_gui_input` method and using the binder to register events will no longer work, simply override the virtual function now.
2021-08-23 08:10:13 -03:00
Rafał Mikrut 504bc5cc67 Fix crashes in *_input functions 2021-04-05 08:52:21 +02:00
Rafał Mikrut 7961a1dea3 Initialize class variables with default values in scene/ [2/2] 2021-02-09 18:24:36 +01:00
Rémi Verschelde b5334d14f7
Update copyright statements to 2021
Happy new year to the wonderful Godot community!

2020 has been a tough year for most of us personally, but a good year for
Godot development nonetheless with a huge amount of work done towards Godot
4.0 and great improvements backported to the long-lived 3.2 branch.

We've had close to 400 contributors to engine code this year, authoring near
7,000 commit! (And that's only for the `master` branch and for the engine code,
there's a lot more when counting docs, demos and other first-party repos.)

Here's to a great year 2021 for all Godot users 🎆
2021-01-01 20:19:21 +01:00
reduz 127458ed17 Reorganized core/ directory, it was too fatty already
-Removed FuncRef, since Callable makes it obsolete
-Removed int_types.h as its obsolete in c++11+
-Changed color names code
2020-11-07 20:17:12 -03:00
Rémi Verschelde 0ee0fa42e6 Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
2020-05-14 21:57:34 +02:00
Rémi Verschelde 0be6d925dc Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to
will now be changed automatically to remove the first empty line.

This makes us lean closer to 1TBS (the one true brace style) instead
of hybridating it with some Allman-inspired spacing.

There's still the case of braces around single-statement blocks that
needs to be addressed (but clang-format can't help with that, but
clang-tidy may if we agree about it).

Part of #33027.
2020-05-14 16:54:55 +02:00
Rémi Verschelde 03b13e0c69 Style: Add missing copyright headers 2020-05-10 13:12:16 +02:00
Michael Alexsander 0c6851ae53 Rename ViewportContainer to SubViewportContainer 2020-04-01 16:11:44 -03:00