gimp/app/brush_edit.c

416 lines
13 KiB
C
Raw Normal View History

/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* brush_edit module Copyright 1998 Jay Cox <jaycox@earthlink.net>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpmath/gimpmath.h"
Makefile.am configure.in added the new library below. 2001-01-24 Michael Natterer <mitch@gimp.org> * Makefile.am * configure.in * gimptool.in: added the new library below. * libgimpwidgets/Makefile.am * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.[ch] * libgimpwidgets/gimpcolorbutton.[ch] * libgimpwidgets/gimpdialog.[ch] * libgimpwidgets/gimpfileselection.[ch] * libgimpwidgets/gimphelpui.[ch] * libgimpwidgets/gimppatheditor.[ch] * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpquerybox.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch] * libgimpwidgets/gimpwidgets.[ch] * libgimpwidgets/gimpwidgets.def * libgimpwidgets/gimpwidgetstypes.h: new shared library. Currently there are some ugly dependencies into libgimp. These will be removed and go to a "libgimpglue" library which will be a library for functions which share a common interface between plug-ins and the app but have different implementations. Include "libgimp/gimpunit.h" from "libgimpwidgets/gimpwidgetstypes.h" to simulate this upcoming separation. * libgimp/Makefile.am * libgimp/gimpchainbutton.[ch] * libgimp/gimpcolorarea.[ch] * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimpfileselection.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimppixmap.[ch] * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: removed from here. * libgimp/gimpui.h * libgimp/gimpuitypes.h * libgimp/makefile.mingw.in * libgimp/makefile.msc: changed accordingly. * app/[all ui files] * app/pdb/palette_cmds.c * app/pdb/tools_cmds.c * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: #include "libgimpwidgets/gimpwidgets.h" and removed useless includes. * app/apptypes.h: #include "libgimpwidgets/gimpwidgetstypes.h" * app/Makefile.am * plug-ins/[all makefiles which link against libgimpui]: link against libgimpwidgets.la * po-libgimp/POTFILES.in: changed file locations.
2001-01-25 06:36:18 +08:00
#include "libgimpwidgets/gimpwidgets.h"
#include "apptypes.h"
#include "gimpbrushgenerated.h"
#include "brush_edit.h"
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
#include "temp_buf.h"
#include "libgimp/gimpintl.h"
struct _BrushEditGeneratedWindow
{
GtkWidget *shell;
GtkWidget *frame;
GtkWidget *preview;
GtkWidget *scale_label;
GtkWidget *options_box;
GtkWidget *name;
GtkAdjustment *radius_data;
GtkAdjustment *hardness_data;
GtkAdjustment *angle_data;
GtkAdjustment *aspect_ratio_data;
/* Brush preview */
GtkWidget *brush_preview;
GimpBrushGenerated *brush;
gint scale;
};
static void brush_edit_close_callback (GtkWidget *widget,
gpointer data);
static void brush_edit_name_activate (GtkWidget *widget,
BrushEditGeneratedWindow *begw);
static void brush_edit_name_focus_out (GtkWidget *wid1,
GtkWidget *wid2,
BrushEditGeneratedWindow *begw);
static void brush_edit_update_brush (GtkAdjustment *adjustment,
BrushEditGeneratedWindow *begw);
static gint brush_edit_preview_resize (GtkWidget *widget,
GtkAllocation *allocation,
BrushEditGeneratedWindow *begw);
static void brush_edit_clear_preview (BrushEditGeneratedWindow *begw);
static gint brush_edit_brush_dirty (GimpBrush *brush,
BrushEditGeneratedWindow *begw);
static void brush_name_changed_callback (GtkWidget *widget,
BrushEditGeneratedWindow *begw);
/* public functions */
BrushEditGeneratedWindow *
1999-10-27 02:27:27 +08:00
brush_edit_generated_new (void)
{
1999-10-27 02:27:27 +08:00
BrushEditGeneratedWindow *begw;
GtkWidget *vbox;
GtkWidget *slider;
GtkWidget *table;
begw = g_new0 (BrushEditGeneratedWindow, 1);
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
begw->shell = gimp_dialog_new (_("Brush Editor"), "generated_brush_editor",
gimp_standard_help_func,
1999-10-04 18:02:46 +08:00
"dialogs/brush_editor.html",
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
GTK_WIN_POS_NONE,
FALSE, TRUE, FALSE,
"_delete_event_", brush_edit_close_callback,
begw, NULL, NULL, TRUE, TRUE,
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
NULL);
gtk_widget_hide (GTK_WIDGET (g_list_nth_data (gtk_container_children (GTK_CONTAINER (GTK_DIALOG (begw->shell)->vbox)), 0)));
gtk_widget_hide (GTK_DIALOG (begw->shell)->action_area);
vbox = gtk_vbox_new (FALSE, 1);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (begw->shell)->vbox), vbox);
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
/* Brush's name */
begw->name = gtk_entry_new ();
gtk_box_pack_start (GTK_BOX (vbox), begw->name, FALSE, FALSE, 0);
gtk_widget_show (begw->name);
gtk_signal_connect (GTK_OBJECT (begw->name), "activate",
GTK_SIGNAL_FUNC (brush_edit_name_activate),
begw);
gtk_signal_connect (GTK_OBJECT (begw->name), "focus_out_event",
GTK_SIGNAL_FUNC (brush_edit_name_focus_out),
begw);
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
/* brush's preview widget w/frame */
begw->frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (begw->frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (vbox), begw->frame, TRUE, TRUE, 0);
begw->preview = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
gtk_preview_size (GTK_PREVIEW (begw->preview), 125, 100);
gtk_signal_connect_after (GTK_OBJECT (begw->frame), "size_allocate",
GTK_SIGNAL_FUNC (brush_edit_preview_resize),
begw);
gtk_container_add (GTK_CONTAINER (begw->frame), begw->preview);
gtk_widget_show (begw->preview);
gtk_widget_show (begw->frame);
/* table for sliders/labels */
begw->scale_label = gtk_label_new ("-1:1");
gtk_box_pack_start (GTK_BOX (vbox), begw->scale_label, FALSE, FALSE, 0);
1999-10-27 02:27:27 +08:00
gtk_widget_show (begw->scale_label);
begw->scale = -1;
/* table for sliders/labels */
table = gtk_table_new (4, 2, FALSE);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
1999-10-27 02:27:27 +08:00
/* brush radius scale */
begw->radius_data =
GTK_ADJUSTMENT (gtk_adjustment_new (10.0, 0.0, 100.0, 0.1, 1.0, 0.0));
slider = gtk_hscale_new (begw->radius_data);
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP);
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
gtk_signal_connect (GTK_OBJECT (begw->radius_data), "value_changed",
GTK_SIGNAL_FUNC (brush_edit_update_brush),
begw);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
1999-10-27 02:27:27 +08:00
_("Radius:"), 1.0, 1.0,
slider, 1, FALSE);
1999-10-27 02:27:27 +08:00
/* brush hardness scale */
begw->hardness_data =
GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 1.0, 0.01, 0.01, 0.0));
slider = gtk_hscale_new (begw->hardness_data);
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP);
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
gtk_signal_connect (GTK_OBJECT (begw->hardness_data), "value_changed",
GTK_SIGNAL_FUNC (brush_edit_update_brush),
begw);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
1999-10-27 02:27:27 +08:00
_("Hardness:"), 1.0, 1.0,
slider, 1, FALSE);
1999-10-27 02:27:27 +08:00
/* brush aspect ratio scale */
begw->aspect_ratio_data =
GTK_ADJUSTMENT (gtk_adjustment_new (1.0, 1.0, 20.0, 0.1, 1.0, 0.0));
slider = gtk_hscale_new (begw->aspect_ratio_data);
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP);
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
gtk_signal_connect (GTK_OBJECT (begw->aspect_ratio_data), "value_changed",
GTK_SIGNAL_FUNC (brush_edit_update_brush),
begw);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 3,
1999-10-27 02:27:27 +08:00
_("Aspect Ratio:"), 1.0, 1.0,
slider, 1, FALSE);
1999-10-27 02:27:27 +08:00
/* brush angle scale */
begw->angle_data =
GTK_ADJUSTMENT (gtk_adjustment_new (00.0, 0.0, 180.0, 0.1, 1.0, 0.0));
slider = gtk_hscale_new (begw->angle_data);
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP);
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
gtk_signal_connect (GTK_OBJECT (begw->angle_data), "value_changed",
GTK_SIGNAL_FUNC (brush_edit_update_brush),
begw);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
1999-10-27 02:27:27 +08:00
_("Angle:"), 1.0, 1.0,
slider, 1, FALSE);
1999-10-27 02:27:27 +08:00
gtk_table_set_row_spacings (GTK_TABLE (table), 3);
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
gtk_widget_show (table);
gtk_widget_show (vbox);
gtk_widget_show (begw->shell);
return begw;
}
void
brush_edit_generated_set_brush (BrushEditGeneratedWindow *begw,
GimpBrush *gbrush)
{
GimpBrushGenerated *brush = NULL;
g_return_if_fail (begw != NULL);
if (begw->brush == (GimpBrushGenerated *) gbrush)
return;
if (begw->brush)
{
gtk_signal_disconnect_by_data (GTK_OBJECT (begw->brush), begw);
gtk_object_unref (GTK_OBJECT (begw->brush));
begw->brush = NULL;
}
if (!gbrush || !GIMP_IS_BRUSH_GENERATED (gbrush))
{
if (GTK_WIDGET_VISIBLE (begw->shell))
gtk_widget_hide (begw->shell);
return;
}
brush = GIMP_BRUSH_GENERATED (gbrush);
gtk_signal_connect (GTK_OBJECT (brush), "invalidate_preview",
GTK_SIGNAL_FUNC (brush_edit_brush_dirty),
begw);
gtk_signal_connect (GTK_OBJECT (brush), "name_changed",
GTK_SIGNAL_FUNC (brush_name_changed_callback),
begw);
gtk_adjustment_set_value (GTK_ADJUSTMENT (begw->radius_data),
gimp_brush_generated_get_radius (brush));
gtk_adjustment_set_value (GTK_ADJUSTMENT (begw->hardness_data),
gimp_brush_generated_get_hardness (brush));
gtk_adjustment_set_value (GTK_ADJUSTMENT (begw->angle_data),
gimp_brush_generated_get_angle (brush));
gtk_adjustment_set_value (GTK_ADJUSTMENT (begw->aspect_ratio_data),
gimp_brush_generated_get_aspect_ratio (brush));
gtk_entry_set_text (GTK_ENTRY (begw->name),
gimp_object_get_name (GIMP_OBJECT (gbrush)));
begw->brush = brush;
gtk_object_ref (GTK_OBJECT (begw->brush));
brush_edit_brush_dirty (GIMP_BRUSH (brush), begw);
if (! GTK_WIDGET_VISIBLE (begw->shell))
gtk_widget_show (begw->shell);
else
gdk_window_raise (begw->shell->window);
}
/* private functions */
static void
brush_edit_close_callback (GtkWidget *widget,
gpointer data)
{
BrushEditGeneratedWindow *begw = (BrushEditGeneratedWindow *) data;
if (GTK_WIDGET_VISIBLE (begw->shell))
gtk_widget_hide (begw->shell);
}
static void
brush_edit_name_activate (GtkWidget *widget,
BrushEditGeneratedWindow *begw)
{
gchar *entry_text;
entry_text = gtk_entry_get_text (GTK_ENTRY (widget));
gimp_object_set_name (GIMP_OBJECT (begw->brush), entry_text);
}
static void
brush_edit_name_focus_out (GtkWidget *wid1,
GtkWidget *wid2,
BrushEditGeneratedWindow *begw)
{
brush_edit_name_activate (wid1, begw);
}
static void
brush_edit_update_brush (GtkAdjustment *adjustment,
BrushEditGeneratedWindow *begw)
{
if (begw->brush &&
((begw->radius_data->value
!= gimp_brush_generated_get_radius (begw->brush))
|| (begw->hardness_data->value
!= gimp_brush_generated_get_hardness (begw->brush))
|| (begw->aspect_ratio_data->value
!= gimp_brush_generated_get_aspect_ratio (begw->brush))
|| (begw->angle_data->value
!= gimp_brush_generated_get_angle (begw->brush))))
{
gimp_brush_generated_freeze (begw->brush);
gimp_brush_generated_set_radius (begw->brush,
begw->radius_data->value);
gimp_brush_generated_set_hardness (begw->brush,
begw->hardness_data->value);
gimp_brush_generated_set_aspect_ratio (begw->brush,
begw->aspect_ratio_data->value);
gimp_brush_generated_set_angle (begw->brush,
begw->angle_data->value);
gimp_brush_generated_thaw (begw->brush);
}
}
static gint
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
brush_edit_preview_resize (GtkWidget *widget,
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
GtkAllocation *allocation,
BrushEditGeneratedWindow *begw)
{
gtk_preview_size (GTK_PREVIEW (begw->preview),
widget->allocation.width - 4,
widget->allocation.height - 4);
/* update the display */
if (begw->brush)
brush_edit_brush_dirty (GIMP_BRUSH (begw->brush), begw);
return FALSE;
}
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
static void
brush_edit_clear_preview (BrushEditGeneratedWindow *begw)
{
guchar *buf;
gint i;
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
buf = g_new (guchar, begw->preview->requisition.width);
/* Set the buffer to white */
memset (buf, 255, begw->preview->requisition.width);
/* Set the image buffer to white */
for (i = 0; i < begw->preview->requisition.height; i++)
gtk_preview_draw_row (GTK_PREVIEW (begw->preview), buf, 0, i,
begw->preview->requisition.width);
g_free (buf);
}
static gint
brush_edit_brush_dirty (GimpBrush *brush,
BrushEditGeneratedWindow *begw)
{
gint x, y, width, yend, ystart, xo;
gint scale;
gchar *src, *buf;
brush_edit_clear_preview (begw);
if (brush == NULL || brush->mask == NULL)
return TRUE;
scale = MAX (ceil (brush->mask->width/
(float) begw->preview->requisition.width),
ceil (brush->mask->height/
(float) begw->preview->requisition.height));
ystart = 0;
xo = begw->preview->requisition.width/2 - brush->mask->width/(2*scale);
ystart = begw->preview->requisition.height/2 - brush->mask->height/(2*scale);
yend = ystart + brush->mask->height/(scale);
width = CLAMP (brush->mask->width/scale, 0, begw->preview->requisition.width);
buf = g_new (gchar, width);
src = (gchar *) temp_buf_data (brush->mask);
for (y = ystart; y < yend; y++)
{
/* Invert the mask for display.
*/
for (x = 0; x < width; x++)
buf[x] = 255 - src[x*scale];
gtk_preview_draw_row (GTK_PREVIEW (begw->preview), (guchar *)buf, xo, y,
width);
src += brush->mask->width*scale;
}
g_free (buf);
if (begw->scale != scale)
{
gchar str[255];
begw->scale = scale;
g_snprintf (str, sizeof (str), "%d:1", scale);
gtk_label_set_text (GTK_LABEL (begw->scale_label), str);
gtk_widget_draw (begw->scale_label, NULL);
}
gtk_widget_draw (begw->preview, NULL);
return TRUE;
}
static void
brush_name_changed_callback (GtkWidget *widget,
BrushEditGeneratedWindow *begw)
{
gtk_entry_set_text (GTK_ENTRY (begw->name),
gimp_object_get_name (GIMP_OBJECT (begw->brush)));
}