Commit graph

35 commits

Author SHA1 Message Date
FrHun
ccdccadc24 LibGUI: Implement calculated min/preferred sizes for TabWidget 2022-07-04 11:15:40 +02:00
Cameron Youell
5b82bd719e LibGUI: TabWidget add vertical tabs
Add vertical tabs to TabWidget, this can be set using
the ```TabWidget::set_tab_position``` function or in the GML
2022-05-21 22:25:16 +02:00
Sam Atkins
0e1c8e702c LibGUI: Expose more TabWidget properties to GML
- close_button_enabled
- show_tab_bar
- reorder_allowed
2022-05-11 20:16:43 +02:00
Simon Wanner
206d6ece55 LibGfx: Move other font-related files to LibGfx/Font/ 2022-04-09 23:48:18 +02:00
kleines Filmröllchen
7e34b88ed4 LibGUI: Fully support TabWidget in GML
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-03 12:21:05 +02:00
Olivier De Cannière
1b7850f511 LibGUI: Add TabWidget::activate_last_tab() 2022-04-02 23:38:32 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Olivier De Cannière
da714f771d LibGUI: Make only the targeted tab of TabWidget respond to double click
Previously, when double clicking on the tab bar, all tabs would respond
to the double click even if they weren't clicked on.

This issue, for example, prevented renaming of individual tabs in
Spreadsheet and instead asked the user to rename all tabs one by one.
2022-03-16 14:25:47 +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
Erik Biederstadt
0cfe446d3f LibGUI: Allow double clicking on tabwidgets 2021-12-01 00:44:26 +03:30
Andreas Kling
8359975ff3 LibGUI: Make GUI::TabWidget tab creation APIs take String
Ultimately we'd like the caller to provide a String if possible (instead
of a StringView) as we're going to end up storing it.
2021-11-28 08:10:53 +01:00
Andreas Kling
47b6339025 LibGUI: Add GUI::TabWidget::try_add_tab<T>(...)
This is a fallible variant of add_tab<T>(...) that returns ErrorOr.
2021-11-24 13:52:01 +01:00
Andreas Kling
8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Noah Haasis
05aeff1c4d LibGUI: Focus next tab after closing active tab
Focus the next tab after closing the currently active tab.
If the tab being closed is the last one then the new last
tab is active.
2021-10-30 17:13:25 +03:30
Filiph Sandström
d6a0726302 Everywhere: Rename left/right-click to primary/secondary
This resolves #10641.
2021-10-27 22:05:58 +03:00
Peter Elliott
e1684860a3 LibGUI: Support drag-to-reorder in TabWidget 2021-10-07 12:19:27 +02:00
sin-ack
8ea22121ac Userland: Migrate to argument-less deferred_invoke
Only one place used this argument and it was to hold on to a strong ref
for the object. Since we already do that now, there's no need to keep
this argument around since this can be easily captured.

This commit contains no changes.
2021-09-02 03:47:47 +04:30
sin-ack
a086be993b LibGUI: Bias text towards bottom when tabs at top have uneven spacing
This makes the text on inactive tabs in Browser look a lil' bit nicer.
:^)
2021-08-31 16:34:55 +02:00
sin-ack
4959fa4f1e LibGUI: Adjust content area and focus rect of tab buttons
This improves the look of tabs and their focus rects. In particular, the
concept of a "text rect" is removed, and whatever tab content area is
left over after the icon and close button are added is used as the area
to draw the text into. This approach is simpler than having a separate
text rect.
2021-08-31 16:34:55 +02:00
Mustafa Quraish
75a706b6eb Everywhere: Use the Optional<T>::operator==(T) operator
In general, I think `opt == x` looks much nicer than
`opt.has_value() && opt.value() == x`, so I'm updating
the remaining few instances I could find with some regex
magic in my search.
2021-08-27 23:13:51 +02:00
TheFightingCatfish
8a0d465fbc LibGUI: Allow TabWidget to remove all tabs except one 2021-08-06 21:03:34 +02:00
Andreas Kling
410b3c85b6 LibGUI+LibGfx: Highlight currently active tab button with accent color
Use the new "Accent" color role to emphasize the currently active tab
within a GUI::TabWidget. :^)
2021-07-28 20:25:14 +02:00
Luke
3ec4ad8a73 LibGUI: Convert indexes to size_t and use Optional in TabWidget
Previously it was using int for indexes and using the -1 magic value.
Supersedes b9d51b8601
2021-07-28 11:03:27 +02:00
Luke
b9d51b8601 LibGUI: Always reset pressed close button index on mouse up in TabWidget
Previously it would only do this if the mouse was over the close 
button.

If you released the mouse outside the close button, the close button
would appear permanently depressed afterwards.
2021-07-28 01:43:51 +02:00
Marcus Nilsson
bab83ecc95 LibGUI: Tighten invalidation rect for TabWidget
Previously the whole bar was repainted, there's no need to invalidate
past the last tab button.
2021-07-19 16:24:06 +02:00
Andreas Kling
ee3a73ddbb AK: Rename downcast<T> => verify_cast<T>
This makes it much clearer what this cast actually does: it will
VERIFY that the thing we're casting is a T (using is<T>()).
2021-06-24 19:57:01 +02:00
Marcus Nilsson
54852832b1 LibGUI/TabWidget: Make sure we don't act on two mouseup events
Make sure that even if we get two mouseup events, we do not try to
remove the same widget twice.
2021-06-20 21:48:29 +02:00
Marcus Nilsson
49d40a908c LibGUI/TabWidget: Add close button to tabs
This adds an optional close button to tabs, useful in
for example browser and pixelpaint.
2021-06-20 15:16:26 +02:00
Andreas Kling
a1eadc755d LibGUI: Allow tweaking each edge of TabWidget's content margins
Instead of having a single uniform margin around the child content of
a TabWidget, use a GUI::Margins to allow individual per-edge margins.
2021-06-15 14:28:39 +02:00
Matthew Olsson
88cfaf7bf0 LibGfx: Unify Rect, Point, and Size
This commit unifies methods and method/param names between the above
classes, as well as adds [[nodiscard]] and ALWAYS_INLINE where
appropriate. It also renamed the various move_by methods to
translate_by, as that more closely matches the transformation
terminology.
2021-05-02 22:48: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
bcd05e199b LibGUI: Fix uniform TabWidget tabs bleeding outside the widget
The last uniform-sized tab button would bleed outside the tab bar area
due to us not taking the bar margin into account.
2021-04-09 22:30:41 +02:00
Andreas Kling
c8ff507534 LibGUI: Add TabWidget::on_tab_count_change hook 2021-04-09 22:23:14 +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
Renamed from Libraries/LibGUI/TabWidget.cpp (Browse further)