Commit graph

404 commits

Author SHA1 Message Date
Sergey Bugaev
b6aae25244 LibGUI: Rename GAbstractColumnView to GAbstractTableView
This is to prevent confusion with GColumnsView, which is unrelated.
2020-01-22 21:22:23 +01:00
Sergey Bugaev
dec95cb8b3 LibGUI: Let GModel specify the drag data type
GModel subclasses can now override drag_data_type() to specify which type
GAbstractView should set for drag data. The default implementation returns a
null string, which disables dragging from this widget.
2020-01-22 21:22:23 +01:00
Sergey Bugaev
d3ce7ae0e3 LibGUI: Move most of mouse event handling to GAbstractView
This deduplicates existing code, and also gives all the model-backed widgets
selection manipulation and drag support for free :^)
2020-01-22 21:22:23 +01:00
Sergey Bugaev
fd11c96e8e LibGUI: Misc tweaks
Minus two empty lines because clang-format insists on it,
and plus an underscore.
2020-01-22 21:22:23 +01:00
Sergey Bugaev
91d3fc54be LibGUI: Move index_at_event_position() up to GAbstractView
It's now an abstract (pure virtual) public method in GAbstractView that
individual widgets have to implement. This will allow us to move more
selection-related logic into GAbstractView in order to share it between
implementations.
2020-01-22 21:22:23 +01:00
Sergey Bugaev
ff66101f9e LibGUI: Add GItemView::index_at_event_position()
This replaces GItemView::item_at_event_position(), which used to return a raw
int, requiring callers to call model()->index() with it again.
2020-01-22 21:22:23 +01:00
Sergey Bugaev
2ccad40a16 LibGUI: Add GListView::index_at_event_position()
And port GListView::mousedown_event() to it.
2020-01-22 21:22:23 +01:00
Andreas Kling
a5e482833d LibGUI: Make GDialog accept escape key press events
Anyone who "handles" an event should really also be accepting it.
2020-01-21 21:55:25 +01:00
Andreas Kling
82cb5b6f64 LibGUI: GFileSystemModel::index() now survives negative inputs
If asked to create an index with negative row and/or column, we should
just return an invalid GModelIndex() instead of asserting.
2020-01-21 21:55:25 +01:00
Andreas Kling
ecd5589d4f LibGUI: Fix missing initializer for GColumnsView::m_model_column 2020-01-21 21:55:25 +01:00
Andreas Kling
a14f08fcc9 LibGUI: Import GColorPicker from the PaintBrush application 2020-01-21 21:55:25 +01:00
Andreas Kling
b25210ee1b LibGUI: Use clamp() is various places 2020-01-20 13:17:16 +01:00
Andreas Kling
94ca55cefd Meta: Add license header to source files
As suggested by Joshua, this commit adds the 2-clause BSD license as a
comment block to the top of every source file.

For the first pass, I've just added myself for simplicity. I encourage
everyone to add themselves as copyright holders of any file they've
added or modified in some significant way. If I've added myself in
error somewhere, feel free to replace it with the appropriate copyright
holder instead.

Going forward, all new source files should include a license header.
2020-01-18 09:45:54 +01:00
Shannon Booth
22d1961c9a LibGUI: Handle "Return" key events
I kept on trying to use the enter key to navigate a tree view, when only
left and right arrow keys are used for this. Now also suport the return
key, is used as a toggle to open a tree.
2020-01-18 00:27:39 +01:00
0xtechnobabble
ecf58ddd4f TextEditor: Implement replacement functionality
This patch adds a new replace widget that cooperates with the find
widget, the replace widget takes the input in the find textbox, searches
for occurences of that input, and replaces them with the input provied
in the replace textbox.
2020-01-12 01:41:36 +01:00
Andreas Kling
75c5e9af56 LibGUI: Fix assertion failure in GItemView::mouse_up() 2020-01-11 22:12:36 +01:00
Andreas Kling
6a529ea425 LibGUI: Fix rendering GColumnsView separator
Patch by Sergey Bugaev.
2020-01-10 18:25:44 +01:00
Sergey Bugaev
edb61d8bfd LibGUI: Add GColumnsView
This is a shiny new widget that can display a tree using Miller columns ^:)

In many cases, the columns view can be used as an alternative to tree view,
but it has its own set of limitations:

* It can only display one model column (so it cannot replace a table)
* It takes up a lot of horizontal space, so it's only suitable if the item text
  is fairly short
* It can only display one subtree at a time

But as long as a usecase doesn't suffer from these limitations, a columns view
can be *much* more intuitive than a tree view.
2020-01-10 17:45:59 +01:00
Sergey Bugaev
10324f95b0 LibGUI+FileManager: Misc tweaks courtesy of clang-format 2020-01-10 17:45:59 +01:00
Sergey Bugaev
fdeb91e000 LibGUI+FileManager: Merge GDirectoryModel into GFileSystemModel
We used to have two different models for displaying file system contents:
the FileManager-grade table-like directory model, which exposed rich data
(such as file icons with integrated image previews) about contents of a
single directory, and the tree-like GFileSystemModel, which only exposed
a tree of file names with very basic info about them.

This commit unifies the two. The new GFileSystemModel can be used both as a
tree-like and as a table-like model, or in fact in both ways simultaneously.
It exposes rich data about a file system subtree rooted at the given root.

The users of the two previous models are all ported to use this new model.
2020-01-10 17:45:59 +01:00
Sergey Bugaev
0f18a16e2c LibGUI: Add GAbstractView::activate_selected()
This is a nice little utility to activate all the selected items,
which is what you usually want to do.
2020-01-10 17:45:59 +01:00
Sergey Bugaev
caa08938e5 LibGUI: Fix GModel::is_valid() behavior for tree-like models 2020-01-10 17:45:59 +01:00
Sergey Bugaev
303fa75d36 LibGUI: Fix tree view column positioning when some columns are hidden 2020-01-10 17:45:59 +01:00
Andreas Kling
463ed77024 WindowServer+LibGUI: Paint exclusive actions as radio buttons in menus
Actions that are checkable and members of a GActionGroup will now be
painted with a radio button appearance in menus.
2020-01-08 21:12:40 +01:00
Andreas Kling
cc8c26c39b LibDraw+LibGUI: Move radio button painting into StylePainter
This will allow WindowServer to draw radio buttons :^)
2020-01-08 21:12:40 +01:00
Dov Alperin
518f469970 LibGUI: clicking and dragging one item will drag other items in selection
Previously if more than one item was selected clicking on one of
them and dragging would de-select everything that is not the one that
was clicked on. Now, if more than one items are selected and there
is a mousedown it goes into a "mightdrag" state.
The user can then perform a drag, if they don't everything that is not
the item being clicked gets unselected in the mouseup event, mimicking
the previous behavior.
2020-01-08 15:20:41 +01:00
Dov Alperin
e0c959ea7f LibGUI: separate file names with commas in the drag operation text 2020-01-08 15:20:41 +01:00
DAlperin
dcc4704fb5 LibGUI: Preserve existing GItemView selection on rubber band (#1031) 2020-01-07 16:18:12 +01:00
Conrad Pankoff
0e7cee58c0 LibGUI: Run clang-format on GModel.h to neaten up some formatting 2020-01-07 12:46:22 +01:00
Shannon Booth
7cf15bcb75 GAbstractView: Add function for adding all to selection 2020-01-07 11:06:27 +01:00
0xtechnobabble
123dcada05 Themes: Support rubberband selection theming 2020-01-07 11:02:43 +01:00
Shannon Booth
d4fa8e4b00 AK+Demos+Libraries: Remove executable permissions from {.cpp,.h} files 2020-01-06 10:43:00 +01:00
Andreas Kling
5a02a0d140 LibGUI: Refine the per-item rects in GItemView
Previously we would consider anything in the large padded area around
each item to also be part of the item for mouse event purposes.
This didn't feel right when rubberbanding, so this patch factors out
the per-item rect computation into a get_item_rects() helper which can
then be used by the various functions that need it.
2020-01-04 21:36:42 +01:00
Andreas Kling
6e21d5c432 LibGUI: Add basic rubber band selection in GItemView 2020-01-04 21:18:48 +01:00
Jami Kettunen
eab34a7de3 WindowServer+LibGUI: Implement minimizable property to windows 2020-01-04 14:58:50 +01:00
Andreas Kling
2d244a70a1 WindowServer+LibGUI: Simplify handling of paint event rects
Now that Vector<T> is convertible to Vector<T, n>, we don't have to
manually copy the paint event rectangles.
2020-01-04 11:03:37 +01:00
Andreas Kling
c6170070ed LibGUI: Clear out a GJsonArrayModel if it fails to open the JSON source
This fixes an issue in SystemMonitor where old data would linger in the
table views after selecting a process owned by another user.

Since we can no longer read /proc/PID/* unless PID belongs to us,
we will now present empty views for these processes. :^)
2020-01-02 20:57:55 +01:00
Andreas Kling
8c8118fbf8 WindowServer+LibGUI: Taskbar should show all windows from each process
We were not sending the ID of the window that was listening for window
management (WM) events along with the WM messages. They only included
the "target" window's ID.

Since the taskbar's single window had the first window ID for its own
connection to the WindowServer, it meant that it would only receive
WM events for the first window ID in other processes as well.

This broke when I ported WindowServer to LibIPC.

Fix this by including the WM listener ID in all WM messages, and since
we're here anyway, get rid of a bunch of unnecessary indirection where
we were passing WM events through the WindowServer event loop before
sending them to the listener.
2020-01-02 03:29:21 +01:00
Andreas Kling
9619dab727 LibGUI: Tweak GAboutDialog text 2020-01-02 02:55:10 +01:00
Andreas Kling
fc86460134 AK: Move the userspace SharedBuffer from LibC to AK
This always felt out-of-place in LibC.
2020-01-01 18:53:34 +01:00
Conrad Pankoff
3d59db4be4 LibGUI: Close and cancel GDialog on escape
This is a small usability enhancement. If you press escape with a GDialog
focused, it will now return its "Cancel" status.
2020-01-01 02:02:29 +01:00
Andreas Kling
57f55f297b LibGUI: Call GWidget::resize_event() before doing widget layout
The widget layout system currently works by having layouts size the
children of a widgets. The children then get resize events, giving them
a chance to lay out their own children, etc.

In keeping with this, we need to handle the resize event before calling
do_layout() in a widget, since the resize event handler may do things
that end up affecting the layout, but layout should not affect the
resize event since the event comes from the widget parent, not itself.
2019-12-30 00:26:19 +01:00
Andreas Kling
aaaf04f393 LibGUI: Relayout GTextEditor on font change
Fixes #941.
2019-12-29 23:03:41 +01:00
Andreas Kling
411d293961 LibCore+LibGUI: Don't fire timers in non-visible windows by default
LibCore timers now have a TimerShouldFireWhenNotVisible flag which is
set to "No" by default.

If "No", the timer will not be fired by the event loop if it's within
a CObject tree whose nearest GWindow ancestor is currently not visible
for timer purposes. (Specificially, this means that the window is
either minimized or fully occluded, and so does not want to fire timers
just to update the UI.)

This is another nice step towards a calm and serene operating system.
2019-12-29 16:03:36 +01:00
Andreas Kling
7b2dd7e116 LibDraw+LibGUI: Allow changing individual colors in a Palette
Palette is now a value wrapper around a NonnullRefPtr<PaletteImpl>.
A new function, set_color(ColorRole, Color) implements a simple
copy-on-write mechanism so that we're sharing the PaletteImpl in the
common case, but allowing you to create custom palettes if you like,
by getting a GWidget's palette, modifying it, and then assigning the
modified palette to the widget via GWidget::set_palette().

Use this to make PaintBrush show its palette colors once again.

Fixes #943.
2019-12-29 00:47:49 +01:00
joshua stein
0b501335f5 Build: wrap make invocations with flock(1)
Lock each directory before entering it so when using -j, the same
dependency isn't built more than once at a time.

This doesn't get full -j parallelism though, since one make child
will be sitting idle waiting for flock to receive its lock and
continue making (which should then do nothing since it will have
been built already).  Unfortunately there's not much that can be
done to fix that since it can't proceed until its dependency is
built by another make process.
2019-12-28 21:09:33 +01:00
Hüseyin ASLITÜRK
71922ee6a5 GListView: Fix for theme support. We have to use theme colors. 2019-12-27 22:47:31 +01:00
Andreas Kling
159289af03 WindowServer: Use the system theme for the fallback window background
When filling in some missing part of a window (typically happens during
interactive window resize) we now use the ColorRole::Background from
the system theme palette instead of expecting the clients to send us
the same information when creating windows.
2019-12-27 13:28:55 +01:00
Andreas Kling
c7847d7c81 WindowServer+LibGUI: Mark window bitmaps volatile in occluded windows
WindowServer now tracks whether windows are occluded (meaning that
they are completely covered by one or more opaque windows sitting above
them.) This state is communicated to the windows via WindowStateChanged
messages, which then allow GWindow to mark its backing store volatile.

This reduces the effective memory impact of windows that are not at all
visible to the user. Very cool. :^)
2019-12-27 11:34:40 +01:00
Andreas Kling
23e16a3e2e LibGUI: Remove bitrotted automatic keybinds feature
This feature hasn't been working at all for several months, so let's
just remove it and simplify GWindow event handling.
2019-12-27 00:52:30 +01:00