All Projects → batiati → IUPforZig

batiati / IUPforZig

Licence: Unlicense License
IUP (Portable User Interface Toolkit) bindings for the Zig language.

Programming Languages

Zig
133 projects
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to IUPforZig

ansi-term
Zig library for dealing with ANSI terminals
Stars: ✭ 25 (-55.36%)
Mutual labels:  ziglang, zig-package
nim-iup-examples
Nim GUI examples using IUP
Stars: ✭ 14 (-75%)
Mutual labels:  iup-gui-library, iup
SDL.zig
A shallow wrapper around SDL that provides object API and error handling
Stars: ✭ 102 (+82.14%)
Mutual labels:  ziglang, zig-package
zero-graphics
Application framework based on OpenGL ES 2.0. Runs on desktop machines, Android phones and the web
Stars: ✭ 72 (+28.57%)
Mutual labels:  ziglang, zig-package
zlm
Zig linear mathemathics
Stars: ✭ 67 (+19.64%)
Mutual labels:  ziglang, zig-package
zig-args
Simple-to-use argument parser with struct-based config
Stars: ✭ 106 (+89.29%)
Mutual labels:  ziglang, zig-package
zetaframe
lightweight zig game framework.
Stars: ✭ 14 (-75%)
Mutual labels:  ziglang, zig-package
qml zig
QML bindings for the Zig programming language
Stars: ✭ 25 (-55.36%)
Mutual labels:  ziglang, zig-package
mach-glfw
Ziggified GLFW bindings with 100% API coverage, zero-fuss installation, cross compilation, and more.
Stars: ✭ 186 (+232.14%)
Mutual labels:  ziglang, zig-package
zig-opengl
OpenGL binding generator based on the opengl registry
Stars: ✭ 29 (-48.21%)
Mutual labels:  ziglang, zig-package
Multiplatform-LiveData
Multiplatorm implementation of LiveDatas / MVVM in kotlin android & native ios
Stars: ✭ 95 (+69.64%)
Mutual labels:  multiplatform
Kotlin-Everywhere
Kotrlin Programming Language Cross-Platform Development which includes Android, iOS and Backend. Pretty much everwhere.
Stars: ✭ 30 (-46.43%)
Mutual labels:  multiplatform
multiplatform-lib
Sample multiplatform library in Kotlin with tests and publishing
Stars: ✭ 41 (-26.79%)
Mutual labels:  multiplatform
spu-mark-ii
CPU and home computer project
Stars: ✭ 14 (-75%)
Mutual labels:  ziglang
PaintCode2Skia
Convert your PaintCode app drawings (Android java export) to SkiaSharp C# code
Stars: ✭ 39 (-30.36%)
Mutual labels:  multiplatform
ToDometer Multiplatform
WIP Kotlin Multiplatform project: A meter to-do list built with Android Jetpack, Compose UI Multiplatform, Wear Compose, SQLDelight, Koin Multiplatform, SwiftUI, Ktor Server / Client, Exposed...
Stars: ✭ 145 (+158.93%)
Mutual labels:  multiplatform
kotlin-simple-architecture
Kotlin Simple Architecture
Stars: ✭ 35 (-37.5%)
Mutual labels:  multiplatform
georgios
Hobby Operating System
Stars: ✭ 19 (-66.07%)
Mutual labels:  ziglang
Keemun
No description or website provided.
Stars: ✭ 13 (-76.79%)
Mutual labels:  multiplatform
tmdb-api
This Kotlin Multiplatform library is for accessing the TMDB API to get movie and TV show content. Using for Android, iOS, and JS projects.
Stars: ✭ 31 (-44.64%)
Mutual labels:  multiplatform

IUP for Zig

Lines of code GitHub code size in bytes made with Zig made with Zig

WIP Work in Progress

A Zig language idiomatic and type-checked bindings for IUP Portable User Interface Toolkit

Examples

Simple Notepad Windows

Simple Notepad Ubuntu

First look

A simple hello world example looks like this:

usingnamespace @import("iup.zig");

pub fn main() !void {
    try MainLoop.open();
    defer MainLoop.close();

    var main_dialog = try (Dialog.init()
        .setTitle("Hello World")
        .setChildren(
        .{
            VBox.init()
                .setMargin(10, 10)
                .setGap(10)
                .setAlignment(.ACenter)
                .setChildren(
                .{
                    Label.init()
                        .setTitle("Hello World from IUPforZig"),
                    Button.init()
                        .setTitle("OK")
                        .setActionCallback(exit),
                },
            ),
        },
    ).unwrap());
    defer main_dialog.deinit();

    try main_dialog.showXY(.Center, .Center);
    try MainLoop.beginLoop();
}

fn exit(button: *Button) !void {
    MainLoop.exitLoop();
}

Resulting in this:

Hello World Windows

Hello World Ubuntu

IUP Metadata

This project contains source-code automatically generated by The IUP Metadata Project.

Most of the hard/repetitive work was done by code-gen tool, however, the API guidelines and all the interop code belongs here on this project.

API

Zig does not require any special treatment to use C libraries, so to use IUP in Zig, it is as simple as adding @cInclude("iup.h") in your source code, no need for special bindings!

This project attempts to create Zig bindings for IUP Toolkit with idiomatic and type-checked API, where none of the original IUP's declarations are exposed in the public interface, only names and concepts are kept as close as possible.

Comparison:

  1. IUP simple example in C:
#include <stdlib.h>
#include <iup.h>

int main(int argc, char **argv)
{
  Ihandle *dlg, *multitext, *vbox;

  IupOpen(&argc, &argv);

  multitext = IupText(NULL);
  vbox = IupVbox(
    multitext,
    NULL);
  IupSetAttribute(multitext, "MULTILINE", "YES");
  IupSetAttribute(multitext, "EXPAND", "YES");

  dlg = IupDialog(vbox);
  IupSetAttribute(dlg, "TITLE", "Simple Notepad");
  IupSetAttribute(dlg, "SIZE", "QUARTERxQUARTER");

  IupShowXY(dlg, IUP_CENTER, IUP_CENTER);
  IupSetAttribute(dlg, "USERSIZE", NULL);

  IupMainLoop();

  IupClose();
  return EXIT_SUCCESS;
}
  1. Equivalent example in Zig:
usingnamespace @import("iup.zig");

pub fn main() !void {
    try MainLoop.open();
    defer MainLoop.close();

    var main_dialog = try (Dialog.init()
        .setTitle("Simple Notepad")
        .setSize(.Quarter, .Quarter)
        .setChildren(
        .{
            VBox.init()
                .setChildren(
                .{
                    Text.init()
                        .setMultiline(true)
                        .setExpand(.Yes),
                },
            ),
        },
    ).unwrap());
    defer main_dialog.deinit();

    try main_dialog.showXY(.Center, .Center);
    try MainLoop.beginLoop();
}

How to build

The build.zig file is the bare minimum for link against IUP shared libraries on Linux and Windows.

Please visit IUP's download page for your platform: https://sourceforge.net/projects/iup/files/3.30/

Dependencies for libim and libcd are also required:

https://sourceforge.net/projects/imtoolkit/files/3.15/

https://sourceforge.net/projects/canvasdraw/files/5.14/

Pending work

  • Support for collections and indexed attributes (list items for example)

  • Complete the Simple Notepad example.

  • Support Linux and Windows (using shared libs)

  • Investigate how to build IUP from C sources in Zig.

  • More tests, and sanitize failing tests.

  • Additional controls (image library, matrix, GLCanvas, scintilla, plot, etc)

Feel free to place any comments/issues/PRs, it will be very nice to receive any feedback 🚀.

Prior Art

Some great projects that served as inspiration.

License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].