Commit Graph

56070 Commits

Author SHA1 Message Date
Matthias Clasen
ce1ac00c59 slice model: Don't report excessive changes
We were not skipping an unchanged initial segment
of the slice in some cases. Fix that.
2019-01-06 12:24:57 -05:00
Matthias Clasen
75a1bafcc0 single selection: Be robust
Make gtk_single_selection_set_selected work without
a model. It gets called a internally, and that might
just happen when there's no model.
2019-01-06 10:52:20 -05:00
Matthias Clasen
c70130edc5 Drop unused variables 2019-01-06 10:52:20 -05:00
Matthias Clasen
596b9202ce Don't warn when setting properties to their default value
That makes our tests choke, and is not really necessary.
2019-01-06 10:52:20 -05:00
Matthias Clasen
c8f27d1ac6 Add missing headers to the public-headers list
Without this, the types don't end up in gtk_test_list_all_types,
and then tests like the defaultvalue test don't check them.
2019-01-06 10:52:07 -05:00
Matthias Clasen
a0f8bf0f6b testlistview: Allow changing sort order
This is a good test case for persistence of selection.
2019-01-05 22:52:34 -05:00
Matthias Clasen
d0ef5f5db4 selection: Make the model an interface property
This is in line with what we do for other wrapper models.
2019-01-05 22:52:34 -05:00
Matthias Clasen
dfd280acd0 gtk-demo: Add a listview demo
Duplicate the listbox demo with GtkListView,
and give both demos a "more messages" button,
to demonstrate scalability.
2019-01-05 21:13:26 -05:00
Matthias Clasen
c97f62a471 Fix up selection constructor return types
Follow the pattern we use for the other list model
types, and return the exact type.
2019-01-05 18:54:05 -05:00
Matthias Clasen
135a875c25 Add a no selection
This is a GtkSelectionModel that never selects anything.

The equivalent of GTK_SELECTION_MODE_NONE.
2019-01-05 17:47:39 -05:00
Matthias Clasen
09cbb5154f font chooser: Add back row activation
This one is easy and doesn't need any list view features.
2019-01-05 14:53:27 -05:00
Matthias Clasen
9e2250e35d list view: Be more careful with selection
I've seen crashes in the font chooser with
the selection-changed signal getting emitted
early, and row being NULL.
2019-01-05 14:38:20 -05:00
Matthias Clasen
d844c98c8a Fix an accidental change
This was just to test multiselection locally.
2019-01-05 14:37:59 -05:00
Matthias Clasen
779fb56213 font chooser: Port to GtkListView
This works, as far as the required features are present
in GtkListview yet. Still missing:
- keynav
- row activation
- scroll to selection
2019-01-05 14:36:31 -05:00
Matthias Clasen
ad25afc298 typo fix 2019-01-05 09:06:25 -05:00
Matthias Clasen
18d7a7daaa gtk: Add GtkMultiSelection
This is a selection modelt that allows selecting
more than one item.

The behavior is not 100% right yet for extending
selections, but it basically works.
2019-01-05 08:49:23 -05:00
Benjamin Otte
be4fe26fef listitem: Add a press gesture to select the item
This requires a bunch of refactoring because so far the ListItem had no
knowledge of the manager, but it needs the manager so it can access the
selection to trigger the select/unselect operation.
2019-01-05 00:30:22 +01:00
Benjamin Otte
46fa122c98 listview: Add initial support for displaying selections 2019-01-05 00:30:22 +01:00
Benjamin Otte
2b780de342 gtk: Add GtkSingleSelection
GtkSingleSelection is a GtkSelectionModel that allows selecting a single
item.
2019-01-05 00:30:22 +01:00
Benjamin Otte
ec0483bdfe gtk: Add GtkSelectionModel
The selection model is a list model interface that takes care of
selections and is to be used by the list model widgets to manage their
selections.
2019-01-05 00:30:22 +01:00
Benjamin Otte
1547d81eb9 listview: Reset listitems' CSS animations when rebinding
This way, newly displayed rows don't play an unselect animation (text
fading in) when they are unselected, but the row was previously used for
a selected item.
2019-01-05 00:30:22 +01:00
Benjamin Otte
498351784c listview: Add selection properties to ListItem
This just brings the infrastructure into place, we're not using the
properties yet.
2019-01-05 00:30:22 +01:00
Benjamin Otte
1f07f9bbae listview: Try to keep the list items in order when scrolling
Instead of just destroying all items and then recreating them (or even
hide()ing and then show()ing them again (or even even repositioning
them in the widget tree)), just try to reust them in the order they are.

This works surprisingly well when scrolling and most/all widgets
just moved.
2019-01-05 00:30:22 +01:00
Benjamin Otte
aa71d8fc51 listlistmodel: Add gtk_list_list_model_item_moved()
Use it to fix a case that just said g_warning ("oops").

Apparently I had forgotten the case where a container moved a child
in the widget tree.
2019-01-05 00:30:22 +01:00
Benjamin Otte
44e4ddfdf0 listitemmanager: Switch from "insert_before" to "insert_after" argumnet
We reorder widgets start to end, so when reusing a list item, we
correctly know the previous sibling for that list item, but not the
next sibling yet. We just know the widget it should ultimately be in
front of.
So we can do a more correct guess of the list item's place in the widget
tree if we think about where to place an item like this.

Actually using this change will come in the next commit.
2019-01-05 00:30:22 +01:00
Benjamin Otte
3481dddbc2 testlistview: Create widgets only once
Previously, we were recreating all widgets every time the list item was
rebound, which caused a lot of extra work every time we scrolled.

Now we keep the widgets around and only set their properties again when
the item changes.
2019-01-05 00:30:22 +01:00
Benjamin Otte
841d6cb327 testlistview: Show the row number
Always show the current row. This is mostly useful for debugging, not
for beauty.
2019-01-05 00:30:22 +01:00
Benjamin Otte
b21fd5fd22 listview: Only allocate necesary rows
This is the big one.

The listview only allocates 200 rows around the visible row now.
Everything else is kept in ListRow instances with row->widget == NULL.

For rows without a widget, we assign the median height of the child
widgets as the row's height and then do all calculations as if there
were widgets that had requested that height (like setting adjustment
values or reacting to adjustment value changes).

When the view is scrolled, we bind the 200 rows to the new visible area,
so that the part of the listview that can be seen is always allocated.
2019-01-05 00:30:20 +01:00
Benjamin Otte
660a6f4e8e listview: Change anchor handling again
The anchor is now a tuple of { listitem, align }.

Using the actual list item allows keeping the anchor across changes
in position (ie when lists get resorted) while still being able to fall
back to positions (list items store their position) when an item gets
removed.

The align value is in the range [0..1] and defines where in the visible
area to do the alignment.
0.0 means to align the top of the row with the top of the visible area,
1.0 aligns the bottom of the widget with the visible area and 0.5 keeps
the center of the widget at the center of the visible area.
It works conceptually the same as percentages in CSS background-position
(where the background area and the background image's size are matched
the same way) or CSS transform-origin.
2019-01-05 00:24:55 +01:00
Benjamin Otte
72902be840 listview: Change how binding is done
We now don't let the functions create widgets for the item from the
listmodel, instead we hand out a GtkListItem for them to add a widget
to.

GtkListItems are created in advance and can only be filled in by the
binding code by gtk_container_add()ing a widget.
However, they are GObjects, so they can provide properties that the
binding code can make use of - either via notify signals or GBinding.
2019-01-05 00:24:55 +01:00
Benjamin Otte
2a7746dba6 listitem: Add gtk_list_item_get_position()
Also refactor the whole list item management yet again.

Now, list item APIs doesn't have bind/unbind functions anymore, but only
property setters.

The item factory is the only one doing the binding.
As before, the item manager manages when items need to be bound.
2019-01-05 00:24:55 +01:00
Benjamin Otte
badad04eb7 tests: Make animating listview do random resorts 2019-01-05 00:24:55 +01:00
Benjamin Otte
81690c7049 listview: Change change management
Add a GtkListItemManagerChange object that tracks all removed list
rows during an item-changed signal so they can be added back later.
2019-01-05 00:24:55 +01:00
Benjamin Otte
ae1331ee92 listview: Make the listitemmanager stricter
Require that items created with the manager get destroyed via the
manager.

To that purpose, renamed create_list_item() to acquire_list_item() and
add a matching release_list_item() function.

This way, the manager can in the future keep track of all items and
cache information about them.
2019-01-05 00:24:55 +01:00
Benjamin Otte
e2354e5f3b listview: Add GtkListItem
GtkListItem is a generic row widget that is supposed to replace
GtkListBoxRow and GtkFlowBoxChild.
2019-01-05 00:24:55 +01:00
Benjamin Otte
2d472da14b listview: Add GtkListItemManager
It's all stubs for now, but here's the basic ideas about what
this object is supposed to do:

(1) It's supposed to be handling all the child GtkWidgets that are
    used by the listview, so that the listview can concern
    itself with how many items it needs and where to put them.
(2) It's meant to do the caching of widgets that are not (currently)
    used.
(3) It's meant to track items that remain in the model across
    items-changed emissions and just change position.
(2) It's code that can be shared between listview and potential
    other widgets like a GridView.

It's also free to assume that the number of items it's supposed to
manage doesn't grow too much, so it's free to use O(N) algorithms.
2019-01-05 00:24:55 +01:00
Benjamin Otte
7edeef2f71 listview: Implement an anchor
The anchor selection is very basic: just anchor the top row.

That's vastly better than any other widget already though.
2019-01-05 00:24:55 +01:00
Benjamin Otte
07ec4f9de0 tests: Add a test for a permanently changing listview
This is mostly for dealing with proper anchoring and can be used to
check that things don't scroll or that selection and focus handling
properly works.

For comparison purposes, a ListBox is provided next to it.
2019-01-05 00:24:55 +01:00
Benjamin Otte
b00b9500e7 listview: Implement GtkScrollable
Scrolling in a very basic form is also supported
2019-01-05 00:24:53 +01:00
Benjamin Otte
d7e64c4423 listview: Make widget actually do something
The thing we're actually doing is create and maintain a widget for every
row. That's it.

Also add a testcase using this. The testcase quickly allocates too many
rows though and then becomes unresponsive though. You have been warned.
2019-01-05 00:13:20 +01:00
Benjamin Otte
5596063220 listview: Introduce GtkListItemFactory
Thisis the abstraction I intend to use for creating widgets and binding
them to the item out of the listview.

For now this is a very dumb wrapper around the functions that exist in
the API.

But it leaves the freedom to turn this into public API, make an
interface out of it and most of all write different implementations, in
particular one that uses GtkBuilder.
2019-01-04 23:57:45 +01:00
Benjamin Otte
3485a4582c gtk: Add a GtkListView skeleton 2019-01-04 23:57:45 +01:00
Benjamin Otte
f1c34aefe0 main: Report correct target for button release events
Button release events should not go to the widget below the pointer, but
to the widget that received the original button press.

Fixes #24
2019-01-04 23:57:45 +01:00
Timm Bäder
f9a5a474f0 imcontextwayland: (Hopefully) fix if expression 2019-01-04 05:55:26 +01:00
Piotr Drąg
c51f1fda28 Update POTFILES.in 2019-01-03 19:21:09 +01:00
Timm Bäder
ea3d0c0f01 buttonbox: Remove redundant if statement
This used to do something in the past.
2019-01-03 08:57:16 +01:00
Timm Bäder
2c1198f6c2 colorchooser: Remove extra custom color 2019-01-03 08:56:46 +01:00
Timm Bäder
9d3120cc1e popover demo: Fix size-allocate callback signature 2019-01-03 08:56:40 +01:00
Timm Bäder
66d3aa8101 window: Fix state_flags_changed impl name
This is unrelated to GdkSurface and was changed by accident.
2019-01-03 08:56:34 +01:00
Timm Bäder
0530637fef stack: Don't queue an unnecessary redraw
Both queue_allocate and queue_resize already queue a draw.
2019-01-03 08:52:35 +01:00