mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-09-29 18:47:38 +00:00
Deprecate old color selection widgets
GtkColorSelectionDialog, GtkColorSelection and GtkHSV have been superseded by the GtkColorChooser* family of widgets.
This commit is contained in:
parent
23a5f7a22c
commit
cb128cc6e9
@ -145,6 +145,8 @@ endif
|
|||||||
# by configure)
|
# by configure)
|
||||||
|
|
||||||
deprecated_h_sources = \
|
deprecated_h_sources = \
|
||||||
|
deprecated/gtkcolorsel.h \
|
||||||
|
deprecated/gtkcolorseldialog.h \
|
||||||
deprecated/gtkfontsel.h \
|
deprecated/gtkfontsel.h \
|
||||||
deprecated/gtkhandlebox.h \
|
deprecated/gtkhandlebox.h \
|
||||||
deprecated/gtkhbbox.h \
|
deprecated/gtkhbbox.h \
|
||||||
@ -153,6 +155,7 @@ deprecated_h_sources = \
|
|||||||
deprecated/gtkhscale.h \
|
deprecated/gtkhscale.h \
|
||||||
deprecated/gtkhscrollbar.h \
|
deprecated/gtkhscrollbar.h \
|
||||||
deprecated/gtkhseparator.h \
|
deprecated/gtkhseparator.h \
|
||||||
|
deprecated/gtkhsv.h \
|
||||||
deprecated/gtkstyle.h \
|
deprecated/gtkstyle.h \
|
||||||
deprecated/gtkrc.h \
|
deprecated/gtkrc.h \
|
||||||
deprecated/gtktable.h \
|
deprecated/gtktable.h \
|
||||||
@ -215,11 +218,10 @@ gtk_public_h_sources = \
|
|||||||
gtkcheckmenuitem.h \
|
gtkcheckmenuitem.h \
|
||||||
gtkclipboard.h \
|
gtkclipboard.h \
|
||||||
gtkcolorbutton.h \
|
gtkcolorbutton.h \
|
||||||
gtkcolorsel.h \
|
|
||||||
gtkcolorseldialog.h \
|
|
||||||
gtkcolorchooser.h \
|
gtkcolorchooser.h \
|
||||||
gtkcolorchooserwidget.h \
|
gtkcolorchooserwidget.h \
|
||||||
gtkcolorchooserdialog.h \
|
gtkcolorchooserdialog.h \
|
||||||
|
gtkcolorutils.h \
|
||||||
gtkcombobox.h \
|
gtkcombobox.h \
|
||||||
gtkcomboboxtext.h \
|
gtkcomboboxtext.h \
|
||||||
gtkcontainer.h \
|
gtkcontainer.h \
|
||||||
@ -249,7 +251,6 @@ gtk_public_h_sources = \
|
|||||||
gtkframe.h \
|
gtkframe.h \
|
||||||
gtkgradient.h \
|
gtkgradient.h \
|
||||||
gtkgrid.h \
|
gtkgrid.h \
|
||||||
gtkhsv.h \
|
|
||||||
gtkiconfactory.h \
|
gtkiconfactory.h \
|
||||||
gtkicontheme.h \
|
gtkicontheme.h \
|
||||||
gtkiconview.h \
|
gtkiconview.h \
|
||||||
@ -514,6 +515,8 @@ gtk_private_h_sources = \
|
|||||||
|
|
||||||
# GTK+ C sources to build the library from
|
# GTK+ C sources to build the library from
|
||||||
deprecated_c_sources = \
|
deprecated_c_sources = \
|
||||||
|
deprecated/gtkcolorsel.c \
|
||||||
|
deprecated/gtkcolorseldialog.c \
|
||||||
deprecated/gtkfontsel.c \
|
deprecated/gtkfontsel.c \
|
||||||
deprecated/gtkhandlebox.c \
|
deprecated/gtkhandlebox.c \
|
||||||
deprecated/gtkhbbox.c \
|
deprecated/gtkhbbox.c \
|
||||||
@ -522,6 +525,7 @@ deprecated_c_sources = \
|
|||||||
deprecated/gtkhscale.c \
|
deprecated/gtkhscale.c \
|
||||||
deprecated/gtkhscrollbar.c \
|
deprecated/gtkhscrollbar.c \
|
||||||
deprecated/gtkhseparator.c \
|
deprecated/gtkhseparator.c \
|
||||||
|
deprecated/gtkhsv.c \
|
||||||
deprecated/gtkrc.c \
|
deprecated/gtkrc.c \
|
||||||
deprecated/gtkstyle.c \
|
deprecated/gtkstyle.c \
|
||||||
deprecated/gtktable.c \
|
deprecated/gtktable.c \
|
||||||
@ -598,15 +602,14 @@ gtk_base_c_sources = \
|
|||||||
gtkcheckbutton.c \
|
gtkcheckbutton.c \
|
||||||
gtkcheckmenuitem.c \
|
gtkcheckmenuitem.c \
|
||||||
gtkcolorbutton.c \
|
gtkcolorbutton.c \
|
||||||
gtkcolorsel.c \
|
gtkcolorchooser.c \
|
||||||
gtkcolorseldialog.c \
|
gtkcolorchooserwidget.c \
|
||||||
|
gtkcolorchooserdialog.c \
|
||||||
gtkcoloreditor.c \
|
gtkcoloreditor.c \
|
||||||
gtkcolorplane.c \
|
gtkcolorplane.c \
|
||||||
gtkcolorscale.c \
|
gtkcolorscale.c \
|
||||||
gtkcolorswatch.c \
|
gtkcolorswatch.c \
|
||||||
gtkcolorchooser.c \
|
gtkcolorutils.c \
|
||||||
gtkcolorchooserwidget.c \
|
|
||||||
gtkcolorchooserdialog.c \
|
|
||||||
gtkcombobox.c \
|
gtkcombobox.c \
|
||||||
gtkcomboboxtext.c \
|
gtkcomboboxtext.c \
|
||||||
gtkcontainer.c \
|
gtkcontainer.c \
|
||||||
@ -656,7 +659,6 @@ gtk_base_c_sources = \
|
|||||||
gtkframe.c \
|
gtkframe.c \
|
||||||
gtkgradient.c \
|
gtkgradient.c \
|
||||||
gtkgrid.c \
|
gtkgrid.c \
|
||||||
gtkhsv.c \
|
|
||||||
gtkiconcache.c \
|
gtkiconcache.c \
|
||||||
gtkiconcachevalidator.c \
|
gtkiconcachevalidator.c \
|
||||||
gtkiconfactory.c \
|
gtkiconfactory.c \
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#define GDK_DISABLE_DEPRECATION_WARNINGS
|
||||||
|
|
||||||
#include "gtkcolorsel.h"
|
#include "gtkcolorsel.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@ -62,7 +64,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* SECTION:gtkcolorsel
|
* SECTION:gtkcolorsel
|
||||||
* @Short_description: A widget used to select a color
|
* @Short_description: Deprecated widget used to select a color
|
||||||
* @Title: GtkColorSelection
|
* @Title: GtkColorSelection
|
||||||
*
|
*
|
||||||
* The #GtkColorSelection is a widget that is used to select
|
* The #GtkColorSelection is a widget that is used to select
|
@ -89,51 +89,67 @@ struct _GtkColorSelectionClass
|
|||||||
/* ColorSelection */
|
/* ColorSelection */
|
||||||
|
|
||||||
GType gtk_color_selection_get_type (void) G_GNUC_CONST;
|
GType gtk_color_selection_get_type (void) G_GNUC_CONST;
|
||||||
|
GDK_DEPRECATED_FOR(gtk_color_chooser_widget_new)
|
||||||
GtkWidget *gtk_color_selection_new (void);
|
GtkWidget *gtk_color_selection_new (void);
|
||||||
|
GDK_DEPRECATED_FOR(gtk_color_chooser_get_use_alpha)
|
||||||
gboolean gtk_color_selection_get_has_opacity_control (GtkColorSelection *colorsel);
|
gboolean gtk_color_selection_get_has_opacity_control (GtkColorSelection *colorsel);
|
||||||
|
GDK_DEPRECATED_FOR(gtk_color_chooser_set_use_alpha)
|
||||||
void gtk_color_selection_set_has_opacity_control (GtkColorSelection *colorsel,
|
void gtk_color_selection_set_has_opacity_control (GtkColorSelection *colorsel,
|
||||||
gboolean has_opacity);
|
gboolean has_opacity);
|
||||||
|
GDK_DEPRECATED
|
||||||
gboolean gtk_color_selection_get_has_palette (GtkColorSelection *colorsel);
|
gboolean gtk_color_selection_get_has_palette (GtkColorSelection *colorsel);
|
||||||
|
GDK_DEPRECATED
|
||||||
void gtk_color_selection_set_has_palette (GtkColorSelection *colorsel,
|
void gtk_color_selection_set_has_palette (GtkColorSelection *colorsel,
|
||||||
gboolean has_palette);
|
gboolean has_palette);
|
||||||
|
|
||||||
|
|
||||||
|
GDK_DEPRECATED_FOR(gtk_color_chooser_set_rgba)
|
||||||
void gtk_color_selection_set_current_alpha (GtkColorSelection *colorsel,
|
void gtk_color_selection_set_current_alpha (GtkColorSelection *colorsel,
|
||||||
guint16 alpha);
|
guint16 alpha);
|
||||||
|
GDK_DEPRECATED_FOR(gtk_color_chooser_get_rgba)
|
||||||
guint16 gtk_color_selection_get_current_alpha (GtkColorSelection *colorsel);
|
guint16 gtk_color_selection_get_current_alpha (GtkColorSelection *colorsel);
|
||||||
|
GDK_DEPRECATED
|
||||||
void gtk_color_selection_set_previous_alpha (GtkColorSelection *colorsel,
|
void gtk_color_selection_set_previous_alpha (GtkColorSelection *colorsel,
|
||||||
guint16 alpha);
|
guint16 alpha);
|
||||||
|
GDK_DEPRECATED
|
||||||
guint16 gtk_color_selection_get_previous_alpha (GtkColorSelection *colorsel);
|
guint16 gtk_color_selection_get_previous_alpha (GtkColorSelection *colorsel);
|
||||||
|
|
||||||
|
GDK_DEPRECATED_FOR(gtk_color_chooser_set_rgba)
|
||||||
void gtk_color_selection_set_current_rgba (GtkColorSelection *colorsel,
|
void gtk_color_selection_set_current_rgba (GtkColorSelection *colorsel,
|
||||||
const GdkRGBA *rgba);
|
const GdkRGBA *rgba);
|
||||||
|
GDK_DEPRECATED_FOR(gtk_color_chooser_get_rgba)
|
||||||
void gtk_color_selection_get_current_rgba (GtkColorSelection *colorsel,
|
void gtk_color_selection_get_current_rgba (GtkColorSelection *colorsel,
|
||||||
GdkRGBA *rgba);
|
GdkRGBA *rgba);
|
||||||
|
GDK_DEPRECATED
|
||||||
void gtk_color_selection_set_previous_rgba (GtkColorSelection *colorsel,
|
void gtk_color_selection_set_previous_rgba (GtkColorSelection *colorsel,
|
||||||
const GdkRGBA *rgba);
|
const GdkRGBA *rgba);
|
||||||
|
GDK_DEPRECATED
|
||||||
void gtk_color_selection_get_previous_rgba (GtkColorSelection *colorsel,
|
void gtk_color_selection_get_previous_rgba (GtkColorSelection *colorsel,
|
||||||
GdkRGBA *rgba);
|
GdkRGBA *rgba);
|
||||||
|
|
||||||
|
GDK_DEPRECATED
|
||||||
gboolean gtk_color_selection_is_adjusting (GtkColorSelection *colorsel);
|
gboolean gtk_color_selection_is_adjusting (GtkColorSelection *colorsel);
|
||||||
|
|
||||||
|
GDK_DEPRECATED
|
||||||
gboolean gtk_color_selection_palette_from_string (const gchar *str,
|
gboolean gtk_color_selection_palette_from_string (const gchar *str,
|
||||||
GdkColor **colors,
|
GdkColor **colors,
|
||||||
gint *n_colors);
|
gint *n_colors);
|
||||||
|
GDK_DEPRECATED
|
||||||
gchar* gtk_color_selection_palette_to_string (const GdkColor *colors,
|
gchar* gtk_color_selection_palette_to_string (const GdkColor *colors,
|
||||||
gint n_colors);
|
gint n_colors);
|
||||||
|
|
||||||
GtkColorSelectionChangePaletteWithScreenFunc gtk_color_selection_set_change_palette_with_screen_hook (GtkColorSelectionChangePaletteWithScreenFunc func);
|
GtkColorSelectionChangePaletteWithScreenFunc gtk_color_selection_set_change_palette_with_screen_hook (GtkColorSelectionChangePaletteWithScreenFunc func);
|
||||||
|
|
||||||
GDK_DEPRECATED_FOR(gtk_color_selection_set_current_rgba)
|
GDK_DEPRECATED_FOR(gtk_color_chooser_set_rgba)
|
||||||
void gtk_color_selection_set_current_color (GtkColorSelection *colorsel,
|
void gtk_color_selection_set_current_color (GtkColorSelection *colorsel,
|
||||||
const GdkColor *color);
|
const GdkColor *color);
|
||||||
GDK_DEPRECATED_FOR(gtk_color_selection_get_current_rgba)
|
GDK_DEPRECATED_FOR(gtk_color_chooser_get_rgba)
|
||||||
void gtk_color_selection_get_current_color (GtkColorSelection *colorsel,
|
void gtk_color_selection_get_current_color (GtkColorSelection *colorsel,
|
||||||
GdkColor *color);
|
GdkColor *color);
|
||||||
GDK_DEPRECATED_FOR(gtk_color_selection_set_previous_rgba)
|
GDK_DEPRECATED
|
||||||
void gtk_color_selection_set_previous_color (GtkColorSelection *colorsel,
|
void gtk_color_selection_set_previous_color (GtkColorSelection *colorsel,
|
||||||
const GdkColor *color);
|
const GdkColor *color);
|
||||||
GDK_DEPRECATED_FOR(gtk_color_selection_get_previous_rgba)
|
GDK_DEPRECATED
|
||||||
void gtk_color_selection_get_previous_color (GtkColorSelection *colorsel,
|
void gtk_color_selection_get_previous_color (GtkColorSelection *colorsel,
|
||||||
GdkColor *color);
|
GdkColor *color);
|
||||||
|
|
@ -24,6 +24,10 @@
|
|||||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||||
*/
|
*/
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#define GDK_DISABLE_DEPRECATION_WARNINGS
|
||||||
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include "gtkcolorseldialog.h"
|
#include "gtkcolorseldialog.h"
|
||||||
@ -36,7 +40,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* SECTION:gtkcolorseldlg
|
* SECTION:gtkcolorseldlg
|
||||||
* @Short_description: A standard dialog box for selecting a color
|
* @Short_description: Deprecated dialog box for selecting a color
|
||||||
* @Title: GtkColorSelectionDialog
|
* @Title: GtkColorSelectionDialog
|
||||||
*
|
*
|
||||||
* The #GtkColorSelectionDialog provides a standard dialog which
|
* The #GtkColorSelectionDialog provides a standard dialog which
|
@ -32,7 +32,7 @@
|
|||||||
#define __GTK_COLOR_SELECTION_DIALOG_H__
|
#define __GTK_COLOR_SELECTION_DIALOG_H__
|
||||||
|
|
||||||
#include <gtk/gtkdialog.h>
|
#include <gtk/gtkdialog.h>
|
||||||
#include <gtk/gtkcolorsel.h>
|
#include <gtk/deprecated/gtkcolorsel.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -71,7 +71,9 @@ struct _GtkColorSelectionDialogClass
|
|||||||
|
|
||||||
/* ColorSelectionDialog */
|
/* ColorSelectionDialog */
|
||||||
GType gtk_color_selection_dialog_get_type (void) G_GNUC_CONST;
|
GType gtk_color_selection_dialog_get_type (void) G_GNUC_CONST;
|
||||||
|
GDK_DEPRECATED_FOR(gtk_color_chooser_dialog_new)
|
||||||
GtkWidget* gtk_color_selection_dialog_new (const gchar *title);
|
GtkWidget* gtk_color_selection_dialog_new (const gchar *title);
|
||||||
|
GDK_DEPRECATED_FOR(GtkColorChooser)
|
||||||
GtkWidget* gtk_color_selection_dialog_get_color_selection (GtkColorSelectionDialog *colorsel);
|
GtkWidget* gtk_color_selection_dialog_get_color_selection (GtkColorSelectionDialog *colorsel);
|
||||||
|
|
||||||
|
|
@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#define GDK_DISABLE_DEPRECATION_WARNINGS
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -52,6 +54,9 @@
|
|||||||
* intuitive way. Moving the selection around the outer ring changes the hue,
|
* intuitive way. Moving the selection around the outer ring changes the hue,
|
||||||
* and moving the selection point inside the inner triangle changes value and
|
* and moving the selection point inside the inner triangle changes value and
|
||||||
* saturation.
|
* saturation.
|
||||||
|
*
|
||||||
|
* #GtkHSV has been deprecated together with #GtkColorSelection, where
|
||||||
|
* it was used.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -1454,84 +1459,6 @@ gtk_hsv_is_adjusting (GtkHSV *hsv)
|
|||||||
return priv->mode != DRAG_NONE;
|
return priv->mode != DRAG_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gtk_hsv_to_rgb:
|
|
||||||
* @h: Hue
|
|
||||||
* @s: Saturation
|
|
||||||
* @v: Value
|
|
||||||
* @r: (out): Return value for the red component
|
|
||||||
* @g: (out): Return value for the green component
|
|
||||||
* @b: (out): Return value for the blue component
|
|
||||||
*
|
|
||||||
* Converts a color from HSV space to RGB.
|
|
||||||
* Input values must be in the [0.0, 1.0] range;
|
|
||||||
* output values will be in the same range.
|
|
||||||
*
|
|
||||||
* Since: 2.14
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
gtk_hsv_to_rgb (gdouble h,
|
|
||||||
gdouble s,
|
|
||||||
gdouble v,
|
|
||||||
gdouble *r,
|
|
||||||
gdouble *g,
|
|
||||||
gdouble *b)
|
|
||||||
{
|
|
||||||
g_return_if_fail (h >= 0.0 && h <= 1.0);
|
|
||||||
g_return_if_fail (s >= 0.0 && s <= 1.0);
|
|
||||||
g_return_if_fail (v >= 0.0 && v <= 1.0);
|
|
||||||
|
|
||||||
hsv_to_rgb (&h, &s, &v);
|
|
||||||
|
|
||||||
if (r)
|
|
||||||
*r = h;
|
|
||||||
|
|
||||||
if (g)
|
|
||||||
*g = s;
|
|
||||||
|
|
||||||
if (b)
|
|
||||||
*b = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gtk_rgb_to_hsv:
|
|
||||||
* @r: Red
|
|
||||||
* @g: Green
|
|
||||||
* @b: Blue
|
|
||||||
* @h: (out): Return value for the hue component
|
|
||||||
* @s: (out): Return value for the saturation component
|
|
||||||
* @v: (out): Return value for the value component
|
|
||||||
*
|
|
||||||
* Converts a color from RGB space to HSV.
|
|
||||||
* Input values must be in the [0.0, 1.0] range;
|
|
||||||
* output values will be in the same range.
|
|
||||||
*
|
|
||||||
* Since: 2.14
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
gtk_rgb_to_hsv (gdouble r,
|
|
||||||
gdouble g,
|
|
||||||
gdouble b,
|
|
||||||
gdouble *h,
|
|
||||||
gdouble *s,
|
|
||||||
gdouble *v)
|
|
||||||
{
|
|
||||||
g_return_if_fail (r >= 0.0 && r <= 1.0);
|
|
||||||
g_return_if_fail (g >= 0.0 && g <= 1.0);
|
|
||||||
g_return_if_fail (b >= 0.0 && b <= 1.0);
|
|
||||||
|
|
||||||
rgb_to_hsv (&r, &g, &b);
|
|
||||||
|
|
||||||
if (h)
|
|
||||||
*h = r;
|
|
||||||
|
|
||||||
if (s)
|
|
||||||
*s = g;
|
|
||||||
|
|
||||||
if (v)
|
|
||||||
*v = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_hsv_move (GtkHSV *hsv,
|
gtk_hsv_move (GtkHSV *hsv,
|
||||||
GtkDirectionType dir)
|
GtkDirectionType dir)
|
@ -80,37 +80,29 @@ struct _GtkHSVClass
|
|||||||
|
|
||||||
|
|
||||||
GType gtk_hsv_get_type (void) G_GNUC_CONST;
|
GType gtk_hsv_get_type (void) G_GNUC_CONST;
|
||||||
|
GDK_DEPRECATED
|
||||||
GtkWidget* gtk_hsv_new (void);
|
GtkWidget* gtk_hsv_new (void);
|
||||||
|
GDK_DEPRECATED
|
||||||
void gtk_hsv_set_color (GtkHSV *hsv,
|
void gtk_hsv_set_color (GtkHSV *hsv,
|
||||||
double h,
|
double h,
|
||||||
double s,
|
double s,
|
||||||
double v);
|
double v);
|
||||||
|
GDK_DEPRECATED
|
||||||
void gtk_hsv_get_color (GtkHSV *hsv,
|
void gtk_hsv_get_color (GtkHSV *hsv,
|
||||||
gdouble *h,
|
gdouble *h,
|
||||||
gdouble *s,
|
gdouble *s,
|
||||||
gdouble *v);
|
gdouble *v);
|
||||||
|
GDK_DEPRECATED
|
||||||
void gtk_hsv_set_metrics (GtkHSV *hsv,
|
void gtk_hsv_set_metrics (GtkHSV *hsv,
|
||||||
gint size,
|
gint size,
|
||||||
gint ring_width);
|
gint ring_width);
|
||||||
|
GDK_DEPRECATED
|
||||||
void gtk_hsv_get_metrics (GtkHSV *hsv,
|
void gtk_hsv_get_metrics (GtkHSV *hsv,
|
||||||
gint *size,
|
gint *size,
|
||||||
gint *ring_width);
|
gint *ring_width);
|
||||||
|
GDK_DEPRECATED
|
||||||
gboolean gtk_hsv_is_adjusting (GtkHSV *hsv);
|
gboolean gtk_hsv_is_adjusting (GtkHSV *hsv);
|
||||||
|
|
||||||
/* Convert colors between the RGB and HSV color spaces */
|
|
||||||
void gtk_hsv_to_rgb (gdouble h,
|
|
||||||
gdouble s,
|
|
||||||
gdouble v,
|
|
||||||
gdouble *r,
|
|
||||||
gdouble *g,
|
|
||||||
gdouble *b);
|
|
||||||
void gtk_rgb_to_hsv (gdouble r,
|
|
||||||
gdouble g,
|
|
||||||
gdouble b,
|
|
||||||
gdouble *h,
|
|
||||||
gdouble *s,
|
|
||||||
gdouble *v);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GTK_HSV_H__ */
|
#endif /* __GTK_HSV_H__ */
|
@ -81,8 +81,7 @@
|
|||||||
#include <gtk/gtkcolorchooser.h>
|
#include <gtk/gtkcolorchooser.h>
|
||||||
#include <gtk/gtkcolorchooserdialog.h>
|
#include <gtk/gtkcolorchooserdialog.h>
|
||||||
#include <gtk/gtkcolorchooserwidget.h>
|
#include <gtk/gtkcolorchooserwidget.h>
|
||||||
#include <gtk/gtkcolorsel.h>
|
#include <gtk/gtkcolorutils.h>
|
||||||
#include <gtk/gtkcolorseldialog.h>
|
|
||||||
#include <gtk/gtkcombobox.h>
|
#include <gtk/gtkcombobox.h>
|
||||||
#include <gtk/gtkcomboboxtext.h>
|
#include <gtk/gtkcomboboxtext.h>
|
||||||
#include <gtk/gtkcontainer.h>
|
#include <gtk/gtkcontainer.h>
|
||||||
@ -112,7 +111,6 @@
|
|||||||
#include <gtk/gtkframe.h>
|
#include <gtk/gtkframe.h>
|
||||||
#include <gtk/gtkgradient.h>
|
#include <gtk/gtkgradient.h>
|
||||||
#include <gtk/gtkgrid.h>
|
#include <gtk/gtkgrid.h>
|
||||||
#include <gtk/gtkhsv.h>
|
|
||||||
#include <gtk/gtkiconfactory.h>
|
#include <gtk/gtkiconfactory.h>
|
||||||
#include <gtk/gtkicontheme.h>
|
#include <gtk/gtkicontheme.h>
|
||||||
#include <gtk/gtkiconview.h>
|
#include <gtk/gtkiconview.h>
|
||||||
@ -226,11 +224,14 @@
|
|||||||
#include <gtk/gtkwidgetpath.h>
|
#include <gtk/gtkwidgetpath.h>
|
||||||
#include <gtk/gtkwindow.h>
|
#include <gtk/gtkwindow.h>
|
||||||
|
|
||||||
|
#include <gtk/deprecated/gtkcolorsel.h>
|
||||||
|
#include <gtk/deprecated/gtkcolorseldialog.h>
|
||||||
#include <gtk/deprecated/gtkfontsel.h>
|
#include <gtk/deprecated/gtkfontsel.h>
|
||||||
#include <gtk/deprecated/gtkhandlebox.h>
|
#include <gtk/deprecated/gtkhandlebox.h>
|
||||||
#include <gtk/deprecated/gtkhbbox.h>
|
#include <gtk/deprecated/gtkhbbox.h>
|
||||||
#include <gtk/deprecated/gtkhbox.h>
|
#include <gtk/deprecated/gtkhbox.h>
|
||||||
#include <gtk/deprecated/gtkhpaned.h>
|
#include <gtk/deprecated/gtkhpaned.h>
|
||||||
|
#include <gtk/deprecated/gtkhsv.h>
|
||||||
#include <gtk/deprecated/gtkhscale.h>
|
#include <gtk/deprecated/gtkhscale.h>
|
||||||
#include <gtk/deprecated/gtkhscrollbar.h>
|
#include <gtk/deprecated/gtkhscrollbar.h>
|
||||||
#include <gtk/deprecated/gtkhseparator.h>
|
#include <gtk/deprecated/gtkhseparator.h>
|
||||||
|
@ -24,9 +24,9 @@
|
|||||||
#include "gtkcolorchooserwidget.h"
|
#include "gtkcolorchooserwidget.h"
|
||||||
#include "gtkcoloreditor.h"
|
#include "gtkcoloreditor.h"
|
||||||
#include "gtkcolorswatch.h"
|
#include "gtkcolorswatch.h"
|
||||||
|
#include "gtkcolorutils.h"
|
||||||
#include "gtkbox.h"
|
#include "gtkbox.h"
|
||||||
#include "gtkgrid.h"
|
#include "gtkgrid.h"
|
||||||
#include "gtkhsv.h"
|
|
||||||
#include "gtklabel.h"
|
#include "gtklabel.h"
|
||||||
#include "gtkorientable.h"
|
#include "gtkorientable.h"
|
||||||
#include "gtkprivate.h"
|
#include "gtkprivate.h"
|
||||||
|
@ -35,13 +35,13 @@
|
|||||||
#include "gtkcolorplane.h"
|
#include "gtkcolorplane.h"
|
||||||
#include "gtkcolorscale.h"
|
#include "gtkcolorscale.h"
|
||||||
#include "gtkcolorswatch.h"
|
#include "gtkcolorswatch.h"
|
||||||
|
#include "gtkcolorutils.h"
|
||||||
#include "gtkgrid.h"
|
#include "gtkgrid.h"
|
||||||
#include "gtkorientable.h"
|
#include "gtkorientable.h"
|
||||||
#include "gtkaspectframe.h"
|
#include "gtkaspectframe.h"
|
||||||
#include "gtkdrawingarea.h"
|
#include "gtkdrawingarea.h"
|
||||||
#include "gtkentry.h"
|
#include "gtkentry.h"
|
||||||
#include "gtkoverlay.h"
|
#include "gtkoverlay.h"
|
||||||
#include "gtkhsv.h"
|
|
||||||
#include "gtkadjustment.h"
|
#include "gtkadjustment.h"
|
||||||
#include "gtklabel.h"
|
#include "gtklabel.h"
|
||||||
#include "gtkspinbutton.h"
|
#include "gtkspinbutton.h"
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "gtkhsv.h"
|
|
||||||
#include "gtkcolorplane.h"
|
#include "gtkcolorplane.h"
|
||||||
|
#include "gtkcolorutils.h"
|
||||||
#include "gtkcontainer.h"
|
#include "gtkcontainer.h"
|
||||||
#include "gtkaccessible.h"
|
#include "gtkaccessible.h"
|
||||||
#include "gtkwindow.h"
|
#include "gtkwindow.h"
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "gtkcolorscale.h"
|
#include "gtkcolorscale.h"
|
||||||
#include "gtkhsv.h"
|
#include "gtkcolorutils.h"
|
||||||
#include "gtkorientable.h"
|
#include "gtkorientable.h"
|
||||||
#include "gtkstylecontext.h"
|
#include "gtkstylecontext.h"
|
||||||
#include "gtkaccessible.h"
|
#include "gtkaccessible.h"
|
||||||
|
260
gtk/gtkcolorutils.c
Normal file
260
gtk/gtkcolorutils.c
Normal file
@ -0,0 +1,260 @@
|
|||||||
|
/* Color utilities
|
||||||
|
*
|
||||||
|
* Copyright (C) 1999 The Free Software Foundation
|
||||||
|
*
|
||||||
|
* Authors: Simon Budig <Simon.Budig@unix-ag.org> (original code)
|
||||||
|
* Federico Mena-Quintero <federico@gimp.org> (cleanup for GTK+)
|
||||||
|
* Jonathan Blandford <jrb@redhat.com> (cleanup for GTK+)
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Lesser 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
||||||
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||||
|
* files for a list of changes. These files are distributed with
|
||||||
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "gtkcolorutils.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define INTENSITY(r, g, b) ((r) * 0.30 + (g) * 0.59 + (b) * 0.11)
|
||||||
|
|
||||||
|
/* Converts from HSV to RGB */
|
||||||
|
static void
|
||||||
|
hsv_to_rgb (gdouble *h,
|
||||||
|
gdouble *s,
|
||||||
|
gdouble *v)
|
||||||
|
{
|
||||||
|
gdouble hue, saturation, value;
|
||||||
|
gdouble f, p, q, t;
|
||||||
|
|
||||||
|
if (*s == 0.0)
|
||||||
|
{
|
||||||
|
*h = *v;
|
||||||
|
*s = *v;
|
||||||
|
*v = *v; /* heh */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hue = *h * 6.0;
|
||||||
|
saturation = *s;
|
||||||
|
value = *v;
|
||||||
|
|
||||||
|
if (hue == 6.0)
|
||||||
|
hue = 0.0;
|
||||||
|
|
||||||
|
f = hue - (int) hue;
|
||||||
|
p = value * (1.0 - saturation);
|
||||||
|
q = value * (1.0 - saturation * f);
|
||||||
|
t = value * (1.0 - saturation * (1.0 - f));
|
||||||
|
|
||||||
|
switch ((int) hue)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
*h = value;
|
||||||
|
*s = t;
|
||||||
|
*v = p;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
*h = q;
|
||||||
|
*s = value;
|
||||||
|
*v = p;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
*h = p;
|
||||||
|
*s = value;
|
||||||
|
*v = t;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
*h = p;
|
||||||
|
*s = q;
|
||||||
|
*v = value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
*h = t;
|
||||||
|
*s = p;
|
||||||
|
*v = value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
*h = value;
|
||||||
|
*s = p;
|
||||||
|
*v = q;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Converts from RGB to HSV */
|
||||||
|
static void
|
||||||
|
rgb_to_hsv (gdouble *r,
|
||||||
|
gdouble *g,
|
||||||
|
gdouble *b)
|
||||||
|
{
|
||||||
|
gdouble red, green, blue;
|
||||||
|
gdouble h, s, v;
|
||||||
|
gdouble min, max;
|
||||||
|
gdouble delta;
|
||||||
|
|
||||||
|
red = *r;
|
||||||
|
green = *g;
|
||||||
|
blue = *b;
|
||||||
|
|
||||||
|
h = 0.0;
|
||||||
|
|
||||||
|
if (red > green)
|
||||||
|
{
|
||||||
|
if (red > blue)
|
||||||
|
max = red;
|
||||||
|
else
|
||||||
|
max = blue;
|
||||||
|
|
||||||
|
if (green < blue)
|
||||||
|
min = green;
|
||||||
|
else
|
||||||
|
min = blue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (green > blue)
|
||||||
|
max = green;
|
||||||
|
else
|
||||||
|
max = blue;
|
||||||
|
|
||||||
|
if (red < blue)
|
||||||
|
min = red;
|
||||||
|
else
|
||||||
|
min = blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
v = max;
|
||||||
|
|
||||||
|
if (max != 0.0)
|
||||||
|
s = (max - min) / max;
|
||||||
|
else
|
||||||
|
s = 0.0;
|
||||||
|
|
||||||
|
if (s == 0.0)
|
||||||
|
h = 0.0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delta = max - min;
|
||||||
|
|
||||||
|
if (red == max)
|
||||||
|
h = (green - blue) / delta;
|
||||||
|
else if (green == max)
|
||||||
|
h = 2 + (blue - red) / delta;
|
||||||
|
else if (blue == max)
|
||||||
|
h = 4 + (red - green) / delta;
|
||||||
|
|
||||||
|
h /= 6.0;
|
||||||
|
|
||||||
|
if (h < 0.0)
|
||||||
|
h += 1.0;
|
||||||
|
else if (h > 1.0)
|
||||||
|
h -= 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
*r = h;
|
||||||
|
*g = s;
|
||||||
|
*b = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_hsv_to_rgb:
|
||||||
|
* @h: Hue
|
||||||
|
* @s: Saturation
|
||||||
|
* @v: Value
|
||||||
|
* @r: (out): Return value for the red component
|
||||||
|
* @g: (out): Return value for the green component
|
||||||
|
* @b: (out): Return value for the blue component
|
||||||
|
*
|
||||||
|
* Converts a color from HSV space to RGB.
|
||||||
|
*
|
||||||
|
* Input values must be in the [0.0, 1.0] range;
|
||||||
|
* output values will be in the same range.
|
||||||
|
*
|
||||||
|
* Since: 2.14
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gtk_hsv_to_rgb (gdouble h, gdouble s, gdouble v,
|
||||||
|
gdouble *r, gdouble *g, gdouble *b)
|
||||||
|
{
|
||||||
|
g_return_if_fail (h >= 0.0 && h <= 1.0);
|
||||||
|
g_return_if_fail (s >= 0.0 && s <= 1.0);
|
||||||
|
g_return_if_fail (v >= 0.0 && v <= 1.0);
|
||||||
|
|
||||||
|
hsv_to_rgb (&h, &s, &v);
|
||||||
|
|
||||||
|
if (r)
|
||||||
|
*r = h;
|
||||||
|
|
||||||
|
if (g)
|
||||||
|
*g = s;
|
||||||
|
|
||||||
|
if (b)
|
||||||
|
*b = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_rgb_to_hsv:
|
||||||
|
* @r: Red
|
||||||
|
* @g: Green
|
||||||
|
* @b: Blue
|
||||||
|
* @h: (out): Return value for the hue component
|
||||||
|
* @s: (out): Return value for the saturation component
|
||||||
|
* @v: (out): Return value for the value component
|
||||||
|
*
|
||||||
|
* Converts a color from RGB space to HSV.
|
||||||
|
*
|
||||||
|
* Input values must be in the [0.0, 1.0] range;
|
||||||
|
* output values will be in the same range.
|
||||||
|
*
|
||||||
|
* Since: 2.14
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gtk_rgb_to_hsv (gdouble r, gdouble g, gdouble b,
|
||||||
|
gdouble *h, gdouble *s, gdouble *v)
|
||||||
|
{
|
||||||
|
g_return_if_fail (r >= 0.0 && r <= 1.0);
|
||||||
|
g_return_if_fail (g >= 0.0 && g <= 1.0);
|
||||||
|
g_return_if_fail (b >= 0.0 && b <= 1.0);
|
||||||
|
|
||||||
|
rgb_to_hsv (&r, &g, &b);
|
||||||
|
|
||||||
|
if (h)
|
||||||
|
*h = r;
|
||||||
|
|
||||||
|
if (s)
|
||||||
|
*s = g;
|
||||||
|
|
||||||
|
if (v)
|
||||||
|
*v = b;
|
||||||
|
}
|
48
gtk/gtkcolorutils.h
Normal file
48
gtk/gtkcolorutils.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/* Color utilties
|
||||||
|
*
|
||||||
|
* Copyright (C) 1999 The Free Software Foundation
|
||||||
|
*
|
||||||
|
* Authors: Simon Budig <Simon.Budig@unix-ag.org> (original code)
|
||||||
|
* Federico Mena-Quintero <federico@gimp.org> (cleanup for GTK+)
|
||||||
|
* Jonathan Blandford <jrb@redhat.com> (cleanup for GTK+)
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Lesser 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
||||||
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||||
|
* files for a list of changes. These files are distributed with
|
||||||
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||||
|
#error "Only <gtk/gtk.h> can be included directly."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __GTK_COLOR_UTILS_H__
|
||||||
|
#define __GTK_COLOR_UTILS_H__
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
void gtk_hsv_to_rgb (gdouble h, gdouble s, gdouble v,
|
||||||
|
gdouble *r, gdouble *g, gdouble *b);
|
||||||
|
void gtk_rgb_to_hsv (gdouble r, gdouble g, gdouble b,
|
||||||
|
gdouble *h, gdouble *s, gdouble *v);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GTK_COLOR_UTILS_H__ */
|
Loading…
Reference in New Issue
Block a user