Commit Graph

130 Commits

Author SHA1 Message Date
Matthias Clasen
2aa52c7d00 Simplify the gtk_snapshot_icon_texture API
Instead of passing the color matrix in from the outside,
just pass a boolean and set up the matrix internally.
2017-11-08 22:21:42 -05:00
Benjamin Otte
0f5d807cae iconhelper: Don't render to surface anymore
Just go directly to texture.
2017-11-05 06:30:45 +01:00
Benjamin Otte
2d959553e9 image: Add the ability to set textures
This also adds it to all other places that use the same infrastructure:
GtkEntry and GtkCellRendererPixbuf
2017-11-05 00:07:17 +01:00
Benjamin Otte
a0ff63e162 iconhelper: Compute surface size without icon helper
This is so we can do the next batch of changes
2017-11-04 15:22:25 +01:00
Benjamin Otte
ca3c23662c GskTexture => GdkTexture
We want this thing to replace GdkPixbuf, so it has to live in GDK.
2017-11-04 00:07:13 +01:00
Alexander Larsson
96b04836d8 Drop all uses of GdkPixbufAnimation in the gtk APIs
These are basically animated gifs, and don't fit well in how
modern things animate.
2017-10-23 16:56:49 +02:00
Alexander Larsson
b1250935a0 GtkIconHelper: Remove unused code 2017-10-23 15:34:17 +02:00
Alexander Larsson
0089e4ad58 Drop pixbuf support in IconHelper and ImageDefinition
These are no longer used, instead we always covert to surface as
early as possible and drop the pixbuf.

This means we never store both the pixbuf and the surface at
for any longer time, which is wasteful. Also, its one step further
to drop GdkPixbufs from generic use in our APIs.
2017-10-23 15:28:33 +02:00
Matthias Clasen
a072f9fc06 Use a color matrix for symbolic icons
The recoloring of symbolic icons is just a color matrix
operation.
2017-10-23 11:47:17 +02:00
Matthias Clasen
e4cdbef092 Allow passing a color matrix when rendering icons
This will be used for symbolic icons.
Update all callers.
2017-10-23 11:44:52 +02:00
Matthias Clasen
b543257e42 icon helper: Use cached textures
Use a cached texture for themed icons if we can.
Currently, we only do this for non-symbolic icons.
2017-10-23 08:07:35 +02:00
Timm Bäder
4e24cb8588 css: Add GTK_CSS_AFFECTS_ICON_SIZE
And use it in GtkIconHelper. This way, we can avoid resizes when e.g.
the fg color of a symbolic icon changes.
2017-10-14 17:27:55 +02:00
Timm Bäder
ce5560a790 iconhelper: Short-circuit clear() if it's cleared already 2017-10-14 17:27:55 +02:00
Benjamin Otte
43c212ac28 build: Enable -Wswitch-enum and -Wswitch-default
This patch makes that work using 1 of 2 options:

1. Add all missing enums to the switch statement
  or
2. Cast the switch argument to a uint to avoid having to do that (mostly
   for GdkEventType).

I even found a bug while doing that: clearing a GtkImage with a surface
did not notify thae surface property.

The reason for enabling this flag even though it is tedious at times is
that it is very useful when adding values to an enum, because it makes
GTK immediately warn about all the switch statements where this enum is
relevant.
And I expect changes to enums to be frequent during the GTK4 development
cycle.
2017-10-06 21:23:39 +02:00
Timm Bäder
a32725bc9a iconhelper: Don't inherit from GObject
It's not a GtkCssGadget anymore, it doesn't have any properties or
signals either and it's not public. Further, its lifetime is very clear
the way it's being used inside GTK+.
2017-10-01 09:19:09 +02:00
Timm Bäder
7b5c12c7dc iconhelper: Inherit from GObject
Nothing is using any gadget API on iconhelpers anymore.
2017-07-19 21:27:14 -04:00
Robert Ancell
82a4e830a3 iconhelper: Show error if fail to load placeholder icon 2017-06-09 09:24:02 +12:00
Timm Bäder
4e141883e8 iconhelper: Remove unused _draw implementation 2017-02-14 16:56:55 +01:00
Benjamin Otte
87497ca2e1 snapshot: Rename gtk_snapshot_translate_2d()
It's now called gtk_snapshot_offset().
2017-01-13 14:37:48 +01:00
Matthias Clasen
a013a16d1c Use _gtk_widget_get_window more
This avoids type checks in places where we know it is safe.
2017-01-10 19:56:02 -05:00
Benjamin Otte
2571036c07 gsk: Turn GskTexture into a GObject 2017-01-01 19:53:36 +01:00
Benjamin Otte
45fbc25e5e css: Remove -gtk-icon-effect
-gtk-icon-filter replaces this now.
2016-12-31 02:49:47 +01:00
Benjamin Otte
1d84555729 iconhelper: Invalidate style before accessing texture
Invalidating the style might cause invalidation of the texture. So we
end up with a pointer to freed memory.
SAD!
2016-12-24 06:19:16 +01:00
Benjamin Otte
c258ee403a snapshot: Make gtk_snapshot_get_renderer() private
Public API doesn't need to be concerned with renderers. Worst case, they
can use NULL instead of the actual renderer.
2016-12-20 18:01:10 +01:00
Benjamin Otte
3ba5c70028 iconhelper: Implement snapshot 2016-12-19 05:36:06 +01:00
Timm Bäder
3dac21f20b entry: Refactor get_icon_pixbuf
This way it will only return a pixbuf if the icon helper has a pixbuf.
2016-12-03 13:19:26 +01:00
Timm Bäder
8a543ab23c iconhelper: Ensure the surface used for textures is ARGB32 2016-12-03 13:19:26 +01:00
Timm Bäder
49508ddfdb iconhelper: Remove allocate implementation 2016-12-03 13:19:26 +01:00
Benjamin Otte
8161f8dcca rendericon: Pass the scale factor when rendeirng textures
Fixes icon rendeirng on hidpi.
2016-11-26 11:52:30 +01:00
Benjamin Otte
2745c2502f snapshot: Move GtkSnapshot declaration to gtypes.h 2016-11-19 20:58:36 +01:00
Benjamin Otte
6d9725f7fd snapshot: Add infrastructure to snapshot CSS images
Use this infrastructure to render builtin images. Which means from now
on, GtkCheckbutton, GtkSpinner and a few others use snapshots.
2016-11-16 20:51:53 +01:00
Benjamin Otte
40565fb030 gsk: Rework GskTexture
We do no longer bind textures to a renderer, instead they are a way for
applications to provide texture data.

For now, that's it. We've reverted to uploading it from scratch every
frame.
2016-11-16 17:36:33 +01:00
Benjamin Otte
dad8703e03 snapshot: Convert GtkSpinner 2016-11-15 17:49:19 +01:00
Benjamin Otte
4b8b06bb08 image: Invalidate icon helper when unrealizing
This frees up any cached surfaces and textures in the iconhelper,
ensuring that the renderer can release its texture data.
2016-11-15 17:49:19 +01:00
Benjamin Otte
c0aa065ac1 snapshot: Convert GtkImage and GtkIconHelper
Adds a bunch of new APIs to render textures with theming.

FIXME: Cannot draw shadows for textures.
2016-11-15 17:49:19 +01:00
Benjamin Otte
1259a489f2 iconhelper: Add support for GskTexture
... and use that in GtkImage.
2016-11-08 20:31:34 +01:00
Timm Bäder
ed184b3935 Remove GtkIconFactory
Move the icon size lookup API into gtkicontheme.c
2016-10-16 18:17:21 +02:00
Timm Bäder
627a824cab image: Remove GtkIconSet API 2016-10-16 18:17:21 +02:00
Timm Bäder
ad155fb26c Remove GtkStock API from GtkImage 2016-10-16 18:17:21 +02:00
Daniel Drake
fa23641992 _gtk_icon_helper_draw: get style earlier
After checking for rendered_surface, the call to gtk_css_node_get_style
can invalidate the style and result in rendered_surface being set to
NULL. This was result in some icon views appearing blank on
Endless OS on armv7hl, and this error:

Gtk-CRITICAL **: gtk_css_style_render_icon_surface: assertion 'surface != NULL' failed

Call gtk_css_node_get_style earlier to ensure we always pass a valid
surface to gtk_css_style_render_icon_surface.

https://bugzilla.gnome.org/show_bug.cgi?id=765649
https://phabricator.endlessm.com/T13524
2016-09-26 14:23:51 -07:00
Christian Hergert
8fc11ef2a5 Revert "iconhelper: check if surface was invalidated"
This reverts commit 88d0258397.
2016-04-27 19:02:25 -07:00
Christian Hergert
88d0258397 iconhelper: check if surface was invalidated
Fetching the style may cause the surface to be invalidated.
2016-04-27 17:45:01 -07:00
Benjamin Otte
3bc58d01e3 iconhelper: Invalidate on clear()
When clearing the icon helper, we need to invalidate it. Otherwise the
previous icon keeps lingering along.
This is not relevant inside gtkiconhelper.c where other code causes the
invalidation, but happens when external code calls
_gtk_icon_helper_clear().

https://bugzilla.gnome.org/show_bug.cgi?id=765066
2016-04-14 15:17:02 -04:00
Matthias Clasen
7382f3c347 icon helper: Properly update on style change
A GtkCssChange of NULL means 'everything changed!'.
2016-03-04 08:50:52 -05:00
Matthias Clasen
bbd94b5a9f gtk: Strip newlines from g_warning and g_error
g_logv adds one for us already.
2016-02-28 12:23:12 -05:00
Matthias Clasen
abd781a2c9 icon helper: Don't set baseline to 0
It is clearly not the intention that the baseline of icons is at
the very top. The visible effect of this was that spin buttons were
higher than expeted, because the box gadget was trying to line up
the baseline of the text with the top of the buttons, forcing extra
height to be requested.

Just don't set a baseline at all for now.
2016-02-25 13:18:02 -05:00
Timm Bäder
ded745a4b9 Make gtk_icon_helper_invalidate private 2016-02-07 19:16:26 +01:00
Timm Bäder
0bd6c48315 Add and use gtk_icon_helper_invalidate_for_change 2016-02-07 19:16:26 +01:00
Timm Bäder
0c80210685 iconhelper: Save whether the surface is symbolic 2016-02-07 19:16:26 +01:00
Timm Bäder
2902063f24 iconhelper: Un-duplicate some code 2016-02-07 19:16:26 +01:00