Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

💻Build one codebase and get native UI on Windows, Linux and Web

License

NotificationsYou must be signed in to change notification settings

capy-ui/capy

Repository files navigation

Capy UI

As of now, Capy is NOT ready for use in production as I'm still making breaking changes

Capy targets Zig version0.14.0-dev.1911+3bf89f55c /2024.10.0-mach (Nominated Zig versions), it doesn't work on Zig0.13.0


Code CoverageMPL-2.0 License

the glorius software in action

Introduction

Capy is aGUI library for Zig. It is mainly intended for creating applications using native controls from the operating system.Capy is a declarative UI library aiming to be easy to write for and versatile.

It has been made with the goal to empower standalone UI applications, integration in games or any other rendering process is a non-goal.

Features

  • Use Zig for frontend and backend
  • Accessibility: compatibility with almost all accessibility tools
  • Cross-platform
  • Uses the target OS toolkit
  • Cross-compilable from any platform to any other platform
  • Tiny executables - Everyexample's size < 2MB, which is smaller than 'hello world' in Go

Getting Started

If you're starting a new project, simply clonecapy-template and follow build instructions.

Otherwise or for more information, please look in thedocs.

You can ask questions and receive updates on the#capy-ui Matrix channel.

Usage

A simple application using capy:

constcapy=@import("capy");conststd=@import("std");pubusingnamespacecapy.cross_platform;pubfnmain()!void {trycapy.init();varwindow=trycapy.Window.init();trywindow.set(capy.column(.{ .spacing=10 }, .{// have 10px spacing between each column's elementcapy.row(.{ .spacing=5 }, .{// have 5px spacing between each row's elementcapy.button(.{ .label="Save", .onclick=@ptrCast(&buttonClicked) }),capy.button(.{ .label="Run",  .onclick=@ptrCast(&buttonClicked) })            }),// 'expanded' means the widget will take all the space it can// in the parent containercapy.expanded(capy.textArea(.{ .text="Hello World!" })            )        })    );window.setPreferredSize(800,600);window.show();capy.runEventLoop();}fnbuttonClicked(button:*capy.Button)!void {std.log.info("You clicked the button with text {s}", .{button.getLabel()});}

It is easy to add something like a button or a text area. The example can already be used to notice a widget's parameters are usually enclosed in anonymousstructs (.{ .label = "Save" }). You can also see that simply wrapping a widget withcapy.Expanded( ... ) will tell it to take all the space it can.

Contributing

Contributing can be as simple as opening an issue and detailling what bug you encountered or what feature you wish to have.
If you want to help the project more directly, you can fork the project and then create a pull request.

Supported platforms

A platform is considered supported only if it can be built to from every other OS.

Legends:

  • ✅ Working and can be cross-compile from all platforms supported by Zig
  • 🧪 Experimental
  • 🏃 Planned

Desktop

✅ Windows x86_64
✅ Windows i386

🏃 macOS M1
🏃 macOS x86_64

✅ Linux x86_64
✅ Linux i386
✅ Linux aarch64 (PinePhone, PineBook...)

✅ FreeBSD x86_64

Mobile

🧪 Android
🏃 iOS

Web

✅ WebAssembly

Note: As there's no "official" GUI library for Linux, GTK 4 has been chosen as it is the onethat works and can be configured on the most distros. It's also the reason Libadwaita won'tbe adopted, as it's meant for GNOME and GNOME only by disallowing styling and integrationwith other DEs.

Supported components

For now, not every platform supports the same components. So here's a list of the ones that are supported:

win32macOSGTKAndroidwasm
Button
Canvas
CheckBox
Dropdown
Image
Label
Menu
Navigation
NavigationSidebar
Scrollable
Slider
Tabs
TextArea
TextField
Window

[8]ページ先頭

©2009-2025 Movatter.jp