[gimp/metadata-browser] Bug 663121 - guides are below rotate/transform/shear/perspective preview
- From: Roman Joost <romanofski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/metadata-browser] Bug 663121 - guides are below rotate/transform/shear/perspective preview
- Date: Wed, 12 Sep 2012 22:14:20 +0000 (UTC)
commit 4798a48500ceb5ae5c72bfa89242b59ac9c1defa
Author: Michael Natterer <mitch gimp org>
Date: Wed Nov 16 21:32:29 2011 +0100
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.
app/display/gimpdisplayshell-items.c | 26 ++++++++++++++
app/display/gimpdisplayshell-items.h | 29 +++++++++-------
app/display/gimpdisplayshell.h | 1 +
app/tools/gimpdrawtool.c | 60 +++++++++++++++++++++++++++------
app/tools/gimpdrawtool.h | 6 +++
5 files changed, 99 insertions(+), 23 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-items.c b/app/display/gimpdisplayshell-items.c
index 3500984..9cb1261 100644
--- a/app/display/gimpdisplayshell-items.c
+++ b/app/display/gimpdisplayshell-items.c
@@ -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;
}
}
@@ -137,6 +143,26 @@ gimp_display_shell_remove_item (GimpDisplayShell *shell,
}
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)
{
diff --git a/app/display/gimpdisplayshell-items.h b/app/display/gimpdisplayshell-items.h
index 61f5f34..5a2a792 100644
--- a/app/display/gimpdisplayshell-items.h
+++ b/app/display/gimpdisplayshell-items.h
@@ -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_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_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_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__ */
diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h
index a780849..01822b6 100644
--- a/app/display/gimpdisplayshell.h
+++ b/app/display/gimpdisplayshell.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 */
diff --git a/app/tools/gimpdrawtool.c b/app/tools/gimpdrawtool.c
index 09dd7d5..8eefd73 100644
--- a/app/tools/gimpdrawtool.c
+++ b/app/tools/gimpdrawtool.c
@@ -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;
+ }
}
}
@@ -374,6 +386,31 @@ gimp_draw_tool_calc_distance_square (GimpDrawTool *draw_tool,
}
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;
diff --git a/app/tools/gimpdrawtool.h b/app/tools/gimpdrawtool.h
index b968ffe..705fae6 100644
--- a/app/tools/gimpdrawtool.h
+++ b/app/tools/gimpdrawtool.h
@@ -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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]