Commit 53cf2c65 authored by Michael Natterer's avatar Michael Natterer 😴

app: move the GTK-free cairo utility functions to core/gimp-cairo.[ch]

parent 25030ce6
......@@ -23,6 +23,8 @@ libappcore_a_sources = \
gimp.h \
gimp-apply-operation.c \
gimp-apply-operation.h \
gimp-cairo.c \
gimp-cairo.h \
gimp-contexts.c \
gimp-contexts.h \
gimp-edit.c \
......
......@@ -233,6 +233,18 @@ struct _GimpCoords
gdouble direction;
};
/* temp hack as replacement for GdkSegment */
typedef struct _GimpSegment GimpSegment;
struct _GimpSegment
{
gint x1;
gint y1;
gint x2;
gint y2;
};
#include "gegl/gimp-gegl-types.h"
#include "paint/paint-types.h"
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcairo.c
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
* gimp-cairo.c
* Copyright (C) 2010-2012 Michael Natterer <mitch@gimp.org>
*
* Some code here is based on code from librsvg that was originally
* written by Raph Levien <raph@artofcode.com> for Gill.
......@@ -23,16 +23,14 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "core-types.h"
#include "gimpcairo.h"
#include "gimpcairo-wilber.h"
#include "gimp-cairo.h"
static cairo_user_data_key_t surface_data_key = { 0, };
......@@ -136,97 +134,3 @@ gimp_cairo_add_segments (cairo_t *cr,
}
}
}
void
gimp_cairo_draw_toolbox_wilber (GtkWidget *widget,
cairo_t *cr)
{
GtkStyle *style;
GtkStateType state;
GtkAllocation allocation;
gdouble wilber_width;
gdouble wilber_height;
gdouble factor;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (cr != NULL);
style = gtk_widget_get_style (widget);
state = gtk_widget_get_state (widget);
gtk_widget_get_allocation (widget, &allocation);
gimp_cairo_wilber_get_size (cr, &wilber_width, &wilber_height);
factor = allocation.width / wilber_width * 0.9;
if (! gtk_widget_get_has_window (widget))
cairo_translate (cr, allocation.x, allocation.y);
cairo_scale (cr, factor, factor);
gimp_cairo_wilber (cr,
(allocation.width / factor - wilber_width) / 2.0,
(allocation.height / factor - wilber_height) / 2.0);
cairo_set_source_rgba (cr,
style->fg[state].red / 65535.0,
style->fg[state].green / 65535.0,
style->fg[state].blue / 65535.0,
0.10);
cairo_fill (cr);
}
void
gimp_cairo_draw_drop_wilber (GtkWidget *widget,
cairo_t *cr)
{
GtkStyle *style;
GtkStateType state;
GtkAllocation allocation;
gdouble wilber_width;
gdouble wilber_height;
gdouble width;
gdouble height;
gdouble side;
gdouble factor;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (cr != NULL);
style = gtk_widget_get_style (widget);
state = gtk_widget_get_state (widget);
gtk_widget_get_allocation (widget, &allocation);
gimp_cairo_wilber_get_size (cr, &wilber_width, &wilber_height);
wilber_width /= 2;
wilber_height /= 2;
side = MIN (MIN (allocation.width, allocation.height),
MAX (allocation.width, allocation.height) / 2);
width = MAX (wilber_width, side);
height = MAX (wilber_height, side);
factor = MIN (width / wilber_width, height / wilber_height);
if (! gtk_widget_get_has_window (widget))
cairo_translate (cr, allocation.x, allocation.y);
cairo_scale (cr, factor, factor);
/* magic factors depend on the image used, everything else is generic
*/
gimp_cairo_wilber (cr,
- wilber_width * 0.6,
allocation.height / factor - wilber_height * 1.1);
cairo_set_source_rgba (cr,
style->fg[state].red / 65535.0,
style->fg[state].green / 65535.0,
style->fg[state].blue / 65535.0,
0.15);
cairo_fill (cr);
}
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcairo.h
* Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
* gimp-cairo.h
* Copyright (C) 2010-2012 Michael Natterer <mitch@gimp.org>
*
* Some code here is based on code from librsvg that was originally
* written by Raph Levien <raph@artofcode.com> for Gill.
......@@ -39,10 +39,5 @@ void gimp_cairo_add_segments (cairo_t *cr,
GimpSegment *segs,
gint n_segs);
void gimp_cairo_draw_toolbox_wilber (GtkWidget *widget,
cairo_t *cr);
void gimp_cairo_draw_drop_wilber (GtkWidget *widget,
cairo_t *cr);
#endif /* __GIMP_CAIRO_H__ */
......@@ -28,7 +28,7 @@
#include "display-types.h"
#include "widgets/gimpcairo.h"
#include "core/gimp-cairo.h"
#include "gimpcanvasarc.h"
#include "gimpdisplayshell.h"
......
......@@ -28,11 +28,10 @@
#include "display-types.h"
#include "core/gimp-cairo.h"
#include "core/gimpboundary.h"
#include "core/gimpparamspecs.h"
#include "widgets/gimpcairo.h"
#include "gimpcanvasboundary.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-transform.h"
......
......@@ -28,7 +28,7 @@
#include "display-types.h"
#include "widgets/gimpcairo.h"
#include "core/gimp-cairo.h"
#include "gimpcanvascursor.h"
#include "gimpdisplayshell.h"
......
......@@ -28,7 +28,7 @@
#include "display-types.h"
#include "widgets/gimpcairo.h"
#include "core/gimp-cairo.h"
#include "gimpcanvashandle.h"
#include "gimpcanvasitem-utils.h"
......
......@@ -29,7 +29,7 @@
#include "core/gimpimage.h"
#include "core/gimpimage-quick-mask.h"
#include "widgets/gimpcairo.h"
#include "widgets/gimpcairo-wilber.h"
#include "widgets/gimpuimanager.h"
#include "gimpcanvasitem.h"
......
......@@ -27,13 +27,12 @@
#include "display-types.h"
#include "core/gimp-cairo.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimppickable.h"
#include "core/gimpprojection.h"
#include "widgets/gimpcairo.h"
#include "gimpcanvas.h"
#include "gimpcanvaspath.h"
#include "gimpdisplay.h"
......
......@@ -25,12 +25,11 @@
#include "config/gimpdisplayconfig.h"
#include "core/gimp.h"
#include "core/gimp-cairo.h"
#include "core/gimpboundary.h"
#include "core/gimpchannel.h"
#include "core/gimpimage.h"
#include "widgets/gimpcairo.h"
#include "gimpdisplay.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-appearance.h"
......
......@@ -28,11 +28,10 @@
#include "display-types.h"
#include "core/gimp-cairo.h"
#include "core/gimpgrid.h"
#include "core/gimplayer.h"
#include "widgets/gimpcairo.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-style.h"
......
......@@ -39,8 +39,6 @@ libappwidgets_a_sources = \
gimpbrushselect.h \
gimpbufferview.c \
gimpbufferview.h \
gimpcairo.c \
gimpcairo.h \
gimpcairo-wilber.c \
gimpcairo-wilber.h \
gimpcellrendererdashes.c \
......
......@@ -29,7 +29,104 @@
#include "libgimpmath/gimpmath.h"
#include <gimpcairo-wilber.h>
#include "widgets-types.h"
#include "gimpcairo-wilber.h"
void
gimp_cairo_draw_toolbox_wilber (GtkWidget *widget,
cairo_t *cr)
{
GtkStyle *style;
GtkStateType state;
GtkAllocation allocation;
gdouble wilber_width;
gdouble wilber_height;
gdouble factor;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (cr != NULL);
style = gtk_widget_get_style (widget);
state = gtk_widget_get_state (widget);
gtk_widget_get_allocation (widget, &allocation);
gimp_cairo_wilber_get_size (cr, &wilber_width, &wilber_height);
factor = allocation.width / wilber_width * 0.9;
if (! gtk_widget_get_has_window (widget))
cairo_translate (cr, allocation.x, allocation.y);
cairo_scale (cr, factor, factor);
gimp_cairo_wilber (cr,
(allocation.width / factor - wilber_width) / 2.0,
(allocation.height / factor - wilber_height) / 2.0);
cairo_set_source_rgba (cr,
style->fg[state].red / 65535.0,
style->fg[state].green / 65535.0,
style->fg[state].blue / 65535.0,
0.10);
cairo_fill (cr);
}
void
gimp_cairo_draw_drop_wilber (GtkWidget *widget,
cairo_t *cr)
{
GtkStyle *style;
GtkStateType state;
GtkAllocation allocation;
gdouble wilber_width;
gdouble wilber_height;
gdouble width;
gdouble height;
gdouble side;
gdouble factor;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (cr != NULL);
style = gtk_widget_get_style (widget);
state = gtk_widget_get_state (widget);
gtk_widget_get_allocation (widget, &allocation);
gimp_cairo_wilber_get_size (cr, &wilber_width, &wilber_height);
wilber_width /= 2;
wilber_height /= 2;
side = MIN (MIN (allocation.width, allocation.height),
MAX (allocation.width, allocation.height) / 2);
width = MAX (wilber_width, side);
height = MAX (wilber_height, side);
factor = MIN (width / wilber_width, height / wilber_height);
if (! gtk_widget_get_has_window (widget))
cairo_translate (cr, allocation.x, allocation.y);
cairo_scale (cr, factor, factor);
/* magic factors depend on the image used, everything else is generic
*/
gimp_cairo_wilber (cr,
- wilber_width * 0.6,
allocation.height / factor - wilber_height * 1.1);
cairo_set_source_rgba (cr,
style->fg[state].red / 65535.0,
style->fg[state].green / 65535.0,
style->fg[state].blue / 65535.0,
0.15);
cairo_fill (cr);
}
/* This string is a path description as found in SVG files. You can
......
......@@ -25,12 +25,17 @@
#define __GIMP_CAIRO_WILBER_H__
void gimp_cairo_wilber (cairo_t *cr,
gdouble x,
gdouble y);
void gimp_cairo_wilber_get_size (cairo_t *cr,
gdouble *width,
gdouble *height);
void gimp_cairo_draw_toolbox_wilber (GtkWidget *widget,
cairo_t *cr);
void gimp_cairo_draw_drop_wilber (GtkWidget *widget,
cairo_t *cr);
void gimp_cairo_wilber (cairo_t *cr,
gdouble x,
gdouble y);
void gimp_cairo_wilber_get_size (cairo_t *cr,
gdouble *width,
gdouble *height);
#endif /* __GIMP_CAIRO_WILBER_H__ */
......@@ -37,7 +37,7 @@
#include "file/file-open.h"
#include "file/file-utils.h"
#include "gimpcairo.h"
#include "gimpcairo-wilber.h"
#include "gimpdevices.h"
#include "gimpdialogfactory.h"
#include "gimpdockwindow.h"
......
......@@ -281,17 +281,4 @@ typedef gboolean (* GimpPanedBoxDroppedFunc) (GtkWidget *source,
gpointer data);
/* temp hack as replacement for GdkSegment */
typedef struct _GimpSegment GimpSegment;
struct _GimpSegment
{
gint x1;
gint y1;
gint x2;
gint y2;
};
#endif /* __WIDGETS_TYPES_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment