summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/Widget.cpp
AgeCommit message (Collapse)Author
2023-05-23LibGfx+Everywhere: Change `Gfx::Rect` to be endpoint exclusiveJelle Raaijmakers
Previously, calling `.right()` on a `Gfx::Rect` would return the last column's coordinate still inside the rectangle, or `left + width - 1`. This is called 'endpoint inclusive' and does not make a lot of sense for `Gfx::Rect<float>` where a rectangle of width 5 at position (0, 0) would return 4 as its right side. This same problem exists for `.bottom()`. This changes `Gfx::Rect` to be endpoint exclusive, which gives us the nice property that `width = right - left` and `height = bottom - top`. It enables us to treat `Gfx::Rect<int>` and `Gfx::Rect<float>` exactly the same. All users of `Gfx::Rect` have been updated accordingly.
2023-04-30LibGUI: Use Variant's built-in equality operator in Window and WidgetAndreas Kling
Now that Variant has operator==(), we don't need to go through all this trouble to compare two Variant values.
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-03-16LibCore+Userland: Add DEPRECATED infix to REGISTER_STRING_PROPERTY macroKarol Kosek
2023-03-06Everywhere: Stop using NonnullRefPtrVectorAndreas Kling
This class had slightly confusing semantics and the added weirdness doesn't seem worth it just so we can say "." instead of "->" when iterating over a vector of NNRPs. This patch replaces NonnullRefPtrVector<T> with Vector<NNRP<T>>.
2023-02-21LibGUI: Fix const-correctness issuesAndreas Kling
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-02-05LibGfx: Pass font width to `FontDatabase::get()`Aliaksandr Kalenik
Width need to be passed to `FontDatabase::get()` to resolve font name unambiguously.
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::IntPoint by valueMacDue
This is just two ints or 8 bytes or the size of the reference on x86_64 or AArch64.
2022-12-06Everywhere: Rename to_{string => deprecated_string}() where applicableLinus Groh
This will make it easier to support both string types at the same time while we convert code, and tracking down remaining uses. One big exception is Value::to_string() in LibJS, where the name is dictated by the ToString AO.
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-11-19LibGUI: Let Widgets track their focus proxy delegatorsthankyouverycool
And update them on relevant events.
2022-11-19LibGUI+WindowServer+Applets+Taskbar: Remove active input conceptsthankyouverycool
and the CaptureInput mode. They are a source of unneeded complexity in WindowServer and have proven prone to regressions, so this patch replaces them with a simple input preemption scheme using Popups. Popup windows now have ergonomics similar to menus: When open, a popup preempts all mouse and key events for the entire window stack; however, they are fragile and will close after WindowServer swallows the first event outside them. This is similar to how combo box windows and popups work in the classic Windows DE and has the added benefit of letting the user click anywhere to dismiss a popup without having to worry about unwanted interactions with other widgets.
2022-11-14LibGUI: Handle Action keyboard shortcuts in Widget keydownZaggy1024
Widgets can now prevent shortcut Actions from being called, which allows text input keydown handlers to override single key shortcuts.
2022-11-14LibGUI: Share code for finding an Action by ShortcutZaggy1024
This moves logic for finding a shortcut on a Window or Widget to Action::find_action_for_shortcut instead.
2022-09-20LibGUI: Fire Show/Hide events when adding/removing widget from treeAndreas Kling
This ensures that widgets always get an initial show event.
2022-08-25LibGUI+WindowServer+Apps: Replace Accessory Windowsthankyouverycool
with the CaptureInput WindowMode. This mode will serve the same function as accessories: redirecting input while allowing parent windows to remain active.
2022-08-16LibGUI: Don't let widgets hide tooltips they didn't showDavid Smith
Widget::handle_leave_event() hides the tooltip if one is shown. That's usually fine and hides the widget's tooltip, but it can happen that another widget managed to show a tooltip after the Leave event was triggered and before it's processed. Thus change handle_leave_event() to only hide the tooltip if it was show by the widget. Fixes the case where this could happen in the flame graph in Profiler when moving the mouse over the tooltip window itself #14852.
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-07-05LibGUI: Don't ignore invisible widgets during layout changesthankyouverycool
As they may be setting themselves visible again in the process. Fixes inability to toggle widgets on and off in some apps.
2022-07-04LibGUI: Notify layout system of more relevant events in WidgetFrHun
2022-07-04LibGUI: Avoid some unneeded relayouts from layout relevant changesFrHun
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 read-only effective size properties for debuggingFrHun
These new read-only properties help with debugging layouts, by exposing the size values that are actually used for final size determination.
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: Introduce UIDimension propertiesFrHun
2022-06-28LibGUI: Use UIDimension in place of int in WidgetFrHun
2022-06-10LibGUI: Add layout spacer support to GMLFrHun
This is a bit of a hack, but it is an easy way to finally get spacers into GML. This will translate well if spacers are later to become child objects of the continer widget.
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-09LibGfx: Move other font-related files to LibGfx/Font/Simon Wanner
2022-04-03LibGUI: Fully support TabWidget in GMLkleines Filmröllchen
TabWidgets couldn't be used in GML properly, as the GML creation routines didn't actually call the necessary functions in the TabWidget to get a new tab added. This commit fixes that by making the name of the tab a normal property, the previously introduced "title", which can be trivially set from GML. Therefore, try_add_widget() loses an argument (while try_add_tab doesn't, because it newly constructs the widget). This allows us to get rid of the silly "fixing my widget tree after the fact" code in Help and will make it super easy to use TabWidget in future GML. :^)
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-25Userland: Rename WindowServerConnection=>ConnectionToWindowServerItamar
This was done with CLion's automatic rename feature.
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-07LibGUI: Remove GML prefix in favor of proper namespacekleines Filmröllchen
Prefixes are very much a C thing which we don't need in C++. This commit moves all GML-related classes in LibGUI into the GUI::GML namespace, a change somewhat overdue.
2022-02-01Everywhere: Fully qualify font names by including their slopethankyouverycool
Fixes typefaces of the same weight but different slopes being incorrectly returned for each other by FontDatabase.
2022-01-10LibGUI+AK: Add DRAG_DEBUG opt and put drag operations behind dbgln_ifMarcus Nilsson
No need to have this enabled all the time.
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
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-11-02LibGUI: Make sure that children are actually widgetsthislooksfun
Previously this section of code would blindly add *anything* as a child as long as it has been registered as an object. Since there is no guarentee that those objects are, in fact, Widgets, this feels like a logical fallacy. For example, up until this change, this is perfectly valid GML: ``` @GUI::Widget { layout: @GUI::VerticalBoxLayout { } @GUI::VerticalBoxLayout { } } ``` What exactly does it do? Who knows! It doesn't seem to *break*, but I think we can all agree it shouldn't be valid. Instead, we now actually verify that the registered class inherets from GUI::Widget before adding it as a child. We also error if it's not, which should hopefully help new GML writers from forgetting to write 'layout: ' before the layout definition and being confused as to why it's not working.