Beispiel #1
0
static void
gimp_blend_tool_commit (GimpBlendTool *blend_tool)
{
  GimpTool *tool = GIMP_TOOL (blend_tool);

  GimpBlendOptions *options       = GIMP_BLEND_TOOL_GET_OPTIONS (tool);
  GimpPaintOptions *paint_options = GIMP_PAINT_OPTIONS (options);
  GimpContext      *context       = GIMP_CONTEXT (options);
  GimpImage        *image         = gimp_display_get_image (tool->display);
  GimpDrawable     *drawable      = gimp_image_get_active_drawable (image);
  GimpProgress     *progress;
  gint              off_x;
  gint              off_y;

  progress = gimp_progress_start (GIMP_PROGRESS (tool), FALSE,
                                  _("Blending"));

  gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);

  gimp_drawable_blend (drawable,
                       context,
                       gimp_context_get_gradient (context),
                       gimp_context_get_paint_mode (context),
                       options->gradient_type,
                       gimp_context_get_opacity (context),
                       options->offset,
                       paint_options->gradient_options->gradient_repeat,
                       paint_options->gradient_options->gradient_reverse,
                       options->supersample,
                       options->supersample_depth,
                       options->supersample_threshold,
                       options->dither,
                       blend_tool->start_x - off_x,
                       blend_tool->start_y - off_y,
                       blend_tool->end_x - off_x,
                       blend_tool->end_y - off_y,
                       progress);

  if (progress)
    gimp_progress_end (progress);

  gimp_image_flush (image);
}
Beispiel #2
0
static void
gimp_blend_tool_button_release (GimpTool              *tool,
                                const GimpCoords      *coords,
                                guint32                time,
                                GdkModifierType        state,
                                GimpButtonReleaseType  release_type,
                                GimpDisplay           *display)
{
    GimpBlendTool    *blend_tool    = GIMP_BLEND_TOOL (tool);
    GimpBlendOptions *options       = GIMP_BLEND_TOOL_GET_OPTIONS (tool);
    GimpPaintOptions *paint_options = GIMP_PAINT_OPTIONS (options);
    GimpContext      *context       = GIMP_CONTEXT (options);
    GimpImage        *image         = gimp_display_get_image (display);

    gimp_tool_pop_status (tool, display);

    gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));

    gimp_tool_control_halt (tool->control);

    if ((release_type != GIMP_BUTTON_RELEASE_CANCEL) &&
            ((blend_tool->start_x != blend_tool->end_x) ||
             (blend_tool->start_y != blend_tool->end_y)))
    {
        GimpDrawable *drawable = gimp_image_get_active_drawable (image);
        GimpProgress *progress;
        gint          off_x;
        gint          off_y;

        progress = gimp_progress_start (GIMP_PROGRESS (tool),
                                        _("Blending"), FALSE);

        gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);

        gimp_drawable_blend (drawable,
                             context,
                             GIMP_CUSTOM_MODE,
                             gimp_context_get_paint_mode (context),
                             options->gradient_type,
                             gimp_context_get_opacity (context),
                             options->offset,
                             paint_options->gradient_options->gradient_repeat,
                             paint_options->gradient_options->gradient_reverse,
                             options->supersample,
                             options->supersample_depth,
                             options->supersample_threshold,
                             options->dither,
                             blend_tool->start_x - off_x,
                             blend_tool->start_y - off_y,
                             blend_tool->end_x - off_x,
                             blend_tool->end_y - off_y,
                             progress);

        if (progress)
            gimp_progress_end (progress);

        gimp_image_flush (image);
    }

    tool->display  = NULL;
    tool->drawable = NULL;
}