summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/TreeView.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-05-02LibGUI: Only clear `TreeView::m_view_metadata` when requiredCaoimhe
Prior to this commit, we were always clearing the TreeView's metadata, even if it wasn't needed. Now, we only clear it if the callee says that we should invalidate indices. This fixes an issue in FileManager (#6903), where updating the file system by creating/deleting any file/folder would cause the tree to collapse completely. This may be more of a 'patch' than an actual fix, since I don't have a lot of experience with `GUI::TreeView` or `GUI::Model`, but it doesn't appear to break any other `TreeView` use-cases and using FileManager is now much better than it was before :^)
2023-02-02LibGUI: Center TreeView item icons verticallyAndreas Kling
This makes tree views with icons look a lot better at larger font sizes.
2023-01-26LibGfx: Remove `try_` prefix from bitmap creation functionsTim Schumacher
Those don't have any non-try counterpart, so we might as well just omit it.
2023-01-03LibGfx: Make Font::width() return a floatAndreas Kling
2023-01-03LibGUI: Fix highlighting of elements in TreeViewmartinfalisse
Previously, incorrect items were highlighted when hovering over elements in TreeView when there was a column header.
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-11-05LibGUI: Hold down Alt when clicking TreeView to expand full subtreeEaston Pillay
On other operating systems, if you hold down Alt when you click to expand part of a tree, it expands all of the children of the node you clicked. This commit makes our TreeView act the same way :)
2022-08-15LibGUI: Programatically draw table header sorting arrowsTimothy Flynn
These arrows were previously drawn using the code points U+2B06 and U+2B07. The .png files for these emoji were removed in commit bfe99eb and added to the Katica Regular 10 font in commit cf62d08. The emoji were not added to the bold Katica variants that are used by the table header view. The effect is that a "?" replacement character was rendered. Instead of rendering the emoji, we can draw the arrows programatically, like we do in other GUI components (e.g. the scrollbar).
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-04-06LibGUI: Don't stringify non-textlike data in TreeView's tree columnkleines Filmröllchen
This would previously cause silly things like [GUI::Icon] to appear if a non-textlike column was used as the tree column (like, in this example, an icon column). Let's just not write anything instead.
2022-04-06LibGUI: Add is_toggled getter for TreeViewkleines Filmröllchen
This has safer fallbacks than toggle_index, because we want to be able to call it on indices that don't have children.
2022-04-06LibGUI: Associate model index metadata directly with the model indexkleines Filmröllchen
This was using internal_data beforehand, which relies on the internal data to be distinct for different model indices. That's not the case for example for SortingProxyModel. Using the model index directly makes tree expansion work properly when using a tree table widget with a SortingProxyModel.
2022-04-06LibGUI: Register should_fill_selected_rows for GML in TreeViewkleines Filmröllchen
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-01-29LibGUI: Allow falling back to default paint behavior in delegatenetworkException
This patch adds a method that can optionally be implemented to allow a TableCellPaintingDelegate to fall back to the default painting in a View.
2021-11-08LibGfx: Use ErrorOr<T> for Bitmap::try_load_from_file()Andreas Kling
This was used in a lot of places, so this patch makes liberal use of ErrorOr<T>::release_value_but_fixme_should_propagate_errors().
2021-10-27Everywhere: Rename left/right-click to primary/secondaryFiliph Sandström
This resolves #10641.
2021-08-10LibGUI: Draw a focus rect over the row when sel. behavior is SelectRowssin-ack
2021-08-10LibGUI: Partially restore original TreeView column painting behaviorsin-ack
TreeView now prints columns mostly like it used to. The paddings are now properly applied, though. focus_rect drawing has been gated behind a selection_behavior() check to make sure we don't draw a focus rect around the column text when we're supposed to draw it over the entire row.
2021-08-10LibGUI: Default TreeView to SelectionBehavior::SelectItemssin-ack
AbstractTableView (which TreeView inherits from) sets the selection behavior of the view to SelectRows. This is not how TreeViews are used in most of the system, and TreeView::paint_event actually always draws with the assumption of selecting individual items. This commit defines the expected selection behavior for TreeViews. Users of TreeView can still override this via TreeView::set_selection_behavior.
2021-08-08LibGUI: Do not allow tree column to shrink beyond indent and iconsin-ack
We always display the tree indent and the icon, so we shouldn't allow the tree column to shrink beyond that size.
2021-08-08LibGUI: TreeView tree column text painting adjustmentssin-ack
The text was painted with the assumption that no other column would be present after the tree column, which won't always be true. Additionally, some alignment and focus rect-related issues have been fixed.
2021-07-27LibGUI: Add ModelRole::IconOpacity and support it in all views :^)Andreas Kling
This role allows you to specify a custom opacity for icon painting. Note that the opacity is not in effect when the item is either selected and/or hovered.
2021-07-27LibGUI: Remove some unused code in GUI::TreeViewAndreas Kling
2021-07-21LibGfx: Use "try_" prefix for static factory functionsAndreas Kling
Also mark them as [[nodiscard]].
2021-07-10LibGUI: Tighten paint invalidation rects in item views :^)Andreas Kling
AbstractView now has a paint_invalidation_rect(index) function that subclasses can override to provide a tighter invalidation rect for an index.
2021-06-05TreeView: Don't try to move cursor with invalid indexMarcus Nilsson
When clicking on the TreeView in profiler without selecting a node and then pressing up or pgup, cursor_index was in an invalid state. Instead select the first node in the index.
2021-06-01LibGUI/TreeView: Select parent on collapseJelle Raaijmakers
When collapsing a tree that contains the current selection, the parent node becomes selected instead.
2021-05-30LibGUI: Don't scroll TreeView horizontally to bring index into viewAndreas Kling
This behavior was really irritating and basically never what you wanted so let's stop doing it.
2021-05-30LibGUI: Avoid a bunch of virtual calls during TreeView paintingAndreas Kling
The index of the tree column will not change while painting. Neither will the number of columsn. So avoid a whole bunch of virtual function calls by caching these two values at the start of painting.
2021-05-29LibGUI/TreeView: Implement Home/End/PageUp/PageDn navigationJelle Raaijmakers
This adds an implementation for the Home, End, Page Up and Page Down cursor movements for TreeView. Also, the Up and Down movement implementations are replaced by a more efficient traversal mechanism: whereas the old code would walk over all visible nodes every time, the new code only evaluates relevant sibling and parent indices.
2021-05-03LibGUI: Rename ScrollableWidget => AbstractScrollableWidgetAndreas Kling
2021-05-01Everywhere: Turn #if *_DEBUG into dbgln_if/if constexprGunnar Beutner
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
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-13Everywhere: It's now "Foobar", not "FooBar", and not "foo bar"Andreas Kling
I hereby declare these to be full nouns that we don't split, neither by space, nor by underscore: - Breadcrumbbar - Coolbar - Menubar - Progressbar - Scrollbar - Statusbar - Taskbar - Toolbar This patch makes everything consistent by replacing every other variant of these with the proper one. :^)
2021-03-19LibGUI: Walk all visible rows when updating TreeView column sizesthankyouverycool
Previously only rows containing root nodes were considered. Fixes offset content drift and columns failing to resize in multi-column TreeViews
2021-03-19LibGUI: Support double-click resizing multi-column TreeViewsthankyouverycool
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...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-20LibGUI: Always set tree column content width to widest open nodethankyouverycool
Fixes hidable horizontal scrollbars remaining visible even after collapsing their responsible nodes. Tree column width defaults to column header width if wider than current content.
2021-02-03Everywhere: Remove some bitrotted "#if 0" blocksAndreas Kling
2021-01-25Everywhere: Hook up remaining debug macros to Debug.h.asynts
2021-01-25Everywhere: Remove unnecessary debug comments.asynts
It would be tempting to uncomment these statements, but that won't work with the new changes. This was done with the following commands: find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec awk -i inplace '$0 !~ /\/\/#define/ { if (!toggle) { print; } else { toggle = !toggle } } ; $0 ~/\/\/#define/ { toggle = 1 }' {} \; find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec awk -i inplace '$0 !~ /\/\/ #define/ { if (!toggle) { print; } else { toggle = !toggle } } ; $0 ~/\/\/ #define/ { toggle = 1 }' {} \;
2021-01-12Libraries: Move to Userland/Libraries/Andreas Kling