예제 #1
0
void
gimp_display_shell_items_init (GimpDisplayShell *shell)
{
  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));

  shell->canvas_item = gimp_canvas_group_new (shell);

  shell->passe_partout = gimp_canvas_passe_partout_new (shell, 0, 0, 0, 0);
  gimp_canvas_item_set_visible (shell->passe_partout, FALSE);
  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);

  shell->grid = gimp_canvas_grid_new (shell, NULL);
  gimp_canvas_item_set_visible (shell->grid, FALSE);
  g_object_set (shell->grid, "grid-style", TRUE, NULL);
  gimp_display_shell_add_item (shell, shell->grid);
  g_object_unref (shell->grid);

  shell->guides = gimp_canvas_proxy_group_new (shell);
  gimp_display_shell_add_item (shell, shell->guides);
  g_object_unref (shell->guides);

  shell->sample_points = gimp_canvas_proxy_group_new (shell);
  gimp_display_shell_add_item (shell, shell->sample_points);
  g_object_unref (shell->sample_points);

  shell->layer_boundary = gimp_canvas_layer_boundary_new (shell);
  gimp_canvas_item_set_visible (shell->layer_boundary, FALSE);
  gimp_display_shell_add_item (shell, shell->layer_boundary);
  g_object_unref (shell->layer_boundary);

  shell->tool_items = gimp_canvas_group_new (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_unrotated_item (shell, shell->cursor);
  g_object_unref (shell->cursor);

  g_signal_connect (shell->unrotated_item, "update",
                    G_CALLBACK (gimp_display_shell_unrotated_item_update),
                    shell);
}
예제 #2
0
static void
gimp_draw_tool_draw (GimpDrawTool *draw_tool)
{
  if (draw_tool->display &&
      draw_tool->paused_count == 0 &&
      ! draw_tool->draw_timeout)
    {
      gimp_draw_tool_undraw (draw_tool);

      GIMP_DRAW_TOOL_GET_CLASS (draw_tool)->draw (draw_tool);

      if (draw_tool->group_stack)
        {
          g_warning ("%s: draw_tool->group_stack not empty after calling "
                     "GimpDrawTool::draw() of %s",
                     G_STRFUNC,
                     g_type_name (G_TYPE_FROM_INSTANCE (draw_tool)));

          while (draw_tool->group_stack)
            gimp_draw_tool_pop_group (draw_tool);
        }

      if (draw_tool->item)
        {
          GimpDisplayShell *shell = gimp_display_get_shell (draw_tool->display);

          gimp_display_shell_add_item (shell, draw_tool->item);
        }
    }
}
static GimpProgress *
gimp_tool_progress_start (GimpProgress *progress,
                          const gchar  *message,
                          gboolean      cancelable)
{
  GimpTool         *tool = GIMP_TOOL (progress);
  GimpDisplayShell *shell;
  gint              x, y, w, h;

  g_return_val_if_fail (GIMP_IS_DISPLAY (tool->display), NULL);
  g_return_val_if_fail (tool->progress == NULL, NULL);

  shell = gimp_display_get_shell (tool->display);

  gimp_display_shell_untransform_viewport (shell, &x, &y, &w, &h);

  tool->progress = gimp_canvas_progress_new (shell,
                                             GIMP_HANDLE_ANCHOR_CENTER,
                                             x + w / 2, y + h / 2);
  gimp_display_shell_add_item (shell, tool->progress);
  g_object_unref (tool->progress);

  gimp_progress_start (GIMP_PROGRESS (tool->progress),
                       message, FALSE);
  gimp_widget_flush_expose (shell->canvas);

  tool->progress_display = tool->display;

  return progress;
}
예제 #4
0
static void
gimp_source_tool_draw (GimpDrawTool *draw_tool)
{
  GimpSourceTool    *source_tool = GIMP_SOURCE_TOOL (draw_tool);
  GimpSourceOptions *options     = GIMP_SOURCE_TOOL_GET_OPTIONS (draw_tool);
  GimpSourceCore    *source;

  source = GIMP_SOURCE_CORE (GIMP_PAINT_TOOL (draw_tool)->core);

  GIMP_DRAW_TOOL_CLASS (parent_class)->draw (draw_tool);

  if (options->use_source && source->src_drawable && source_tool->src_display)
    {
      GimpDisplayShell *src_shell;
      gint              off_x;
      gint              off_y;

      src_shell = gimp_display_get_shell (source_tool->src_display);

      gimp_item_get_offset (GIMP_ITEM (source->src_drawable), &off_x, &off_y);

      if (source_tool->src_outline)
        {
          gimp_display_shell_remove_item (src_shell,
                                          source_tool->src_outline);
          source_tool->src_outline = NULL;
        }

      if (source_tool->show_source_outline)
        {
          source_tool->src_outline =
            gimp_brush_tool_create_outline (GIMP_BRUSH_TOOL (source_tool),
                                            source_tool->src_display,
                                            source_tool->src_x + off_x,
                                            source_tool->src_y + off_y,
                                            FALSE);

          if (source_tool->src_outline)
            {
              gimp_display_shell_add_item (src_shell,
                                           source_tool->src_outline);
              g_object_unref (source_tool->src_outline);
            }
        }

      if (! source_tool->src_handle)
        {
          source_tool->src_handle =
            gimp_canvas_handle_new (src_shell,
                                    GIMP_HANDLE_CROSS,
                                    GIMP_HANDLE_ANCHOR_CENTER,
                                    source_tool->src_x + off_x,
                                    source_tool->src_y + off_y,
                                    GIMP_TOOL_HANDLE_SIZE_CROSS,
                                    GIMP_TOOL_HANDLE_SIZE_CROSS);
          gimp_display_shell_add_item (src_shell,
                                       source_tool->src_handle);
          g_object_unref (source_tool->src_handle);
        }
      else
        {
          gimp_canvas_handle_set_position (source_tool->src_handle,
                                           source_tool->src_x + off_x,
                                           source_tool->src_y + off_y);
        }
    }
}