gimp/app/brush_select.c

1895 lines
52 KiB
C
Raw Normal View History

1997-11-25 06:05:25 +08:00
/* The GIMP -- an image manipulation program
* 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 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.
1997-11-25 06:05:25 +08:00
*/
#include "config.h"
1997-11-25 06:05:25 +08:00
#include <string.h>
#include <gtk/gtk.h>
#include "apptypes.h"
1997-11-25 06:05:25 +08:00
#include "appenv.h"
#include "brush_scale.h"
1999-10-27 02:27:27 +08:00
#include "brush_edit.h"
#include "brush_select.h"
#include "dialog_handler.h"
#include "gimpbrushgenerated.h"
#include "gimpbrushlist.h"
#include "gimpbrushpipe.h"
#include "gimpcontext.h"
1999-10-28 23:05:49 +08:00
#include "gimpdnd.h"
#include "gimplist.h"
#include "gimprc.h"
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
#include "gimpui.h"
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
#include "paint_options.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 "procedural_db.h"
#include "session.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/gimphelpui.h"
1997-11-25 06:05:25 +08:00
#include "libgimp/gimpintl.h"
1997-11-25 06:05:25 +08:00
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
#define MIN_CELL_SIZE 25
#define MAX_CELL_SIZE 25 /* disable variable brush preview size */
1997-11-25 06:05:25 +08:00
#define STD_BRUSH_COLUMNS 5
#define STD_BRUSH_ROWS 5
/* how long to wait after mouse-down before showing brush popup */
#define POPUP_DELAY_MS 150
#define MAX_WIN_WIDTH(bsp) (MIN_CELL_SIZE * ((bsp)->NUM_BRUSH_COLUMNS))
#define MAX_WIN_HEIGHT(bsp) (MIN_CELL_SIZE * ((bsp)->NUM_BRUSH_ROWS))
#define MARGIN_WIDTH 1
#define MARGIN_HEIGHT 1
1997-11-25 06:05:25 +08:00
#define BRUSH_EVENT_MASK GDK_EXPOSURE_MASK | \
GDK_BUTTON_PRESS_MASK | \
GDK_BUTTON_RELEASE_MASK | \
GDK_BUTTON1_MOTION_MASK | \
GDK_ENTER_NOTIFY_MASK
/* the pixmaps for the [scale|pipe]_indicators */
1999-10-27 02:27:27 +08:00
#define indicator_width 7
#define indicator_height 7
#define WHT {255, 255, 255}
#define BLK { 0, 0, 0}
#define RED {255, 127, 127}
1997-11-25 06:05:25 +08:00
/* local function prototypes */
1999-10-28 23:05:49 +08:00
static void brush_change_callbacks (BrushSelect *bsp,
gboolean closing);
static GimpBrush * brush_select_drag_brush (GtkWidget *widget,
gpointer data);
1999-10-28 23:05:49 +08:00
static void brush_select_drop_brush (GtkWidget *widget,
GimpBrush *brush,
gpointer data);
1999-10-27 02:27:27 +08:00
static void brush_select_brush_changed (GimpContext *context,
GimpBrush *brush,
BrushSelect *bsp);
static void brush_select_opacity_changed (GimpContext *context,
gdouble opacity,
BrushSelect *bsp);
static void brush_select_paint_mode_changed (GimpContext *context,
LayerModeEffects paint_mode,
BrushSelect *bsp);
static void brush_select_select (BrushSelect *bsp,
GimpBrush *brush);
static void brush_select_brush_dirty_callback (GimpBrush *brush,
BrushSelect *bsp);
static void connect_signals_to_brush (GimpBrush *brush,
BrushSelect *bsp);
static void disconnect_signals_from_brush (GimpBrush *brush,
BrushSelect *bsp);
static void brush_added_callback (GimpBrushList *list,
GimpBrush *brush,
BrushSelect *bsp);
static void brush_removed_callback (GimpBrushList *list,
GimpBrush *brush,
BrushSelect *bsp);
static void draw_brush_popup (GtkPreview *preview,
GimpBrush *brush,
gint width,
gint height);
static gint brush_popup_anim_timeout (gpointer data);
static gboolean brush_popup_timeout (gpointer data);
static void brush_popup_open (BrushSelect *,
gint, gint, GimpBrush *);
static void brush_popup_close (BrushSelect *);
static void display_setup (BrushSelect *);
static void clear_brush (BrushSelect *,
1999-10-27 02:27:27 +08:00
GimpBrush *, gint, gint);
static void display_brush (BrushSelect *,
GimpBrush *, gint, gint,
gboolean);
1999-10-27 02:27:27 +08:00
static void do_display_brush (GimpBrush *brush,
BrushSelect *bsp);
static void display_brushes (BrushSelect *);
static void brush_select_show_selected (BrushSelect *, gint, gint);
static void update_active_brush_field (BrushSelect *);
static void preview_calc_scrollbar (BrushSelect *);
static gint brush_select_resize (GtkWidget *, GdkEvent *,
BrushSelect *);
static gint brush_select_events (GtkWidget *, GdkEvent *,
BrushSelect *);
/* static void brush_select_map_callback (GtkWidget *,
BrushSelect *); */
static void brush_select_scroll_update (GtkAdjustment *, gpointer);
static void opacity_scale_update (GtkAdjustment *, gpointer);
static void paint_mode_menu_callback (GtkWidget *, gpointer);
static void spacing_scale_update (GtkAdjustment *, gpointer);
static void brush_select_close_callback (GtkWidget *, gpointer);
static void brush_select_refresh_callback (GtkWidget *, gpointer);
static void brush_select_new_brush_callback (GtkWidget *, gpointer);
static void brush_select_edit_brush_callback (GtkWidget *, gpointer);
static void brush_select_delete_brush_callback (GtkWidget *, gpointer);
1999-10-28 23:05:49 +08:00
static unsigned char scale_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, BLK, BLK, BLK, BLK, BLK, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT }
};
static unsigned char pipe_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, WHT, WHT, WHT, RED },
{ WHT, WHT, WHT, WHT, WHT, RED, RED },
{ WHT, WHT, WHT, WHT, RED, RED, RED },
{ WHT, WHT, WHT, RED, RED, RED, RED },
{ WHT, WHT, RED, RED, RED, RED, RED },
{ WHT, RED, RED, RED, RED, RED, RED }
};
static unsigned char scale_pipe_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, RED },
{ WHT, WHT, WHT, BLK, WHT, RED, RED },
{ WHT, BLK, BLK, BLK, BLK, BLK, RED },
{ WHT, WHT, WHT, BLK, RED, RED, RED },
{ WHT, WHT, RED, BLK, RED, RED, RED },
{ WHT, RED, RED, RED, RED, RED, RED }
};
/* dnd stuff */
static GtkTargetEntry preview_target_table[] =
{
GIMP_TARGET_BRUSH
};
static guint preview_n_targets = (sizeof (preview_target_table) /
sizeof (preview_target_table[0]));
1999-10-27 02:27:27 +08:00
/* The main brush selection dialog */
BrushSelect *brush_select_dialog = NULL;
1997-11-25 06:05:25 +08:00
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
/* local variables */
1997-11-25 06:05:25 +08:00
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
/* List of active dialogs */
gave parasite undo a MISC_UNDO class for now so it compiles * app/gimpdrawable.c: gave parasite undo a MISC_UNDO class for now so it compiles * app/tools_cmds.c: fix crop invoker to give correct args to crop_image * app/color_cmds.c: s/GRAY/GRAY_LUT/g; * app/brush_select.[ch]: removed PDB procs, export brush_active_dialogs, brush_select_dialog, s/active_dialogs/brush_active_dialogs/ * app/gimage_cmds.[ch] * app/channel_ops.[ch]: removed channel ops PDB procs, moved duplicate function from gimage_cmds to channel_ops, export offset and duplicate * app/gimpbrushlist.[ch]: removed PDB procs * app/gradient.[ch]: removed PDB procs, * app/gradient_header.h: exported G_SAMPLE, GradSelect, num_gradients, grad_active_dialogs, gradient_select_dialog * app/gradient_select.c: removed PDB procs, s/active_dialogs/grad_active_dialogs/ * app/patterns.[ch]: removed PDB procs * app/pattern_select.[ch]: removed PDB procs, s/active_dialogs/pattern_active_dialogs/ * app/procedural_db.c: removed PDB procs and supporting functions * app/procedrual_db.h: fiddled with enums * app/channel_cmds.[ch] * app/drawable_cmds.[ch] * app/parasite_cmds.[ch]: pdbgenned now, removed header files * app/gimpparasite.c: minor cleanup * app/internal_procs.c: use pdbgen stuff * app/tools_cmds.c * app/text_tool_cmds.c: updated from pdbgen * app/brushes_cmds.c * app/brush_select_cmds.c * app/gradient_cmds.c * app/gradient_select_cmds.c * app/patterns_cmds.c * app/pattern_select_cmds.c * app/procedural_db_cmds.c: new pdbgen files * app/Makefile.am: file shuffle (see above) -Yosh
1999-04-24 04:54:02 +08:00
GSList *brush_active_dialogs = NULL;
1997-11-25 06:05:25 +08:00
1999-10-27 02:27:27 +08:00
/* Brush editor dialog */
static BrushEditGeneratedWindow *brush_edit_generated_dialog;
1999-10-27 02:27:27 +08:00
void
brush_dialog_create (void)
{
if (! brush_select_dialog)
{
brush_select_dialog = brush_select_new (NULL, NULL, 0.0, 0, 0);
}
else
{
if (!GTK_WIDGET_VISIBLE (brush_select_dialog->shell))
gtk_widget_show (brush_select_dialog->shell);
else
gdk_window_raise (brush_select_dialog->shell->window);
}
}
void
brush_dialog_free (void)
1999-10-27 02:27:27 +08:00
{
if (brush_select_dialog)
{
1999-10-28 23:05:49 +08:00
session_get_window_info (brush_select_dialog->shell,
&brush_select_session_info);
/* save the size of the preview */
brush_select_session_info.width =
brush_select_dialog->preview->allocation.width;
brush_select_session_info.height =
brush_select_dialog->preview->allocation.height;
1999-10-27 02:27:27 +08:00
brush_select_free (brush_select_dialog);
brush_select_dialog = NULL;
}
}
/* If title == NULL then it is the main brush dialog */
1999-10-27 02:27:27 +08:00
BrushSelect *
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
brush_select_new (gchar *title,
/* These are the required initial vals
* If init_name == NULL then use current brush
*/
gchar *init_name,
gdouble init_opacity,
gint init_spacing,
gint init_mode)
1997-11-25 06:05:25 +08:00
{
1999-10-27 02:27:27 +08:00
BrushSelect *bsp;
1997-11-25 06:05:25 +08:00
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *frame;
1997-11-25 06:05:25 +08:00
GtkWidget *sbar;
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
GtkWidget *sep;
GtkWidget *table;
1997-11-25 06:05:25 +08:00
GtkWidget *util_box;
GtkWidget *slider;
1999-10-27 02:27:27 +08:00
GtkWidget *button;
1999-10-27 02:27:27 +08:00
GimpBrush *active = NULL;
1997-11-25 06:05:25 +08:00
1999-10-28 23:05:49 +08:00
static gboolean first_call = TRUE;
1997-11-25 06:05:25 +08:00
1999-10-27 02:27:27 +08:00
bsp = g_new (BrushSelect, 1);
bsp->callback_name = NULL;
bsp->dnd_brush = NULL;
1999-10-27 02:27:27 +08:00
bsp->brush_popup = NULL;
bsp->popup_timeout_tag = 0;
bsp->popup_anim_timeout_tag = 0;
bsp->scroll_offset = 0;
bsp->old_row = 0;
bsp->old_col = 0;
bsp->NUM_BRUSH_COLUMNS = STD_BRUSH_COLUMNS;
bsp->NUM_BRUSH_ROWS = STD_BRUSH_ROWS;
bsp->redraw = TRUE;
bsp->freeze = FALSE;
/* The shell */
bsp->shell = gimp_dialog_new (title ? title : _("Brush Selection"),
"brush_selection",
gimp_standard_help_func,
"dialogs/brush_selection.html",
title ? GTK_WIN_POS_MOUSE : GTK_WIN_POS_NONE,
1999-10-27 02:27:27 +08:00
FALSE, TRUE, FALSE,
_("Refresh"), brush_select_refresh_callback,
bsp, NULL, NULL, FALSE, FALSE,
1999-10-27 02:27:27 +08:00
_("Close"), brush_select_close_callback,
bsp, NULL, NULL, TRUE, TRUE,
1999-10-27 02:27:27 +08:00
NULL);
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
if (title)
{
1999-10-27 02:27:27 +08:00
bsp->context = gimp_context_new (title, NULL);
}
else
{
1999-10-28 23:05:49 +08:00
bsp->context = gimp_context_get_user ();
1999-10-27 02:27:27 +08:00
session_set_window_geometry (bsp->shell, &brush_select_session_info,
FALSE);
1999-10-28 23:05:49 +08:00
dialog_register (bsp->shell);
1999-10-27 02:27:27 +08:00
}
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
1999-10-28 23:05:49 +08:00
if (no_data && first_call)
1999-10-27 02:27:27 +08:00
brushes_init (FALSE);
1999-10-28 23:05:49 +08:00
first_call = FALSE;
1999-10-27 02:27:27 +08:00
if (title && init_name && strlen (init_name))
{
active = gimp_brush_list_get_brush (brush_list, init_name);
}
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
else
{
1999-10-27 02:27:27 +08:00
active = gimp_context_get_brush (gimp_context_get_user ());
}
1997-11-25 06:05:25 +08:00
1999-10-27 02:27:27 +08:00
if (!active)
{
active = gimp_context_get_brush (gimp_context_get_standard ());
}
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
1999-10-27 02:27:27 +08:00
if (title)
{
gimp_context_set_brush (bsp->context, active);
gimp_context_set_paint_mode (bsp->context, init_mode);
gimp_context_set_opacity (bsp->context, init_opacity);
bsp->spacing_value = init_spacing;
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
}
1997-11-25 06:05:25 +08:00
/* The main vbox */
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (bsp->shell)->vbox), vbox);
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
/* The horizontal box containing the brush list & options box */
1997-11-25 06:05:25 +08:00
hbox = gtk_hbox_new (FALSE, 2);
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
gtk_container_add (GTK_CONTAINER (vbox), hbox);
/* A place holder for paint mode switching */
bsp->left_box = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), bsp->left_box, TRUE, TRUE, 0);
1999-10-27 02:27:27 +08:00
/* The horizontal box containing preview & scrollbar */
bsp->brush_selection_box = gtk_hbox_new (FALSE, 2);
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
gtk_container_add (GTK_CONTAINER (bsp->left_box), bsp->brush_selection_box);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (bsp->brush_selection_box), frame,
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
TRUE, TRUE, 0);
1999-10-27 02:27:27 +08:00
bsp->sbar_data =
GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, MAX_WIN_HEIGHT (bsp),
1, 1, MAX_WIN_HEIGHT (bsp)));
1997-11-25 06:05:25 +08:00
sbar = gtk_vscrollbar_new (bsp->sbar_data);
gtk_signal_connect (GTK_OBJECT (bsp->sbar_data), "value_changed",
1999-10-27 02:27:27 +08:00
GTK_SIGNAL_FUNC (brush_select_scroll_update),
bsp);
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
gtk_box_pack_start (GTK_BOX (bsp->brush_selection_box), sbar, FALSE, FALSE, 0);
1997-11-25 06:05:25 +08:00
/* Create the brush preview window and the underlying image */
/* Get the maximum brush extents */
1999-10-27 02:27:27 +08:00
bsp->cell_width = MIN_CELL_SIZE;
bsp->cell_height = MIN_CELL_SIZE;
1997-11-25 06:05:25 +08:00
bsp->preview = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_size (GTK_PREVIEW (bsp->preview),
MAX_WIN_WIDTH (bsp), MAX_WIN_HEIGHT (bsp));
gtk_widget_set_usize (bsp->preview,
MAX_WIN_WIDTH (bsp), MAX_WIN_HEIGHT (bsp));
gtk_preview_set_expand (GTK_PREVIEW (bsp->preview), TRUE);
1997-11-25 06:05:25 +08:00
gtk_widget_set_events (bsp->preview, BRUSH_EVENT_MASK);
1997-11-25 06:05:25 +08:00
gtk_signal_connect (GTK_OBJECT (bsp->preview), "event",
1999-10-27 02:27:27 +08:00
GTK_SIGNAL_FUNC (brush_select_events),
1997-11-25 06:05:25 +08:00
bsp);
gtk_signal_connect (GTK_OBJECT(bsp->preview), "size_allocate",
1999-10-27 02:27:27 +08:00
GTK_SIGNAL_FUNC (brush_select_resize),
bsp);
1997-11-25 06:05:25 +08:00
1999-10-28 23:05:49 +08:00
/* dnd stuff */
gtk_drag_source_set (bsp->preview,
GDK_BUTTON2_MASK,
preview_target_table, preview_n_targets,
GDK_ACTION_COPY);
gimp_dnd_brush_source_set (bsp->preview, brush_select_drag_brush, bsp);
1999-10-28 23:05:49 +08:00
gtk_drag_dest_set (bsp->preview,
GTK_DEST_DEFAULT_ALL,
preview_target_table, preview_n_targets,
GDK_ACTION_COPY);
gimp_dnd_brush_dest_set (bsp->preview, brush_select_drop_brush, bsp);
gtk_container_add (GTK_CONTAINER (frame), bsp->preview);
1997-11-25 06:05:25 +08:00
gtk_widget_show (bsp->preview);
gtk_widget_show (sbar);
gtk_widget_show (frame);
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
gtk_widget_show (bsp->brush_selection_box);
gtk_widget_show (bsp->left_box);
1997-11-25 06:05:25 +08:00
/* Options box */
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
bsp->options_box = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), bsp->options_box, FALSE, FALSE, 0);
1997-11-25 06:05:25 +08:00
/* Create the active brush label */
util_box = gtk_hbox_new (FALSE, 0);
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
gtk_box_pack_start (GTK_BOX (bsp->options_box), util_box, FALSE, FALSE, 2);
1997-11-25 06:05:25 +08:00
app/airbrush.c app/apptypes.h app/brushes_cmds.c 1999-11-14 Michael Natterer <mitch@gimp.org> * app/airbrush.c * app/apptypes.h * app/brushes_cmds.c * tools/pdbgen/pdb/brushes.pdb * app/bucket_fill.c * app/clone.c * app/gimpbrushpipe.c * app/paint_core.c * app/patterns.h * app/patterns_cmds.c * tools/pdbgen/pdb/patterns.pdb: removed the GimpBrushP and GPatternP types and use ordinary pointers instead. The following stuff makes the "no_data" behaviour consistent. As a side-effect it should make the gimp work when there are _really_ no brushes/patterns/gradients. * app/brush_select.c * app/pattern_select.c: set the initial brush/pattern name to "No Brushes/Patterns available" instead of "Active". * app/devices.c: set the device contexts' brush/pattern/gradient names if we started with no_data, so we find them on refresh. * app/gimpbrushlist.c: set the name of the standard_brush to "Standard". * app/gimpcontext.c: don't replace the current brush/pattern/gradient's name if the new one to be set is the standard one. Together with the change in devices.c, this ensures that we get what is set in devicerc. Minor fixes. * app/gradient.c: changed gradients_init() to work like the other data init functions. Only insert a default gradient in the gradients list when the editor is opened (this means that the gradients now behave like brushes/patterns when we start with "no_data"). New function gradient_update() avoids tons of useless redraws of all clist gradient previews whenever the gradient editor wants to update it's large preview. * app/gradient_select.c: don't segfault when the user tries to drag from an empty gradient list. * app/patterns.c: set the index of the standard_pattern to -1 to indicate that it's not part of the pattern list.
1999-11-14 18:50:19 +08:00
bsp->brush_name = gtk_label_new (_("No Brushes available"));
gtk_box_pack_start (GTK_BOX (util_box), bsp->brush_name, FALSE, FALSE, 4);
bsp->brush_size = gtk_label_new ("(0 x 0)");
1997-11-25 06:05:25 +08:00
gtk_box_pack_start (GTK_BOX (util_box), bsp->brush_size, FALSE, FALSE, 2);
gtk_widget_show (bsp->brush_name);
gtk_widget_show (bsp->brush_size);
gtk_widget_show (util_box);
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
/* A place holder for paint mode switching */
bsp->right_box = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (bsp->options_box), bsp->right_box, TRUE, TRUE, 0);
1997-11-25 06:05:25 +08:00
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
/* The vbox for the paint options */
bsp->paint_options_box = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (bsp->right_box), bsp->paint_options_box,
FALSE, FALSE, 0);
/* A separator before the paint options */
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
sep = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (bsp->paint_options_box), sep, FALSE, FALSE, 0);
gtk_widget_show (sep);
/* Create the frame and the table for the options */
table = gtk_table_new (2, 2, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (bsp->paint_options_box), table, FALSE, FALSE, 2);
1997-11-25 06:05:25 +08:00
/* Create the opacity scale widget */
bsp->opacity_data =
1999-10-27 02:27:27 +08:00
GTK_ADJUSTMENT (gtk_adjustment_new
(gimp_context_get_opacity (bsp->context) * 100.0,
0.0, 100.0, 1.0, 1.0, 0.0));
1997-11-25 06:05:25 +08:00
slider = gtk_hscale_new (bsp->opacity_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 (bsp->opacity_data), "value_changed",
1999-10-27 02:27:27 +08:00
GTK_SIGNAL_FUNC (opacity_scale_update),
bsp);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
1999-10-27 02:27:27 +08:00
_("Opacity:"), 1.0, 1.0,
slider, 1, FALSE);
1997-11-25 06:05:25 +08:00
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
/* Create the paint mode option menu */
bsp->option_menu =
paint_mode_menu_new (paint_mode_menu_callback, (gpointer) bsp,
gimp_context_get_paint_mode (bsp->context));
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
1999-10-27 02:27:27 +08:00
_("Mode:"), 1.0, 0.5,
bsp->option_menu, 1, TRUE);
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
gtk_widget_show (table);
gtk_widget_show (bsp->paint_options_box);
gtk_widget_show (bsp->right_box);
1997-11-25 06:05:25 +08:00
/* Create the edit/new buttons */
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
util_box = gtk_hbox_new (FALSE, 0);
gtk_box_pack_end (GTK_BOX (bsp->options_box), util_box, FALSE, FALSE, 4);
1999-10-27 02:27:27 +08:00
button = gtk_button_new_with_label (_("New"));
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (brush_select_new_brush_callback),
bsp);
gtk_box_pack_start (GTK_BOX (util_box), button, TRUE, TRUE, 6);
bsp->edit_button = gtk_button_new_with_label (_("Edit"));
gtk_signal_connect (GTK_OBJECT (bsp->edit_button), "clicked",
1999-10-27 02:27:27 +08:00
GTK_SIGNAL_FUNC (brush_select_edit_brush_callback),
bsp);
gtk_box_pack_start (GTK_BOX (util_box), bsp->edit_button, TRUE, TRUE, 5);
bsp->delete_button = gtk_button_new_with_label (_("Delete"));
gtk_signal_connect (GTK_OBJECT (bsp->delete_button), "clicked",
1999-10-27 02:27:27 +08:00
GTK_SIGNAL_FUNC (brush_select_delete_brush_callback),
bsp);
gtk_box_pack_start (GTK_BOX (util_box), bsp->delete_button, TRUE, TRUE, 5);
gtk_widget_show (bsp->edit_button);
1999-10-27 02:27:27 +08:00
gtk_widget_show (button);
gtk_widget_show (bsp->delete_button);
gtk_widget_show (util_box);
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
/* Create the spacing scale widget */
table = gtk_table_new (1, 2, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
gtk_box_pack_end (GTK_BOX (bsp->options_box), table, FALSE, FALSE, 2);
bsp->spacing_data =
GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 1.0, 1000.0, 1.0, 1.0, 0.0));
slider = gtk_hscale_new (bsp->spacing_data);
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP);
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
1999-10-27 02:27:27 +08:00
if (title && init_spacing >= 0)
{
/* Use passed spacing instead of brushes default */
gtk_adjustment_set_value (GTK_ADJUSTMENT (bsp->spacing_data),
init_spacing);
}
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
gtk_signal_connect (GTK_OBJECT (bsp->spacing_data), "value_changed",
1999-10-27 02:27:27 +08:00
GTK_SIGNAL_FUNC (spacing_scale_update),
bsp);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
1999-10-27 02:27:27 +08:00
_("Spacing:"), 1.0, 1.0,
slider, 1, FALSE);
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
gtk_widget_show (table);
1997-11-25 06:05:25 +08:00
gtk_widget_show (bsp->options_box);
gtk_widget_show (hbox);
gtk_widget_show (vbox);
1999-10-27 02:27:27 +08:00
/* add callbacks to keep the display area current */
gimp_list_foreach (GIMP_LIST (brush_list),
(GFunc) connect_signals_to_brush,
bsp);
gtk_signal_connect (GTK_OBJECT (brush_list), "add",
GTK_SIGNAL_FUNC (brush_added_callback),
bsp);
gtk_signal_connect (GTK_OBJECT (brush_list), "remove",
GTK_SIGNAL_FUNC (brush_removed_callback),
bsp);
1997-11-25 06:05:25 +08:00
/* Only for main dialog */
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
if (!title)
{
/* set the preview's size in the callback
gtk_signal_connect (GTK_OBJECT (bsp->shell), "map",
GTK_SIGNAL_FUNC (brush_select_map_callback),
bsp);
*/
/* if we are in per-tool paint options mode, hide the paint options */
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
brush_select_show_paint_options (bsp, global_paint_options);
}
1999-10-27 02:27:27 +08:00
gtk_widget_show (bsp->shell);
1999-10-27 02:27:27 +08:00
preview_calc_scrollbar (bsp);
1999-10-27 02:27:27 +08:00
gtk_signal_connect (GTK_OBJECT (bsp->context), "brush_changed",
GTK_SIGNAL_FUNC (brush_select_brush_changed),
bsp);
gtk_signal_connect (GTK_OBJECT (bsp->context), "opacity_changed",
GTK_SIGNAL_FUNC (brush_select_opacity_changed),
bsp);
gtk_signal_connect (GTK_OBJECT (bsp->context), "paint_mode_changed",
GTK_SIGNAL_FUNC (brush_select_paint_mode_changed),
bsp);
1999-10-27 02:27:27 +08:00
if (active)
brush_select_select (bsp, active);
1999-10-27 02:27:27 +08:00
/* Add to active brush dialogs list */
brush_active_dialogs = g_slist_append (brush_active_dialogs, bsp);
1997-11-25 06:05:25 +08:00
return bsp;
}
void
1999-10-27 02:27:27 +08:00
brush_select_free (BrushSelect *bsp)
1997-11-25 06:05:25 +08:00
{
1999-10-27 02:27:27 +08:00
if (!bsp)
return;
1999-10-27 02:27:27 +08:00
/* remove from active list */
brush_active_dialogs = g_slist_remove (brush_active_dialogs, bsp);
gtk_signal_disconnect_by_data (GTK_OBJECT (bsp->context), bsp);
if (bsp->brush_popup != NULL)
gtk_widget_destroy (bsp->brush_popup);
if (bsp->callback_name)
{
1999-10-27 02:27:27 +08:00
g_free (bsp->callback_name);
gtk_object_unref (GTK_OBJECT (bsp->context));
}
1997-11-25 06:05:25 +08:00
1999-10-27 02:27:27 +08:00
gimp_list_foreach (GIMP_LIST (brush_list),
(GFunc) disconnect_signals_from_brush,
bsp);
gtk_signal_disconnect_by_data (GTK_OBJECT (brush_list), bsp);
g_free (bsp);
1997-11-25 06:05:25 +08:00
}
void
1999-10-27 02:27:27 +08:00
brush_select_freeze_all (void)
1997-11-25 06:05:25 +08:00
{
1999-10-27 02:27:27 +08:00
BrushSelect *bsp;
GSList *list;
1999-10-27 02:27:27 +08:00
for (list = brush_active_dialogs; list; list = g_slist_next (list))
{
bsp = (BrushSelect *) list->data;
1999-10-27 02:27:27 +08:00
bsp->freeze = TRUE;
1997-11-25 06:05:25 +08:00
}
}
1999-10-28 23:05:49 +08:00
void
1999-10-27 02:27:27 +08:00
brush_select_thaw_all (void)
{
1999-10-27 02:27:27 +08:00
BrushSelect *bsp;
GSList *list;
1999-10-27 02:27:27 +08:00
for (list = brush_active_dialogs; list; list = g_slist_next (list))
{
bsp = (BrushSelect *) list->data;
1999-10-27 02:27:27 +08:00
bsp->freeze = FALSE;
1999-10-27 02:27:27 +08:00
preview_calc_scrollbar (bsp);
}
}
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
void
1999-10-27 02:27:27 +08:00
brush_select_show_paint_options (BrushSelect *bsp,
gboolean show)
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
{
if ((bsp == NULL) && ((bsp = brush_select_dialog) == NULL))
return;
if (show)
{
if (! GTK_WIDGET_VISIBLE (bsp->paint_options_box))
gtk_widget_show (bsp->paint_options_box);
1999-10-27 02:27:27 +08:00
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
if (bsp->brush_selection_box->parent != bsp->left_box)
gtk_widget_reparent (bsp->brush_selection_box, bsp->left_box);
gtk_box_set_child_packing (GTK_BOX (bsp->options_box->parent),
bsp->options_box,
FALSE, FALSE, 0, GTK_PACK_START);
gtk_box_set_child_packing (GTK_BOX (bsp->left_box->parent),
bsp->left_box,
TRUE, TRUE, 0, GTK_PACK_START);
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
gtk_box_set_spacing (GTK_BOX (bsp->left_box->parent), 2);
}
else
{
if (GTK_WIDGET_VISIBLE (bsp->paint_options_box))
gtk_widget_hide (bsp->paint_options_box);
1999-10-27 02:27:27 +08:00
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
if (bsp->brush_selection_box->parent != bsp->right_box)
gtk_widget_reparent (bsp->brush_selection_box, bsp->right_box);
gtk_box_set_child_packing (GTK_BOX (bsp->left_box->parent),
bsp->left_box,
FALSE, FALSE, 0, GTK_PACK_START);
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
gtk_box_set_child_packing (GTK_BOX (bsp->options_box->parent),
bsp->options_box,
TRUE, TRUE, 0, GTK_PACK_START);
gtk_box_set_spacing (GTK_BOX (bsp->left_box->parent), 0);
}
}
1999-10-27 02:27:27 +08:00
/* call this dialog's PDB callback */
1999-10-28 23:05:49 +08:00
static void
1999-10-27 02:27:27 +08:00
brush_change_callbacks (BrushSelect *bsp,
1999-10-28 23:05:49 +08:00
gboolean closing)
1999-10-27 02:27:27 +08:00
{
gchar *name;
ProcRecord *prec = NULL;
GimpBrush *brush;
gint nreturn_vals;
static gboolean busy = FALSE;
/* Any procs registered to callback? */
Argument *return_vals;
if (!bsp || !bsp->callback_name || busy)
return;
busy = TRUE;
name = bsp->callback_name;
brush = gimp_context_get_brush (bsp->context);
/* If its still registered run it */
prec = procedural_db_lookup (name);
if (prec && brush)
{
return_vals =
procedural_db_run_proc (name,
&nreturn_vals,
1999-10-28 23:05:49 +08:00
PDB_STRING, brush->name,
PDB_FLOAT, gimp_context_get_opacity (bsp->context),
PDB_INT32, bsp->spacing_value,
PDB_INT32, (gint) gimp_context_get_paint_mode (bsp->context),
PDB_INT32, brush->mask->width,
PDB_INT32, brush->mask->height,
PDB_INT32, brush->mask->width * brush->mask->height,
1999-10-27 02:27:27 +08:00
PDB_INT8ARRAY, temp_buf_data (brush->mask),
1999-10-28 23:05:49 +08:00
PDB_INT32, (gint) closing,
1999-10-27 02:27:27 +08:00
PDB_END);
if (!return_vals || return_vals[0].value.pdb_int != PDB_SUCCESS)
g_message ("failed to run brush callback function");
procedural_db_destroy_args (return_vals, nreturn_vals);
}
busy = FALSE;
}
/* Close active dialogs that no longer have PDB registered for them */
void
brushes_check_dialogs (void)
{
BrushSelect *bsp;
GSList *list;
gchar *name;
ProcRecord *prec = NULL;
list = brush_active_dialogs;
while (list)
{
bsp = (BrushSelect *) list->data;
1999-10-28 23:05:49 +08:00
list = g_slist_next (list);
1999-10-27 02:27:27 +08:00
name = bsp->callback_name;
if (name)
{
prec = procedural_db_lookup (name);
if (!prec)
{
/* Can alter brush_active_dialogs list */
brush_select_close_callback (NULL, bsp);
}
}
}
}
/*
* Local functions
*/
static GimpBrush *
brush_select_drag_brush (GtkWidget *widget,
gpointer data)
{
BrushSelect *bsp;
bsp = (BrushSelect *) data;
return bsp->dnd_brush;
}
1999-10-28 23:05:49 +08:00
static void
brush_select_drop_brush (GtkWidget *widget,
GimpBrush *brush,
gpointer data)
{
BrushSelect *bsp;
bsp = (BrushSelect *) data;
gimp_context_set_brush (bsp->context, brush);
}
static void
1999-10-27 02:27:27 +08:00
brush_select_brush_changed (GimpContext *context,
GimpBrush *brush,
BrushSelect *bsp)
{
1999-10-27 02:27:27 +08:00
if (brush)
{
brush_select_select (bsp, brush);
if (bsp->callback_name)
brush_change_callbacks (bsp, FALSE);
}
1999-10-27 02:27:27 +08:00
}
1999-10-27 02:27:27 +08:00
static void
brush_select_opacity_changed (GimpContext *context,
gdouble opacity,
BrushSelect *bsp)
{
gtk_signal_handler_block_by_data (GTK_OBJECT (bsp->opacity_data), bsp);
gtk_adjustment_set_value (GTK_ADJUSTMENT (bsp->opacity_data),
opacity * 100.0);
gtk_signal_handler_unblock_by_data (GTK_OBJECT (bsp->opacity_data), bsp);
if (bsp->callback_name)
brush_change_callbacks (bsp, FALSE);
}
static void
1999-10-27 02:27:27 +08:00
brush_select_paint_mode_changed (GimpContext *context,
LayerModeEffects paint_mode,
BrushSelect *bsp)
{
gimp_option_menu_set_history (GTK_OPTION_MENU (bsp->option_menu),
(gpointer) paint_mode);
if (bsp->callback_name)
brush_change_callbacks (bsp, FALSE);
}
1999-10-27 02:27:27 +08:00
static void
brush_select_select (BrushSelect *bsp,
GimpBrush *brush)
{
gint index;
gint row, col;
1999-10-28 23:05:49 +08:00
gint scroll_offset = 0;
1999-10-27 02:27:27 +08:00
index = gimp_brush_list_get_brush_index (brush_list, brush);
1999-10-28 23:05:49 +08:00
if (index < 0)
1999-10-27 02:27:27 +08:00
return;
if (GIMP_IS_BRUSH_GENERATED (brush))
{
gtk_widget_set_sensitive (bsp->edit_button, TRUE);
gtk_widget_set_sensitive (bsp->delete_button, TRUE);
}
else
{
gtk_widget_set_sensitive (bsp->edit_button, FALSE);
gtk_widget_set_sensitive (bsp->delete_button, FALSE);
}
update_active_brush_field (bsp);
row = index / bsp->NUM_BRUSH_COLUMNS;
col = index - row * (bsp->NUM_BRUSH_COLUMNS);
1999-10-28 23:05:49 +08:00
/* check if the new active brush is already in the preview */
if (((row + 1) * bsp->cell_height) >
(bsp->preview->allocation.height + bsp->scroll_offset))
{
scroll_offset = (((row + 1) * bsp->cell_height) -
(bsp->scroll_offset + bsp->preview->allocation.height));
}
else if ((row * bsp->cell_height) < bsp->scroll_offset)
{
scroll_offset = (row * bsp->cell_height) - bsp->scroll_offset;
}
else
{
brush_select_show_selected (bsp, row, col);
}
gtk_adjustment_set_value (bsp->sbar_data, bsp->scroll_offset + scroll_offset);
1999-10-27 02:27:27 +08:00
}
static void
brush_select_brush_dirty_callback (GimpBrush *brush,
BrushSelect *bsp)
{
gint index;
gboolean redraw;
1999-10-27 02:27:27 +08:00
if (!bsp || bsp->freeze)
1999-10-27 02:27:27 +08:00
return;
index = gimp_brush_list_get_brush_index (brush_list, brush);
redraw = (brush != gimp_context_get_brush (bsp->context));
clear_brush (bsp, brush,
index % (bsp->NUM_BRUSH_COLUMNS),
index / (bsp->NUM_BRUSH_COLUMNS));
1999-10-27 02:27:27 +08:00
display_brush (bsp, brush,
index % (bsp->NUM_BRUSH_COLUMNS),
index / (bsp->NUM_BRUSH_COLUMNS),
redraw);
}
static void
1999-10-27 02:27:27 +08:00
connect_signals_to_brush (GimpBrush *brush,
BrushSelect *bsp)
{
gtk_signal_connect (GTK_OBJECT (brush), "dirty",
GTK_SIGNAL_FUNC (brush_select_brush_dirty_callback),
bsp);
gtk_signal_connect (GTK_OBJECT (brush), "rename",
GTK_SIGNAL_FUNC (brush_select_brush_dirty_callback),
bsp);
}
static void
1999-10-27 02:27:27 +08:00
disconnect_signals_from_brush (GimpBrush *brush,
BrushSelect *bsp)
{
if (!GTK_OBJECT_DESTROYED (brush))
gtk_signal_disconnect_by_data (GTK_OBJECT (brush), bsp);
}
static void
brush_added_callback (GimpBrushList *list,
1999-10-27 02:27:27 +08:00
GimpBrush *brush,
BrushSelect *bsp)
{
connect_signals_to_brush (brush, bsp);
1999-10-27 02:27:27 +08:00
if (bsp->freeze)
return;
1999-10-27 02:27:27 +08:00
preview_calc_scrollbar (bsp);
}
static void
brush_removed_callback (GimpBrushList *list,
1999-10-27 02:27:27 +08:00
GimpBrush *brush,
BrushSelect *bsp)
{
disconnect_signals_from_brush (brush, bsp);
1999-10-27 02:27:27 +08:00
if (bsp->freeze)
return;
1999-10-27 02:27:27 +08:00
preview_calc_scrollbar (bsp);
}
static void
draw_brush_popup (GtkPreview *preview,
GimpBrush *brush,
gint width,
gint height)
{
gint x, y;
gint brush_width, brush_height;
gint offset_x, offset_y;
guchar *mask, *buf, *b;
guchar bg;
brush_width = brush->mask->width;
brush_height = brush->mask->height;
offset_x = (width - brush_width) / 2;
offset_y = (height - brush_height) / 2;
mask = temp_buf_data (brush->mask);
buf = g_new (guchar, 3 * width);
memset (buf, 255, 3 * width);
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
if (gimp_brush_get_pixmap (brush))
{
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
guchar *pixmap = temp_buf_data (gimp_brush_get_pixmap (brush));
for (y = 0; y < offset_y; y++)
gtk_preview_draw_row (preview, buf, 0, y, width);
for (y = offset_y; y < brush_height + offset_y; y++)
{
b = buf + 3 * offset_x;
for (x = 0; x < brush_width ; x++)
{
bg = (255 - *mask);
*b++ = bg + (*mask * *pixmap++) / 255;
*b++ = bg + (*mask * *pixmap++) / 255;
*b++ = bg + (*mask * *pixmap++) / 255;
mask++;
}
gtk_preview_draw_row (preview, buf, 0, y, width);
}
memset (buf, 255, 3 * width);
for (y = brush_height + offset_y; y < height; y++)
gtk_preview_draw_row (preview, buf, 0, y, width);
}
else
{
for (y = 0; y < offset_y; y++)
gtk_preview_draw_row (preview, buf, 0, y, width);
for (y = offset_y; y < brush_height + offset_y; y++)
{
b = buf + 3 * offset_x;
for (x = 0; x < brush_width ; x++)
{
bg = 255 - *mask++;
memset (b, bg, 3);
b += 3;
}
gtk_preview_draw_row (preview, buf, 0, y, width);
}
memset (buf, 255, 3 * width);
for (y = brush_height + offset_y; y < height; y++)
gtk_preview_draw_row (preview, buf, 0, y, width);
}
g_free (buf);
}
1999-10-27 02:27:27 +08:00
typedef struct
{
BrushSelect *bsp;
gint x;
gint y;
GimpBrush *brush;
} popup_timeout_args_t;
static gint
brush_popup_anim_timeout (gpointer data)
{
popup_timeout_args_t *args = data;
1999-10-27 02:27:27 +08:00
BrushSelect *bsp = args->bsp;
GimpBrushPipe *pipe;
GimpBrush *brush;
if (bsp->brush_popup != NULL && !GTK_WIDGET_VISIBLE (bsp->brush_popup))
{
bsp->popup_anim_timeout_tag = 0;
return (FALSE);
}
pipe = GIMP_BRUSH_PIPE (args->brush);
if (++bsp->popup_pipe_index >= pipe->nbrushes)
bsp->popup_pipe_index = 0;
brush = GIMP_BRUSH (pipe->brushes[bsp->popup_pipe_index]);
draw_brush_popup (GTK_PREVIEW (bsp->brush_preview), brush, args->x, args->y);
gtk_widget_queue_draw (bsp->brush_preview);
return (TRUE);
}
static gboolean
brush_popup_timeout (gpointer data)
1997-11-25 06:05:25 +08:00
{
popup_timeout_args_t *args = data;
1999-10-27 02:27:27 +08:00
BrushSelect *bsp = args->bsp;
GimpBrush *brush = args->brush;
gint x, y;
1997-11-25 06:05:25 +08:00
gint x_org, y_org;
gint scr_w, scr_h;
gint width, height;
1997-11-25 06:05:25 +08:00
/* timeout has gone off so our tag is now invalid */
bsp->popup_timeout_tag = 0;
1997-12-18 12:19:11 +08:00
/* make sure the popup exists and is not visible */
1997-11-25 06:05:25 +08:00
if (bsp->brush_popup == NULL)
{
GtkWidget *frame;
bsp->brush_popup = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_set_policy (GTK_WINDOW (bsp->brush_popup),
FALSE, FALSE, TRUE);
1997-11-25 06:05:25 +08:00
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_container_add (GTK_CONTAINER (bsp->brush_popup), frame);
gtk_widget_show (frame);
bsp->brush_preview = gtk_preview_new (GTK_PREVIEW_COLOR);
1997-11-25 06:05:25 +08:00
gtk_container_add (GTK_CONTAINER (frame), bsp->brush_preview);
gtk_widget_show (bsp->brush_preview);
}
else
1997-12-18 12:19:11 +08:00
{
gtk_widget_hide (bsp->brush_popup);
}
1997-11-25 06:05:25 +08:00
1997-12-18 12:19:11 +08:00
/* decide where to put the popup */
width = brush->mask->width;
height = brush->mask->height;
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
if (GIMP_IS_BRUSH_PIPE (brush))
{
GimpBrushPipe *pipe = GIMP_BRUSH_PIPE (brush);
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
GimpBrush *tmp_brush;
gint i;
for (i = 1; i < pipe->nbrushes; i++)
{
tmp_brush = GIMP_BRUSH (pipe->brushes[i]);
width = MAX (width, tmp_brush->mask->width);
height = MAX (height, tmp_brush->mask->height);
}
}
1997-11-25 06:05:25 +08:00
gdk_window_get_origin (bsp->preview->window, &x_org, &y_org);
scr_w = gdk_screen_width ();
scr_h = gdk_screen_height ();
x = x_org + args->x - width * 0.5;
y = y_org + args->y - height * 0.5;
1997-11-25 06:05:25 +08:00
x = (x < 0) ? 0 : x;
y = (y < 0) ? 0 : y;
x = (x + width > scr_w) ? scr_w - width : x;
y = (y + height > scr_h) ? scr_h - height : y;
gtk_preview_size (GTK_PREVIEW (bsp->brush_preview), width, height);
1997-11-25 06:05:25 +08:00
gtk_widget_popup (bsp->brush_popup, x, y);
1997-11-25 06:05:25 +08:00
/* Draw the brush preview */
draw_brush_popup (GTK_PREVIEW (bsp->brush_preview), brush, width, height);
gtk_widget_queue_draw (bsp->brush_preview);
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
if (GIMP_IS_BRUSH_PIPE (brush) && bsp->popup_anim_timeout_tag == 0)
{
static popup_timeout_args_t timeout_args;
timeout_args.bsp = bsp;
timeout_args.x = width;
timeout_args.y = height;
timeout_args.brush = brush;
bsp->popup_pipe_index = 0;
1999-10-27 02:27:27 +08:00
bsp->popup_anim_timeout_tag =
gtk_timeout_add (300, brush_popup_anim_timeout, &timeout_args);
}
1999-10-27 02:27:27 +08:00
return FALSE; /* don't repeat */
1997-11-25 06:05:25 +08:00
}
static void
1999-10-27 02:27:27 +08:00
brush_popup_open (BrushSelect *bsp,
gint x,
gint y,
GimpBrush *brush)
{
static popup_timeout_args_t popup_timeout_args;
/* if we've already got a timeout scheduled, then we complain */
g_return_if_fail (bsp->popup_timeout_tag == 0);
popup_timeout_args.bsp = bsp;
popup_timeout_args.x = x;
popup_timeout_args.y = y;
popup_timeout_args.brush = brush;
bsp->popup_timeout_tag = gtk_timeout_add (POPUP_DELAY_MS,
brush_popup_timeout,
&popup_timeout_args);
}
1997-11-25 06:05:25 +08:00
static void
1999-10-27 02:27:27 +08:00
brush_popup_close (BrushSelect *bsp)
1997-11-25 06:05:25 +08:00
{
if (bsp->popup_timeout_tag != 0)
gtk_timeout_remove (bsp->popup_timeout_tag);
bsp->popup_timeout_tag = 0;
if (bsp->popup_anim_timeout_tag != 0)
gtk_timeout_remove (bsp->popup_anim_timeout_tag);
bsp->popup_anim_timeout_tag = 0;
1997-11-25 06:05:25 +08:00
if (bsp->brush_popup != NULL)
gtk_widget_hide (bsp->brush_popup);
}
1997-11-25 06:05:25 +08:00
static void
1999-10-27 02:27:27 +08:00
display_setup (BrushSelect *bsp)
{
guchar * buf;
gint i;
buf = g_new (guchar, 3 * bsp->preview->allocation.width);
/* Set the buffer to white */
memset (buf, 255, bsp->preview->allocation.width * 3);
/* Set the image buffer to white */
for (i = 0; i < bsp->preview->allocation.height; i++)
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf, 0, i,
bsp->preview->allocation.width);
g_free (buf);
}
static void
clear_brush (BrushSelect *bsp,
GimpBrush *brush,
gint col,
gint row)
{
guchar *buf;
gint width, height;
gint offset_x, offset_y;
gint ystart, yend;
gint i;
width = bsp->cell_width - 2 * MARGIN_WIDTH;
height = bsp->cell_height - 2 * MARGIN_HEIGHT;
offset_x = col * bsp->cell_width + MARGIN_WIDTH;
offset_y = row * bsp->cell_height - bsp->scroll_offset + MARGIN_HEIGHT;
ystart = CLAMP (offset_y, 0, bsp->preview->allocation.height);
yend = CLAMP (offset_y + height, 0, bsp->preview->allocation.height);
buf = g_new (guchar, 3 * width);
memset (buf, 255, 3 * width * sizeof (guchar));
for (i = ystart; i < yend; i++)
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
offset_x, i, width);
}
1999-10-27 02:27:27 +08:00
static void
display_brush (BrushSelect *bsp,
GimpBrush *brush,
gint col,
gint row,
gboolean redraw)
1997-11-25 06:05:25 +08:00
{
TempBuf *mask_buf, *pixmap_buf = NULL;
guchar *mask, *buf, *b;
guchar bg;
gboolean scale = FALSE;
gint cell_width, cell_height;
gint width, height;
gint offset_x, offset_y;
gint yend;
gint ystart;
gint i, j;
1997-11-25 06:05:25 +08:00
1999-10-27 02:27:27 +08:00
cell_width = bsp->cell_width - 2 * MARGIN_WIDTH;
cell_height = bsp->cell_height - 2 * MARGIN_HEIGHT;
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
mask_buf = gimp_brush_get_mask (brush);
pixmap_buf = gimp_brush_get_pixmap (brush);
1997-11-25 06:05:25 +08:00
if (mask_buf->width > cell_width || mask_buf->height > cell_height)
{
gdouble ratio_x = (gdouble)mask_buf->width / cell_width;
gdouble ratio_y = (gdouble)mask_buf->height / cell_height;
mask_buf = brush_scale_mask (mask_buf,
(gdouble)(mask_buf->width) / MAX (ratio_x, ratio_y) + 0.5,
(gdouble)(mask_buf->height) / MAX (ratio_x, ratio_y) + 0.5);
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
if (pixmap_buf)
{
/* TODO: the scale function should scale the pixmap
and the mask in one run */
1999-10-27 02:27:27 +08:00
pixmap_buf = brush_scale_pixmap (pixmap_buf,
mask_buf->width, mask_buf->height);
}
scale = TRUE;
}
1997-11-25 06:05:25 +08:00
/* calculate the offset into the image */
width = (mask_buf->width > cell_width) ? cell_width : mask_buf->width;
height = (mask_buf->height > cell_height) ? cell_height : mask_buf->height;
1997-11-25 06:05:25 +08:00
offset_x = col * bsp->cell_width + ((cell_width - width) >> 1) + MARGIN_WIDTH;
offset_y = row * bsp->cell_height + ((cell_height - height) >> 1) - bsp->scroll_offset + MARGIN_HEIGHT;
1997-11-25 06:05:25 +08:00
ystart = CLAMP (offset_y, 0, bsp->preview->allocation.height);
yend = CLAMP (offset_y + height, 0, bsp->preview->allocation.height);
1997-11-25 06:05:25 +08:00
1999-09-13 19:03:37 +08:00
mask = temp_buf_data (mask_buf) + (ystart - offset_y) * mask_buf->width;
buf = g_new (guchar, 3 * cell_width);
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
if (pixmap_buf)
{
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
guchar *pixmap =
temp_buf_data (pixmap_buf) + (ystart - offset_y) * mask_buf->width * 3;
for (i = ystart; i < yend; i++)
{
b = buf;
for (j = 0; j < width ; j++)
{
bg = (255 - *mask);
*b++ = bg + (*mask * *pixmap++) / 255;
*b++ = bg + (*mask * *pixmap++) / 255;
*b++ = bg + (*mask * *pixmap++) / 255;
mask++;
}
1999-10-27 02:27:27 +08:00
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
offset_x, i, width);
}
}
else
{
for (i = ystart; i < yend; i++)
{
/* Invert the mask for display. We're doing this because
* a value of 255 in the mask means it is full intensity.
* However, it makes more sense for full intensity to show
* up as black in this brush preview window...
*/
b = buf;
for (j = 0; j < width; j++)
{
bg = 255 - *mask++;
memset (b, bg, 3);
b += 3;
}
1999-10-27 02:27:27 +08:00
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
offset_x, i, width);
}
1997-11-25 06:05:25 +08:00
}
g_free (buf);
offset_x = (col + 1) * bsp->cell_width - indicator_width - MARGIN_WIDTH;
offset_y = (row + 1) * bsp->cell_height - indicator_height - bsp->scroll_offset - MARGIN_HEIGHT;
1999-10-27 02:27:27 +08:00
if (scale)
{
temp_buf_free (mask_buf);
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
if (pixmap_buf)
temp_buf_free (pixmap_buf);
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
for (i = 0; i < indicator_height; i++, offset_y++)
{
if (offset_y > 0 && offset_y < bsp->preview->allocation.height)
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
(GIMP_IS_BRUSH_PIPE (brush)) ?
1999-10-27 02:27:27 +08:00
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview),
scale_pipe_indicator_bits[i][0],
offset_x, offset_y, indicator_width) :
1999-10-27 02:27:27 +08:00
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview),
scale_indicator_bits[i][0],
offset_x, offset_y, indicator_width);
}
}
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
else if (GIMP_IS_BRUSH_PIPE (brush))
{
for (i = 0; i < indicator_height; i++, offset_y++)
{
if (offset_y > 0 && offset_y < bsp->preview->allocation.height)
1999-10-27 02:27:27 +08:00
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview),
pipe_indicator_bits[i][0],
offset_x, offset_y, indicator_width);
}
}
if (redraw && bsp->redraw)
{
GdkRectangle area;
area.x = col * bsp->cell_width + MARGIN_WIDTH;
area.y = CLAMP (row * bsp->cell_height - bsp->scroll_offset +
MARGIN_HEIGHT,
0, bsp->preview->allocation.height);
area.width = cell_width;
area.height = CLAMP (row * bsp->cell_height - bsp->scroll_offset +
MARGIN_HEIGHT + cell_height,
0, bsp->preview->allocation.height);
gtk_widget_draw (bsp->preview, &area);
}
1997-11-25 06:05:25 +08:00
}
1999-10-27 02:27:27 +08:00
static gint brush_counter = 0;
static void
1999-10-27 02:27:27 +08:00
do_display_brush (GimpBrush *brush,
BrushSelect *bsp)
{
display_brush (bsp, brush,
brush_counter % (bsp->NUM_BRUSH_COLUMNS),
brush_counter / (bsp->NUM_BRUSH_COLUMNS),
FALSE);
brush_counter++;
}
1997-11-25 06:05:25 +08:00
static void
1999-10-27 02:27:27 +08:00
display_brushes (BrushSelect *bsp)
1997-11-25 06:05:25 +08:00
{
1999-10-27 02:27:27 +08:00
if (brush_list == NULL || gimp_brush_list_length (brush_list) == 0)
{
gtk_widget_set_sensitive (bsp->options_box, FALSE);
return;
}
1997-11-25 06:05:25 +08:00
else
1999-10-27 02:27:27 +08:00
{
gtk_widget_set_sensitive (bsp->options_box, TRUE);
}
1997-11-25 06:05:25 +08:00
/* setup the display area */
display_setup (bsp);
1999-10-27 02:27:27 +08:00
brush_counter = 0;
gimp_list_foreach (GIMP_LIST (brush_list), (GFunc) do_display_brush, bsp);
1997-11-25 06:05:25 +08:00
}
static void
1999-10-27 02:27:27 +08:00
brush_select_show_selected (BrushSelect *bsp,
gint row,
gint col)
1997-11-25 06:05:25 +08:00
{
GdkRectangle area;
1999-10-27 02:27:27 +08:00
guchar *buf;
gint yend;
gint ystart;
gint offset_x, offset_y;
gint i;
1997-11-25 06:05:25 +08:00
1999-10-27 02:27:27 +08:00
buf = g_new (guchar, 3 * bsp->cell_width);
1997-11-25 06:05:25 +08:00
if (bsp->old_col != col || bsp->old_row != row)
1997-11-25 06:05:25 +08:00
{
/* remove the old selection */
offset_x = bsp->old_col * bsp->cell_width;
offset_y = bsp->old_row * bsp->cell_height - bsp->scroll_offset;
1997-11-25 06:05:25 +08:00
ystart = CLAMP (offset_y , 0, bsp->preview->allocation.height);
yend = CLAMP (offset_y + bsp->cell_height, 0, bsp->preview->allocation.height);
1997-11-25 06:05:25 +08:00
/* set the buf to white */
1999-10-27 02:27:27 +08:00
memset (buf, 255, 3 * bsp->cell_width);
1997-11-25 06:05:25 +08:00
for (i = ystart; i < yend; i++)
{
if (i == offset_y || i == (offset_y + bsp->cell_height - 1))
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
offset_x, i, bsp->cell_width);
1997-11-25 06:05:25 +08:00
else
{
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
offset_x, i, 1);
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
offset_x + bsp->cell_width - 1, i, 1);
1997-11-25 06:05:25 +08:00
}
}
if (bsp->redraw)
{
area.x = offset_x;
area.y = ystart;
area.width = bsp->cell_width;
area.height = (yend - ystart);
gtk_widget_draw (bsp->preview, &area);
}
}
/* make the new selection */
offset_x = col * bsp->cell_width;
offset_y = row * bsp->cell_height - bsp->scroll_offset;
ystart = CLAMP (offset_y , 0, bsp->preview->allocation.height);
yend = CLAMP (offset_y + bsp->cell_height, 0, bsp->preview->allocation.height);
1997-11-25 06:05:25 +08:00
/* set the buf to black */
memset (buf, 0, bsp->cell_width * 3);
1997-11-25 06:05:25 +08:00
for (i = ystart; i < yend; i++)
{
if (i == offset_y || i == (offset_y + bsp->cell_height - 1))
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview),
buf, offset_x, i, bsp->cell_width);
1997-11-25 06:05:25 +08:00
else
{
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
offset_x, i, 1);
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
offset_x + bsp->cell_width - 1, i, 1);
1997-11-25 06:05:25 +08:00
}
}
if (bsp->redraw)
{
area.x = offset_x;
area.y = ystart;
area.width = bsp->cell_width;
area.height = (yend - ystart);
gtk_widget_draw (bsp->preview, &area);
}
bsp->old_row = row;
bsp->old_col = col;
1997-11-25 06:05:25 +08:00
g_free (buf);
}
static void
1999-10-27 02:27:27 +08:00
update_active_brush_field (BrushSelect *bsp)
{
GimpBrush *brush;
gchar buf[32];
brush = gimp_context_get_brush (bsp->context);
if (!brush)
return;
/* Set brush name */
gtk_label_set_text (GTK_LABEL (bsp->brush_name), brush->name);
/* Set brush size */
g_snprintf (buf, sizeof (buf), "(%d x %d)",
1999-10-27 02:27:27 +08:00
brush->mask->width, brush->mask->height);
gtk_label_set_text (GTK_LABEL (bsp->brush_size), buf);
/* Set brush spacing */
gtk_adjustment_set_value (GTK_ADJUSTMENT (bsp->spacing_data),
gimp_brush_get_spacing (brush));
}
static void
preview_calc_scrollbar (BrushSelect *bsp)
1997-11-25 06:05:25 +08:00
{
1999-10-27 02:27:27 +08:00
gint num_rows;
gint page_size;
gint max;
1997-11-25 06:05:25 +08:00
bsp->scroll_offset = 0;
1999-10-27 02:27:27 +08:00
num_rows = ((gimp_brush_list_length (brush_list) +
(bsp->NUM_BRUSH_COLUMNS) - 1)
/ (bsp->NUM_BRUSH_COLUMNS));
1997-11-25 06:05:25 +08:00
max = num_rows * bsp->cell_width;
1999-10-27 02:27:27 +08:00
if (!num_rows)
num_rows = 1;
1997-11-25 06:05:25 +08:00
page_size = bsp->preview->allocation.height;
1999-10-27 02:27:27 +08:00
bsp->sbar_data->value = bsp->scroll_offset;
bsp->sbar_data->upper = max;
bsp->sbar_data->page_size = ((page_size < max) ? page_size : max);
1997-11-25 06:05:25 +08:00
bsp->sbar_data->page_increment = (page_size >> 1);
bsp->sbar_data->step_increment = bsp->cell_width;
1999-10-28 23:05:49 +08:00
gtk_signal_emit_by_name (GTK_OBJECT (bsp->sbar_data), "changed");
1999-10-27 02:27:27 +08:00
gtk_signal_emit_by_name (GTK_OBJECT (bsp->sbar_data), "value_changed");
1997-11-25 06:05:25 +08:00
}
static gint
1999-10-27 02:27:27 +08:00
brush_select_resize (GtkWidget *widget,
GdkEvent *event,
BrushSelect *bsp)
1997-11-25 06:05:25 +08:00
{
/* calculate the best-fit approximation... */
gint wid;
gint now;
gint cell_size;
wid = widget->allocation.width;
1999-10-27 02:27:27 +08:00
for (now = cell_size = MIN_CELL_SIZE;
now < MAX_CELL_SIZE; ++now)
{
if ((wid % now) < (wid % cell_size)) cell_size = now;
if ((wid % cell_size) == 0)
break;
}
bsp->NUM_BRUSH_COLUMNS =
(gint) (wid / cell_size);
bsp->NUM_BRUSH_ROWS =
(gint) ((gimp_brush_list_length (brush_list) + bsp->NUM_BRUSH_COLUMNS - 1) /
bsp->NUM_BRUSH_COLUMNS);
1999-10-27 02:27:27 +08:00
bsp->cell_width = cell_size;
bsp->cell_height = cell_size;
1997-11-25 06:05:25 +08:00
/* recalculate scrollbar extents */
preview_calc_scrollbar (bsp);
return FALSE;
}
static gint
1999-10-27 02:27:27 +08:00
brush_select_events (GtkWidget *widget,
GdkEvent *event,
BrushSelect *bsp)
1997-11-25 06:05:25 +08:00
{
GdkEventButton *bevent;
1999-10-27 02:27:27 +08:00
GimpBrush *brush;
gint row, col, index;
1997-11-25 06:05:25 +08:00
switch (event->type)
{
case GDK_EXPOSE:
break;
case GDK_2BUTTON_PRESS:
bevent = (GdkEventButton *) event;
col = bevent->x / bsp->cell_width;
row = (bevent->y + bsp->scroll_offset) / bsp->cell_height;
index = row * bsp->NUM_BRUSH_COLUMNS + col;
/* Get the brush and check if it is editable */
brush = gimp_brush_list_get_brush_by_index (brush_list, index);
if (GIMP_IS_BRUSH_GENERATED (brush))
1999-10-27 02:27:27 +08:00
brush_select_edit_brush_callback (NULL, bsp);
break;
1999-10-27 02:27:27 +08:00
1997-11-25 06:05:25 +08:00
case GDK_BUTTON_PRESS:
bevent = (GdkEventButton *) event;
col = bevent->x / bsp->cell_width;
row = (bevent->y + bsp->scroll_offset) / bsp->cell_height;
index = row * bsp->NUM_BRUSH_COLUMNS + col;
brush = gimp_brush_list_get_brush_by_index (brush_list, index);
if (brush)
bsp->dnd_brush = brush;
else
bsp->dnd_brush = gimp_context_get_brush (bsp->context);
1997-11-25 06:05:25 +08:00
if (bevent->button == 1)
{
/* Get the brush and display the popup brush preview */
if (brush)
1997-11-25 06:05:25 +08:00
{
gdk_pointer_grab (bsp->preview->window, FALSE,
(GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK),
NULL, NULL, bevent->time);
/* Make this brush the active brush */
1999-10-27 02:27:27 +08:00
gimp_context_set_brush (bsp->context, brush);
/* only if dialog is main one */
1999-10-27 02:27:27 +08:00
if (bsp == brush_select_dialog &&
brush_edit_generated_dialog)
{
1999-10-27 02:27:27 +08:00
brush_edit_generated_set_brush (brush_edit_generated_dialog,
brush);
}
1997-11-25 06:05:25 +08:00
/* Show the brush popup window if the brush is too large */
if (brush->mask->width > bsp->cell_width - 2 * MARGIN_WIDTH ||
brush->mask->height > bsp->cell_height - 2 * MARGIN_HEIGHT ||
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
GIMP_IS_BRUSH_PIPE (brush))
1999-10-27 02:27:27 +08:00
{
brush_popup_open (bsp, bevent->x, bevent->y, brush);
}
1997-11-25 06:05:25 +08:00
}
}
/* wheelmouse support */
else if (bevent->button == 4)
{
GtkAdjustment *adj = bsp->sbar_data;
gfloat new_value = adj->value - adj->page_increment / 2;
new_value =
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
else if (bevent->button == 5)
{
GtkAdjustment *adj = bsp->sbar_data;
gfloat new_value = adj->value + adj->page_increment / 2;
new_value =
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
1997-11-25 06:05:25 +08:00
break;
case GDK_BUTTON_RELEASE:
bevent = (GdkEventButton *) event;
if (bevent->button == 1)
{
/* Ungrab the pointer */
gdk_pointer_ungrab (bevent->time);
/* Close the brush popup window */
brush_popup_close (bsp);
}
break;
1999-10-27 02:27:27 +08:00
1997-11-25 06:05:25 +08:00
case GDK_DELETE:
/* g_warning ("test"); */
1997-11-25 06:05:25 +08:00
break;
default:
break;
}
return FALSE;
}
1999-10-27 02:27:27 +08:00
/* Disabled until I've figured out how gtk window resizing *really* works.
* I don't think that the function below is the correct way to do it
* -- Michael
*
1997-11-25 06:05:25 +08:00
static void
1999-10-27 02:27:27 +08:00
brush_select_map_callback (GtkWidget *widget,
BrushSelect *bsp)
1997-11-25 06:05:25 +08:00
{
1999-10-27 02:27:27 +08:00
GtkAllocation allocation;
gint xdiff, ydiff;
1997-11-25 06:05:25 +08:00
1999-10-27 02:27:27 +08:00
xdiff =
bsp->shell->allocation.width - bsp->preview->allocation.width;
ydiff =
bsp->shell->allocation.height - bsp->preview->allocation.height;
1997-11-25 06:05:25 +08:00
1999-10-27 02:27:27 +08:00
allocation = bsp->shell->allocation;
allocation.width = brush_select_session_info.width + xdiff;
allocation.height = brush_select_session_info.height + ydiff;
1997-11-25 06:05:25 +08:00
1999-10-27 02:27:27 +08:00
gtk_widget_size_allocate (bsp->shell, &allocation);
1997-11-25 06:05:25 +08:00
}
1999-10-27 02:27:27 +08:00
*/
1997-11-25 06:05:25 +08:00
static void
1999-10-27 02:27:27 +08:00
brush_select_scroll_update (GtkAdjustment *adjustment,
gpointer data)
1997-11-25 06:05:25 +08:00
{
1999-10-27 02:27:27 +08:00
BrushSelect *bsp;
GimpBrush *active;
gint row, col, index;
1997-11-25 06:05:25 +08:00
1999-10-27 02:27:27 +08:00
bsp = (BrushSelect *) data;
1997-11-25 06:05:25 +08:00
if (bsp)
{
bsp->scroll_offset = adjustment->value;
1999-10-27 02:27:27 +08:00
1997-11-25 06:05:25 +08:00
display_brushes (bsp);
1999-10-27 02:27:27 +08:00
active = gimp_context_get_brush (bsp->context);
1997-11-25 06:05:25 +08:00
if (active)
{
index = gimp_brush_list_get_brush_index (brush_list, active);
if (index < 0)
return;
row = index / bsp->NUM_BRUSH_COLUMNS;
col = index - row * bsp->NUM_BRUSH_COLUMNS;
1999-10-27 02:27:27 +08:00
1997-11-25 06:05:25 +08:00
brush_select_show_selected (bsp, row, col);
}
if (bsp->redraw)
gtk_widget_draw (bsp->preview, NULL);
}
}
1999-10-27 02:27:27 +08:00
static void
opacity_scale_update (GtkAdjustment *adjustment,
gpointer data)
{
BrushSelect *bsp;
bsp = (BrushSelect *) data;
gtk_signal_handler_block_by_data (GTK_OBJECT (bsp->context), data);
1999-10-27 02:27:27 +08:00
gimp_context_set_opacity (bsp->context, adjustment->value / 100.0);
gtk_signal_handler_unblock_by_data (GTK_OBJECT (bsp->context), data);
1999-10-27 02:27:27 +08:00
}
1997-11-25 06:05:25 +08:00
static void
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
paint_mode_menu_callback (GtkWidget *widget,
gpointer data)
1997-11-25 06:05:25 +08:00
{
LayerModeEffects paint_mode;
BrushSelect *bsp;
paint_mode = (LayerModeEffects) gtk_object_get_user_data (GTK_OBJECT (widget));
bsp = (BrushSelect *) data;
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
gimp_context_set_paint_mode (((BrushSelect *) data)->context, paint_mode);
1997-11-25 06:05:25 +08:00
}
static void
1999-10-27 02:27:27 +08:00
spacing_scale_update (GtkAdjustment *adjustment,
1997-11-25 06:05:25 +08:00
gpointer data)
{
1999-10-27 02:27:27 +08:00
BrushSelect *bsp;
bsp = (BrushSelect *) data;
if (bsp == brush_select_dialog)
{
1999-10-27 02:27:27 +08:00
gimp_brush_set_spacing (gimp_context_get_brush (bsp->context),
(gint) adjustment->value);
}
else
{
1999-10-27 02:27:27 +08:00
if (bsp->spacing_value != adjustment->value)
{
bsp->spacing_value = adjustment->value;
1999-10-28 23:05:49 +08:00
brush_change_callbacks (bsp, FALSE);
1999-10-27 02:27:27 +08:00
}
}
1997-11-25 06:05:25 +08:00
}
static void
1999-10-27 02:27:27 +08:00
brush_select_close_callback (GtkWidget *widget,
gpointer data)
1997-11-25 06:05:25 +08:00
{
1999-10-27 02:27:27 +08:00
BrushSelect *bsp;
bsp = (BrushSelect *) data;
if (GTK_WIDGET_VISIBLE (bsp->shell))
gtk_widget_hide (bsp->shell);
/* Free memory if poping down dialog which is not the main one */
if (bsp != brush_select_dialog)
{
1999-10-27 02:27:27 +08:00
/* Send data back */
1999-10-28 23:05:49 +08:00
brush_change_callbacks (bsp, TRUE);
1999-10-27 02:27:27 +08:00
gtk_widget_destroy (bsp->shell);
brush_select_free (bsp);
}
1997-11-25 06:05:25 +08:00
}
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
static void
1999-10-27 02:27:27 +08:00
brush_select_refresh_callback (GtkWidget *widget,
gpointer data)
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
{
1999-10-27 02:27:27 +08:00
/* re-init the brush list */
brushes_init (FALSE);
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
}
1999-10-27 02:27:27 +08:00
static void
brush_select_new_brush_callback (GtkWidget *widget,
gpointer data)
{
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
GimpBrush *brush;
1999-10-27 02:27:27 +08:00
BrushSelect *bsp;
1999-10-27 02:27:27 +08:00
bsp = (BrushSelect *) data;
brush = gimp_brush_generated_new (10, .5, 0.0, 1.0);
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
if (brush)
{
gimp_brush_list_add (brush_list, brush);
1999-10-27 02:27:27 +08:00
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
gimp_context_set_brush (bsp->context, brush);
1999-10-27 02:27:27 +08:00
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
if (brush_edit_generated_dialog)
brush_edit_generated_set_brush (brush_edit_generated_dialog, brush);
}
1999-10-27 02:27:27 +08:00
brush_select_edit_brush_callback (widget, data);
}
static void
brush_select_edit_brush_callback (GtkWidget *widget,
gpointer data)
{
1999-10-27 02:27:27 +08:00
BrushSelect *bsp;
GimpBrush *brush;
1999-10-27 02:27:27 +08:00
bsp = (BrushSelect *) data;
brush = gimp_context_get_brush (bsp->context);
1999-10-27 02:27:27 +08:00
if (GIMP_IS_BRUSH_GENERATED (brush))
{
1999-10-27 02:27:27 +08:00
if (!brush_edit_generated_dialog)
{
1999-10-27 02:27:27 +08:00
/* Create the dialog... */
brush_edit_generated_dialog = brush_edit_generated_new ();
brush_edit_generated_set_brush (brush_edit_generated_dialog, brush);
}
else
{
/* Popup the dialog */
if (!GTK_WIDGET_VISIBLE (brush_edit_generated_dialog->shell))
gtk_widget_show (brush_edit_generated_dialog->shell);
else
gdk_window_raise (brush_edit_generated_dialog->shell->window);
}
}
1999-10-27 02:27:27 +08:00
else
2000-01-30 10:48:50 +08:00
/* this should never happen */
g_message (_("Sorry, this brush can't be edited."));
1999-10-27 02:27:27 +08:00
}
static void
brush_select_delete_brush_callback (GtkWidget *widget,
gpointer data)
{
BrushSelect *bsp;
GimpBrush *brush;
bsp = (BrushSelect *) data;
brush = gimp_context_get_brush (bsp->context);
if (GIMP_IS_BRUSH_GENERATED (brush))
{
gint index;
gimp_brush_generated_delete (GIMP_BRUSH_GENERATED (brush));
brush_select_freeze_all ();
index = gimp_brush_list_get_brush_index (brush_list, brush);
gimp_brush_list_remove (brush_list, GIMP_BRUSH (brush));
gimp_context_refresh_brushes ();
brush_select_thaw_all ();
}
else
2000-01-30 10:48:50 +08:00
/* this should never happen */
g_message (_("Sorry, this brush can't be deleted."));
}