101 lines
3.3 KiB
C
101 lines
3.3 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 "operations/layer-modes/pika-layer-modes.h"
|
|
|
|
#include "paint/pikapaintoptions.h"
|
|
|
|
#include "widgets/pikahelp-ids.h"
|
|
|
|
#include "pikapaintbrushtool.h"
|
|
#include "pikapaintoptions-gui.h"
|
|
#include "pikatoolcontrol.h"
|
|
|
|
#include "pika-intl.h"
|
|
|
|
|
|
static gboolean pika_paintbrush_tool_is_alpha_only (PikaPaintTool *paint_tool,
|
|
PikaDrawable *drawable);
|
|
|
|
|
|
G_DEFINE_TYPE (PikaPaintbrushTool, pika_paintbrush_tool, PIKA_TYPE_BRUSH_TOOL)
|
|
|
|
|
|
void
|
|
pika_paintbrush_tool_register (PikaToolRegisterCallback callback,
|
|
gpointer data)
|
|
{
|
|
(* callback) (PIKA_TYPE_PAINTBRUSH_TOOL,
|
|
PIKA_TYPE_PAINT_OPTIONS,
|
|
pika_paint_options_gui,
|
|
PIKA_PAINT_OPTIONS_CONTEXT_MASK |
|
|
PIKA_CONTEXT_PROP_MASK_EXPAND |
|
|
PIKA_CONTEXT_PROP_MASK_GRADIENT |
|
|
PIKA_CONTEXT_PROP_MASK_PATTERN,
|
|
"pika-paintbrush-tool",
|
|
_("Paintbrush"),
|
|
_("Paintbrush Tool: Paint smooth strokes using a brush"),
|
|
N_("_Paintbrush"), "P",
|
|
NULL, PIKA_HELP_TOOL_PAINTBRUSH,
|
|
PIKA_ICON_TOOL_PAINTBRUSH,
|
|
data);
|
|
}
|
|
|
|
static void
|
|
pika_paintbrush_tool_class_init (PikaPaintbrushToolClass *klass)
|
|
{
|
|
PikaPaintToolClass *paint_tool_class = PIKA_PAINT_TOOL_CLASS (klass);
|
|
|
|
paint_tool_class->is_alpha_only = pika_paintbrush_tool_is_alpha_only;
|
|
}
|
|
|
|
static void
|
|
pika_paintbrush_tool_init (PikaPaintbrushTool *paintbrush)
|
|
{
|
|
PikaTool *tool = PIKA_TOOL (paintbrush);
|
|
|
|
pika_tool_control_set_tool_cursor (tool->control,
|
|
PIKA_TOOL_CURSOR_PAINTBRUSH);
|
|
|
|
pika_paint_tool_enable_color_picker (PIKA_PAINT_TOOL (paintbrush),
|
|
PIKA_COLOR_PICK_TARGET_FOREGROUND);
|
|
}
|
|
|
|
static gboolean
|
|
pika_paintbrush_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);
|
|
}
|