app: redo preview backgrounds completely
While there is a style "background color", the idea of a "widget background color" is completely bogus, the widget background can be a gradient or whatever. - Get rid of "background" in GimpViewable's preview API, only leave the "foreground color" there for things like brushes or fonts. - In GimpViewRenderer, add the background types to be used to class and instance, so each renderer type can choose what it needs. - Render all previews to alpha surfaces, and do the background for all renderers generically in gimp_view_renderer_real_draw(), then render the preview surface on top of it.
This commit is contained in:
parent
977bcae71e
commit
c2195a24ca
44 changed files with 497 additions and 659 deletions
|
|
@ -80,8 +80,7 @@ static GimpTempBuf * gimp_brush_get_new_preview (GimpViewable *vie
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
static gchar * gimp_brush_get_description (GimpViewable *viewable,
|
||||
gchar **tooltip);
|
||||
|
||||
|
|
@ -276,8 +275,7 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background)
|
||||
GeglColor *fg_color)
|
||||
{
|
||||
GimpBrush *brush = GIMP_BRUSH (viewable);
|
||||
const GimpTempBuf *mask_buf = brush->priv->mask;
|
||||
|
|
@ -373,10 +371,10 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
|
|||
}
|
||||
else
|
||||
{
|
||||
guint8 rgb[3] = {0, 0, 0};
|
||||
guint8 rgb[3] = { 0, 0, 0 };
|
||||
|
||||
if (color != NULL)
|
||||
gegl_color_get_pixel (color, babl_format ("R'G'B' u8"), rgb);
|
||||
if (fg_color)
|
||||
gegl_color_get_pixel (fg_color, babl_format ("R'G'B' u8"), rgb);
|
||||
|
||||
for (y = 0; y < mask_height; y++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -64,14 +64,12 @@ static GimpTempBuf * gimp_buffer_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
static GdkPixbuf * gimp_buffer_get_new_pixbuf (GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
static gchar * gimp_buffer_get_description (GimpViewable *viewable,
|
||||
gchar **tooltip);
|
||||
|
||||
|
|
@ -232,8 +230,7 @@ gimp_buffer_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
GeglColor *fg_color G_GNUC_UNUSED)
|
||||
{
|
||||
GimpBuffer *buffer = GIMP_BUFFER (viewable);
|
||||
const Babl *format = gimp_buffer_get_format (buffer);
|
||||
|
|
@ -268,8 +265,7 @@ gimp_buffer_get_new_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
GeglColor *fg_color G_GNUC_UNUSED)
|
||||
{
|
||||
GimpBuffer *buffer = GIMP_BUFFER (viewable);
|
||||
GdkPixbuf *pixbuf;
|
||||
|
|
|
|||
|
|
@ -87,8 +87,7 @@ static GimpTempBuf * gimp_curve_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
static gchar * gimp_curve_get_description (GimpViewable *viewable,
|
||||
gchar **tooltip);
|
||||
|
||||
|
|
@ -524,8 +523,7 @@ gimp_curve_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
GeglColor *fg_color G_GNUC_UNUSED)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,8 +113,7 @@ gimp_drawable_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
GeglColor *fg_color G_GNUC_UNUSED)
|
||||
{
|
||||
GimpItem *item = GIMP_ITEM (viewable);
|
||||
GimpImage *image = gimp_item_get_image (item);
|
||||
|
|
@ -135,8 +134,7 @@ gimp_drawable_get_new_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
GeglColor *fg_color G_GNUC_UNUSED)
|
||||
{
|
||||
GimpItem *item = GIMP_ITEM (viewable);
|
||||
GimpImage *image = gimp_item_get_image (item);
|
||||
|
|
|
|||
|
|
@ -25,14 +25,12 @@ GimpTempBuf * gimp_drawable_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
GdkPixbuf * gimp_drawable_get_new_pixbuf (GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
|
||||
/*
|
||||
* normal functions (no virtuals)
|
||||
|
|
|
|||
|
|
@ -63,8 +63,7 @@ static GimpTempBuf * gimp_gradient_get_new_preview (GimpViewable *viewa
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
|
||||
static const gchar * gimp_gradient_get_extension (GimpData *data);
|
||||
static void gimp_gradient_copy (GimpData *data,
|
||||
|
|
@ -219,8 +218,7 @@ gimp_gradient_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
GeglColor *fg_color G_GNUC_UNUSED)
|
||||
{
|
||||
GimpGradient *gradient = GIMP_GRADIENT (viewable);
|
||||
GimpGradientSegment *seg = NULL;
|
||||
|
|
|
|||
|
|
@ -122,8 +122,7 @@ gimp_image_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
GeglColor *fg_color G_GNUC_UNUSED)
|
||||
{
|
||||
GimpImage *image = GIMP_IMAGE (viewable);
|
||||
const Babl *format;
|
||||
|
|
@ -153,8 +152,7 @@ gimp_image_get_new_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
GeglColor *fg_color G_GNUC_UNUSED)
|
||||
{
|
||||
GimpImage *image = GIMP_IMAGE (viewable);
|
||||
GdkPixbuf *pixbuf;
|
||||
|
|
|
|||
|
|
@ -41,11 +41,9 @@ GimpTempBuf * gimp_image_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
GdkPixbuf * gimp_image_get_new_pixbuf (GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
|
|
|
|||
|
|
@ -95,8 +95,7 @@ static GdkPixbuf * gimp_imagefile_get_new_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
static gchar * gimp_imagefile_get_description (GimpViewable *viewable,
|
||||
gchar **tooltip);
|
||||
|
||||
|
|
@ -260,8 +259,7 @@ gimp_imagefile_get_new_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
GeglColor *fg_color G_GNUC_UNUSED)
|
||||
{
|
||||
GimpImagefile *imagefile = GIMP_IMAGEFILE (viewable);
|
||||
|
||||
|
|
@ -1112,7 +1110,7 @@ gimp_imagefile_save_thumb (GimpImagefile *imagefile,
|
|||
pixbuf = gimp_viewable_get_new_pixbuf (GIMP_VIEWABLE (image),
|
||||
/* random context, unused */
|
||||
gimp_get_user_context (image->gimp),
|
||||
width, height, NULL, NULL);
|
||||
width, height, NULL);
|
||||
|
||||
/* when layer previews are disabled, we won't get a pixbuf */
|
||||
if (! pixbuf)
|
||||
|
|
|
|||
|
|
@ -94,14 +94,12 @@ static GimpTempBuf * gimp_image_proxy_get_new_preview (GimpViewabl
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
static GdkPixbuf * gimp_image_proxy_get_new_pixbuf (GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
static gchar * gimp_image_proxy_get_description (GimpViewable *viewable,
|
||||
gchar **tooltip);
|
||||
|
||||
|
|
@ -378,8 +376,7 @@ gimp_image_proxy_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
GeglColor *fg_color G_GNUC_UNUSED)
|
||||
{
|
||||
GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (viewable);
|
||||
GimpImage *image = image_proxy->priv->image;
|
||||
|
|
@ -421,8 +418,7 @@ gimp_image_proxy_get_new_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
GeglColor *fg_color G_GNUC_UNUSED)
|
||||
{
|
||||
GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (viewable);
|
||||
GimpImage *image = image_proxy->priv->image;
|
||||
|
|
|
|||
|
|
@ -76,8 +76,7 @@ static GimpTempBuf * gimp_palette_get_new_preview (GimpViewable *vie
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
static gchar * gimp_palette_get_description (GimpViewable *viewable,
|
||||
gchar **tooltip);
|
||||
static const gchar * gimp_palette_get_extension (GimpData *data);
|
||||
|
|
@ -243,8 +242,7 @@ gimp_palette_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
GeglColor *fg_color G_GNUC_UNUSED)
|
||||
{
|
||||
GimpPalette *palette = GIMP_PALETTE (viewable);
|
||||
GimpTempBuf *temp_buf;
|
||||
|
|
|
|||
|
|
@ -50,8 +50,7 @@ static GimpTempBuf * gimp_pattern_get_new_preview (GimpViewable *viewa
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
static gchar * gimp_pattern_get_description (GimpViewable *viewable,
|
||||
gchar **tooltip);
|
||||
|
||||
|
|
@ -145,8 +144,7 @@ gimp_pattern_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
GeglColor *fg_color G_GNUC_UNUSED)
|
||||
{
|
||||
GimpPattern *pattern = GIMP_PATTERN (viewable);
|
||||
GimpTempBuf *temp_buf;
|
||||
|
|
|
|||
|
|
@ -83,8 +83,7 @@ static GimpTempBuf * gimp_undo_get_new_preview (GimpViewable *viewabl
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
|
||||
static void gimp_undo_real_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
|
|
@ -304,8 +303,7 @@ gimp_undo_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
GeglColor *fg_color G_GNUC_UNUSED)
|
||||
{
|
||||
GimpUndo *undo = GIMP_UNDO (viewable);
|
||||
|
||||
|
|
@ -495,7 +493,7 @@ gimp_undo_create_preview_private (GimpUndo *undo,
|
|||
}
|
||||
|
||||
undo->preview = gimp_viewable_get_new_preview (preview_viewable, context,
|
||||
width, height, NULL, NULL);
|
||||
width, height, NULL);
|
||||
|
||||
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (undo));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,11 +75,10 @@ struct _GimpViewablePrivate
|
|||
gint depth;
|
||||
|
||||
GimpTempBuf *preview_temp_buf;
|
||||
GeglColor *preview_temp_buf_color;
|
||||
|
||||
GdkPixbuf *preview_pixbuf;
|
||||
GeglColor *preview_pixbuf_color;
|
||||
GeglColor *preview_pixbuf_background;
|
||||
GeglColor *preview_temp_buf_color;
|
||||
GeglColor *preview_temp_buf_background;
|
||||
};
|
||||
|
||||
#define GET_PRIVATE(viewable) \
|
||||
|
|
@ -108,8 +107,7 @@ static GdkPixbuf * gimp_viewable_real_get_new_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
static void gimp_viewable_real_get_preview_size (GimpViewable *viewable,
|
||||
gint size,
|
||||
gboolean popup,
|
||||
|
|
@ -255,13 +253,11 @@ gimp_viewable_finalize (GObject *object)
|
|||
GimpViewablePrivate *private = GET_PRIVATE (object);
|
||||
|
||||
g_clear_pointer (&private->icon_name, g_free);
|
||||
g_clear_object (&private->icon_pixbuf);
|
||||
g_clear_object (&private->icon_pixbuf);
|
||||
g_clear_pointer (&private->preview_temp_buf, gimp_temp_buf_unref);
|
||||
g_clear_object (&private->preview_pixbuf);
|
||||
g_clear_object (&private->preview_pixbuf_color);
|
||||
g_clear_object (&private->preview_pixbuf_background);
|
||||
g_clear_object (&private->preview_temp_buf_color);
|
||||
g_clear_object (&private->preview_temp_buf_background);
|
||||
g_clear_object (&private->preview_temp_buf_color);
|
||||
g_clear_object (&private->preview_pixbuf);
|
||||
g_clear_object (&private->preview_pixbuf_color);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
|
@ -345,11 +341,9 @@ gimp_viewable_real_invalidate_preview (GimpViewable *viewable)
|
|||
GimpViewablePrivate *private = GET_PRIVATE (viewable);
|
||||
|
||||
g_clear_pointer (&private->preview_temp_buf, gimp_temp_buf_unref);
|
||||
g_clear_object (&private->preview_pixbuf);
|
||||
g_clear_object (&private->preview_pixbuf_color);
|
||||
g_clear_object (&private->preview_pixbuf_background);
|
||||
g_clear_object (&private->preview_temp_buf_color);
|
||||
g_clear_object (&private->preview_temp_buf_background);
|
||||
g_clear_object (&private->preview_temp_buf_color);
|
||||
g_clear_object (&private->preview_pixbuf);
|
||||
g_clear_object (&private->preview_pixbuf_color);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -419,14 +413,15 @@ gimp_viewable_real_get_new_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background)
|
||||
GeglColor *fg_color)
|
||||
{
|
||||
GimpViewablePrivate *private = GET_PRIVATE (viewable);
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
GimpTempBuf *temp_buf;
|
||||
|
||||
temp_buf = gimp_viewable_get_preview (viewable, context, width, height, color, background);
|
||||
temp_buf = gimp_viewable_get_preview (viewable, context,
|
||||
width, height,
|
||||
fg_color);
|
||||
|
||||
if (temp_buf)
|
||||
{
|
||||
|
|
@ -859,10 +854,8 @@ gimp_viewable_get_popup_size (GimpViewable *viewable,
|
|||
* @context: The context to render the preview for.
|
||||
* @width: desired width for the preview
|
||||
* @height: desired height for the preview
|
||||
* @color: desired foreground color for the preview when the type of
|
||||
* @fg_color :desired foreground color for the preview when the type of
|
||||
* @viewable support recolorization.
|
||||
* @background: desired background color for the preview when the type
|
||||
* of @viewable supports recolorization.
|
||||
*
|
||||
* Gets a preview for a viewable object, by running through a variety
|
||||
* of methods until it finds one that works. First, if an
|
||||
|
|
@ -888,8 +881,7 @@ gimp_viewable_get_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background)
|
||||
GeglColor *fg_color)
|
||||
{
|
||||
GimpViewablePrivate *private = GET_PRIVATE (viewable);
|
||||
GimpViewableClass *viewable_class;
|
||||
|
|
@ -899,8 +891,6 @@ gimp_viewable_get_preview (GimpViewable *viewable,
|
|||
g_return_val_if_fail (context == NULL || GIMP_IS_CONTEXT (context), NULL);
|
||||
g_return_val_if_fail (width > 0, NULL);
|
||||
g_return_val_if_fail (height > 0, NULL);
|
||||
g_return_val_if_fail ((color == NULL && background == NULL) ||
|
||||
(color != NULL && background != NULL), NULL);
|
||||
|
||||
if (G_UNLIKELY (context == NULL))
|
||||
g_warning ("%s: context is NULL", G_STRFUNC);
|
||||
|
|
@ -908,21 +898,23 @@ gimp_viewable_get_preview (GimpViewable *viewable,
|
|||
viewable_class = GIMP_VIEWABLE_GET_CLASS (viewable);
|
||||
|
||||
if (viewable_class->get_preview)
|
||||
temp_buf = viewable_class->get_preview (viewable, context, width, height, color, background);
|
||||
temp_buf = viewable_class->get_preview (viewable, context,
|
||||
width, height,
|
||||
fg_color);
|
||||
|
||||
if (temp_buf)
|
||||
return temp_buf;
|
||||
|
||||
if (private->preview_temp_buf &&
|
||||
((color == NULL && private->preview_temp_buf_color == NULL) ||
|
||||
(color != NULL && private->preview_temp_buf_color != NULL)))
|
||||
((fg_color == NULL && private->preview_temp_buf_color == NULL) ||
|
||||
(fg_color != NULL && private->preview_temp_buf_color != NULL)))
|
||||
{
|
||||
if (gimp_temp_buf_get_width (private->preview_temp_buf) == width &&
|
||||
gimp_temp_buf_get_height (private->preview_temp_buf) == height)
|
||||
{
|
||||
gboolean same_colors = TRUE;
|
||||
|
||||
if (color != NULL)
|
||||
if (fg_color)
|
||||
{
|
||||
gdouble r1, g1, b1, a1;
|
||||
gdouble r2, g2, b2, a2;
|
||||
|
|
@ -930,18 +922,12 @@ gimp_viewable_get_preview (GimpViewable *viewable,
|
|||
/* Don't use gimp_color_is_perceptually_identical(). Exact
|
||||
* comparison is fine for this use case.
|
||||
*/
|
||||
gegl_color_get_rgba (color, &r1, &g1, &b1, &a1);
|
||||
gegl_color_get_rgba (private->preview_temp_buf_color, &r2, &g2, &b2, &a2);
|
||||
gegl_color_get_rgba (fg_color,
|
||||
&r1, &g1, &b1, &a1);
|
||||
gegl_color_get_rgba (private->preview_temp_buf_color,
|
||||
&r2, &g2, &b2, &a2);
|
||||
|
||||
same_colors = (r1 == r2 && g1 == g2 && b1 == b2 && a1 == a2);
|
||||
|
||||
if (same_colors)
|
||||
{
|
||||
gegl_color_get_rgba (background, &r1, &g1, &b1, &a1);
|
||||
gegl_color_get_rgba (private->preview_temp_buf_background, &r2, &g2, &b2, &a2);
|
||||
|
||||
same_colors = (r1 == r2 && g1 == g2 && b1 == b2 && a1 == a2);
|
||||
}
|
||||
}
|
||||
|
||||
if (same_colors)
|
||||
|
|
@ -951,15 +937,15 @@ gimp_viewable_get_preview (GimpViewable *viewable,
|
|||
|
||||
g_clear_pointer (&private->preview_temp_buf, gimp_temp_buf_unref);
|
||||
g_clear_object (&private->preview_temp_buf_color);
|
||||
g_clear_object (&private->preview_temp_buf_background);
|
||||
|
||||
if (viewable_class->get_new_preview)
|
||||
temp_buf = viewable_class->get_new_preview (viewable, context,
|
||||
width, height, color, background);
|
||||
width, height,
|
||||
fg_color);
|
||||
|
||||
private->preview_temp_buf = temp_buf;
|
||||
private->preview_temp_buf_color = color ? gegl_color_duplicate (color) : NULL;
|
||||
private->preview_temp_buf_background = background ? gegl_color_duplicate (background) : NULL;
|
||||
private->preview_temp_buf = temp_buf;
|
||||
private->preview_temp_buf_color = fg_color ?
|
||||
gegl_color_duplicate (fg_color) : NULL;
|
||||
|
||||
return temp_buf;
|
||||
}
|
||||
|
|
@ -969,10 +955,8 @@ gimp_viewable_get_preview (GimpViewable *viewable,
|
|||
* @viewable: The viewable object to get a preview for.
|
||||
* @width: desired width for the preview
|
||||
* @height: desired height for the preview
|
||||
* @color: desired foreground color for the preview when the type of
|
||||
* @fg_color: desired foreground color for the preview when the type of
|
||||
* @viewable support recolorization.
|
||||
* @background: desired background color for the preview when the type
|
||||
* of @viewable supports recolorization.
|
||||
*
|
||||
* Gets a new preview for a viewable object. Similar to
|
||||
* gimp_viewable_get_preview(), except that it tries things in a
|
||||
|
|
@ -988,8 +972,7 @@ gimp_viewable_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background)
|
||||
GeglColor *fg_color)
|
||||
{
|
||||
GimpViewableClass *viewable_class;
|
||||
GimpTempBuf *temp_buf = NULL;
|
||||
|
|
@ -1006,14 +989,16 @@ gimp_viewable_get_new_preview (GimpViewable *viewable,
|
|||
|
||||
if (viewable_class->get_new_preview)
|
||||
temp_buf = viewable_class->get_new_preview (viewable, context,
|
||||
width, height, color, background);
|
||||
width, height,
|
||||
fg_color);
|
||||
|
||||
if (temp_buf)
|
||||
return temp_buf;
|
||||
|
||||
if (viewable_class->get_preview)
|
||||
temp_buf = viewable_class->get_preview (viewable, context,
|
||||
width, height, color, background);
|
||||
width, height,
|
||||
fg_color);
|
||||
|
||||
if (temp_buf)
|
||||
return gimp_temp_buf_copy (temp_buf);
|
||||
|
|
@ -1065,10 +1050,8 @@ gimp_viewable_get_dummy_preview (GimpViewable *viewable,
|
|||
* @context: The context to render the preview for.
|
||||
* @width: desired width for the preview
|
||||
* @height: desired height for the preview
|
||||
* @color: desired foreground color for the preview when the type of
|
||||
* @fg_color: desired foreground color for the preview when the type of
|
||||
* @viewable supports recolorization.
|
||||
* @background: desired background color for the preview when the type
|
||||
* of @viewable supports recolorization.
|
||||
*
|
||||
* Gets a preview for a viewable object, by running through a variety
|
||||
* of methods until it finds one that works. First, if an
|
||||
|
|
@ -1088,8 +1071,7 @@ gimp_viewable_get_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background)
|
||||
GeglColor *fg_color)
|
||||
{
|
||||
GimpViewablePrivate *private = GET_PRIVATE (viewable);
|
||||
GimpViewableClass *viewable_class;
|
||||
|
|
@ -1099,8 +1081,6 @@ gimp_viewable_get_pixbuf (GimpViewable *viewable,
|
|||
g_return_val_if_fail (context == NULL || GIMP_IS_CONTEXT (context), NULL);
|
||||
g_return_val_if_fail (width > 0, NULL);
|
||||
g_return_val_if_fail (height > 0, NULL);
|
||||
g_return_val_if_fail ((color == NULL && background == NULL) ||
|
||||
(color != NULL && background != NULL), NULL);
|
||||
|
||||
if (G_UNLIKELY (context == NULL))
|
||||
g_warning ("%s: context is NULL", G_STRFUNC);
|
||||
|
|
@ -1108,21 +1088,23 @@ gimp_viewable_get_pixbuf (GimpViewable *viewable,
|
|||
viewable_class = GIMP_VIEWABLE_GET_CLASS (viewable);
|
||||
|
||||
if (viewable_class->get_pixbuf)
|
||||
pixbuf = viewable_class->get_pixbuf (viewable, context, width, height, color, background);
|
||||
pixbuf = viewable_class->get_pixbuf (viewable, context,
|
||||
width, height,
|
||||
fg_color);
|
||||
|
||||
if (pixbuf)
|
||||
return pixbuf;
|
||||
|
||||
if (private->preview_pixbuf &&
|
||||
((color == NULL && private->preview_pixbuf_color == NULL) ||
|
||||
(color != NULL && private->preview_pixbuf_color != NULL)))
|
||||
((fg_color == NULL && private->preview_pixbuf_color == NULL) ||
|
||||
(fg_color != NULL && private->preview_pixbuf_color != NULL)))
|
||||
{
|
||||
if (gdk_pixbuf_get_width (private->preview_pixbuf) == width &&
|
||||
gdk_pixbuf_get_height (private->preview_pixbuf) == height)
|
||||
{
|
||||
gboolean same_colors = TRUE;
|
||||
|
||||
if (color != NULL)
|
||||
if (fg_color)
|
||||
{
|
||||
gdouble r1, g1, b1, a1;
|
||||
gdouble r2, g2, b2, a2;
|
||||
|
|
@ -1130,18 +1112,12 @@ gimp_viewable_get_pixbuf (GimpViewable *viewable,
|
|||
/* Don't use gimp_color_is_perceptually_identical(). Exact
|
||||
* comparison is fine for this use case.
|
||||
*/
|
||||
gegl_color_get_rgba (color, &r1, &g1, &b1, &a1);
|
||||
gegl_color_get_rgba (private->preview_pixbuf_color, &r2, &g2, &b2, &a2);
|
||||
gegl_color_get_rgba (fg_color,
|
||||
&r1, &g1, &b1, &a1);
|
||||
gegl_color_get_rgba (private->preview_pixbuf_color,
|
||||
&r2, &g2, &b2, &a2);
|
||||
|
||||
same_colors = (r1 == r2 && g1 == g2 && b1 == b2 && a1 == a2);
|
||||
|
||||
if (same_colors)
|
||||
{
|
||||
gegl_color_get_rgba (background, &r1, &g1, &b1, &a1);
|
||||
gegl_color_get_rgba (private->preview_pixbuf_background, &r2, &g2, &b2, &a2);
|
||||
|
||||
same_colors = (r1 == r2 && g1 == g2 && b1 == b2 && a1 == a2);
|
||||
}
|
||||
}
|
||||
|
||||
if (same_colors)
|
||||
|
|
@ -1151,14 +1127,15 @@ gimp_viewable_get_pixbuf (GimpViewable *viewable,
|
|||
|
||||
g_clear_object (&private->preview_pixbuf);
|
||||
g_clear_object (&private->preview_pixbuf_color);
|
||||
g_clear_object (&private->preview_pixbuf_background);
|
||||
|
||||
if (viewable_class->get_new_pixbuf)
|
||||
pixbuf = viewable_class->get_new_pixbuf (viewable, context, width, height, color, background);
|
||||
pixbuf = viewable_class->get_new_pixbuf (viewable, context,
|
||||
width, height,
|
||||
fg_color);
|
||||
|
||||
private->preview_pixbuf = pixbuf;
|
||||
private->preview_pixbuf_color = color ? gegl_color_duplicate (color) : NULL;
|
||||
private->preview_pixbuf_background = background ? gegl_color_duplicate (background) : NULL;
|
||||
private->preview_pixbuf = pixbuf;
|
||||
private->preview_pixbuf_color = fg_color ?
|
||||
gegl_color_duplicate (fg_color) : NULL;
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
|
@ -1169,7 +1146,7 @@ gimp_viewable_get_pixbuf (GimpViewable *viewable,
|
|||
* @context: The context to render the preview for.
|
||||
* @width: desired width for the pixbuf
|
||||
* @height: desired height for the pixbuf
|
||||
* @color: desired foreground color for the preview when the type of
|
||||
* @fg_color: desired foreground color for the preview when the type of
|
||||
* @viewable support recolorization.
|
||||
*
|
||||
* Gets a new preview for a viewable object. Similar to
|
||||
|
|
@ -1186,8 +1163,7 @@ gimp_viewable_get_new_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background)
|
||||
GeglColor *fg_color)
|
||||
{
|
||||
GimpViewableClass *viewable_class;
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
|
|
@ -1203,13 +1179,17 @@ gimp_viewable_get_new_pixbuf (GimpViewable *viewable,
|
|||
viewable_class = GIMP_VIEWABLE_GET_CLASS (viewable);
|
||||
|
||||
if (viewable_class->get_new_pixbuf)
|
||||
pixbuf = viewable_class->get_new_pixbuf (viewable, context, width, height, color, background);
|
||||
pixbuf = viewable_class->get_new_pixbuf (viewable, context,
|
||||
width, height,
|
||||
fg_color);
|
||||
|
||||
if (pixbuf)
|
||||
return pixbuf;
|
||||
|
||||
if (viewable_class->get_pixbuf)
|
||||
pixbuf = viewable_class->get_pixbuf (viewable, context, width, height, color, background);
|
||||
pixbuf = viewable_class->get_pixbuf (viewable, context,
|
||||
width, height,
|
||||
fg_color);
|
||||
|
||||
if (pixbuf)
|
||||
return gdk_pixbuf_copy (pixbuf);
|
||||
|
|
|
|||
|
|
@ -71,26 +71,22 @@ struct _GimpViewableClass
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *fg_color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
GimpTempBuf * (* get_new_preview) (GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *fg_color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
GdkPixbuf * (* get_pixbuf) (GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *fg_color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
GdkPixbuf * (* get_new_pixbuf) (GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *fg_color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
gchar * (* get_description) (GimpViewable *viewable,
|
||||
gchar **tooltip);
|
||||
|
||||
|
|
@ -145,14 +141,12 @@ GimpTempBuf * gimp_viewable_get_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *fg_color,
|
||||
GeglColor *bg_color);
|
||||
GeglColor *fg_color);
|
||||
GimpTempBuf * gimp_viewable_get_new_preview (GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *fg_color,
|
||||
GeglColor *bg_color);
|
||||
GeglColor *fg_color);
|
||||
|
||||
GimpTempBuf * gimp_viewable_get_dummy_preview (GimpViewable *viewable,
|
||||
gint width,
|
||||
|
|
@ -163,14 +157,12 @@ GdkPixbuf * gimp_viewable_get_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
GdkPixbuf * gimp_viewable_get_new_pixbuf (GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
|
||||
GdkPixbuf * gimp_viewable_get_dummy_pixbuf (GimpViewable *viewable,
|
||||
gint width,
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ gimp_image_metadata_rotate_dialog (GimpImage *image,
|
|||
|
||||
gimp_pickable_flush (GIMP_PICKABLE (image));
|
||||
pixbuf = gimp_viewable_get_pixbuf (GIMP_VIEWABLE (image), context,
|
||||
width, height, NULL, NULL);
|
||||
width, height, NULL);
|
||||
if (pixbuf)
|
||||
{
|
||||
GdkPixbuf *rotated;
|
||||
|
|
|
|||
|
|
@ -429,7 +429,7 @@ resize_dialog_new (GimpViewable *viewable,
|
|||
|
||||
gimp_viewable_get_preview_size (viewable, 200, TRUE, TRUE, &width, &height);
|
||||
pixbuf = gimp_viewable_get_pixbuf (viewable, context,
|
||||
width, height, NULL, NULL);
|
||||
width, height, NULL);
|
||||
|
||||
if (pixbuf)
|
||||
gimp_offset_area_set_pixbuf (GIMP_OFFSET_AREA (private->area), pixbuf);
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@ gimp_path_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
GeglColor *fg_color G_GNUC_UNUSED)
|
||||
{
|
||||
GimpPath *path;
|
||||
GimpItem *item;
|
||||
|
|
|
|||
|
|
@ -26,5 +26,4 @@ GimpTempBuf * gimp_path_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
|
|
|
|||
|
|
@ -980,7 +980,7 @@ drawable_thumbnail_invoker (GimpProcedure *procedure,
|
|||
|
||||
if (image->gimp->config->layer_previews)
|
||||
buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (drawable), context,
|
||||
width, height, NULL, NULL);
|
||||
width, height, NULL);
|
||||
else
|
||||
buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
|
||||
width, height,
|
||||
|
|
|
|||
|
|
@ -1849,7 +1849,7 @@ image_thumbnail_invoker (GimpProcedure *procedure,
|
|||
gimp_pickable_flush (GIMP_PICKABLE (image));
|
||||
|
||||
buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (image), context,
|
||||
width, height, NULL, NULL);
|
||||
width, height, NULL);
|
||||
|
||||
if (buf)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -134,8 +134,7 @@ static GimpTempBuf * gimp_font_get_new_preview (GimpViewable *viewab
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GeglColor *fg_color);
|
||||
|
||||
static void gimp_font_config_iface_init (GimpConfigInterface *iface);
|
||||
static gboolean gimp_font_serialize (GimpConfig *config,
|
||||
|
|
@ -714,8 +713,7 @@ gimp_font_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color,
|
||||
GeglColor *background)
|
||||
GeglColor *fg_color)
|
||||
{
|
||||
GimpFont *font = GIMP_FONT (viewable);
|
||||
PangoContext *pango_context;
|
||||
|
|
@ -736,8 +734,9 @@ gimp_font_get_new_preview (GimpViewable *viewable,
|
|||
if (! pango_context)
|
||||
return NULL;
|
||||
|
||||
if (! font->popup_layout ||
|
||||
font->popup_width != width || font->popup_height != height)
|
||||
if (! font->popup_layout ||
|
||||
font->popup_width != width ||
|
||||
font->popup_height != height)
|
||||
{
|
||||
PangoFontDescription *font_desc;
|
||||
const gchar *name;
|
||||
|
|
@ -770,19 +769,7 @@ gimp_font_get_new_preview (GimpViewable *viewable,
|
|||
stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width);
|
||||
|
||||
temp_buf = gimp_temp_buf_new (width, height, babl_format ("cairo-ARGB32"));
|
||||
if (background)
|
||||
{
|
||||
guint32 *data = (guint32 *) gimp_temp_buf_get_data (temp_buf);
|
||||
guint32 argb;
|
||||
|
||||
gegl_color_get_pixel (background, babl_format ("cairo-ARGB32"), &argb);
|
||||
for (gint i = 0; i < width * height; i++)
|
||||
data[i] = argb;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset (gimp_temp_buf_get_data (temp_buf), 255, width * height * 4);
|
||||
}
|
||||
memset (gimp_temp_buf_get_data (temp_buf), 0, width * height * 4);
|
||||
|
||||
surface = cairo_image_surface_create_for_data (gimp_temp_buf_get_data (temp_buf),
|
||||
CAIRO_FORMAT_ARGB32,
|
||||
|
|
@ -806,11 +793,11 @@ gimp_font_get_new_preview (GimpViewable *viewable,
|
|||
|
||||
cairo_translate (cr, layout_x, layout_y);
|
||||
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
|
||||
if (color)
|
||||
if (fg_color)
|
||||
{
|
||||
gfloat rgb[3];
|
||||
|
||||
gegl_color_get_pixel (color, babl_format ("R'G'B' float"), rgb);
|
||||
gegl_color_get_pixel (fg_color, babl_format ("R'G'B' float"), rgb);
|
||||
cairo_set_source_rgb (cr, rgb[0], rgb[1], rgb[2]);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1172,7 +1172,7 @@ gimp_clipboard_send_image (GtkClipboard *clipboard,
|
|||
gimp_get_user_context (gimp),
|
||||
gimp_image_get_width (gimp_clip->image),
|
||||
gimp_image_get_height (gimp_clip->image),
|
||||
NULL, NULL);
|
||||
NULL);
|
||||
|
||||
if (pixbuf)
|
||||
{
|
||||
|
|
@ -1218,7 +1218,7 @@ gimp_clipboard_send_buffer (GtkClipboard *clipboard,
|
|||
gimp_get_user_context (gimp),
|
||||
gimp_buffer_get_width (gimp_clip->buffer),
|
||||
gimp_buffer_get_height (gimp_clip->buffer),
|
||||
NULL, NULL);
|
||||
NULL);
|
||||
|
||||
if (pixbuf)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -828,55 +828,9 @@ gimp_container_icon_view_drag_pixbuf (GtkWidget *widget,
|
|||
gint height;
|
||||
|
||||
if (renderer && gimp_viewable_get_size (renderer->viewable, &width, &height))
|
||||
{
|
||||
GeglColor *color = NULL;
|
||||
GeglColor *background = NULL;
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
if (renderer->context)
|
||||
{
|
||||
gboolean follow_theme = FALSE;
|
||||
|
||||
g_object_get (renderer->context->gimp->config,
|
||||
"viewables-follow-theme", &follow_theme,
|
||||
NULL);
|
||||
if (follow_theme)
|
||||
{
|
||||
GtkStyleContext *style;
|
||||
GdkRGBA *fg_color = NULL;
|
||||
GdkRGBA *bg_color = NULL;
|
||||
|
||||
style = gtk_widget_get_style_context (widget);
|
||||
gtk_style_context_get (style, gtk_style_context_get_state (style),
|
||||
GTK_STYLE_PROPERTY_COLOR, &fg_color,
|
||||
GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &bg_color,
|
||||
NULL);
|
||||
if (fg_color && bg_color)
|
||||
{
|
||||
color = gegl_color_new (NULL);
|
||||
gegl_color_set_rgba_with_space (color,
|
||||
fg_color->red, fg_color->green, fg_color->blue, 1.0,
|
||||
NULL);
|
||||
|
||||
background = gegl_color_new (NULL);
|
||||
gegl_color_set_rgba_with_space (background,
|
||||
bg_color->red, bg_color->green, bg_color->blue, 1.0,
|
||||
NULL);
|
||||
}
|
||||
g_clear_pointer (&fg_color, gdk_rgba_free);
|
||||
g_clear_pointer (&bg_color, gdk_rgba_free);
|
||||
}
|
||||
}
|
||||
|
||||
pixbuf = gimp_viewable_get_new_pixbuf (renderer->viewable,
|
||||
renderer->context,
|
||||
width, height, color, background);
|
||||
|
||||
g_clear_object (&color);
|
||||
g_clear_object (&background);
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
return gimp_viewable_get_new_pixbuf (renderer->viewable,
|
||||
renderer->context,
|
||||
width, height, NULL);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1791,7 +1791,7 @@ gimp_container_tree_view_drag_pixbuf (GtkWidget *widget,
|
|||
if (renderer && gimp_viewable_get_size (renderer->viewable, &width, &height))
|
||||
return gimp_viewable_get_new_pixbuf (renderer->viewable,
|
||||
renderer->context,
|
||||
width, height, NULL, NULL);
|
||||
width, height, NULL);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -897,7 +897,7 @@ gimp_row_drag_pixbuf (GtkWidget *widget,
|
|||
{
|
||||
return gimp_viewable_get_new_pixbuf (priv->viewable,
|
||||
priv->context,
|
||||
width, height, NULL, NULL);
|
||||
width, height, NULL);
|
||||
}
|
||||
|
||||
g_printerr ("failed\n");
|
||||
|
|
|
|||
|
|
@ -848,7 +848,7 @@ gimp_view_drag_pixbuf (GtkWidget *widget,
|
|||
|
||||
if (viewable && gimp_viewable_get_size (viewable, &width, &height))
|
||||
return gimp_viewable_get_new_pixbuf (viewable, view->renderer->context,
|
||||
width, height, NULL, NULL);
|
||||
width, height, NULL);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ gimp_view_renderer_get_frame_pixbuf (GimpViewRenderer *renderer,
|
|||
{
|
||||
pixbuf = gimp_viewable_get_pixbuf (renderer->viewable,
|
||||
renderer->context,
|
||||
w, h, NULL, NULL);
|
||||
w, h, NULL);
|
||||
if (!pixbuf)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -252,7 +252,7 @@ gimp_view_renderer_get_frame_pixbuf (GimpViewRenderer *renderer,
|
|||
pixbuf = gimp_viewable_get_pixbuf (renderer->viewable,
|
||||
renderer->context,
|
||||
width - 2, height - 2,
|
||||
NULL, NULL);
|
||||
NULL);
|
||||
if (!pixbuf)
|
||||
return NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -37,13 +37,16 @@
|
|||
|
||||
#include "path/gimppath.h"
|
||||
|
||||
#include "text/gimpfont.h"
|
||||
|
||||
#include "gimpviewrenderer-utils.h"
|
||||
#include "gimpviewrendererbrush.h"
|
||||
#include "gimpviewrendererbuffer.h"
|
||||
#include "gimpviewrendererlayer.h"
|
||||
#include "gimpviewrendererfont.h"
|
||||
#include "gimpviewrenderergradient.h"
|
||||
#include "gimpviewrendererimage.h"
|
||||
#include "gimpviewrendererimagefile.h"
|
||||
#include "gimpviewrendererlayer.h"
|
||||
#include "gimpviewrendererpalette.h"
|
||||
#include "gimpviewrendererpath.h"
|
||||
|
||||
|
|
@ -93,6 +96,10 @@ gimp_view_renderer_type_from_viewable_type (GType viewable_type)
|
|||
{
|
||||
type = GIMP_TYPE_VIEW_RENDERER_PALETTE;
|
||||
}
|
||||
else if (g_type_is_a (viewable_type, GIMP_TYPE_FONT))
|
||||
{
|
||||
type = GIMP_TYPE_VIEW_RENDERER_FONT;
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
#include "widgets-types.h"
|
||||
|
||||
#include "config/gimpcoreconfig.h"
|
||||
#include "config/gimpguiconfig.h"
|
||||
|
||||
#include "gegl/gimp-gegl-loops.h"
|
||||
|
||||
|
|
@ -114,7 +115,9 @@ static cairo_pattern_t *
|
|||
gimp_view_renderer_create_background (GimpViewRenderer *renderer,
|
||||
GtkWidget *widget);
|
||||
|
||||
static void gimp_view_renderer_redraw (GimpViewRenderer *renderer);
|
||||
static void gimp_view_renderer_redraw (GimpGuiConfig *config,
|
||||
const GParamSpec *pspec,
|
||||
GimpViewRenderer *renderer);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GimpViewRenderer, gimp_view_renderer, G_TYPE_OBJECT)
|
||||
|
|
@ -140,17 +143,20 @@ gimp_view_renderer_class_init (GimpViewRendererClass *klass)
|
|||
object_class->dispose = gimp_view_renderer_dispose;
|
||||
object_class->finalize = gimp_view_renderer_finalize;
|
||||
|
||||
klass->update = NULL;
|
||||
klass->set_context = gimp_view_renderer_real_set_context;
|
||||
klass->invalidate = gimp_view_renderer_real_invalidate;
|
||||
klass->draw = gimp_view_renderer_real_draw;
|
||||
klass->render = gimp_view_renderer_real_render;
|
||||
klass->default_bg = GIMP_VIEW_BG_USE_STYLE;
|
||||
klass->follow_theme_bg = GIMP_VIEW_BG_USE_STYLE;
|
||||
|
||||
klass->frame = NULL;
|
||||
klass->frame_left = 0;
|
||||
klass->frame_right = 0;
|
||||
klass->frame_top = 0;
|
||||
klass->frame_bottom = 0;
|
||||
|
||||
klass->update = NULL;
|
||||
klass->set_context = gimp_view_renderer_real_set_context;
|
||||
klass->invalidate = gimp_view_renderer_real_invalidate;
|
||||
klass->draw = gimp_view_renderer_real_draw;
|
||||
klass->render = gimp_view_renderer_real_render;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -165,6 +171,7 @@ gimp_view_renderer_init (GimpViewRenderer *renderer)
|
|||
renderer->border_type = GIMP_VIEW_BORDER_BLACK;
|
||||
renderer->border_color = gegl_color_new ("black");
|
||||
|
||||
renderer->surface_bg = GIMP_VIEW_BG_USE_STYLE;
|
||||
renderer->size = -1;
|
||||
|
||||
renderer->priv->needs_render = TRUE;
|
||||
|
|
@ -298,14 +305,22 @@ gimp_view_renderer_set_context (GimpViewRenderer *renderer,
|
|||
|
||||
if (renderer->context)
|
||||
{
|
||||
g_signal_connect_object (renderer->context->gimp->config,
|
||||
GimpViewRendererClass *klass = GIMP_VIEW_RENDERER_GET_CLASS (renderer);
|
||||
GimpCoreConfig *config = renderer->context->gimp->config;
|
||||
|
||||
g_signal_connect_object (config,
|
||||
"notify::viewables-follow-theme",
|
||||
G_CALLBACK (gimp_view_renderer_redraw),
|
||||
renderer, G_CONNECT_SWAPPED);
|
||||
g_signal_connect_object (renderer->context->gimp->config,
|
||||
renderer, 0);
|
||||
g_signal_connect_object (config,
|
||||
"notify::theme-color-scheme",
|
||||
G_CALLBACK (gimp_view_renderer_redraw),
|
||||
renderer, G_CONNECT_SWAPPED);
|
||||
renderer, 0);
|
||||
|
||||
if (GIMP_GUI_CONFIG (config)->viewables_follow_theme)
|
||||
renderer->surface_bg = klass->follow_theme_bg;
|
||||
else
|
||||
renderer->surface_bg = klass->default_bg;
|
||||
}
|
||||
|
||||
if (renderer->viewable)
|
||||
|
|
@ -750,6 +765,56 @@ gimp_view_renderer_real_draw (GimpViewRenderer *renderer,
|
|||
renderer->priv->needs_render = FALSE;
|
||||
}
|
||||
|
||||
if (renderer->priv->bg_icon_name)
|
||||
{
|
||||
if (! renderer->priv->pattern)
|
||||
{
|
||||
renderer->priv->pattern =
|
||||
gimp_view_renderer_create_background (renderer, widget);
|
||||
}
|
||||
|
||||
cairo_set_source (cr, renderer->priv->pattern);
|
||||
cairo_paint (cr);
|
||||
}
|
||||
else
|
||||
{
|
||||
gint width = renderer->width;
|
||||
gint height = renderer->height;
|
||||
gint offset_x = (available_width - width) / 2;
|
||||
gint offset_y = (available_height - height) / 2;
|
||||
|
||||
cairo_translate (cr, offset_x, offset_y);
|
||||
cairo_rectangle (cr, 0, 0, width, height);
|
||||
|
||||
switch (renderer->surface_bg)
|
||||
{
|
||||
case GIMP_VIEW_BG_CHECKS:
|
||||
if (! renderer->priv->pattern)
|
||||
{
|
||||
const GeglColor *rgb1 = gimp_render_check_color1 ();
|
||||
const GeglColor *rgb2 = gimp_render_check_color2 ();
|
||||
|
||||
renderer->priv->pattern =
|
||||
gimp_cairo_checkerboard_create (cr, GIMP_CHECK_SIZE_SM,
|
||||
rgb1, rgb2);
|
||||
}
|
||||
|
||||
cairo_set_source (cr, renderer->priv->pattern);
|
||||
cairo_fill (cr);
|
||||
break;
|
||||
|
||||
case GIMP_VIEW_BG_WHITE:
|
||||
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
|
||||
cairo_fill (cr);
|
||||
break;
|
||||
|
||||
case GIMP_VIEW_BG_USE_STYLE:
|
||||
break;
|
||||
}
|
||||
|
||||
cairo_translate (cr, -offset_x, -offset_y);
|
||||
}
|
||||
|
||||
if (renderer->priv->icon_surface)
|
||||
{
|
||||
gint scale_factor = gtk_widget_get_scale_factor (widget);
|
||||
|
|
@ -763,57 +828,25 @@ gimp_view_renderer_real_draw (GimpViewRenderer *renderer,
|
|||
width /= scale_factor;
|
||||
height /= scale_factor;
|
||||
|
||||
if (renderer->priv->bg_icon_name)
|
||||
{
|
||||
if (! renderer->priv->pattern)
|
||||
{
|
||||
renderer->priv->pattern =
|
||||
gimp_view_renderer_create_background (renderer, widget);
|
||||
}
|
||||
|
||||
cairo_set_source (cr, renderer->priv->pattern);
|
||||
cairo_paint (cr);
|
||||
}
|
||||
|
||||
x = (available_width - width) / 2;
|
||||
y = (available_height - height) / 2;
|
||||
|
||||
cairo_set_source_surface (cr, renderer->priv->icon_surface, x, y);
|
||||
cairo_rectangle (cr, x, y, width, height);
|
||||
|
||||
cairo_set_source_surface (cr, renderer->priv->icon_surface, x, y);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
else if (renderer->surface)
|
||||
{
|
||||
cairo_content_t content = cairo_surface_get_content (renderer->surface);
|
||||
gint width = renderer->width;
|
||||
gint height = renderer->height;
|
||||
gint offset_x = (available_width - width) / 2;
|
||||
gint offset_y = (available_height - height) / 2;
|
||||
gint width = renderer->width;
|
||||
gint height = renderer->height;
|
||||
gint offset_x = (available_width - width) / 2;
|
||||
gint offset_y = (available_height - height) / 2;
|
||||
|
||||
cairo_translate (cr, offset_x, offset_y);
|
||||
cairo_rectangle (cr, offset_x, offset_y, width, height);
|
||||
|
||||
cairo_rectangle (cr, 0, 0, width, height);
|
||||
|
||||
if (content == CAIRO_CONTENT_COLOR_ALPHA)
|
||||
{
|
||||
if (! renderer->priv->pattern)
|
||||
{
|
||||
const GeglColor *rgb1;
|
||||
const GeglColor *rgb2;
|
||||
|
||||
rgb1 = gimp_render_check_color1 ();
|
||||
rgb2 = gimp_render_check_color2 ();
|
||||
renderer->priv->pattern = gimp_cairo_checkerboard_create (cr, GIMP_CHECK_SIZE_SM, rgb1, rgb2);
|
||||
}
|
||||
|
||||
cairo_set_source (cr, renderer->priv->pattern);
|
||||
cairo_fill_preserve (cr);
|
||||
}
|
||||
|
||||
cairo_set_source_surface (cr, renderer->surface, 0, 0);
|
||||
cairo_set_source_surface (cr, renderer->surface, offset_x, offset_y);
|
||||
cairo_fill (cr);
|
||||
|
||||
cairo_translate (cr, - offset_x, - offset_y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -824,55 +857,29 @@ gimp_view_renderer_real_render (GimpViewRenderer *renderer,
|
|||
GdkPixbuf *pixbuf;
|
||||
GimpTempBuf *temp_buf;
|
||||
const gchar *icon_name;
|
||||
GeglColor *color = NULL;
|
||||
GeglColor *background = NULL;
|
||||
GeglColor *fg_color = NULL;
|
||||
GimpViewBG inside_bg = GIMP_VIEW_BG_CHECKS;
|
||||
GimpViewBG outside_bg = GIMP_VIEW_BG_WHITE;
|
||||
gint scale_factor = gtk_widget_get_scale_factor (widget);
|
||||
|
||||
if (renderer->context)
|
||||
if (renderer->context &&
|
||||
GIMP_GUI_CONFIG (renderer->context->gimp->config)->viewables_follow_theme)
|
||||
{
|
||||
gboolean follow_theme = FALSE;
|
||||
fg_color = gimp_get_style_color (widget, GTK_STYLE_PROPERTY_COLOR);
|
||||
|
||||
g_object_get (renderer->context->gimp->config,
|
||||
"viewables-follow-theme", &follow_theme,
|
||||
NULL);
|
||||
if (follow_theme)
|
||||
{
|
||||
GtkStyleContext *style;
|
||||
GdkRGBA *fg_color = NULL;
|
||||
GdkRGBA *bg_color = NULL;
|
||||
|
||||
style = gtk_widget_get_style_context (widget);
|
||||
gtk_style_context_get (style, gtk_style_context_get_state (style),
|
||||
GTK_STYLE_PROPERTY_COLOR, &fg_color,
|
||||
GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &bg_color,
|
||||
NULL);
|
||||
if (fg_color && bg_color)
|
||||
{
|
||||
color = gegl_color_new (NULL);
|
||||
gegl_color_set_rgba_with_space (color,
|
||||
fg_color->red, fg_color->green, fg_color->blue, 1.0,
|
||||
NULL);
|
||||
|
||||
background = gegl_color_new (NULL);
|
||||
gegl_color_set_rgba_with_space (background,
|
||||
bg_color->red, bg_color->green, bg_color->blue, 1.0,
|
||||
NULL);
|
||||
}
|
||||
g_clear_pointer (&fg_color, gdk_rgba_free);
|
||||
g_clear_pointer (&bg_color, gdk_rgba_free);
|
||||
}
|
||||
inside_bg = GIMP_VIEW_BG_USE_STYLE;
|
||||
outside_bg = GIMP_VIEW_BG_USE_STYLE;
|
||||
}
|
||||
|
||||
pixbuf = gimp_viewable_get_pixbuf (renderer->viewable,
|
||||
renderer->context,
|
||||
renderer->width * scale_factor,
|
||||
renderer->height * scale_factor,
|
||||
color, background);
|
||||
fg_color);
|
||||
if (pixbuf)
|
||||
{
|
||||
gimp_view_renderer_render_pixbuf (renderer, widget, pixbuf);
|
||||
g_clear_object (&color);
|
||||
g_clear_object (&background);
|
||||
g_clear_object (&fg_color);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -880,18 +887,21 @@ gimp_view_renderer_real_render (GimpViewRenderer *renderer,
|
|||
renderer->context,
|
||||
renderer->width,
|
||||
renderer->height,
|
||||
color, background);
|
||||
fg_color);
|
||||
if (temp_buf)
|
||||
{
|
||||
gimp_view_renderer_render_temp_buf_simple (renderer, widget, temp_buf);
|
||||
gimp_view_renderer_render_temp_buf_simple (renderer, widget,
|
||||
temp_buf,
|
||||
inside_bg,
|
||||
outside_bg);
|
||||
g_clear_object (&fg_color);
|
||||
return;
|
||||
}
|
||||
|
||||
icon_name = gimp_viewable_get_icon_name (renderer->viewable);
|
||||
gimp_view_renderer_render_icon (renderer, widget, icon_name);
|
||||
|
||||
g_clear_object (&color);
|
||||
g_clear_object (&background);
|
||||
g_clear_object (&fg_color);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -926,7 +936,9 @@ gimp_view_renderer_config_notify (GObject *config,
|
|||
void
|
||||
gimp_view_renderer_render_temp_buf_simple (GimpViewRenderer *renderer,
|
||||
GtkWidget *widget,
|
||||
GimpTempBuf *temp_buf)
|
||||
GimpTempBuf *temp_buf,
|
||||
GimpViewBG inside_bg,
|
||||
GimpViewBG outside_bg)
|
||||
{
|
||||
gint temp_buf_x = 0;
|
||||
gint temp_buf_y = 0;
|
||||
|
|
@ -948,8 +960,8 @@ gimp_view_renderer_render_temp_buf_simple (GimpViewRenderer *renderer,
|
|||
gimp_view_renderer_render_temp_buf (renderer, widget, temp_buf,
|
||||
temp_buf_x, temp_buf_y,
|
||||
-1,
|
||||
GIMP_VIEW_BG_CHECKS,
|
||||
GIMP_VIEW_BG_WHITE);
|
||||
inside_bg,
|
||||
outside_bg);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -965,7 +977,7 @@ gimp_view_renderer_render_temp_buf (GimpViewRenderer *renderer,
|
|||
g_clear_pointer (&renderer->priv->icon_surface, cairo_surface_destroy);
|
||||
|
||||
if (! renderer->surface)
|
||||
renderer->surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
|
||||
renderer->surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
||||
renderer->width,
|
||||
renderer->height);
|
||||
|
||||
|
|
@ -992,6 +1004,7 @@ gimp_view_renderer_render_pixbuf (GimpViewRenderer *renderer,
|
|||
const Babl *format;
|
||||
gint scale_factor;
|
||||
|
||||
g_clear_pointer (&renderer->priv->icon_surface, cairo_surface_destroy);
|
||||
g_clear_pointer (&renderer->surface, cairo_surface_destroy);
|
||||
|
||||
format = gimp_pixbuf_get_format (pixbuf);
|
||||
|
|
@ -1037,7 +1050,6 @@ gimp_view_renderer_render_pixbuf (GimpViewRenderer *renderer,
|
|||
|
||||
scale_factor = gtk_widget_get_scale_factor (widget);
|
||||
|
||||
g_clear_pointer (&renderer->priv->icon_surface, cairo_surface_destroy);
|
||||
renderer->priv->icon_surface =
|
||||
gdk_cairo_surface_create_from_pixbuf (pixbuf, scale_factor, NULL);
|
||||
g_object_unref (pixbuf);
|
||||
|
|
@ -1088,7 +1100,6 @@ gimp_view_renderer_render_icon (GimpViewRenderer *renderer,
|
|||
pixbuf = scaled_pixbuf;
|
||||
}
|
||||
|
||||
g_clear_pointer (&renderer->priv->icon_surface, cairo_surface_destroy);
|
||||
renderer->priv->icon_surface =
|
||||
gdk_cairo_surface_create_from_pixbuf (pixbuf, scale_factor, NULL);
|
||||
g_object_unref (pixbuf);
|
||||
|
|
@ -1174,6 +1185,7 @@ gimp_view_renderer_free_color_transform (GimpViewRenderer *renderer)
|
|||
gimp_view_renderer_invalidate (renderer);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
|
|
@ -1217,17 +1229,21 @@ gimp_view_render_temp_buf_to_surface (GimpViewRenderer *renderer,
|
|||
|
||||
cr = cairo_create (surface);
|
||||
|
||||
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
|
||||
cairo_paint (cr);
|
||||
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
|
||||
|
||||
if (outside_bg == GIMP_VIEW_BG_CHECKS ||
|
||||
inside_bg == GIMP_VIEW_BG_CHECKS)
|
||||
{
|
||||
if (! renderer->priv->pattern)
|
||||
{
|
||||
const GeglColor *rgb1;
|
||||
const GeglColor *rgb2;
|
||||
const GeglColor *rgb1 = gimp_render_check_color1 ();
|
||||
const GeglColor *rgb2 = gimp_render_check_color2 ();
|
||||
|
||||
rgb1 = gimp_render_check_color1 ();
|
||||
rgb2 = gimp_render_check_color2 ();
|
||||
renderer->priv->pattern = gimp_cairo_checkerboard_create (cr, GIMP_CHECK_SIZE_SM, rgb1, rgb2);
|
||||
renderer->priv->pattern =
|
||||
gimp_cairo_checkerboard_create (cr, GIMP_CHECK_SIZE_SM,
|
||||
rgb1, rgb2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1235,54 +1251,18 @@ gimp_view_render_temp_buf_to_surface (GimpViewRenderer *renderer,
|
|||
{
|
||||
case GIMP_VIEW_BG_CHECKS:
|
||||
cairo_set_source (cr, renderer->priv->pattern);
|
||||
cairo_paint (cr);
|
||||
break;
|
||||
|
||||
case GIMP_VIEW_BG_WHITE:
|
||||
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
|
||||
cairo_paint (cr);
|
||||
break;
|
||||
|
||||
case GIMP_VIEW_BG_USE_STYLE:
|
||||
{
|
||||
GtkStyleContext *style;
|
||||
GdkRGBA *color = NULL;
|
||||
|
||||
/* Try to get the parent's color first to prevent issues with
|
||||
* changes in preselected backgrounds. If not set though, go for
|
||||
* the current's widget's color instead */
|
||||
style = gtk_widget_get_style_context (gtk_widget_get_parent (widget));
|
||||
gtk_style_context_get (style, gtk_style_context_get_state (style),
|
||||
GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &color,
|
||||
NULL);
|
||||
|
||||
if (color &&
|
||||
color->red == 0 &&
|
||||
color->green == 0 &&
|
||||
color->blue == 0)
|
||||
{
|
||||
gdk_rgba_free (color);
|
||||
|
||||
style = gtk_widget_get_style_context (widget);
|
||||
gtk_style_context_get (style, gtk_style_context_get_state (style),
|
||||
GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &color,
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (color)
|
||||
{
|
||||
cairo_set_source_rgb (cr, color->red, color->green, color->blue);
|
||||
|
||||
gdk_rgba_free (color);
|
||||
}
|
||||
else
|
||||
{
|
||||
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
cairo_paint (cr);
|
||||
|
||||
if (! gimp_rectangle_intersect (0, 0,
|
||||
surface_width, surface_height,
|
||||
temp_buf_x, temp_buf_y,
|
||||
|
|
@ -1294,8 +1274,9 @@ gimp_view_render_temp_buf_to_surface (GimpViewRenderer *renderer,
|
|||
return;
|
||||
}
|
||||
|
||||
if (inside_bg != outside_bg &&
|
||||
babl_format_has_alpha (temp_buf_format) && channel == -1)
|
||||
if (inside_bg != outside_bg &&
|
||||
babl_format_has_alpha (temp_buf_format) &&
|
||||
channel == -1)
|
||||
{
|
||||
cairo_rectangle (cr, x, y, width, height);
|
||||
|
||||
|
|
@ -1303,32 +1284,31 @@ gimp_view_render_temp_buf_to_surface (GimpViewRenderer *renderer,
|
|||
{
|
||||
case GIMP_VIEW_BG_CHECKS:
|
||||
cairo_set_source (cr, renderer->priv->pattern);
|
||||
cairo_fill (cr);
|
||||
break;
|
||||
|
||||
case GIMP_VIEW_BG_WHITE:
|
||||
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
|
||||
cairo_fill (cr);
|
||||
break;
|
||||
|
||||
case GIMP_VIEW_BG_USE_STYLE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
if (babl_format_has_alpha (temp_buf_format) && channel == -1)
|
||||
if (channel == -1)
|
||||
{
|
||||
GimpColorTransform *transform;
|
||||
GeglBuffer *src_buffer;
|
||||
GeglBuffer *dest_buffer;
|
||||
cairo_surface_t *alpha_surface;
|
||||
cairo_surface_t *tmp_surface;
|
||||
|
||||
alpha_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
||||
width, height);
|
||||
tmp_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
||||
width, height);
|
||||
|
||||
src_buffer = gimp_temp_buf_create_buffer (temp_buf);
|
||||
dest_buffer = gimp_cairo_surface_create_buffer (alpha_surface, NULL);
|
||||
dest_buffer = gimp_cairo_surface_create_buffer (tmp_surface, NULL);
|
||||
|
||||
transform =
|
||||
gimp_view_renderer_get_color_transform (renderer, widget,
|
||||
|
|
@ -1359,56 +1339,14 @@ gimp_view_render_temp_buf_to_surface (GimpViewRenderer *renderer,
|
|||
g_object_unref (src_buffer);
|
||||
g_object_unref (dest_buffer);
|
||||
|
||||
cairo_surface_mark_dirty (alpha_surface);
|
||||
cairo_surface_mark_dirty (tmp_surface);
|
||||
|
||||
cairo_translate (cr, x, y);
|
||||
cairo_rectangle (cr, 0, 0, width, height);
|
||||
cairo_set_source_surface (cr, alpha_surface, 0, 0);
|
||||
cairo_set_source_surface (cr, tmp_surface, 0, 0);
|
||||
cairo_fill (cr);
|
||||
|
||||
cairo_surface_destroy (alpha_surface);
|
||||
}
|
||||
else if (channel == -1)
|
||||
{
|
||||
GimpColorTransform *transform;
|
||||
GeglBuffer *src_buffer;
|
||||
GeglBuffer *dest_buffer;
|
||||
|
||||
cairo_surface_flush (surface);
|
||||
|
||||
src_buffer = gimp_temp_buf_create_buffer (temp_buf);
|
||||
dest_buffer = gimp_cairo_surface_create_buffer (surface, NULL);
|
||||
|
||||
transform =
|
||||
gimp_view_renderer_get_color_transform (renderer, widget,
|
||||
gegl_buffer_get_format (src_buffer),
|
||||
gegl_buffer_get_format (dest_buffer));
|
||||
|
||||
if (transform)
|
||||
{
|
||||
gimp_color_transform_process_buffer (transform,
|
||||
src_buffer,
|
||||
GEGL_RECTANGLE (x - temp_buf_x,
|
||||
y - temp_buf_y,
|
||||
width, height),
|
||||
dest_buffer,
|
||||
GEGL_RECTANGLE (x, y, 0, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_gegl_buffer_copy (src_buffer,
|
||||
GEGL_RECTANGLE (x - temp_buf_x,
|
||||
y - temp_buf_y,
|
||||
width, height),
|
||||
GEGL_ABYSS_NONE,
|
||||
dest_buffer,
|
||||
GEGL_RECTANGLE (x, y, 0, 0));
|
||||
}
|
||||
|
||||
g_object_unref (src_buffer);
|
||||
g_object_unref (dest_buffer);
|
||||
|
||||
cairo_surface_mark_dirty (surface);
|
||||
cairo_surface_destroy (tmp_surface);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1493,8 +1431,17 @@ gimp_view_renderer_create_background (GimpViewRenderer *renderer,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_view_renderer_redraw (GimpViewRenderer *renderer)
|
||||
gimp_view_renderer_redraw (GimpGuiConfig *config,
|
||||
const GParamSpec *pspec,
|
||||
GimpViewRenderer *renderer)
|
||||
{
|
||||
GimpViewRendererClass *klass = GIMP_VIEW_RENDERER_GET_CLASS (renderer);
|
||||
|
||||
if (config->viewables_follow_theme)
|
||||
renderer->surface_bg = klass->follow_theme_bg;
|
||||
else
|
||||
renderer->surface_bg = klass->default_bg;
|
||||
|
||||
gimp_view_renderer_invalidate (renderer);
|
||||
gimp_view_renderer_update (renderer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ struct _GimpViewRenderer
|
|||
|
||||
/*< protected >*/
|
||||
cairo_surface_t *surface;
|
||||
GimpViewBG surface_bg;
|
||||
|
||||
gint size;
|
||||
|
||||
|
|
@ -66,6 +67,9 @@ struct _GimpViewRendererClass
|
|||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
GimpViewBG default_bg;
|
||||
GimpViewBG follow_theme_bg;
|
||||
|
||||
GdkPixbuf *frame;
|
||||
gint frame_left;
|
||||
gint frame_right;
|
||||
|
|
@ -142,7 +146,9 @@ void gimp_view_renderer_draw (GimpViewRenderer *renderer,
|
|||
|
||||
void gimp_view_renderer_render_temp_buf_simple (GimpViewRenderer *renderer,
|
||||
GtkWidget *widget,
|
||||
GimpTempBuf *temp_buf);
|
||||
GimpTempBuf *temp_buf,
|
||||
GimpViewBG inside_bg,
|
||||
GimpViewBG outside_bg);
|
||||
void gimp_view_renderer_render_temp_buf (GimpViewRenderer *renderer,
|
||||
GtkWidget *widget,
|
||||
GimpTempBuf *temp_buf,
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "config/gimpguiconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpbrushpipe.h"
|
||||
#include "core/gimpbrushgenerated.h"
|
||||
|
|
@ -32,19 +34,18 @@
|
|||
#include "core/gimptempbuf.h"
|
||||
|
||||
#include "gimpviewrendererbrush.h"
|
||||
#include "gimpwidgets-utils.h"
|
||||
|
||||
|
||||
static void gimp_view_renderer_brush_finalize (GObject *object);
|
||||
static void gimp_view_renderer_brush_finalize (GObject *object);
|
||||
|
||||
static void gimp_view_renderer_brush_set_context (GimpViewRenderer *renderer,
|
||||
GimpContext *context);
|
||||
static void gimp_view_renderer_brush_render (GimpViewRenderer *renderer,
|
||||
GtkWidget *widget);
|
||||
static void gimp_view_renderer_brush_draw (GimpViewRenderer *renderer,
|
||||
GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gint available_width,
|
||||
gint available_height);
|
||||
static void gimp_view_renderer_brush_render (GimpViewRenderer *renderer,
|
||||
GtkWidget *widget);
|
||||
static void gimp_view_renderer_brush_draw (GimpViewRenderer *renderer,
|
||||
GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
gint available_width,
|
||||
gint available_height);
|
||||
|
||||
static gboolean gimp_view_renderer_brush_render_timeout (gpointer data);
|
||||
|
||||
|
|
@ -61,11 +62,13 @@ gimp_view_renderer_brush_class_init (GimpViewRendererBrushClass *klass)
|
|||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpViewRendererClass *renderer_class = GIMP_VIEW_RENDERER_CLASS (klass);
|
||||
|
||||
object_class->finalize = gimp_view_renderer_brush_finalize;
|
||||
object_class->finalize = gimp_view_renderer_brush_finalize;
|
||||
|
||||
renderer_class->set_context = gimp_view_renderer_brush_set_context;
|
||||
renderer_class->render = gimp_view_renderer_brush_render;
|
||||
renderer_class->draw = gimp_view_renderer_brush_draw;
|
||||
renderer_class->default_bg = GIMP_VIEW_BG_WHITE;
|
||||
renderer_class->follow_theme_bg = GIMP_VIEW_BG_USE_STYLE;
|
||||
|
||||
renderer_class->render = gimp_view_renderer_brush_render;
|
||||
renderer_class->draw = gimp_view_renderer_brush_draw;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -89,44 +92,16 @@ gimp_view_renderer_brush_finalize (GObject *object)
|
|||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_view_renderer_brush_set_context (GimpViewRenderer *renderer,
|
||||
GimpContext *context)
|
||||
{
|
||||
if (renderer->context)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (renderer->context->gimp->config,
|
||||
G_CALLBACK (gimp_view_renderer_invalidate),
|
||||
renderer);
|
||||
}
|
||||
|
||||
GIMP_VIEW_RENDERER_CLASS (parent_class)->set_context (renderer, context);
|
||||
|
||||
if (renderer->context)
|
||||
{
|
||||
g_signal_connect_object (renderer->context->gimp->config,
|
||||
"notify::viewables-follow-theme",
|
||||
G_CALLBACK (gimp_view_renderer_invalidate),
|
||||
renderer, G_CONNECT_SWAPPED);
|
||||
g_signal_connect_object (renderer->context->gimp->config,
|
||||
"notify::theme-color-scheme",
|
||||
G_CALLBACK (gimp_view_renderer_invalidate),
|
||||
renderer, G_CONNECT_SWAPPED);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_view_renderer_brush_render (GimpViewRenderer *renderer,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GimpViewRendererBrush *renderbrush = GIMP_VIEW_RENDERER_BRUSH (renderer);
|
||||
GimpViewRendererBrush *renderbrush = GIMP_VIEW_RENDERER_BRUSH (renderer);
|
||||
GimpTempBuf *temp_buf;
|
||||
GeglColor *color = NULL;
|
||||
GeglColor *background = NULL;
|
||||
gboolean follow_theme = FALSE;
|
||||
GimpViewBG view_bg_style = GIMP_VIEW_BG_WHITE;
|
||||
gint temp_buf_x = 0;
|
||||
gint temp_buf_y = 0;
|
||||
GeglColor *fg_color = NULL;
|
||||
GimpViewBG bg_style = GIMP_VIEW_BG_WHITE;
|
||||
gint temp_buf_x = 0;
|
||||
gint temp_buf_y = 0;
|
||||
gint temp_buf_width;
|
||||
gint temp_buf_height;
|
||||
|
||||
|
|
@ -136,41 +111,17 @@ gimp_view_renderer_brush_render (GimpViewRenderer *renderer,
|
|||
renderbrush->pipe_timeout_id = 0;
|
||||
}
|
||||
|
||||
g_object_get (renderer->context->gimp->config,
|
||||
"viewables-follow-theme", &follow_theme,
|
||||
NULL);
|
||||
if (follow_theme)
|
||||
if (renderer->context &&
|
||||
GIMP_GUI_CONFIG (renderer->context->gimp->config)->viewables_follow_theme)
|
||||
{
|
||||
GtkStyleContext *style;
|
||||
GdkRGBA *fg_color = NULL;
|
||||
GdkRGBA *bg_color = NULL;
|
||||
|
||||
style = gtk_widget_get_style_context (widget);
|
||||
gtk_style_context_get (style, gtk_style_context_get_state (style),
|
||||
GTK_STYLE_PROPERTY_COLOR, &fg_color,
|
||||
GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &bg_color,
|
||||
NULL);
|
||||
if (fg_color)
|
||||
{
|
||||
color = gegl_color_new (NULL);
|
||||
gegl_color_set_rgba_with_space (color,
|
||||
fg_color->red, fg_color->green, fg_color->blue, 1.0,
|
||||
NULL);
|
||||
|
||||
background = gegl_color_new (NULL);
|
||||
gegl_color_set_rgba_with_space (background,
|
||||
bg_color->red, bg_color->green, bg_color->blue, 1.0,
|
||||
NULL);
|
||||
view_bg_style = GIMP_VIEW_BG_USE_STYLE;
|
||||
}
|
||||
g_clear_pointer (&fg_color, gdk_rgba_free);
|
||||
g_clear_pointer (&bg_color, gdk_rgba_free);
|
||||
fg_color = gimp_get_style_color (widget, GTK_STYLE_PROPERTY_COLOR);
|
||||
bg_style = GIMP_VIEW_BG_USE_STYLE;
|
||||
}
|
||||
|
||||
temp_buf = gimp_viewable_get_new_preview (renderer->viewable, renderer->context,
|
||||
renderer->width, renderer->height, color, background);
|
||||
g_clear_object (&color);
|
||||
g_clear_object (&background);
|
||||
temp_buf = gimp_viewable_get_new_preview (renderer->viewable,
|
||||
renderer->context,
|
||||
renderer->width, renderer->height,
|
||||
fg_color);
|
||||
|
||||
temp_buf_width = gimp_temp_buf_get_width (temp_buf);
|
||||
temp_buf_height = gimp_temp_buf_get_height (temp_buf);
|
||||
|
|
@ -181,33 +132,21 @@ gimp_view_renderer_brush_render (GimpViewRenderer *renderer,
|
|||
if (temp_buf_height < renderer->height)
|
||||
temp_buf_y = (renderer->height - temp_buf_height) / 2;
|
||||
|
||||
if (renderer->is_popup)
|
||||
{
|
||||
gimp_view_renderer_render_temp_buf (renderer, widget, temp_buf,
|
||||
temp_buf_x, temp_buf_y,
|
||||
-1,
|
||||
view_bg_style,
|
||||
view_bg_style);
|
||||
|
||||
gimp_temp_buf_unref (temp_buf);
|
||||
|
||||
if (GIMP_IS_BRUSH_PIPE (renderer->viewable))
|
||||
{
|
||||
renderbrush->widget = widget;
|
||||
renderbrush->pipe_animation_index = 0;
|
||||
renderbrush->pipe_timeout_id =
|
||||
g_timeout_add (300, gimp_view_renderer_brush_render_timeout,
|
||||
renderbrush);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
gimp_view_renderer_render_temp_buf (renderer, widget, temp_buf,
|
||||
temp_buf_x, temp_buf_y,
|
||||
-1,
|
||||
view_bg_style,
|
||||
view_bg_style);
|
||||
bg_style,
|
||||
bg_style);
|
||||
|
||||
if (renderer->is_popup &&
|
||||
GIMP_IS_BRUSH_PIPE (renderer->viewable))
|
||||
{
|
||||
renderbrush->widget = widget;
|
||||
renderbrush->pipe_animation_index = 0;
|
||||
renderbrush->pipe_timeout_id =
|
||||
g_timeout_add (300, gimp_view_renderer_brush_render_timeout,
|
||||
renderbrush);
|
||||
}
|
||||
|
||||
gimp_temp_buf_unref (temp_buf);
|
||||
}
|
||||
|
|
@ -220,10 +159,8 @@ gimp_view_renderer_brush_render_timeout (gpointer data)
|
|||
GimpBrushPipe *brush_pipe;
|
||||
GimpBrush *brush;
|
||||
GimpTempBuf *temp_buf;
|
||||
GeglColor *color = NULL;
|
||||
GeglColor *background = NULL;
|
||||
gboolean follow_theme = FALSE;
|
||||
GimpViewBG view_bg_style = GIMP_VIEW_BG_WHITE;
|
||||
GeglColor *fg_color = NULL;
|
||||
GimpViewBG bg_style = GIMP_VIEW_BG_WHITE;
|
||||
gint temp_buf_x = 0;
|
||||
gint temp_buf_y = 0;
|
||||
gint temp_buf_width;
|
||||
|
|
@ -239,35 +176,13 @@ gimp_view_renderer_brush_render_timeout (gpointer data)
|
|||
|
||||
brush_pipe = GIMP_BRUSH_PIPE (renderer->viewable);
|
||||
|
||||
g_object_get (renderer->context->gimp->config,
|
||||
"viewables-follow-theme", &follow_theme,
|
||||
NULL);
|
||||
if (follow_theme)
|
||||
if (renderer->context &&
|
||||
GIMP_GUI_CONFIG (renderer->context->gimp->config)->viewables_follow_theme)
|
||||
{
|
||||
GtkStyleContext *style;
|
||||
GdkRGBA *bg_color = NULL;
|
||||
GdkRGBA *fg_color = NULL;
|
||||
bg_style = GIMP_VIEW_BG_USE_STYLE;
|
||||
|
||||
style = gtk_widget_get_style_context (renderbrush->widget);
|
||||
gtk_style_context_get (style, gtk_style_context_get_state (style),
|
||||
GTK_STYLE_PROPERTY_COLOR, &fg_color,
|
||||
GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &bg_color,
|
||||
NULL);
|
||||
if (fg_color)
|
||||
{
|
||||
color = gegl_color_new (NULL);
|
||||
gegl_color_set_rgba_with_space (color,
|
||||
fg_color->red, fg_color->green, fg_color->blue, 1.0,
|
||||
NULL);
|
||||
|
||||
background = gegl_color_new (NULL);
|
||||
gegl_color_set_rgba_with_space (background,
|
||||
bg_color->red, bg_color->green, bg_color->blue, 1.0,
|
||||
NULL);
|
||||
view_bg_style = GIMP_VIEW_BG_USE_STYLE;
|
||||
}
|
||||
g_clear_pointer (&fg_color, gdk_rgba_free);
|
||||
g_clear_pointer (&bg_color, gdk_rgba_free);
|
||||
fg_color = gimp_get_style_color (renderbrush->widget,
|
||||
GTK_STYLE_PROPERTY_COLOR);
|
||||
}
|
||||
|
||||
renderbrush->pipe_animation_index++;
|
||||
|
|
@ -282,9 +197,8 @@ gimp_view_renderer_brush_render_timeout (gpointer data)
|
|||
renderer->context,
|
||||
renderer->width,
|
||||
renderer->height,
|
||||
color, background);
|
||||
g_clear_object (&color);
|
||||
g_clear_object (&background);
|
||||
fg_color);
|
||||
g_clear_object (&fg_color);
|
||||
|
||||
temp_buf_width = gimp_temp_buf_get_width (temp_buf);
|
||||
temp_buf_height = gimp_temp_buf_get_height (temp_buf);
|
||||
|
|
@ -298,8 +212,8 @@ gimp_view_renderer_brush_render_timeout (gpointer data)
|
|||
gimp_view_renderer_render_temp_buf (renderer, renderbrush->widget, temp_buf,
|
||||
temp_buf_x, temp_buf_y,
|
||||
-1,
|
||||
view_bg_style,
|
||||
view_bg_style);
|
||||
bg_style,
|
||||
bg_style);
|
||||
|
||||
gimp_temp_buf_unref (temp_buf);
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ gimp_view_renderer_buffer_render (GimpViewRenderer *renderer,
|
|||
temp_buf = gimp_viewable_get_new_preview (renderer->viewable,
|
||||
renderer->context,
|
||||
buffer_width, buffer_height,
|
||||
NULL, NULL);
|
||||
NULL);
|
||||
|
||||
if (temp_buf)
|
||||
{
|
||||
|
|
@ -99,12 +99,15 @@ gimp_view_renderer_buffer_render (GimpViewRenderer *renderer,
|
|||
render_buf = gimp_viewable_get_new_preview (renderer->viewable,
|
||||
renderer->context,
|
||||
view_width, view_height,
|
||||
NULL, NULL);
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (render_buf)
|
||||
{
|
||||
gimp_view_renderer_render_temp_buf_simple (renderer, widget, render_buf);
|
||||
gimp_view_renderer_render_temp_buf_simple (renderer, widget,
|
||||
render_buf,
|
||||
GIMP_VIEW_BG_CHECKS,
|
||||
GIMP_VIEW_BG_WHITE);
|
||||
|
||||
gimp_temp_buf_unref (render_buf);
|
||||
}
|
||||
|
|
|
|||
50
app/widgets/gimpviewrendererfont.c
Normal file
50
app/widgets/gimpviewrendererfont.c
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpviewrendererfont.c
|
||||
* Copyright (C) 2025 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "gimpviewrendererfont.h"
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpViewRendererFont,
|
||||
gimp_view_renderer_font,
|
||||
GIMP_TYPE_VIEW_RENDERER)
|
||||
|
||||
#define parent_class gimp_view_renderer_font_parent_class
|
||||
|
||||
|
||||
static void
|
||||
gimp_view_renderer_font_class_init (GimpViewRendererFontClass *klass)
|
||||
{
|
||||
GimpViewRendererClass *renderer_class = GIMP_VIEW_RENDERER_CLASS (klass);
|
||||
|
||||
renderer_class->default_bg = GIMP_VIEW_BG_WHITE;
|
||||
renderer_class->follow_theme_bg = GIMP_VIEW_BG_USE_STYLE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_view_renderer_font_init (GimpViewRendererFont *renderer)
|
||||
{
|
||||
}
|
||||
47
app/widgets/gimpviewrendererfont.h
Normal file
47
app/widgets/gimpviewrendererfont.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpviewrendererfont.h
|
||||
* Copyright (C) 2025 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gimpviewrenderer.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_VIEW_RENDERER_FONT (gimp_view_renderer_font_get_type ())
|
||||
#define GIMP_VIEW_RENDERER_FONT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_VIEW_RENDERER_FONT, GimpViewRendererFont))
|
||||
#define GIMP_VIEW_RENDERER_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_VIEW_RENDERER_FONT, GimpViewRendererFontClass))
|
||||
#define GIMP_IS_VIEW_RENDERER_FONT(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GIMP_TYPE_VIEW_RENDERER_FONT))
|
||||
#define GIMP_IS_VIEW_RENDERER_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_VIEW_RENDERER_FONT))
|
||||
#define GIMP_VIEW_RENDERER_FONT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_VIEW_RENDERER_FONT, GimpViewRendererFontClass))
|
||||
|
||||
|
||||
typedef struct _GimpViewRendererFontClass GimpViewRendererFontClass;
|
||||
|
||||
struct _GimpViewRendererFont
|
||||
{
|
||||
GimpViewRenderer parent_instance;
|
||||
};
|
||||
|
||||
struct _GimpViewRendererFontClass
|
||||
{
|
||||
GimpViewRendererClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_view_renderer_font_get_type (void) G_GNUC_CONST;
|
||||
|
|
@ -55,9 +55,12 @@ gimp_view_renderer_gradient_class_init (GimpViewRendererGradientClass *klass)
|
|||
{
|
||||
GimpViewRendererClass *renderer_class = GIMP_VIEW_RENDERER_CLASS (klass);
|
||||
|
||||
renderer_class->set_context = gimp_view_renderer_gradient_set_context;
|
||||
renderer_class->invalidate = gimp_view_renderer_gradient_invalidate;
|
||||
renderer_class->render = gimp_view_renderer_gradient_render;
|
||||
renderer_class->default_bg = GIMP_VIEW_BG_CHECKS;
|
||||
renderer_class->follow_theme_bg = GIMP_VIEW_BG_CHECKS;
|
||||
|
||||
renderer_class->set_context = gimp_view_renderer_gradient_set_context;
|
||||
renderer_class->invalidate = gimp_view_renderer_gradient_invalidate;
|
||||
renderer_class->render = gimp_view_renderer_gradient_render;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ gimp_view_renderer_image_render (GimpViewRenderer *renderer,
|
|||
|
||||
temp_buf = gimp_viewable_get_new_preview (renderer->viewable,
|
||||
renderer->context,
|
||||
width, height, NULL, NULL);
|
||||
width, height, NULL);
|
||||
|
||||
if (temp_buf)
|
||||
{
|
||||
|
|
@ -132,7 +132,7 @@ gimp_view_renderer_image_render (GimpViewRenderer *renderer,
|
|||
render_buf = gimp_viewable_get_new_preview (renderer->viewable,
|
||||
renderer->context,
|
||||
view_width,
|
||||
view_height, NULL, NULL);
|
||||
view_height, NULL);
|
||||
}
|
||||
|
||||
if (render_buf)
|
||||
|
|
|
|||
|
|
@ -20,13 +20,10 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
|
@ -57,9 +54,12 @@ gimp_view_renderer_palette_class_init (GimpViewRendererPaletteClass *klass)
|
|||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpViewRendererClass *renderer_class = GIMP_VIEW_RENDERER_CLASS (klass);
|
||||
|
||||
object_class->finalize = gimp_view_renderer_palette_finalize;
|
||||
object_class->finalize = gimp_view_renderer_palette_finalize;
|
||||
|
||||
renderer_class->render = gimp_view_renderer_palette_render;
|
||||
renderer_class->default_bg = GIMP_VIEW_BG_USE_STYLE;
|
||||
renderer_class->follow_theme_bg = GIMP_VIEW_BG_USE_STYLE;
|
||||
|
||||
renderer_class->render = gimp_view_renderer_palette_render;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -83,9 +83,6 @@ gimp_view_renderer_palette_render (GimpViewRenderer *renderer,
|
|||
GimpViewRendererPalette *renderpal = GIMP_VIEW_RENDERER_PALETTE (renderer);
|
||||
GimpPalette *palette;
|
||||
GimpColorTransform *transform;
|
||||
GtkStyleContext *style;
|
||||
GdkRGBA *bg_color = NULL;
|
||||
guchar bg_rgb[3];
|
||||
guchar *row;
|
||||
guchar *dest;
|
||||
GList *list;
|
||||
|
|
@ -99,25 +96,6 @@ gimp_view_renderer_palette_render (GimpViewRenderer *renderer,
|
|||
if (gimp_palette_get_n_colors (palette) == 0)
|
||||
return;
|
||||
|
||||
/* Get background colors from context */
|
||||
style = gtk_widget_get_style_context (widget);
|
||||
gtk_style_context_get (style, gtk_style_context_get_state (style),
|
||||
GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &bg_color,
|
||||
NULL);
|
||||
|
||||
if (bg_color)
|
||||
{
|
||||
bg_rgb[0] = (gint) (bg_color->red * 255);
|
||||
bg_rgb[1] = (gint) (bg_color->green * 255);
|
||||
bg_rgb[2] = (gint) (bg_color->blue * 255);
|
||||
|
||||
gdk_rgba_free (bg_color);
|
||||
}
|
||||
else
|
||||
{
|
||||
bg_rgb[0] = bg_rgb[1] = bg_rgb[2] = 255;
|
||||
}
|
||||
|
||||
grid_width = renderpal->draw_grid ? 1 : 0;
|
||||
|
||||
if (renderpal->cell_size > 0)
|
||||
|
|
@ -162,7 +140,7 @@ gimp_view_renderer_palette_render (GimpViewRenderer *renderer,
|
|||
list = gimp_palette_get_colors (palette);
|
||||
|
||||
if (! renderer->surface)
|
||||
renderer->surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
|
||||
renderer->surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
||||
renderer->width,
|
||||
renderer->height);
|
||||
|
||||
|
|
@ -183,12 +161,13 @@ gimp_view_renderer_palette_render (GimpViewRenderer *renderer,
|
|||
|
||||
if ((y % renderpal->cell_height) == 0)
|
||||
{
|
||||
guchar rgb[3];
|
||||
gint n = 0;
|
||||
guchar *d = row;
|
||||
|
||||
for (x = 0; x < renderer->width; x++, d += 4)
|
||||
{
|
||||
guchar rgba[4];
|
||||
|
||||
if ((x % renderpal->cell_width) == 0)
|
||||
{
|
||||
if (list && n < renderpal->columns &&
|
||||
|
|
@ -200,45 +179,45 @@ gimp_view_renderer_palette_render (GimpViewRenderer *renderer,
|
|||
n++;
|
||||
|
||||
/* TODO: render directly to widget color space! */
|
||||
gegl_color_get_pixel (entry->color, babl_format ("R'G'B' u8"), rgb);
|
||||
gegl_color_get_pixel (entry->color,
|
||||
babl_format ("R'G'B'A u8"), rgba);
|
||||
}
|
||||
else
|
||||
{
|
||||
gint i;
|
||||
|
||||
/* Background color (not entries, not grids) */
|
||||
for (gint i = 0; i < 3; i++)
|
||||
rgb[i] = bg_rgb[i];
|
||||
for (i = 0; i < 4; i++)
|
||||
rgba[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (renderpal->draw_grid && (x % renderpal->cell_width) == 0)
|
||||
{
|
||||
/* Vertical grid lines */
|
||||
GIMP_CAIRO_RGB24_SET_PIXEL (d, bg_rgb[0], bg_rgb[1], bg_rgb[2]);
|
||||
GIMP_CAIRO_ARGB32_SET_PIXEL (d, 0, 0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Palette entry */
|
||||
GIMP_CAIRO_RGB24_SET_PIXEL (d, rgb[0], rgb[1], rgb[2]);
|
||||
GIMP_CAIRO_ARGB32_SET_PIXEL (d, rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (renderpal->draw_grid && (y % renderpal->cell_height) == 0)
|
||||
{
|
||||
guchar *d = dest;
|
||||
|
||||
/* Horizontal grid lines */
|
||||
for (x = 0; x < renderer->width; x++, d += 4)
|
||||
GIMP_CAIRO_RGB24_SET_PIXEL (d, bg_rgb[0], bg_rgb[1], bg_rgb[2]);
|
||||
memset (dest, 0, renderer->width * 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (transform)
|
||||
{
|
||||
gimp_color_transform_process_pixels (transform,
|
||||
babl_format ("cairo-RGB24"),
|
||||
babl_format ("cairo-ARGB32"),
|
||||
row,
|
||||
babl_format ("cairo-RGB24"),
|
||||
babl_format ("cairo-ARGB32"),
|
||||
dest,
|
||||
renderer->width);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -866,36 +866,36 @@ gimp_get_monitor_resolution (GdkMonitor *monitor,
|
|||
*yres = ROUND (y);
|
||||
}
|
||||
|
||||
gboolean
|
||||
GeglColor *
|
||||
gimp_get_style_color (GtkWidget *widget,
|
||||
const gchar *property_name,
|
||||
GdkRGBA *color)
|
||||
const gchar *color_name)
|
||||
{
|
||||
GdkRGBA *c = NULL;
|
||||
GtkStyleContext *style;
|
||||
GdkRGBA *gdk_rgba = NULL;
|
||||
GeglColor *color = NULL;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
|
||||
g_return_val_if_fail (property_name != NULL, FALSE);
|
||||
g_return_val_if_fail (color != NULL, FALSE);
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
g_return_val_if_fail (color_name != NULL, NULL);
|
||||
|
||||
gtk_widget_style_get (widget,
|
||||
property_name, &c,
|
||||
NULL);
|
||||
style = gtk_widget_get_style_context (widget);
|
||||
gtk_style_context_get (style, gtk_style_context_get_state (style),
|
||||
color_name, &gdk_rgba,
|
||||
NULL);
|
||||
|
||||
if (c)
|
||||
if (gdk_rgba)
|
||||
{
|
||||
*color = *c;
|
||||
gdk_rgba_free (c);
|
||||
color = gegl_color_new (NULL);
|
||||
gegl_color_set_rgba_with_space (color,
|
||||
gdk_rgba->red,
|
||||
gdk_rgba->green,
|
||||
gdk_rgba->blue,
|
||||
1.0,
|
||||
NULL);
|
||||
|
||||
return TRUE;
|
||||
gdk_rgba_free (gdk_rgba);
|
||||
}
|
||||
|
||||
/* return ugly magenta to indicate that something is wrong */
|
||||
color->red = 1.0;
|
||||
color->green = 1.0;
|
||||
color->blue = 0.0;
|
||||
color->alpha = 1.0;
|
||||
|
||||
return FALSE;
|
||||
return color;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -66,9 +66,8 @@ GdkModifierType gimp_get_all_modifiers_mask (void);
|
|||
void gimp_get_monitor_resolution (GdkMonitor *monitor,
|
||||
gdouble *xres,
|
||||
gdouble *yres);
|
||||
gboolean gimp_get_style_color (GtkWidget *widget,
|
||||
const gchar *property_name,
|
||||
GdkRGBA *color);
|
||||
GeglColor * gimp_get_style_color (GtkWidget *widget,
|
||||
const gchar *color_name);
|
||||
void gimp_window_set_hint (GtkWindow *window,
|
||||
GimpWindowHint hint);
|
||||
void gimp_window_set_transient_for (GtkWindow *window,
|
||||
|
|
|
|||
|
|
@ -254,6 +254,7 @@ libappwidgets_sources = [
|
|||
'gimpviewrendererbrush.c',
|
||||
'gimpviewrendererbuffer.c',
|
||||
'gimpviewrendererdrawable.c',
|
||||
'gimpviewrendererfont.c',
|
||||
'gimpviewrenderergradient.c',
|
||||
'gimpviewrendererimage.c',
|
||||
'gimpviewrendererimagefile.c',
|
||||
|
|
|
|||
|
|
@ -261,6 +261,7 @@ typedef struct _GimpViewRenderer GimpViewRenderer;
|
|||
typedef struct _GimpViewRendererBrush GimpViewRendererBrush;
|
||||
typedef struct _GimpViewRendererBuffer GimpViewRendererBuffer;
|
||||
typedef struct _GimpViewRendererDrawable GimpViewRendererDrawable;
|
||||
typedef struct _GimpViewRendererFont GimpViewRendererFont;
|
||||
typedef struct _GimpViewRendererGradient GimpViewRendererGradient;
|
||||
typedef struct _GimpViewRendererImage GimpViewRendererImage;
|
||||
typedef struct _GimpViewRendererImagefile GimpViewRendererImagefile;
|
||||
|
|
|
|||
|
|
@ -983,7 +983,7 @@ HELP
|
|||
|
||||
if (image->gimp->config->layer_previews)
|
||||
buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (drawable), context,
|
||||
width, height, NULL, NULL);
|
||||
width, height, NULL);
|
||||
else
|
||||
buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
|
||||
width, height,
|
||||
|
|
|
|||
|
|
@ -3154,7 +3154,7 @@ HELP
|
|||
gimp_pickable_flush (GIMP_PICKABLE (image));
|
||||
|
||||
buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (image), context,
|
||||
width, height, NULL, NULL);
|
||||
width, height, NULL);
|
||||
|
||||
if (buf)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue