PIKApp/app/tools/pikaclonetool.c

114 lines
3.8 KiB
C
Raw Permalink Normal View History

2023-09-26 00:35:21 +02:00
/* 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 "operations/layer-modes/pika-layer-modes.h"
#include "paint/pikaclone.h"
#include "paint/pikacloneoptions.h"
#include "widgets/pikahelp-ids.h"
#include "display/pikadisplay.h"
#include "pikaclonetool.h"
#include "pikacloneoptions-gui.h"
#include "pikatoolcontrol.h"
#include "pika-intl.h"
static gboolean pika_clone_tool_is_alpha_only (PikaPaintTool *paint_tool,
PikaDrawable *drawable);
G_DEFINE_TYPE (PikaCloneTool, pika_clone_tool, PIKA_TYPE_SOURCE_TOOL)
#define parent_class pika_clone_tool_parent_class
void
pika_clone_tool_register (PikaToolRegisterCallback callback,
gpointer data)
{
(* callback) (PIKA_TYPE_CLONE_TOOL,
PIKA_TYPE_CLONE_OPTIONS,
pika_clone_options_gui,
PIKA_PAINT_OPTIONS_CONTEXT_MASK |
2023-12-02 20:03:24 +01:00
PIKA_CONTEXT_PROP_MASK_EXPAND |
2023-09-26 00:35:21 +02:00
PIKA_CONTEXT_PROP_MASK_PATTERN,
"pika-clone-tool",
_("Clone"),
_("Clone Tool: Selectively copy from an image or pattern, using a brush"),
N_("_Clone"), "C",
NULL, PIKA_HELP_TOOL_CLONE,
PIKA_ICON_TOOL_CLONE,
data);
}
static void
pika_clone_tool_class_init (PikaCloneToolClass *klass)
{
PikaPaintToolClass *paint_tool_class = PIKA_PAINT_TOOL_CLASS (klass);
paint_tool_class->is_alpha_only = pika_clone_tool_is_alpha_only;
}
static void
pika_clone_tool_init (PikaCloneTool *clone)
{
PikaTool *tool = PIKA_TOOL (clone);
PikaPaintTool *paint_tool = PIKA_PAINT_TOOL (tool);
PikaSourceTool *source_tool = PIKA_SOURCE_TOOL (tool);
pika_tool_control_set_tool_cursor (tool->control,
PIKA_TOOL_CURSOR_CLONE);
pika_tool_control_set_action_object_2 (tool->control,
"context-pattern-select-set");
paint_tool->status = _("Click to clone");
paint_tool->status_ctrl = _("%s to set a new clone source");
source_tool->status_paint = _("Click to clone");
/* Translators: the translation of "Click" must be the first word */
source_tool->status_set_source = _("Click to set a new clone source");
source_tool->status_set_source_ctrl = _("%s to set a new clone source");
}
static gboolean
pika_clone_tool_is_alpha_only (PikaPaintTool *paint_tool,
PikaDrawable *drawable)
{
PikaPaintOptions *paint_options = PIKA_PAINT_TOOL_GET_OPTIONS (paint_tool);
PikaContext *context = PIKA_CONTEXT (paint_options);
PikaLayerMode paint_mode = pika_context_get_paint_mode (context);
return pika_layer_mode_is_alpha_only (paint_mode);
}