GithubHelp home page GithubHelp logo

oinpentuls / capy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from capy-ui/capy

0.0 0.0 0.0 19.72 MB

๐Ÿ’ปBuild one codebase and get native UI on Windows, Linux and Web

Home Page: https://capy-ui.org

License: Mozilla Public License 2.0

Shell 0.01% JavaScript 3.10% C 0.12% Java 0.10% Nix 0.23% HTML 0.06% GLSL 0.04% Zig 96.34%

capy's Introduction

Capy

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


Code Coverage MPL-2.0 License

the glorius software in action

Introduction

Capy is a GUI 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 - Every example's size < 2MB, which is smaller than 'hello world' in Go

Usage

Target Zig Version: 0.12.0-dev.2063+804cee3b9 (2024.1.0-mach)

A simple application using capy:

const capy = @import("capy");
const std = @import("std");

pub fn main() !void {
    try capy.backend.init();

    var window = try capy.Window.init();
    try window.set(
        capy.column(.{ .spacing = 10 }, .{ // have 10px spacing between each column's element
            capy.row(.{ .spacing = 5 }, .{ // have 5px spacing between each row's element
                capy.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 container
            capy.expanded(
                capy.textArea(.{ .text = "Hello World!" })
            )
        })
    );

    window.setPreferredSize(800, 600);
    window.show();
    capy.runEventLoop();
}

fn buttonClicked(button: *capy.Button) !void {
    std.log.info("You clicked 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 anonymous structs (.{ .label = "Save" }). You can also see that simply wrapping a widget with capy.Expanded( ... ) will tell it to take all the space it can.

Getting Started

Note: Capy targets Zig master so please try to get the latest version

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

Otherwise or for more information, please look in the docs.

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

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.

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

  • โœ… Working and can be cross-compile from all platforms supported by Zig
  • ๐Ÿงช Experimental
  • ๐Ÿƒ Planned

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

capy's People

Contributors

zenith391 avatar dvmason avatar wukgdu avatar adjectiveallison avatar mochalins avatar traxar avatar frmdstryr avatar iddev5 avatar bnyro avatar brainwo avatar dubbathony avatar marler8997 avatar ymndoseijin avatar desttinghim avatar mseiler-png avatar truemedian avatar zigster64 avatar tapiot avatar trnxdev avatar thechampagne avatar jernejp21 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.