app: change the default item line cap to round
but add and API to configure it and set it to suare for handles which are always axis-aligned.
This commit is contained in:
@ -156,6 +156,9 @@ gimp_canvas_handle_init (GimpCanvasHandle *handle)
|
|||||||
{
|
{
|
||||||
GimpCanvasHandlePrivate *private = GET_PRIVATE (handle);
|
GimpCanvasHandlePrivate *private = GET_PRIVATE (handle);
|
||||||
|
|
||||||
|
gimp_canvas_item_set_line_cap (GIMP_CANVAS_ITEM (handle),
|
||||||
|
CAIRO_LINE_CAP_SQUARE);
|
||||||
|
|
||||||
private->start_angle = 0.0;
|
private->start_angle = 0.0;
|
||||||
private->slice_angle = 2.0 * G_PI;
|
private->slice_angle = 2.0 * G_PI;
|
||||||
}
|
}
|
||||||
|
@ -32,10 +32,19 @@
|
|||||||
#include "gimpdisplayshell-style.h"
|
#include "gimpdisplayshell-style.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_LINE_CAP,
|
||||||
|
PROP_HIGHLIGHT
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef struct _GimpCanvasItemPrivate GimpCanvasItemPrivate;
|
typedef struct _GimpCanvasItemPrivate GimpCanvasItemPrivate;
|
||||||
|
|
||||||
struct _GimpCanvasItemPrivate
|
struct _GimpCanvasItemPrivate
|
||||||
{
|
{
|
||||||
|
cairo_line_cap_t line_cap;
|
||||||
gboolean highlight;
|
gboolean highlight;
|
||||||
gint suspend_stroking;
|
gint suspend_stroking;
|
||||||
};
|
};
|
||||||
@ -48,6 +57,15 @@ struct _GimpCanvasItemPrivate
|
|||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
|
|
||||||
|
static void gimp_canvas_item_set_property (GObject *object,
|
||||||
|
guint property_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec);
|
||||||
|
static void gimp_canvas_item_get_property (GObject *object,
|
||||||
|
guint property_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec);
|
||||||
|
|
||||||
static void gimp_canvas_item_real_draw (GimpCanvasItem *item,
|
static void gimp_canvas_item_real_draw (GimpCanvasItem *item,
|
||||||
GimpDisplayShell *shell,
|
GimpDisplayShell *shell,
|
||||||
cairo_t *cr);
|
cairo_t *cr);
|
||||||
@ -64,15 +82,85 @@ G_DEFINE_TYPE (GimpCanvasItem, gimp_canvas_item,
|
|||||||
static void
|
static void
|
||||||
gimp_canvas_item_class_init (GimpCanvasItemClass *klass)
|
gimp_canvas_item_class_init (GimpCanvasItemClass *klass)
|
||||||
{
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->set_property = gimp_canvas_item_set_property;
|
||||||
|
object_class->get_property = gimp_canvas_item_get_property;
|
||||||
|
|
||||||
klass->draw = gimp_canvas_item_real_draw;
|
klass->draw = gimp_canvas_item_real_draw;
|
||||||
klass->get_extents = gimp_canvas_item_real_get_extents;
|
klass->get_extents = gimp_canvas_item_real_get_extents;
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class, PROP_LINE_CAP,
|
||||||
|
g_param_spec_int ("line-cap",
|
||||||
|
NULL, NULL,
|
||||||
|
CAIRO_LINE_CAP_BUTT,
|
||||||
|
CAIRO_LINE_CAP_SQUARE,
|
||||||
|
CAIRO_LINE_CAP_ROUND,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class, PROP_HIGHLIGHT,
|
||||||
|
g_param_spec_boolean ("highlight",
|
||||||
|
NULL, NULL,
|
||||||
|
FALSE,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (GimpCanvasItemPrivate));
|
g_type_class_add_private (klass, sizeof (GimpCanvasItemPrivate));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_canvas_item_init (GimpCanvasItem *item)
|
gimp_canvas_item_init (GimpCanvasItem *item)
|
||||||
{
|
{
|
||||||
|
GimpCanvasItemPrivate *private = GET_PRIVATE (item);
|
||||||
|
|
||||||
|
private->line_cap = CAIRO_LINE_CAP_ROUND;
|
||||||
|
private->highlight = FALSE;
|
||||||
|
private->suspend_stroking = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_canvas_item_set_property (GObject *object,
|
||||||
|
guint property_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GimpCanvasItemPrivate *private = GET_PRIVATE (object);
|
||||||
|
|
||||||
|
switch (property_id)
|
||||||
|
{
|
||||||
|
case PROP_LINE_CAP:
|
||||||
|
private->line_cap = g_value_get_int (value);
|
||||||
|
break;
|
||||||
|
case PROP_HIGHLIGHT:
|
||||||
|
private->highlight = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_canvas_item_get_property (GObject *object,
|
||||||
|
guint property_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GimpCanvasItemPrivate *private = GET_PRIVATE (object);
|
||||||
|
|
||||||
|
switch (property_id)
|
||||||
|
{
|
||||||
|
case PROP_LINE_CAP:
|
||||||
|
g_value_set_int (value, private->line_cap);
|
||||||
|
break;
|
||||||
|
case PROP_HIGHLIGHT:
|
||||||
|
g_value_set_boolean (value, private->highlight);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -119,17 +207,26 @@ gimp_canvas_item_get_extents (GimpCanvasItem *item,
|
|||||||
return GIMP_CANVAS_ITEM_GET_CLASS (item)->get_extents (item, shell);
|
return GIMP_CANVAS_ITEM_GET_CLASS (item)->get_extents (item, shell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_canvas_item_set_line_cap (GimpCanvasItem *item,
|
||||||
|
cairo_line_cap_t line_cap)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GIMP_IS_CANVAS_ITEM (item));
|
||||||
|
|
||||||
|
g_object_set (item,
|
||||||
|
"line-cap", line_cap,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_canvas_item_set_highlight (GimpCanvasItem *item,
|
gimp_canvas_item_set_highlight (GimpCanvasItem *item,
|
||||||
gboolean highlight)
|
gboolean highlight)
|
||||||
{
|
{
|
||||||
GimpCanvasItemPrivate *private;
|
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_CANVAS_ITEM (item));
|
g_return_if_fail (GIMP_IS_CANVAS_ITEM (item));
|
||||||
|
|
||||||
private = GET_PRIVATE (item);
|
g_object_set (item,
|
||||||
|
"highlight", highlight,
|
||||||
private->highlight = highlight ? TRUE : FALSE;
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -170,6 +267,8 @@ _gimp_canvas_item_stroke (GimpCanvasItem *item,
|
|||||||
|
|
||||||
if (private->suspend_stroking == 0)
|
if (private->suspend_stroking == 0)
|
||||||
{
|
{
|
||||||
|
cairo_set_line_cap (cr, private->line_cap);
|
||||||
|
|
||||||
gimp_display_shell_set_tool_bg_style (shell, cr);
|
gimp_display_shell_set_tool_bg_style (shell, cr);
|
||||||
cairo_stroke_preserve (cr);
|
cairo_stroke_preserve (cr);
|
||||||
|
|
||||||
|
@ -60,6 +60,8 @@ void gimp_canvas_item_draw (GimpCanvasItem *item,
|
|||||||
GdkRegion * gimp_canvas_item_get_extents (GimpCanvasItem *item,
|
GdkRegion * gimp_canvas_item_get_extents (GimpCanvasItem *item,
|
||||||
GimpDisplayShell *shell);
|
GimpDisplayShell *shell);
|
||||||
|
|
||||||
|
void gimp_canvas_item_set_line_cap (GimpCanvasItem *item,
|
||||||
|
cairo_line_cap_t line_cap);
|
||||||
void gimp_canvas_item_set_highlight (GimpCanvasItem *item,
|
void gimp_canvas_item_set_highlight (GimpCanvasItem *item,
|
||||||
gboolean highlight);
|
gboolean highlight);
|
||||||
|
|
||||||
|
@ -330,7 +330,6 @@ gimp_display_shell_set_tool_bg_style (GimpDisplayShell *shell,
|
|||||||
g_return_if_fail (cr != NULL);
|
g_return_if_fail (cr != NULL);
|
||||||
|
|
||||||
cairo_set_line_width (cr, 3.0);
|
cairo_set_line_width (cr, 3.0);
|
||||||
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
|
|
||||||
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
|
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
|
||||||
|
|
||||||
gimp_cairo_set_source_rgba (cr, &tool_bg);
|
gimp_cairo_set_source_rgba (cr, &tool_bg);
|
||||||
@ -345,7 +344,6 @@ gimp_display_shell_set_tool_fg_style (GimpDisplayShell *shell,
|
|||||||
g_return_if_fail (cr != NULL);
|
g_return_if_fail (cr != NULL);
|
||||||
|
|
||||||
cairo_set_line_width (cr, 1.0);
|
cairo_set_line_width (cr, 1.0);
|
||||||
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
|
|
||||||
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
|
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
|
||||||
|
|
||||||
if (highlight)
|
if (highlight)
|
||||||
|
Reference in New Issue
Block a user