Commit 37fe1a88 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/color_notebook.[ch] moved the scales and the toggle butttons out of

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

	* app/color_notebook.[ch]
	* app/color_select.c: moved the scales and the toggle butttons out
	of the notebook. Added an "Aplha" scale (the opacity is not yet
	shown in the color area). Removed the ColorNotebook structure from
	the header.

	* app/color_area.c: the ColorNotebook struct is no longer public.

	* libgimp/gimpcolorselector.h
	* modules/colorsel_gtk.c
	* modules/colorsel_triangle.c
	* modules/colorsel_water.c: changed the ColorSelector module
	interface again: Pass H, S, V, R, G, B and A in all functions
	and callbacks. Added a "set_channel" method because the channel
	toggles are outside the notebook now. This needs more work...
parent bd96765d
2001-01-09 Michael Natterer <mitch@gimp.org>
* app/color_notebook.[ch]
* app/color_select.c: moved the scales and the toggle butttons out
of the notebook. Added an "Aplha" scale (the opacity is not yet
shown in the color area). Removed the ColorNotebook structure from
the header.
* app/color_area.c: the ColorNotebook struct is no longer public.
* libgimp/gimpcolorselector.h
* modules/colorsel_gtk.c
* modules/colorsel_triangle.c
* modules/colorsel_water.c: changed the ColorSelector module
interface again: Pass H, S, V, R, G, B and A in all functions
and callbacks. Added a "set_channel" method because the channel
toggles are outside the notebook now. This needs more work...
2001-01-08 Michael Natterer <mitch@gimp.org>
* app/color_notebook.[ch]
......
......@@ -313,7 +313,7 @@ static void
color_area_edit (void)
{
GimpContext *user_context;
guchar r, g, b;
guchar r, g, b;
user_context = gimp_context_get_user ();
......@@ -346,8 +346,10 @@ color_area_edit (void)
color_notebook_show (color_notebook);
color_notebook_active = TRUE;
}
else
gdk_window_raise (color_notebook->shell->window);
else
{
color_notebook_show (color_notebook);
}
color_notebook_set_color (color_notebook, r, g, b, 255);
}
......
This diff is collapsed.
......@@ -36,28 +36,6 @@ typedef void (* ColorNotebookCallback) (gint red,
typedef struct _ColorSelectorInstance ColorSelectorInstance;
struct _ColorNotebook
{
GtkWidget *shell;
GtkWidget *notebook;
GtkWidget *new_color;
GtkWidget *orig_color;
GdkGC *gc;
gint values[4];
gint orig_values[4];
ColorNotebookCallback callback;
gpointer client_data;
gint wants_updates;
ColorSelectorInstance *selectors;
ColorSelectorInstance *cur_page;
};
ColorNotebook * color_notebook_new (gint red,
gint green,
gint blue,
......
This diff is collapsed.
This diff is collapsed.
......@@ -36,28 +36,6 @@ typedef void (* ColorNotebookCallback) (gint red,
typedef struct _ColorSelectorInstance ColorSelectorInstance;
struct _ColorNotebook
{
GtkWidget *shell;
GtkWidget *notebook;
GtkWidget *new_color;
GtkWidget *orig_color;
GdkGC *gc;
gint values[4];
gint orig_values[4];
ColorNotebookCallback callback;
gpointer client_data;
gint wants_updates;
ColorSelectorInstance *selectors;
ColorSelectorInstance *cur_page;
};
ColorNotebook * color_notebook_new (gint red,
gint green,
gint blue,
......
......@@ -313,7 +313,7 @@ static void
color_area_edit (void)
{
GimpContext *user_context;
guchar r, g, b;
guchar r, g, b;
user_context = gimp_context_get_user ();
......@@ -346,8 +346,10 @@ color_area_edit (void)
color_notebook_show (color_notebook);
color_notebook_active = TRUE;
}
else
gdk_window_raise (color_notebook->shell->window);
else
{
color_notebook_show (color_notebook);
}
color_notebook_set_color (color_notebook, r, g, b, 255);
}
......
This diff is collapsed.
......@@ -36,28 +36,6 @@ typedef void (* ColorNotebookCallback) (gint red,
typedef struct _ColorSelectorInstance ColorSelectorInstance;
struct _ColorNotebook
{
GtkWidget *shell;
GtkWidget *notebook;
GtkWidget *new_color;
GtkWidget *orig_color;
GdkGC *gc;
gint values[4];
gint orig_values[4];
ColorNotebookCallback callback;
gpointer client_data;
gint wants_updates;
ColorSelectorInstance *selectors;
ColorSelectorInstance *cur_page;
};
ColorNotebook * color_notebook_new (gint red,
gint green,
gint blue,
......
This diff is collapsed.
This diff is collapsed.
......@@ -36,28 +36,6 @@ typedef void (* ColorNotebookCallback) (gint red,
typedef struct _ColorSelectorInstance ColorSelectorInstance;
struct _ColorNotebook
{
GtkWidget *shell;
GtkWidget *notebook;
GtkWidget *new_color;
GtkWidget *orig_color;
GdkGC *gc;
gint values[4];
gint orig_values[4];
ColorNotebookCallback callback;
gpointer client_data;
gint wants_updates;
ColorSelectorInstance *selectors;
ColorSelectorInstance *cur_page;
};
ColorNotebook * color_notebook_new (gint red,
gint green,
gint blue,
......
......@@ -313,7 +313,7 @@ static void
color_area_edit (void)
{
GimpContext *user_context;
guchar r, g, b;
guchar r, g, b;
user_context = gimp_context_get_user ();
......@@ -346,8 +346,10 @@ color_area_edit (void)
color_notebook_show (color_notebook);
color_notebook_active = TRUE;
}
else
gdk_window_raise (color_notebook->shell->window);
else
{
color_notebook_show (color_notebook);
}
color_notebook_set_color (color_notebook, r, g, b, 255);
}
......
......@@ -28,13 +28,31 @@ extern "C" {
/* For information look at the html documentation */
typedef enum
{
GIMP_COLOR_SELECTOR_HUE,
GIMP_COLOR_SELECTOR_SATURATION,
GIMP_COLOR_SELECTOR_VALUE,
GIMP_COLOR_SELECTOR_RED,
GIMP_COLOR_SELECTOR_GREEN,
GIMP_COLOR_SELECTOR_BLUE,
GIMP_COLOR_SELECTOR_ALPHA
} GimpColorSelectorChannelType;
typedef void (* GimpColorSelectorCallback) (gpointer data,
gint h,
gint s,
gint v,
gint r,
gint g,
gint b,
gint a);
typedef GtkWidget * (* GimpColorSelectorNewFunc) (gint r,
typedef GtkWidget * (* GimpColorSelectorNewFunc) (gint h,
gint s,
gint v,
gint r,
gint g,
gint b,
gint a,
......@@ -47,11 +65,17 @@ typedef void (* GimpColorSelectorFreeFunc) (gpointer selector_data);
typedef void (* GimpColorSelectorSetColorFunc) (gpointer selector_data,
gint h,
gint s,
gint v,
gint r,
gint g,
gint b,
gint a);
typedef void (* GimpColorSelectorSetChannelFunc) (gpointer selector_data,
GimpColorSelectorChannelType type);
typedef void (* GimpColorSelectorFinishedCB) (gpointer finished_data);
......@@ -59,9 +83,11 @@ typedef struct _GimpColorSelectorMethods GimpColorSelectorMethods;
struct _GimpColorSelectorMethods
{
GimpColorSelectorNewFunc new;
GimpColorSelectorFreeFunc free;
GimpColorSelectorSetColorFunc setcolor;
GimpColorSelectorNewFunc new;
GimpColorSelectorFreeFunc free;
GimpColorSelectorSetColorFunc set_color;
GimpColorSelectorSetChannelFunc set_channel;
};
typedef gpointer GimpColorSelectorID;
......
This diff is collapsed.
......@@ -27,28 +27,38 @@
#include "gimpmodregister.h"
#include "libgimp/gimpcolorselector.h"
#include "libgimp/gimpcolor.h"
#include "libgimp/gimpcolorspace.h"
#include "libgimp/gimpmodule.h"
#include "libgimp/gimpintl.h"
/* prototypes */
static GtkWidget * colorsel_gtk_new (gint r,
gint g,
gint b,
gint a,
gboolean show_alpha,
GimpColorSelectorCallback callback,
gpointer data,
gpointer *selector_data);
static void colorsel_gtk_free (gpointer data);
static void colorsel_gtk_setcolor (gpointer data,
gint r,
gint g,
gint b,
gint a);
static void colorsel_gtk_update (GtkWidget *widget,
gpointer data);
static GtkWidget * colorsel_gtk_new (gint h,
gint s,
gint v,
gint r,
gint g,
gint b,
gint a,
gboolean show_alpha,
GimpColorSelectorCallback callback,
gpointer data,
gpointer *selector_data);
static void colorsel_gtk_free (gpointer data);
static void colorsel_gtk_set_color (gpointer data,
gint h,
gint s,
gint v,
gint r,
gint g,
gint b,
gint a);
static void colorsel_gtk_set_channel (gpointer data,
GimpColorSelectorChannelType channel);
static void colorsel_gtk_update (GtkWidget *widget,
gpointer data);
/* EEK */
static gboolean colorsel_gtk_widget_idle_hide (gpointer data);
......@@ -61,7 +71,8 @@ static GimpColorSelectorMethods methods =
{
colorsel_gtk_new,
colorsel_gtk_free,
colorsel_gtk_setcolor
colorsel_gtk_set_color,
colorsel_gtk_set_channel
};
static GimpModuleInfo info =
......@@ -125,7 +136,10 @@ typedef struct
static GtkWidget *
colorsel_gtk_new (gint r,
colorsel_gtk_new (gint h,
gint s,
gint v,
gint r,
gint g,
gint b,
gint a,
......@@ -148,11 +162,9 @@ colorsel_gtk_new (gint r,
gtk_color_selection_set_opacity (GTK_COLOR_SELECTION (p->selector),
show_alpha);
/*
gtk_widget_hide (GTK_COLOR_SELECTION (p->selector)->sample_area->parent);
*/
gtk_widget_hide (GTK_COLOR_SELECTION (p->selector)->scales[0]->parent);
colorsel_gtk_setcolor (p, r, g, b, a);
colorsel_gtk_set_color (p, h, s, v, r, g, b, a);
/* EEK: to be removed */
gtk_signal_connect_object_after
......@@ -190,11 +202,14 @@ colorsel_gtk_free (gpointer data)
}
static void
colorsel_gtk_setcolor (gpointer data,
gint r,
gint g,
gint b,
gint a)
colorsel_gtk_set_color (gpointer data,
gint h,
gint s,
gint v,
gint r,
gint g,
gint b,
gint a)
{
ColorselGtk *p = data;
......@@ -208,11 +223,20 @@ colorsel_gtk_setcolor (gpointer data,
gtk_color_selection_set_color (GTK_COLOR_SELECTION (p->selector), color);
}
static void
colorsel_gtk_set_channel (gpointer data,
GimpColorSelectorChannelType channel)
{
}
static void
colorsel_gtk_update (GtkWidget *widget,
gpointer data)
{
ColorselGtk *p = data;
gint h;
gint s;
gint v;
gint r;
gint g;
gint b;
......@@ -226,7 +250,13 @@ colorsel_gtk_update (GtkWidget *widget,
b = (gint) (color[2] * 255.999);
a = (gint) (color[3] * 255.999);
p->callback (p->client_data, r, g, b, a);
gimp_rgb_to_hsv_double (&color[0], &color[1], &color[2]);
h = (gint) (color[0] * 360.999);
s = (gint) (color[1] * 255.999);
v = (gint) (color[2] * 255.999);
p->callback (p->client_data, h, v, s, r, g, b, a);
}
/* EEK */
......
......@@ -37,7 +37,10 @@
/* prototypes */
static GtkWidget * colorsel_triangle_new (gint red,
static GtkWidget * colorsel_triangle_new (gint hue,
gint saturation,
gint value,
gint red,
gint green,
gint blue,
gint alpha,
......@@ -48,11 +51,16 @@ static GtkWidget * colorsel_triangle_new (gint red,
static void colorsel_triangle_free (gpointer selector_data);
static void colorsel_triangle_setcolor (gpointer selector_data,
static void colorsel_triangle_set_color (gpointer selector_data,
gint hue,
gint saturation,
gint value,
gint red,
gint green,
gint blue,
gint alpha);
static void colorsel_triangle_set_channel (gpointer selector_data,
GimpColorSelectorChannelType channel);
/* local methods */
......@@ -60,7 +68,8 @@ static GimpColorSelectorMethods methods =
{
colorsel_triangle_new,
colorsel_triangle_free,
colorsel_triangle_setcolor
colorsel_triangle_set_color,
colorsel_triangle_set_channel
};
......@@ -123,7 +132,9 @@ static void color_select_update_rgb_values (ColorSelect *coldata);
static void update_previews (ColorSelect *coldata,
gboolean hue_changed);
/*
static void color_select_update_hsv_values (ColorSelect *coldata);
*/
/*************************************************************/
......@@ -168,7 +179,10 @@ module_unload (gpointer shutdown_data,
/* methods */
static GtkWidget *
colorsel_triangle_new (gint red,
colorsel_triangle_new (gint hue,
gint saturation,
gint value,
gint red,
gint green,
gint blue,
gint alpha,
......@@ -185,12 +199,13 @@ colorsel_triangle_new (gint red,
GtkWidget *vbox;
coldata = g_new (ColorSelect, 1);
coldata->values[RED] = red;
coldata->values[GREEN] = green;
coldata->values[BLUE] = blue;
coldata->values[ALPHA] = alpha;
color_select_update_hsv_values (coldata);
coldata->values[HUE] = hue;
coldata->values[SATURATION] = saturation;
coldata->values[VALUE] = value;
coldata->values[RED] = red;
coldata->values[GREEN] = green;
coldata->values[BLUE] = blue;
coldata->values[ALPHA] = alpha;
coldata->oldsat = 0;
coldata->oldval = 0;
......@@ -227,26 +242,36 @@ colorsel_triangle_free (gpointer selector_data)
}
static void
colorsel_triangle_setcolor (gpointer selector_data,
gint red,
gint green,
gint blue,
gint alpha)
colorsel_triangle_set_color (gpointer selector_data,
gint hue,
gint saturation,
gint value,
gint red,
gint green,
gint blue,
gint alpha)
{
ColorSelect *coldata;
coldata = selector_data;
coldata->values[RED] = red;
coldata->values[GREEN] = green;
coldata->values[BLUE] = blue;
coldata->values[ALPHA] = alpha;
color_select_update_hsv_values (coldata);
coldata->values[HUE] = hue;
coldata->values[SATURATION] = saturation;
coldata->values[VALUE] = value;
coldata->values[RED] = red;
coldata->values[GREEN] = green;
coldata->values[BLUE] = blue;
coldata->values[ALPHA] = alpha;
update_previews (coldata, TRUE);
}
static void
colorsel_triangle_set_channel (gpointer selector_data,
GimpColorSelectorChannelType channel)
{
}
/*************************************************************/
/* helper functions */
......@@ -262,14 +287,15 @@ color_select_update_rgb_values (ColorSelect *csp)
&(csp->values[BLUE]));
}
/*
static void
color_select_update_hsv_values (ColorSelect *csp)
{
gdouble hue, sat, val;
hue = (gdouble) csp->values[RED] / 255;
hue = (gdouble) csp->values[RED] / 255;
sat = (gdouble) csp->values[GREEN] / 255;
val = (gdouble) csp->values[BLUE] / 255;
val = (gdouble) csp->values[BLUE] / 255;
gimp_rgb_to_hsv_double (&hue, &sat, &val);
......@@ -277,7 +303,7 @@ color_select_update_hsv_values (ColorSelect *csp)
csp->values[SATURATION] = RINT (sat * 100);
csp->values[VALUE] = RINT (val * 100);
}
*/
static void
update_previews (ColorSelect *coldata,
......@@ -492,11 +518,14 @@ color_selection_callback (GtkWidget *widget,
gtk_grab_remove (widget);
/* callback the user */
(*coldata->callback) (coldata->data,
coldata->values[RED],
coldata->values[GREEN],
coldata->values[BLUE],
coldata->values[ALPHA]);
(* coldata->callback) (coldata->data,
coldata->values[HUE],
coldata->values[SATURATION],
coldata->values[VALUE],
coldata->values[RED],
coldata->values[GREEN],
coldata->values[BLUE],
coldata->values[ALPHA]);
return FALSE;
break;
......@@ -580,11 +609,14 @@ color_selection_callback (GtkWidget *widget,
}
/* callback the user */
(*coldata->callback) (coldata->data,
coldata->values[RED],
coldata->values[GREEN],
coldata->values[BLUE],
coldata->values[ALPHA]);
(* coldata->callback) (coldata->data,
coldata->values[HUE],
coldata->values[SATURATION],
coldata->values[VALUE],
coldata->values[RED],
coldata->values[GREEN],
coldata->values[BLUE],
coldata->values[ALPHA]);
return FALSE;
}
......
......@@ -26,6 +26,8 @@
#include <gtk/gtk.h>
#include <libgimp/gimpcolorselector.h>
#include <libgimp/gimpcolor.h>
#include <libgimp/gimpcolorspace.h>
#include <libgimp/gimpmodule.h>