예제 #1
0
static void
gimp_selection_editor_drop_color (GtkWidget     *widget,
                                  gint           x,
                                  gint           y,
                                  const GimpRGB *color,
                                  gpointer       data)
{
  GimpImageEditor         *editor = GIMP_IMAGE_EDITOR (data);
  GimpToolInfo            *tool_info;
  GimpSelectionOptions    *sel_options;
  GimpRegionSelectOptions *options;
  GimpDrawable            *drawable;

  if (! editor->image)
    return;

  tool_info = gimp_get_tool_info (editor->image->gimp,
                                  "gimp-by-color-select-tool");
  if (! tool_info)
    return;

  sel_options = GIMP_SELECTION_OPTIONS (tool_info->tool_options);
  options     = GIMP_REGION_SELECT_OPTIONS (tool_info->tool_options);

  drawable = gimp_image_get_active_drawable (editor->image);

  if (! drawable)
    return;

  gimp_channel_select_by_color (gimp_image_get_mask (editor->image),
                                drawable,
                                options->sample_merged,
                                color,
                                options->threshold,
                                options->select_transparent,
                                options->select_criterion,
                                sel_options->operation,
                                sel_options->antialias,
                                sel_options->feather,
                                sel_options->feather_radius,
                                sel_options->feather_radius);
  gimp_image_flush (editor->image);
}
예제 #2
0
GtkWidget *
gimp_rectangle_select_options_gui (GimpToolOptions *tool_options)
{
  GObject   *config = G_OBJECT (tool_options);
  GtkWidget *vbox   = gimp_selection_options_gui (tool_options);

  /*  the round corners frame  */
  if (tool_options->tool_info->tool_type == GIMP_TYPE_RECTANGLE_SELECT_TOOL)
    {
      GtkWidget *frame;
      GtkWidget *scale;
      GtkWidget *toggle;

      scale = gimp_prop_spin_scale_new (config, "corner-radius",
                                        _("Radius"),
                                        1.0, 10.0, 1);

      frame = gimp_prop_expanding_frame_new (config, "round-corners",
                                             _("Rounded corners"),
                                             scale, NULL);
      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
      gtk_widget_show (frame);

      toggle = GIMP_SELECTION_OPTIONS (tool_options)->antialias_toggle;

      g_object_bind_property (config, "round-corners",
                              toggle, "sensitive",
                              G_BINDING_SYNC_CREATE);
    }

  /*  the rectangle options  */
  {
    GtkWidget *vbox_rectangle;

    vbox_rectangle = gimp_rectangle_options_gui (tool_options);
    gtk_box_pack_start (GTK_BOX (vbox), vbox_rectangle, FALSE, FALSE, 0);
    gtk_widget_show (vbox_rectangle);
  }

  return vbox;
}
예제 #3
0
static gboolean
gimp_selection_view_button_press (GtkWidget           *widget,
                                  GdkEventButton      *bevent,
                                  GimpSelectionEditor *editor)
{
  GimpImageEditor      *image_editor = GIMP_IMAGE_EDITOR (editor);
  GimpViewRenderer     *renderer;
  GimpToolInfo         *tool_info;
  GimpSelectionOptions *options;
  GimpDrawable         *drawable;
  GimpChannelOps        operation = GIMP_CHANNEL_OP_REPLACE;
  gint                  x, y;
  GimpRGB               color;

  if (! image_editor->image)
    return TRUE;

  renderer = GIMP_VIEW (editor->view)->renderer;

  tool_info = gimp_get_tool_info (image_editor->image->gimp,
                                  "gimp-by-color-select-tool");

  if (! tool_info)
    return TRUE;

  options = GIMP_SELECTION_OPTIONS (tool_info->tool_options);

  drawable = gimp_image_get_active_drawable (image_editor->image);

  if (! drawable)
    return TRUE;

  if (bevent->state & GDK_SHIFT_MASK)
    {
      if (bevent->state & GDK_CONTROL_MASK)
        {
          operation = GIMP_CHANNEL_OP_INTERSECT;
        }
      else
        {
          operation = GIMP_CHANNEL_OP_ADD;
        }
    }
  else if (bevent->state & GDK_CONTROL_MASK)
    {
      operation = GIMP_CHANNEL_OP_SUBTRACT;
    }

  x = image_editor->image->width  * bevent->x / renderer->width;
  y = image_editor->image->height * bevent->y / renderer->height;

  if (gimp_image_pick_color (image_editor->image, drawable, x, y,
                             options->sample_merged,
                             FALSE, 0.0,
                             NULL,
                             &color, NULL))
    {
      gimp_channel_select_by_color (gimp_image_get_mask (image_editor->image),
                                    drawable,
                                    options->sample_merged,
                                    &color,
                                    options->threshold,
                                    options->select_transparent,
                                    options->select_criterion,
                                    operation,
                                    options->antialias,
                                    options->feather,
                                    options->feather_radius,
                                    options->feather_radius);
      gimp_image_flush (image_editor->image);
    }

  return TRUE;
}
예제 #4
0
static gboolean
gimp_selection_view_button_press (GtkWidget           *widget,
                                  GdkEventButton      *bevent,
                                  GimpSelectionEditor *editor)
{
  GimpImageEditor         *image_editor = GIMP_IMAGE_EDITOR (editor);
  GimpViewRenderer        *renderer;
  GimpToolInfo            *tool_info;
  GimpSelectionOptions    *sel_options;
  GimpRegionSelectOptions *options;
  GimpDrawable            *drawable;
  GimpChannelOps           operation;
  gint                     x, y;
  GimpRGB                  color;

  if (! image_editor->image)
    return TRUE;

  renderer = GIMP_VIEW (editor->view)->renderer;

  tool_info = gimp_get_tool_info (image_editor->image->gimp,
                                  "gimp-by-color-select-tool");

  if (! tool_info)
    return TRUE;

  sel_options = GIMP_SELECTION_OPTIONS (tool_info->tool_options);
  options     = GIMP_REGION_SELECT_OPTIONS (tool_info->tool_options);

  drawable = gimp_image_get_active_drawable (image_editor->image);

  if (! drawable)
    return TRUE;

  operation = gimp_modifiers_to_channel_op (bevent->state);

  x = gimp_image_get_width  (image_editor->image) * bevent->x / renderer->width;
  y = gimp_image_get_height (image_editor->image) * bevent->y / renderer->height;

  if (gimp_image_pick_color (image_editor->image, drawable, x, y,
                             options->sample_merged,
                             FALSE, 0.0,
                             NULL,
                             &color, NULL))
    {
      gimp_channel_select_by_color (gimp_image_get_mask (image_editor->image),
                                    drawable,
                                    options->sample_merged,
                                    &color,
                                    options->threshold,
                                    options->select_transparent,
                                    options->select_criterion,
                                    operation,
                                    sel_options->antialias,
                                    sel_options->feather,
                                    sel_options->feather_radius,
                                    sel_options->feather_radius);
      gimp_image_flush (image_editor->image);
    }

  return TRUE;
}