Table of Contents
- GUI POPUP: a popup menu with submenus
- Types
- Functions
- Defines
- Types Documentation
- Functions Documentation
- function n_gui_popup_window
- function n_gui_popup_set_title
- function n_gui_popup_set_shown
- function n_gui_popup_set_enabled
- function n_gui_popup_press
- function n_gui_popup_open
- function n_gui_popup_new
- function n_gui_popup_is_open
- function n_gui_popup_hit
- function n_gui_popup_free
- function n_gui_popup_close
- function n_gui_popup_add_submenu
- function n_gui_popup_add_separator
- function n_gui_popup_add_item
- Macros Documentation
GUI POPUP: a popup menu with submenus
Types
| Name | |
|---|---|
| typedef void(*)(N_GUI_POPUP *popup, int tag, void *user_data) | N_GUI_POPUP_FN called when an item is picked, after the popup has closed. |
Functions
| Name | |
|---|---|
| int | n_gui_popup_window(const N_GUI_POPUP * popup, int level) The window of a level, for an application that wants to test it. |
| void | n_gui_popup_set_title(N_GUI_POPUP * popup, const char * text) Set the heading line over the top level. |
| void | n_gui_popup_set_shown(N_GUI_POPUP * popup, int entry, int shown) Show or hide an entry. |
| void | n_gui_popup_set_enabled(N_GUI_POPUP * popup, int entry, int enabled) Enable or grey out an entry. |
| int | n_gui_popup_press(N_GUI_POPUP * popup, int entry) Press the row of an entry, as a click on it would. |
| int | n_gui_popup_open(N_GUI_POPUP * popup, float x, float y) Open the top level with its corner at a point. |
| N_GUI_POPUP * | n_gui_popup_new(N_GUI_CTX * ctx, float scale, N_GUI_POPUP_FN on_pick, void * user_data) Make an empty popup menu in ctx, closed. |
| int | n_gui_popup_is_open(const N_GUI_POPUP * popup) Is its top level on screen. |
| int | n_gui_popup_hit(const N_GUI_POPUP * popup, float x, float y) Is a point on any of its open levels. |
| void | n_gui_popup_free(N_GUI_POPUP ** popup) Close the popup and release the handle. |
| void | n_gui_popup_close(N_GUI_POPUP * popup) Close every level without picking anything. |
| int | n_gui_popup_add_submenu(N_GUI_POPUP * popup, int parent, const char * text, const char * tip) Add a submenu at the end of a level. |
| int | n_gui_popup_add_separator(N_GUI_POPUP * popup, int parent) Add a separator at the end of a level. |
| int | n_gui_popup_add_item(N_GUI_POPUP * popup, int parent, const char * text, int tag, const char * tip) Add an item at the end of a level. |
Defines
| Name | |
|---|---|
| N_GUI_POPUP_ROOT the top level, as a parent for n_gui_popup_add_item() and the others |
Types Documentation
typedef N_GUI_POPUP_FN
typedef void(* N_GUI_POPUP_FN) (N_GUI_POPUP *popup, int tag, void *user_data);
called when an item is picked, after the popup has closed.
Parameters:
- popup the popup
- tag the tag the item was added with
- user_data what was handed to n_gui_popup_new()
Functions Documentation
function n_gui_popup_window
int n_gui_popup_window(
const N_GUI_POPUP * popup,
int level
)
The window of a level, for an application that wants to test it.
Parameters:
- popup the popup
- level N_GUI_POPUP_ROOT or a submenu's id
Return: the window id, or -1 when that level has not been opened yet.
function n_gui_popup_set_title
void n_gui_popup_set_title(
N_GUI_POPUP * popup,
const char * text
)
Set the heading line over the top level.
Parameters:
- popup the popup
- text the heading, or NULL or "" for none. Copied.
Not a row that can be picked: it says what the popup is about, a file name or a count. Takes effect at the next n_gui_popup_open().
function n_gui_popup_set_shown
void n_gui_popup_set_shown(
N_GUI_POPUP * popup,
int entry,
int shown
)
Show or hide an entry.
Parameters:
- popup the popup
- entry an id returned by one of the add functions
- shown non-zero to show it
function n_gui_popup_set_enabled
void n_gui_popup_set_enabled(
N_GUI_POPUP * popup,
int entry,
int enabled
)
Enable or grey out an entry.
Parameters:
- popup the popup
- entry an id returned by one of the add functions
- enabled non-zero to enable it
A disabled row is drawn greyed, is not highlighted and does nothing when pressed; a disabled submenu does not open.
function n_gui_popup_press
int n_gui_popup_press(
N_GUI_POPUP * popup,
int entry
)
Press the row of an entry, as a click on it would.
Parameters:
- popup the popup
- entry the entry's id
Return: 1 when something happened, 0 otherwise.
For tests and for keyboard front ends: an item is picked (the popup closes, then on_pick is called), a submenu opens beside its row. The entry's level must be open and the entry shown and enabled.
function n_gui_popup_open
int n_gui_popup_open(
N_GUI_POPUP * popup,
float x,
float y
)
Open the top level with its corner at a point.
Parameters:
- popup the popup
- x screen x, usually where the click was
- y screen y
Return: 0, or -1 when a window could not be made or nothing is shown.
Below and to the right of the point, pulled back inside the display rather than flipped. Any level already open is closed first.
function n_gui_popup_new
N_GUI_POPUP * n_gui_popup_new(
N_GUI_CTX * ctx,
float scale,
N_GUI_POPUP_FN on_pick,
void * user_data
)
Make an empty popup menu in ctx, closed.
Parameters:
- ctx the GUI context
- scale interface scale, for padding and the arrow; 1.0 at 96 dpi
- on_pick called with an item's tag when it is picked. Required.
- user_data handed back to on_pick
Return: the popup, or NULL on failure. Release it with n_gui_popup_free().
No window is made until a level is first opened. The windows belong to ctx like any others and outlive the handle, closed and inert.
function n_gui_popup_is_open
int n_gui_popup_is_open(
const N_GUI_POPUP * popup
)
Is its top level on screen.
Parameters:
- popup the popup
Return: 1 when it is open.
function n_gui_popup_hit
int n_gui_popup_hit(
const N_GUI_POPUP * popup,
float x,
float y
)
Is a point on any of its open levels.
Parameters:
- popup the popup
- x screen x
- y screen y
Return: 1 when the point is inside an open level, 0 otherwise.
function n_gui_popup_free
void n_gui_popup_free(
N_GUI_POPUP ** popup
)
Close the popup and release the handle.
Parameters:
- popup the popup; set to NULL. NULL or *NULL is a no-op.
Its windows stay in the context, closed, and their widgets no longer call into the freed handle.
function n_gui_popup_close
void n_gui_popup_close(
N_GUI_POPUP * popup
)
Close every level without picking anything.
Parameters:
- popup the popup. NULL is a no-op.
function n_gui_popup_add_submenu
int n_gui_popup_add_submenu(
N_GUI_POPUP * popup,
int parent,
const char * text,
const char * tip
)
Add a submenu at the end of a level.
Parameters:
- popup the popup
- parent N_GUI_POPUP_ROOT, or another submenu's id
- text what its row says; the arrow is drawn, not written. Copied.
- tip tooltip for the row, or NULL. Copied.
Return: the submenu's id, a parent for its own entries, or -1 on failure.
function n_gui_popup_add_separator
int n_gui_popup_add_separator(
N_GUI_POPUP * popup,
int parent
)
Add a separator at the end of a level.
Parameters:
- popup the popup
- parent N_GUI_POPUP_ROOT or a submenu's id
Return: the separator's id, or -1 on failure.
function n_gui_popup_add_item
int n_gui_popup_add_item(
N_GUI_POPUP * popup,
int parent,
const char * text,
int tag,
const char * tip
)
Add an item at the end of a level.
Parameters:
- popup the popup
- parent N_GUI_POPUP_ROOT, or an id from n_gui_popup_add_submenu()
- text what the row says. Copied.
- tag handed to on_pick when it is picked
- tip tooltip for the row, or NULL. Copied.
Return: the entry's id, or -1 on failure (no memory, a parent that is not a level).
Macros Documentation
define N_GUI_POPUP_ROOT
#define N_GUI_POPUP_ROOT 0
the top level, as a parent for n_gui_popup_add_item() and the others
Modules
- AABB3D
- ACCEPT_POOL
- ALLEGRO4
- ALLEGRO5
- ANIM_LIB
- ASTAR
- ATLAS_LIB
- AVRO
- CLOCK_SYNC
- COMMONS
- CONFIGFILE
- CYPHER_BASE64
- CYPHER_VIGENERE
- DEAD_RECKONING
- ENUMS
- EXCEPTIONS
- GAME_ENV
- GIT
- GUI
- HASH_TABLE
- ISOMETRIC_ENGINE
- LIST
- LOG
- LOGNODUP
- LZ4
- NETWORKING
- NETWORK_MSG
- N_COOKIES
- N_DIFF
- N_DIGEST
- N_DISK_CACHE
- N_DNS
- N_ECC
- N_ENTROPY
- N_FILES
- N_FLUIDS
- N_GUI_COLOR
- N_GUI_COLORWHEEL
- N_GUI_CURVE
- N_GUI_GRID
- N_GUI_POPUP
- N_HEX
- N_HTTP3
- N_HTTP_COOKIE
- N_HTTP_FORM
- N_HTTP_MIME
- N_HTTP_REQ
- N_HTTP_RESP
- N_HTTP_ROUTER
- N_HTTP_SERVER
- N_ICC
- N_JSON
- N_KAFKA
- N_LINALG
- N_MODULE
- N_OPENSSL_COMPAT
- N_PRETTY
- N_PTH
- N_QUERY
- N_RANDOM
- N_SHA256
- N_STR
- N_TIFF
- N_TIME
- N_USER
- N_X509
- N_ZIP
- PARTICLES
- PCRE
- PHYSICS
- SIGNALS
- STACK
- THREADS
- TRAJECTORY
- TREE
- ZLIB