Commit Graph

166 Commits

Author SHA1 Message Date
Alexander Larsson
ff3e022182 icon helper: Remove profiler mark
This was hitting every time we looked up an icon, and we already
log the actual load of the icon in the icon theme.
2020-01-30 10:53:43 +01:00
Alexander Larsson
b087f9ca51 icon-theme: Drop the _for_scale() versions and always take scale 2020-01-30 10:53:43 +01:00
Alexander Larsson
e2f778602b icon-theme: Rename GtkIconInfo to GtkIcon 2020-01-30 10:53:43 +01:00
Alexander Larsson
aefd8443de GtkIconHelper use GtkIconInfo as paintable 2020-01-29 19:06:16 +01:00
Matthias Clasen
10e4c04e61 Use style values directly
Replace uses of gtk_css_style_get_value with direct access,
throughout the tree. We don't replace all uses, just those
where we are dealing with a fixed property. Be careful to
handle the currentColor special case for color properties.
2020-01-29 11:07:32 +01:00
Matthias Clasen
71ee4df357 css: Update affects flags for icons
We want to differentiate what requires recreating the
texture and what doesn't. In particular, the current
flags are not handling symbolic icons right.
2020-01-24 20:55:42 -05:00
Matthias Clasen
9b29da93b6 iconhelper: Add profiler marks around icon loading
These mainly happen during the first frame, causing
it to be longer than 'normal' frames.
2020-01-22 23:44:01 -05:00
Timm Bäder
71339225eb icontheme: Remove gtk_icon_info_load_texture
It's the same as load_icon now.
2019-09-09 17:36:26 +02:00
Timm Bäder
6821fe0c13 icontheme: Add error argument to _load_texture
Loading an icon might fail.
2019-09-09 17:36:26 +02:00
Timm Bäder
21123a1264 iconhelper: Don't snapshot 0 sized icons
This is happening for me when snapshotting small thumbnails in the file
chooser. The GtkScaler will scale the 1px height/width by 2, resulting
in nothing being drawn at all.
2019-08-09 15:55:38 +02:00
Timm Bäder
95f30fee87 iconhelper: Try to avoid some save/restore calls
GtkImage already does something similar so we often end up with 0/0
here. Avoid the save()/restore() calls in GtkSnapshot in that case.
2019-07-07 07:24:00 +02:00
Benjamin Otte
a5a7cdd84b iconhelper: Use new snapshot transforms 2019-02-21 19:47:28 +01:00
Benjamin Otte
89522e6923 iconhelper: Fix drawing of empty and paintable helpers
Empty helpers did try to draw a NULL paintable (not good) and in the
non-null case code used the wrong width/height.
2018-09-05 06:34:32 +02:00
Benjamin Otte
93c5455796 iconhelper: Plug memleak 2018-07-04 15:04:04 +02:00
Benjamin Otte
e1b6496af7 image: size request is always CONSTANT_SIZE
It's always -gtk-icon-size in both directions, even for paintables.
There's no width-for-height happening.
2018-07-04 06:15:33 +02:00
Benjamin Otte
884aaa2193 iconhelper: Always size contents to icon size
No more special casing for paintables. If you want the special case for
paintables, you should use GtkPicture.
2018-06-10 02:25:28 +02:00
Robert Ancell
e95eeaeef1 Fix comment typo introduced in a32725bc9a 2018-05-09 11:28:53 +12:00
Benjamin Otte
0ea8395c03 image: Actually report a request mode
This makes height-for-width actually work for GtkImage.

I'm kinda ashamed I didn't notice it not working before.
2018-04-05 14:57:10 +02:00
Krzesimir Nowak
06661da8b0 Fix some leaks 2018-03-27 13:14:41 +02:00
Benjamin Otte
e2ee2a6dab iconhelper: Apply scale to paintable
Instead of fiddling around with scale in the iconhelper (and getting it
wrong), create a GtkScaler around the paintable that takes care of the
scaling.
2018-03-26 18:46:22 +02:00
Benjamin Otte
12409ee075 cellrendererpixbuf: Store the texture in the iconhelper paintable
That's kinda weird but allows us to delete the texture case from
GtkIconHelper and GTK_IMAGE_TEXTURE from the GtkImageType enum.

And it doesn't cause any other problems because the cell renderer
can't deal with paintables - otherwise it would mirror GtkImage and have
a "paintable" property instead.
2018-03-16 06:04:45 +01:00
Benjamin Otte
c6541853ab image: Add gtk_image_set_keep_aspect_ratio()
If set, the image will draw its contents while keeping their aspect
ratio. That means empty areas show up on the top/bottom or left/right.

Also move the special-case snapshotting code for icons to
GtkIconHelper. That's where it belongs.
2018-03-16 06:04:45 +01:00
Benjamin Otte
0a08c03885 iconhelper: Implement GdkPaintable
This only implements the vfuncs, but does not actually emit signals
yet.

It's also not useed for anything other than snapshot() so far, this
will come in later commits.
2018-03-16 06:04:45 +01:00
Benjamin Otte
9e54c22c49 image: Don't handle surfaces anymore
Lots of special cases that are no longer needed because no code uses
surfaces.

Also remove the GdkCellRendererPixbuf:surface property.
2018-03-16 06:04:45 +01:00
Benjamin Otte
7844320f10 image: Load resources and files into textures
Instead of loading them into surfaces (which we want to get rid of), we
load into textures.
In fact, we introduce a new paintable subclass called a GtkScaler that
takes care of tracking scaling.

This also ideally gets rid of an extra conversion once renderers learn
to render textures directly.
2018-03-16 06:04:44 +01:00
Benjamin Otte
c9557c207f iconhelper: Handle texture scale again
We will need that in the next commits.
2018-03-16 06:04:44 +01:00
Benjamin Otte
2016f56176 iconhelper: Turn into a GObject 2018-03-16 06:04:44 +01:00
Benjamin Otte
3427639b08 iconhelper: Rework to allow resizing of paintables
GtkImage will now allow paintables to be rendered to the full image and
the image will be sized according to CSS rules for image sizing.
2018-03-16 06:04:44 +01:00
Benjamin Otte
3e50092869 iconhelper: Rename function
There are no more icon sizes, this is now the default size we render at.

This naming change is kinda relevant because of CSS terminology.
2018-03-16 06:04:44 +01:00
Benjamin Otte
9fa1e68151 image: Implement support for paintables
This includes adding support to GtkImageDefintion and GtkIconHelper.

Only GtkImage handles support for signals from the paintable.
2018-03-16 06:04:44 +01:00
Benjamin Otte
c59948169d iconhelper: transition to GdkPaintable
This is in preparation for accepting the image type paintable.

It's a bit incovenient because we need more code to track width/height
ourselves (as the paintable no longer does it for us), but it's not too
hard.

GtkIconHelper does not track invalidations on the paintable.
2018-03-16 06:04:44 +01:00
Matthias Clasen
a1c0b81bae icon helper: Avoid gratitious pixbuf use
We can just get the texture directly from the icontheme.
2017-11-30 17:31:17 -05:00
Matthias Clasen
7c4a1a596f icon helper: Avoid a few string copies 2017-11-17 23:21:24 -05:00
Matthias Clasen
c6c3427507 iconhelper: Query size via CSS
Instead of looking at the icon size, look at the CSS value for
-gtk-icon-size. Set style classes depending on icon size instead.

Trivially change Adwaita and HighContrast to report the same values as
before.
2017-11-15 14:22:17 -05:00
Matthias Clasen
2301d8d90b enums: Change GtkIconSize values
The new values are the ones we intend to keep. The old ones had
duplicated meanings and nobody knew which one to take.
2017-11-15 14:22:17 -05:00
Matthias Clasen
dbfaa99107 image: Remove icon-size argument from icon setters
Instead, add a function gtk_image_set_icon_size() for the cases where
overriding the icon size is necessary.

Treat icon sizes the same way as pixel sizes, too. So gtk_image_clear()
no longer unsets the icon size.
2017-11-15 14:22:17 -05:00
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