Commit Graph

246 Commits

Author SHA1 Message Date
Gaspar Capello efe744c36d
Merge ea01d1963c into cef92c1a38 2025-07-29 23:47:48 -05:00
Martín Capello 45fbeda95b Avoid enqueuing events directly to laf-os 2025-06-02 19:45:37 -03:00
Martín Capello a3236bc1e9 Remove ui::Manager as friend of ui::Widget 2025-06-02 19:45:37 -03:00
Christian Kaiser b130601716
Startup optimizations (#5090)
* Delay DitheringSelector startup
* Delay setting the drag target
* Delay & enqueue menu reloading
2025-04-02 07:59:52 -03:00
David Capello d5738fb492 Avoid capturing the mouse from widgets in background windows
This avoids clicking buttons that are not in the foreground/modal
window. At the same time the onBroadcastMouseMessage() functionality
was expanded in such a way that added widgets to the broadcast are the
only ones allowed to re-capture the mouse (even if they are not in the
current foreground window). This is required so the Editor can be
scrolled when we are visualizing a Filter window with preview.

New functions added to simplify some code:

* Manager::transferAsMouseDownMessage()
* Manager::allowCapture()
* base::contains()

Related to #4963 and #4973.
2025-02-12 11:01:59 -03:00
David Capello 09538f9a1a clang-format all files 2024-12-16 14:52:19 -03:00
David Capello 4ba88ce49c Fix failing assert in ui::details::::removeWidget()
When running multiple UI tests, if the mouse was moved on a created
window, it made the ui::details::removeWidget() fail because the
widget was still ui::Manager::widgetAssociatedToManager().
2024-12-07 14:34:45 -03:00
David Capello d5d5894df6 Allow re-creating the ui::Manager multiple times 2024-12-07 14:34:45 -03:00
David Capello 969dd68490 Move default handleWindowResize handler to ui-lib 2024-12-03 15:52:26 -03:00
Gaspar Capello ea01d1963c Fix inactive window passes events to window below (fix #4561)
Prior to this fix, if all of the following conditions were met:
+ While a modal window (such as the Preferences dialog) was open.
+ 'Multiple window UI' was enabled.
+ A non-modal window (such as the Preview window) overlapped the modal
  window.
+ The non-modal window was selected, so this window is on top of
  the modal window.
Caused mouse clicks and movements within the overlay area of ​​the
non-modal window to be incorrectly passed to the window below, i.e.
the modal window.
Instead, it would be expected that no action would be taken.
2024-12-03 10:38:47 -03:00
David Capello 60bd3378fc New UILayers to composite floating elements (fix #4825)
* Replaced ui::Overlays with ui::UILayer
* Refactored BrushPreview to use its own UILayer (+ new blender shader
  for the negative black & white effect).
* Add a default back UILayer to each ui::Display
* Use ui::move_region() in this "back layer" when GPU is disabled.

Although we should completely remove ui::move_region in a future, for
CPU rendering sometimes it's faster to just move memory instead of
redrawing the widgets.
2024-12-01 22:46:37 -03:00
David Capello 6b7aa371ce Add benchmark for ui::View scroll
This patch includes a new ui::Manager::dontWaitEvents() function to
avoid waiting for any user interaction. The old editor_benchmark now
uses this new function too.
2024-11-30 09:38:04 -03:00
David Capello 84f3101681 [win] Use WinTab/tablet pressure only for certain windows (#3358)
Windows that need tablet information are the MainWindow, DynamicsPopup,
and scripts Dialog.
2024-11-21 17:23:50 -03:00
David Capello 41baef2627 Merge branch 'main' into beta 2024-11-19 16:00:11 -03:00
Martín Capello f76bbcff67 Avoid clipping hidden windows (fix #4546) 2024-11-19 14:14:53 -03:00
David Capello 10eaec8a87 Merge branch 'import-image-as-new-layer' into beta (fix #131, #4636) 2024-11-11 17:26:39 -03:00
Martín Capello c1405e0d3a Revert wrapping MouseEnter/Leave messages
Changes reverted to fix #4754
2024-11-06 18:13:06 -03:00
Martín Capello 9e396227c2 Refactor HAS_MOUSE flag handling
Now each widget is responsible to enable/disable its own HAS_MOUSE flag
in response to the kMouseEnter/Leave message received. Also there is no
need to iterate over the parents since these messages are propagated
to the parent
2024-10-30 10:10:31 -03:00
Martín Capello f67643a24e Avoid using CallbackMessage for MouseEnter/Leave
Instead of wrapping the MouseEnter and MouseLeave OS events handling
inside a UI CallbackMessage, we now enqueue the corresponding
kMouseEnterMessage and kMouseLeaveMessage
2024-10-30 10:10:31 -03:00
David Capello aed7c6a3b1 Merge branch 'main' into beta 2024-10-23 23:10:45 -03:00
Martín Capello 9667def753 Move kCallbackMessage logic to Widget 2024-10-23 23:09:28 -03:00
Martín Capello cbac6f98a7 Fix MouseEnter and MouseLeave (fix #4240)
Callback messages were not being handled and since MouseEnter and
MouseLeave events were wrapped into CallbackMessages they were lost
and so never got called
2024-10-23 23:09:28 -03:00
David Capello b90807f3e3 Merge branch 'main' into beta 2024-10-21 11:09:01 -03:00
David Capello a7799b76fc Add more tracing options to debug UI messages
Added REPORT_MOUSE/PAINT/TIMER_MESSAGES macros, and change _EVENTS to
_MESSAGES to avoid confusion with the current terminology.

The output string for each message was also simplified.
2024-10-17 19:23:52 -03:00
David Capello 71f6dbad28 Assert that we're in the UI thread in some ui::Manager functions
Simplify code removing DEBUG_UI_THREADS.
2024-10-17 15:30:18 -03:00
Martín Capello 96ed89db8a Propagate drop events to ancestors
When a drop event is not handled by a drag & drop enabled widget then
look for the next drag & drop enabled ancestor to propagate the drop
2024-10-15 16:24:41 -03:00
Martín Capello 365bad61d5 Support drag and drop images as new documents 2024-10-15 16:24:41 -03:00
Martín Capello 573822d9f1 Propagate drag & drop events to ancestors 2024-10-15 16:24:41 -03:00
Martín Capello 65ec2bd7b7 Introduce drag & drop events to widgets 2024-10-15 16:24:41 -03:00
David Capello 1d9f14665f New ui::FocusMessage with oldFocus/newFocus fields 2024-08-26 11:47:57 -03:00
David Capello f27fb00acf Merge branch 'main' into beta 2024-06-14 20:26:25 -03:00
David Capello 2c7fc767bf Update GPU flag correctly on all display when it's changed 2024-06-14 20:07:05 -03:00
David Capello 571b4ec9f2 Update to new laf API (os::System::instance()/make()) 2024-03-05 18:50:24 -03:00
David Capello f6db44b81d Fix std::clamp() assert in Manager::onInitTheme() 2023-10-11 15:05:10 -03:00
David Capello bd91a6430f Process os::Event::MouseEnter/Leave in correct order
When we received a MouseEnter/Leave, we were processing those laf-os
events immediately without taking care of all the MouseMove/Down/Up
events in the middle. Now we enqueue all the events as
messages (MouseEnter -> MouseMove/Down/Up -> MouseLeave).

This is important because when we process MouseLeave we are calling
setMouse(nullptr), which resets the mouse widget HAS_MOUSE flag, and
some widgets needs to know if they have the mouse above before the
MouseUp event. With this change we can remove the
Widget::hasMouseOver() function (that was checking the global
ui::get_mouse_position() instead of the HAS_MOUSE flag directly).

Another change was introduced to keep the old behavior now that
hasMouseOver() is not available: the ui::Manager doesn't assign the
HAS_MOUSE flag if the mouse is captured (it only assign the HAS_MOUSE
to the widget with the mouse captured, or to no widget, at least until
the capture is released).
2023-07-10 10:54:37 -03:00
David Capello 8cdb4edcac Fix bug where we were able to click a non-foreground window
With multiple windows on, if a modal/foreground window like Canvas
Size (which has a special onBroadcastMouseMessage()) were running, and
there was a script dialog also opened on the background, the
non-foreground dialog could receive clicks. This patch fixes this
particular scenario (no other window than the actual foreground window
can receive mouse clicks).
2023-05-05 20:08:39 -03:00
David Capello f655d57069 [lua] Add app.editor.spritePos/mousePos and app.editor:cancel()
Added properties needed to know where the mouse position is on the
editor canvas + a method to cancel app.editor:askPoint() from Lua.

Related to aseprite/Attachment-System#102
2023-04-25 09:03:20 -03:00
David Capello b28550faf5 Use new ScopedValue w/o old arg + C++17 class template argument deduction (CTAD) 2023-04-14 13:43:36 -03:00
Martín Capello 8841f3da32 Move window relayout before inserting the window to the manager (fix #3746)
This is necessary to prevent the manager to invalidate a window whose relayout is not finished. This can happen when a script opens a new window when another is currently opening. For instance a script whose canvas.onpaint handler opens another dialog.
2023-04-12 14:10:45 -03:00
David Capello f5a79ce3b8 [lua] Add possibility to specify parent dialog 2023-01-11 09:38:19 -03:00
David Capello f5bc573bfc Remove base::thread, we use std::thread 2023-01-05 16:43:09 -03:00
David Capello bc16ab3a71 Fix crash accessing a deleted display using parentDisplay() (fix #3491, fix #2907)
This might be a fix for two frequently reported crashes from Sentry:

1) In Manager::_closeWindow() (#3491): We can reproduce this bug (without
this patch) pressing Ctrl+S to save the active sprite and clicking
randomly in the menu bar (File, Edit, etc. options) to open other menu
boxes (a crash can happen when multiple windows UI is enabled).

2) In set_native_cursor_on_all_displays() (#2907): We weren't able to
reproduce this bug.
2022-08-29 20:01:50 -03:00
David Capello 05bf34f084 Merge branch 'main' into beta 2022-08-02 16:48:32 -03:00
David Capello 3e6360d024 Fix crash using deleted os::Surface (fix #3451)
It looks like processing a specific kPaintMessage with
ui::Widget::sendMessage() might re-create the os::Surface and destroy
the previous one, so we need to keep a reference to the previous
surface just in case to keep it alive.

We aren't able to reproduce this crash, but we've received several
Sentry reports about it, only on Windows and since v1.2.34.1 (not sure
if it's related to that). We'll see if this does fix the crashes or we
have some kind of regression in the future.
2022-08-02 16:22:13 -03:00
David Capello f8f925c634 Merge branch 'main' into beta 2022-07-13 19:49:03 -03:00
David Capello 4f2eae6b77 Use C++17 [[fallthrough]] if needed 2022-06-29 20:14:03 -03:00
David Capello 8f44b521b6 Merge branch 'main' into beta 2022-06-10 10:31:13 -03:00
David Capello 71d885d2a0 Replace base::clamp -> std::clamp as now we use C++17 2022-06-09 19:05:48 -03:00
David Capello fa6325d237 Add extra checks in Manager::_closeWindow() to avoid crashes
Possible fix for #3362
2022-06-08 13:10:26 -03:00
David Capello 77771b703b Merge branch 'main' into beta 2022-05-30 20:41:35 -03:00