Commit Graph

16 Commits

Author SHA1 Message Date
thankyouverycool
f76d24c2ec LibGUI: Simplify Dialog::ScreenPosition and allow Dialogs to opt out
These options were created 2 years ago but the only use cases thus far
are for Center and CenterWithinParent, so let's chuck the rest for now.

Adds a new DoNotPosition option to opt out of automatic centering and
a ScreenPosition setter and getter for configuration before exec()
2023-05-15 12:15:39 +02:00
thankyouverycool
5c923977b7 LibGUI: Always close() Dialogs no matter the execution result
Fixes Blocking modal race conditions when new windows are created
in the same scope as Dialogs.
2022-11-19 16:04:42 +01:00
Timothy Flynn
5b31a3dbc7 LibGUI: Allow more programmatic control over GUI::InputBox
This will be needed for WebDriver, which will require constructing and
controlling dialogs manually. Currently, InputBox will only set its text
value when the OK button is pressed. This changes InputBox to update its
text when done(ExecResult::OK) is invoked in any way.

This also makes the text_value() method public, allows for setting the
text value, and allows for moving-in the initial text value.
2022-11-16 17:23:56 +00:00
Mike Akers
7eed3dab5d LibGUI: Fix a typo 2022-11-07 20:43:39 -08:00
thankyouverycool
51006930da LibGUI: Only react on KeyDown when escaping a Dialog
Both KeyEvents aren't necessary and erroneously close two
Dialogs at once.
2022-09-08 23:21:54 +01:00
thankyouverycool
589572cfa4 LibGUI+WindowServer: Introduce WindowModes
Previously, Windows only understood blocking modality: Windows were
either modal, i.e., in a blocking state, or not. Windows could also
be set as Accessories or ToolWindows, attributes which technically
applied modes to their parents but were implemented ad hoc. This patch
redefines these modal effects as WindowModes and sets up some helpers.
This will let us simplify a lot of modal logic in the upcoming patches
and make it easier to build new modal effects in the future.

Windows can now set 1 of 5 modes before reification:
-Modeless:	No modal effect; begins a new modal chain
-Passive:	Window joins its modal chain but has no effect
-RenderAbove:	Window renders above its parent
-CaptureInput:	Window captures the active input role from its parent
-Blocking:	Window blocks all interaction with its modal chain

States like fullscreen and tiling are dynamic and don't alter behavior
in modal chains, so they aren't included.
2022-08-25 13:28:50 +02:00
Mike Akers
27f93a3052 LibGUI: Prevent CenterWithinParent Dialogs from appearing offscreen
When a dialog is created the position is checked against the Desktop's
rect and repositioned to be entirely visible. If the dialog is larger
than the desktop's rect it is just centered.
2022-06-20 16:50:25 +01:00
Sam Atkins
cd5210a87a LibGUI: Make Dialog::ScreenPosition an enum class 2022-05-13 16:27:43 +02:00
Sam Atkins
cdffe556c8 LibGUI+Userland: Make Dialog::ExecResult an enum class 2022-05-13 16:27:43 +02:00
networkException
64c66e26f5 LibGUI: Check if event loop is alive before quitting it in Dialog::close
Previously we would quit the event loop of a dialog without checking if
it is still alive in the Window::close overload. This patch updates the
implementation to make use of the existing done method, handling closes
more gracefully.

This fixes a CommandPalette crashing when opening an about dialog, as
since 1074c399f3 the command palette
dialog would handle a WindowBecameInactive event after closing itself
due to the action already being called.
2022-04-26 22:41:44 +02:00
Lenny Maiorani
fe3b846ac8 Libraries: Use default constructors/destructors in LibGUI
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-12 14:44:43 -08:00
LuK1337
84ee95c346 LibGUI: Allow to specify position on screen for Dialog window
This change allows us to specify where on screen we'd like the Dialog
window to be drawn. By default it's set to CenterWithinParent which
may fall back to Center if parent window is unset or not visible on
screen.
2021-07-29 09:24:08 +02:00
LuK1337
62c5a5351c LibGUI: Handle KeyDown when checking for Key_Escape in Dialog too
This makes 'escaping' the dialogs seem bit faster :^)
It also follows what RunWindow and probably others do.
2021-07-13 23:23:49 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00