117 lines
4.2 KiB
C
117 lines
4.2 KiB
C
/* PIKA - Photo and Image Kooker Application
|
|
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
|
|
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
|
|
*
|
|
* Original copyright, applying to most contents (license remains unchanged):
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#include <gegl.h>
|
|
#include <gtk/gtk.h>
|
|
|
|
#include "libpikawidgets/pikawidgets.h"
|
|
|
|
#include "tools-types.h"
|
|
|
|
#include "core/pikachannel-select.h"
|
|
#include "core/pikaimage.h"
|
|
|
|
#include "widgets/pikahelp-ids.h"
|
|
|
|
#include "display/pikadisplay.h"
|
|
|
|
#include "pikaellipseselecttool.h"
|
|
#include "pikarectangleselectoptions.h"
|
|
#include "pikatoolcontrol.h"
|
|
|
|
#include "pika-intl.h"
|
|
|
|
|
|
static void pika_ellipse_select_tool_select (PikaRectangleSelectTool *rect_tool,
|
|
PikaChannelOps operation,
|
|
gint x,
|
|
gint y,
|
|
gint w,
|
|
gint h);
|
|
|
|
|
|
G_DEFINE_TYPE (PikaEllipseSelectTool, pika_ellipse_select_tool,
|
|
PIKA_TYPE_RECTANGLE_SELECT_TOOL)
|
|
|
|
#define parent_class pika_ellipse_select_tool_parent_class
|
|
|
|
|
|
void
|
|
pika_ellipse_select_tool_register (PikaToolRegisterCallback callback,
|
|
gpointer data)
|
|
{
|
|
(* callback) (PIKA_TYPE_ELLIPSE_SELECT_TOOL,
|
|
PIKA_TYPE_RECTANGLE_SELECT_OPTIONS,
|
|
pika_rectangle_select_options_gui,
|
|
0,
|
|
"pika-ellipse-select-tool",
|
|
_("Ellipse Select"),
|
|
_("Ellipse Select Tool: Select an elliptical region"),
|
|
N_("_Ellipse Select"), "E",
|
|
NULL, PIKA_HELP_TOOL_ELLIPSE_SELECT,
|
|
PIKA_ICON_TOOL_ELLIPSE_SELECT,
|
|
data);
|
|
}
|
|
|
|
static void
|
|
pika_ellipse_select_tool_class_init (PikaEllipseSelectToolClass *klass)
|
|
{
|
|
PikaRectangleSelectToolClass *rect_tool_class;
|
|
|
|
rect_tool_class = PIKA_RECTANGLE_SELECT_TOOL_CLASS (klass);
|
|
|
|
rect_tool_class->select = pika_ellipse_select_tool_select;
|
|
rect_tool_class->draw_ellipse = TRUE;
|
|
}
|
|
|
|
static void
|
|
pika_ellipse_select_tool_init (PikaEllipseSelectTool *ellipse_select)
|
|
{
|
|
PikaTool *tool = PIKA_TOOL (ellipse_select);
|
|
|
|
pika_tool_control_set_tool_cursor (tool->control,
|
|
PIKA_TOOL_CURSOR_ELLIPSE_SELECT);
|
|
}
|
|
|
|
static void
|
|
pika_ellipse_select_tool_select (PikaRectangleSelectTool *rect_tool,
|
|
PikaChannelOps operation,
|
|
gint x,
|
|
gint y,
|
|
gint w,
|
|
gint h)
|
|
{
|
|
PikaTool *tool = PIKA_TOOL (rect_tool);
|
|
PikaSelectionOptions *options = PIKA_SELECTION_TOOL_GET_OPTIONS (rect_tool);
|
|
PikaImage *image = pika_display_get_image (tool->display);
|
|
|
|
pika_channel_select_ellipse (pika_image_get_mask (image),
|
|
x, y, w, h,
|
|
operation,
|
|
options->antialias,
|
|
options->feather,
|
|
options->feather_radius,
|
|
options->feather_radius,
|
|
TRUE);
|
|
}
|