2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1999-06-02 05:55:02 +00:00
|
|
|
* 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
|
1999-06-02 05:55:02 +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
|
1999-06-02 05:55:02 +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/>.
|
1999-06-02 05:55:02 +00:00
|
|
|
*/
|
2000-12-29 15:22:01 +00:00
|
|
|
|
2000-12-16 21:37:03 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
1999-06-02 05:55:02 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
1999-10-26 18:27:27 +00:00
|
|
|
|
2012-03-17 21:59:10 +01:00
|
|
|
#include <gegl.h>
|
2000-12-29 15:22:01 +00:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2001-01-24 22:36:18 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2002-03-14 17:07:02 +00:00
|
|
|
#include "widgets-types.h"
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2012-01-30 23:52:59 +01:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
#include "core/gimpbrush.h"
|
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
#include "core/gimpgradient.h"
|
|
|
|
#include "core/gimppattern.h"
|
|
|
|
|
2002-03-14 17:07:02 +00:00
|
|
|
#include "gimpdnd.h"
|
2018-10-08 12:39:34 +02:00
|
|
|
#include "gimphelp-ids.h"
|
2002-03-14 17:07:02 +00:00
|
|
|
#include "gimptoolbox.h"
|
|
|
|
#include "gimptoolbox-indicator-area.h"
|
2018-10-08 12:39:34 +02:00
|
|
|
#include "gimpview.h"
|
2014-05-02 03:01:23 +02:00
|
|
|
#include "gimpwidgets-utils.h"
|
2012-01-30 23:52:59 +01:00
|
|
|
#include "gimpwindowstrategy.h"
|
2001-04-17 16:00:27 +00:00
|
|
|
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
1999-06-02 05:55:02 +00:00
|
|
|
|
2000-12-29 15:22:01 +00:00
|
|
|
|
2007-05-17 13:07:52 +00:00
|
|
|
#define CELL_SIZE 24 /* The size of the previews */
|
|
|
|
#define GRAD_CELL_WIDTH 52 /* The width of the gradient preview */
|
|
|
|
#define GRAD_CELL_HEIGHT 12 /* The height of the gradient preview */
|
2004-05-31 20:30:52 +00:00
|
|
|
#define CELL_SPACING 2 /* How much between brush and pattern cells */
|
1999-06-03 06:54:11 +00:00
|
|
|
|
2001-02-12 03:27:28 +00:00
|
|
|
|
1999-10-26 18:27:27 +00:00
|
|
|
static void
|
2003-03-20 15:49:48 +00:00
|
|
|
brush_preview_clicked (GtkWidget *widget,
|
|
|
|
GdkModifierType state,
|
2004-08-24 17:16:46 +00:00
|
|
|
GimpToolbox *toolbox)
|
1999-06-02 05:55:02 +00:00
|
|
|
{
|
2012-01-30 23:52:59 +01:00
|
|
|
GimpContext *context = gimp_toolbox_get_context (toolbox);
|
|
|
|
|
|
|
|
gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (context->gimp)),
|
|
|
|
context->gimp,
|
|
|
|
gimp_dock_get_dialog_factory (GIMP_DOCK (toolbox)),
|
2014-05-02 03:01:23 +02:00
|
|
|
gimp_widget_get_monitor (widget),
|
2012-01-30 23:52:59 +01:00
|
|
|
"gimp-brush-grid|gimp-brush-list");
|
1999-06-02 05:55:02 +00:00
|
|
|
}
|
|
|
|
|
1999-09-05 10:45:07 +00:00
|
|
|
static void
|
2001-02-13 19:53:07 +00:00
|
|
|
brush_preview_drop_brush (GtkWidget *widget,
|
2004-12-31 14:36:30 +00:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2004-08-24 17:16:46 +00:00
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data)
|
1999-09-05 10:45:07 +00:00
|
|
|
{
|
2004-05-31 20:30:52 +00:00
|
|
|
GimpContext *context = GIMP_CONTEXT (data);
|
2001-02-24 02:42:09 +00:00
|
|
|
|
|
|
|
gimp_context_set_brush (context, GIMP_BRUSH (viewable));
|
1999-09-05 10:45:07 +00:00
|
|
|
}
|
|
|
|
|
1999-10-26 18:27:27 +00:00
|
|
|
static void
|
2003-03-20 15:49:48 +00:00
|
|
|
pattern_preview_clicked (GtkWidget *widget,
|
|
|
|
GdkModifierType state,
|
2004-08-24 17:16:46 +00:00
|
|
|
GimpToolbox *toolbox)
|
1999-06-03 06:54:11 +00:00
|
|
|
{
|
2012-01-30 23:52:59 +01:00
|
|
|
GimpContext *context = gimp_toolbox_get_context (toolbox);
|
|
|
|
|
|
|
|
gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (context->gimp)),
|
|
|
|
context->gimp,
|
|
|
|
gimp_dock_get_dialog_factory (GIMP_DOCK (toolbox)),
|
2014-05-02 03:01:23 +02:00
|
|
|
gimp_widget_get_monitor (widget),
|
2012-01-30 23:52:59 +01:00
|
|
|
"gimp-pattern-grid|gimp-pattern-list");
|
1999-06-03 06:54:11 +00:00
|
|
|
}
|
|
|
|
|
1999-09-05 10:45:07 +00:00
|
|
|
static void
|
2001-02-13 19:53:07 +00:00
|
|
|
pattern_preview_drop_pattern (GtkWidget *widget,
|
2004-12-31 14:36:30 +00:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2004-08-24 17:16:46 +00:00
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data)
|
1999-09-05 10:45:07 +00:00
|
|
|
{
|
2004-05-31 20:30:52 +00:00
|
|
|
GimpContext *context = GIMP_CONTEXT (data);
|
2001-02-24 02:42:09 +00:00
|
|
|
|
|
|
|
gimp_context_set_pattern (context, GIMP_PATTERN (viewable));
|
1999-09-05 10:45:07 +00:00
|
|
|
}
|
|
|
|
|
1999-10-26 18:27:27 +00:00
|
|
|
static void
|
2003-03-20 15:49:48 +00:00
|
|
|
gradient_preview_clicked (GtkWidget *widget,
|
|
|
|
GdkModifierType state,
|
2004-08-24 17:16:46 +00:00
|
|
|
GimpToolbox *toolbox)
|
1999-09-01 11:29:39 +00:00
|
|
|
{
|
2012-01-30 23:52:59 +01:00
|
|
|
GimpContext *context = gimp_toolbox_get_context (toolbox);
|
|
|
|
|
|
|
|
gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (context->gimp)),
|
|
|
|
context->gimp,
|
|
|
|
gimp_dock_get_dialog_factory (GIMP_DOCK (toolbox)),
|
2014-05-02 03:01:23 +02:00
|
|
|
gimp_widget_get_monitor (widget),
|
2012-01-30 23:52:59 +01:00
|
|
|
"gimp-gradient-list|gimp-gradient-grid");
|
1999-10-28 15:05:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-02-10 19:35:29 +00:00
|
|
|
gradient_preview_drop_gradient (GtkWidget *widget,
|
2004-12-31 14:36:30 +00:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2004-08-24 17:16:46 +00:00
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data)
|
1999-10-28 15:05:49 +00:00
|
|
|
{
|
2004-05-31 20:30:52 +00:00
|
|
|
GimpContext *context = GIMP_CONTEXT (data);
|
2001-02-24 02:42:09 +00:00
|
|
|
|
|
|
|
gimp_context_set_gradient (context, GIMP_GRADIENT (viewable));
|
1999-09-01 11:29:39 +00:00
|
|
|
}
|
|
|
|
|
2002-03-14 17:07:02 +00:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
1999-06-03 06:54:11 +00:00
|
|
|
GtkWidget *
|
2002-03-14 17:07:02 +00:00
|
|
|
gimp_toolbox_indicator_area_create (GimpToolbox *toolbox)
|
1999-06-03 06:54:11 +00:00
|
|
|
{
|
2002-03-14 17:07:02 +00:00
|
|
|
GimpContext *context;
|
2018-10-08 12:39:34 +02:00
|
|
|
GtkWidget *grid;
|
2004-08-24 17:16:46 +00:00
|
|
|
GtkWidget *brush_view;
|
|
|
|
GtkWidget *pattern_view;
|
|
|
|
GtkWidget *gradient_view;
|
2002-03-14 17:07:02 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_TOOLBOX (toolbox), NULL);
|
1999-09-01 11:29:39 +00:00
|
|
|
|
2009-12-05 21:20:18 +01:00
|
|
|
context = gimp_toolbox_get_context (toolbox);
|
1999-10-26 18:27:27 +00:00
|
|
|
|
2018-10-08 12:39:34 +02:00
|
|
|
grid = gtk_grid_new ();
|
|
|
|
gtk_grid_set_row_spacing (GTK_GRID (grid), CELL_SPACING);
|
|
|
|
gtk_grid_set_column_spacing (GTK_GRID (grid), CELL_SPACING);
|
|
|
|
|
|
|
|
gimp_help_set_help_data (grid, NULL, GIMP_HELP_TOOLBOX_INDICATOR_AREA);
|
1999-10-28 15:05:49 +00:00
|
|
|
|
2004-08-24 17:16:46 +00:00
|
|
|
/* brush view */
|
2001-02-12 03:27:28 +00:00
|
|
|
|
2004-08-24 17:16:46 +00:00
|
|
|
brush_view =
|
2006-08-29 21:44:51 +00:00
|
|
|
gimp_view_new_full_by_types (context,
|
|
|
|
GIMP_TYPE_VIEW, GIMP_TYPE_BRUSH,
|
2007-05-17 13:07:52 +00:00
|
|
|
CELL_SIZE, CELL_SIZE, 1,
|
2004-08-24 17:16:46 +00:00
|
|
|
FALSE, TRUE, TRUE);
|
|
|
|
gimp_view_set_viewable (GIMP_VIEW (brush_view),
|
|
|
|
GIMP_VIEWABLE (gimp_context_get_brush (context)));
|
2018-10-08 12:39:34 +02:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), brush_view, 0, 0, 1, 1);
|
2004-08-24 17:16:46 +00:00
|
|
|
gtk_widget_show (brush_view);
|
2001-02-12 03:27:28 +00:00
|
|
|
|
2004-08-24 17:16:46 +00:00
|
|
|
gimp_help_set_help_data (brush_view,
|
2004-05-31 20:30:52 +00:00
|
|
|
_("The active brush.\n"
|
|
|
|
"Click to open the Brush Dialog."), NULL);
|
2001-02-12 03:27:28 +00:00
|
|
|
|
2005-05-27 16:51:39 +00:00
|
|
|
g_signal_connect_object (context, "brush-changed",
|
2004-08-24 17:16:46 +00:00
|
|
|
G_CALLBACK (gimp_view_set_viewable),
|
|
|
|
brush_view,
|
2004-05-31 20:30:52 +00:00
|
|
|
G_CONNECT_SWAPPED);
|
2001-08-09 16:39:08 +00:00
|
|
|
|
2004-08-24 17:16:46 +00:00
|
|
|
g_signal_connect (brush_view, "clicked",
|
2004-05-31 20:30:52 +00:00
|
|
|
G_CALLBACK (brush_preview_clicked),
|
|
|
|
toolbox);
|
2001-08-09 16:39:08 +00:00
|
|
|
|
2004-08-24 17:16:46 +00:00
|
|
|
gimp_dnd_viewable_dest_add (brush_view,
|
2001-02-12 03:27:28 +00:00
|
|
|
GIMP_TYPE_BRUSH,
|
|
|
|
brush_preview_drop_brush,
|
2001-02-24 02:42:09 +00:00
|
|
|
context);
|
2001-02-12 03:27:28 +00:00
|
|
|
|
2004-08-24 17:16:46 +00:00
|
|
|
/* pattern view */
|
2001-02-12 03:27:28 +00:00
|
|
|
|
2004-08-24 17:16:46 +00:00
|
|
|
pattern_view =
|
2006-08-29 21:44:51 +00:00
|
|
|
gimp_view_new_full_by_types (context,
|
|
|
|
GIMP_TYPE_VIEW, GIMP_TYPE_PATTERN,
|
2007-05-17 13:07:52 +00:00
|
|
|
CELL_SIZE, CELL_SIZE, 1,
|
2004-08-24 17:16:46 +00:00
|
|
|
FALSE, TRUE, TRUE);
|
|
|
|
gimp_view_set_viewable (GIMP_VIEW (pattern_view),
|
|
|
|
GIMP_VIEWABLE (gimp_context_get_pattern (context)));
|
2003-11-24 01:23:45 +00:00
|
|
|
|
2018-10-08 12:39:34 +02:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), pattern_view, 1, 0, 1, 1);
|
2004-08-24 17:16:46 +00:00
|
|
|
gtk_widget_show (pattern_view);
|
2001-02-12 03:27:28 +00:00
|
|
|
|
2004-08-24 17:16:46 +00:00
|
|
|
gimp_help_set_help_data (pattern_view,
|
2004-05-31 20:30:52 +00:00
|
|
|
_("The active pattern.\n"
|
|
|
|
"Click to open the Pattern Dialog."), NULL);
|
2001-02-12 03:27:28 +00:00
|
|
|
|
2005-05-27 16:51:39 +00:00
|
|
|
g_signal_connect_object (context, "pattern-changed",
|
2004-08-24 17:16:46 +00:00
|
|
|
G_CALLBACK (gimp_view_set_viewable),
|
|
|
|
pattern_view,
|
2004-05-31 20:30:52 +00:00
|
|
|
G_CONNECT_SWAPPED);
|
2001-08-09 16:39:08 +00:00
|
|
|
|
2004-08-24 17:16:46 +00:00
|
|
|
g_signal_connect (pattern_view, "clicked",
|
2004-05-31 20:30:52 +00:00
|
|
|
G_CALLBACK (pattern_preview_clicked),
|
|
|
|
toolbox);
|
2001-08-09 16:39:08 +00:00
|
|
|
|
2004-08-24 17:16:46 +00:00
|
|
|
gimp_dnd_viewable_dest_add (pattern_view,
|
2001-02-12 03:27:28 +00:00
|
|
|
GIMP_TYPE_PATTERN,
|
|
|
|
pattern_preview_drop_pattern,
|
2001-02-24 02:42:09 +00:00
|
|
|
context);
|
2001-02-12 03:27:28 +00:00
|
|
|
|
2004-08-24 17:16:46 +00:00
|
|
|
/* gradient view */
|
2001-02-12 03:27:28 +00:00
|
|
|
|
2004-08-24 17:16:46 +00:00
|
|
|
gradient_view =
|
2006-08-29 21:44:51 +00:00
|
|
|
gimp_view_new_full_by_types (context,
|
|
|
|
GIMP_TYPE_VIEW, GIMP_TYPE_GRADIENT,
|
2007-05-17 13:07:52 +00:00
|
|
|
GRAD_CELL_WIDTH, GRAD_CELL_HEIGHT, 1,
|
2004-08-24 17:16:46 +00:00
|
|
|
FALSE, TRUE, TRUE);
|
|
|
|
gimp_view_set_viewable (GIMP_VIEW (gradient_view),
|
|
|
|
GIMP_VIEWABLE (gimp_context_get_gradient (context)));
|
2003-11-24 01:23:45 +00:00
|
|
|
|
2018-10-08 12:39:34 +02:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), gradient_view, 0, 1, 2, 1);
|
2004-08-24 17:16:46 +00:00
|
|
|
gtk_widget_show (gradient_view);
|
2001-02-12 03:27:28 +00:00
|
|
|
|
2004-08-24 17:16:46 +00:00
|
|
|
gimp_help_set_help_data (gradient_view,
|
2004-05-31 20:30:52 +00:00
|
|
|
_("The active gradient.\n"
|
|
|
|
"Click to open the Gradient Dialog."), NULL);
|
2001-02-12 03:27:28 +00:00
|
|
|
|
2005-05-27 16:51:39 +00:00
|
|
|
g_signal_connect_object (context, "gradient-changed",
|
2004-08-24 17:16:46 +00:00
|
|
|
G_CALLBACK (gimp_view_set_viewable),
|
|
|
|
gradient_view,
|
2004-05-31 20:30:52 +00:00
|
|
|
G_CONNECT_SWAPPED);
|
2001-08-09 16:39:08 +00:00
|
|
|
|
2004-08-24 17:16:46 +00:00
|
|
|
g_signal_connect (gradient_view, "clicked",
|
2004-05-31 20:30:52 +00:00
|
|
|
G_CALLBACK (gradient_preview_clicked),
|
|
|
|
toolbox);
|
2001-08-09 16:39:08 +00:00
|
|
|
|
2004-08-24 17:16:46 +00:00
|
|
|
gimp_dnd_viewable_dest_add (gradient_view,
|
2001-02-12 03:27:28 +00:00
|
|
|
GIMP_TYPE_GRADIENT,
|
|
|
|
gradient_preview_drop_gradient,
|
2001-02-24 02:42:09 +00:00
|
|
|
context);
|
2001-02-12 03:27:28 +00:00
|
|
|
|
2018-10-08 12:39:34 +02:00
|
|
|
gtk_widget_show (grid);
|
1999-08-26 20:11:36 +00:00
|
|
|
|
2018-10-08 12:39:34 +02:00
|
|
|
return grid;
|
1999-06-03 06:54:11 +00:00
|
|
|
}
|