PIKApp/app/tools/pikaairbrushtool.c

154 lines
4.8 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 "paint/pikaairbrush.h"
#include "paint/pikaairbrushoptions.h"
#include "widgets/pikahelp-ids.h"
#include "widgets/pikapropwidgets.h"
#include "pikaairbrushtool.h"
#include "pikapaintoptions-gui.h"
#include "pikapainttool-paint.h"
#include "pikatoolcontrol.h"
#include "pika-intl.h"
static void pika_airbrush_tool_constructed (GObject *object);
static void pika_airbrush_tool_airbrush_stamp (PikaAirbrush *airbrush,
PikaAirbrushTool *airbrush_tool);
static void pika_airbrush_tool_stamp (PikaAirbrushTool *airbrush_tool,
gpointer data);
static GtkWidget * pika_airbrush_options_gui (PikaToolOptions *tool_options);
G_DEFINE_TYPE (PikaAirbrushTool, pika_airbrush_tool, PIKA_TYPE_PAINTBRUSH_TOOL)
#define parent_class pika_airbrush_tool_parent_class
void
pika_airbrush_tool_register (PikaToolRegisterCallback callback,
gpointer data)
{
(* callback) (PIKA_TYPE_AIRBRUSH_TOOL,
PIKA_TYPE_AIRBRUSH_OPTIONS,
pika_airbrush_options_gui,
PIKA_PAINT_OPTIONS_CONTEXT_MASK |
PIKA_CONTEXT_PROP_MASK_EXPAND |
PIKA_CONTEXT_PROP_MASK_PATTERN |
PIKA_CONTEXT_PROP_MASK_GRADIENT,
"pika-airbrush-tool",
_("Airbrush"),
_("Airbrush Tool: Paint using a brush, with variable pressure"),
N_("_Airbrush"), "A",
NULL, PIKA_HELP_TOOL_AIRBRUSH,
PIKA_ICON_TOOL_AIRBRUSH,
data);
}
static void
pika_airbrush_tool_class_init (PikaAirbrushToolClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = pika_airbrush_tool_constructed;
}
static void
pika_airbrush_tool_init (PikaAirbrushTool *airbrush)
{
PikaTool *tool = PIKA_TOOL (airbrush);
pika_tool_control_set_tool_cursor (tool->control, PIKA_TOOL_CURSOR_AIRBRUSH);
}
static void
pika_airbrush_tool_constructed (GObject *object)
{
PikaPaintTool *paint_tool = PIKA_PAINT_TOOL (object);
G_OBJECT_CLASS (parent_class)->constructed (object);
g_signal_connect_object (paint_tool->core, "stamp",
G_CALLBACK (pika_airbrush_tool_airbrush_stamp),
object, 0);
}
static void
pika_airbrush_tool_airbrush_stamp (PikaAirbrush *airbrush,
PikaAirbrushTool *airbrush_tool)
{
PikaPaintTool *paint_tool = PIKA_PAINT_TOOL (airbrush_tool);
pika_paint_tool_paint_push (
paint_tool,
(PikaPaintToolPaintFunc) pika_airbrush_tool_stamp,
NULL);
}
static void
pika_airbrush_tool_stamp (PikaAirbrushTool *airbrush_tool,
gpointer data)
{
PikaPaintTool *paint_tool = PIKA_PAINT_TOOL (airbrush_tool);
pika_airbrush_stamp (PIKA_AIRBRUSH (paint_tool->core));
}
/* tool options stuff */
static GtkWidget *
pika_airbrush_options_gui (PikaToolOptions *tool_options)
{
GObject *config = G_OBJECT (tool_options);
GtkWidget *vbox = pika_paint_options_gui (tool_options);
GtkWidget *button;
GtkWidget *scale;
button = pika_prop_check_button_new (config, "motion-only", NULL);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
scale = pika_prop_spin_scale_new (config, "rate",
1.0, 10.0, 1);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
scale = pika_prop_spin_scale_new (config, "flow",
1.0, 10.0, 1);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
return vbox;
}