2008-01-28 21:08:35 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2008-01-28 21:08:35 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2008-01-28 21:08:35 +00:00
|
|
|
* (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
|
2018-07-11 23:27:07 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2008-01-28 21:08:35 +00:00
|
|
|
*/
|
|
|
|
|
1999-08-26 22:29:37 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2001-12-29 13:26:29 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2002-11-19 20:25:57 +00:00
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
1999-08-26 22:29:37 +00:00
|
|
|
|
2003-02-04 12:50:42 +00:00
|
|
|
#include "gimpressionist.h"
|
2004-07-13 20:58:02 +00:00
|
|
|
#include "infile.h"
|
2006-10-30 21:36:08 +00:00
|
|
|
#include "general.h"
|
2003-02-04 12:50:42 +00:00
|
|
|
|
2001-12-29 13:26:29 +00:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
|
|
|
|
|
|
|
|
2003-02-04 12:50:42 +00:00
|
|
|
#define COLORBUTTONWIDTH 30
|
1999-08-26 22:29:37 +00:00
|
|
|
#define COLORBUTTONHEIGHT 20
|
|
|
|
|
|
|
|
|
|
|
|
#define NUMGENERALBGRADIO 4
|
|
|
|
|
2020-10-31 03:44:21 +01:00
|
|
|
static GtkWidget *general_bg_radio[NUMGENERALBGRADIO];
|
|
|
|
static GtkWidget *general_paint_edges = NULL;
|
|
|
|
static GtkWidget *general_dark_edge_scale = NULL;
|
|
|
|
static GtkWidget *general_tileable;
|
|
|
|
static GtkWidget *general_drop_shadow = NULL;
|
|
|
|
static GtkWidget *general_color_button;
|
|
|
|
static GtkWidget *general_shadow_scale = NULL;
|
|
|
|
static GtkWidget *general_shadow_depth = NULL;
|
|
|
|
static GtkWidget *general_shadow_blur = NULL;
|
|
|
|
static GtkWidget *dev_thresh_scale = NULL;
|
2004-07-02 13:31:25 +00:00
|
|
|
|
2004-09-02 23:28:44 +00:00
|
|
|
static int
|
|
|
|
normalize_bg (int n)
|
2004-07-02 13:31:25 +00:00
|
|
|
{
|
|
|
|
return (!img_has_alpha && (n == 3)) ? 1 : n;
|
|
|
|
}
|
1999-08-26 22:29:37 +00:00
|
|
|
|
2004-09-02 23:28:44 +00:00
|
|
|
static void
|
|
|
|
general_bg_callback (GtkWidget *wg, void *d)
|
1999-08-26 22:29:37 +00:00
|
|
|
{
|
2004-07-29 18:41:47 +00:00
|
|
|
pcvals.general_background_type = normalize_bg (GPOINTER_TO_INT (d));
|
2004-07-02 13:31:25 +00:00
|
|
|
}
|
|
|
|
|
2004-09-02 23:28:44 +00:00
|
|
|
void
|
|
|
|
general_store (void)
|
2004-07-02 13:31:25 +00:00
|
|
|
{
|
2008-06-29 13:34:05 +00:00
|
|
|
pcvals.general_paint_edges = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (general_paint_edges));
|
2020-11-05 17:37:15 +01:00
|
|
|
pcvals.general_dark_edge = gimp_label_spin_get_value (GIMP_LABEL_SPIN (general_dark_edge_scale));
|
2008-06-29 13:34:05 +00:00
|
|
|
pcvals.general_tileable = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (general_tileable));
|
|
|
|
pcvals.general_drop_shadow = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (general_drop_shadow));
|
2020-11-05 17:37:15 +01:00
|
|
|
pcvals.general_shadow_darkness = gimp_label_spin_get_value (GIMP_LABEL_SPIN (general_shadow_scale));
|
|
|
|
pcvals.general_shadow_depth = gimp_label_spin_get_value (GIMP_LABEL_SPIN (general_shadow_depth));
|
|
|
|
pcvals.general_shadow_blur = gimp_label_spin_get_value (GIMP_LABEL_SPIN (general_shadow_blur));
|
|
|
|
pcvals.devthresh = gimp_label_spin_get_value (GIMP_LABEL_SPIN (dev_thresh_scale));
|
2004-07-02 13:31:25 +00:00
|
|
|
}
|
|
|
|
|
2004-09-02 23:28:44 +00:00
|
|
|
int
|
|
|
|
general_bg_type_input (int in)
|
2004-07-25 14:29:27 +00:00
|
|
|
{
|
|
|
|
return CLAMP_UP_TO (in, NUMGENERALBGRADIO);
|
|
|
|
}
|
|
|
|
|
2004-09-02 23:28:44 +00:00
|
|
|
void
|
|
|
|
general_restore (void)
|
2004-07-02 13:31:25 +00:00
|
|
|
{
|
2004-09-02 23:28:44 +00:00
|
|
|
gtk_toggle_button_set_active
|
|
|
|
(GTK_TOGGLE_BUTTON (general_bg_radio[normalize_bg (pcvals.general_background_type)]),
|
|
|
|
TRUE);
|
2004-07-08 15:55:14 +00:00
|
|
|
|
2004-07-17 09:43:46 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (general_paint_edges),
|
|
|
|
pcvals.general_paint_edges);
|
2020-11-05 17:37:15 +01:00
|
|
|
gimp_label_spin_set_value (GIMP_LABEL_SPIN (general_dark_edge_scale),
|
|
|
|
pcvals.general_dark_edge);
|
|
|
|
gimp_label_spin_set_value (GIMP_LABEL_SPIN (general_shadow_scale),
|
|
|
|
pcvals.general_shadow_darkness);
|
2004-07-17 09:43:46 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (general_drop_shadow),
|
|
|
|
pcvals.general_drop_shadow);
|
2020-11-05 17:37:15 +01:00
|
|
|
gimp_label_spin_set_value (GIMP_LABEL_SPIN (general_shadow_depth),
|
|
|
|
pcvals.general_shadow_depth);
|
|
|
|
gimp_label_spin_set_value (GIMP_LABEL_SPIN (general_shadow_blur),
|
|
|
|
pcvals.general_shadow_blur);
|
2004-07-17 09:43:46 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (general_tileable),
|
|
|
|
pcvals.general_tileable);
|
|
|
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (general_color_button),
|
2023-11-24 15:35:50 +01:00
|
|
|
pcvals.color);
|
2020-11-05 17:37:15 +01:00
|
|
|
gimp_label_spin_set_value (GIMP_LABEL_SPIN (dev_thresh_scale),
|
|
|
|
pcvals.devthresh);
|
1999-08-26 22:29:37 +00:00
|
|
|
}
|
|
|
|
|
2004-09-02 23:28:44 +00:00
|
|
|
static void
|
|
|
|
select_color (GtkWidget *widget, gpointer data)
|
1999-08-26 22:29:37 +00:00
|
|
|
{
|
2004-09-02 23:28:44 +00:00
|
|
|
gtk_toggle_button_set_active
|
|
|
|
(GTK_TOGGLE_BUTTON (general_bg_radio[BG_TYPE_SOLID]),
|
|
|
|
TRUE);
|
2004-07-02 13:31:25 +00:00
|
|
|
}
|
|
|
|
|
2023-11-24 15:35:50 +01:00
|
|
|
static void
|
|
|
|
color_changed (GimpColorButton *button,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
g_clear_object (&pcvals.color);
|
|
|
|
pcvals.color = gimp_color_button_get_color (button);
|
|
|
|
}
|
|
|
|
|
2004-09-02 23:28:44 +00:00
|
|
|
static GtkWidget *
|
2008-05-17 13:08:19 +00:00
|
|
|
create_general_button (GtkWidget *box,
|
|
|
|
int idx,
|
|
|
|
const gchar *label,
|
|
|
|
const gchar *help_string,
|
|
|
|
GSList **radio_group)
|
2004-07-02 13:31:25 +00:00
|
|
|
{
|
2004-09-02 23:28:44 +00:00
|
|
|
return create_radio_button (box, idx, general_bg_callback, label,
|
2004-07-17 09:43:46 +00:00
|
|
|
help_string, radio_group, general_bg_radio);
|
1999-08-26 22:29:37 +00:00
|
|
|
}
|
|
|
|
|
2004-09-02 23:28:44 +00:00
|
|
|
void
|
|
|
|
create_generalpage (GtkNotebook *notebook)
|
1999-08-26 22:29:37 +00:00
|
|
|
{
|
|
|
|
GtkWidget *box1, *box2, *box3, *box4, *thispage;
|
2018-05-05 23:37:02 +02:00
|
|
|
GtkWidget *label, *tmpw, *frame, *grid;
|
2004-09-02 23:28:44 +00:00
|
|
|
GSList * radio_group = NULL;
|
1999-08-26 22:29:37 +00:00
|
|
|
|
2002-11-19 20:25:57 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("_General"));
|
1999-08-26 22:29:37 +00:00
|
|
|
|
2011-09-30 12:17:53 +02:00
|
|
|
thispage = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
2004-05-25 15:27:46 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (thispage), 12);
|
2004-09-02 23:28:44 +00:00
|
|
|
gtk_widget_show (thispage);
|
1999-08-26 22:29:37 +00:00
|
|
|
|
2004-05-25 15:27:46 +00:00
|
|
|
frame = gimp_frame_new (_("Background"));
|
2004-09-02 23:28:44 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (thispage), frame, FALSE, FALSE, 0);
|
2002-12-12 20:11:24 +00:00
|
|
|
gtk_widget_show (frame);
|
1999-08-26 22:29:37 +00:00
|
|
|
|
2011-09-30 12:17:53 +02:00
|
|
|
box3 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
2004-09-02 23:28:44 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), box3);
|
2004-05-25 15:27:46 +00:00
|
|
|
gtk_widget_show (box3);
|
1999-08-26 22:29:37 +00:00
|
|
|
|
2004-09-02 23:28:44 +00:00
|
|
|
create_general_button (box3,
|
|
|
|
BG_TYPE_KEEP_ORIGINAL,
|
|
|
|
_("Keep original"),
|
|
|
|
_("Preserve the original image as a background"),
|
|
|
|
&radio_group);
|
2004-07-02 13:31:25 +00:00
|
|
|
|
2004-09-02 23:28:44 +00:00
|
|
|
create_general_button (box3,
|
|
|
|
BG_TYPE_FROM_PAPER,
|
|
|
|
_("From paper"),
|
|
|
|
_("Copy the texture of the selected paper as a background"),
|
|
|
|
&radio_group);
|
2004-03-09 09:56:32 +00:00
|
|
|
|
2011-09-30 12:17:53 +02:00
|
|
|
box4 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
2004-09-02 23:28:44 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (box3), box4, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (box4);
|
1999-08-26 22:29:37 +00:00
|
|
|
|
2004-09-02 23:28:44 +00:00
|
|
|
create_general_button (box4,
|
|
|
|
BG_TYPE_SOLID,
|
|
|
|
_("Solid"),
|
|
|
|
_("Solid colored background"),
|
|
|
|
&radio_group);
|
1999-08-26 22:29:37 +00:00
|
|
|
|
2023-11-24 15:35:50 +01:00
|
|
|
pcvals.color = gegl_color_new ("black");
|
|
|
|
|
2004-07-17 09:43:46 +00:00
|
|
|
general_color_button = gimp_color_button_new (_("Color"),
|
2004-09-02 23:28:44 +00:00
|
|
|
COLORBUTTONWIDTH,
|
|
|
|
COLORBUTTONHEIGHT,
|
2023-11-24 15:35:50 +01:00
|
|
|
pcvals.color,
|
2004-09-02 23:28:44 +00:00
|
|
|
GIMP_COLOR_AREA_FLAT);
|
2004-07-17 09:43:46 +00:00
|
|
|
g_signal_connect (general_color_button, "clicked",
|
2004-09-02 23:28:44 +00:00
|
|
|
G_CALLBACK (select_color), NULL);
|
2005-06-30 16:03:24 +00:00
|
|
|
g_signal_connect (general_color_button, "color-changed",
|
2023-11-24 15:35:50 +01:00
|
|
|
G_CALLBACK (color_changed),
|
2002-11-19 20:25:57 +00:00
|
|
|
&pcvals.color);
|
2004-09-02 23:28:44 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (box4), general_color_button, FALSE, FALSE, 0);
|
2004-07-17 09:43:46 +00:00
|
|
|
gtk_widget_show (general_color_button);
|
2002-11-19 20:25:57 +00:00
|
|
|
|
2004-09-02 23:28:44 +00:00
|
|
|
tmpw = create_general_button (box3,
|
|
|
|
BG_TYPE_TRANSPARENT,
|
|
|
|
_("Transparent"),
|
|
|
|
_("Use a transparent background; Only the strokes painted will be visible"),
|
|
|
|
&radio_group);
|
2004-07-02 13:31:25 +00:00
|
|
|
|
2004-09-02 23:28:44 +00:00
|
|
|
if (!img_has_alpha)
|
1999-08-26 22:29:37 +00:00
|
|
|
gtk_widget_set_sensitive (tmpw, FALSE);
|
|
|
|
|
2004-03-09 09:56:32 +00:00
|
|
|
gtk_toggle_button_set_active
|
2004-07-29 18:41:47 +00:00
|
|
|
(GTK_TOGGLE_BUTTON (general_bg_radio[pcvals.general_background_type]), TRUE);
|
1999-08-26 22:29:37 +00:00
|
|
|
|
2011-09-30 12:17:53 +02:00
|
|
|
box1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
2004-09-02 23:28:44 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (thispage), box1, FALSE, FALSE, 0);
|
1999-08-26 22:29:37 +00:00
|
|
|
gtk_widget_show (box1);
|
|
|
|
|
2011-09-30 12:17:53 +02:00
|
|
|
box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
2004-09-02 23:28:44 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
|
1999-08-26 22:29:37 +00:00
|
|
|
gtk_widget_show (box2);
|
|
|
|
|
2004-09-02 23:28:44 +00:00
|
|
|
tmpw = gtk_check_button_new_with_label ( _("Paint edges"));
|
2004-07-17 09:43:46 +00:00
|
|
|
general_paint_edges = tmpw;
|
1999-08-26 22:29:37 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (box2), tmpw, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (tmpw);
|
2004-09-02 23:28:44 +00:00
|
|
|
gimp_help_set_help_data (tmpw,
|
|
|
|
_("Selects if to place strokes all the way out to the edges of the image"),
|
|
|
|
NULL);
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tmpw),
|
|
|
|
pcvals.general_paint_edges);
|
1999-08-26 22:29:37 +00:00
|
|
|
|
2004-09-02 23:28:44 +00:00
|
|
|
general_tileable = tmpw = gtk_check_button_new_with_label ( _("Tileable"));
|
1999-08-26 22:29:37 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (box2), tmpw, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (tmpw);
|
2004-09-02 23:28:44 +00:00
|
|
|
gimp_help_set_help_data (tmpw,
|
|
|
|
_("Selects if the resulting image should be seamlessly tileable"),
|
|
|
|
NULL);
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tmpw),
|
|
|
|
pcvals.general_tileable);
|
1999-08-26 22:29:37 +00:00
|
|
|
|
2005-08-23 00:18:08 +00:00
|
|
|
tmpw = gtk_check_button_new_with_label ( _("Drop shadow"));
|
2004-07-17 09:43:46 +00:00
|
|
|
general_drop_shadow = tmpw;
|
1999-08-26 22:29:37 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (box2), tmpw, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (tmpw);
|
2004-09-02 23:28:44 +00:00
|
|
|
gimp_help_set_help_data (tmpw,
|
|
|
|
_("Adds a shadow effect to each brush stroke"),
|
|
|
|
NULL);
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tmpw),
|
|
|
|
pcvals.general_drop_shadow);
|
1999-08-26 22:29:37 +00:00
|
|
|
|
2018-05-05 23:37:02 +02:00
|
|
|
grid = gtk_grid_new ();
|
|
|
|
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
|
|
|
|
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
|
|
|
|
gtk_box_pack_start (GTK_BOX (box1), grid, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (grid);
|
2002-12-12 20:11:24 +00:00
|
|
|
|
2020-10-31 03:44:21 +01:00
|
|
|
general_dark_edge_scale =
|
2020-11-01 02:35:03 +01:00
|
|
|
gimp_scale_entry_new (_("Edge darken:"), pcvals.general_dark_edge, 0.0, 1.0, 2);
|
2020-10-31 03:44:21 +01:00
|
|
|
gimp_help_set_help_data (general_dark_edge_scale,
|
|
|
|
_("How much to \"darken\" the edges of each brush stroke"),
|
|
|
|
NULL);
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), general_dark_edge_scale, 0, 0, 3, 1);
|
|
|
|
gtk_widget_show (general_dark_edge_scale);
|
|
|
|
|
|
|
|
general_shadow_scale =
|
2020-11-01 02:35:03 +01:00
|
|
|
gimp_scale_entry_new (_("Shadow darken:"), pcvals.general_shadow_darkness, 0.0, 99.0, 2);
|
2020-11-05 17:37:15 +01:00
|
|
|
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (general_shadow_scale), 0.1, 1.0);
|
2020-10-31 03:44:21 +01:00
|
|
|
gimp_help_set_help_data (general_shadow_scale,
|
|
|
|
_("How much to \"darken\" the drop shadow"),
|
|
|
|
NULL);
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), general_shadow_scale, 0, 1, 3, 1);
|
|
|
|
gtk_widget_show (general_shadow_scale);
|
2002-12-12 20:11:24 +00:00
|
|
|
|
2004-07-17 09:43:46 +00:00
|
|
|
general_shadow_depth =
|
2020-11-01 02:35:03 +01:00
|
|
|
gimp_scale_entry_new (_("Shadow depth:"), pcvals.general_shadow_depth, 0, 99, 0);
|
2020-10-31 03:44:21 +01:00
|
|
|
gimp_help_set_help_data (general_shadow_depth,
|
|
|
|
_("The depth of the drop shadow, i.e. how far apart from the object it should be"),
|
|
|
|
NULL);
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), general_shadow_depth, 0, 2, 3, 1);
|
|
|
|
gtk_widget_show (general_shadow_depth);
|
2002-12-12 20:11:24 +00:00
|
|
|
|
2004-07-17 09:43:46 +00:00
|
|
|
general_shadow_blur =
|
2020-11-01 02:35:03 +01:00
|
|
|
gimp_scale_entry_new (_("Shadow blur:"), pcvals.general_shadow_blur, 0, 99, 0);
|
2020-10-31 03:44:21 +01:00
|
|
|
gimp_help_set_help_data (general_shadow_blur,
|
|
|
|
_("How much to blur the drop shadow"),
|
|
|
|
NULL);
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), general_shadow_blur, 0, 3, 3, 1);
|
|
|
|
gtk_widget_show (general_shadow_blur);
|
|
|
|
|
|
|
|
dev_thresh_scale =
|
2020-11-01 02:35:03 +01:00
|
|
|
gimp_scale_entry_new (_("Deviation threshold:"), pcvals.devthresh, 0.0, 1.0, 2);
|
2020-10-31 03:44:21 +01:00
|
|
|
gimp_help_set_help_data (dev_thresh_scale,
|
|
|
|
_("A bailout-value for adaptive selections"),
|
|
|
|
NULL);
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), dev_thresh_scale, 0, 4, 3, 1);
|
|
|
|
gtk_widget_show (dev_thresh_scale);
|
1999-08-26 22:29:37 +00:00
|
|
|
|
2002-11-19 20:25:57 +00:00
|
|
|
gtk_notebook_append_page_menu (notebook, thispage, label, NULL);
|
1999-08-26 22:29:37 +00:00
|
|
|
}
|