1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 22:05:07 +00:00
Commit graph

1186 commits

Author SHA1 Message Date
AmusedNetwork
de6483bcdb LibGUI: Set vertical distance between icons relative to scroll value
When calculating the vertical distance between icons, we should take
into account the value of the vertical scrollbar.

Fixes #4040
2020-11-11 15:14:09 +01:00
Andreas Kling
50aa726db7 LibGUI: Ignore application-global shortcuts in modal windows
This is making me question the usefulness of application-global
shortcuts, but for now let's just prevent them from triggering while
you're looking at a modal message box..
2020-11-10 19:41:03 +01:00
Tom
75f61fe3d9 AK: Make RefPtr, NonnullRefPtr, WeakPtr thread safe
This makes most operations thread safe, especially so that they
can safely be used in the Kernel. This includes obtaining a strong
reference from a weak reference, which now requires an explicit
call to WeakPtr::strong_ref(). Another major change is that
Weakable::make_weak_ref() may require the explicit target type.
Previously we used reinterpret_cast in WeakPtr, assuming that it
can be properly converted. But WeakPtr does not necessarily have
the knowledge to be able to do this. Instead, we now ask the class
itself to deliver a WeakPtr to the type that we want.

Also, WeakLink is no longer specific to a target type. The reason
for this is that we want to be able to safely convert e.g. WeakPtr<T>
to WeakPtr<U>, and before this we just reinterpret_cast the internal
WeakLink<T> to WeakLink<U>, which is a bold assumption that it would
actually produce the correct code. Instead, WeakLink now operates
on just a raw pointer and we only make those constructors/operators
available if we can verify that it can be safely cast.

In order to guarantee thread safety, we now use the least significant
bit in the pointer for locking purposes. This also means that only
properly aligned pointers can be used.
2020-11-10 19:11:52 +01:00
AmusedNetwork
eac0344ef0 LibGUI: Limit the height of item text in IconView
Set the max height of the text_rect to be the height difference
between two icons. Calculate the number of text lines that can be
displayed in this height, and display only that many.
2020-11-10 09:54:18 +01:00
Jack Byrne
1041ab88ca
TextEditor: Go-to-line now shows line in middle of view (#4008) 2020-11-10 09:53:50 +01:00
AnotherTest
a2cfb7eb94 LibGUI: Prevent multiple drag initiations while drag messages are passed 2020-11-08 21:46:13 +01:00
AnotherTest
6d1e47e7dd LibGUI+WindowServer: Make DragOperation hold a MimeData instance
...instead of maybe bitmap + a single mime type and its corresponding data.
This allows drag&drop operations to hold multiple different kinds of
data, and the views/applications to choose between those.
For instance, Spreadsheet can keep the structure of the dragged cells,
and still provide text-only data to be passed to different unrelated editors.
2020-11-08 21:46:13 +01:00
Linus Groh
d1e1cfc133 LibGUI: Limit ScrollableWidget::available_size() width/height to 0
The current implementation is lying, it returns negative values if the
inner rect has a zero width or height but also a scrollbar - which
doesn't mean there's a "negative size" available though; it's still "no
size available", i.e. 0.
2020-11-08 17:21:11 +01:00
Joseph Bywater
348cd0fdc1 LibGUI: Clip rubber band to IconView widget content area
Add a clip rect for the rubber band painter of widget_inner_rect
This ensures the rubber band is not drawn over the scrollbars.

Fixes #3926
2020-11-06 15:50:46 +01:00
Joseph Bywater
15bc42479a LibGUI: Fix AbstractView selection after initial focusin event
After moving the cursor to the home position, clear the
selection.

Fixes #3925.
2020-11-06 00:33:47 +01:00
AnotherTest
6e9c6acc87 LibGUI: Implement shift-select
shift-selecting simply toggles all indices in the range between the
cursor and the index that is being 'selected'.
2020-11-03 16:47:56 +01:00
Joseph
9efcb5d290
LibGUI: Return early if drag_data_type is null (#3919)
If the user tries to drag an item with a null drag data type from an
AbstractView, return from the mouse event early.
2020-11-02 22:26:38 +01:00
Andreas Kling
a7f4f6afc3 LibGUI: Allow dragging a previously unselected item with a single click
Views would previously require that an item be selected before it could
be dragged. This patch makes us consider initiating a drag immediately
after the view has been selected, without requiring a mouseup event in
between.
2020-11-01 15:42:09 +01:00
Andreas Kling
844c5709ac LibGUI: Views should ignore double clicks that don't hit any index 2020-11-01 15:31:18 +01:00
Andreas Kling
e499b0f161 LibGUI: Invalidate view cursor on model update
This is sad (since it would be nice to preserve the cursor+selection)
but until we implement persistent model indexes, this at least prevents
us from keeping a stale cursor index.
2020-11-01 10:39:37 +01:00
Andreas Kling
982e066100 LibGfx: Move FontDatabase from LibGUI to LibGfx
Not sure why I put this into LibGUI in the first place.
2020-10-31 13:56:21 +01:00
Andreas Kling
66a8e151fb LibGUI: Remove redundant scroll_into_view() calls in TableView
The calls to set_cursor() already take care of scrolling the new cursor
into view if needed.
2020-10-30 23:52:59 +01:00
Andreas Kling
b11b4b29e9 LibGUI: Add Widget::has_focus_within()
This returns true if the widget has focus, or if one of its descendant
widgets does. Use this in StackWidget and TabWidget.

This also fixes HackStudio crashing on startup in StackWidget, due to
running before the window has a focused widget.
2020-10-30 23:40:23 +01:00
Andreas Kling
dee639f19b LibGUI: Improve TabWidget+StackWidget focus behavior further
When setting a new active widget, transfer focus if it's anywhere in
the old active widget's tree, not just at the immediate child.
2020-10-30 19:17:09 +01:00
Andreas Kling
b0cdb6b074 LibGUI: Deduplicate widgets with proxied focus in focus chain
When computing the chain of focusable widgets in a window, only include
each widget once (to avoid loops) and resolve focus proxies immediately
instead of lazily. This prevents the focus from getting stuck when
cycling backwards and hitting a proxy that points forward.
2020-10-30 19:17:09 +01:00
Andreas Kling
ddad7575a9 LibGUI: Improve automatic focus guessing somewhat
When opening a new window, we'll now try to find a suitable widget for
initial focus by picking the first available mouse-focusable one.

Whenever you press the tab key in a window with no focused widget,
we'll attempt to find a keyboard-focusable widget and give it focus.

This should make all applications keyboard-interactive immediately
without having to manually place focus with the mouse.
2020-10-30 17:03:29 +01:00
Andreas Kling
28df2ede06 LibGUI: Use ToolBarButton helper class inside ToolBar 2020-10-30 17:03:29 +01:00
Andreas Kling
9baa649389 LibGUI: Fix null parent deref in AbstractButton::set_checked()
If a button is orphaned, there are no siblings anyway, so there's no
need to try to update them.
2020-10-30 17:03:29 +01:00
Andreas Kling
3f4df354cb LibGUI: Make TabWidget unfocusable when tab-less
If there are no tab buttons or tab children, don't participate in the
focus chain.
2020-10-30 17:03:29 +01:00
Andreas Kling
0b798a50dc LibGUI: Make StackWidget/TabWidget preserve focus in inactive windows
This one is a bit sketchy. While a window is inactive, none of its
widgets are considered focused (Widget::is_focused() will return false)
but this caused programmatic changes of the active widget in a tab
or stack widget to fail focus propagation from old child to new child.

Work around this by checking against Window::focused_widget() directly
instead of asking Widget::is_focused().
2020-10-30 17:03:29 +01:00
Andreas Kling
cf93c66e6e LibGUI: Make StackWidget set the active widget as its focus proxy
This transparently transfers focus to the active widget whenever the
stack widget is focused.
2020-10-30 17:03:29 +01:00
Andreas Kling
698490c565 LibGUI: Make TabWidget focusable and allow left/right arrow tab switch
You can now focus a TabWidget by tabbing (with the keyboard!) to it.
Once focused, you can switch the active tab by pressing the left/right
keyboard keys.
2020-10-30 17:03:28 +01:00
Andreas Kling
73ea191a05 LibGUI: TabWidget should not steal focus on programmatic tab switch
This matches the behavior of GUI::StackWidget.
2020-10-30 17:03:28 +01:00
Andreas Kling
aef56159a8 LibGUI: Add Widget focus policies
Every widget now has a GUI::FocusPolicy that determines how it can
receive focus:

- NoFocus: The widget is not focusable (default)
- TabFocus: The widget can be focused using the tab key.
- ClickFocus: The widget can be focused by clicking on it.
- StrongFocus: Both of the above.

For widgets that have a focus proxy, getting/setting the focus policy
will affect the proxy instead.
2020-10-30 17:03:28 +01:00
Andreas Kling
23c4f10027 LibGUI: Add TextDocument::span_at(TextPosition) 2020-10-29 23:52:07 +01:00
Andreas Kling
d27a8e505f LibGUI: IconView was hard-coding column 0 instead of model_column()
Some of the indexes generated during cursor movement were using column
instead of model_column(), which caused inconsistent display of items
under the cursor.
2020-10-28 21:41:51 +01:00
Andreas Kling
de3dc15a6e LibGUI: Default-initialize cursor when focusing an AbstractView
If an AbstractView receives focus without a valid cursor index, we now
ask it to move its cursor to the home position. This way, the user can
actually start moving the cursor after tabbing to a view.
2020-10-28 21:40:31 +01:00
Andreas Kling
1f789a07b1 LibGUI: Don't start AbstractView type-ahead search with tab key
This was preventing views from relinquishing focus via the keyboard.

Fixes #3862.
2020-10-28 21:26:27 +01:00
Andreas Kling
80e12999c4 LibGUI: Model-less views should not swallow key events
At least pass them up to GUI::Widget so they can be handled there.
2020-10-28 21:26:27 +01:00
Andreas Kling
3ec19ae4b6 LibGUI+LibGfx+WindowServer: Auto-generate disabled action icons :^)
This patch adds a simple filter that makes button and menu item icons
have that "'90s disabled" look when disabled. It's pretty awesome.
2020-10-27 21:25:40 +01:00
Andreas Kling
ea14c67e29 LibGUI: Make TreeView use the view cursor properly
TreeView was still partly sticking to the pre-cursor way of using the
first index in the selection as the implied cursor. This patch fixes
all of the TreeView code to operate on the cursor instead.

This makes trees behave much more intuitively when alternating between
mouse and keyboard interaction.
2020-10-27 21:00:12 +01:00
Andreas Kling
0391806eec LibGUI: Shrink the default selection rect of TreeView items
Instead of filling the whole row with selection color, only fill behind
the text. This gives a snugger, more focused appearance.

For embedders that want the entire row to get filled with the selection
color when selected, they can opt in to the old behavior by calling
TreeView::set_should_fill_selected_rows(). This is used by Profiler.
2020-10-27 20:33:30 +01:00
Andreas Kling
df98c9ebbe LibGUI: Run clang-format on TableView.cpp 2020-10-27 20:21:51 +01:00
Andreas Kling
f7d8174bee LibGUI: Paint a focus rect around the cursor index in ColumnsView 2020-10-27 16:20:20 +01:00
Andreas Kling
c0076681ad LibGUI: Paint a focus rect around the cursor index in TableView 2020-10-27 16:18:55 +01:00
Andreas Kling
5030f1ed4b LibGUI: Paint a focus rect around the cursor index in IconView
This makes the cursor actually visible to the user, and looks rather
neat if I may say so. :^)
2020-10-27 16:12:54 +01:00
Andreas Kling
272af7685b LibGUI: Improve and simplify IconView item name wrapping
Move the wrapping logic to get_item_rects(). This makes mouse events
able to hit the wrapped labels, and various other little things stop
glitching out as well.

Also, instead of having a per-line width when wrapping icon names,
make the text rect wide enough to fit every line.
2020-10-27 16:10:30 +01:00
Andreas Kling
4bc8768737 LibGUI: Tint selected icons in {Icon,Table,Columns}View
Add a gentle tint to selected icons based on the selection color. :^)
2020-10-26 21:32:27 +01:00
Andreas Kling
d172783d33 LibGUI: Fix bogus focus rect in buttons with icon but no text 2020-10-26 21:08:01 +01:00
Andreas Kling
06b5d292d7 LibGUI: Allow activating a focused button by pressing the space key :^)
This applies to normal push buttons, checkboxes, and radio buttons.
It feels very natural. Even moreso than activating with return..
2020-10-26 21:01:45 +01:00
Andreas Kling
b7dfa83223 LibGUI+LibGfx: Improve focus rect appearance
Draw a dotted focus rect to make it stand out more. Also make it much
larger on regular text-only GUI::Buttons.
2020-10-26 21:01:45 +01:00
Andreas Kling
f6084d42d9 LibGUI: Call up to the correct base class in GUI::AbstractView 2020-10-26 21:01:45 +01:00
Andreas Kling
f57c058c5e LibGUI: Call up to the correct base class in GUI::TextEditor 2020-10-26 21:01:45 +01:00
Andreas Kling
4e1dabeb15 LibGUI: Tweak "OK" button height in GUI::AboutDialog 2020-10-26 21:01:45 +01:00
Andreas Kling
9d347352a1 LibGfx+LibGUI+Clients: Make fonts findable by their qualified name
The qualified name of a font is "<Family> <Size> <Weight>". You can
get the QN of a Font via the Font::qualified_name() API, and you can
get any system font by QN from the GUI::FontDatabase. :^)
2020-10-25 21:18:18 +01:00