Esempio n. 1
0
static void
gimp_source_tool_set_src_display (GimpSourceTool *source_tool,
                                  GimpDisplay    *display)
{
  if (source_tool->src_display != display)
    {
      if (source_tool->src_display)
        {
          GimpDisplayShell *src_shell;

          src_shell = gimp_display_get_shell (source_tool->src_display);

          if (source_tool->src_handle)
            {
              gimp_display_shell_remove_tool_item (src_shell,
                                                   source_tool->src_handle);
              source_tool->src_handle = NULL;
            }

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

      source_tool->src_display = display;
    }
}
Esempio n. 2
0
static void
gimp_draw_tool_undraw (GimpDrawTool *draw_tool)
{
  if (draw_tool->display)
    {
      GimpDisplayShell *shell = gimp_display_get_shell (draw_tool->display);

      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;
        }
    }
}
Esempio n. 3
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 (gimp_source_core_use_source (source, options) &&
      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_tool_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);

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

      if (source_tool->src_outline)
        {
          if (source_tool->src_handle)
            {
              gimp_display_shell_remove_tool_item (src_shell,
                                                   source_tool->src_handle);
              source_tool->src_handle = NULL;
            }
        }
      else
        {
          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_tool_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);
            }
        }
    }
}