Software:NAppGUI
Original author(s) | Francisco García Collado |
---|---|
Initial release | 31 December 2019 |
Stable release | v1.4.0
/ December 31, 2023 |
Repository | github |
Written in | C |
Operating system | Windows, MacOS, Linux |
License | MIT License |
Website | nappgui |
NAppGUI is an open-source SDK for building cross-platform desktop applications using the C Programming Language (ANSI C90). NAppGUI operates as a lightweight layer on top of the operating system's native APIs, which allows creating portable programs very fast and small without external dependencies.
Architecture
The NAppGUI SDK goes beyond a pure GUI widget library and provides the below cross-platform core components.[1]
- Sewer: Basic types, assertions, Unicode, standard C library, math functions.
- Osbs: Operating system services. Portable API on files, directories, processes, threads, memory, etc.
- Core: Commonly used non-graphical utilities. Memory auditor, data structures, I/O channels, lexical analysis, etc.
- Geom2D: 2D geometry. Transformations, vectors, polygons, collisions, etc.
- Draw2D: Vector drawing API, images and fonts.
- Gui: High-level user interface composer.
- OSApp: Desktop applications. Message loops.
- INet: Internet protocols and services, such as HTTP.
Supported Platforms
NAppGUI currently supports the following platforms:[2]
Portability and Deployment
thumb NAppGUI aims to compile and debug a program on any of the above platforms without touching a single line of code. It leverages CMake for creating or updating a build project from the source code and uses Visual Studio, Xcode or GCC depending on the active platform.[3]
Since the very beginning of the project, the main objective of NAppGUI has been to simplify as much as possible the arduous task of creating applications with a graphical interface in C. The philosophy on which the project is based and some of its characteristics are:
- Rapid prototyping, evolution and maintenance in real applications, apart from the simple examples we find in the literature and the Internet.
- The user interface is described using ANSI-C functions, completely eliminating visual design. This fact facilitates the creation of dynamic interfaces, guarantees portability and enables access to the API from any programming language.
- Windows are automatically laid out and sized, without the programmer having to explicitly specify the coordinates and size of the controls.
- It is possible to have a complete application in a single .c file, by removing the usual resource files (*.rc, *.xvid , etc) and their associated controllers. The programmer has complete freedom when defining his own file structure.
- Automatic synchronization of internal data structures with the interface or with I/O channels. “Data binding".
- Unified management of resources which facilitates internationalization. “Resources”
- Translations between languages at runtime without the need to restart the application. “Runtime translation”.
- The compiled version of NAppGUI occupies less than 1Mb, and is distributed in several static libraries that generate very small executables. This is a great advantage over other solutions that require the distribution of heavy .DLLs, sometimes larger than the application itself.
- Native Appearance: The applications will be integrated into each system respecting their original aesthetic.
- Backends. The NAppGUI core provides structures and objects for creating highly efficient command-line applications on Windows or Linux servers.
Documentation
Documentation for NAppGUI is available in the form of an introductory Quick Start Guide, User Guide[4] with build instructions and creating a new application, API reference[5] as well as a free ebook[6].
A set of sample applications demonstrates NAppGUI functionality and facilitates creating own applications.[7]
There exist a NAppGUI Programming Tutorial on YouTube (Spanish language).[8]
Hello World Example
The below code sample creates a window, adds label, button and text control widgets and reacts on a button click. Three screenshots show the program running on the supported platforms.[9]
/* NAppGUI Hello World */ #include <nappgui.h> typedef struct _app_t App; struct _app_t { Window *window; TextView *text; uint32_t clicks; }; /*---------------------------------------------------------------------------*/ static void i_OnButton(App *app, Event *e) { String *msg = str_printf("Button click (%d)\n", app->clicks); textview_writef(app->text, tc(msg)); str_destroy(&msg); app->clicks += 1; unref(e); } /*---------------------------------------------------------------------------*/ static Panel *i_panel(App *app) { Panel *panel = panel_create(); Layout *layout = layout_create(1, 3); Label *label = label_create(); Button *button = button_push(); TextView *text = textview_create(); app->text = text; label_text(label, "Hello!, I'm a label"); button_text(button, "Click Me!"); button_OnClick(button, listener(app, i_OnButton, App)); layout_label(layout, label, 0, 0); layout_button(layout, button, 0, 1); layout_textview(layout, text, 0, 2); layout_hsize(layout, 0, 250); layout_vsize(layout, 2, 100); layout_margin(layout, 5); layout_vmargin(layout, 0, 5); layout_vmargin(layout, 1, 5); panel_layout(panel, layout); return panel; } /*---------------------------------------------------------------------------*/ static void i_OnClose(App *app, Event *e) { osapp_finish(); unref(app); unref(e); } /*---------------------------------------------------------------------------*/ static App *i_create(void) { App *app = heap_new0(App); Panel *panel = i_panel(app); app->window = window_create(ekWINDOW_STD); window_panel(app->window, panel); window_title(app->window, "Hello, World!"); window_origin(app->window, v2df(500, 200)); window_OnClose(app->window, listener(app, i_OnClose, App)); window_show(app->window); return app; } /*---------------------------------------------------------------------------*/ static void i_destroy(App **app) { window_destroy(&(*app)->window); heap_delete(app, App); } /*---------------------------------------------------------------------------*/ #include "osmain.h" osmain(i_create, i_destroy, "", App)
Other Language Bindings
There exist bindings to the below programming languages for NAppGUI.
Licensing
NAppGUI is an open-source project and is distributed under the MIT license.
References
- ↑ "NAppGUI API - Cross-platform C SDK". https://nappgui.com/en/sdk/sdk.html.
- ↑ "Quick start - Cross-platform C SDK". https://nappgui.com/en/start/quick.html.
- ↑ "Welcome to NAppGUI - Cross-platform C SDK". https://nappgui.com/en/start/start.html.
- ↑ "Welcome to NAppGUI - Cross-platform C SDK". https://nappgui.com/en/start/start.html.
- ↑ "NAppGUI API - Cross-platform C SDK". https://nappgui.com/en/sdk/sdk.html.
- ↑ García Collado, Francisco (7 January 2024). "Mastering NAppGUI". https://nappgui.com/res/nappgui_en.pdf.
- ↑ "Die - Cross-platform C SDK". https://nappgui.com/en/demo/die.html.
- ↑ "Tutorial Programación Multiplataforma en C - YouTube". https://www.youtube.com/playlist?list=PLI1sfVva9-pI7NVYURmOHYJqcENdEkAsF&si=b9PcLOUnwftWIg-M.
- ↑ "Hello World! - Cross-platform C SDK". https://nappgui.com/en/start/hello.html.
- ↑ Ringey, Brennan (2023-07-07), stoneface86/nappgui-nim, https://github.com/stoneface86/nappgui-nim, retrieved 2024-01-12
- ↑ Ogi-kun (2023-05-03), Ogi-kun/nappgui, https://github.com/Ogi-kun/nappgui, retrieved 2024-01-12
- ↑ "nappgui-go command - github.com/parro-it/nappgui-go - Go Packages". https://pkg.go.dev/github.com/parro-it/nappgui-go.
- ↑ "Release Cross-platform OS abstraction and GUI library MVP · rochus-keller/Oberon" (in en). https://github.com/rochus-keller/Oberon/releases/tag/NAPPGUI_MVP.
Original source: https://en.wikipedia.org/wiki/NAppGUI.
Read more |