Commit Graph

400 Commits

Author SHA1 Message Date
Timm Bäder
f053a63d74 container: Remove include_internals parameter from forall
with include_internals=TRUE, this is the same as the (still private)
gtk_widget_forall, or just using the children/sibling accessors in a
loop.
2017-04-25 20:30:37 +02:00
Timm Bäder
43cdeee3c4 widget: Save pointer to focus child
Do the same thing GtkContainer does.
2017-03-31 09:50:39 +02:00
Daniel Boles
5c2f642ddd ScrolledWindow: Don’t check if child is Scrollable
If the child added is not a Scrollable, it gets wrapped in a ViewPort –
which is. So it is impossible to end up with a non-Scrollable child.

Just check we have /any/ child where needed, which is semantically nicer

https://bugzilla.gnome.org/show_bug.cgi?id=778853
2017-03-20 23:25:23 +00:00
Daniel Boles
52547054a5 ScrolledWindow: Streamline/clarify the intro docs
• intro: Clarify that external policy and/or adjustments can be used.
 • add(): Don’t waffle on about having to add a ViewPort since we handle
          that transparently for the user, so they can add() any widget.
 • Adjustment stuff: most of this was repeating the docs for Scrollbar,
                     so just refer the user to that. Also, mention how
                     policies NEVER and EXTERNAL interact with all this.

https://bugzilla.gnome.org/show_bug.cgi?id=778853
2017-03-20 23:25:23 +00:00
Daniel Boles
10e49a2861 Revert "ScrolledWindow—Don’t req size for auto-hidden bars"
This reverts commit 901e5ff3a3.

This causes criticals in e.g. the Text View: Multiple Buffers demo.
More work is required to get a fix for Bug 778853 that does not cause
anything else to regress.

https://bugzilla.gnome.org/show_bug.cgi?id=778853
2017-02-22 19:31:38 +00:00
Daniel Boles
901e5ff3a3 ScrolledWindow—Don’t req size for auto-hidden bars
POLICY_AUTOMATIC means scrollbars are only shown when needed, i.e. when
the size of the window is not large enough to show the entire child. So
when measuring the preferred size, such scrollbars should be ignored.

But measure() was adding size for bars for which policy_may_be_visible()
was TRUE, which it returns for POLICY_ALWAYS (good) & _AUTOMATIC (bad).
So we reserved space for child plus scrollbars, & because we have enough
space for the child, POLICY_AUTOMATIC hides the scrollbar, leaving the
extra reserved space empty at the right/bottom sides of the child. This
is very noticeable/inconvenient for non-overlay, automatic scrollbars.

Fix this by only requesting size for scrollbars that use POLICY_ALWAYS,
rather than basing the decision on policy_may_be_visible().

https://bugzilla.gnome.org/show_bug.cgi?id=778853
2017-02-19 17:03:44 +00:00
Timm Bäder
85aaf13c03 scrolledwindow: Remove unused define 2017-02-18 19:11:22 +01:00
Timm Bäder
ed245b42cb scrolledwindow: Avoid usage of uninitialized local
the scrollbar passed in better be either priv->hscrollbar or
priv->vscrollbar. Ensure that by using a simple else instead of an
else-if and a g_assert.
2017-02-18 19:01:28 +01:00
Timm Bäder
56a58655fe Remove unnecessary gtk_widget_show calls 2017-01-22 14:38:21 +01:00
Alexander Larsson
7bee22bcb6 Avoid some more type checks for internal calls 2017-01-11 15:27:51 +01:00
Daniel Boles
0259312142 scrolledwindow: Fix func summary being cut off in bindings using doxygen
...which treats the first '.' in doc comments as the end of the summary.
So, e.g., in gtkmm, get_kinetic_scrolling() is currently summarised as
"Changes the behaviour of @scrolled_window wrt." Not very informative!

No need for a period there & anyway, the phrase "wrt to" is superfluous,
and we have space to actually say "with regard to", so just do that now.
2016-12-31 13:27:15 +00:00
Benjamin Otte
0dbdf0c428 gadget: Remove gtk_css_gadget_draw()
And with it, remove the draw func from custom gadgets, that has been
NULL everywhere.

All gadgets are snapshot now.
2016-12-20 18:01:12 +01:00
Benjamin Otte
2090219abb scrolledwindow: Implement snapshot() 2016-12-19 05:36:06 +01:00
Benjamin Otte
e09fd1eb8a scrolledwindow: Fix rendering
We used to allocate the gadget relative to the view window. We allocate
relative to widget->window now.
2016-12-19 05:36:06 +01:00
Timm Bäder
5ee590fbc8 scrolledwindow: measure child widgets using gtk_widget_measure 2016-12-04 12:00:46 +01:00
Benjamin Otte
4850271ae8 API: Remove gtk_cairo_should_draw_window()
The answer is: Yes.
2016-11-23 18:48:38 +01:00
Benjamin Otte
da207c9fdd snapshot: Add a snapshot function to GtkCssCustomGadget 2016-11-15 17:48:45 +01:00
Matthias Clasen
5e19e06dcc Fix a copy-paste error
Pointed out in https://bugzilla.gnome.org/show_bug.cgi?id=774185#c3
2016-11-10 15:07:08 -05:00
Benjamin Otte
e0600346e2 scrolledwindow: Turn into no-window widget 2016-11-06 15:50:26 +01:00
Benjamin Otte
2ca641edc9 scrolledwindow: Use gtk_widget_queue_draw() 2016-10-27 05:07:23 +02:00
Sébastien Wilmet
83dc4c8b39 docs: fix copy/paste errors in the docs of GtkScrolledWindow
Trivial commit.
2016-10-26 15:20:25 +02:00
Alexander Larsson
70935f0952 Drop support for offscreen GdkWindows
These complicate a lot of GdkWindow internals to implement features
that not a lot of apps use, and will be better achieved using gsk.
So, we just drop it all.
2016-10-25 09:54:37 +02:00
Timm Bäder
9992a616ef widget: Use ::measure vfunc to measure size
Add a new ::measure vfunc similar to GtkCssGadget's that widget
implementations have to override instead of the old get_preferred_width,
get_preferred_height, get_preferred_width_for_height,
get_preferred_height_for_width and
get_preferred_height_and_baseline_for_width.
2016-10-22 19:05:47 +02:00
Benjamin Otte
e54a76aee7 scrolledwindow: Use gdk_window_new_child() 2016-10-18 00:22:35 +02:00
Benjamin Otte
4df6ddad54 API: container: Remove gtk_container_set_border_width() 2016-10-16 18:18:58 +02:00
Timm Bäder
2e96f8ae70 scrolledwindow: Remove window-placement-set property 2016-10-16 18:17:21 +02:00
Timm Bäder
ba9220591f scrolledwindow: Remove scrollbar-spacing and scrollbars-within-bevel 2016-10-16 18:17:21 +02:00
Timm Bäder
05353ec933 scrolledwindow: Remove _add_with_viewport
Replaced by a normal gtk_container_add
2016-10-16 18:17:21 +02:00
Benjamin Otte
eace2cf421 API: Remove gdk_window_set_background()
Backgrounds are always transparent black.
2016-10-16 18:17:21 +02:00
Benjamin Otte
662001b60a API: Remove ability to set visuals on windows
And with it, gtk_widget_get_visual() and gtk_widget_set_visual() are
gone.

We now always use the RGBA visual (if available) and otherwise fall back
to the system visual.
2016-10-16 18:17:21 +02:00
Alan Jenkins
38667b8dd0 scrolledwindow: fix leak of pan_gesture
https://bugzilla.gnome.org/show_bug.cgi?id=772859
2016-10-13 09:39:02 -04:00
Christian Hergert
73d09c8f74 scrolledwindow: handle NULL cursor safely
It's possible to get a NULL cursor back if there are improperly
configured or missing cursors on the system.
2016-09-28 12:37:41 -07:00
Tristan Van Berkom
eaa6ca4a49 GtkScrolledWindow: Bug 766569 - fix return types in added APIs
In gtkscrolledwindow.c, the return type of _get_propagate_natural_width()
and _get_propagate_natural_height() were accidentally gint instead of
gboolean, fixed to match the type correctly declared in the header file.
2016-09-05 16:08:27 +09:00
Tristan Van Berkom
0984d1622d GtkScrolledWindow: Bug 766569 - Make propagation of natural child sizes optional
Making propagation of child natural sizes mandatory (or default, even) was
evidently a mistake as this causes dynamic content in a scrolled window
to resize it's parent when the scrolled window is competing for space
with an adjacent widget.

This patch instead adds API to control whether natural width and
height of the child should be propagated through the scrolled windows
size requests.
2016-08-31 14:44:50 -04:00
Benjamin Otte
e1a03ead7a Use NULL for generic marshallers in g_signal_new()
glib will use the correct marshaller automatically. And as a side
effect, we also get all glib optimizations, like a va marshaller.
2016-08-29 16:20:54 +02:00
Carlos Garnacho
8e6a68c5fc GtkScrolledWindow: reset scroll history if it contained no real history
Scroll history must refer to a timespan for the values to be valid, otherwise
we return FALSE, in this case the stored event(s) should be discarded anyway.
2016-07-27 20:29:38 +02:00
Carlos Garnacho
9eb356d9f2 GtkScrolledWindow: Always uninstall scroll cursor when starting deceleration
It could be the case that the last scroll event is received long after any
previous scroll event, in this case the last scroll event discards all "old"
scroll events, and scroll_history_finish() returns FALSE because there's no
time/offset deltas in the scroll history.

This is desired so we don't trigger the deceleration effect if there was no
effective velocity, we still must reset the installed scroll cursor, so take
it out of this if() condition.
2016-07-27 20:28:23 +02:00
Tristan Van Berkom
a9a59ac55e scrolledwindow: Fix calls to gdk_window_move_resize()
This is a bit of fallout from 34feba1, now that we resolve
the has_indicators value earlier than realize, it becomes
possible to call gdk_window_move_resize() before realization.

Just added the appropriate checks.
2016-06-10 21:16:53 +09:00
Tristan Van Berkom
34feba1e7c scrolledwindow: Resolve whether we use overlay scrollbars early.
Widgets should support size requests before being realized in general,
otherwise this can cause flicker/resize at initial display time as
the toplevel window can make a request before realize/allocate.

This also makes the added testsuite/gtk/scrolledwindow.c test work again,
this was broken because we only ever calculate whether we are going
to use overlay scrollbars once the scrolled window is realized (and
the test case does not realize any window).
2016-06-09 14:57:10 +09:00
Tristan Van Berkom
d7e242eec0 scrolledwindow: Bug 766569 - General size request fixes.
This patch does a couple of things:

  o Removes the obscure 'extra_width' and 'extra_height' variables
    making the request code exceedingly difficult to read

  o Fixes the max-content-size properties introduced in bug 742281
    so that they do not grow the minimum request.

  o Cleanup of request code in general:
    - min/max content sizes are clamped around the child request as needed
    - scrollbar requests are only added in one place, after child request
      sizes are calculated and without the extra_width/height thing.
2016-06-09 14:57:10 +09:00
Kjell Ahlstedt
ff5304ee13 Make gtk_scrolled_window_remove() smart
If gtk_scrolled_window_add() has added a GtkViewport,
  gtk_container_remove (GTK_CONTAINER (scrolled_window), child_widget);
or
  gtk_container_remove(GTK_CONTAINER(scrolled_window),
                       gtk_bin_get_child(GTK_BIN(scrolled_window)));
removes both the added child widget and the viewport.

https://bugzilla.gnome.org/show_bug.cgi?id=710471
2016-06-08 10:30:22 +02:00
Matthias Clasen
dce4003c20 Fix preconditions in set_max_content_size setters
We must allow resetting the properties to -1.
2016-06-07 16:37:09 -04:00
Matthias Clasen
289fc9640b Revert "scrolledwindow: Bug 766569 - Report child natural size unconditionally"
This reverts commit 0943c9f6b2.

The commit caused unexpected breakage in gtk3-widget-factory,
and also broke the just-added max-content-size properties.
2016-06-06 14:35:46 -04:00
Tristan Van Berkom
03742e83fb scrolledwindow: Bug 767238 - Fixing up for max content sizes
Needed to adjust this again after applying commit 4e5ecb7
for bug 742281. Now that we also have max content size properties,
pushed the addition of possible scrollbar sizes to after the
clause which clamps the child request size into min/max content
sizes.
2016-06-06 12:04:58 +09:00
Tristan Van Berkom
0943c9f6b2 scrolledwindow: Bug 766569 - Report child natural size unconditionally
This patch causes the scrolled window default behavior to change in
such a way that the natural size request of the child is unconditionally
reported, which probably should have been the case since day 1.

This should not cause significant fallout since a scrolled window is
normally used to expand/fill, eating up remaining space for scrollable
content - it will however cause the scrolled window to compete for
additional space with siblings, proportionally to the size of the
scrolled window's content.
2016-06-06 11:37:21 +09:00
Matthias Clasen
b4ebe4e5c1 scrolled window: Free gestures and gadgets in finalize
This is the right place for this.
2016-06-05 20:00:43 -04:00
Georges Basile Stavracas Neto
4e5ecb7052 scrolledwindow: add ::max-content-width and -height properties
The GtkScrolledWindow has support to set the minimum content size (both
width and height) which controls the minimum space allocated, but does
not exposes any way to control the maximum size the content can grow.

After the introduction of GtkPopover, which always uses the minimum
size of it's children widgets, the lack of max-content-width and -height
properties became a concrete use case.

This patch introduces the GtkScrolledWindow::max-content-width and
-height properties. The properties will alter the minimum size of
the scrolled window, making it grow up to the set value. They also
respect the previously set ::min-content-width and -height.

https://bugzilla.gnome.org/show_bug.cgi?id=742281
2016-06-05 11:02:59 -03:00
Matthias Clasen
de8af76897 Show a scroll cursor when appropriate
When doing two-finger scrolling or click scrolling using a
trackpoint, show the all-scroll cursor to indicate what is
going on.

https://bugzilla.gnome.org/show_bug.cgi?id=753202
2016-06-01 21:47:31 -04:00
Matthias Clasen
743d18c0f8 scrolled window: Remove trackpoint heuristics
This is now done in GDK, so we can just use the input type here.

https://bugzilla.gnome.org/show_bug.cgi?id=767100
2016-06-01 09:31:18 -04:00
Matthias Clasen
f516faaef8 Revert "scrolledwindow: Better size requisition for GTK_SCROLL_NATURAL children"
This reverts commit 096bea3f0e.

This was accidentally pushed.
2016-05-18 07:52:18 -04:00