Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
ex_gui_colorwheel.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <allegro5/allegro_primitives.h>
#include "nilorea/n_common.h"
#include "nilorea/n_log.h"
#include "nilorea/n_gui.h"
#include "nilorea/n_gui_colorwheel.h"
Include dependency graph for ex_gui_colorwheel.c:

Go to the source code of this file.

Macros

#define ALLEGRO_UNSTABLE   1
#define AT_X(u)
 the wheel sits at 50,50 and is 200 by 200, its disc of radius 98 centred at 150,150: display position of a wheel coordinate
#define AT_Y(v)
 as AT_X, for v, which goes up

Functions

static void drag (N_GUI_CTX *gui, float fu, float fv, float tu, float tv)
 press at one point, drag to another, release
static void expect_true (const char *what, int ok)
 count a failed check
static void feed (N_GUI_CTX *gui, int type, int x, int y, int button)
 feed one mouse event at display coordinates
static ALLEGRO_COLOR grey (float u, float v, void *user_data)
 a caller's colour: grey everywhere
int main (int argc, char **argv)
 run the checks
static int near (float a, float b)
 is a near b
static void on_change (int widget_id, int dragging, void *user_data)
 change callback
static int process_args (int argc, char **argv)
 read -V

Variables

static int changes = 0
 changes seen, and those while dragging
static int colour_asked = 0
 set when the caller's colour was asked for
static int drag_changes = 0
static int failures = 0
 failed checks
static int log_level = 3
 log level from -V

Macro Definition Documentation

◆ ALLEGRO_UNSTABLE

#define ALLEGRO_UNSTABLE   1

Definition at line 29 of file ex_gui_colorwheel.c.

◆ AT_X

#define AT_X ( u)
Value:
((int)(150.0f + (u) * 98.0f + 0.5f))

the wheel sits at 50,50 and is 200 by 200, its disc of radius 98 centred at 150,150: display position of a wheel coordinate

Examples
ex_gui_colorwheel.c, and ex_gui_curve.c.

Definition at line 125 of file ex_gui_colorwheel.c.

Referenced by drag(), drag(), main(), and right().

◆ AT_Y

#define AT_Y ( v)
Value:
((int)(150.0f - (v) * 98.0f + 0.5f))

as AT_X, for v, which goes up

Examples
ex_gui_colorwheel.c, and ex_gui_curve.c.

Definition at line 127 of file ex_gui_colorwheel.c.

Referenced by drag(), drag(), main(), and right().

Function Documentation

◆ drag()

void drag ( N_GUI_CTX * gui,
float fu,
float fv,
float tu,
float tv )
static

press at one point, drag to another, release

Parameters
guithe GUI
fufrom, across
fvfrom, up
tuto, across
tvto, up
Examples
ex_gui_colorwheel.c, and ex_gui_curve.c.

Definition at line 135 of file ex_gui_colorwheel.c.

References AT_X, AT_Y, feed(), and gui.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ expect_true()

void expect_true ( const char * what,
int ok )
static

count a failed check

Parameters
whatthe check
okits result

Definition at line 55 of file ex_gui_colorwheel.c.

References failures, LOG_ERR, LOG_INFO, and n_log.

◆ feed()

void feed ( N_GUI_CTX * gui,
int type,
int x,
int y,
int button )
static

feed one mouse event at display coordinates

Parameters
guithe GUI
typethe Allegro event type
xdisplay x
ydisplay y
buttonthe button
Examples
ex_gui_colorwheel.c, ex_gui_curve.c, ex_gui_custom_mouse.c, ex_gui_grid.c, and ex_gui_popup.c.

Definition at line 111 of file ex_gui_colorwheel.c.

References gui, n_gui_process_event(), and type().

Referenced by drag(), drag(), main(), and right().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ grey()

ALLEGRO_COLOR grey ( float u,
float v,
void * user_data )
static

a caller's colour: grey everywhere

Parameters
uacross
vup
user_dataunused
Returns
grey
Examples
ex_gui_colorwheel.c.

Definition at line 97 of file ex_gui_colorwheel.c.

References colour_asked.

Referenced by main(), and n_gui_draw_color_swatch().

Here is the caller graph for this function:

◆ main()

◆ near()

int near ( float a,
float b )
static

is a near b

Parameters
aone
bthe other
Returns
non-zero when within about a pixel
Examples
ex_gui_colorwheel.c, and ex_gui_curve.c.

Definition at line 146 of file ex_gui_colorwheel.c.

Referenced by main().

Here is the caller graph for this function:

◆ on_change()

void on_change ( int widget_id,
int dragging,
void * user_data )
static

change callback

Parameters
widget_idthe wheel
draggingset while the button is held
user_dataunused

Definition at line 85 of file ex_gui_colorwheel.c.

References changes, and drag_changes.

◆ process_args()

int process_args ( int argc,
char ** argv )
static

read -V

Parameters
argcargument count
argvarguments
Returns
0, or -1 on a bad argument

Definition at line 68 of file ex_gui_colorwheel.c.

References log_level.

Variable Documentation

◆ changes

int changes = 0
static

changes seen, and those while dragging

Definition at line 48 of file ex_gui_colorwheel.c.

◆ colour_asked

int colour_asked = 0
static

set when the caller's colour was asked for

Examples
ex_gui_colorwheel.c.

Definition at line 50 of file ex_gui_colorwheel.c.

Referenced by grey(), and main().

◆ drag_changes

int drag_changes = 0
static
Examples
ex_gui_colorwheel.c, and ex_gui_curve.c.

Definition at line 48 of file ex_gui_colorwheel.c.

Referenced by main(), on_change(), and on_change().

◆ failures

int failures = 0
static

failed checks

Definition at line 46 of file ex_gui_colorwheel.c.

◆ log_level

int log_level = 3
static

log level from -V

Definition at line 44 of file ex_gui_colorwheel.c.