Commit Graph

216 Commits

Author SHA1 Message Date
Timm Bäder
7096d6dd28 viewport: Use gtk_widget_measure to measure child sizes
and rewrite the adjustment handling in a orientation-agnostic way.
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
Benjamin Otte
d818f3fcd4 viewport: Turn into no-window widget
While doing so, get rid of the GdkWindow instead of keeping it.
2016-11-02 22:00:29 +01:00
Benjamin Otte
a750f942ac viewport: Remove pixelcache
With the rework for GSK and queueing of redraws pending, the pixel cache
just gets in the way. So we remove it everywhere.
2016-10-26 19:52:02 +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
Timm Bäder
019960f131 viewport: remove deprecated api 2016-10-18 00:29:17 +02:00
Benjamin Otte
3cf7b21256 viewport: 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
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
Matthias Clasen
c8cab6a79a viewport: Free gadgets in finalize
This is the right place for this.
2016-06-05 20:00:43 -04:00
Benjamin Otte
4e8fb33f56 pixelcache: Don't have a style context argument
That would imply the pixelcache monitors the style context for changes
and it doesn't do that.

Its only use case was opacity checks, so add
gtk_pixel_cache_se_is_opaque() instead.
2016-02-25 16:52:58 +01:00
Benjamin Otte
e3f8316d08 viewport: Don't destroy pixelcache while it's still used
Removing the child unsets the pxielcache's style context...
2016-01-20 05:10:16 +01:00
Benjamin Otte
9cb0a97bb5 viewport: Set the pixel cache background from the child
The viewport itself doesn't move, so we cannot use it as the pixel
cache's background. Use the bottommost using element instead, which is
the viewport's child.

This might need adaptations in themes as we want the backgroud to be
opaque to speed up pixel cache performance.
2016-01-20 04:37:05 +01:00
Cosimo Cecchi
09835b4c39 viewport: don't render a background over the bin window
GtkViewport currently tries to draw a background over the bin window.
The feature is a bit broken at the moment, as it does not take into
account padding that might have been set on the GtkViewport, but in
general it does not seem very useful, and goes somewhat against the CSS
box model where every widget/gadget is responsible to draw its own
background. For a fix, we could either have the viewport gain a "bin"
gadget, or we could stop drawing the background.

As it isn't clear that there are any users of this feature, stop drawing
the background; a client can achieve the same effect by drawing the
background on the widget inside the viewport itself.
2015-12-29 13:50:19 -08:00
Cosimo Cecchi
5daede51f7 viewport: port to use a gadget
This will get us margin support, among other things, and simplifies the
code.
2015-12-29 13:50:19 -08:00
Cosimo Cecchi
71d7b10dad viewport: trivial code cleanup 2015-12-29 13:50:19 -08:00
Cosimo Cecchi
a37129fd60 viewport: use gtk_container_class_handle_border_width()
No need to do this manually.
2015-12-29 13:50:19 -08:00
Timm Bäder
2182fe7d9d Don't pass widget state flags to GtkStyleContext API 2015-11-22 17:11:35 +01:00
Matthias Clasen
93629325d5 Cosmetic: Avoid explicit state variables
Using the state of the context makes this more obviously correct.
2015-11-14 12:32:57 -05:00
Matthias Clasen
b6dbfc791f viewport: Add an element name to the css node
This lets us avoid hardcoding the type in CSS.
2015-10-29 07:47:31 -04:00
Alexander Larsson
d5f1754981 gtk: Stop setting GDK_EXPOSURE_MASK on random widgets
These days exposure happens only on the native windows (generally the
toplevel window) and is propagated down recursively. The expose event
is only useful for backwards compat, and in fact, for double buffered
widgets we totally ignore the event (and non-double buffering breaks
on wayland).

So, by not setting the mask we avoid emitting these events and then
later ignoring them.

We still keep it on eventbox, fixed and layout as these are used
in weird ways that want backwards compat.
2015-09-14 11:01:13 +02:00
Christian Hergert
7c1ce9f3ad viewport: share style context with pixelcache
This allows the pixel cache to opportunistically use CAIRO_CONTENT_COLOR
instead of CAIRO_CONTENT_COLOR_ALPHA during surface creation.

https://bugzilla.gnome.org/show_bug.cgi?id=754658
2015-09-13 13:41:19 -07:00
Cosimo Cecchi
d4ecdbd300 viewport: don't call gtk_style_context_set_background() 2015-07-01 16:09:23 -07:00
Benjamin Otte
b09fbadddf viewport: Remove wrong save/restore 2014-10-13 04:39:57 +02:00
Benjamin Otte
d3c147a62d stylecontext: Split render functions out into gtkrender.[ch] 2014-10-03 06:18:05 +02:00
Matthias Clasen
dbeb0c9ca8 GtkViewport: Use style classes for shadow
Translate shadow != None into the FRAME style class.
This doesn't change the style classes used for drawing,
it only sets the style class permanently instead of
saving and restoring in draw().
https://bugzilla.gnome.org/show_bug.cgi?id=732256
2014-06-26 21:56:20 -04:00
Benjamin Otte
cdd341ed7d viewport: Remove unused variable 2014-06-10 13:47:51 +02:00
Matthias Clasen
b22b2298be GtkViewport: Don't do silly things in a setter
Just queue a resize instead of fiddling with the size allocation.
2014-06-09 13:51:58 -04:00
Matthias Clasen
bcd804613f GtkViewport: Use G_PARAM_EXPLICIT_NOTIFY 2014-06-09 13:31:14 -04:00
Benjamin Otte
352e28a138 viewport: Don't subtract borders and padding from -1
-1 is a special value for "undefined" and needs to stay that way

https://bugzilla.gnome.org/show_bug.cgi?id=729607
2014-05-06 04:02:40 +02:00
Benjamin Otte
9652b8cf82 viewport: Remove unneeded checks
Size vfuncs always get non-null out variables passed, so no need to
check for NULL.
2014-05-01 14:51:27 +02:00
Benjamin Otte
29a4f0131e viewport: Implement hfw properly
Previously, the code would fall back on GtkBin's hfw implementation
which didn't account for padding and borders.
2014-05-01 14:51:27 +02:00
Benjamin Otte
b261fc64e2 viewport: Use a convenience function
That function looks longer than not using it, but we'll need it in the
next commit.
2014-05-01 14:51:27 +02:00
Benjamin Otte
2e2e3a5e24 viewport: Request 2x border-width
It's nice that bugs get pointed out in code comments. Fixing them would
probably have been preferrable though.
2014-05-01 14:51:27 +02:00
Benjamin Otte
461f1900f2 viewport: Call map/unmap functions on pixel cache
https://bugzilla.gnome.org/show_bug.cgi?id=726475
2014-04-10 00:16:53 +02:00
William Jon McCann
469d333aa2 docs: use Returns: consistently
Instead of Return value:
2014-02-19 18:56:05 -05:00
William Jon McCann
7a208fbbf3 docs: use proper apostrophe
https://wiki.gnome.org/Design/OS/Typography
2014-02-07 13:06:10 -05:00
Emmanuele Bassi
0899ef7cc9 gtk: Use new macros for defining private data
https://bugzilla.gnome.org/show_bug.cgi?id=702996
2013-07-09 09:30:02 +01:00
Alexander Larsson
2df27ce7f8 Make GtkViewport use GtkPixelCache
Since gdk_window_move() no longer uses XCopyArea all scrolling
now re-renders everything in the window. To get performance
back we use a GtkPixelCache to store already drawn children,
and we when we expose the viewport we just blit the
offscreen to the right place.
2013-05-07 16:34:05 +02:00
Matthias Clasen
3b4804bbf1 Always use gint for border_width
This avoids an evil trap when doing MAX (..., ... - 2 * border_width)
and the expression on the right gets promoted to unsigned, instead
of going negative as you would expect.
https://bugzilla.gnome.org/show_bug.cgi?id=699633
2013-05-04 19:21:56 -04:00
Torsten Schönfeld
afc57cabf0 GtkViewport: annotate the adjustment args of the constructor
NULL is accepted here, so add (allow-none).

https://bugzilla.gnome.org/show_bug.cgi?id=694022
2013-02-18 19:39:12 -05:00
Alexander Larsson
3d4cd4db3e Add gtk_widget_(un)register_window
This replaces the previously hardcoded calls to gdk_window_set_user_data,
and also lets us track which windows are a part of a widget. Old code
should continue working as is, but new features that require the
windows may not work perfectly.

We need this for the transparent widget support to work, as we need
to specially mark the windows of child widgets.

https://bugzilla.gnome.org/show_bug.cgi?id=687842
2013-02-07 11:11:37 +01:00
Cosimo Cecchi
9efa28591c scrolledwindow: make gtk_scrolled_window_add() smart
There's really no reason why we shouldn't automatically create a
GtkViewport when the widget added to GtkScrolledWindow is not a
GtkScrollable, instead of just printing a g_warning.
Copy the viewport special case into the scrolled window implementation
of gtk_container_add().

https://bugzilla.gnome.org/show_bug.cgi?id=693015
2013-02-01 22:58:53 -05:00
Alexander Larsson
0cb714fe62 Use GTK_RESIZE_PARENT resize_mode for GtkViewport
We used to use GTK_RESIZE_QUEUE, but that is problematic for e.g
a GtkScrolledWindow with NEVER scroll policies, as size changes
in ancestors will never get propagated to the scrolled window, causing
it to not have the correct size.

This is a slight performance hit, but in practice its not bound to be
problematic. In typical UIs there is only a single "large" GtkScrolledWindow
visible at a time, so a size requeust propagating out of such a window
will only hit the smaller amount of widgetry outside the scrolled window,
and additionally all such widgets will have their size request caches
still valid.

https://bugzilla.gnome.org/show_bug.cgi?id=690099
2012-12-12 15:03:24 +01:00
Cosimo Cecchi
f70fc49ebc docs: fix a number of typos and obsolete references 2012-07-02 10:41:11 -04:00
Benjamin Otte
917ca6a802 gtk: Don't call gdk_window_process_updates() when scrolling
This can cause lagging when scrolling as it causes us to repaint
on every scroll event. This wasn't historically a great problem,
but with smooth scrolling we get a lot more events, so this
now creates visible lagging on slower machines.
2012-04-05 15:48:51 +02:00
Benjamin Otte
2353d60b8a types: Move GtkAdustment declaration to gtktypes.h
... and make all the headers to not include gtkadjustment.h anymore. Of
course, also include it in the source files instead.
2012-03-03 19:45:03 +01:00
Carlos Garnacho
f34a236814 viewport: set GDK_SMOOTH_SCROLL_MASK
This is so smooth scroll events are send/handled by the
parent GtkScrolledWindow if any.
2012-03-01 16:28:59 -05:00
Matthias Clasen
42c75d28b8 viewport: select for touch events
This makes kinetic scrolling work with viewports where the
content does not otherwise select for button or touch events,
such as testscrolledwindow's label.
2012-03-01 16:25:22 -05:00