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

Go to the source code of this file.

Macros

#define ALLEGRO_UNSTABLE   1

Functions

static void expect_true (const char *label, int cond)
 Assert a condition, logging which check failed.
int main (void)
static ALLEGRO_EVENT mouse_event (int type, int x, int y)
 Build a left-button mouse event at (x, y).
static void on_change (int widget_id, double value, void *user_data)
 The slider's on_change: count the calls and keep the value.
static void press_at (N_GUI_CTX *gui, int x, int y, int release)
 Press the primary button at (x, y), and release it unless asked not to.

Variables

static int changes = 0
 How many times on_change ran, and the last value it was given.
static int failures = 0
 Count of failed assertions.
static double last_value = -1.0
 how many times the picker called back, and with what

Macro Definition Documentation

◆ ALLEGRO_UNSTABLE

#define ALLEGRO_UNSTABLE   1

Definition at line 36 of file ex_gui_slider_default.c.

Function Documentation

◆ expect_true()

void expect_true ( const char * label,
int cond )
static

Assert a condition, logging which check failed.

Parameters
labelWhat is being checked.
condNon-zero to pass.

Definition at line 60 of file ex_gui_slider_default.c.

References failures, LOG_ERR, LOG_INFO, and n_log.

◆ main()

◆ mouse_event()

ALLEGRO_EVENT mouse_event ( int type,
int x,
int y )
static

Build a left-button mouse event at (x, y).

Parameters
typeThe ALLEGRO_EVENT_MOUSE_* type.
xCursor x.
yCursor y.
Returns
The event.

Definition at line 89 of file ex_gui_slider_default.c.

References type().

Here is the call graph for this function:

◆ on_change()

void on_change ( int widget_id,
double value,
void * user_data )
static

The slider's on_change: count the calls and keep the value.

Parameters
widget_idThe slider.
valueIts new value.
user_dataUnused.

Definition at line 75 of file ex_gui_slider_default.c.

References changes, and last_value.

◆ press_at()

void press_at ( N_GUI_CTX * gui,
int x,
int y,
int release )
static

Press the primary button at (x, y), and release it unless asked not to.

Parameters
guiGUI context.
xCursor x.
yCursor y.
releaseNon-zero to send the release as well.

Definition at line 106 of file ex_gui_slider_default.c.

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

Here is the call graph for this function:

Variable Documentation

◆ changes

int changes = 0
static

How many times on_change ran, and the last value it was given.

Definition at line 51 of file ex_gui_slider_default.c.

◆ failures

int failures = 0
static

Count of failed assertions.

Definition at line 48 of file ex_gui_slider_default.c.

◆ last_value

double last_value = -1.0
static

how many times the picker called back, and with what

Examples
ex_gui_slider_default.c.

Definition at line 53 of file ex_gui_slider_default.c.

Referenced by main(), and on_change().