[gimp] app: add an unrotated canvas item group to GimpDisplayShell
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add an unrotated canvas item group to GimpDisplayShell
- Date: Tue, 23 Apr 2013 22:02:29 +0000 (UTC)
commit aea94211b1fea52ee469ffc0a8d80b324c834e60
Author: Michael Natterer <mitch gimp org>
Date: Wed Apr 24 00:01:01 2013 +0200
app: add an unrotated canvas item group to GimpDisplayShell
and put the software cursor and the tool progress there.
app/display/gimpdisplayshell-callbacks.c | 6 +++
app/display/gimpdisplayshell-items.c | 62 ++++++++++++++++++++++++++---
app/display/gimpdisplayshell-items.h | 39 ++++++++++--------
app/display/gimpdisplayshell.h | 1 +
app/tools/gimptool-progress.c | 4 +-
5 files changed, 86 insertions(+), 26 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c
index 5861c0a..7f14f11 100644
--- a/app/display/gimpdisplayshell-callbacks.c
+++ b/app/display/gimpdisplayshell-callbacks.c
@@ -533,11 +533,17 @@ gimp_display_shell_canvas_draw_image (GimpDisplayShell *shell,
*/
/* draw canvas items */
+ cairo_save (cr);
+
if (shell->rotate_transform)
cairo_transform (cr, shell->rotate_transform);
gimp_canvas_item_draw (shell->canvas_item, cr);
+ cairo_restore (cr);
+
+ gimp_canvas_item_draw (shell->unrotated_item, cr);
+
/* restart (and recalculate) the selection boundaries */
gimp_display_shell_selection_restart (shell);
}
diff --git a/app/display/gimpdisplayshell-items.c b/app/display/gimpdisplayshell-items.c
index 0e3ef2d..e8fe8dd 100644
--- a/app/display/gimpdisplayshell-items.c
+++ b/app/display/gimpdisplayshell-items.c
@@ -39,9 +39,12 @@
/* local function prototypes */
-static void gimp_display_shell_item_update (GimpCanvasItem *item,
- cairo_region_t *region,
- GimpDisplayShell *shell);
+static void gimp_display_shell_item_update (GimpCanvasItem *item,
+ cairo_region_t *region,
+ GimpDisplayShell *shell);
+static void gimp_display_shell_unrotated_item_update (GimpCanvasItem *item,
+ cairo_region_t *region,
+ GimpDisplayShell *shell);
/* public functions */
@@ -89,13 +92,19 @@ gimp_display_shell_items_init (GimpDisplayShell *shell)
gimp_display_shell_add_item (shell, shell->tool_items);
g_object_unref (shell->tool_items);
+ g_signal_connect (shell->canvas_item, "update",
+ G_CALLBACK (gimp_display_shell_item_update),
+ shell);
+
+ shell->unrotated_item = gimp_canvas_group_new (shell);
+
shell->cursor = gimp_canvas_cursor_new (shell);
gimp_canvas_item_set_visible (shell->cursor, FALSE);
- gimp_display_shell_add_item (shell, shell->cursor);
+ gimp_display_shell_add_unrotated_item (shell, shell->cursor);
g_object_unref (shell->cursor);
- g_signal_connect (shell->canvas_item, "update",
- G_CALLBACK (gimp_display_shell_item_update),
+ g_signal_connect (shell->unrotated_item, "update",
+ G_CALLBACK (gimp_display_shell_unrotated_item_update),
shell);
}
@@ -121,7 +130,18 @@ gimp_display_shell_items_free (GimpDisplayShell *shell)
shell->sample_points = NULL;
shell->layer_boundary = NULL;
shell->tool_items = NULL;
- shell->cursor = NULL;
+ }
+
+ if (shell->unrotated_item)
+ {
+ g_signal_handlers_disconnect_by_func (shell->unrotated_item,
+ gimp_display_shell_unrotated_item_update,
+ shell);
+
+ g_object_unref (shell->unrotated_item);
+ shell->unrotated_item = NULL;
+
+ shell->cursor = NULL;
}
}
@@ -166,6 +186,26 @@ gimp_display_shell_remove_preview_item (GimpDisplayShell *shell,
}
void
+gimp_display_shell_add_unrotated_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->unrotated_item), item);
+}
+
+void
+gimp_display_shell_remove_unrotated_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->unrotated_item), item);
+}
+
+void
gimp_display_shell_add_tool_item (GimpDisplayShell *shell,
GimpCanvasItem *item)
{
@@ -228,3 +268,11 @@ gimp_display_shell_item_update (GimpCanvasItem *item,
gimp_display_shell_expose_region (shell, region);
}
}
+
+static void
+gimp_display_shell_unrotated_item_update (GimpCanvasItem *item,
+ cairo_region_t *region,
+ GimpDisplayShell *shell)
+{
+ gimp_display_shell_expose_region (shell, region);
+}
diff --git a/app/display/gimpdisplayshell-items.h b/app/display/gimpdisplayshell-items.h
index 5a2a792..50e7eb4 100644
--- a/app/display/gimpdisplayshell-items.h
+++ b/app/display/gimpdisplayshell-items.h
@@ -22,23 +22,28 @@
#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_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);
+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_unrotated_item (GimpDisplayShell *shell,
+ GimpCanvasItem *item);
+void gimp_display_shell_remove_unrotated_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 8c8db4d..50f1823 100644
--- a/app/display/gimpdisplayshell.h
+++ b/app/display/gimpdisplayshell.h
@@ -118,6 +118,7 @@ struct _GimpDisplayShell
cairo_pattern_t *checkerboard; /* checkerboard pattern */
GimpCanvasItem *canvas_item; /* items drawn on the canvas */
+ GimpCanvasItem *unrotated_item; /* unrotated items for e.g. cursor */
GimpCanvasItem *passe_partout; /* item for the highlight */
GimpCanvasItem *preview_items; /* item for previews */
GimpCanvasItem *vectors; /* item proxy of vectors */
diff --git a/app/tools/gimptool-progress.c b/app/tools/gimptool-progress.c
index c9af158..a3e8a81 100644
--- a/app/tools/gimptool-progress.c
+++ b/app/tools/gimptool-progress.c
@@ -96,7 +96,7 @@ gimp_tool_progress_start (GimpProgress *progress,
tool->progress = gimp_canvas_progress_new (shell,
GIMP_HANDLE_ANCHOR_CENTER,
x + w / 2, y + h / 2);
- gimp_display_shell_add_tool_item (shell, tool->progress);
+ gimp_display_shell_add_unrotated_item (shell, tool->progress);
g_object_unref (tool->progress);
gimp_progress_start (GIMP_PROGRESS (tool->progress),
@@ -118,7 +118,7 @@ gimp_tool_progress_end (GimpProgress *progress)
GimpDisplayShell *shell = gimp_display_get_shell (tool->progress_display);
gimp_progress_end (GIMP_PROGRESS (tool->progress));
- gimp_display_shell_remove_tool_item (shell, tool->progress);
+ gimp_display_shell_remove_unrotated_item (shell, tool->progress);
tool->progress = NULL;
tool->progress_display = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]