Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_gui_popup.h
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 */
19
49
50#ifndef __NILOREA_GUI_POPUP__
51#define __NILOREA_GUI_POPUP__
52
53/* Allegro only: the popup is N_GUI windows and custom widgets. */
54#ifdef HAVE_ALLEGRO
55
56#ifdef __cplusplus
57extern "C" {
58#endif
59
64
65#include "nilorea/n_gui.h"
66
68#define N_GUI_POPUP_ROOT 0
69
72typedef struct N_GUI_POPUP N_GUI_POPUP;
73
78typedef void (*N_GUI_POPUP_FN)(N_GUI_POPUP* popup, int tag, void* user_data);
79
94
107int n_gui_popup_add_item(N_GUI_POPUP* popup, int parent, const char* text, int tag, const char* tip);
108
119int n_gui_popup_add_submenu(N_GUI_POPUP* popup, int parent, const char* text, const char* tip);
120
129int n_gui_popup_add_separator(N_GUI_POPUP* popup, int parent);
130
140void n_gui_popup_set_title(N_GUI_POPUP* popup, const char* text);
141
149void n_gui_popup_set_shown(N_GUI_POPUP* popup, int entry, int shown);
150
161void n_gui_popup_set_enabled(N_GUI_POPUP* popup, int entry, int enabled);
162
175int n_gui_popup_open(N_GUI_POPUP* popup, float x, float y);
176
182void n_gui_popup_close(N_GUI_POPUP* popup);
183
191int n_gui_popup_is_open(const N_GUI_POPUP* popup);
192
202int n_gui_popup_hit(const N_GUI_POPUP* popup, float x, float y);
203
212int n_gui_popup_window(const N_GUI_POPUP* popup, int level);
213
226int n_gui_popup_press(N_GUI_POPUP* popup, int entry);
227
236void n_gui_popup_free(N_GUI_POPUP** popup);
237
241
242#ifdef __cplusplus
243}
244#endif
245
246#endif /* HAVE_ALLEGRO */
247
248#endif /* __NILOREA_GUI_POPUP__ */
static void on_pick(N_GUI_POPUP *popup, int tag, void *user_data)
the pick callback
The top-level GUI context that holds all windows.
Definition n_gui.h:1669
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_close(N_GUI_POPUP *popup)
Close every level without picking anything.
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.
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.
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_hit(const N_GUI_POPUP *popup, float x, float y)
Is a point on any of its open levels.
void n_gui_popup_set_shown(N_GUI_POPUP *popup, int entry, int shown)
Show or hide an entry.
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.
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.
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.
Definition n_gui_popup.h:78
int n_gui_popup_is_open(const N_GUI_POPUP *popup)
Is its top level on screen.
void n_gui_popup_set_enabled(N_GUI_POPUP *popup, int entry, int enabled)
Enable or grey out an entry.
void n_gui_popup_free(N_GUI_POPUP **popup)
Close the popup and release the handle.
GUI system: buttons, sliders, text areas, checkboxes, scrollbars, dropdown menus, windows.
void * user_data
handed to on_pick
float scale
interface scale
N_GUI_CTX * ctx
the context
the popup