summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/Widget.h
AgeCommit message (Collapse)Author
2023-03-16LibGUI+HackStudio+PixelPaint: Port Widget title to the new StringKarol Kosek
I had to add a set_title(String) helper function for ImageEditor because TabWidget requires it. This is a temporary fix and will be handled in subsequent commit.
2023-02-21LibGUI: Fix const-correctness issuesAndreas Kling
2023-02-18LibGUI+Userland: Stop returning Layout from `Widget::(try_)set_layout()`Sam Atkins
Nobody uses this return value any more. It also lets us remove a whole bunch of `(void)` casts. :^)
2023-02-18LibGUI: Add Widget::add_spacer() wrapperSam Atkins
This just calls Layout::try_add_spacer(), but saves you having to access the Widget's Layout directly. We verify that the Widget has a Layout, since it would be a programming error if we tried to do so without one.
2023-01-07LibGUI+Userland: Rename `try_load_from_gml()` -> `load_from_gml()` :^)Sam Atkins
It's the only one, so the `try` prefix is unnecessary now.
2023-01-07LibGUI: Delete old now-unused `Widget::load_from_gml()`Sam Atkins
2023-01-07LibGUI: Create an alias for Widget UnregisteredChildHandlerSam Atkins
2023-01-01LibGUI+Userland: Make GML unregistered_child_handler fallibleSam Atkins
2023-01-01LibCore+LibGUI: Add fallible versions of Widget::load_from_gml()Sam Atkins
The existing `load_from_gml()` methods look the same as before from the outside. Inside though, they now forward to `try_load_from_gml()` which returns Error when things go wrong. It also now calls the `try_create()` factory method for Objects instead of the `construct()` one.
2022-12-07Meta+Userland: Pass Gfx::IntSize by valueMacDue
Just two ints like Gfx::IntPoint.
2022-12-07Meta+Userland: Pass Gfx::IntPoint by valueMacDue
This is just two ints or 8 bytes or the size of the reference on x86_64 or AArch64.
2022-12-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
2022-12-05LibGUI: Fix a typoCameron Youell
2022-12-03Everywhere: Run clang-formatLinus Groh
2022-11-19LibGUI: Let Widgets track their focus proxy delegatorsthankyouverycool
And update them on relevant events.
2022-11-19LibGUI+WindowServer: Replace WindowInput{Enter,Leave} Eventsthankyouverycool
with WindowInput{Preempted,Restored} Events and allow Widgets to save the state of their focus preemption. As of now, only Popups will preempt input and trigger these events.
2022-09-30LibCore+LibGUI: Make it fast to check if a Core::Object is a WidgetAndreas Kling
This check happens very often in LibGUI code. 25% of time spent layouting the emoji input dialog was wasted on RTTI. Adding a simple fast_is<Widget>() melts almost all of that away.
2022-09-11LibGUI+LibVT: Notify widgets of emoji selection with a callbackTimothy Flynn
Currently, LibGUI modifies the Ctrl+Alt+Space key event to instead represent the emoji that was selected through EmojiInputDialog. This is limited to a single code point. For multiple code point emoji support, individual widgets now set a hook to be notified of the emoji selection with a UTF-8 encoded string. This replaces the previous set_accepts_emoji_input() method.
2022-08-16LibGUI: Retain the active input tracking widget's cursorAndreas Kling
Until the tracking stops, we want to keep displaying the same cursor.
2022-07-19LibGUI: Add VerticalDirection::operator!Lucas CHOLLET
This allows to invert the direction of a VerticalDirection.
2022-07-15LibGUI: Add a helper for VerticalDirectionLucas CHOLLET
The function converts Key_[Up, Down] to the corresponding VerticalDirection.
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2022-06-30LibGUI: Add layout change propagation to WidgetFrHun
This function is intended to propagate layout changes upwards in the widget hierarchy. Widgets that can know what to do with this information without causing a full layout invalidation (i.e. just because one of their child widgets changed layout/size, doesn't necessairily mean that they have to change their layout/size) can override this and prevent a full relayout and redraw.
2022-06-28LibGUI: Add effective and calculated sizes to WidgetFrHun
Effective sizes are the ones that are actually to be used for layout. They are just their respective propertys value, or the value returned by the calculated_<min/preferred>_size, when the respective property is set to shrink or fit. The "calculated" values in turn are specific to the widget. Container widgets for example can calculate their values depending on their layout and child widget requirement. Simple widgets like labels and buttons can for example calculate their values based upon their current text.
2022-06-28LibGUI: Use preferred_size to emulate old is_shrink_to_fitFrHun
2022-06-28LibGUI: Add preferred_size to WidgetFrHun
2022-06-28LibGUI: Use UIDimension in place of int in WidgetFrHun
2022-05-30LibGUI: Search for actions with a Shortcut instead of for KeyEventGeordie Hall
Instead of having widget/window/application create a shortcut from a KeyEvent within their find methods, we'll just pass them a Shortcut so that the "where to search" logic doesn't need to be duplicated for different Shortcut types. It also lets us handle invalid Shortcut rejection at a higher level, with most things letting the caller be responsible for not searching for actions with an invalid shortcut.
2022-04-03LibGUI: Add a title to all Widgetskleines Filmröllchen
This title is a generic user-facing name for the widget. For now, it's only used by TabWidget for tab names.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-12Libraries: Use default constructors/destructors in LibGUILenny Maiorani
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-02-07LibGUI: Move GML parsing and formatting to new ASTkleines Filmröllchen
This commit introduces a couple of connected changes that are hard to untangle, unfortunately: - Parse GML into the AST instead of JSON - Change the load_from_json API on Widget to load_from_gml_ast - Remove this same API from Core::Object as it isn't used outside of LibGUI and was a workaround for the object registration detection; by verifying the objects we're getting and casting we can remove this constraint. - Format GML by calling the formating APIs on the AST itself; remove GMLFormatter.cpp as it's not needed anymore. After this change, GML formatting already respects comments :^)
2022-02-03LibGUI: Allow widgets to opt-out from showing the command paletteSam Atkins
2021-11-24LibGUI: Add GUI::Widget::try_set_layout<T>(...)Andreas Kling
This is a fallible variant of set_layout<T>(...) that returns ErrorOr.
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-11-03LibGUI: Add content marginsFrHun
Introduce the basic interface through which widgets can define a rect relative to which Layout margins are now applied.
2021-11-03LibGUI+FileManager: Clarify Widget margins nameFrHun
Even though they are called content_margins, they are actually only ever used to determine where a Widget is supposed to be grabbable. So all methods and members are renamed accordingly.
2021-10-31LibGUI: Support using a bitmap as override cursorMarco Cutecchia
2021-10-23LibGUI: Add Widget::repaint() to force an immediate repaintAndreas Kling
In most situations, Widget::update() is preferable, since that allows us to coalesce repaints and avoid redundant work, reducing system load. However, there are some cases where you really want a paint to happen right away, to make sure that the user has a chance to see a short-lived visual state.
2021-10-21LibGUI: Move GUI::FocusPolicy to its own header & add explainer commentAndreas Kling
2021-09-22LibGUI: Rename CallOnChange => AllowCallback and implement elsewherethankyouverycool
This is a helpful option to prevent unwanted side effects, distinguish between user and programmatic input, etc. Sliders and SpinBoxes were implementing it idiosyncratically, so let's generalize the API and give Buttons and TextEditors the same ability.
2021-09-19LibGUI: Add option to disable on_change call for sliders set_value()David Isaksson
This makes it possible to avoid messy situations where a slider controlled value can be changed from multiple sources.
2021-09-08LibGUI+WindowServer: Remove now-obsolete cursor tracking featureBen Wiederhake
This feature was problematic for several reasons: - Tracking *all* the user activity seems like a privacy nightmare. - LibGUI actually only supports one globally tracking widget per window, even if no window is necessary, or if multiple callbacks are desired. - Widgets can easily get confused whether an event is actually directed at it, or is actually just the result of global tracking. The third item caused an issue where right-clicking CatDog opened two context menus instead of one.
2021-08-31WindowServer: Add message to notify clients of applet area resizeJoe Bentley
Applets and windows would like to be able to know when the applet area has been resized. For example, this happens asynchronously after an applet has been resized, so we cannot then rely on the applet area position synchronously after resizing. This adds a new message applet_area_rect_changed and associated Event AppletAreaRectChange, and the appropriate virtual functions.
2021-08-18LibGUI: Allow widgets to make themselves non-auto-focusableRob Ryan
This patchs adds a way for widgets exclude themselves from being a focus candidate in Window::focus_a_widget_if_possible(). This is to allow the URL box to not get auto-focused when the browser is loaded.
2021-07-28Revert "LibGUI: Only dispatch Leave if the now-hovered widget isn't a child"Andreas Kling
This reverts commit cfc9ee6f16b9c4d2b246bb2832dd436637cbeaad. This change was wrong: The parent *does* lose hover when the mouse cursor enters a child widget. Hover is not hierarchical, there is only a hovered window and a hovered widget within that window. This fixes an issue with GUI::TabWidget buttons appearing hovered despite the mouse cursor not being over the buttons.
2021-07-26LibGUI: Only dispatch Leave if the now-hovered widget isn't a childsin-ack
Without this change, when the mouse starts hovering over a child widget, the parent would receive a Leave event despite the parent widget not losing mouse hover.
2021-07-12LibGUI: Redraw widgets when default font changesLuK1337
2021-07-12LibGUI: Add FontsChanged event and deliver it to windows and widgetsLuK1337
2021-07-05LibGUI: Don't fire visibility-tracking timers in non-visible widgetsAndreas Kling
We were already avoiding firing timers within non-visible *windows*. This patch extends the mechanism to support timers within non-visible *widgets*.