Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
ex_gui_grid.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_grid.h"
Include dependency graph for ex_gui_grid.c:

Go to the source code of this file.

Macros

#define ALLEGRO_UNSTABLE   1

Functions

static void draw (N_GUI_CTX *gui)
 draw the whole context into a memory bitmap
static void draw_background (int widget_id, float x, float y, float w, float h, void *user_data)
 draw behind
static void draw_cell (int widget_id, size_t index, float x, float y, float w, float h, void *user_data)
 draw one cell
static void expect_true (const char *what, int ok)
 record one check
static void feed (N_GUI_CTX *gui, int type, float x, float y, int button, int dz)
 feed one mouse event
static void feed_key (N_GUI_CTX *gui, int type, int keycode)
 feed one key event
int main (int argc, char **argv)
static void press (int widget_id, size_t index, int button, float x, float y, void *user_data)
 a press on a cell
static int process_args (int argc, char **argv)
 read -V LOGLEVEL
static void visible (int widget_id, size_t first, size_t last, void *user_data)
 the range to prepare
static int wheel (int widget_id, int dz, int modifiers, void *user_data)
 Ctrl+wheel resizes the cells; the plain wheel is left to scroll.

Variables

static int backgrounds = 0
static int cells_drawn = 0
 what the callbacks saw
static int failures = 0
static size_t first_seen = 0
static size_t last_seen = 0
static int log_level = 3
static int pressed_button = 0
static size_t pressed_index = 0
static float pressed_x = 0.0f
static float pressed_y = 0.0f
static int presses = 0
static int wheel_mods = 0
static int wheels = 0
 what the wheel callback saw, and the cell size it keeps
static float zoom_cell = 50.0f
static N_GUI_CTX * zoom_gui = NULL
 the context the wheel callback resizes the grid in

Macro Definition Documentation

◆ ALLEGRO_UNSTABLE

#define ALLEGRO_UNSTABLE   1

Definition at line 17 of file ex_gui_grid.c.

Function Documentation

◆ draw()

void draw ( N_GUI_CTX * gui)
static

draw the whole context into a memory bitmap

Examples
ex_gui_grid.c, and ex_gui_popup.c.

Definition at line 140 of file ex_gui_grid.c.

References cells_drawn, gui, and n_gui_draw().

Referenced by iso_map_draw(), main(), n_gui_add_custom(), and n_gui_curve_set_background().

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

◆ draw_background()

void draw_background ( int widget_id,
float x,
float y,
float w,
float h,
void * user_data )
static

draw behind

Examples
ex_gui_grid.c.

Definition at line 78 of file ex_gui_grid.c.

References backgrounds.

Referenced by main().

Here is the caller graph for this function:

◆ draw_cell()

void draw_cell ( int widget_id,
size_t index,
float x,
float y,
float w,
float h,
void * user_data )
static

draw one cell

Examples
ex_gui_grid.c.

Definition at line 69 of file ex_gui_grid.c.

References cells_drawn.

Referenced by main().

Here is the caller graph for this function:

◆ expect_true()

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

record one check

Definition at line 45 of file ex_gui_grid.c.

References failures, LOG_ERR, LOG_INFO, and n_log.

◆ feed()

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

feed one mouse event

Definition at line 126 of file ex_gui_grid.c.

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

Here is the call graph for this function:

◆ feed_key()

void feed_key ( N_GUI_CTX * gui,
int type,
int keycode )
static

feed one key event

Examples
ex_gui_grid.c.

Definition at line 116 of file ex_gui_grid.c.

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

Referenced by main().

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

◆ main()

◆ press()

void press ( int widget_id,
size_t index,
int button,
float x,
float y,
void * user_data )
static

a press on a cell

Examples
ex_gui_grid.c.

Definition at line 94 of file ex_gui_grid.c.

References pressed_button, pressed_index, pressed_x, pressed_y, and presses.

Referenced by main().

Here is the caller graph for this function:

◆ process_args()

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

read -V LOGLEVEL

Definition at line 55 of file ex_gui_grid.c.

References log_level.

◆ visible()

◆ wheel()

int wheel ( int widget_id,
int dz,
int modifiers,
void * user_data )
static

Ctrl+wheel resizes the cells; the plain wheel is left to scroll.

Definition at line 105 of file ex_gui_grid.c.

References n_gui_grid_set_cell_size(), wheel_mods, wheels, zoom_cell, and zoom_gui.

Here is the call graph for this function:

Variable Documentation

◆ backgrounds

int backgrounds = 0
static
Examples
ex_gui_grid.c.

Definition at line 35 of file ex_gui_grid.c.

Referenced by draw_background(), and main().

◆ cells_drawn

int cells_drawn = 0
static

what the callbacks saw

Examples
ex_gui_grid.c.

Definition at line 35 of file ex_gui_grid.c.

Referenced by draw(), draw_cell(), and main().

◆ failures

int failures = 0
static

Definition at line 32 of file ex_gui_grid.c.

◆ first_seen

size_t first_seen = 0
static
Examples
ex_gui_grid.c.

Definition at line 36 of file ex_gui_grid.c.

Referenced by main(), and visible().

◆ last_seen

size_t last_seen = 0
static
Examples
ex_gui_grid.c.

Definition at line 36 of file ex_gui_grid.c.

Referenced by main(), and visible().

◆ log_level

int log_level = 3
static

Definition at line 31 of file ex_gui_grid.c.

◆ pressed_button

int pressed_button = 0
static
Examples
ex_gui_grid.c.

Definition at line 35 of file ex_gui_grid.c.

Referenced by main(), and press().

◆ pressed_index

size_t pressed_index = 0
static
Examples
ex_gui_grid.c.

Definition at line 36 of file ex_gui_grid.c.

Referenced by main(), and press().

◆ pressed_x

float pressed_x = 0.0f
static
Examples
ex_gui_grid.c.

Definition at line 37 of file ex_gui_grid.c.

Referenced by main(), and press().

◆ pressed_y

float pressed_y = 0.0f
static
Examples
ex_gui_grid.c.

Definition at line 37 of file ex_gui_grid.c.

Referenced by main(), and press().

◆ presses

int presses = 0
static
Examples
ex_gui_grid.c.

Definition at line 35 of file ex_gui_grid.c.

Referenced by main(), and press().

◆ wheel_mods

int wheel_mods = 0
static
Examples
ex_gui_grid.c.

Definition at line 39 of file ex_gui_grid.c.

Referenced by main(), and wheel().

◆ wheels

int wheels = 0
static

what the wheel callback saw, and the cell size it keeps

Examples
ex_gui_grid.c.

Definition at line 39 of file ex_gui_grid.c.

Referenced by main(), and wheel().

◆ zoom_cell

float zoom_cell = 50.0f
static
Examples
ex_gui_grid.c.

Definition at line 40 of file ex_gui_grid.c.

Referenced by main(), and wheel().

◆ zoom_gui

N_GUI_CTX* zoom_gui = NULL
static

the context the wheel callback resizes the grid in

Examples
ex_gui_grid.c.

Definition at line 42 of file ex_gui_grid.c.

Referenced by main(), and wheel().