1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 02:35:06 +00:00
Commit graph

1186 commits

Author SHA1 Message Date
Andreas Kling
c241ab75cd LibGUI: Simplify HeaderView::mouseup_event() slightly 2020-08-26 17:00:40 +02:00
Andreas Kling
3f4df7c6da LibGUI: Reset hovered section when mouse cursor leaves a HeaderView 2020-08-26 17:00:40 +02:00
thankyouverycool
45901d4141 LibGUI+HackStudio: Associate new icons with their extensions 2020-08-26 16:59:34 +02:00
Andreas Kling
9a25dd99c3 LibGUI: HeaderView should always notify parent when sections resize
The view needs to recompute the scrollable content size whenever this
happens, so let's always notify it. Previously we were only doing this
when resizing columns with interactively (not programmatically.)
2020-08-26 00:51:35 +02:00
Andreas Kling
cfc30b11ba LibGUI: Rename table view's "cell painting delegate" to "column *"
What you install with this API is a delegate that manages painting of
all the items in a specific column, so let's make the API reflect that.
2020-08-26 00:51:35 +02:00
Andreas Kling
44e371635e LibGUI: Move table view headers into their own widget
This patch introduces the HeaderView class, which is a widget that
implements the column headers of TableView and TreeView.

This greatly simplifies event management in the view implementations
and also makes it much easier to eventually implement row headers.
2020-08-26 00:51:35 +02:00
Andreas Kling
eca6ff353e LibGUI: Make Splitter inherit from Widget instead of Frame
It wasn't using any of the Frame features, so I'm not sure what the
idea here was.
2020-08-26 00:51:35 +02:00
Andreas Kling
ac78531756 LibGUI: Clip GUI::Frame children to the frame_inner_rect()
This way we don't draw the frame border underneath our children. :^)
2020-08-26 00:51:35 +02:00
Andreas Kling
a265d40d6e LibGUI: Allow widgets to clip their child widgets
This patch adds Widget::children_clip_rect() which can be overridden
to tighten clipping of a widget's children. The default implementation
simply returns Widget::rect().
2020-08-26 00:51:35 +02:00
Andreas Kling
af16552624 LibGUI: Add Widget focus proxies
A Widget can now have a focus proxy widget. Questions about focus are
redirected to the proxy if present. This is useful if a widget could
logically get focus, but wants one of its child widgets to actually
handle it.
2020-08-26 00:51:35 +02:00
LepkoQQ
777b298880 LibGUI: Change window size and margin in ColorPicker 2020-08-26 00:38:23 +02:00
LepkoQQ
9e75c124a8 LibGUI: Add spinbox for alpha channel in ColorPicker 2020-08-26 00:38:23 +02:00
LepkoQQ
b10dde70b7 LibGUI: Show current and selected color comparison in ColorPicker 2020-08-26 00:38:23 +02:00
LepkoQQ
9f5310d607 LibGUI: Resize ColorPicker to include frame thickness
Also clamp mouse events to frame rect when dragging outside of the color
field area.
Store hue separately from color, to prevent pure white resetting the hue
back to 0.
2020-08-26 00:38:23 +02:00
LepkoQQ
189c493162 LibGUI: Split ColorPicker in to a field and slider 2020-08-26 00:38:23 +02:00
LepkoQQ
0604f82a96 LibGUI: Select current color when opening picker 2020-08-26 00:38:23 +02:00
Nico Weber
31510de6a8 LibGUI: Make ScrollBar show hover state of scrubber after gutter drag
With this, if clicking the gutter until the scrubber's below the
mouse and then releasing the mouse, the scrubber is correctly
highlighted after releasing the mouse.
2020-08-25 20:20:45 +02:00
Nico Weber
a9136d0f47 LibGUI: Only paint ScrollBar hover states if a component is pressed
While left-mouse is pressed on any component (arrows, gutter, scrubber),
don't draw hover states for components other than the pressed component.

For example, while clicking the arrow-down button and then dragging
around, the arrow-up button and the scrubber now aren't highlighted.
This also means that during a gutter drag session, the scrubber
isn't highlighted while it's under the mouse cursor. That makes
sense, since we get the gutter drag behavior, not the scrubber
drag behavior, in this case.

The highlight is supposed to indicate "clickability", but if the
mouse is already down, they can't be clicked.

Now that I check for it, this seems to match the scrollbar behavior
on Windows.
2020-08-25 20:20:45 +02:00
Nico Weber
23e2944aa4 LibGUI: Make ScrollBar track the currently pressed component
And remove the now-redundant members m_scrubbing, m_scrubber_in_use,
and m_automatic_scrolling_kind.

This also made it clear that we weren't canceling the autoscroll
timer if the scrollbar got disabled while it was scrolling, so
this fixes that too.
2020-08-25 20:20:45 +02:00
Nico Weber
98dd034c29 LibGUI: Make scrollbars keep scrolling by page while clicking the gutter
Note that m_hovered_component is only updated on mouse move, not while
just keeping left down. It's arguably wrong to update it on mouse move
while the mouse is down, I'll probably change things so that it doesn't
update there either.

The behavior on click-in-gutter-keep-left-down-then-move-mouse varies
a surprising amount between platforms. This implements the macOS
behavior where the scrubber follows the mouse direction while scrolling
by pages. (To be precise, it's the macOS behavior of Finder and Preview,
Safari has Windows's scrollbar behavior).

On Windows, the first click locks in the scroll direction and then
dragging the mouse off the scrubber in that direction makes the
scroll continue, but dragging it off the other direction has no effect.
I see no reason for that behavior.
2020-08-25 18:09:56 +02:00
Nico Weber
0a462dac14 LibGUI: Keep scrollbar timer active while mouse is down
Rather than disable and re-enable the timer, always keep it active
and make it do collision checks to decide if it should have an effect.

This is because set_automatic_scrolling_active(true) calls the
timeout callback immediately before starting the timer, and
when clicking the gutter this callback could disable the timer
again (if the first page scroll put the scrubber under the cursor).

Intead of making set_automatic_scrolling_active() work when it's
called reentrantly (which is easy: just swap the order of
on_automatic_scrolling_timer_fired() and timer->start() so that
on_automatic_scrolling_timer_fired() can immediately stop the
timer again, but it's confusing), make the timer check if it
should do anything.

This is keyed off m_last_mouse_position instead of
m_hovered_component because m_hovered_component is a visual state
and we arguably shouldn't modify it while the left mouse button
is down (as it indicated what part is activated on click).
2020-08-25 18:09:56 +02:00
Nico Weber
b96759930d LibGUI: Extract ScrollBar::update_hovered_component() method 2020-08-25 18:09:56 +02:00
Nico Weber
bf0b5c3c5a LibGUI: Extract ScrollBar::component_at_position() method
...and use it in mousedown_event(), which allows putting in
stricter asserts.
2020-08-25 18:09:56 +02:00
Nico Weber
ecf6cbbd02 LibGUI: Make AutomaticScrollingKind a paramter on set_automatic_scrolling_active
Most callers of set_automatic_scrolling_active() also change
m_automatic_scrolling_kind, and it makes it possible to make timer
behavior dependent on the autoscroll kind later.
2020-08-25 16:21:26 +02:00
Nico Weber
129816e056 LibGUI: In ScrollBar, rename AutomaticScrollingDirection to AutomaticScrollingKind
Also rename Decrement to DecrementButton and Increment to
IncrementButton.
2020-08-25 16:21:26 +02:00
Nico Weber
c34956839e LibGUI: Make ScrollBar shift-click use same code path as scrubber click
It's slightly less code, and m_scrubber_in_use is now set correctly
when shift-clicking, keeping the mouse button down, and then
dragging the throbber.

The shift-click brings the scrubber under the cursor, and then
the scrubber_rect().contains() condition is true and both scrubber
drags and shift-click-drags are handled the same naturally.
2020-08-25 16:21:26 +02:00
AnotherTest
5568da9a59 LibGUI: Add a save_as common action 2020-08-25 09:46:28 +02:00
Andreas Kling
f86c074be8 LibGUI: Pressing Return in an editable TableView should begin editing
This matches what happens when you double-click on a cell.
2020-08-24 21:20:54 +02:00
Andreas Kling
0f0b37d137 LibGUI: Return focus to view when stopping editing
If the editing widget (as provided by the editing delegate) was focused
when editing stops, have the view take back focus.
2020-08-24 21:10:00 +02:00
Andreas Kling
032f567422 LibGUI: Always update() after changing AbstractView sort column/order
Otherwise we may end up with a stale appearance until something else
causes it to repaint.
2020-08-24 21:06:42 +02:00
Andreas Kling
2cbe290930 LibGUI: Allow moving the TableView selection horizontally with keyboard 2020-08-24 21:03:34 +02:00
Andreas Kling
e5a6e297bf LibGUI: Add AbstractTableView::scroll_into_view(ModelIndex, bool, bool)
This API lets you specify whether to scroll horizontally, vertically,
or both.
2020-08-24 21:03:34 +02:00
AnotherTest
de13c6939d Spreadsheet: Add a syntax highlighter to the cell editor 2020-08-24 19:15:07 +02:00
AnotherTest
09ccb46980 LibGUI: Calculate the text rect correctly in AbstractTableView
This fixes the misalignments when a header is not left-aligned.
2020-08-24 18:21:33 +02:00
AnotherTest
a6ebd29aa5 Spreadsheet: Start making a spreadsheet application 2020-08-24 18:21:33 +02:00
AnotherTest
e1a819827c LibGUI: Make AbstractTableView and TableView more customisable
This patchset adds a few getters/setters to AbstractTableView to make
its looks more customisable:
- Header width & text alignment
- Default column width
- Ability to disable selected row highlighting
2020-08-24 18:21:33 +02:00
Andreas Kling
638c6b7547 LibGUI: Fix an unsightly pixel glitch in bottom-side tabs 2020-08-24 00:05:40 +02:00
Andreas Kling
03c576acc5 LibGUI+LibGfx: Implement upside-down appearance for bottom-side tabs
GUI::TabWidget has long has a TabPosition::Bottom option, but we still
rendered the tab buttons the same as TabPosition::Top.

This patch implements a custom look for bottom-side tabs. I've done my
best to match the look of the top-side ones, but there might be some
improvements we can make here. :^)
2020-08-23 23:53:45 +02:00
thankyouverycool
f88b2b064c LibGUI: Remove spacing between day labels in Calendar
Provides better centering over columns.
2020-08-23 11:22:21 +02:00
Peter Elliott
45ed58865e LibGUI+WindowServer: Add resize_aspect_ratio()
When a resize_aspect_ratio is specified, and window will only be resized
to a multiple of that ratio. When resize_aspect_ratio is set, windows
cannot be tiled.
2020-08-23 01:05:22 +02:00
Andreas Kling
e374eb3035 LibGUI+WindowServer: Remove ResizeEvent::old_size()
Turns out nobody was using this information anyway, so let's not go
through all the trouble of plumbing it from WindowServer to LibGUI.

Fixes #3247.
2020-08-22 13:11:25 +02:00
Andreas Kling
683ae4f7ad LibGUI: Fix crash during HackStudio application teardown
We can't rely on a plain global WeakPtr during application teardown
since destruction order is not defined. Instead, use a NeverDestroyed
to hold the GUI::Application weak pointer. This way it will always
be reliable.

Fixes #3251.
2020-08-22 13:10:14 +02:00
thankyouverycool
ab3fff4211 LibGUI+Calendar: Make Calendar a common widget in LibGUI
Refactors the Calendar widget into LibGUI and updates the Calendar
app interface. Calendar widget lets layout engine manage most of
its geometry now and has a few new features like tile click
navigation, hover highlighting and a togglable year/month mode.
2020-08-22 11:54:30 +02:00
Itamar
ebab512c03 TextEditor: Increase padding in ruler width 2020-08-22 09:48:59 +02:00
Andreas Kling
8055813ecf LibGUI: Add ComboBox::selected_index()
This returns the currently selected index. It was a bit strange that
we had set_selected_index() but not a way to read it back. :^)
2020-08-21 21:16:13 +02:00
Andreas Kling
6d4016dd01 LibGUI: Use StringBuilder::join() in Shortcut::to_string() 2020-08-19 21:17:02 +02:00
Andreas Kling
f0349323c4 LibGUI: Don't require passing model to FileSystemModel::Node APIs
The Node API was obnoxiously requiring you to pass the model into it
all the time, simply because nodes could not find their way back to
the containing model. This patch adds a back-reference to the model
and simplifies the API.
2020-08-17 22:02:21 +02:00
Andreas Kling
ce48de9845 LibGUI: Add WidgetClassRegistration to Forward.h 2020-08-17 18:05:35 +02:00
Luke
c434a91c91 FileManager: Apply wallpaper on startup
I noticed that nothing actually applies the wallpaper on startup.
I wasn't sure where to put the responsibility, so I gave it to
the desktop mode file manager.

Also adds a save_config option to set_wallpaper so it doesn't
needlessly save the config.
2020-08-17 17:47:14 +02:00
thankyouverycool
bc27aa9b6f LibGUI: Use matching family fonts for TextEditor ruler
Fixes incorrect glyph sizes when drawing bold line counts.
2020-08-16 19:39:46 +02:00