Commit aea94211 authored by Michael Natterer's avatar Michael Natterer 😴

app: add an unrotated canvas item group to GimpDisplayShell

and put the software cursor and the tool progress there.
parent c3c4287b
......@@ -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);
}
......
......@@ -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;
}
}
......@@ -165,6 +185,26 @@ gimp_display_shell_remove_preview_item (GimpDisplayShell *shell,
gimp_canvas_group_remove_item (GIMP_CANVAS_GROUP (shell->preview_items), item);
}
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);
}
......@@ -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__ */
......@@ -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 */
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment