app: add a "highlight" mode for the tool FG style
such a hack, but looks better than dashed lines
This commit is contained in:
@ -36,7 +36,7 @@ typedef struct _GimpCanvasItemPrivate GimpCanvasItemPrivate;
|
|||||||
|
|
||||||
struct _GimpCanvasItemPrivate
|
struct _GimpCanvasItemPrivate
|
||||||
{
|
{
|
||||||
gint unused; /* gobject doesn't like empty private structs */
|
gboolean highlight;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GET_PRIVATE(item) \
|
#define GET_PRIVATE(item) \
|
||||||
@ -118,6 +118,17 @@ 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_highlight (GimpCanvasItem *item,
|
||||||
|
gboolean highlight)
|
||||||
|
{
|
||||||
|
GimpCanvasItemPrivate *private = GET_PRIVATE (item);
|
||||||
|
|
||||||
|
g_return_if_fail (GIMP_IS_CANVAS_ITEM (item));
|
||||||
|
|
||||||
|
private->highlight = highlight ? TRUE : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* protexted functions */
|
/* protexted functions */
|
||||||
|
|
||||||
@ -126,10 +137,12 @@ _gimp_canvas_item_stroke (GimpCanvasItem *item,
|
|||||||
GimpDisplayShell *shell,
|
GimpDisplayShell *shell,
|
||||||
cairo_t *cr)
|
cairo_t *cr)
|
||||||
{
|
{
|
||||||
|
GimpCanvasItemPrivate *private = GET_PRIVATE (item);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
gimp_display_shell_set_tool_fg_style (shell, cr);
|
gimp_display_shell_set_tool_fg_style (shell, cr, private->highlight);
|
||||||
cairo_stroke (cr);
|
cairo_stroke (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,10 +151,12 @@ _gimp_canvas_item_fill (GimpCanvasItem *item,
|
|||||||
GimpDisplayShell *shell,
|
GimpDisplayShell *shell,
|
||||||
cairo_t *cr)
|
cairo_t *cr)
|
||||||
{
|
{
|
||||||
|
GimpCanvasItemPrivate *private = GET_PRIVATE (item);
|
||||||
|
|
||||||
gimp_display_shell_set_tool_bg_style (shell, cr);
|
gimp_display_shell_set_tool_bg_style (shell, cr);
|
||||||
cairo_set_line_width (cr, 2.0);
|
cairo_set_line_width (cr, 2.0);
|
||||||
cairo_stroke_preserve (cr);
|
cairo_stroke_preserve (cr);
|
||||||
|
|
||||||
gimp_display_shell_set_tool_fg_style (shell, cr);
|
gimp_display_shell_set_tool_fg_style (shell, cr, private->highlight);
|
||||||
cairo_fill (cr);
|
cairo_fill (cr);
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,9 @@ 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_highlight(GimpCanvasItem *item,
|
||||||
|
gboolean highlight);
|
||||||
|
|
||||||
|
|
||||||
/* protected */
|
/* protected */
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ static const GimpRGB vectors_active_fg = { 1.0, 0.0, 0.0, 0.8 };
|
|||||||
|
|
||||||
static const GimpRGB tool_bg = { 1.0, 1.0, 1.0, 0.6 };
|
static const GimpRGB tool_bg = { 1.0, 1.0, 1.0, 0.6 };
|
||||||
static const GimpRGB tool_fg = { 0.0, 0.0, 0.0, 0.8 };
|
static const GimpRGB tool_fg = { 0.0, 0.0, 0.0, 0.8 };
|
||||||
|
static const GimpRGB tool_fg_highlight = { 0.0, 1.0, 1.0, 0.8 };
|
||||||
|
|
||||||
|
|
||||||
/* public functions */
|
/* public functions */
|
||||||
@ -337,7 +338,8 @@ gimp_display_shell_set_tool_bg_style (GimpDisplayShell *shell,
|
|||||||
|
|
||||||
void
|
void
|
||||||
gimp_display_shell_set_tool_fg_style (GimpDisplayShell *shell,
|
gimp_display_shell_set_tool_fg_style (GimpDisplayShell *shell,
|
||||||
cairo_t *cr)
|
cairo_t *cr,
|
||||||
|
gboolean highlight)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||||
g_return_if_fail (cr != NULL);
|
g_return_if_fail (cr != NULL);
|
||||||
@ -346,5 +348,8 @@ gimp_display_shell_set_tool_fg_style (GimpDisplayShell *shell,
|
|||||||
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
|
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)
|
||||||
|
gimp_cairo_set_source_rgba (cr, &tool_fg_highlight);
|
||||||
|
else
|
||||||
gimp_cairo_set_source_rgba (cr, &tool_fg);
|
gimp_cairo_set_source_rgba (cr, &tool_fg);
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,8 @@ void gimp_display_shell_set_vectors_fg_style (GimpDisplayShell *shell,
|
|||||||
void gimp_display_shell_set_tool_bg_style (GimpDisplayShell *shell,
|
void gimp_display_shell_set_tool_bg_style (GimpDisplayShell *shell,
|
||||||
cairo_t *cr);
|
cairo_t *cr);
|
||||||
void gimp_display_shell_set_tool_fg_style (GimpDisplayShell *shell,
|
void gimp_display_shell_set_tool_fg_style (GimpDisplayShell *shell,
|
||||||
cairo_t *cr);
|
cairo_t *cr,
|
||||||
|
gboolean highlight);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_DISPLAY_SHELL_STYLE_H__ */
|
#endif /* __GIMP_DISPLAY_SHELL_STYLE_H__ */
|
||||||
|
Reference in New Issue
Block a user