Esempio n. 1
0
static void
gimp_perspective_clone_tool_modifier_key (GimpTool        *tool,
                                          GdkModifierType  key,
                                          gboolean         press,
                                          GdkModifierType  state,
                                          GimpDisplay     *display)
{
  GimpPerspectiveCloneTool    *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (tool);
  GimpPerspectiveCloneOptions *options;

  options = GIMP_PERSPECTIVE_CLONE_TOOL_GET_OPTIONS (tool);

  if (options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_PAINT &&
      key == gimp_get_toggle_behavior_mask ())
    {
      if (press)
        {
          clone_tool->saved_precision =
            gimp_tool_control_get_precision (tool->control);
          gimp_tool_control_set_precision (tool->control,
                                           GIMP_CURSOR_PRECISION_PIXEL_CENTER);
        }
      else
        {
          gimp_tool_control_set_precision (tool->control,
                                           clone_tool->saved_precision);
        }
    }

  GIMP_TOOL_CLASS (parent_class)->modifier_key (tool, key, press, state,
                                                display);
}
static void
gimp_rectangle_select_tool_init (GimpRectangleSelectTool *rect_sel_tool)
{
  GimpTool                       *tool = GIMP_TOOL (rect_sel_tool);
  GimpRectangleSelectToolPrivate *priv;

  gimp_rectangle_tool_init (GIMP_RECTANGLE_TOOL (rect_sel_tool));

  rect_sel_tool->priv = G_TYPE_INSTANCE_GET_PRIVATE (rect_sel_tool,
                                                     GIMP_TYPE_RECTANGLE_SELECT_TOOL,
                                                     GimpRectangleSelectToolPrivate);

  priv = GIMP_RECTANGLE_SELECT_TOOL_GET_PRIVATE (rect_sel_tool);

  gimp_tool_control_set_wants_click (tool->control, TRUE);
  gimp_tool_control_set_precision   (tool->control,
                                     GIMP_CURSOR_PRECISION_PIXEL_BORDER);
  gimp_tool_control_set_tool_cursor (tool->control,
                                     GIMP_TOOL_CURSOR_RECT_SELECT);
  gimp_tool_control_set_preserve    (tool->control, FALSE);
  gimp_tool_control_set_dirty_mask  (tool->control,
                                     GIMP_DIRTY_IMAGE_SIZE |
                                     GIMP_DIRTY_SELECTION);

  priv->undo    = NULL;
  priv->redo    = NULL;

  priv->press_x = 0.0;
  priv->press_y = 0.0;
}
Esempio n. 3
0
static void
gimp_paint_tool_hard_notify (GimpPaintOptions *options,
                             const GParamSpec *pspec,
                             GimpTool         *tool)
{
  gimp_tool_control_set_precision (tool->control,
                                   options->hard ?
                                   GIMP_CURSOR_PRECISION_PIXEL_CENTER :
                                   GIMP_CURSOR_PRECISION_SUBPIXEL);
}
Esempio n. 4
0
static void
gimp_align_tool_init (GimpAlignTool *align_tool)
{
    GimpTool *tool = GIMP_TOOL (align_tool);

    gimp_tool_control_set_snap_to     (tool->control, FALSE);
    gimp_tool_control_set_precision   (tool->control,
                                       GIMP_CURSOR_PRECISION_PIXEL_BORDER);
    gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_MOVE);

    align_tool->function = ALIGN_TOOL_IDLE;
}
Esempio n. 5
0
static void
gimp_crop_tool_init (GimpCropTool *crop_tool)
{
  GimpTool *tool = GIMP_TOOL (crop_tool);

  gimp_tool_control_set_wants_click (tool->control, TRUE);
  gimp_tool_control_set_precision   (tool->control,
                                     GIMP_CURSOR_PRECISION_PIXEL_BORDER);
  gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_CROP);

  gimp_rectangle_tool_init (GIMP_RECTANGLE_TOOL (crop_tool));

  crop_tool->current_image = NULL;
}
Esempio n. 6
0
static void
gimp_blend_tool_init (GimpBlendTool *blend_tool)
{
  GimpTool *tool = GIMP_TOOL (blend_tool);

  gimp_tool_control_set_scroll_lock     (tool->control, TRUE);
  gimp_tool_control_set_precision       (tool->control,
                                         GIMP_CURSOR_PRECISION_SUBPIXEL);
  gimp_tool_control_set_tool_cursor     (tool->control,
                                         GIMP_TOOL_CURSOR_BLEND);
  gimp_tool_control_set_action_opacity  (tool->control,
                                         "context/context-opacity-set");
  gimp_tool_control_set_action_object_1 (tool->control,
                                         "context/context-gradient-select-set");
}
Esempio n. 7
0
static void
gimp_guide_tool_init (GimpGuideTool *guide_tool)
{
  GimpTool *tool = GIMP_TOOL (guide_tool);

  gimp_tool_control_set_snap_to            (tool->control, FALSE);
  gimp_tool_control_set_handle_empty_image (tool->control, TRUE);
  gimp_tool_control_set_tool_cursor        (tool->control,
                                            GIMP_TOOL_CURSOR_MOVE);
  gimp_tool_control_set_scroll_lock        (tool->control, TRUE);
  gimp_tool_control_set_precision          (tool->control,
                                            GIMP_CURSOR_PRECISION_PIXEL_BORDER);

  guide_tool->guide             = NULL;
  guide_tool->guide_position    = GIMP_GUIDE_POSITION_UNDEFINED;
  guide_tool->guide_orientation = GIMP_ORIENTATION_UNKNOWN;
}
Esempio n. 8
0
static void
gimp_flip_tool_init (GimpFlipTool *flip_tool)
{
  GimpTool *tool = GIMP_TOOL (flip_tool);

  gimp_tool_control_set_snap_to            (tool->control, FALSE);
  gimp_tool_control_set_precision          (tool->control,
                                            GIMP_CURSOR_PRECISION_PIXEL_CENTER);
  gimp_tool_control_set_cursor             (tool->control, GIMP_CURSOR_MOUSE);
  gimp_tool_control_set_toggle_cursor      (tool->control, GIMP_CURSOR_MOUSE);
  gimp_tool_control_set_tool_cursor        (tool->control,
                                            GIMP_TOOL_CURSOR_FLIP_HORIZONTAL);
  gimp_tool_control_set_toggle_tool_cursor (tool->control,
                                            GIMP_TOOL_CURSOR_FLIP_VERTICAL);

  flip_tool->guide = NULL;
}
Esempio n. 9
0
static void
gimp_sample_point_tool_init (GimpSamplePointTool *sp_tool)
{
  GimpTool *tool = GIMP_TOOL (sp_tool);

  gimp_tool_control_set_snap_to            (tool->control, FALSE);
  gimp_tool_control_set_handle_empty_image (tool->control, TRUE);
  gimp_tool_control_set_tool_cursor        (tool->control,
                                            GIMP_TOOL_CURSOR_MOVE);
  gimp_tool_control_set_scroll_lock        (tool->control, TRUE);
  gimp_tool_control_set_precision          (tool->control,
                                            GIMP_CURSOR_PRECISION_PIXEL_CENTER);

  sp_tool->sample_point   = NULL;
  sp_tool->sample_point_x = GIMP_SAMPLE_POINT_POSITION_UNDEFINED;
  sp_tool->sample_point_y = GIMP_SAMPLE_POINT_POSITION_UNDEFINED;
}
Esempio n. 10
0
static void
gimp_perspective_clone_tool_options_notify (GimpTool         *tool,
                                            GimpToolOptions  *options,
                                            const GParamSpec *pspec)
{
  GimpPerspectiveCloneTool    *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (tool);
  GimpPaintTool               *paint_tool = GIMP_PAINT_TOOL (tool);
  GimpPerspectiveCloneOptions *clone_options;

  clone_options = GIMP_PERSPECTIVE_CLONE_OPTIONS (options);

  GIMP_TOOL_CLASS (parent_class)->options_notify (tool, options, pspec);

  if (! strcmp (pspec->name, "clone-mode"))
    {
      GimpPerspectiveClone *clone;

      clone = GIMP_PERSPECTIVE_CLONE (GIMP_PAINT_TOOL (tool)->core);

      gimp_draw_tool_pause (GIMP_DRAW_TOOL (clone_tool));

      if (clone_options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_PAINT)
        {
          gimp_perspective_clone_set_transform (clone, &clone_tool->transform);

          gimp_paint_tool_set_active (paint_tool, TRUE);
        }
      else
        {
          gimp_paint_tool_set_active (paint_tool, FALSE);

          gimp_tool_control_set_precision (tool->control,
                                           GIMP_CURSOR_PRECISION_SUBPIXEL);

          /*  start drawing the bounding box and handles...  */
          if (tool->display &&
              ! gimp_draw_tool_is_active (GIMP_DRAW_TOOL (clone_tool)))
            {
              gimp_draw_tool_start (GIMP_DRAW_TOOL (clone_tool), tool->display);
            }
        }

      gimp_draw_tool_resume (GIMP_DRAW_TOOL (clone_tool));
    }
}
Esempio n. 11
0
static void
gimp_flip_tool_init (GimpFlipTool *flip_tool)
{
  GimpTool *tool = GIMP_TOOL (flip_tool);
  GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (flip_tool);

  gimp_tool_control_set_snap_to            (tool->control, FALSE);
  gimp_tool_control_set_precision          (tool->control,
                                            GIMP_CURSOR_PRECISION_PIXEL_CENTER);
  gimp_tool_control_set_cursor             (tool->control, GIMP_CURSOR_MOUSE);
  gimp_tool_control_set_toggle_cursor      (tool->control, GIMP_CURSOR_MOUSE);
  gimp_tool_control_set_tool_cursor        (tool->control,
                                            GIMP_TOOL_CURSOR_FLIP_HORIZONTAL);
  gimp_tool_control_set_toggle_tool_cursor (tool->control,
                                            GIMP_TOOL_CURSOR_FLIP_VERTICAL);

  tr_tool->undo_desc = C_("command", "Flip");
}
Esempio n. 12
0
static void
gimp_foreground_select_tool_init (GimpForegroundSelectTool *fg_select)
{
  GimpTool *tool = GIMP_TOOL (fg_select);

  gimp_tool_control_set_scroll_lock (tool->control, FALSE);
  gimp_tool_control_set_preserve    (tool->control, FALSE);
  gimp_tool_control_set_dirty_mask  (tool->control, GIMP_DIRTY_IMAGE_SIZE);
  gimp_tool_control_set_precision   (tool->control,
                                     GIMP_CURSOR_PRECISION_PIXEL_CENTER);
  gimp_tool_control_set_tool_cursor (tool->control,
                                     GIMP_TOOL_CURSOR_FREE_SELECT);

  gimp_tool_control_set_action_value_2 (tool->control,
                                        "tools/tools-foreground-select-brush-size-set");

  fg_select->idle_id = 0;
  fg_select->stroke  = NULL;
  fg_select->strokes = NULL;
  fg_select->mask    = NULL;
}
static void
gimp_perspective_clone_tool_mode_notify (GimpPerspectiveCloneOptions *options,
                                         GParamSpec                  *pspec,
                                         GimpPerspectiveCloneTool    *clone_tool)
{
  GimpTool             *tool = GIMP_TOOL (clone_tool);
  GimpPerspectiveClone *clone;

  clone = GIMP_PERSPECTIVE_CLONE (GIMP_PAINT_TOOL (clone_tool)->core);

  gimp_draw_tool_pause (GIMP_DRAW_TOOL (clone_tool));

  if (options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_PAINT)
    {
      /* GimpPaintTool's notify callback will set the right precision */
      g_object_notify (G_OBJECT (options), "hard");

      gimp_tool_control_set_tool_cursor (tool->control,
                                         GIMP_TOOL_CURSOR_CLONE);

      gimp_perspective_clone_set_transform (clone, &clone_tool->transform);
    }
  else
    {
      gimp_tool_control_set_precision (tool->control,
                                       GIMP_CURSOR_PRECISION_SUBPIXEL);

      gimp_tool_control_set_tool_cursor (tool->control,
                                         GIMP_TOOL_CURSOR_PERSPECTIVE);

      /*  start drawing the bounding box and handles...  */
      if (tool->display &&
          ! gimp_draw_tool_is_active (GIMP_DRAW_TOOL (clone_tool)))
        {
          gimp_draw_tool_start (GIMP_DRAW_TOOL (clone_tool), tool->display);
        }
    }

  gimp_draw_tool_resume (GIMP_DRAW_TOOL (clone_tool));
}
Esempio n. 14
0
static void
gimp_move_tool_button_release (GimpTool              *tool,
                               const GimpCoords      *coords,
                               guint32                time,
                               GdkModifierType        state,
                               GimpButtonReleaseType  release_type,
                               GimpDisplay           *display)
{
  GimpMoveTool     *move   = GIMP_MOVE_TOOL (tool);
  GimpGuiConfig    *config = GIMP_GUI_CONFIG (display->gimp->config);
  GimpDisplayShell *shell  = gimp_display_get_shell (display);
  GimpImage        *image  = gimp_display_get_image (display);

  if (gimp_tool_control_is_active (tool->control))
    gimp_tool_control_halt (tool->control);

  if (move->moving_guide)
    {
      gboolean delete_guide = FALSE;
      gint     x, y, width, height;

      gimp_tool_pop_status (tool, display);

      gimp_tool_control_set_scroll_lock (tool->control, FALSE);
      gimp_tool_control_set_precision   (tool->control,
                                         GIMP_CURSOR_PRECISION_PIXEL_CENTER);

      gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));

      if (release_type == GIMP_BUTTON_RELEASE_CANCEL)
        {
          move->moving_guide      = FALSE;
          move->guide_position    = GUIDE_POSITION_INVALID;
          move->guide_orientation = GIMP_ORIENTATION_UNKNOWN;

          gimp_display_shell_selection_resume (shell);
          return;
        }

      gimp_display_shell_untransform_viewport (shell, &x, &y, &width, &height);

      switch (move->guide_orientation)
        {
        case GIMP_ORIENTATION_HORIZONTAL:
          if ((move->guide_position < y) ||
              (move->guide_position > (y + height)))
            delete_guide = TRUE;
          break;

        case GIMP_ORIENTATION_VERTICAL:
          if ((move->guide_position < x) ||
              (move->guide_position > (x + width)))
            delete_guide = TRUE;
          break;

        default:
          break;
        }

      if (delete_guide)
        {
          if (move->guide)
            {
              gimp_image_remove_guide (image, move->guide, TRUE);
              move->guide = NULL;
            }
        }
      else
        {
          if (move->guide)
            {
              gimp_image_move_guide (image, move->guide,
                                     move->guide_position, TRUE);
            }
          else
            {
              switch (move->guide_orientation)
                {
                case GIMP_ORIENTATION_HORIZONTAL:
                  move->guide = gimp_image_add_hguide (image,
                                                       move->guide_position,
                                                       TRUE);
                  break;

                case GIMP_ORIENTATION_VERTICAL:
                  move->guide = gimp_image_add_vguide (image,
                                                       move->guide_position,
                                                       TRUE);
                  break;

                default:
                  g_assert_not_reached ();
                }
            }
        }

      gimp_display_shell_selection_resume (shell);
      gimp_image_flush (image);

      move->moving_guide      = FALSE;
      move->guide_position    = GUIDE_POSITION_INVALID;
      move->guide_orientation = GIMP_ORIENTATION_UNKNOWN;

      if (move->guide)
        gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display);
    }
  else
    {
      gboolean flush = FALSE;

      if (! config->move_tool_changes_active ||
          (release_type == GIMP_BUTTON_RELEASE_CANCEL))
        {
          if (move->old_active_layer)
            {
              gimp_image_set_active_layer (image, move->old_active_layer);
              move->old_active_layer = NULL;

              flush = TRUE;
            }

          if (move->old_active_vectors)
            {
              gimp_image_set_active_vectors (image, move->old_active_vectors);
              move->old_active_vectors = NULL;

              flush = TRUE;
            }
        }

      if (release_type != GIMP_BUTTON_RELEASE_CANCEL)
        {
          if (move->floating_layer)
            {
              floating_sel_anchor (move->floating_layer);

              flush = TRUE;
            }
        }

      if (flush)
        gimp_image_flush (image);
    }
}
Esempio n. 15
0
static void
gimp_move_tool_button_press (GimpTool            *tool,
                             const GimpCoords    *coords,
                             guint32              time,
                             GdkModifierType      state,
                             GimpButtonPressType  press_type,
                             GimpDisplay         *display)
{
  GimpMoveTool     *move    = GIMP_MOVE_TOOL (tool);
  GimpMoveOptions  *options = GIMP_MOVE_TOOL_GET_OPTIONS (tool);
  GimpDisplayShell *shell   = gimp_display_get_shell (display);
  GimpImage        *image   = gimp_display_get_image (display);

  tool->display = display;

  move->floating_layer     = NULL;
  move->guide              = NULL;
  move->moving_guide       = FALSE;
  move->old_active_layer   = NULL;
  move->old_active_vectors = NULL;

  if (! options->move_current)
    {
      if (options->move_type == GIMP_TRANSFORM_TYPE_PATH)
        {
          GimpVectors *vectors;

          if (gimp_draw_tool_on_vectors (GIMP_DRAW_TOOL (tool), display,
                                         coords, 7, 7,
                                         NULL, NULL, NULL, NULL, NULL,
                                         &vectors))
            {
              move->old_active_vectors =
                gimp_image_get_active_vectors (image);

              gimp_image_set_active_vectors (image, vectors);
            }
          else
            {
              /*  no path picked  */
              return;
            }
        }
      else if (options->move_type == GIMP_TRANSFORM_TYPE_LAYER)
        {
          GimpGuide  *guide;
          GimpLayer  *layer;
          const gint  snap_distance = display->config->snap_distance;

          if (gimp_display_shell_get_show_guides (shell) &&
              (guide = gimp_image_find_guide (image,
                                              coords->x, coords->y,
                                              FUNSCALEX (shell, snap_distance),
                                              FUNSCALEY (shell, snap_distance))))
            {
              move->guide             = guide;
              move->moving_guide      = TRUE;
              move->guide_position    = gimp_guide_get_position (guide);
              move->guide_orientation = gimp_guide_get_orientation (guide);

              gimp_tool_control_set_scroll_lock (tool->control, TRUE);
              gimp_tool_control_set_precision   (tool->control,
                                                 GIMP_CURSOR_PRECISION_PIXEL_BORDER);

              gimp_tool_control_activate (tool->control);

              gimp_display_shell_selection_pause (shell);

              gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display);

              gimp_tool_push_status_length (tool, display,
                                            _("Move Guide: "),
                                            SWAP_ORIENT (move->guide_orientation),
                                            move->guide_position,
                                            NULL);

              return;
            }
          else if ((layer = gimp_image_pick_layer (image,
                                                   coords->x,
                                                   coords->y)))
            {
              if (gimp_image_get_floating_selection (image) &&
                  ! gimp_layer_is_floating_sel (layer))
                {
                  /*  If there is a floating selection, and this aint it,
                   *  use the move tool to anchor it.
                   */
                  move->floating_layer =
                    gimp_image_get_floating_selection (image);

                  gimp_tool_control_activate (tool->control);

                  return;
                }
              else
                {
                  move->old_active_layer = gimp_image_get_active_layer (image);

                  gimp_image_set_active_layer (image, layer);
                }
            }
          else
            {
              /*  no guide and no layer picked  */

              return;
            }
        }
    }

  switch (options->move_type)
    {
    case GIMP_TRANSFORM_TYPE_PATH:
      if (gimp_image_get_active_vectors (image))
        gimp_edit_selection_tool_start (tool, display, coords,
                                        GIMP_TRANSLATE_MODE_VECTORS, TRUE);
      break;

    case GIMP_TRANSFORM_TYPE_SELECTION:
      if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
        gimp_edit_selection_tool_start (tool, display, coords,
                                        GIMP_TRANSLATE_MODE_MASK, TRUE);
      break;

    case GIMP_TRANSFORM_TYPE_LAYER:
      {
        GimpDrawable *drawable = gimp_image_get_active_drawable (image);

        if (GIMP_IS_LAYER_MASK (drawable))
          gimp_edit_selection_tool_start (tool, display, coords,
                                          GIMP_TRANSLATE_MODE_LAYER_MASK, TRUE);
        else if (GIMP_IS_CHANNEL (drawable))
          gimp_edit_selection_tool_start (tool, display, coords,
                                          GIMP_TRANSLATE_MODE_CHANNEL, TRUE);
        else if (GIMP_IS_LAYER (drawable))
          gimp_edit_selection_tool_start (tool, display, coords,
                                          GIMP_TRANSLATE_MODE_LAYER, TRUE);
      }
      break;
    }
}