mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-22 04:22:29 +00:00
app: move the wilber drawing functions to gimpcairo.c
This commit is contained in:
parent
6130f6b0bb
commit
02abdff8aa
|
@ -27,7 +27,6 @@
|
|||
|
||||
#include "config/gimpdisplayconfig.h"
|
||||
|
||||
#include "widgets/gimpcairo-wilber.h"
|
||||
#include "widgets/gimpwidgets-utils.h"
|
||||
|
||||
#include "gimpcanvas.h"
|
||||
|
@ -551,52 +550,6 @@ gimp_canvas_get_layout (GimpCanvas *canvas,
|
|||
return canvas->layout;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_canvas_draw_drop_zone (GimpCanvas *canvas,
|
||||
cairo_t *cr)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (canvas);
|
||||
GtkStyle *style = gtk_widget_get_style (widget);
|
||||
GtkStateType state = gtk_widget_get_state (widget);
|
||||
GtkAllocation allocation;
|
||||
gdouble wilber_width;
|
||||
gdouble wilber_height;
|
||||
gdouble width;
|
||||
gdouble height;
|
||||
gdouble side;
|
||||
gdouble factor;
|
||||
|
||||
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);
|
||||
|
||||
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_canvas_set_clip_rect:
|
||||
* @canvas: a #GimpCanvas widget
|
||||
|
|
|
@ -115,8 +115,6 @@ void gimp_canvas_draw_segments (GimpCanvas *canvas,
|
|||
PangoLayout *gimp_canvas_get_layout (GimpCanvas *canvas,
|
||||
const gchar *format,
|
||||
...) G_GNUC_PRINTF (2, 3);
|
||||
void gimp_canvas_draw_drop_zone (GimpCanvas *canvas,
|
||||
cairo_t *cr);
|
||||
|
||||
void gimp_canvas_set_clip_rect (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "tools/tool_manager.h"
|
||||
#include "tools/tools-enums.h"
|
||||
|
||||
#include "widgets/gimpcairo.h"
|
||||
#include "widgets/gimpcontrollers.h"
|
||||
#include "widgets/gimpcontrollerkeyboard.h"
|
||||
#include "widgets/gimpcontrollerwheel.h"
|
||||
|
@ -2352,5 +2353,5 @@ gimp_display_shell_canvas_expose_drop_zone (GimpDisplayShell *shell,
|
|||
|
||||
g_free (rects);
|
||||
|
||||
gimp_canvas_draw_drop_zone (GIMP_CANVAS (shell->canvas), cr);
|
||||
gimp_cairo_draw_drop_wilber (shell->canvas, cr);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "widgets-types.h"
|
||||
|
||||
#include "gimpcairo.h"
|
||||
#include "gimpcairo-wilber.h"
|
||||
|
||||
|
||||
static cairo_user_data_key_t surface_data_key = { 0, };
|
||||
|
@ -110,3 +111,91 @@ 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;
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -33,5 +33,10 @@ void gimp_cairo_add_segments (cairo_t *cr,
|
|||
GdkSegment *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__ */
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "file/file-open.h"
|
||||
#include "file/file-utils.h"
|
||||
|
||||
#include "gimpcairo-wilber.h"
|
||||
#include "gimpcairo.h"
|
||||
#include "gimpdevices.h"
|
||||
#include "gimpdialogfactory.h"
|
||||
#include "gimpdockwindow.h"
|
||||
|
@ -674,38 +674,13 @@ gimp_toolbox_expose_event (GtkWidget *widget,
|
|||
&header_allocation,
|
||||
&clip_rect))
|
||||
{
|
||||
GtkStyle *style = gtk_widget_get_style (widget);
|
||||
GtkStateType state = gtk_widget_get_state (widget);
|
||||
cairo_t *cr;
|
||||
gint header_height;
|
||||
gint header_width;
|
||||
gdouble wilber_width;
|
||||
gdouble wilber_height;
|
||||
gdouble factor;
|
||||
cairo_t *cr;
|
||||
|
||||
cr = gdk_cairo_create (gtk_widget_get_window (widget));
|
||||
gdk_cairo_rectangle (cr, &clip_rect);
|
||||
cairo_clip (cr);
|
||||
|
||||
header_width = header_allocation.width;
|
||||
header_height = header_allocation.height;
|
||||
|
||||
gimp_cairo_wilber_get_size (cr, &wilber_width, &wilber_height);
|
||||
|
||||
factor = header_width / wilber_width * 0.9;
|
||||
|
||||
cairo_scale (cr, factor, factor);
|
||||
|
||||
gimp_cairo_wilber (cr,
|
||||
(header_width / factor - wilber_width) / 2.0,
|
||||
(header_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);
|
||||
gimp_cairo_draw_toolbox_wilber (toolbox->p->header, cr);
|
||||
|
||||
cairo_destroy (cr);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue