5 Module N_GUI_COLORWHEEL
gullradriel edited this page 2026-10-09 00:55:18 +02:00

GUI COLORWHEEL: a colour wheel widget

Types

Name
typedef ALLEGRO_COLOR(*)(float u, float v, void *user_data) N_GUI_COLORWHEEL_COLOUR
The colour the disc shows for a point.
typedef void(*)(int widget_id, int dragging, void *user_data) N_GUI_COLORWHEEL_CHANGE
Called when the point moves.

Functions

Name
void n_gui_colorwheel_set_colour(N_GUI_CTX * ctx, int widget_id, N_GUI_COLORWHEEL_COLOUR colour, void * user_data)
Paint the disc with the caller's colours.
int n_gui_colorwheel_set(N_GUI_CTX * ctx, int widget_id, float u, float v)
Set the point.
int n_gui_colorwheel_new(N_GUI_CTX * ctx, int window_id, float x, float y, float w, float h, N_GUI_COLORWHEEL_CHANGE on_change, void * user_data)
Add a colour wheel, its point in the centre.
ALLEGRO_COLOR n_gui_colorwheel_hue(float u, float v, void * user_data)
The default disc colour: HSV, hue by angle with red to the right and going counter clockwise, saturation by distance from the centre, value one.
int n_gui_colorwheel_get(N_GUI_CTX * ctx, int widget_id, float * u, float * v)
Read the point.

Types Documentation

typedef N_GUI_COLORWHEEL_COLOUR

typedef ALLEGRO_COLOR(* N_GUI_COLORWHEEL_COLOUR) (float u, float v, void *user_data);

The colour the disc shows for a point.

Parameters:

Return: the colour

typedef N_GUI_COLORWHEEL_CHANGE

typedef void(* N_GUI_COLORWHEEL_CHANGE) (int widget_id, int dragging, void *user_data);

Called when the point moves.

Parameters:

  • widget_id the wheel
  • dragging non-zero while the button is still held
  • user_data the pointer given to n_gui_colorwheel_new()

Functions Documentation

function n_gui_colorwheel_set_colour

void n_gui_colorwheel_set_colour(
    N_GUI_CTX * ctx,
    int widget_id,
    N_GUI_COLORWHEEL_COLOUR colour,
    void * user_data
)

Paint the disc with the caller's colours.

Parameters:

  • ctx the GUI
  • widget_id the wheel
  • colour the colour for a point, NULL for the default hue circle
  • user_data handed back to colour

function n_gui_colorwheel_set

int n_gui_colorwheel_set(
    N_GUI_CTX * ctx,
    int widget_id,
    float u,
    float v
)

Set the point.

Parameters:

  • ctx the GUI
  • widget_id the wheel
  • u across, -1 to 1
  • v up, -1 to 1

Return: TRUE, or FALSE for a widget that is not a wheel or while dragging

Kept inside the unit circle; ignored while it is being dragged.

function n_gui_colorwheel_new

int n_gui_colorwheel_new(
    N_GUI_CTX * ctx,
    int window_id,
    float x,
    float y,
    float w,
    float h,
    N_GUI_COLORWHEEL_CHANGE on_change,
    void * user_data
)

Add a colour wheel, its point in the centre.

Parameters:

  • ctx the GUI
  • window_id the window
  • x left, in the window
  • y top, in the window
  • w width; the disc is the largest circle that fits
  • h height
  • on_change called on every change, may be NULL
  • user_data handed back to on_change

Return: the widget id, or -1

function n_gui_colorwheel_hue

ALLEGRO_COLOR n_gui_colorwheel_hue(
    float u,
    float v,
    void * user_data
)

The default disc colour: HSV, hue by angle with red to the right and going counter clockwise, saturation by distance from the centre, value one.

Parameters:

  • u across, -1 to 1
  • v up, -1 to 1
  • user_data unused

Return: the colour

function n_gui_colorwheel_get

int n_gui_colorwheel_get(
    N_GUI_CTX * ctx,
    int widget_id,
    float * u,
    float * v
)

Read the point.

Parameters:

  • ctx the GUI
  • widget_id the wheel
  • u receives across, may be NULL
  • v receives up, may be NULL

Return: TRUE, or FALSE for a widget that is not a wheel