mirror of https://github.com/GNOME/gimp.git
Bug 663121 - guides are below rotate/transform/shear/perspective preview
Add a canvas item group for previews, and a small preview infrastructure to GimpDrawTool, and put the transform preview into the preview group, which is below all guides, grid and layer boundaries.
This commit is contained in:
parent
ffc9948d6e
commit
d38ded387d
|
@ -55,6 +55,10 @@ gimp_display_shell_items_init (GimpDisplayShell *shell)
|
|||
gimp_display_shell_add_item (shell, shell->passe_partout);
|
||||
g_object_unref (shell->passe_partout);
|
||||
|
||||
shell->preview_items = gimp_canvas_group_new (shell);
|
||||
gimp_display_shell_add_item (shell, shell->preview_items);
|
||||
g_object_unref (shell->preview_items);
|
||||
|
||||
shell->vectors = gimp_canvas_proxy_group_new (shell);
|
||||
gimp_display_shell_add_item (shell, shell->vectors);
|
||||
g_object_unref (shell->vectors);
|
||||
|
@ -107,11 +111,13 @@ gimp_display_shell_items_free (GimpDisplayShell *shell)
|
|||
shell->canvas_item = NULL;
|
||||
|
||||
shell->passe_partout = NULL;
|
||||
shell->preview_items = NULL;
|
||||
shell->vectors = NULL;
|
||||
shell->grid = NULL;
|
||||
shell->guides = NULL;
|
||||
shell->sample_points = NULL;
|
||||
shell->layer_boundary = NULL;
|
||||
shell->tool_items = NULL;
|
||||
shell->cursor = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -136,6 +142,26 @@ gimp_display_shell_remove_item (GimpDisplayShell *shell,
|
|||
gimp_canvas_group_remove_item (GIMP_CANVAS_GROUP (shell->canvas_item), item);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_display_shell_add_preview_item (GimpDisplayShell *shell,
|
||||
GimpCanvasItem *item)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
g_return_if_fail (GIMP_IS_CANVAS_ITEM (item));
|
||||
|
||||
gimp_canvas_group_add_item (GIMP_CANVAS_GROUP (shell->preview_items), item);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_display_shell_remove_preview_item (GimpDisplayShell *shell,
|
||||
GimpCanvasItem *item)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
g_return_if_fail (GIMP_IS_CANVAS_ITEM (item));
|
||||
|
||||
gimp_canvas_group_remove_item (GIMP_CANVAS_GROUP (shell->preview_items), item);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_display_shell_add_tool_item (GimpDisplayShell *shell,
|
||||
GimpCanvasItem *item)
|
||||
|
|
|
@ -22,18 +22,23 @@
|
|||
#define __GIMP_DISPLAY_SHELL_ITEMS_H__
|
||||
|
||||
|
||||
void gimp_display_shell_items_init (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_items_free (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_items_init (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_items_free (GimpDisplayShell *shell);
|
||||
|
||||
void gimp_display_shell_add_item (GimpDisplayShell *shell,
|
||||
GimpCanvasItem *item);
|
||||
void gimp_display_shell_remove_item (GimpDisplayShell *shell,
|
||||
GimpCanvasItem *item);
|
||||
void gimp_display_shell_add_item (GimpDisplayShell *shell,
|
||||
GimpCanvasItem *item);
|
||||
void gimp_display_shell_remove_item (GimpDisplayShell *shell,
|
||||
GimpCanvasItem *item);
|
||||
|
||||
void gimp_display_shell_add_tool_item (GimpDisplayShell *shell,
|
||||
GimpCanvasItem *item);
|
||||
void gimp_display_shell_remove_tool_item (GimpDisplayShell *shell,
|
||||
GimpCanvasItem *item);
|
||||
void gimp_display_shell_add_preview_item (GimpDisplayShell *shell,
|
||||
GimpCanvasItem *item);
|
||||
void gimp_display_shell_remove_preview_item (GimpDisplayShell *shell,
|
||||
GimpCanvasItem *item);
|
||||
|
||||
void gimp_display_shell_add_tool_item (GimpDisplayShell *shell,
|
||||
GimpCanvasItem *item);
|
||||
void gimp_display_shell_remove_tool_item (GimpDisplayShell *shell,
|
||||
GimpCanvasItem *item);
|
||||
|
||||
|
||||
#endif /* __GIMP_DISPLAY_SHELL_ITEMS_H__ */
|
||||
|
|
|
@ -120,6 +120,7 @@ struct _GimpDisplayShell
|
|||
|
||||
GimpCanvasItem *canvas_item; /* items drawn on the canvas */
|
||||
GimpCanvasItem *passe_partout; /* item for the highlight */
|
||||
GimpCanvasItem *preview_items; /* item for previews */
|
||||
GimpCanvasItem *vectors; /* item proxy of vectors */
|
||||
GimpCanvasItem *grid; /* item proxy of the grid */
|
||||
GimpCanvasItem *guides; /* item proxies of guides */
|
||||
|
|
|
@ -103,6 +103,7 @@ gimp_draw_tool_init (GimpDrawTool *draw_tool)
|
|||
{
|
||||
draw_tool->display = NULL;
|
||||
draw_tool->paused_count = 0;
|
||||
draw_tool->preview = NULL;
|
||||
draw_tool->item = NULL;
|
||||
}
|
||||
|
||||
|
@ -193,6 +194,8 @@ gimp_draw_tool_draw (GimpDrawTool *draw_tool)
|
|||
draw_tool->paused_count == 0 &&
|
||||
! draw_tool->draw_timeout)
|
||||
{
|
||||
GimpDisplayShell *shell = gimp_display_get_shell (draw_tool->display);
|
||||
|
||||
gimp_draw_tool_undraw (draw_tool);
|
||||
|
||||
GIMP_DRAW_TOOL_GET_CLASS (draw_tool)->draw (draw_tool);
|
||||
|
@ -208,25 +211,34 @@ gimp_draw_tool_draw (GimpDrawTool *draw_tool)
|
|||
gimp_draw_tool_pop_group (draw_tool);
|
||||
}
|
||||
|
||||
if (draw_tool->item)
|
||||
{
|
||||
GimpDisplayShell *shell = gimp_display_get_shell (draw_tool->display);
|
||||
if (draw_tool->preview)
|
||||
gimp_display_shell_add_preview_item (shell, draw_tool->preview);
|
||||
|
||||
gimp_display_shell_add_tool_item (shell, draw_tool->item);
|
||||
}
|
||||
if (draw_tool->item)
|
||||
gimp_display_shell_add_tool_item (shell, draw_tool->item);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_draw_tool_undraw (GimpDrawTool *draw_tool)
|
||||
{
|
||||
if (draw_tool->display && draw_tool->item)
|
||||
if (draw_tool->display)
|
||||
{
|
||||
GimpDisplayShell *shell = gimp_display_get_shell (draw_tool->display);
|
||||
|
||||
gimp_display_shell_remove_tool_item (shell, draw_tool->item);
|
||||
g_object_unref (draw_tool->item);
|
||||
draw_tool->item = NULL;
|
||||
if (draw_tool->preview)
|
||||
{
|
||||
gimp_display_shell_remove_preview_item (shell, draw_tool->preview);
|
||||
g_object_unref (draw_tool->preview);
|
||||
draw_tool->preview = NULL;
|
||||
}
|
||||
|
||||
if (draw_tool->item)
|
||||
{
|
||||
gimp_display_shell_remove_tool_item (shell, draw_tool->item);
|
||||
g_object_unref (draw_tool->item);
|
||||
draw_tool->item = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -373,6 +385,31 @@ gimp_draw_tool_calc_distance_square (GimpDrawTool *draw_tool,
|
|||
return SQR (tx2 - tx1) + SQR (ty2 - ty1);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_draw_tool_add_preview (GimpDrawTool *draw_tool,
|
||||
GimpCanvasItem *item)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
|
||||
g_return_if_fail (GIMP_IS_CANVAS_ITEM (item));
|
||||
|
||||
if (! draw_tool->preview)
|
||||
draw_tool->preview =
|
||||
gimp_canvas_group_new (gimp_display_get_shell (draw_tool->display));
|
||||
|
||||
gimp_canvas_group_add_item (GIMP_CANVAS_GROUP (draw_tool->preview), item);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_draw_tool_remove_preview (GimpDrawTool *draw_tool,
|
||||
GimpCanvasItem *item)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
|
||||
g_return_if_fail (GIMP_IS_CANVAS_ITEM (item));
|
||||
g_return_if_fail (draw_tool->preview != NULL);
|
||||
|
||||
gimp_canvas_group_remove_item (GIMP_CANVAS_GROUP (draw_tool->preview), item);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_draw_tool_add_item (GimpDrawTool *draw_tool,
|
||||
GimpCanvasItem *item)
|
||||
|
@ -383,7 +420,8 @@ gimp_draw_tool_add_item (GimpDrawTool *draw_tool,
|
|||
g_return_if_fail (GIMP_IS_CANVAS_ITEM (item));
|
||||
|
||||
if (! draw_tool->item)
|
||||
draw_tool->item = gimp_canvas_group_new (gimp_display_get_shell (draw_tool->display));
|
||||
draw_tool->item =
|
||||
gimp_canvas_group_new (gimp_display_get_shell (draw_tool->display));
|
||||
|
||||
group = GIMP_CANVAS_GROUP (draw_tool->item);
|
||||
|
||||
|
@ -911,7 +949,7 @@ gimp_draw_tool_add_transform_preview (GimpDrawTool *draw_tool,
|
|||
x1, y1, x2, y2,
|
||||
perspective, opacity);
|
||||
|
||||
gimp_draw_tool_add_item (draw_tool, item);
|
||||
gimp_draw_tool_add_preview (draw_tool, item);
|
||||
g_object_unref (item);
|
||||
|
||||
return item;
|
||||
|
|
|
@ -49,6 +49,7 @@ struct _GimpDrawTool
|
|||
gint paused_count; /* count to keep track of multiple pauses */
|
||||
guint draw_timeout; /* draw delay timeout ID */
|
||||
|
||||
GimpCanvasItem *preview;
|
||||
GimpCanvasItem *item;
|
||||
GList *group_stack;
|
||||
};
|
||||
|
@ -87,6 +88,11 @@ gdouble gimp_draw_tool_calc_distance_square (GimpDrawTool *draw_too
|
|||
gdouble x2,
|
||||
gdouble y2);
|
||||
|
||||
void gimp_draw_tool_add_preview (GimpDrawTool *draw_tool,
|
||||
GimpCanvasItem *item);
|
||||
void gimp_draw_tool_remove_preview (GimpDrawTool *draw_tool,
|
||||
GimpCanvasItem *item);
|
||||
|
||||
void gimp_draw_tool_add_item (GimpDrawTool *draw_tool,
|
||||
GimpCanvasItem *item);
|
||||
void gimp_draw_tool_remove_item (GimpDrawTool *draw_tool,
|
||||
|
|
Loading…
Reference in New Issue