Commit Graph

45 Commits

Author SHA1 Message Date
Caoimhe
d05cb50b24 LibGUI: Only clear TreeView::m_view_metadata when required
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-05-02 07:24:55 +02:00
Andreas Kling
eb9d2c64c8 LibGUI: Center TreeView item icons vertically
This makes tree views with icons look a lot better at larger font sizes.
2023-02-02 14:49:54 +01:00
Tim Schumacher
82a152b696 LibGfx: Remove try_ prefix from bitmap creation functions
Those don't have any non-try counterpart, so we might as well just omit
it.
2023-01-26 20:24:37 +00:00
Andreas Kling
3407ab0fd1 LibGfx: Make Font::width() return a float 2023-01-03 15:25:02 +01:00
martinfalisse
481c0419ba LibGUI: Fix highlighting of elements in TreeView
Previously, incorrect items were highlighted when hovering over
elements in TreeView when there was a column header.
2023-01-03 12:46:51 +00:00
MacDue
7be0b27dd3 Meta+Userland: Pass Gfx::IntPoint by value
This is just two ints or 8 bytes or the size of the reference on
x86_64 or AArch64.
2022-12-07 11:48:27 +01:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
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-06 08:54:33 +01:00
Easton Pillay
22d54cd446 LibGUI: Hold down Alt when clicking TreeView to expand full subtree
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-11-05 14:49:22 +01:00
Timothy Flynn
32642394a9 LibGUI: Programatically draw table header sorting arrows
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-08-15 17:17:54 +02:00
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
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-12 23:11:35 +02:00
kleines Filmröllchen
cd5ed44f64 LibGUI: Don't stringify non-textlike data in TreeView's tree column
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-06 12:47:50 +02:00
kleines Filmröllchen
4e8cb0508f LibGUI: Add is_toggled getter for TreeView
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-06 12:47:50 +02:00
kleines Filmröllchen
d813bf77ee LibGUI: Associate model index metadata directly with the model index
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-06 12:47:50 +02:00
kleines Filmröllchen
68a758304a LibGUI: Register should_fill_selected_rows for GML in TreeView 2022-04-06 12:47:50 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01: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
networkException
b67d4ab52f LibGUI: Allow falling back to default paint behavior in delegate
This patch adds a method that can optionally be implemented to allow
a TableCellPaintingDelegate to fall back to the default painting in a
View.
2022-01-29 11:22:02 +01:00
Andreas Kling
235f39e449 LibGfx: Use ErrorOr<T> for Bitmap::try_load_from_file()
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-11-08 00:35:27 +01:00
Filiph Sandström
d6a0726302 Everywhere: Rename left/right-click to primary/secondary
This resolves #10641.
2021-10-27 22:05:58 +03:00
sin-ack
309a20c014 LibGUI: Draw a focus rect over the row when sel. behavior is SelectRows 2021-08-10 21:56:47 +02:00
sin-ack
158629d1c4 LibGUI: Partially restore original TreeView column painting behavior
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-10 21:56:47 +02:00
sin-ack
8c1a6a8436 LibGUI: Default TreeView to SelectionBehavior::SelectItems
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-10 21:56:47 +02:00
sin-ack
1408aa1295 LibGUI: Do not allow tree column to shrink beyond indent and icon
We always display the tree indent and the icon, so we shouldn't allow
the tree column to shrink beyond that size.
2021-08-08 14:12:45 +02:00
sin-ack
ba768eb872 LibGUI: TreeView tree column text painting adjustments
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-08-08 01:41:23 +02:00
Andreas Kling
8ba47facf6 LibGUI: Add ModelRole::IconOpacity and support it in all views :^)
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-27 18:27:49 +02:00
Andreas Kling
4486e5b26d LibGUI: Remove some unused code in GUI::TreeView 2021-07-27 18:27:49 +02:00
Andreas Kling
c7d891765c LibGfx: Use "try_" prefix for static factory functions
Also mark them as [[nodiscard]].
2021-07-21 18:02:15 +02:00
Andreas Kling
df96380121 LibGUI: Tighten paint invalidation rects in item views :^)
AbstractView now has a paint_invalidation_rect(index) function that
subclasses can override to provide a tighter invalidation rect for
an index.
2021-07-10 18:30:46 +02:00
Marcus Nilsson
94551149d1 TreeView: Don't try to move cursor with invalid index
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-05 11:27:05 +02:00
Jelle Raaijmakers
7a4445a1fe LibGUI/TreeView: Select parent on collapse
When collapsing a tree that contains the current selection, the parent
node becomes selected instead.
2021-06-01 08:22:51 +02:00
Andreas Kling
460c0f9847 LibGUI: Don't scroll TreeView horizontally to bring index into view
This behavior was really irritating and basically never what you wanted
so let's stop doing it.
2021-05-30 09:28:19 +02:00
Andreas Kling
42b27d9f87 LibGUI: Avoid a bunch of virtual calls during TreeView painting
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-30 09:05:37 +02:00
Jelle Raaijmakers
80a84f726e LibGUI/TreeView: Implement Home/End/PageUp/PageDn navigation
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-29 21:58:51 +04:30
Andreas Kling
d47f15ab8b LibGUI: Rename ScrollableWidget => AbstractScrollableWidget 2021-05-03 21:03:13 +02:00
Gunnar Beutner
6cf59b6ae9 Everywhere: Turn #if *_DEBUG into dbgln_if/if constexpr 2021-05-01 21:25:06 +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
a2baab38fd Everywhere: It's now "Foobar", not "FooBar", and not "foo bar"
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-04-13 16:58:15 +02:00
thankyouverycool
cfaf97a463 LibGUI: Walk all visible rows when updating TreeView column sizes
Previously only rows containing root nodes were considered. Fixes
offset content drift and columns failing to resize in multi-column
TreeViews
2021-03-19 22:56:36 +01:00
thankyouverycool
bf86676272 LibGUI: Support double-click resizing multi-column TreeViews 2021-03-19 22:56:36 +01: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
thankyouverycool
ef61a963e9 LibGUI: Always set tree column content width to widest open node
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-20 22:27:52 +01:00
Andreas Kling
9c77980965 Everywhere: Remove some bitrotted "#if 0" blocks 2021-02-03 11:17:47 +01:00
asynts
eea72b9b5c Everywhere: Hook up remaining debug macros to Debug.h. 2021-01-25 09:47:36 +01:00
asynts
acdcf59a33 Everywhere: Remove unnecessary debug comments.
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-25 09:47:36 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00