Commit b6c21c4f authored by Sven Neumann's avatar Sven Neumann
Browse files

Channels can now be intersected with the selection.


--Sven
parent 462055c4
Thu Jun 3 16:51:18 MEST 1999 Sven Neumann <sven@gimp.org>
* app/channels_dialog.c
* app/layers_dialog.c
* app/ops_buttons.[ch]: Channels can now be intersected with the
active selection. Bound this to <Shift><Ctrl> and <Alt> when pressing
the 'Channel to Selection'-button in the Channels dialog. Added
tooltips for all modifier functions.
Thur Jun 3 9:06:00 CST 1999 Seth Burgess <sjburges@gimp.org>
* plug-ins/script-fu/scripts/drop-shadow.scm: you can't
......
......@@ -126,6 +126,7 @@ static void channels_dialog_delete_channel_callback (GtkWidget *, gpointer);
static void channels_dialog_channel_to_sel_callback (GtkWidget *, gpointer);
static void channels_dialog_add_channel_to_sel_callback (GtkWidget *, gpointer);
static void channels_dialog_sub_channel_from_sel_callback (GtkWidget *, gpointer);
static void channels_dialog_intersect_channel_with_sel_callback (GtkWidget *, gpointer);
/* channel widget function prototypes */
static ChannelWidget *channel_widget_get_ID (Channel *);
......@@ -167,9 +168,11 @@ static MenuItem channels_ops[] =
channels_dialog_delete_channel_callback, NULL, NULL, NULL },
{ N_("Channel To Selection"), 'S', GDK_CONTROL_MASK,
channels_dialog_channel_to_sel_callback, NULL, NULL, NULL },
{ N_("Add Channel To Selection"), 0, 0,
{ N_("Add To Selection"), 0, 0,
channels_dialog_add_channel_to_sel_callback, NULL, NULL, NULL },
{ N_("Sub Channel From Selection"), 0, 0,
{ N_("Subtract From Selection"), 0, 0,
channels_dialog_sub_channel_from_sel_callback, NULL, NULL, NULL },
{ N_("Intersect With Selection"), 0, 0,
channels_dialog_sub_channel_from_sel_callback, NULL, NULL, NULL },
{ NULL, 0, 0, NULL, NULL, NULL, NULL },
};
......@@ -178,8 +181,12 @@ static MenuItem channels_ops[] =
/* the ops buttons */
static OpsButtonCallback to_selection_ext_callbacks[] =
{ channels_dialog_add_channel_to_sel_callback,
channels_dialog_sub_channel_from_sel_callback, NULL };
{
channels_dialog_add_channel_to_sel_callback, /* SHIFT */
channels_dialog_sub_channel_from_sel_callback, /* CTRL */
channels_dialog_intersect_channel_with_sel_callback, /* MOD1 */
channels_dialog_intersect_channel_with_sel_callback, /* SHIFT + CTRL */
};
static OpsButton channels_ops_buttons[] =
{
......@@ -188,7 +195,7 @@ static OpsButton channels_ops_buttons[] =
{ lower_xpm, channels_dialog_lower_channel_callback, NULL, N_("Lower Channel"), NULL, 0 },
{ duplicate_xpm, channels_dialog_duplicate_channel_callback, NULL, N_("Duplicate Channel"), NULL, 0 },
{ delete_xpm, channels_dialog_delete_channel_callback, NULL, N_("Delete Channel"), NULL, 0 },
{ toselection_xpm, channels_dialog_channel_to_sel_callback, to_selection_ext_callbacks, N_("Channel To Selection"), NULL, 0 },
{ toselection_xpm, channels_dialog_channel_to_sel_callback, to_selection_ext_callbacks, N_("Channel To Selection \n<Shift> Add <Ctrl> Subtract <Shift><Ctrl> Intersect"), NULL, 0 },
{ NULL, NULL, NULL, NULL, NULL, 0 }
};
......@@ -575,6 +582,8 @@ channels_dialog_set_menu_sensitivity ()
gtk_widget_set_sensitive (channels_ops[6].widget, aux_sensitive);
/* sub channel from selection */
gtk_widget_set_sensitive (channels_ops[7].widget, aux_sensitive);
/* intersect channel with selection */
gtk_widget_set_sensitive (channels_ops[8].widget, aux_sensitive);
}
......@@ -966,7 +975,7 @@ channels_dialog_channel_to_sel_callback (GtkWidget *w,
static void
channels_dialog_add_channel_to_sel_callback (GtkWidget *w,
gpointer client_data)
gpointer client_data)
{
GImage *gimage;
Channel *active_channel;
......@@ -992,7 +1001,6 @@ channels_dialog_add_channel_to_sel_callback (GtkWidget *w,
}
}
static void
channels_dialog_sub_channel_from_sel_callback (GtkWidget *w,
gpointer client_data)
......@@ -1021,6 +1029,34 @@ channels_dialog_sub_channel_from_sel_callback (GtkWidget *w,
}
}
static void
channels_dialog_intersect_channel_with_sel_callback (GtkWidget *w,
gpointer client_data)
{
GImage *gimage;
Channel *active_channel;
Channel *new_channel;
/* if there is a currently selected gimage
*/
if (!channelsD)
return;
if (! (gimage = channelsD->gimage))
return;
if ((active_channel = gimage_get_active_channel (gimage)))
{
new_channel = channel_copy (gimage_get_mask (gimage));
channel_combine_mask (new_channel,
active_channel,
INTERSECT,
0, 0); /* off x/y */
gimage_mask_load (gimage, new_channel);
channel_delete (new_channel);
gdisplays_flush ();
}
}
/****************************/
/* channel widget functions */
......
......@@ -126,6 +126,7 @@ static void channels_dialog_delete_channel_callback (GtkWidget *, gpointer);
static void channels_dialog_channel_to_sel_callback (GtkWidget *, gpointer);
static void channels_dialog_add_channel_to_sel_callback (GtkWidget *, gpointer);
static void channels_dialog_sub_channel_from_sel_callback (GtkWidget *, gpointer);
static void channels_dialog_intersect_channel_with_sel_callback (GtkWidget *, gpointer);
/* channel widget function prototypes */
static ChannelWidget *channel_widget_get_ID (Channel *);
......@@ -167,9 +168,11 @@ static MenuItem channels_ops[] =
channels_dialog_delete_channel_callback, NULL, NULL, NULL },
{ N_("Channel To Selection"), 'S', GDK_CONTROL_MASK,
channels_dialog_channel_to_sel_callback, NULL, NULL, NULL },
{ N_("Add Channel To Selection"), 0, 0,
{ N_("Add To Selection"), 0, 0,
channels_dialog_add_channel_to_sel_callback, NULL, NULL, NULL },
{ N_("Sub Channel From Selection"), 0, 0,
{ N_("Subtract From Selection"), 0, 0,
channels_dialog_sub_channel_from_sel_callback, NULL, NULL, NULL },
{ N_("Intersect With Selection"), 0, 0,
channels_dialog_sub_channel_from_sel_callback, NULL, NULL, NULL },
{ NULL, 0, 0, NULL, NULL, NULL, NULL },
};
......@@ -178,8 +181,12 @@ static MenuItem channels_ops[] =
/* the ops buttons */
static OpsButtonCallback to_selection_ext_callbacks[] =
{ channels_dialog_add_channel_to_sel_callback,
channels_dialog_sub_channel_from_sel_callback, NULL };
{
channels_dialog_add_channel_to_sel_callback, /* SHIFT */
channels_dialog_sub_channel_from_sel_callback, /* CTRL */
channels_dialog_intersect_channel_with_sel_callback, /* MOD1 */
channels_dialog_intersect_channel_with_sel_callback, /* SHIFT + CTRL */
};
static OpsButton channels_ops_buttons[] =
{
......@@ -188,7 +195,7 @@ static OpsButton channels_ops_buttons[] =
{ lower_xpm, channels_dialog_lower_channel_callback, NULL, N_("Lower Channel"), NULL, 0 },
{ duplicate_xpm, channels_dialog_duplicate_channel_callback, NULL, N_("Duplicate Channel"), NULL, 0 },
{ delete_xpm, channels_dialog_delete_channel_callback, NULL, N_("Delete Channel"), NULL, 0 },
{ toselection_xpm, channels_dialog_channel_to_sel_callback, to_selection_ext_callbacks, N_("Channel To Selection"), NULL, 0 },
{ toselection_xpm, channels_dialog_channel_to_sel_callback, to_selection_ext_callbacks, N_("Channel To Selection \n<Shift> Add <Ctrl> Subtract <Shift><Ctrl> Intersect"), NULL, 0 },
{ NULL, NULL, NULL, NULL, NULL, 0 }
};
......@@ -575,6 +582,8 @@ channels_dialog_set_menu_sensitivity ()
gtk_widget_set_sensitive (channels_ops[6].widget, aux_sensitive);
/* sub channel from selection */
gtk_widget_set_sensitive (channels_ops[7].widget, aux_sensitive);
/* intersect channel with selection */
gtk_widget_set_sensitive (channels_ops[8].widget, aux_sensitive);
}
......@@ -966,7 +975,7 @@ channels_dialog_channel_to_sel_callback (GtkWidget *w,
static void
channels_dialog_add_channel_to_sel_callback (GtkWidget *w,
gpointer client_data)
gpointer client_data)
{
GImage *gimage;
Channel *active_channel;
......@@ -992,7 +1001,6 @@ channels_dialog_add_channel_to_sel_callback (GtkWidget *w,
}
}
static void
channels_dialog_sub_channel_from_sel_callback (GtkWidget *w,
gpointer client_data)
......@@ -1021,6 +1029,34 @@ channels_dialog_sub_channel_from_sel_callback (GtkWidget *w,
}
}
static void
channels_dialog_intersect_channel_with_sel_callback (GtkWidget *w,
gpointer client_data)
{
GImage *gimage;
Channel *active_channel;
Channel *new_channel;
/* if there is a currently selected gimage
*/
if (!channelsD)
return;
if (! (gimage = channelsD->gimage))
return;
if ((active_channel = gimage_get_active_channel (gimage)))
{
new_channel = channel_copy (gimage_get_mask (gimage));
channel_combine_mask (new_channel,
active_channel,
INTERSECT,
0, 0); /* off x/y */
gimage_mask_load (gimage, new_channel);
channel_delete (new_channel);
gdisplays_flush ();
}
}
/****************************/
/* channel widget functions */
......
......@@ -292,16 +292,16 @@ static MenuItem option_items[] =
/* the ops buttons */
static OpsButtonCallback raise_layers_ext_callbacks[] =
{ layers_dialog_raise_layer_to_top_callback, NULL, NULL };
{ layers_dialog_raise_layer_to_top_callback, NULL, NULL, NULL };
static OpsButtonCallback lower_layers_ext_callbacks[] =
{ layers_dialog_lower_layer_to_bottom_callback, NULL, NULL };
{ layers_dialog_lower_layer_to_bottom_callback, NULL, NULL, NULL };
static OpsButton layers_ops_buttons[] =
{
{ new_xpm, layers_dialog_new_layer_callback, NULL, N_("New Layer"), NULL, 0 },
{ raise_xpm, layers_dialog_raise_layer_callback, raise_layers_ext_callbacks, N_("Raise Layer"), NULL, 0 },
{ lower_xpm, layers_dialog_lower_layer_callback, lower_layers_ext_callbacks, N_("Lower Layer"), NULL, 0 },
{ raise_xpm, layers_dialog_raise_layer_callback, raise_layers_ext_callbacks, N_("Raise Layer \n<Shift> To Top"), NULL, 0 },
{ lower_xpm, layers_dialog_lower_layer_callback, lower_layers_ext_callbacks, N_("Lower Layer \n<Shift> To Bottom"), NULL, 0 },
{ duplicate_xpm, layers_dialog_duplicate_layer_callback, NULL, N_("Duplicate Layer"), NULL, 0 },
{ delete_xpm, layers_dialog_delete_layer_callback, NULL, N_("Delete Layer"), NULL, 0 },
{ anchor_xpm, layers_dialog_anchor_layer_callback, NULL, N_("Anchor Layer"), NULL, 0 },
......
......@@ -292,16 +292,16 @@ static MenuItem option_items[] =
/* the ops buttons */
static OpsButtonCallback raise_layers_ext_callbacks[] =
{ layers_dialog_raise_layer_to_top_callback, NULL, NULL };
{ layers_dialog_raise_layer_to_top_callback, NULL, NULL, NULL };
static OpsButtonCallback lower_layers_ext_callbacks[] =
{ layers_dialog_lower_layer_to_bottom_callback, NULL, NULL };
{ layers_dialog_lower_layer_to_bottom_callback, NULL, NULL, NULL };
static OpsButton layers_ops_buttons[] =
{
{ new_xpm, layers_dialog_new_layer_callback, NULL, N_("New Layer"), NULL, 0 },
{ raise_xpm, layers_dialog_raise_layer_callback, raise_layers_ext_callbacks, N_("Raise Layer"), NULL, 0 },
{ lower_xpm, layers_dialog_lower_layer_callback, lower_layers_ext_callbacks, N_("Lower Layer"), NULL, 0 },
{ raise_xpm, layers_dialog_raise_layer_callback, raise_layers_ext_callbacks, N_("Raise Layer \n<Shift> To Top"), NULL, 0 },
{ lower_xpm, layers_dialog_lower_layer_callback, lower_layers_ext_callbacks, N_("Lower Layer \n<Shift> To Bottom"), NULL, 0 },
{ duplicate_xpm, layers_dialog_duplicate_layer_callback, NULL, N_("Duplicate Layer"), NULL, 0 },
{ delete_xpm, layers_dialog_delete_layer_callback, NULL, N_("Delete Layer"), NULL, 0 },
{ anchor_xpm, layers_dialog_anchor_layer_callback, NULL, N_("Anchor Layer"), NULL, 0 },
......
......@@ -134,8 +134,13 @@ ops_button_pressed_callback (GtkWidget *widget,
g_return_if_fail (client_data != NULL);
ops_button = (OpsButton*)client_data;
if (bevent->state & GDK_SHIFT_MASK)
ops_button->modifier = OPS_BUTTON_MODIFIER_SHIFT;
if (bevent->state & GDK_SHIFT_MASK)
{
if (bevent->state & GDK_CONTROL_MASK)
ops_button->modifier = OPS_BUTTON_MODIFIER_SHIFT_CTRL;
else
ops_button->modifier = OPS_BUTTON_MODIFIER_SHIFT;
}
else if (bevent->state & GDK_CONTROL_MASK)
ops_button->modifier = OPS_BUTTON_MODIFIER_CTRL;
else if (bevent->state & GDK_MOD1_MASK)
......@@ -153,14 +158,16 @@ ops_button_extended_callback (GtkWidget *widget,
g_return_if_fail (client_data != NULL);
ops_button = (OpsButton*)client_data;
if (ops_button->modifier < 1 || ops_button->modifier > 3)
if (ops_button->modifier > OPS_BUTTON_MODIFIER_NONE &&
ops_button->modifier < OPS_BUTTON_MODIFIER_LAST)
{
if (ops_button->ext_callbacks[ops_button->modifier - 1] != NULL)
(ops_button->ext_callbacks[ops_button->modifier - 1]) (widget, NULL);
else
(ops_button->callback) (widget, NULL);
}
else
(ops_button->callback) (widget, NULL);
else {
if (ops_button->ext_callbacks[ops_button->modifier - 1] != NULL)
(ops_button->ext_callbacks[ops_button->modifier - 1]) (widget, NULL);
else
(ops_button->callback) (widget, NULL);
}
ops_button->modifier = OPS_BUTTON_MODIFIER_NONE;
}
......
......@@ -24,13 +24,13 @@ typedef struct _OpsButton OpsButton;
typedef void (*OpsButtonCallback) (GtkWidget *widget,
gpointer user_data);
/* typedef OpsButtonCallback OpsButtonExtCallbacks; */
typedef enum {
OPS_BUTTON_MODIFIER_NONE,
OPS_BUTTON_MODIFIER_SHIFT,
OPS_BUTTON_MODIFIER_CTRL,
OPS_BUTTON_MODIFIER_ALT,
OPS_BUTTON_MODIFIER_SHIFT_CTRL,
OPS_BUTTON_MODIFIER_LAST
} OpsButtonModifier;
typedef enum {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment