Skip to content
mcpplibsPublic

About

Slint (declarative GUI toolkit) as C++23 modules for mcpp: import mcpplibs.mwrap.slint; and the build rule mcpp.plugins.slint

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Slint

Slint, the declarative GUI toolkit, through C++23 modules: its runtime API, the interpreter and .slint files compiled into modules.

English · 简体中文 · Upstream · Releases · mcpp · Index

C++23 License mcpp-community CI

The upstream API is unchanged: slint::ComponentHandle, slint::SharedString, slint::VectorModel, slint::interpreter::ComponentCompiler are the names of <slint.h>. The SDK is compat.slint 1.19.0 (xim:slint: libslint_cpp, its headers and slint-compiler, built from the release tag with upstream CMake's default features). A .slint file is compiled by mcpp.mcpplibs.slintgen (package mcpplibs.slintgen, in rules/ of this repository), which the project's build.mcpp imports; with module set, each file becomes a module the program imports.

Modules

  • import mcpplibs.mwrap.slint;: slint:: -- windows and components, SharedString, SharedVector, models, Color, Brush, Image, timers, the event loop, slint::language
  • import mcpplibs.mwrap.slint.interpreter;: slint::interpreter -- .slint sources loaded at run time
  • import mcpplibs.mwrap.slint.platform;: slint::platform -- a custom platform, the software renderer (Clang; with GCC include <slint-platform.h>)
  • import mcpplibs.mwrap.slint.macros;: SLINT_FEATURE_* as constexpr bool in mcpplibs::mwrap::slint::macros
  • import app.ui;: a component of yours, from ui/app.slint (mcpp.mcpplibs.slintgen, options::module)

More Modules API -> Usage and API

Getting started

mcpp new counter --template mcpplibs.mwrap.slint@1.19.0
cd counter
mcpp run

The default template opens a window with a counter; without a display (or with SLINT_HEADLESS=1) it runs on Slint's software renderer and prints the counter.

[dependencies]
mcpplibs.mwrap.slint = "1.19.0.2"
// build.mcpp
import mcpp;
import mcpp.mcpplibs.slintgen;
int main() {
    mcpp::mcpplibs::slintgen::options o;
    o.sources = {"ui/app.slint"};
    o.module = "app.ui";
    return mcpp::mcpplibs::slintgen::compile(o) ? 0 : 1;
}
// src/main.cpp
import mcpplibs.mwrap.slint;
import app.ui;

int main() {
    auto ui = AppWindow::create();
    ui->on_increase([&] { ui->set_counter(ui->get_counter() + 1); });
    ui->run();
}

Features of the SDK

compat.slint 1.19.0 is upstream CMake's default desktop set: interpreter, backend-winit (X11, Wayland, Windows, macOS), renderer-femtovg (OpenGL), renderer-software, accessibility, system-tray, testing, and the compiler. Skia, LinuxKMS, Qt and gettext are not in it. On Linux the library needs fontconfig (xim:fontconfig) and the C runtime only; X11, Wayland and GL are loaded when used. mcpplibs::mwrap::slint::macros::SLINT_FEATURE_RENDERER_SKIA and the others say which features are present.

Build and testing

Linux, macOS and Windows CI build the modules with GCC and Clang and run the tests: the runtime types through the module, and a component compiled at run time by slint::interpreter and driven headless through its properties and callbacks. The export audit (tools/check_exports.py) reads clang's AST of the SDK's headers: every public name exported, the key codes and features mapped, the SDK's features upstream CMake's defaults. A separate job scaffolds the default template as an installed package, builds it with mcpp.mcpplibs.slintgen and runs it headless.

License

Apache-2.0 for the wrapper, by mcpp-community (NOTICE). Slint is available under the GNU GPLv3, the Slint Royalty-free License 2.0 (desktop, mobile and web; not embedded) or the Slint Commercial License, at your choice (upstream/slint/LICENSE.md, LICENSES). The SDK's own notices, including the Rust crates it links, are deployed with programs.

About

Slint (declarative GUI toolkit) as C++23 modules for mcpp: import mcpplibs.mwrap.slint; and the build rule mcpp.plugins.slint

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages