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

Go to the source code of this file.

Data Structures

struct  DEMO_PANEL
 one demo panel: a window plus the button that detaches / attaches it More...

Macros

#define ALLEGRO_UNSTABLE   1
#define HEIGHT   640
#define LAYOUT_FILE   "ex_gui_detach_layout.json"
#define WIDTH   960

Functions

static int build_panel (const char *title, float x, float y, float w, float h, int detach_flags, const char *name)
 build one demo panel: a few ordinary widgets plus its detach button
int main (int argc, char **argv)
static void on_attach_all (int widget_id, void *user_data)
static void on_detach_all (int widget_id, void *user_data)
static void on_load_layout (int widget_id, void *user_data)
static void on_panel_close (int window_id, void *user_data)
 A native window's close button (the window manager's, or N_GUI's own when the panel keeps its chrome) lands here exactly like a pop-up's would.
static void on_save_layout (int widget_id, void *user_data)
static void on_show_all (int widget_id, void *user_data)
static void on_slider_change (int widget_id, double value, void *user_data)
static void on_toggle_detach (int widget_id, void *user_data)
 the per-panel button: toggle this panel between pop-up and native window
static DEMO_PANEL * panel_of (int window_id)
 find the panel a window id belongs to, or NULL
static void process_args (int argc, char **argv)
static void refresh_buttons (void)
 keep each panel's button label in sync with what it will do next

Variables

static int auto_detach = 0
 1 to detach every panel at startup (-a)
static int DONE = 0
static N_GUI_CTX * gui = NULL
static int lbl_hint = -1
static int lbl_status = -1
static int log_level = 5
static int nb_panels = 0
static int notes_txt = -1
 text area of the "Notes" panel, used by the copy/paste hint
static DEMO_PANEL panels [3]
static double quit_after = 0.0
 seconds after which the demo quits on its own (0 = run until ESC)

Data Structure Documentation

◆ DEMO_PANEL

struct DEMO_PANEL

one demo panel: a window plus the button that detaches / attaches it

Examples
ex_gui_detach.c.

Definition at line 60 of file ex_gui_detach.c.

Collaboration diagram for DEMO_PANEL:
Data Fields
int btn id of the panel's own detach / attach button
int detach_flags options this panel detaches with (N_GUI_DETACH_*)
const char * name short name used in the status line
int win window id

Macro Definition Documentation

◆ ALLEGRO_UNSTABLE

#define ALLEGRO_UNSTABLE   1

Definition at line 44 of file ex_gui_detach.c.

◆ HEIGHT

#define HEIGHT   640

Definition at line 56 of file ex_gui_detach.c.

◆ LAYOUT_FILE

#define LAYOUT_FILE   "ex_gui_detach_layout.json"
Examples
ex_gui_detach.c.

Definition at line 57 of file ex_gui_detach.c.

Referenced by on_load_layout(), and on_save_layout().

◆ WIDTH

#define WIDTH   960

Definition at line 55 of file ex_gui_detach.c.

Function Documentation

◆ build_panel()

int build_panel ( const char * title,
float x,
float y,
float w,
float h,
int detach_flags,
const char * name )
static

build one demo panel: a few ordinary widgets plus its detach button

Examples
ex_gui_detach.c.

Definition at line 237 of file ex_gui_detach.c.

References DEMO_PANEL::btn, DEMO_PANEL::detach_flags, gui, n_gui_add_button(), n_gui_add_window(), n_gui_set_widget_tooltip(), N_GUI_SHAPE_ROUNDED, N_GUI_WIN_BTN_ALL, N_GUI_WIN_RESIZABLE, n_gui_window_set_close_callback(), n_gui_window_set_flags(), DEMO_PANEL::name, nb_panels, on_panel_close(), on_toggle_detach(), panels, and DEMO_PANEL::win.

Referenced by main().

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

◆ main()

◆ on_attach_all()

void on_attach_all ( int widget_id,
void * user_data )
static
Examples
ex_gui_detach.c.

Definition at line 180 of file ex_gui_detach.c.

References gui, n_gui_window_attach(), nb_panels, panels, and refresh_buttons().

Referenced by main().

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

◆ on_detach_all()

void on_detach_all ( int widget_id,
void * user_data )
static
Examples
ex_gui_detach.c.

Definition at line 170 of file ex_gui_detach.c.

References gui, n_gui_window_detach(), n_gui_window_is_detached(), nb_panels, panels, and refresh_buttons().

Referenced by main().

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

◆ on_load_layout()

void on_load_layout ( int widget_id,
void * user_data )
static
Examples
ex_gui_detach.c.

Definition at line 220 of file ex_gui_detach.c.

References gui, LAYOUT_FILE, LOG_ERR, LOG_NOTICE, n_gui_load_layout_json(), n_log, and refresh_buttons().

Referenced by main().

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

◆ on_panel_close()

void on_panel_close ( int window_id,
void * user_data )
static

A native window's close button (the window manager's, or N_GUI's own when the panel keeps its chrome) lands here exactly like a pop-up's would.

The display itself is released at the next n_gui_draw_detached, never from inside this callback.

Examples
ex_gui_detach.c.

Definition at line 193 of file ex_gui_detach.c.

References gui, LOG_NOTICE, n_gui_close_window(), n_log, DEMO_PANEL::name, and panel_of().

Referenced by build_panel().

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

◆ on_save_layout()

void on_save_layout ( int widget_id,
void * user_data )
static
Examples
ex_gui_detach.c.

Definition at line 211 of file ex_gui_detach.c.

References gui, LAYOUT_FILE, LOG_ERR, LOG_NOTICE, n_gui_save_layout_json(), and n_log.

Referenced by main().

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

◆ on_show_all()

void on_show_all ( int widget_id,
void * user_data )
static
Examples
ex_gui_detach.c.

Definition at line 200 of file ex_gui_detach.c.

References gui, n_gui_open_window(), nb_panels, panels, and refresh_buttons().

Referenced by main().

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

◆ on_slider_change()

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

Definition at line 230 of file ex_gui_detach.c.

References LOG_INFO, and n_log.

◆ on_toggle_detach()

void on_toggle_detach ( int widget_id,
void * user_data )
static

the per-panel button: toggle this panel between pop-up and native window

Examples
ex_gui_detach.c.

Definition at line 155 of file ex_gui_detach.c.

References DEMO_PANEL::detach_flags, gui, LOG_ERR, LOG_NOTICE, n_gui_window_attach(), n_gui_window_detach(), n_gui_window_is_detached(), n_log, DEMO_PANEL::name, refresh_buttons(), and DEMO_PANEL::win.

Referenced by build_panel().

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

◆ panel_of()

DEMO_PANEL * panel_of ( int window_id)
static

find the panel a window id belongs to, or NULL

Examples
ex_gui_detach.c.

Definition at line 126 of file ex_gui_detach.c.

References nb_panels, and panels.

Referenced by on_panel_close().

Here is the caller graph for this function:

◆ process_args()

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

Definition at line 86 of file ex_gui_detach.c.

References auto_detach, LOG_DEBUG, LOG_ERR, LOG_INFO, log_level, LOG_NOTICE, LOG_NULL, n_log, quit_after, and set_log_level().

Here is the call graph for this function:

◆ refresh_buttons()

void refresh_buttons ( void )
static

keep each panel's button label in sync with what it will do next

Examples
ex_gui_detach.c.

Definition at line 134 of file ex_gui_detach.c.

References gui, lbl_status, n_gui_button_set_label(), n_gui_count_detached(), n_gui_label_set_text(), n_gui_window_is_detached(), nb_panels, and panels.

Referenced by main(), on_attach_all(), on_detach_all(), on_load_layout(), on_show_all(), and on_toggle_detach().

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

Variable Documentation

◆ auto_detach

int auto_detach = 0
static

1 to detach every panel at startup (-a)

Examples
ex_gui_detach.c.

Definition at line 76 of file ex_gui_detach.c.

Referenced by main(), and process_args().

◆ DONE

int DONE = 0
static

Definition at line 72 of file ex_gui_detach.c.

◆ gui

N_GUI_CTX* gui = NULL
static
Examples
ex_gui.c, ex_gui_bench.c, ex_gui_button_keys.c, ex_gui_checkbox_label.c, ex_gui_color_picker.c, ex_gui_colorwheel.c, ex_gui_combobox_items.c, ex_gui_combobox_wheel.c, ex_gui_cursor.c, ex_gui_curve.c, ex_gui_custom.c, ex_gui_custom_mouse.c, ex_gui_datagrid.c, ex_gui_datagrid_keys.c, ex_gui_datagrid_sort.c, ex_gui_detach.c, ex_gui_dictionary.c, ex_gui_display_fallback.c, ex_gui_double_click.c, ex_gui_dropmenu.c, ex_gui_frameless_drag.c, ex_gui_global_scroll.c, ex_gui_glyph.c, ex_gui_grid.c, ex_gui_hexview.c, ex_gui_hover.c, ex_gui_kvtable.c, ex_gui_label_fits.c, ex_gui_label_lines.c, ex_gui_layout_persist.c, ex_gui_listbox.c, ex_gui_md.c, ex_gui_multiwin.c, ex_gui_network.c, ex_gui_particles.c, ex_gui_placeholder.c, ex_gui_popup.c, ex_gui_progressbar.c, ex_gui_reentrant.c, ex_gui_round.c, ex_gui_sectionlist.c, ex_gui_slider_default.c, ex_gui_slider_handle.c, ex_gui_slider_step.c, ex_gui_splitpane.c, ex_gui_suggest.c, ex_gui_syntaxview.c, ex_gui_text_shorten.c, ex_gui_textarea_selection.c, ex_gui_tooltip.c, ex_gui_tree_lazy.c, ex_gui_tree_order.c, ex_gui_tree_state.c, ex_gui_window_rect.c, and ex_gui_zorder.c.

Definition at line 78 of file ex_gui_detach.c.

Referenced by add_once(), build_datagrid_window(), build_panel(), build_syntaxview_window(), build_textarea_window(), build_widgets_window(), build_window(), chat_log_add(), click_and_report(), click_at(), click_at(), click_at(), click_at(), click_middle(), click_on(), ctrl_key(), ctrl_key(), drag(), drag(), drag_right(), draw(), draw(), draw_into(), draw_once(), dropmenu_label(), feed(), feed(), feed(), feed(), feed(), feed_key(), fill_rows(), handle_stays_inside(), hex_equals(), hover_tooltip_at(), ink(), key(), level_window(), main(), main(), main(), mouse(), mouse_button(), mouse_button(), move_to(), move_to(), on_attach_all(), on_button_click(), on_clear_click(), on_completion_select(), on_detach_all(), on_ghost_toggle(), on_grid_toggle(), on_height_toggle(), on_load_layout(), on_load_layout_click(), on_panel_close(), on_player_toggle(), on_proj_select(), on_save_layout(), on_save_layout_click(), on_search_change(), on_send_click(), on_show_all(), on_smooth_toggle(), on_toggle_detach(), on_window_toggle_click(), on_windows_menu_open(), placeholder_of(), press_at(), press_at(), refresh_buttons(), refresh_clients_list(), render(), right(), run(), send_key(), type(), update_completion(), update_definitions(), wheel(), wheel_then_click(), widget_visible(), and widget_y().

◆ lbl_hint

int lbl_hint = -1
static
Examples
ex_gui_detach.c.

Definition at line 82 of file ex_gui_detach.c.

Referenced by main().

◆ lbl_status

int lbl_status = -1
static

Definition at line 81 of file ex_gui_detach.c.

◆ log_level

int log_level = 5
static

Definition at line 71 of file ex_gui_detach.c.

◆ nb_panels

int nb_panels = 0
static

◆ notes_txt

int notes_txt = -1
static

text area of the "Notes" panel, used by the copy/paste hint

Examples
ex_gui_detach.c.

Definition at line 84 of file ex_gui_detach.c.

Referenced by main().

◆ panels

DEMO_PANEL panels[3]
static

◆ quit_after

double quit_after = 0.0
static

seconds after which the demo quits on its own (0 = run until ESC)

Examples
ex_gui_detach.c.

Definition at line 74 of file ex_gui_detach.c.

Referenced by main(), and process_args().