Commit 89452261 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

the color scales from the main color selection as GimpColorSelector

2002-10-28  Michael Natterer  <mitch@gimp.org>

	* libgimpwidgets/gimpcolorscales.[ch]: the color scales from
	the main color selection as GimpColorSelector subclass.

	* libgimpwidgets/Makefile.am
	* libgimpwidgets/gimpwidgets.h
	* libgimpwidgets/gimpwidgetsmarshal.list
	* libgimpwidgets/gimpwidgetstypes.h: changed accordingly.

	* libgimpwidgets/gimpcolornotebook.c: skip it when iterating the
	GimpColorSelector subclasses.

	* libgimpwidgets/gimpcolorselector.[ch]: added virtual function
	set_has_alpha() amd signal "channel_changed". Put RGB, HSV and
	channel values into to the GimpColorSelector struct where they are
	available for subclasses.

	* libgimpwidgets/gimpcolorselect.[ch]
	* modules/colorsel_triangle.c
	* modules/colorsel_water.c: changed accordingly, cleanup.

	* app/gui/color-notebook.[ch]: use the new GimpColorScales widget,
	lots of cleanup.

2002-10-28  Michael Natterer  <mitch@gimp.org>

	* libgimpwidgets/tmpl/gimpcolorscales.sgml: added GimpColorScales.

	* libgimpwidgets/libgimpwidgets-docs.sgml
	* libgimpwidgets/libgimpwidgets-sections.txt
	* libgimpwidgets/libgimpwidgets.types
	* libgimpwidgets/tmpl/gimpcolorselect.sgml
	* libgimpwidgets/tmpl/gimpcolorselector.sgml; updated.
parent dcb5f7b2
2002-10-28 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/gimpcolorscales.[ch]: the color scales from
the main color selection as GimpColorSelector subclass.
* libgimpwidgets/Makefile.am
* libgimpwidgets/gimpwidgets.h
* libgimpwidgets/gimpwidgetsmarshal.list
* libgimpwidgets/gimpwidgetstypes.h: changed accordingly.
* libgimpwidgets/gimpcolornotebook.c: skip it when iterating the
GimpColorSelector subclasses.
* libgimpwidgets/gimpcolorselector.[ch]: added virtual function
set_has_alpha() amd signal "channel_changed". Put RGB, HSV and
channel values into to the GimpColorSelector struct where they are
available for subclasses.
* libgimpwidgets/gimpcolorselect.[ch]
* modules/colorsel_triangle.c
* modules/colorsel_water.c: changed accordingly, cleanup.
* app/gui/color-notebook.[ch]: use the new GimpColorScales widget,
lots of cleanup.
2002-10-28 Michael Natterer <mitch@gimp.org>
 
* plug-ins/common/unsharp.c: reordered action buttons.
......
This diff is collapsed.
......@@ -51,6 +51,8 @@ ColorNotebook * color_notebook_viewable_new (GimpViewable *viewable,
gboolean wants_update,
gboolean show_alpha);
void color_notebook_free (ColorNotebook *cnb);
void color_notebook_set_viewable (ColorNotebook *cnb,
GimpViewable *viewable);
void color_notebook_set_title (ColorNotebook *cnb,
......@@ -58,7 +60,6 @@ void color_notebook_set_title (ColorNotebook *cnb,
void color_notebook_show (ColorNotebook *cnb);
void color_notebook_hide (ColorNotebook *cnb);
void color_notebook_free (ColorNotebook *cnb);
void color_notebook_set_color (ColorNotebook *cnb,
const GimpRGB *color);
......
This diff is collapsed.
......@@ -51,6 +51,8 @@ ColorNotebook * color_notebook_viewable_new (GimpViewable *viewable,
gboolean wants_update,
gboolean show_alpha);
void color_notebook_free (ColorNotebook *cnb);
void color_notebook_set_viewable (ColorNotebook *cnb,
GimpViewable *viewable);
void color_notebook_set_title (ColorNotebook *cnb,
......@@ -58,7 +60,6 @@ void color_notebook_set_title (ColorNotebook *cnb,
void color_notebook_show (ColorNotebook *cnb);
void color_notebook_hide (ColorNotebook *cnb);
void color_notebook_free (ColorNotebook *cnb);
void color_notebook_set_color (ColorNotebook *cnb,
const GimpRGB *color);
......
This diff is collapsed.
......@@ -51,6 +51,8 @@ ColorNotebook * color_notebook_viewable_new (GimpViewable *viewable,
gboolean wants_update,
gboolean show_alpha);
void color_notebook_free (ColorNotebook *cnb);
void color_notebook_set_viewable (ColorNotebook *cnb,
GimpViewable *viewable);
void color_notebook_set_title (ColorNotebook *cnb,
......@@ -58,7 +60,6 @@ void color_notebook_set_title (ColorNotebook *cnb,
void color_notebook_show (ColorNotebook *cnb);
void color_notebook_hide (ColorNotebook *cnb);
void color_notebook_free (ColorNotebook *cnb);
void color_notebook_set_color (ColorNotebook *cnb,
const GimpRGB *color);
......
2002-10-28 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/tmpl/gimpcolorscales.sgml: added GimpColorScales.
* libgimpwidgets/libgimpwidgets-docs.sgml
* libgimpwidgets/libgimpwidgets-sections.txt
* libgimpwidgets/libgimpwidgets.types
* libgimpwidgets/tmpl/gimpcolorselect.sgml
* libgimpwidgets/tmpl/gimpcolorselector.sgml; updated.
2002-10-28 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/tmpl/gimpcolornotebook.sgml: added GimpColorNotebook.
......
......@@ -5,6 +5,7 @@
<!entity GimpColorButton SYSTEM "sgml/gimpcolorbutton.sgml">
<!entity GimpColorDisplay SYSTEM "sgml/gimpcolordisplay.sgml">
<!entity GimpColorNotebook SYSTEM "sgml/gimpcolornotebook.sgml">
<!entity GimpColorScales SYSTEM "sgml/gimpcolorscales.sgml">
<!entity GimpColorSelect SYSTEM "sgml/gimpcolorselect.sgml">
<!entity GimpColorSelector SYSTEM "sgml/gimpcolorselector.sgml">
<!entity GimpDialog SYSTEM "sgml/gimpdialog.sgml">
......@@ -44,5 +45,6 @@
&GimpColorDisplay;
&GimpColorSelector;
&GimpColorSelect;
&GimpColorScales;
</chapter>
</book>
......@@ -392,9 +392,11 @@ GIMP_COLOR_SELECTOR_SIZE
GIMP_COLOR_SELECTOR_BAR_SIZE
GimpColorSelectorChannel
gimp_color_selector_new
gimp_color_selector_set_show_alpha
gimp_color_selector_set_color
gimp_color_selector_set_channel
gimp_color_selector_color_changed
gimp_color_selector_channel_changed
<SUBSECTION Standard>
GIMP_COLOR_SELECTOR
GIMP_IS_COLOR_SELECTOR
......@@ -409,15 +411,11 @@ GIMP_COLOR_SELECTOR_GET_CLASS
<FILE>gimpcolorselect</FILE>
<TITLE>GimpColorSelect</TITLE>
GimpColorSelect
GimpColorSelectClass
<SUBSECTION Standard>
GIMP_COLOR_SELECT
GIMP_IS_COLOR_SELECT
GIMP_TYPE_COLOR_SELECT
gimp_color_select_get_type
GIMP_COLOR_SELECT_CLASS
GIMP_IS_COLOR_SELECT_CLASS
GIMP_COLOR_SELECT_GET_CLASS
</SECTION>
<SECTION>
......@@ -460,3 +458,14 @@ GIMP_COLOR_NOTEBOOK_CLASS
GIMP_IS_COLOR_NOTEBOOK_CLASS
GIMP_COLOR_NOTEBOOK_GET_CLASS
</SECTION>
<SECTION>
<FILE>gimpcolorscales</FILE>
GimpColorScales
gimp_color_scales_set_toggles_sensitive
<SUBSECTION Standard>
GIMP_COLOR_SCALES
GIMP_IS_COLOR_SCALES
GIMP_TYPE_COLOR_SCALES
gimp_color_scales_get_type
</SECTION>
......@@ -8,6 +8,7 @@ gimp_chain_button_get_type
gimp_color_button_get_type
gimp_color_display_get_type
gimp_color_notebook_get_type
gimp_color_scales_get_type
gimp_color_selector_get_type
gimp_color_select_get_type
gimp_dialog_get_type
......
<!-- ##### SECTION Title ##### -->
gimpcolorscales
<!-- ##### SECTION Short_Description ##### -->
<!-- ##### SECTION Long_Description ##### -->
<para>
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### STRUCT GimpColorScales ##### -->
<para>
</para>
<!-- ##### FUNCTION gimp_color_scales_set_toggles_sensitive ##### -->
<para>
</para>
@scales:
@sensitive:
......@@ -20,9 +20,3 @@ gimpcolorselect
</para>
<!-- ##### STRUCT GimpColorSelectClass ##### -->
<para>
</para>
......@@ -63,7 +63,19 @@ color selector module.
@selector_type:
@rgb:
@hsv:
@channel:
@Returns:
<!-- # Unused Parameters # -->
@show_alpha:
<!-- ##### FUNCTION gimp_color_selector_set_show_alpha ##### -->
<para>
</para>
@selector:
@show_alpha:
<!-- ##### FUNCTION gimp_color_selector_set_color ##### -->
......@@ -91,10 +103,27 @@ color selector module.
</para>
@selector:
<!-- # Unused Parameters # -->
@rgb:
@hsv:
<!-- ##### FUNCTION gimp_color_selector_channel_changed ##### -->
<para>
</para>
@selector:
<!-- ##### SIGNAL GimpColorSelector::channel-changed ##### -->
<para>
</para>
@gimpcolorselector: the object which received the signal.
@arg1:
<!-- ##### SIGNAL GimpColorSelector::color-changed ##### -->
<para>
......
......@@ -29,6 +29,8 @@ libgimpwidgets_1_3_la_sources = \
gimpcolordisplay.h \
gimpcolornotebook.c \
gimpcolornotebook.h \
gimpcolorscales.c \
gimpcolorscales.h \
gimpcolorselector.c \
gimpcolorselector.h \
gimpcolorselect.c \
......@@ -80,6 +82,7 @@ libgimpwidgetsinclude_HEADERS = \
gimpcolorbutton.h \
gimpcolordisplay.h \
gimpcolornotebook.h \
gimpcolorscales.h \
gimpcolorselector.h \
gimpcolorselect.h \
gimpdialog.h \
......
......@@ -32,6 +32,7 @@
#include "gimpwidgetstypes.h"
#include "gimpcolornotebook.h"
#include "gimpcolorscales.h"
#include "gimpcolorselector.h"
#include "gimpwidgetsmarshal.h"
......@@ -131,6 +132,8 @@ gimp_color_notebook_init (GimpColorNotebook *notebook)
gimp_rgba_set (&notebook->rgb, 0.0, 0.0, 0.0, 1.0);
gimp_rgb_to_hsv (&notebook->rgb, &notebook->hsv);
notebook->channel = GIMP_COLOR_SELECTOR_HUE;
selector_types = g_type_children (GIMP_TYPE_COLOR_SELECTOR, &n_selector_types);
if (n_selector_types == 1)
......@@ -141,13 +144,20 @@ gimp_color_notebook_init (GimpColorNotebook *notebook)
for (i = 0; i < n_selector_types; i++)
{
/* skip the "Scales" color selector */
if (g_type_is_a (selector_types[i], GIMP_TYPE_COLOR_SCALES))
continue;
selector = gimp_color_selector_new (selector_types[i],
&notebook->rgb,
&notebook->hsv);
&notebook->hsv,
notebook->channel);
if (! selector)
continue;
gimp_color_selector_set_show_alpha (GIMP_COLOR_SELECTOR (selector), FALSE);
label = gtk_label_new (GIMP_COLOR_SELECTOR_GET_CLASS (selector)->name);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), selector, label);
......
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpcolorscales.c
* Copyright (C) 2002 Michael Natterer <mitch@gimp.org>
*
* based on color_notebook module
* Copyright (C) 1998 Austin Donnelly <austin@greenend.org.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdio.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "libgimpcolor/gimpcolor.h"
#include "gimpwidgetstypes.h"
#include "gimpcolorscales.h"
#include "gimpwidgets.h"
#include "libgimp/gimpintl.h"
#define GIMP_COLOR_SCALES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_SCALES, GimpColorScalesClass))
#define GIMP_IS_COLOR_SCALES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_SCALES))
#define GIMP_COLOR_SCALES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_SCALES, GimpColorScalesClass))
typedef struct _GimpColorScalesClass GimpColorScalesClass;
struct _GimpColorScales
{
GimpColorSelector parent_instance;
GtkWidget *toggles[7];
GtkObject *slider_data[7];
GtkWidget *hex_entry;
};
struct _GimpColorScalesClass
{
GimpColorSelectorClass parent_class;
};
static void gimp_color_scales_class_init (GimpColorScalesClass *klass);
static void gimp_color_scales_init (GimpColorScales *scales);
static void gimp_color_scales_finalize (GObject *object);
static void gimp_color_scales_set_show_alpha (GimpColorSelector *selector,
gboolean show_alpha);
static void gimp_color_scales_set_color (GimpColorSelector *selector,
const GimpRGB *rgb,
const GimpHSV *hsv);
static void gimp_color_scales_set_channel (GimpColorSelector *selector,
GimpColorSelectorChannel channel);
static void gimp_color_scales_update_scales (GimpColorScales *scales,
gint skip);
static void gimp_color_scales_toggle_update (GtkWidget *widget,
GimpColorScales *scales);
static void gimp_color_scales_scale_update (GtkAdjustment *adjustment,
GimpColorScales *scales);
static gboolean gimp_color_scales_hex_events (GtkWidget *widget,
GdkEvent *event,
GimpColorScales *scales);
static GimpColorSelectorClass *parent_class = NULL;
GType
gimp_color_scales_get_type (void)
{
static GType scales_type = 0;
if (! scales_type)
{
static const GTypeInfo scales_info =
{
sizeof (GimpColorScalesClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_color_scales_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpColorScales),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_color_scales_init,
};
scales_type = g_type_register_static (GIMP_TYPE_COLOR_SELECTOR,
"GimpColorScales",
&scales_info, 0);
}
return scales_type;
}
static void
gimp_color_scales_class_init (GimpColorScalesClass *klass)
{
GObjectClass *object_class;
GimpColorSelectorClass *selector_class;
object_class = G_OBJECT_CLASS (klass);
selector_class = GIMP_COLOR_SELECTOR_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_color_scales_finalize;
selector_class->name = "Scales";
selector_class->help_page = "scales.html";
selector_class->set_show_alpha = gimp_color_scales_set_show_alpha;
selector_class->set_color = gimp_color_scales_set_color;
selector_class->set_channel = gimp_color_scales_set_channel;
}
static void
gimp_color_scales_init (GimpColorScales *scales)
{
GtkWidget *table;
GtkWidget *hbox;
GtkWidget *label;
GSList *group;
gint i;
static gchar *toggle_titles[] =
{
/* Hue */
N_("H"),
/* Saturation */
N_("S"),
/* Value */
N_("V"),
/* Red */
N_("R"),
/* Green */
N_("G"),
/* Blue */
N_("B"),
/* Alpha */
N_("A")
};
static gchar *slider_tips[7] =
{
N_("Hue"),
N_("Saturation"),
N_("Value"),
N_("Red"),
N_("Green"),
N_("Blue"),
N_("Alpha")
};
static gdouble slider_initial_vals[] = { 0, 0, 0, 0, 0, 0, 0 };
static gdouble slider_max_vals[] = { 360, 100, 100, 255, 255, 255, 100 };
static gdouble slider_incs[] = { 30, 10, 10, 16, 16, 16, 10 };
table = gtk_table_new (7, 4, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 1);
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 0);
gtk_box_pack_start (GTK_BOX (scales), table, FALSE, FALSE, 0);
gtk_widget_show (table);
group = NULL;
for (i = 0; i < 7; i++)
{
if (i == 6)
{
scales->toggles[i] = NULL;
}
else
{
scales->toggles[i] = gtk_radio_button_new (group);
gimp_help_set_help_data (scales->toggles[i],
gettext (slider_tips[i]), NULL);
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (scales->toggles[i]));
gtk_table_attach (GTK_TABLE (table), scales->toggles[i],
0, 1, i, i + 1,
GTK_SHRINK, GTK_EXPAND, 0, 0);
gtk_widget_show (scales->toggles[i]);
g_signal_connect (G_OBJECT (scales->toggles[i]), "toggled",
G_CALLBACK (gimp_color_scales_toggle_update),
scales);
}
scales->slider_data[i] = gimp_scale_entry_new (GTK_TABLE (table), 1, i,
gettext (toggle_titles[i]),
80, -1,
slider_initial_vals[i],
0.0, slider_max_vals[i],
1.0, slider_incs[i],
0, TRUE, 0.0, 0.0,
gettext (slider_tips[i]),
NULL);
g_signal_connect (G_OBJECT (scales->slider_data[i]), "value_changed",
G_CALLBACK (gimp_color_scales_scale_update),
scales);
}
/* The hex triplet entry */
hbox = gtk_hbox_new (FALSE, 4);
gtk_box_pack_end (GTK_BOX (scales), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
scales->hex_entry = gtk_entry_new ();
gtk_entry_set_width_chars (GTK_ENTRY (scales->hex_entry), 7);
gtk_entry_set_max_length (GTK_ENTRY (scales->hex_entry), 7);
gtk_box_pack_end (GTK_BOX (hbox), scales->hex_entry, FALSE, FALSE, 0);
gtk_widget_show (scales->hex_entry);
g_signal_connect (G_OBJECT (scales->hex_entry), "focus_out_event",
G_CALLBACK (gimp_color_scales_hex_events),
scales);
g_signal_connect (G_OBJECT (scales->hex_entry), "key_press_event",
G_CALLBACK (gimp_color_scales_hex_events),
scales);
label = gtk_label_new_with_mnemonic (_("He_x Triplet:"));
gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
}
static void
gimp_color_scales_finalize (GObject *object)
{
GimpColorScales *scales;
scales = GIMP_COLOR_SCALES (object);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_color_scales_set_show_alpha (GimpColorSelector *selector,
gboolean show_alpha)
{
GimpColorScales *scales;
GtkWidget *label;
GtkWidget *scale;
GtkWidget *spin;
scales = GIMP_COLOR_SCALES (selector);
label = GIMP_SCALE_ENTRY_LABEL (scales->slider_data[6]);
scale = GIMP_SCALE_ENTRY_SCALE (scales->slider_data[6]);
spin = GIMP_SCALE_ENTRY_SPINBUTTON (scales->slider_data[6]);
if (show_alpha)
{
gtk_widget_show (label);
gtk_widget_show (scale);
gtk_widget_show (spin);
}
else
{
gtk_widget_hide (label);
gtk_widget_hide (scale);
gtk_widget_hide (spin);
}
}
static void
gimp_color_scales_set_color (GimpColorSelector *selector,
const GimpRGB *rgb,
const GimpHSV *hsv)
{
GimpColorScales *scales;
scales = GIMP_COLOR_SCALES (selector);
gimp_color_scales_update_scales (scales, -1);
}
static void
gimp_color_scales_set_channel (GimpColorSelector *selector,
GimpColorSelectorChannel channel)
{
GimpColorScales *scales;
scales = GIMP_COLOR_SCALES (selector);
if (channel >= 0 && channel <= 7)