Commit Graph

104 Commits

Author SHA1 Message Date
bruvzg cfdb968848
[Window] Allow to override viewport and project settings and force use of native window. 2024-03-04 23:06:27 +02:00
Rémi Verschelde 3ce9ae71fc
Merge pull request #84906 from /fix-some-defvals 2024-02-23 11:29:22 +01:00
Raul Santos 5ba92e5a57
Fix some DEFVALs to use the right type
- Use `StringName()` in DEFVAL for StringNames.
- Use `Variant()` in DEFVAL for Variants.
2024-02-23 01:50:18 +01:00
Michael Alexsander 584a6aeeb7
Revert "Fix `NOTIFICATION_WM_SIZE_CHANGED` firing if the size hasn't changed"
This reverts commit 957378a69e, reversing
changes made to 0d88840e81.
2024-02-21 15:37:53 -03:00
Michael Alexsander 7b42c24550
Make auto translation inheritable 2024-02-15 16:51:19 -03:00
Rémi Verschelde 03767fbf3b
Merge pull request #86446 from reduz/transient-to-focused
Implement a `transient_to_focused` Window mode
2024-01-15 13:25:00 +01:00
Juan Linietsky 15144c24bd Implement a transient_to_focused mode
This intends to be the correct way to handle non-child windows becoming covered by the current window when becoming focused.
Enabling this property on select windows, they will become transient to the currently focused one when becoming visible.

This deprecates the "unparent_when_invisible" function introduced by #76025.
2024-01-14 18:51:44 +01:00
Jakub Marcowski 06534f8ad5 Add deprecation notice to a duplicate method of class `Window` 2024-01-12 18:18:28 +01:00
Rémi Verschelde 957378a69e
Merge pull request #84151 from YeldhamDev/that_was_not_a_resize_you_dunce
Fix `NOTIFICATION_WM_SIZE_CHANGED` firing if the size hasn't changed
2024-01-02 15:08:46 +01:00
Yuri Sizov 02d4579fa2 Merge pull request #85000 from bruvzg/ed_ui_direction
[Editor] Add option to override editor UI layout direction.
2023-12-19 13:01:35 +01:00
bruvzg 932174fedf
[Editor] Add option to override editor UI layout direction. 2023-11-17 14:56:45 +02:00
Markus Sauermann fa02d19fd1 Fix internal events not being delivered to some Window types
`AcceptDialog`, `Popup` and `PopupMenu` no longer subscribe to
"window_input" signal, because that is only sent if it is not an
internal signal.

Instead they receive events in `_input_from_window`. They ensure that
the event is also propagated to their super-function, just like
previously the signals would be treated.
2023-11-14 20:29:17 +01:00
Michael Alexsander 62ab9bf1c4
Fix `NOTIFICATION_WM_SIZE_CHANGED` firing if the size hasn't changed 2023-10-31 22:58:12 -03:00
bruvzg 72e2e47059
[DisplayServer] Add method to estimate window title bar size. 2023-10-03 16:13:52 +03:00
Rémi Verschelde 1e819ae3aa
Merge pull request #82590 from YuriSizov/window-you-come-to-me-on-this-day-the-day-when-my-child-becomes-exclusive-with-a-transient-parent-to-ask-for-this
Add more context to some `Window` errors
2023-10-02 13:16:39 +02:00
Yuri Sizov 53172d9860 Add more context to some `Window` errors 2023-09-30 21:44:05 +02:00
bruvzg c52db6190c
[FileDialog] Make set_visible compatible with native dialogs. 2023-09-30 00:40:49 +03: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
Yuri Sizov 2924bfd4d3 Register theme properties with ThemeDB 2023-09-11 13:45:23 +02:00
Yuri Sizov 58126e479c Introduce the concept of global theme contexts
This commit adds the default theme context, which replaces
the need to manually check the project and the default theme
all the time; simplifies related code.

It also adds framework for custom theme contexts, to be used
by the editor. Custom contexts can be attached to any node,
and not necessarily a GUI/Window node. Contexts do no break
theme inheritance and only define which global themes a node
uses as a fallback.

Contexts propagate NOTIFICATION_THEME_CHANGED when one of their
global themes changes. This ensures that global themes act just
like themes assigned to individual nodes and can be previewed
live in the editor.
2023-09-06 19:40:43 +02:00
kobewi 6de34fde27 Add EditorStringNames singleton 2023-09-03 19:58:18 +02:00
Jordyfel 9819ffb166 Implement window center function. 2023-08-26 21:34:21 +03:00
Rémi Verschelde a7dc4c22a9
Merge pull request #80334 from Sauermann/fix-window-out-of-viewport-events
Fix nodes receiving mouse events in black bars of `Window`
2023-08-16 09:12:42 +02:00
Rémi Verschelde 33198d0df0
Merge pull request #75784 from Riteo/int-scale
Add content scale stretch modes, implement integer scaling
2023-08-11 10:32:11 +02:00
Riteo 87cfc415a3 Add content scale stretch modes, implement integer scaling
Integer scaling is achieved (after aspect expansion) by "lying" to the
stretching code about the window's size, telling it that it's always an
integer multiple of the viewport so that it only gets stretched to an
integer factor.

This approach works with all stretch and aspect modes and doesn't
require handling for each, only requiring to "loosen up" some
self-excluding conditions (in other words, replacing some `else if`s
with just `if`s) regarding viewport offset and margin calculation (black
bars).

Includes a tiny usability change that adds a range hint for the content
scale factor between 0.5 to 8.0.

Co-Authored-By: Hugo Locurcio <hugo.locurcio@hugo.pro>
2023-08-10 19:45:47 +02: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
Michael Alexsander f270163ab0
Expose `Window`'s `_get_contents_minimum_size()` to scripting 2023-08-02 14:40:38 -03: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
bruvzg 4790da7900
[macOS] Implement optional native file selection dialog support for sandboxed apps. 2023-07-12 22:36:24 +03:00
jeana helver 5ec1b698d2
Fix missing enum value for `Window.initial_position`
Reorder the properties in a possibly more intuitive order.

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2023-06-21 22:39:43 +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
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
Yuri Sizov 17f492fb82 Expose dialog parent-and-popup logic to the API 2023-05-15 19:49:28 +02:00
bruvzg 520a8d8ed2
Add project manager / editor initial screen settings, implement DisplayServer.get_keyboard_focus_screen method. 2023-04-19 08:54:53 +03:00
Yuri Sizov 91ff34b5b5 Add a warning when trying to access theme items too early 2023-04-03 18:01:10 +02:00
Ryan Roden-Corrent 894ce41180
Apply clamp_to_embedder on parent resize and popup.
Fixes #75084.

The clamp_to_embedder setting was added in 8be16e0704,
but was not set on any of the in-editor dialogs.

This patch sets `clamp_to_embedder` on editor dialogs so they cannot be dragged out of the frame.
This also modifies `clamp_to_embedder` so a window is clamped to the bounds of an embedder when
it pops up and when the parent is resized.
2023-03-27 07:08:29 -04:00
Markus Sauermann 888add8418 Fix Color Picking
With the 4.x-introduction of Windows the previous method for
color picking was no longer working.

This PR uses the following approach to reintroduce color-picking.
When the Color-Picking-Button is pressed, a quasi-screenshot of the
Window-content is created and displayed in a new Popup-Window.
This new Window allows selecting colors by Mouse-Click.
A Preview of the targeted Color is also displayed.
2023-02-09 01:00:54 +01:00
Rémi Verschelde 929333fe26
Merge pull request #62179 from Rindbee/fix-popup_center-off-center
Use min_size/max_size to limit window size and position while popup center
2023-02-07 16:30:41 +01:00
Rindbee c73844f117 Use min_size/max_size to limit the window size and the position while popup center 2023-02-07 21:28:26 +08:00
Markus Sauermann 5312d83f3b Fix Viewport::get_mouse_position for SubViewports
SubViewports don't have a cached mouse position available.
This PR calculates the mouse position from the screen position of
the mouse cursor.
2023-02-07 13:54:47 +01:00
Markus Sauermann e3e9da78e8 Remove `Viewport::_get_input_pre_xform`
This function is only relevant for `Window`. So this PR moves
the functionality to the `Window`-class.
2023-02-02 22:03:52 +01:00
Rémi Verschelde 1c42e141d0
Merge pull request #59310 from Sauermann/proposal-event-transform
Calculate window input event transform only on window change
2023-01-31 15:57:07 +01:00
Rémi Verschelde aae96945fa
Merge pull request #71470 from YeldhamDev/window_fixes
Fix some small bugs in the `Window` node
2023-01-27 19:26:31 +01:00
Rémi Verschelde 13e20fed99
Merge pull request #68627 from Sauermann/fix-tooltip-position
Fix position of Tooltips
2023-01-26 16:00:14 +01:00
Markus Sauermann c4ed247f5f Fix position of Tooltips
CanvasItem::get_screen_transform returns a transform from the CanvasItem
to the coordinate system, where a Popup - created as a child of the
CanvasItem - should be opened.
get_screen_transform makes some simplifications, that work well, when used
in the editor, but not in general cases.

Since Popups like Tooltips are now used more commonly in projects,
it becomes necessary to correct these simplifications.

This solution introduces Viewport::get_popup_base_transform, which makes
the necessary calculations.
2023-01-26 15:15:14 +01:00
bruvzg aade5abd4f
Reorganize main and sub-window initial position properties. 2023-01-19 13:44:06 +02:00
Michael Alexsander 52b077ca28 Fix some small bugs in the `Window` node 2023-01-18 21:20:49 -03:00
bruvzg 34b34b104c
Add `WINDOW_FLAG_MOUSE_PASSTHROUGH` flag and enabled it for tooltips. Expose `window_set_mouse_passthrough` to `Window`. 2023-01-16 11:42:49 +02:00
bruvzg 19293d1813
Automatically reparent editor progress dialog to avoid error spam. 2023-01-11 10:13:21 +02:00
bruvzg 2718a7b7d3
Add support for the custom initial screen for the main window, fix primary screen detection. 2023-01-07 11:14:35 +02:00