Commit e8f7363b authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

Show the "Alpha" scale only when needed.

2001-01-09  Michael Natterer  <mitch@gimp.org>

	* app/color_notebook.c: Show the "Alpha" scale only when needed.

	* libgimp/gimpcolorarea.[ch]: fixed typos.
parent e5e8e26f
2001-01-09 Michael Natterer <mitch@gimp.org>
* app/color_notebook.c: Show the "Alpha" scale only when needed.
* libgimp/gimpcolorarea.[ch]: fixed typos.
2001-01-09 Sven Neumann <sven@gimp.org>
* TODO.xml: add more stuff
......
......@@ -80,7 +80,8 @@ struct _ColorNotebook
ColorNotebookCallback callback;
gpointer client_data;
gint wants_updates;
gboolean wants_updates;
gboolean show_alpha;
ColorSelectorInstance *selectors;
ColorSelectorInstance *cur_page;
......@@ -245,6 +246,7 @@ color_notebook_new (gint red,
cnp->callback = callback;
cnp->client_data = client_data;
cnp->wants_updates = wants_updates;
cnp->show_alpha = show_alpha;
cnp->selectors = NULL;
cnp->cur_page = NULL;
......@@ -405,25 +407,39 @@ color_notebook_new (gint red,
cnp);
/* The color space sliders, toggle buttons and entries */
table = gtk_table_new (7, 3, FALSE);
table = gtk_table_new (show_alpha ? 7 : 6, 3, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (right_vbox), table, TRUE, TRUE, 0);
gtk_widget_show (table);
group = NULL;
for (i = 0; i < 7; i++)
for (i = 0; i < (show_alpha ? 7 : 6); i++)
{
cnp->toggles[i] =
gtk_radio_button_new_with_label (group, gettext (toggle_titles[i]));
gimp_help_set_help_data (cnp->toggles[i], gettext (slider_tips[i]), NULL);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (cnp->toggles[i]));
gtk_table_attach (GTK_TABLE (table), cnp->toggles[i],
0, 1, i, i + 1, GTK_FILL, GTK_EXPAND, 0, 0);
gtk_signal_connect (GTK_OBJECT (cnp->toggles[i]), "toggled",
GTK_SIGNAL_FUNC (color_notebook_toggle_update),
cnp);
gtk_widget_show (cnp->toggles[i]);
if (i == 6)
{
cnp->toggles[i] = NULL;
label = gtk_label_new (toggle_titles[i]);
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label,
0, 1, i, i + 1, GTK_FILL, GTK_EXPAND, 0, 0);
}
else
{
cnp->toggles[i] =
gtk_radio_button_new_with_label (group, gettext (toggle_titles[i]));
gimp_help_set_help_data (cnp->toggles[i],
gettext (slider_tips[i]), NULL);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (cnp->toggles[i]));
gtk_table_attach (GTK_TABLE (table), cnp->toggles[i],
0, 1, i, i + 1, GTK_FILL, GTK_EXPAND, 0, 0);
gtk_signal_connect (GTK_OBJECT (cnp->toggles[i]), "toggled",
GTK_SIGNAL_FUNC (color_notebook_toggle_update),
cnp);
gtk_widget_show (cnp->toggles[i]);
}
cnp->slider_data[i] = gimp_scale_entry_new (GTK_TABLE (table), 0, i,
NULL,
......@@ -910,7 +926,7 @@ color_notebook_update_scales (ColorNotebook *cnp,
if (!cnp)
return;
for (i = 0; i < 7; i++)
for (i = 0; i < (cnp->show_alpha ? 7 : 6); i++)
if (i != skip)
{
gtk_signal_handler_block_by_data (GTK_OBJECT (cnp->slider_data[i]), cnp);
......@@ -974,7 +990,7 @@ color_notebook_toggle_update (GtkWidget *widget,
if (!cnp)
return;
for (i = 0; i < 7; i++)
for (i = 0; i < 6; i++)
if (widget == cnp->toggles[i])
cnp->active_channel = (GimpColorSelectorChannelType) i;
......@@ -986,21 +1002,17 @@ color_notebook_scale_update (GtkAdjustment *adjustment,
gpointer data)
{
ColorNotebook *cnp;
gint old_values[7];
gint i, j;
gint i;
cnp = (ColorNotebook *) data;
if (!cnp)
return;
for (i = 0; i < 7; i++)
for (i = 0; i < (cnp->show_alpha ? 7 : 6); i++)
if (cnp->slider_data[i] == GTK_OBJECT (adjustment))
break;
for (j = 0; j < 7; j++)
old_values[j] = cnp->values[j];
cnp->values[i] = (gint) (GTK_ADJUSTMENT (adjustment)->value);
if ((i >= GIMP_COLOR_SELECTOR_HUE) && (i <= GIMP_COLOR_SELECTOR_VALUE))
......
......@@ -80,7 +80,8 @@ struct _ColorNotebook
ColorNotebookCallback callback;
gpointer client_data;
gint wants_updates;
gboolean wants_updates;
gboolean show_alpha;
ColorSelectorInstance *selectors;
ColorSelectorInstance *cur_page;
......@@ -245,6 +246,7 @@ color_notebook_new (gint red,
cnp->callback = callback;
cnp->client_data = client_data;
cnp->wants_updates = wants_updates;
cnp->show_alpha = show_alpha;
cnp->selectors = NULL;
cnp->cur_page = NULL;
......@@ -405,25 +407,39 @@ color_notebook_new (gint red,
cnp);
/* The color space sliders, toggle buttons and entries */
table = gtk_table_new (7, 3, FALSE);
table = gtk_table_new (show_alpha ? 7 : 6, 3, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (right_vbox), table, TRUE, TRUE, 0);
gtk_widget_show (table);
group = NULL;
for (i = 0; i < 7; i++)
for (i = 0; i < (show_alpha ? 7 : 6); i++)
{
cnp->toggles[i] =
gtk_radio_button_new_with_label (group, gettext (toggle_titles[i]));
gimp_help_set_help_data (cnp->toggles[i], gettext (slider_tips[i]), NULL);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (cnp->toggles[i]));
gtk_table_attach (GTK_TABLE (table), cnp->toggles[i],
0, 1, i, i + 1, GTK_FILL, GTK_EXPAND, 0, 0);
gtk_signal_connect (GTK_OBJECT (cnp->toggles[i]), "toggled",
GTK_SIGNAL_FUNC (color_notebook_toggle_update),
cnp);
gtk_widget_show (cnp->toggles[i]);
if (i == 6)
{
cnp->toggles[i] = NULL;
label = gtk_label_new (toggle_titles[i]);
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label,
0, 1, i, i + 1, GTK_FILL, GTK_EXPAND, 0, 0);
}
else
{
cnp->toggles[i] =
gtk_radio_button_new_with_label (group, gettext (toggle_titles[i]));
gimp_help_set_help_data (cnp->toggles[i],
gettext (slider_tips[i]), NULL);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (cnp->toggles[i]));
gtk_table_attach (GTK_TABLE (table), cnp->toggles[i],
0, 1, i, i + 1, GTK_FILL, GTK_EXPAND, 0, 0);
gtk_signal_connect (GTK_OBJECT (cnp->toggles[i]), "toggled",
GTK_SIGNAL_FUNC (color_notebook_toggle_update),
cnp);
gtk_widget_show (cnp->toggles[i]);
}
cnp->slider_data[i] = gimp_scale_entry_new (GTK_TABLE (table), 0, i,
NULL,
......@@ -910,7 +926,7 @@ color_notebook_update_scales (ColorNotebook *cnp,
if (!cnp)
return;
for (i = 0; i < 7; i++)
for (i = 0; i < (cnp->show_alpha ? 7 : 6); i++)
if (i != skip)
{
gtk_signal_handler_block_by_data (GTK_OBJECT (cnp->slider_data[i]), cnp);
......@@ -974,7 +990,7 @@ color_notebook_toggle_update (GtkWidget *widget,
if (!cnp)
return;
for (i = 0; i < 7; i++)
for (i = 0; i < 6; i++)
if (widget == cnp->toggles[i])
cnp->active_channel = (GimpColorSelectorChannelType) i;
......@@ -986,21 +1002,17 @@ color_notebook_scale_update (GtkAdjustment *adjustment,
gpointer data)
{
ColorNotebook *cnp;
gint old_values[7];
gint i, j;
gint i;
cnp = (ColorNotebook *) data;
if (!cnp)
return;
for (i = 0; i < 7; i++)
for (i = 0; i < (cnp->show_alpha ? 7 : 6); i++)
if (cnp->slider_data[i] == GTK_OBJECT (adjustment))
break;
for (j = 0; j < 7; j++)
old_values[j] = cnp->values[j];
cnp->values[i] = (gint) (GTK_ADJUSTMENT (adjustment)->value);
if ((i >= GIMP_COLOR_SELECTOR_HUE) && (i <= GIMP_COLOR_SELECTOR_VALUE))
......
......@@ -80,7 +80,8 @@ struct _ColorNotebook
ColorNotebookCallback callback;
gpointer client_data;
gint wants_updates;
gboolean wants_updates;
gboolean show_alpha;
ColorSelectorInstance *selectors;
ColorSelectorInstance *cur_page;
......@@ -245,6 +246,7 @@ color_notebook_new (gint red,
cnp->callback = callback;
cnp->client_data = client_data;
cnp->wants_updates = wants_updates;
cnp->show_alpha = show_alpha;
cnp->selectors = NULL;
cnp->cur_page = NULL;
......@@ -405,25 +407,39 @@ color_notebook_new (gint red,
cnp);
/* The color space sliders, toggle buttons and entries */
table = gtk_table_new (7, 3, FALSE);
table = gtk_table_new (show_alpha ? 7 : 6, 3, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (right_vbox), table, TRUE, TRUE, 0);
gtk_widget_show (table);
group = NULL;
for (i = 0; i < 7; i++)
for (i = 0; i < (show_alpha ? 7 : 6); i++)
{
cnp->toggles[i] =
gtk_radio_button_new_with_label (group, gettext (toggle_titles[i]));
gimp_help_set_help_data (cnp->toggles[i], gettext (slider_tips[i]), NULL);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (cnp->toggles[i]));
gtk_table_attach (GTK_TABLE (table), cnp->toggles[i],
0, 1, i, i + 1, GTK_FILL, GTK_EXPAND, 0, 0);
gtk_signal_connect (GTK_OBJECT (cnp->toggles[i]), "toggled",
GTK_SIGNAL_FUNC (color_notebook_toggle_update),
cnp);
gtk_widget_show (cnp->toggles[i]);
if (i == 6)
{
cnp->toggles[i] = NULL;
label = gtk_label_new (toggle_titles[i]);
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label,
0, 1, i, i + 1, GTK_FILL, GTK_EXPAND, 0, 0);
}
else
{
cnp->toggles[i] =
gtk_radio_button_new_with_label (group, gettext (toggle_titles[i]));
gimp_help_set_help_data (cnp->toggles[i],
gettext (slider_tips[i]), NULL);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (cnp->toggles[i]));
gtk_table_attach (GTK_TABLE (table), cnp->toggles[i],
0, 1, i, i + 1, GTK_FILL, GTK_EXPAND, 0, 0);
gtk_signal_connect (GTK_OBJECT (cnp->toggles[i]), "toggled",
GTK_SIGNAL_FUNC (color_notebook_toggle_update),
cnp);
gtk_widget_show (cnp->toggles[i]);
}
cnp->slider_data[i] = gimp_scale_entry_new (GTK_TABLE (table), 0, i,
NULL,
......@@ -910,7 +926,7 @@ color_notebook_update_scales (ColorNotebook *cnp,
if (!cnp)
return;
for (i = 0; i < 7; i++)
for (i = 0; i < (cnp->show_alpha ? 7 : 6); i++)
if (i != skip)
{
gtk_signal_handler_block_by_data (GTK_OBJECT (cnp->slider_data[i]), cnp);
......@@ -974,7 +990,7 @@ color_notebook_toggle_update (GtkWidget *widget,
if (!cnp)
return;
for (i = 0; i < 7; i++)
for (i = 0; i < 6; i++)
if (widget == cnp->toggles[i])
cnp->active_channel = (GimpColorSelectorChannelType) i;
......@@ -986,21 +1002,17 @@ color_notebook_scale_update (GtkAdjustment *adjustment,
gpointer data)
{
ColorNotebook *cnp;
gint old_values[7];
gint i, j;
gint i;
cnp = (ColorNotebook *) data;
if (!cnp)
return;
for (i = 0; i < 7; i++)
for (i = 0; i < (cnp->show_alpha ? 7 : 6); i++)
if (cnp->slider_data[i] == GTK_OBJECT (adjustment))
break;
for (j = 0; j < 7; j++)
old_values[j] = cnp->values[j];
cnp->values[i] = (gint) (GTK_ADJUSTMENT (adjustment)->value);
if ((i >= GIMP_COLOR_SELECTOR_HUE) && (i <= GIMP_COLOR_SELECTOR_VALUE))
......
......@@ -80,7 +80,8 @@ struct _ColorNotebook
ColorNotebookCallback callback;
gpointer client_data;
gint wants_updates;
gboolean wants_updates;
gboolean show_alpha;
ColorSelectorInstance *selectors;
ColorSelectorInstance *cur_page;
......@@ -245,6 +246,7 @@ color_notebook_new (gint red,
cnp->callback = callback;
cnp->client_data = client_data;
cnp->wants_updates = wants_updates;
cnp->show_alpha = show_alpha;
cnp->selectors = NULL;
cnp->cur_page = NULL;
......@@ -405,25 +407,39 @@ color_notebook_new (gint red,
cnp);
/* The color space sliders, toggle buttons and entries */
table = gtk_table_new (7, 3, FALSE);
table = gtk_table_new (show_alpha ? 7 : 6, 3, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (right_vbox), table, TRUE, TRUE, 0);
gtk_widget_show (table);
group = NULL;
for (i = 0; i < 7; i++)
for (i = 0; i < (show_alpha ? 7 : 6); i++)
{
cnp->toggles[i] =
gtk_radio_button_new_with_label (group, gettext (toggle_titles[i]));
gimp_help_set_help_data (cnp->toggles[i], gettext (slider_tips[i]), NULL);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (cnp->toggles[i]));
gtk_table_attach (GTK_TABLE (table), cnp->toggles[i],
0, 1, i, i + 1, GTK_FILL, GTK_EXPAND, 0, 0);
gtk_signal_connect (GTK_OBJECT (cnp->toggles[i]), "toggled",
GTK_SIGNAL_FUNC (color_notebook_toggle_update),
cnp);
gtk_widget_show (cnp->toggles[i]);
if (i == 6)
{
cnp->toggles[i] = NULL;
label = gtk_label_new (toggle_titles[i]);
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label,
0, 1, i, i + 1, GTK_FILL, GTK_EXPAND, 0, 0);
}
else
{
cnp->toggles[i] =
gtk_radio_button_new_with_label (group, gettext (toggle_titles[i]));
gimp_help_set_help_data (cnp->toggles[i],
gettext (slider_tips[i]), NULL);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (cnp->toggles[i]));
gtk_table_attach (GTK_TABLE (table), cnp->toggles[i],
0, 1, i, i + 1, GTK_FILL, GTK_EXPAND, 0, 0);
gtk_signal_connect (GTK_OBJECT (cnp->toggles[i]), "toggled",
GTK_SIGNAL_FUNC (color_notebook_toggle_update),
cnp);
gtk_widget_show (cnp->toggles[i]);
}
cnp->slider_data[i] = gimp_scale_entry_new (GTK_TABLE (table), 0, i,
NULL,
......@@ -910,7 +926,7 @@ color_notebook_update_scales (ColorNotebook *cnp,
if (!cnp)
return;
for (i = 0; i < 7; i++)
for (i = 0; i < (cnp->show_alpha ? 7 : 6); i++)
if (i != skip)
{
gtk_signal_handler_block_by_data (GTK_OBJECT (cnp->slider_data[i]), cnp);
......@@ -974,7 +990,7 @@ color_notebook_toggle_update (GtkWidget *widget,
if (!cnp)
return;
for (i = 0; i < 7; i++)
for (i = 0; i < 6; i++)
if (widget == cnp->toggles[i])
cnp->active_channel = (GimpColorSelectorChannelType) i;
......@@ -986,21 +1002,17 @@ color_notebook_scale_update (GtkAdjustment *adjustment,
gpointer data)
{
ColorNotebook *cnp;
gint old_values[7];
gint i, j;
gint i;
cnp = (ColorNotebook *) data;
if (!cnp)
return;
for (i = 0; i < 7; i++)
for (i = 0; i < (cnp->show_alpha ? 7 : 6); i++)
if (cnp->slider_data[i] == GTK_OBJECT (adjustment))
break;
for (j = 0; j < 7; j++)
old_values[j] = cnp->values[j];
cnp->values[i] = (gint) (GTK_ADJUSTMENT (adjustment)->value);
if ((i >= GIMP_COLOR_SELECTOR_HUE) && (i <= GIMP_COLOR_SELECTOR_VALUE))
......
......@@ -69,7 +69,7 @@ static void gimp_color_area_drag_end (GtkWidget *widget,
static void gimp_color_area_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time);
......@@ -121,8 +121,8 @@ gimp_color_area_class_init (GimpColorAreaClass *class)
object_class->type,
GTK_SIGNAL_OFFSET (GimpColorAreaClass,
color_changed),
gtk_marshal_NONE__POINTER ,
GTK_TYPE_NONE,
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE,
1, GTK_TYPE_POINTER);
gtk_object_class_add_signals (object_class, gimp_color_area_signals,
......@@ -219,20 +219,20 @@ gimp_color_area_set_color (GimpColorArea *gca,
g_return_if_fail (GIMP_IS_COLOR_AREA (gca));
g_return_if_fail (color != NULL);
if (gimp_rgba_distance (&gca->color, color) > 0.000001)
{
gca->color = *color;
gimp_color_area_paint (gca);
gtk_signal_emit (GTK_OBJECT (gca),
gimp_color_area_signals[COLOR_CHANGED],
&gca->color);
}
}
static void
static void
gimp_color_area_paint (GimpColorArea *gca)
{
gint x, y;
......@@ -246,7 +246,7 @@ gimp_color_area_paint (GimpColorArea *gca)
if (! GTK_WIDGET_DRAWABLE (GTK_WIDGET (gca)))
return;
gdk_window_get_size (GTK_WIDGET (gca)->window, &width, &height);
if (!width || !height)
......@@ -320,7 +320,7 @@ gimp_color_area_drag_begin (GtkWidget *widget,
gtk_widget_set_usize (window, DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
gtk_widget_realize (window);
gtk_object_set_data_full (GTK_OBJECT (widget),
"gimp-color-button-drag-window",
"gimp-color-area-drag-window",
window,
(GtkDestroyNotify) gtk_widget_destroy);
......@@ -363,7 +363,7 @@ gimp_color_area_drag_data_received (GtkWidget *widget,
if ((selection_data->format != 16) ||
(selection_data->length != 8))
{
g_warning ("Received invalid color data\n");
g_warning ("Received invalid color data");
return;
}
......@@ -374,7 +374,7 @@ gimp_color_area_drag_data_received (GtkWidget *widget,
(gdouble) vals[1] / 0xffff,
(gdouble) vals[2] / 0xffff,
(gdouble) vals[3] / 0xffff);
gimp_color_area_set_color (gca, &color);
}
......@@ -399,5 +399,3 @@ gimp_color_area_drag_data_get (GtkWidget *widget,
gdk_atom_intern ("application/x-color", FALSE),
16, (guchar *)vals, 8);
}
......@@ -28,6 +28,10 @@
#ifndef __GIMP_COLOR_AREA_H__
#define __GIMP_COLOR_AREA_H__
#include <gtk/gtkpreview.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
......@@ -39,6 +43,7 @@ extern "C" {
#define GIMP_IS_COLOR_AREA(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_COLOR_AREA))
#define GIMP_IS_COLOR_AREA_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_AREA))
typedef struct _GimpColorAreaClass GimpColorAreaClass;
struct _GimpColorAreaClass
......@@ -53,7 +58,8 @@ struct _GimpColorAreaClass
GtkType gimp_color_area_get_type (void);
GtkWidget * gimp_color_area_new (GimpRGB *color,
gboolean alpha);
void gimp_color_area_update (GimpColorArea *gca);
void gimp_color_area_set_color (GimpColorArea *gca,
GimpRGB *color);
#ifdef __cplusplus
......
......@@ -69,7 +69,7 @@ static void gimp_color_area_drag_end (GtkWidget *widget,
static void gimp_color_area_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time);
......@@ -121,8 +121,8 @@ gimp_color_area_class_init (GimpColorAreaClass *class)
object_class->type,
GTK_SIGNAL_OFFSET (GimpColorAreaClass,
color_changed),
gtk_marshal_NONE__POINTER ,
GTK_TYPE_NONE,
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE,
1, GTK_TYPE_POINTER);
gtk_object_class_add_signals (object_class, gimp_color_area_signals,
......@@ -219,20 +219,20 @@ gimp_color_area_set_color (GimpColorArea *gca,
g_return_if_fail (GIMP_IS_COLOR_AREA (gca));
g_return_if_fail (color != NULL);
if (gimp_rgba_distance (&gca->color, color) > 0.000001)
{
gca->color = *color;
gimp_color_area_paint (gca);
gtk_signal_emit (GTK_OBJECT (gca),
gimp_color_area_signals[COLOR_CHANGED],
&gca->color);
}
}
static void
static void
gimp_color_area_paint (GimpColorArea *gca)
{
gint x, y;
......@@ -246,7 +246,7 @@ gimp_color_area_paint (GimpColorArea *gca)
if (! GTK_WIDGET_DRAWABLE (GTK_WIDGET (gca)))
return;