From 958071b0c8f65e4f27ffdda70dec4470109ca32d Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Wed, 21 Nov 2001 03:54:09 +0000 Subject: [PATCH] key press and release events were sent swapped to tools. 2001-11-21 Michael Natterer * app/display/gimpdisplayshell-callbacks.c: key press and release events were sent swapped to tools. * app/tools/selection_options.[ch]: added radio buttons for the selection operation (REPLACE, ADD, ...). Partly fixes #51108. * app/tools/gimpselectiontool.[ch]: honor the new tool options stuff. Do evil things in gimp_selection_tool_modifier_key(). * app/tools/gimpbycolorselecttool.[ch]: removed most of the widgets from the by_color_select window because they are all in the selection_options now. * libgimpwidgets/gimpstock.[ch]: added new stock items for the buttons. * themes/Default/Makefile.am * themes/Default/images/Makefile.am * themes/Default/images/stock-button-selection-add.png * themes/Default/images/stock-button-selection-intersect.png * themes/Default/images/stock-button-selection-replace.png * themes/Default/images/stock-button-selection-subtract.png: new stock images. --- ChangeLog | 28 ++- app/display/gimpdisplayshell-callbacks.c | 4 +- app/tools/gimpbycolorselecttool.c | 236 ++++-------------- app/tools/gimpbycolorselecttool.h | 3 +- app/tools/gimpselectionoptions.c | 83 +++++- app/tools/gimpselectionoptions.h | 4 + app/tools/gimpselectiontool.c | 73 +++++- app/tools/gimpselectiontool.h | 3 +- app/tools/selection_options.c | 83 +++++- app/tools/selection_options.h | 4 + libgimpwidgets/gimpstock.c | 12 +- libgimpwidgets/gimpstock.h | 5 + themes/Default/Makefile.am | 84 ++++--- themes/Default/images/Makefile.am | 42 ++-- .../images/stock-button-selection-add.png | Bin 0 -> 268 bytes .../stock-button-selection-intersect.png | Bin 0 -> 253 bytes .../images/stock-button-selection-replace.png | Bin 0 -> 199 bytes .../stock-button-selection-subtract.png | Bin 0 -> 248 bytes 18 files changed, 399 insertions(+), 265 deletions(-) create mode 100644 themes/Default/images/stock-button-selection-add.png create mode 100644 themes/Default/images/stock-button-selection-intersect.png create mode 100644 themes/Default/images/stock-button-selection-replace.png create mode 100644 themes/Default/images/stock-button-selection-subtract.png diff --git a/ChangeLog b/ChangeLog index fec483950d..d5738a3ab5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +2001-11-21 Michael Natterer + + * app/display/gimpdisplayshell-callbacks.c: key press and release + events were sent swapped to tools. + + * app/tools/selection_options.[ch]: added radio buttons for the + selection operation (REPLACE, ADD, ...). Partly fixes #51108. + + * app/tools/gimpselectiontool.[ch]: honor the new tool options + stuff. Do evil things in gimp_selection_tool_modifier_key(). + + * app/tools/gimpbycolorselecttool.[ch]: removed most of the + widgets from the by_color_select window because they are all in + the selection_options now. + + * libgimpwidgets/gimpstock.[ch]: added new stock items for the + buttons. + + * themes/Default/Makefile.am + * themes/Default/images/Makefile.am + * themes/Default/images/stock-button-selection-add.png + * themes/Default/images/stock-button-selection-intersect.png + * themes/Default/images/stock-button-selection-replace.png + * themes/Default/images/stock-button-selection-subtract.png: new + stock images. + 2001-11-21 Michael Natterer * app/tools/selection_options.c: added "reset" code for the new @@ -53,7 +79,7 @@ 2001-11-20 David Neary - * app/core/gimppalette.c: Included errno,h + * app/core/gimppalette.c: Included errno.h 2001-11-20 Rebecca Walter diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c index 9246ed7fc9..88d5758f92 100644 --- a/app/display/gimpdisplayshell-callbacks.c +++ b/app/display/gimpdisplayshell-callbacks.c @@ -878,7 +878,7 @@ gimp_display_shell_canvas_events (GtkWidget *canvas, if (! gimp_image_is_empty (gdisp->gimage)) { tool_manager_modifier_key_active (gdisp->gimage->gimp, - key, FALSE, state, + key, TRUE, state, gdisp); return_val = TRUE; @@ -920,7 +920,7 @@ gimp_display_shell_canvas_events (GtkWidget *canvas, if (! gimp_image_is_empty (gdisp->gimage)) { tool_manager_modifier_key_active (gdisp->gimage->gimp, - key, TRUE, state, + key, FALSE, state, gdisp); } break; diff --git a/app/tools/gimpbycolorselecttool.c b/app/tools/gimpbycolorselecttool.c index 425227af02..aec677bc4b 100644 --- a/app/tools/gimpbycolorselecttool.c +++ b/app/tools/gimpbycolorselecttool.c @@ -72,11 +72,6 @@ struct _ByColorDialog GtkWidget *preview; GtkWidget *gimage_name; - GtkWidget *replace_button; - GtkObject *threshold_adj; - - gint threshold; /* threshold value for color select */ - gint operation; /* Add, Subtract, Replace */ GimpImage *gimage; /* gimpimage which is currently under examination */ }; @@ -135,8 +130,6 @@ static void by_color_select_select_all_callback (GtkWidget *, gpointer ); static void by_color_select_select_none_callback (GtkWidget *, gpointer ); -static void by_color_select_reset_callback (GtkWidget *, - gpointer ); static void by_color_select_close_callback (GtkWidget *, gpointer ); static void by_color_select_preview_button_press (ByColorDialog *, @@ -366,12 +359,14 @@ by_color_select_button_release (GimpTool *tool, GimpDisplay *gdisp) { GimpByColorSelectTool *by_color_sel; + GimpSelectionTool *sel_tool; SelectionOptions *sel_options; GimpDrawable *drawable; guchar *col; GimpRGB color; by_color_sel = GIMP_BY_COLOR_SELECT_TOOL (tool); + sel_tool = GIMP_SELECTION_TOOL (tool); sel_options = (SelectionOptions *) tool->tool_info->tool_options; @@ -413,8 +408,8 @@ by_color_select_button_release (GimpTool *tool, gimp_image_mask_select_by_color (gdisp->gimage, drawable, sel_options->sample_merged, &color, - by_color_dialog->threshold, - by_color_sel->operation, + sel_options->threshold, + sel_tool->op, sel_options->antialias, sel_options->feather, sel_options->feather_radius, @@ -436,36 +431,31 @@ by_color_select_oper_update (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { - GimpByColorSelectTool *by_col_sel; + GimpSelectionTool *sel_tool; + SelectionOptions *sel_options; if (tool->state == ACTIVE) return; - by_col_sel = GIMP_BY_COLOR_SELECT_TOOL (tool); + sel_tool = GIMP_SELECTION_TOOL (tool); + + sel_options = (SelectionOptions *) tool->tool_info->tool_options; if ((state & GDK_CONTROL_MASK) && (state & GDK_SHIFT_MASK)) { - by_col_sel->operation = SELECTION_INTERSECT; /* intersect with selection */ + sel_tool->op = SELECTION_INTERSECT; /* intersect with selection */ } else if (state & GDK_SHIFT_MASK) { - by_col_sel->operation = SELECTION_ADD; /* add to the selection */ + sel_tool->op = SELECTION_ADD; /* add to the selection */ } else if (state & GDK_CONTROL_MASK) { - by_col_sel->operation = SELECTION_SUB; /* subtract from the selection */ + sel_tool->op = SELECTION_SUB; /* subtract from the selection */ } else { - if (by_color_dialog) - { - /* To be careful, set it to by_select_dialog's default */ - by_col_sel->operation = by_color_dialog->operation; - } - else - { - by_col_sel->operation = SELECTION_REPLACE; - } + sel_tool->op = sel_options->op; } } @@ -488,61 +478,18 @@ by_color_select_cursor_update (GimpTool *tool, layer = gimp_image_pick_correlate_layer (gdisp->gimage, coords->x, coords->y); - if (sel_options->sample_merged || - (layer && layer == gdisp->gimage->active_layer)) + if (! sel_options->sample_merged && + layer && layer != gdisp->gimage->active_layer) { - switch (by_col_sel->operation) - { - case SELECTION_ADD: - gimp_display_shell_install_tool_cursor (shell, - GIMP_MOUSE_CURSOR, - GIMP_TOOL_CURSOR_NONE, - GIMP_CURSOR_MODIFIER_PLUS); - break; - case SELECTION_SUB: - gimp_display_shell_install_tool_cursor (shell, - GIMP_MOUSE_CURSOR, - GIMP_TOOL_CURSOR_NONE, - GIMP_CURSOR_MODIFIER_MINUS); - break; - case SELECTION_INTERSECT: - gimp_display_shell_install_tool_cursor (shell, - GIMP_MOUSE_CURSOR, - GIMP_TOOL_CURSOR_NONE, - GIMP_CURSOR_MODIFIER_INTERSECT); - break; - case SELECTION_REPLACE: - gimp_display_shell_install_tool_cursor (shell, - GIMP_MOUSE_CURSOR, - GIMP_TOOL_CURSOR_NONE, - GIMP_CURSOR_MODIFIER_NONE); - break; - case SELECTION_MOVE_MASK: - gimp_display_shell_install_tool_cursor (shell, - GIMP_MOUSE_CURSOR, - GIMP_RECT_SELECT_TOOL_CURSOR, - GIMP_CURSOR_MODIFIER_MOVE); - break; - case SELECTION_MOVE: - gimp_display_shell_install_tool_cursor (shell, - GIMP_MOUSE_CURSOR, - GIMP_MOVE_TOOL_CURSOR, - GIMP_CURSOR_MODIFIER_NONE); - break; - case SELECTION_ANCHOR: - gimp_display_shell_install_tool_cursor (shell, - GIMP_MOUSE_CURSOR, - GIMP_RECT_SELECT_TOOL_CURSOR, - GIMP_CURSOR_MODIFIER_ANCHOR); - } - - return; + gimp_display_shell_install_tool_cursor (shell, + GIMP_BAD_CURSOR, + tool->tool_cursor, + GIMP_CURSOR_MODIFIER_NONE); + } + else + { + GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp); } - - gimp_display_shell_install_tool_cursor (shell, - GIMP_BAD_CURSOR, - GIMP_TOOL_CURSOR_NONE, - GIMP_CURSOR_MODIFIER_NONE); } void @@ -560,19 +507,13 @@ static ByColorDialog * by_color_select_dialog_new (void) { ByColorDialog *bcd; - GtkWidget *hbox; - GtkWidget *frame; - GtkWidget *options_box; - GtkWidget *label; - GtkWidget *util_box; - GtkWidget *slider; - GtkWidget *table; - GtkWidget *button; + GtkWidget *vbox; + GtkWidget *frame; + GtkWidget *hbox; + GtkWidget *button; bcd = g_new (ByColorDialog, 1); bcd->gimage = NULL; - bcd->operation = SELECTION_REPLACE; - bcd->threshold = gimprc.default_threshold; /* The shell and main vbox */ bcd->shell = gimp_dialog_new (_("By Color Selection"), "by_color_selection", @@ -580,25 +521,30 @@ by_color_select_dialog_new (void) GTK_WIN_POS_NONE, FALSE, TRUE, FALSE, - _("Reset"), by_color_select_reset_callback, - bcd, NULL, NULL, FALSE, FALSE, - GTK_STOCK_CLOSE, by_color_select_close_callback, + "_delete_event_", by_color_select_close_callback, bcd, NULL, NULL, TRUE, TRUE, NULL); - /* The main hbox */ - hbox = gtk_hbox_new (FALSE, 4); - gtk_container_set_border_width (GTK_CONTAINER (hbox), 4); - gtk_container_add (GTK_CONTAINER (GTK_DIALOG (bcd->shell)->vbox), hbox); + gtk_dialog_set_has_separator (GTK_DIALOG (bcd->shell), FALSE); + gtk_widget_hide (GTK_DIALOG (bcd->shell)->action_area); + + /* The main vbox */ + vbox = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (bcd->shell)->vbox), vbox); + gtk_widget_show (vbox); + + /* Create the active image label */ + bcd->gimage_name = gtk_label_new (_("Inactive")); + gtk_misc_set_alignment (GTK_MISC (bcd->gimage_name), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (vbox), bcd->gimage_name, FALSE, FALSE, 0); + gtk_widget_show (bcd->gimage_name); /* The preview */ - util_box = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), util_box, FALSE, FALSE, 0); - frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); - gtk_box_pack_start (GTK_BOX (util_box), frame, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); bcd->preview = gtk_preview_new (GTK_PREVIEW_GRAYSCALE); gtk_preview_size (GTK_PREVIEW (bcd->preview), PREVIEW_WIDTH, PREVIEW_HEIGHT); @@ -621,75 +567,18 @@ by_color_select_dialog_new (void) gtk_widget_show (bcd->preview); gtk_widget_show (frame); - gtk_widget_show (util_box); - - /* options box */ - options_box = gtk_vbox_new (FALSE, 4); - gtk_box_pack_start (GTK_BOX (hbox), options_box, FALSE, FALSE, 0); - - /* Create the active image label */ - util_box = gtk_hbox_new (FALSE, 2); - gtk_box_pack_start (GTK_BOX (options_box), util_box, FALSE, FALSE, 0); - - bcd->gimage_name = gtk_label_new (_("Inactive")); - gtk_box_pack_start (GTK_BOX (util_box), bcd->gimage_name, FALSE, FALSE, 0); - - gtk_widget_show (bcd->gimage_name); - gtk_widget_show (util_box); - - /* Create the selection mode radio box */ - frame = gimp_radio_group_new2 - (TRUE, _("Selection Mode"), - G_CALLBACK (gimp_radio_button_update), - &bcd->operation, - GINT_TO_POINTER (bcd->operation), - - _("Replace"), GINT_TO_POINTER (SELECTION_REPLACE), &bcd->replace_button, - _("Add"), GINT_TO_POINTER (SELECTION_ADD), NULL, - _("Subtract"), GINT_TO_POINTER (SELECTION_SUB), NULL, - _("Intersect"), GINT_TO_POINTER (SELECTION_INTERSECT), NULL, - - NULL); - - gtk_box_pack_start (GTK_BOX (options_box), frame, FALSE, FALSE, 0); - gtk_widget_show (frame); - - /* Create the opacity scale widget */ - util_box = gtk_vbox_new (FALSE, 2); - gtk_box_pack_start (GTK_BOX (options_box), util_box, FALSE, FALSE, 0); - - label = gtk_label_new (_("Fuzziness Threshold")); - gtk_box_pack_start (GTK_BOX (util_box), label, FALSE, FALSE, 2); - - gtk_widget_show (label); - gtk_widget_show (util_box); - - bcd->threshold_adj = - gtk_adjustment_new (bcd->threshold, 0.0, 255.0, 1.0, 1.0, 0.0); - slider = gtk_hscale_new (GTK_ADJUSTMENT (bcd->threshold_adj)); - gtk_box_pack_start (GTK_BOX (util_box), slider, TRUE, TRUE, 0); - gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP); - gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); - - g_signal_connect (G_OBJECT (bcd->threshold_adj), "value_changed", - G_CALLBACK (gimp_int_adjustment_update), - &bcd->threshold); - - gtk_widget_show (slider); frame = gtk_frame_new (_("Selection")); - gtk_box_pack_end (GTK_BOX (options_box), frame, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); - table = gtk_table_new (2, 2, TRUE); - gtk_container_set_border_width (GTK_CONTAINER (table), 2); - gtk_table_set_col_spacings (GTK_TABLE (table), 2); - gtk_table_set_row_spacings (GTK_TABLE (table), 2); - gtk_container_add (GTK_CONTAINER (frame), table); - gtk_widget_show (table); + hbox = gtk_hbox_new (TRUE, 2); + gtk_container_set_border_width (GTK_CONTAINER (hbox), 2); + gtk_container_add (GTK_CONTAINER (frame), hbox); + gtk_widget_show (hbox); button = gtk_button_new_with_label (_("Invert")); - gtk_table_attach_defaults (GTK_TABLE (table), button, 0, 2, 0, 1); + gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); gtk_widget_show (button); g_signal_connect (G_OBJECT (button), "clicked", @@ -697,7 +586,7 @@ by_color_select_dialog_new (void) bcd); button = gtk_button_new_with_label (_("All")); - gtk_table_attach_defaults (GTK_TABLE (table), button, 0, 1, 1, 2); + gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); gtk_widget_show (button); g_signal_connect (G_OBJECT (button), "clicked", @@ -705,15 +594,13 @@ by_color_select_dialog_new (void) bcd); button = gtk_button_new_with_label (_("None")); - gtk_table_attach_defaults (GTK_TABLE (table), button, 1, 2, 1, 2); + gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); gtk_widget_show (button); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (by_color_select_select_none_callback), bcd); - gtk_widget_show (options_box); - gtk_widget_show (hbox); gtk_widget_show (bcd->shell); return bcd; @@ -868,19 +755,6 @@ by_color_select_preview_events (GtkWidget *widget, return FALSE; } -static void -by_color_select_reset_callback (GtkWidget *widget, - gpointer data) -{ - ByColorDialog *bcd; - - bcd = (ByColorDialog *) data; - - gtk_widget_activate (bcd->replace_button); - gtk_adjustment_set_value (GTK_ADJUSTMENT (bcd->threshold_adj), - gimprc.default_threshold); -} - static void by_color_select_invert_callback (GtkWidget *widget, gpointer data) @@ -1021,7 +895,7 @@ by_color_select_preview_button_press (ByColorDialog *bcd, (bevent->state & GDK_SHIFT_MASK)) operation = SELECTION_INTERSECT; else - operation = by_color_dialog->operation; + operation = sel_options->op; /* Find x, y and modify selection */ @@ -1061,7 +935,7 @@ by_color_select_preview_button_press (ByColorDialog *bcd, gimp_image_mask_select_by_color (bcd->gimage, drawable, sel_options->sample_merged, &color, - bcd->threshold, + sel_options->threshold, operation, sel_options->antialias, sel_options->feather, @@ -1099,8 +973,8 @@ by_color_select_color_drop (GtkWidget *widget, gimp_image_mask_select_by_color (bcd->gimage, drawable, sel_options->sample_merged, color, - bcd->threshold, - bcd->operation, + sel_options->threshold, + sel_options->op, sel_options->antialias, sel_options->feather, sel_options->feather_radius, diff --git a/app/tools/gimpbycolorselecttool.h b/app/tools/gimpbycolorselecttool.h index ae81fbddcc..83c7826091 100644 --- a/app/tools/gimpbycolorselecttool.h +++ b/app/tools/gimpbycolorselecttool.h @@ -40,8 +40,7 @@ struct _GimpByColorSelectTool { GimpSelectionTool parent_instance; - gint x, y; /* Point from which to execute seed fill */ - SelectOps operation; /* add, subtract, normal color selection */ + gint x, y; /* Point from which to execute seed fill */ }; diff --git a/app/tools/gimpselectionoptions.c b/app/tools/gimpselectionoptions.c index 3e66a9ed44..1d99dc94b1 100644 --- a/app/tools/gimpselectionoptions.c +++ b/app/tools/gimpselectionoptions.c @@ -60,9 +60,15 @@ selection_options_init (SelectionOptions *options, vbox = options->tool_options.main_vbox; /* initialize the selection options structure */ + options->op = options->op_d = SELECTION_REPLACE; options->feather = options->feather_d = FALSE; options->feather_radius = options->feather_radius_d = 10.0; - options->antialias = options->antialias_d = TRUE; + + if (tool_info->tool_type == GIMP_TYPE_RECT_SELECT_TOOL) + options->antialias = options->antialias_d = FALSE; + else + options->antialias = options->antialias_d = TRUE; + options->sample_merged = options->sample_merged_d = FALSE; options->threshold = gimprc.default_threshold; options->auto_shrink = options->auto_shrink_d = FALSE; @@ -86,6 +92,63 @@ selection_options_init (SelectionOptions *options, options->fixed_unit_w = NULL; options->interactive_w = NULL; + /* the selection operation radio buttons */ + { + struct + { + SelectOps op; + const gchar *stock_id; + } + select_op_entries[] = + { + { SELECTION_REPLACE, GIMP_STOCK_SELECTION_REPLACE }, + { SELECTION_ADD, GIMP_STOCK_SELECTION_ADD }, + { SELECTION_SUB, GIMP_STOCK_SELECTION_SUBTRACT }, + { SELECTION_INTERSECT, GIMP_STOCK_SELECTION_INTERSECT } + }; + + GtkWidget *hbox; + GtkWidget *label; + GtkWidget *image; + GSList *group = NULL; + gint i; + + hbox = gtk_hbox_new (FALSE, 2); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + gtk_widget_show (hbox); + + label = gtk_label_new (_("Mode:")); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + + for (i = 0; i < G_N_ELEMENTS (select_op_entries); i++) + { + options->op_w[i] = gtk_radio_button_new (group); + group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (options->op_w[i])); + gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (options->op_w[i]), + FALSE); + gtk_box_pack_start (GTK_BOX (hbox), options->op_w[i], FALSE, FALSE, 0); + gtk_widget_show (options->op_w[i]); + + image = gtk_image_new_from_stock (select_op_entries[i].stock_id, + GTK_ICON_SIZE_BUTTON); + gtk_container_add (GTK_CONTAINER (options->op_w[i]), image); + gtk_widget_show (image); + + if (select_op_entries[i].op == options->op) + { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->op_w[i]), + TRUE); + } + + g_object_set_data (G_OBJECT (options->op_w[i]), "user_data", + GINT_TO_POINTER (select_op_entries[i].op)); + g_signal_connect (G_OBJECT (options->op_w[i]), "toggled", + G_CALLBACK (gimp_radio_button_update), + &options->op); + } + } + /* the feather toggle button */ table = gtk_table_new (2, 2, FALSE); gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4); @@ -135,14 +198,18 @@ selection_options_init (SelectionOptions *options, gtk_widget_show (table); /* the antialias toggle button */ - if (tool_info->tool_type != GIMP_TYPE_RECT_SELECT_TOOL) - { - options->antialias_w = gtk_check_button_new_with_label (_("Antialiasing")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->antialias_w), - options->antialias_d); - gtk_box_pack_start (GTK_BOX (vbox), options->antialias_w, FALSE, FALSE, 0); - gtk_widget_show (options->antialias_w); + options->antialias_w = gtk_check_button_new_with_label (_("Antialiasing")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->antialias_w), + options->antialias_d); + gtk_box_pack_start (GTK_BOX (vbox), options->antialias_w, FALSE, FALSE, 0); + gtk_widget_show (options->antialias_w); + if (tool_info->tool_type == GIMP_TYPE_RECT_SELECT_TOOL) + { + gtk_widget_set_sensitive (options->antialias_w, FALSE); + } + else + { g_signal_connect (G_OBJECT (options->antialias_w), "toggled", G_CALLBACK (gimp_toggle_button_update), &options->antialias); diff --git a/app/tools/gimpselectionoptions.h b/app/tools/gimpselectionoptions.h index 3817681c92..cd1970ccfb 100644 --- a/app/tools/gimpselectionoptions.h +++ b/app/tools/gimpselectionoptions.h @@ -30,6 +30,10 @@ struct _SelectionOptions GimpToolOptions tool_options; /* options used by all selection tools */ + SelectOps op; + SelectOps op_d; + GtkWidget *op_w[4]; /* 4 radio buttons */ + gboolean feather; gboolean feather_d; GtkWidget *feather_w; diff --git a/app/tools/gimpselectiontool.c b/app/tools/gimpselectiontool.c index ac2b628abb..b660d911e5 100644 --- a/app/tools/gimpselectiontool.c +++ b/app/tools/gimpselectiontool.c @@ -25,17 +25,24 @@ #include "core/gimpimage.h" #include "core/gimpimage-mask.h" +#include "core/gimptoolinfo.h" #include "display/gimpdisplay.h" #include "display/gimpdisplayshell.h" #include "gimpdrawtool.h" #include "gimpselectiontool.h" +#include "selection_options.h" static void gimp_selection_tool_class_init (GimpSelectionToolClass *klass); static void gimp_selection_tool_init (GimpSelectionTool *selection_tool); +static void gimp_selection_tool_modifier_key (GimpTool *tool, + GdkModifierType key, + gboolean press, + GdkModifierType state, + GimpDisplay *gdisp); static void gimp_selection_tool_oper_update (GimpTool *tool, GimpCoords *coords, GdkModifierType state, @@ -86,6 +93,7 @@ gimp_selection_tool_class_init (GimpSelectionToolClass *klass) parent_class = g_type_class_peek_parent (klass); + tool_class->modifier_key = gimp_selection_tool_modifier_key; tool_class->oper_update = gimp_selection_tool_oper_update; tool_class->cursor_update = gimp_selection_tool_cursor_update; } @@ -97,7 +105,62 @@ gimp_selection_tool_init (GimpSelectionTool *selection_tool) tool = GIMP_TOOL (selection_tool); - selection_tool->op = SELECTION_REPLACE; + selection_tool->op = SELECTION_REPLACE; + selection_tool->saved_op = SELECTION_REPLACE; +} + +static void +gimp_selection_tool_modifier_key (GimpTool *tool, + GdkModifierType key, + gboolean press, + GdkModifierType state, + GimpDisplay *gdisp) +{ + GimpSelectionTool *selection_tool; + SelectionOptions *sel_options; + gint eek[4] = { 1, 2, 0, 3 }; + gint press_button = -1; + + selection_tool = GIMP_SELECTION_TOOL (tool); + + sel_options = (SelectionOptions *) tool->tool_info->tool_options; + + if (key == GDK_SHIFT_MASK || key == GDK_CONTROL_MASK) + { + if (press) + { + if (key == state) /* first modifier pressed */ + { + selection_tool->saved_op = sel_options->op; + } + } + else + { + if (! state) /* last modifier released */ + { + press_button = eek[selection_tool->saved_op]; + } + } + + if ((state & GDK_CONTROL_MASK) && (state & GDK_SHIFT_MASK)) + { + press_button = eek[SELECTION_INTERSECT]; + } + else if (state & GDK_SHIFT_MASK) + { + press_button = eek[SELECTION_ADD]; + } + else if (state & GDK_CONTROL_MASK) + { + press_button = eek[SELECTION_SUB]; + } + + if (press_button != -1) + { + gtk_toggle_button_set_active + (GTK_TOGGLE_BUTTON (sel_options->op_w[press_button]), TRUE); + } + } } static void @@ -107,16 +170,18 @@ gimp_selection_tool_oper_update (GimpTool *tool, GimpDisplay *gdisp) { GimpSelectionTool *selection_tool; + SelectionOptions *sel_options; GimpLayer *layer; GimpLayer *floating_sel; selection_tool = GIMP_SELECTION_TOOL (tool); + sel_options = (SelectionOptions *) tool->tool_info->tool_options; + if (tool->state == ACTIVE) return; - layer = gimp_image_pick_correlate_layer (gdisp->gimage, - coords->x, coords->y); + layer = gimp_image_pick_correlate_layer (gdisp->gimage, coords->x, coords->y); floating_sel = gimp_image_floating_sel (gdisp->gimage); if ((state & GDK_MOD1_MASK) && ! gimage_mask_is_empty (gdisp->gimage)) @@ -149,7 +214,7 @@ gimp_selection_tool_oper_update (GimpTool *tool, } else { - selection_tool->op = SELECTION_REPLACE; /* replace the selection */ + selection_tool->op = sel_options->op; } } diff --git a/app/tools/gimpselectiontool.h b/app/tools/gimpselectiontool.h index cbe262ca7e..53d32faae1 100644 --- a/app/tools/gimpselectiontool.h +++ b/app/tools/gimpselectiontool.h @@ -38,7 +38,8 @@ struct _GimpSelectionTool { GimpDrawTool parent_instance; - SelectOps op; /* selection operation (SELECTION_ADD etc.) */ + SelectOps op; /* selection operation (SELECTION_ADD etc.) */ + SelectOps saved_op; /* saved tool options state */ }; struct _GimpSelectionToolClass diff --git a/app/tools/selection_options.c b/app/tools/selection_options.c index 3e66a9ed44..1d99dc94b1 100644 --- a/app/tools/selection_options.c +++ b/app/tools/selection_options.c @@ -60,9 +60,15 @@ selection_options_init (SelectionOptions *options, vbox = options->tool_options.main_vbox; /* initialize the selection options structure */ + options->op = options->op_d = SELECTION_REPLACE; options->feather = options->feather_d = FALSE; options->feather_radius = options->feather_radius_d = 10.0; - options->antialias = options->antialias_d = TRUE; + + if (tool_info->tool_type == GIMP_TYPE_RECT_SELECT_TOOL) + options->antialias = options->antialias_d = FALSE; + else + options->antialias = options->antialias_d = TRUE; + options->sample_merged = options->sample_merged_d = FALSE; options->threshold = gimprc.default_threshold; options->auto_shrink = options->auto_shrink_d = FALSE; @@ -86,6 +92,63 @@ selection_options_init (SelectionOptions *options, options->fixed_unit_w = NULL; options->interactive_w = NULL; + /* the selection operation radio buttons */ + { + struct + { + SelectOps op; + const gchar *stock_id; + } + select_op_entries[] = + { + { SELECTION_REPLACE, GIMP_STOCK_SELECTION_REPLACE }, + { SELECTION_ADD, GIMP_STOCK_SELECTION_ADD }, + { SELECTION_SUB, GIMP_STOCK_SELECTION_SUBTRACT }, + { SELECTION_INTERSECT, GIMP_STOCK_SELECTION_INTERSECT } + }; + + GtkWidget *hbox; + GtkWidget *label; + GtkWidget *image; + GSList *group = NULL; + gint i; + + hbox = gtk_hbox_new (FALSE, 2); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + gtk_widget_show (hbox); + + label = gtk_label_new (_("Mode:")); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + + for (i = 0; i < G_N_ELEMENTS (select_op_entries); i++) + { + options->op_w[i] = gtk_radio_button_new (group); + group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (options->op_w[i])); + gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (options->op_w[i]), + FALSE); + gtk_box_pack_start (GTK_BOX (hbox), options->op_w[i], FALSE, FALSE, 0); + gtk_widget_show (options->op_w[i]); + + image = gtk_image_new_from_stock (select_op_entries[i].stock_id, + GTK_ICON_SIZE_BUTTON); + gtk_container_add (GTK_CONTAINER (options->op_w[i]), image); + gtk_widget_show (image); + + if (select_op_entries[i].op == options->op) + { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->op_w[i]), + TRUE); + } + + g_object_set_data (G_OBJECT (options->op_w[i]), "user_data", + GINT_TO_POINTER (select_op_entries[i].op)); + g_signal_connect (G_OBJECT (options->op_w[i]), "toggled", + G_CALLBACK (gimp_radio_button_update), + &options->op); + } + } + /* the feather toggle button */ table = gtk_table_new (2, 2, FALSE); gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4); @@ -135,14 +198,18 @@ selection_options_init (SelectionOptions *options, gtk_widget_show (table); /* the antialias toggle button */ - if (tool_info->tool_type != GIMP_TYPE_RECT_SELECT_TOOL) - { - options->antialias_w = gtk_check_button_new_with_label (_("Antialiasing")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->antialias_w), - options->antialias_d); - gtk_box_pack_start (GTK_BOX (vbox), options->antialias_w, FALSE, FALSE, 0); - gtk_widget_show (options->antialias_w); + options->antialias_w = gtk_check_button_new_with_label (_("Antialiasing")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->antialias_w), + options->antialias_d); + gtk_box_pack_start (GTK_BOX (vbox), options->antialias_w, FALSE, FALSE, 0); + gtk_widget_show (options->antialias_w); + if (tool_info->tool_type == GIMP_TYPE_RECT_SELECT_TOOL) + { + gtk_widget_set_sensitive (options->antialias_w, FALSE); + } + else + { g_signal_connect (G_OBJECT (options->antialias_w), "toggled", G_CALLBACK (gimp_toggle_button_update), &options->antialias); diff --git a/app/tools/selection_options.h b/app/tools/selection_options.h index 3817681c92..cd1970ccfb 100644 --- a/app/tools/selection_options.h +++ b/app/tools/selection_options.h @@ -30,6 +30,10 @@ struct _SelectionOptions GimpToolOptions tool_options; /* options used by all selection tools */ + SelectOps op; + SelectOps op_d; + GtkWidget *op_w[4]; /* 4 radio buttons */ + gboolean feather; gboolean feather_d; GtkWidget *feather_w; diff --git a/libgimpwidgets/gimpstock.c b/libgimpwidgets/gimpstock.c index 2a5d3a1f66..d1c116ddd9 100644 --- a/libgimpwidgets/gimpstock.c +++ b/libgimpwidgets/gimpstock.c @@ -105,7 +105,12 @@ static GtkStockItem gimp_stock_items[] = { GIMP_STOCK_NAVIGATION, NULL, 0, 0, "gimp-libgimp" }, { GIMP_STOCK_QMASK_OFF, NULL, 0, 0, "gimp-libgimp" }, - { GIMP_STOCK_QMASK_ON, NULL, 0, 0, "gimp-libgimp" } + { GIMP_STOCK_QMASK_ON, NULL, 0, 0, "gimp-libgimp" }, + + { GIMP_STOCK_SELECTION_REPLACE, NULL, 0, 0, "gimp-libgimp" }, + { GIMP_STOCK_SELECTION_ADD, NULL, 0, 0, "gimp-libgimp" }, + { GIMP_STOCK_SELECTION_SUBTRACT, NULL, 0, 0, "gimp-libgimp" }, + { GIMP_STOCK_SELECTION_INTERSECT, NULL, 0, 0, "gimp-libgimp" } }; static struct @@ -133,6 +138,11 @@ gimp_stock_button_pixbufs[] = { GIMP_STOCK_TO_SELECTION, stock_button_to_selection }, { GIMP_STOCK_VISIBLE, stock_button_eye }, + { GIMP_STOCK_SELECTION_REPLACE, stock_button_selection_replace }, + { GIMP_STOCK_SELECTION_ADD, stock_button_selection_add }, + { GIMP_STOCK_SELECTION_SUBTRACT, stock_button_selection_subtract }, + { GIMP_STOCK_SELECTION_INTERSECT, stock_button_selection_intersect }, + { GIMP_STOCK_TOOL_AIRBRUSH, stock_tool_button_airbrush }, { GIMP_STOCK_TOOL_BEZIER_SELECT, stock_tool_button_bezier_select }, { GIMP_STOCK_TOOL_BLEND, stock_tool_button_blend }, diff --git a/libgimpwidgets/gimpstock.h b/libgimpwidgets/gimpstock.h index 2522d224e7..e5365f0508 100644 --- a/libgimpwidgets/gimpstock.h +++ b/libgimpwidgets/gimpstock.h @@ -52,6 +52,11 @@ extern "C" { #define GIMP_STOCK_QMASK_OFF "gimp-qmask-off" #define GIMP_STOCK_QMASK_ON "gimp-qmask-on" +#define GIMP_STOCK_SELECTION_REPLACE "gimp-selection-replace" +#define GIMP_STOCK_SELECTION_ADD "gimp-selection-add" +#define GIMP_STOCK_SELECTION_SUBTRACT "gimp-selection-subtract" +#define GIMP_STOCK_SELECTION_INTERSECT "gimp-selection-intersect" + #define GIMP_STOCK_TOOL_AIRBRUSH "gimp-tool-airbrush" #define GIMP_STOCK_TOOL_BEZIER_SELECT "gimp-tool-bezier-select" #define GIMP_STOCK_TOOL_BLEND "gimp-tool-blend" diff --git a/themes/Default/Makefile.am b/themes/Default/Makefile.am index efc2b7e9d8..f2b1f5c62f 100644 --- a/themes/Default/Makefile.am +++ b/themes/Default/Makefile.am @@ -9,45 +9,53 @@ themedata_DATA = gtkrc imagerc EXTRA_DIST = $(themedata_DATA) STOCK_VARIABLES = @STRIP_BEGIN@ \ - stock_button_anchor \ - $(srcdir)/images/stock-button-anchor.png \ - stock_button_delete \ - $(srcdir)/images/stock-button-delete.png \ - stock_button_duplicate \ - $(srcdir)/images/stock-button-duplicate.png \ - stock_button_edit \ - $(srcdir)/images/stock-button-edit.png \ - stock_button_eye \ - $(srcdir)/images/stock-button-eye.png \ - stock_button_linked \ - $(srcdir)/images/stock-button-linked.png \ - stock_button_lower \ - $(srcdir)/images/stock-button-lower.png \ - stock_button_new \ - $(srcdir)/images/stock-button-new.png \ - stock_button_paste \ - $(srcdir)/images/stock-button-paste.png \ - stock_button_paste_as_new \ - $(srcdir)/images/stock-button-paste-as-new.png \ - stock_button_paste_into \ - $(srcdir)/images/stock-button-paste-into.png \ - stock_button_raise \ - $(srcdir)/images/stock-button-raise.png \ - stock_button_refresh \ - $(srcdir)/images/stock-button-refresh.png \ - stock_button_stroke \ - $(srcdir)/images/stock-button-stroke.png \ - stock_button_to_path \ - $(srcdir)/images/stock-button-to-path.png \ - stock_button_to_selection \ - $(srcdir)/images/stock-button-to-selection.png \ + stock_button_anchor \ + $(srcdir)/images/stock-button-anchor.png \ + stock_button_delete \ + $(srcdir)/images/stock-button-delete.png \ + stock_button_duplicate \ + $(srcdir)/images/stock-button-duplicate.png \ + stock_button_edit \ + $(srcdir)/images/stock-button-edit.png \ + stock_button_eye \ + $(srcdir)/images/stock-button-eye.png \ + stock_button_linked \ + $(srcdir)/images/stock-button-linked.png \ + stock_button_lower \ + $(srcdir)/images/stock-button-lower.png \ + stock_button_new \ + $(srcdir)/images/stock-button-new.png \ + stock_button_paste \ + $(srcdir)/images/stock-button-paste.png \ + stock_button_paste_as_new \ + $(srcdir)/images/stock-button-paste-as-new.png \ + stock_button_paste_into \ + $(srcdir)/images/stock-button-paste-into.png \ + stock_button_raise \ + $(srcdir)/images/stock-button-raise.png \ + stock_button_refresh \ + $(srcdir)/images/stock-button-refresh.png \ + stock_button_stroke \ + $(srcdir)/images/stock-button-stroke.png \ + stock_button_to_path \ + $(srcdir)/images/stock-button-to-path.png \ + stock_button_to_selection \ + $(srcdir)/images/stock-button-to-selection.png \ + stock_button_selection_replace \ + $(srcdir)/images/stock-button-selection-replace.png \ + stock_button_selection_add \ + $(srcdir)/images/stock-button-selection-add.png \ + stock_button_selection_subtract \ + $(srcdir)/images/stock-button-selection-subtract.png \ + stock_button_selection_intersect \ + $(srcdir)/images/stock-button-selection-intersect.png \ \ - stock_menu_navigation \ - $(srcdir)/images/stock-menu-navigation.png \ - stock_menu_qmask_off \ - $(srcdir)/images/stock-menu-qmask-off.png \ - stock_menu_qmask_on \ - $(srcdir)/images/stock-menu-qmask-on.png \ + stock_menu_navigation \ + $(srcdir)/images/stock-menu-navigation.png \ + stock_menu_qmask_off \ + $(srcdir)/images/stock-menu-qmask-off.png \ + stock_menu_qmask_on \ + $(srcdir)/images/stock-menu-qmask-on.png \ @STRIP_END@ STOCK_TOOL_VARIABLES = @STRIP_BEGIN@ \ diff --git a/themes/Default/images/Makefile.am b/themes/Default/images/Makefile.am index add25edf2f..dc28773037 100644 --- a/themes/Default/images/Makefile.am +++ b/themes/Default/images/Makefile.am @@ -5,25 +5,29 @@ SUBDIRS = tools themedatadir = $(gimpdatadir)/themes/Default/images STOCK_IMAGES = @STRIP_BEGIN@ \ - stock-button-anchor.png \ - stock-button-delete.png \ - stock-button-duplicate.png \ - stock-button-edit.png \ - stock-button-eye.png \ - stock-button-linked.png \ - stock-button-lower.png \ - stock-button-new.png \ - stock-button-paste.png \ - stock-button-paste-as-new.png \ - stock-button-paste-into.png \ - stock-button-stroke.png \ - stock-button-raise.png \ - stock-button-refresh.png \ - stock-button-to-path.png \ - stock-button-to-selection.png \ - stock-menu-navigation.png \ - stock-menu-qmask-off.png \ - stock-menu-qmask-on.png \ + stock-button-anchor.png \ + stock-button-delete.png \ + stock-button-duplicate.png \ + stock-button-edit.png \ + stock-button-eye.png \ + stock-button-linked.png \ + stock-button-lower.png \ + stock-button-new.png \ + stock-button-paste.png \ + stock-button-paste-as-new.png \ + stock-button-paste-into.png \ + stock-button-stroke.png \ + stock-button-raise.png \ + stock-button-refresh.png \ + stock-button-to-path.png \ + stock-button-to-selection.png \ + stock-button-selection-replace.png \ + stock-button-selection-add.png \ + stock-button-selection-subtract.png \ + stock-button-selection-intersect.png \ + stock-menu-navigation.png \ + stock-menu-qmask-off.png \ + stock-menu-qmask-on.png \ @STRIP_END@ themedata_DATA = $(STOCK_IMAGES) diff --git a/themes/Default/images/stock-button-selection-add.png b/themes/Default/images/stock-button-selection-add.png new file mode 100644 index 0000000000000000000000000000000000000000..b2f347e153b80720c3b5acfca9e29bc04f4ea395 GIT binary patch literal 268 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjY)RhkE%y{W;-5;PJdx@v7EBi%mQ3hj^3w24tK%tqQE{-7;bKZtH@--Xq6btY#uy36{ zVg4rhis^YXx{Nx^OjK$-7cc7!-p;s=Z?ftB8LxZ8=B|A2Jack&>3Yson}+$~8QIb& zWmOW>s&%>VH#ntST_Ejl)0QZH`pLcv`q@bbj)|r+DNgv@yhiN8g2e$vSpVn< zwvOoGn%lKLU%qkPWu`C|L#usL?|e1A!IfmDD4q7byn^YuNVU!6p2+<`M>2T2`njxg HN@xNAe^*?y literal 0 HcmV?d00001 diff --git a/themes/Default/images/stock-button-selection-intersect.png b/themes/Default/images/stock-button-selection-intersect.png new file mode 100644 index 0000000000000000000000000000000000000000..62323d9362304466075ba28ac956eebd250c3597 GIT binary patch literal 253 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjY)RhkE%y{W;-5;PJdx@v7EBi%mQ3eymPmcubfkIuLE{-7;bKZtH@--;%XdmPM5mI+3 z_^+caLz;$?j$8A>>5d$4PkA)nOFS}*zv%6Zr)^gB##W;)kbC{ghb>Fu zkGwk1s@`uLv3BjNqC&ly@dD}l>f$FB>uktq-5*E67-4p!&6zD1jPgg&ebxsLQ0J!v6hX4Qo literal 0 HcmV?d00001 diff --git a/themes/Default/images/stock-button-selection-replace.png b/themes/Default/images/stock-button-selection-replace.png new file mode 100644 index 0000000000000000000000000000000000000000..a80f5001196b255a82baeae3af4620c682a9bd48 GIT binary patch literal 199 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjY)RhkE%y{W;-5;PJdx@v7EBi%mQ3fN+?N{{Q1BF67T^vIy<|HRbur>?+`40s3Tp1z< zI?jIKZ*5K4=~Hlsg~xcNK~Bn%4U;n(jxx^>O9*z+Iq+;pp!|Y{KzRX{#dZoDZOi#L lXf9f^Lhb(V#SLi;45~|O&-C&=Is!DG!PC{xWt~$(69C%jKo|f3 literal 0 HcmV?d00001 diff --git a/themes/Default/images/stock-button-selection-subtract.png b/themes/Default/images/stock-button-selection-subtract.png new file mode 100644 index 0000000000000000000000000000000000000000..2a3487b33cb7d6c94a492cd8ba89e874508bd284 GIT binary patch literal 248 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjY)RhkE%y{W;-5;PJdx@v7EBi%mQ3ex!JrmgvK%rJo7srr_Id7-j<~^Xm;kvMp(Y#c| z{4K|q#Rr9iLtbd-+Q=&fzT)@>U(|S;w`rR|F`E*T zi%f6G(;IIZI@*-GPt6JBeWIqFbIoMJ>@{cjb^(#it;S!m*Yz){?7A-799R5m#<71& l%PVH?ukOBaMEd_hHf5*OxIK|et^pmy;OXk;vd$@?2>_23SD63+ literal 0 HcmV?d00001