![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
A colour wheel for N_GUI: one point in a disc, dragged. More...
#include "nilorea/n_gui.h"Go to the source code of this file.
Typedefs | |
| typedef void(* | N_GUI_COLORWHEEL_CHANGE) (int widget_id, int dragging, void *user_data) |
| Called when the point moves. | |
| typedef ALLEGRO_COLOR(* | N_GUI_COLORWHEEL_COLOUR) (float u, float v, void *user_data) |
| The colour the disc shows for a point. | |
Functions | |
| int | n_gui_colorwheel_get (N_GUI_CTX *ctx, int widget_id, float *u, float *v) |
| Read the point. | |
| 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_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. | |
| int | n_gui_colorwheel_set (N_GUI_CTX *ctx, int widget_id, float u, float v) |
| Set the point. | |
| 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. | |
A colour wheel for N_GUI: one point in a disc, dragged.
A disc whose point, u across and v up, both -1 to 1 and never outside the unit circle, is set by pressing and dragging with the left button; a right press or a double click puts it back in the centre, the double click timed as the context times it (n_gui_set_double_click_time()). What the point means is the caller's: a hue and a strength, a shift on two colour axes, a direction. So is what the disc shows: n_gui_colorwheel_set_colour() paints each place of it with the caller's colour for that point, so the wheel shows what choosing it does. By default the disc is an HSV hue circle, saturated at the rim and grey in the centre.
The widget is a custom one (n_gui_add_custom() with n_gui_custom_set_mouse()), so it lives in any window and its state is freed with it. on_change is called on every change, with dragging set while the button is held.
Definition in file n_gui_colorwheel.h.