Etk
Main Page Object Hierarchy Data Structures Related Pages
Etk

Etk_Colorpicker


Detailed Description

The colorpicker is a widget that allows the user to select a color.

colorpicker.png
A colorpicker can work in 6 different modes, H (Hue), S (saturation), V (value), R (red), G (green) and B (blue). The default mode is H, but you can change it with etk_colorpicker_mode_set(). For each of these modes, there is a slider that allows the user to change the corresponding value.
Optionally, the colorpicker can also have a slider to control the alpha channel of the color, corresponding to how much the color is transparent. This slider is hidden by default, but can be shown with etk_colorpicker_use_alpha_set().
Most of the time, all you want to do is getting the selected color, and be notified when the selected color is changed. This can be done with etk_colorpicker_current_color_get() and by connecting a callback to the "color-changed" signal.

Object Hierarchy:
  • Etk_Object
    • Etk_Widget
      • Etk_Colorpicker
Signals:
  • "color-changed": Emitted when the selected color is changed
    • Callback: Etk_Bool callback(Etk_Colorpicker *colorpicker, void *data)
      • button: the colorpicker whose color has been changed
      • data: the user data set when the callback has been connected to the signal
Properties:
  • "color-mode": The current color-mode of the colorpicker
    • Type: Integer (Etk_Colorpicker_Mode)
    • Access: Read/Write
    • Default Value: ETK_COLORPICKER_H
  • "use-alpha": Whether or not the alpha slider is visible
    • Type: Boolean
    • Access: Read/Write
    • Default Value: ETK_FALSE


Data Structures

struct  Etk_Colorpicker
 [Widget] A widget that allows the user to select a color More...

Defines

#define ETK_COLORPICKER_TYPE   (etk_colorpicker_type_get())
#define ETK_COLORPICKER(obj)   (ETK_OBJECT_CAST((obj), ETK_COLORPICKER_TYPE, Etk_Colorpicker))
#define ETK_IS_COLORPICKER(obj)   (ETK_OBJECT_CHECK_TYPE((obj), ETK_COLORPICKER_TYPE))

Enumerations

enum  Etk_Colorpicker_Mode {
  ETK_COLORPICKER_H,
  ETK_COLORPICKER_S,
  ETK_COLORPICKER_V,
  ETK_COLORPICKER_R,
  ETK_COLORPICKER_G,
  ETK_COLORPICKER_B
}
 The different color modes that can be used by the colorpicker. More...

Functions

Etk_Widget * etk_colorpicker_new (void)
 Creates a new colorpicker.
void etk_colorpicker_mode_set (Etk_Colorpicker *cp, Etk_Colorpicker_Mode mode)
 Sets the current color mode of the colorpicker.
Etk_Colorpicker_Mode etk_colorpicker_mode_get (Etk_Colorpicker *cp)
 Gets the current color mode of the colorpicker.
void etk_colorpicker_current_color_set (Etk_Colorpicker *cp, Etk_Color color)
 Sets the color currently selected by the colorpicker.
Etk_Color etk_colorpicker_current_color_get (Etk_Colorpicker *cp)
 Gets the color currently selected by the colorpicker.
void etk_colorpicker_use_alpha_set (Etk_Colorpicker *cp, Etk_Bool use_alpha)
 Sets whether or not the colorpicker has a slider that allows the user to choose the alpha component of the color.
Etk_Bool etk_colorpicker_use_alpha_get (Etk_Colorpicker *cp)
 Gets whether the colorpicker has an alpha slider.


Define Documentation

#define ETK_COLORPICKER_TYPE   (etk_colorpicker_type_get())

Gets the type of a colorpicker

Referenced by etk_colorpicker_new().

#define ETK_COLORPICKER ( obj   )     (ETK_OBJECT_CAST((obj), ETK_COLORPICKER_TYPE, Etk_Colorpicker))

Casts the object to a colorpicker

#define ETK_IS_COLORPICKER ( obj   )     (ETK_OBJECT_CHECK_TYPE((obj), ETK_COLORPICKER_TYPE))

Check if the object is an Etk_Colorpicker


Enumeration Type Documentation

enum Etk_Colorpicker_Mode

The different color modes that can be used by the colorpicker.

Enumerator:
ETK_COLORPICKER_H  The "Hue" mode
ETK_COLORPICKER_S  The "Saturation" mode
ETK_COLORPICKER_V  The "Value" mode
ETK_COLORPICKER_R  The "Red" mode
ETK_COLORPICKER_G  The "Green" mode
ETK_COLORPICKER_B  The "Blue" mode


Function Documentation

Etk_Widget * etk_colorpicker_new ( void   ) 

Creates a new colorpicker.

Returns:
Returns the new colorpicker

References ETK_COLORPICKER_TYPE, and etk_widget_new().

void etk_colorpicker_mode_set ( Etk_Colorpicker *  cp,
Etk_Colorpicker_Mode  mode 
)

Sets the current color mode of the colorpicker.

Parameters:
cp a colorpicker
mode the color mode to use

References ETK_COLORPICKER_B, ETK_COLORPICKER_G, ETK_COLORPICKER_H, ETK_COLORPICKER_R, ETK_COLORPICKER_S, ETK_COLORPICKER_V, ETK_OBJECT, etk_object_notify(), mode, sp_xcomponent, and sp_ycomponent.

Etk_Colorpicker_Mode etk_colorpicker_mode_get ( Etk_Colorpicker *  cp  ) 

Gets the current color mode of the colorpicker.

Parameters:
cp a colorpicker
Returns:
Returns the current color mode of the colorpicker

References ETK_COLORPICKER_H, and mode.

void etk_colorpicker_current_color_set ( Etk_Colorpicker *  cp,
Etk_Color  color 
)

Sets the color currently selected by the colorpicker.

Parameters:
cp a colorpicker
color the color to set

References Etk_Color::a, alpha_slider, Etk_Color::b, current_color, ETK_COLORPICKER_B, ETK_COLORPICKER_G, ETK_COLORPICKER_R, ETK_OBJECT, ETK_RANGE, etk_range_value_set(), etk_signal_emit(), Etk_Color::g, ignore_value_changed, Etk_Color::r, and sliders.

Etk_Color etk_colorpicker_current_color_get ( Etk_Colorpicker *  cp  ) 

Gets the color currently selected by the colorpicker.

Parameters:
cp a colorpicker
Returns:
Returns the color selected by the colorpicker

References current_color, and Etk_Color::r.

void etk_colorpicker_use_alpha_set ( Etk_Colorpicker *  cp,
Etk_Bool  use_alpha 
)

Sets whether or not the colorpicker has a slider that allows the user to choose the alpha component of the color.

Parameters:
cp a colorpicher
use_alpha ETK_TRUE to make the colorpicker have an alpha slider, ETK_FALSE otherwise

References Etk_Color::a, alpha_label, alpha_slider, current_color, ETK_OBJECT, etk_object_notify(), ETK_RANGE, etk_range_value_set(), etk_widget_hide(), etk_widget_show(), and use_alpha.

Etk_Bool etk_colorpicker_use_alpha_get ( Etk_Colorpicker *  cp  ) 

Gets whether the colorpicker has an alpha slider.

Parameters:
cp a colorpicher
Returns:
Returns ETK_TRUE if the colorpicker has an alpha slider, ETK_FALSE otherwise

References use_alpha.