app: move the wilber drawing functions to gimpcairo.c
This commit is contained in:
@ -27,7 +27,6 @@
|
|||||||
|
|
||||||
#include "config/gimpdisplayconfig.h"
|
#include "config/gimpdisplayconfig.h"
|
||||||
|
|
||||||
#include "widgets/gimpcairo-wilber.h"
|
|
||||||
#include "widgets/gimpwidgets-utils.h"
|
#include "widgets/gimpwidgets-utils.h"
|
||||||
|
|
||||||
#include "gimpcanvas.h"
|
#include "gimpcanvas.h"
|
||||||
@ -551,52 +550,6 @@ gimp_canvas_get_layout (GimpCanvas *canvas,
|
|||||||
return canvas->layout;
|
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:
|
* gimp_canvas_set_clip_rect:
|
||||||
* @canvas: a #GimpCanvas widget
|
* @canvas: a #GimpCanvas widget
|
||||||
|
@ -115,8 +115,6 @@ void gimp_canvas_draw_segments (GimpCanvas *canvas,
|
|||||||
PangoLayout *gimp_canvas_get_layout (GimpCanvas *canvas,
|
PangoLayout *gimp_canvas_get_layout (GimpCanvas *canvas,
|
||||||
const gchar *format,
|
const gchar *format,
|
||||||
...) G_GNUC_PRINTF (2, 3);
|
...) G_GNUC_PRINTF (2, 3);
|
||||||
void gimp_canvas_draw_drop_zone (GimpCanvas *canvas,
|
|
||||||
cairo_t *cr);
|
|
||||||
|
|
||||||
void gimp_canvas_set_clip_rect (GimpCanvas *canvas,
|
void gimp_canvas_set_clip_rect (GimpCanvas *canvas,
|
||||||
GimpCanvasStyle style,
|
GimpCanvasStyle style,
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
#include "tools/tool_manager.h"
|
#include "tools/tool_manager.h"
|
||||||
#include "tools/tools-enums.h"
|
#include "tools/tools-enums.h"
|
||||||
|
|
||||||
|
#include "widgets/gimpcairo.h"
|
||||||
#include "widgets/gimpcontrollers.h"
|
#include "widgets/gimpcontrollers.h"
|
||||||
#include "widgets/gimpcontrollerkeyboard.h"
|
#include "widgets/gimpcontrollerkeyboard.h"
|
||||||
#include "widgets/gimpcontrollerwheel.h"
|
#include "widgets/gimpcontrollerwheel.h"
|
||||||
@ -2352,5 +2353,5 @@ gimp_display_shell_canvas_expose_drop_zone (GimpDisplayShell *shell,
|
|||||||
|
|
||||||
g_free (rects);
|
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 "widgets-types.h"
|
||||||
|
|
||||||
#include "gimpcairo.h"
|
#include "gimpcairo.h"
|
||||||
|
#include "gimpcairo-wilber.h"
|
||||||
|
|
||||||
|
|
||||||
static cairo_user_data_key_t surface_data_key = { 0, };
|
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,
|
GdkSegment *segs,
|
||||||
gint n_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__ */
|
#endif /* __GIMP_CAIRO_H__ */
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include "file/file-open.h"
|
#include "file/file-open.h"
|
||||||
#include "file/file-utils.h"
|
#include "file/file-utils.h"
|
||||||
|
|
||||||
#include "gimpcairo-wilber.h"
|
#include "gimpcairo.h"
|
||||||
#include "gimpdevices.h"
|
#include "gimpdevices.h"
|
||||||
#include "gimpdialogfactory.h"
|
#include "gimpdialogfactory.h"
|
||||||
#include "gimpdockwindow.h"
|
#include "gimpdockwindow.h"
|
||||||
@ -674,38 +674,13 @@ gimp_toolbox_expose_event (GtkWidget *widget,
|
|||||||
&header_allocation,
|
&header_allocation,
|
||||||
&clip_rect))
|
&clip_rect))
|
||||||
{
|
{
|
||||||
GtkStyle *style = gtk_widget_get_style (widget);
|
|
||||||
GtkStateType state = gtk_widget_get_state (widget);
|
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
gint header_height;
|
|
||||||
gint header_width;
|
|
||||||
gdouble wilber_width;
|
|
||||||
gdouble wilber_height;
|
|
||||||
gdouble factor;
|
|
||||||
|
|
||||||
cr = gdk_cairo_create (gtk_widget_get_window (widget));
|
cr = gdk_cairo_create (gtk_widget_get_window (widget));
|
||||||
gdk_cairo_rectangle (cr, &clip_rect);
|
gdk_cairo_rectangle (cr, &clip_rect);
|
||||||
cairo_clip (cr);
|
cairo_clip (cr);
|
||||||
|
|
||||||
header_width = header_allocation.width;
|
gimp_cairo_draw_toolbox_wilber (toolbox->p->header, cr);
|
||||||
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);
|
|
||||||
|
|
||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user