gtk_colorComboBoxWidget

gtk_colorComboBoxWidget — Defines a specialised GtkComboBox to choose stored colours.

Synopsis

#include <coreTools/toolColor.h>

                    VisuUiColorCombobox;
                    VisuUiColorComboboxClass;
GdkPixbuf *         visu_ui_color_combobox_getPixbufFromColor
                                                        (VisuUiColorCombobox *colorComboBox,
                                                         ToolColor *color);
float *             visu_ui_color_combobox_getRangeColor
                                                        (VisuUiColorCombobox *colorComboBox);
float *             visu_ui_color_combobox_getRangeMaterial
                                                        (VisuUiColorCombobox *colorComboBox);
GtkWidget *         visu_ui_color_combobox_getRangeWidgets
                                                        (VisuUiColorCombobox *colorComboBox);
ToolColor *         visu_ui_color_combobox_getSelection (VisuUiColorCombobox *colorComboBox);
GtkWidget *         visu_ui_color_combobox_new          (gboolean hasAlphaChannel);
GtkWidget *         visu_ui_color_combobox_newWithRanges
                                                        (gboolean hasAlphaChannel);
void                visu_ui_color_combobox_setExpanded  (VisuUiColorCombobox *colorComboBox,
                                                         gboolean value);
void                visu_ui_color_combobox_setPrintValues
                                                        (VisuUiColorCombobox *colorComboBox,
                                                         gboolean value);
void                visu_ui_color_combobox_setRangeColor
                                                        (VisuUiColorCombobox *colorComboBox,
                                                         float rgba[4],
                                                         gboolean raiseSignal);
void                visu_ui_color_combobox_setRangeMaterial
                                                        (VisuUiColorCombobox *colorComboBox,
                                                         float material[VISU_GL_LIGHT_MATERIAL_N_VALUES],
                                                         gboolean raiseSignal);
gboolean            visu_ui_color_combobox_setSelection (VisuUiColorCombobox *colorComboBox,
                                                         ToolColor *color);

Object Hierarchy

  GObject
   +----GInitiallyUnowned
         +----GtkWidget
               +----GtkContainer
                     +----GtkBin
                           +----GtkComboBox
                                 +----VisuUiColorCombobox

Implemented Interfaces

VisuUiColorCombobox implements AtkImplementorIface, GtkBuildable, GtkCellLayout and GtkCellEditable.

Signals

  "color-selected"                                 : Action
  "color-value-changed"                            : Action
  "material-value-changed"                         : Action

Description

This widget looks like a GtkComboBox and it displays a list of stored colours. These colours may come from the configuration files or can be selected and stored by the user actions. To do it, the first entry of the combo box is 'new / modify', that opens a GTK colour picker. The new values are used to craete a new colour entry in the combo box. In a complete version, the combo box can have a GtkVBox associated to modify colours without creating new entries, see visu_ui_color_combobox_newWithRanges() method. Otherwise, only already selected colours are available. The stored colours are shared by all widgets of this class. It is thus a convenient way to have coherent colour picker through V_Sim.

When the widget is created with ranges, the additional part can be retrieve with visu_ui_color_combobox_getRangeWidgets() and attached whereever is convenient. When the ranges are modified, the new colour is not added to the combo box. It can be read using visu_ui_color_combobox_getRangeColor() or visu_ui_color_combobox_getRangeMaterial(). The combo box is set thus to an unselected state and visu_ui_color_combobox_getSelection() will return a NULL pointer. Besides the colour ranges, there is an add button to insert the newly defined colour into the combo box.

This widget can emit a "color-selected" signal that is a wrapper around the "changed" signal, but it is emitted only when a new colour is selected (either an existing one or a newly created from the picker). This colour is passed to the callback. The two other signals, "color-value-changed" and "material-value-changed", are generated when the widget have been created with ranges and that one of these ranges is modified.

Details

VisuUiColorCombobox

typedef struct _VisuUiColorCombobox VisuUiColorCombobox;

Private structure to store informations of a VisuUiColorCombobox object.

Since 3.1


VisuUiColorComboboxClass

typedef struct _VisuUiColorComboboxClass VisuUiColorComboboxClass;

Private structure to store informations of a VisuUiColorComboboxClass object.

Since 3.1


visu_ui_color_combobox_getPixbufFromColor ()

GdkPixbuf *         visu_ui_color_combobox_getPixbufFromColor
                                                        (VisuUiColorCombobox *colorComboBox,
                                                         ToolColor *color);

The colorComboBox has little pixbufs to represent the color. User methods can use these pixbufs but should considered them read-only.

colorComboBox :

a VisuUiColorCombobox widget ;

color :

a ToolColor object.

Returns :

a pixbuf pointer corresponding to the little image shown on the colorComboBox. [transfer none]

Since 3.1


visu_ui_color_combobox_getRangeColor ()

float *             visu_ui_color_combobox_getRangeColor
                                                        (VisuUiColorCombobox *colorComboBox);

If the colorComboBox uses ranges (see visu_ui_color_combobox_newWithRanges()), this method is used to get the values from the color ranges.

colorComboBox :

a VisuUiColorCombobox widget.

Returns :

a newly created array of size 4. Use g_free() to delete it. [array fixed-size=4][transfer full]

Since 3.2


visu_ui_color_combobox_getRangeMaterial ()

float *             visu_ui_color_combobox_getRangeMaterial
                                                        (VisuUiColorCombobox *colorComboBox);

If the colorComboBox uses ranges (see visu_ui_color_combobox_newWithRanges()), this method is used to get the values from the material ranges.

colorComboBox :

a VisuUiColorCombobox widget.

Returns :

a newly created array of size VISU_GL_LIGHT_MATERIAL_N_VALUES (see VisuGlLightMaterial). Use g_free() to delete it. [array fixed-size=5][transfer full]

Since 3.3


visu_ui_color_combobox_getRangeWidgets ()

GtkWidget *         visu_ui_color_combobox_getRangeWidgets
                                                        (VisuUiColorCombobox *colorComboBox);

Retrieve the wiodget using to represent the ranges, or NULL if the object has no ranges.

colorComboBox :

a ToolColor object.

Returns :

a widget owned by color. [transfer none]

Since 3.3


visu_ui_color_combobox_getSelection ()

ToolColor *         visu_ui_color_combobox_getSelection (VisuUiColorCombobox *colorComboBox);

The user can access to the selected ToolColor object using this method.

colorComboBox :

a VisuUiColorCombobox widget.

Returns :

a pointer to the selected ToolColor object (or NULL). This object is read-only. [transfer none]

Since 3.1


visu_ui_color_combobox_new ()

GtkWidget *         visu_ui_color_combobox_new          (gboolean hasAlphaChannel);

A VisuUiColorCombobox widget is like a GtkComboBox widget, but it is already filled with the colors stores in the structures adhoc in visu_tools.h. Using this widget is a convienient way to share colors between all part of V_Sim and to give a consistent look of all color selection. If the argument hasAlphaChannel is FALSE, the widget display all colors but without their alpha channel, assuming it to be fully opaque.

hasAlphaChannel :

a boolean.

Returns :

a newly created VisuUiColorCombobox widget. [transfer full]

Since 3.1


visu_ui_color_combobox_newWithRanges ()

GtkWidget *         visu_ui_color_combobox_newWithRanges
                                                        (gboolean hasAlphaChannel);

Create a color combo and several ranges.

hasAlphaChannel :

a boolean.

Returns :

a newly created VisuUiColorCombobox widget. [transfer full]

Since 3.3


visu_ui_color_combobox_setExpanded ()

void                visu_ui_color_combobox_setExpanded  (VisuUiColorCombobox *colorComboBox,
                                                         gboolean value);

Set the expanded state of the ranges. This is usable only if the colorComboBox has been created with ranges.

colorComboBox :

a ToolColor object ;

value :

a boolean value.

Since 3.3


visu_ui_color_combobox_setPrintValues ()

void                visu_ui_color_combobox_setPrintValues
                                                        (VisuUiColorCombobox *colorComboBox,
                                                         gboolean value);

Print or not the RGB values.

colorComboBox :

a ToolColor object ;

value :

a boolean.

Since 3.4


visu_ui_color_combobox_setRangeColor ()

void                visu_ui_color_combobox_setRangeColor
                                                        (VisuUiColorCombobox *colorComboBox,
                                                         float rgba[4],
                                                         gboolean raiseSignal);

Change the values for the ranges that control the color. If the color exists in the list, it is also selected. This is possible only if the colorComboBox has been created with visu_ui_color_combobox_newWithRanges().

colorComboBox :

a VisuUiColorCombobox widget ;

rgba :

4 floating point values ;

raiseSignal :

if TRUE a material-value-changed can be raised.

Since 3.3


visu_ui_color_combobox_setRangeMaterial ()

void                visu_ui_color_combobox_setRangeMaterial
                                                        (VisuUiColorCombobox *colorComboBox,
                                                         float material[VISU_GL_LIGHT_MATERIAL_N_VALUES],
                                                         gboolean raiseSignal);

Change the values for the ranges that control the light (emission, diffuse...). This is possible only if the colorComboBox has been created with visu_ui_color_combobox_newWithRanges().

colorComboBox :

a VisuUiColorCombobox widget ;

material :

VISU_GL_LIGHT_MATERIAL_N_VALUES (see VisuGlLightMaterial) floating point values ;

raiseSignal :

if TRUE a material-value-changed can be raised.

Since 3.3


visu_ui_color_combobox_setSelection ()

gboolean            visu_ui_color_combobox_setSelection (VisuUiColorCombobox *colorComboBox,
                                                         ToolColor *color);

Use this method to set the ComboBox on the given color. This emits a 'color-channel' signal if the color is changed, which means, a previous color has been modified, or a new color is selected.

colorComboBox :

a VisuUiColorCombobox widget ;

color :

a ToolColor object.

Returns :

TRUE if the color already exists in the model.

Since 3.1

Signal Details

The "color-selected" signal

void                user_function                      (VisuUiColorCombobox *combo,
                                                        gpointer             color,
                                                        gpointer             user_data)      : Action

This signal is emitted when a new valid colour is selected, either an existing one or newly created one.

combo :

the VisuUiColorCombobox that emits the signal ;

color :

the newly selected ToolColor.

user_data :

user data set when the signal handler was connected.

Since 3.1


The "color-value-changed" signal

void                user_function                      (VisuUiColorCombobox *combo,
                                                        guint                RGBA,
                                                        gpointer             user_data)      : Action

This signal is emitted when the range of a colour is modified.

combo :

the VisuUiColorCombobox that emits the signal ;

RGBA :

the modified channel.

user_data :

user data set when the signal handler was connected.

Since 3.3


The "material-value-changed" signal

void                user_function                      (VisuUiColorCombobox *combo,
                                                        guint                mat,
                                                        gpointer             user_data)      : Action

This signal is emitted when the range of a material is modified.

combo :

the VisuUiColorCombobox that emits the signal ;

mat :

the modified material channel (see VisuGlLightMaterial).

user_data :

user data set when the signal handler was connected.

Since 3.3

See Also

ToolColor, VisuUiStippleCombobox, VisuUiShadeCombobox