libLuna Dokumentacja
PL EN
GitHub

Referencja

Indeks API

Ponad 1600 publicznych elementów z sześciu crate'ów libLuny. Ten indeks jest generowany bezpośrednio ze źródeł — można go przeszukiwać po nazwie, module, sygnaturze i opisie. Pełne, autorytatywne rustdoc buduje się jednym poleceniem.

Sześć crate'ów, jeden kontrakt

libluna start tutaj

Fasada: core, render, platform, widgets, i18n oraz prelude. Typowa aplikacja dodaje tylko ten crate.

libluna-core

Geometria, kolor, skala, zdarzenia, ruch, motyw, tokeny, ustawienia wyglądu, ikony, locale.

libluna-render

Graf sceny, polecenia rysowania, tekst, SVG, tapety i backend CPU.

libluna-platform

run, Frame, AppConfig, okna xdg-shell, panele wlr-layer-shell, schowek.

libluna-widgets

PaintCtx, 77 widgetów, rodziny kontenerów, layout Node/Layout, hover.

libluna-i18n

Locale, Catalog, tr, tr_args, makro t!, ładowanie plików .lang.

prelude — najkrótsza droga

Do większości aplikacji wystarczy use libluna::prelude::*;. To re-eksport najczęściej używanych typów:

rust · zawartość prelude
pub use crate::core::event::{
    ButtonState, Event, KeyEvent, Modifiers, PointerButton,
};
pub use crate::core::{
    Accent, Color, Insets, Point, Rect, Size, Theme,
    ThemePreference, ThemeSettings,
};
pub use crate::i18n::{set_locale, tr, Locale};
pub use crate::platform::{run, AppConfig, Frame};
pub use crate::render::{Scene, SoftwareRenderer, TextEngine, TextRun};
pub use crate::widgets::{NavEntry, NavList, PaintCtx, ViewSwitcher};

Makro t! jest w korzeniu crate'a, nie w prelude: use libluna::t;.

libluna-core

ElementSygnatura / rola
Point, Size, Rect, InsetsGeometria w pikselach logicznych; Rect::from_xywh, contains, inflate, deflate, intersection.
ColorColor::rgb, rgba, from_rgba8, from_hex, with_alpha, lerp.
ScaleScale::new(factor), to_physical, to_logical.
EventPointerButton, PointerMotion, PointerLeave, Scroll, Key, Text, Paste, Window.
ThemeTheme::light(), Theme::dark(), accented(accent, fg); pola colors, spacing, radius, typography, metrics.
AccentALL, name(), from_name(), color(), foreground().
ThemePreferenceSystem, Light, Dark; resolve(system_dark, accent).
ThemeSettingsTrwałe ustawienia: preferencja, akcent, styl; load()/save().
theme_fileThemePatch, StyledTheme, available_themes(), load(id).
motionEasing, lerp, Animation::{animate_to, jump_to, advance}.
IconSet, IconThemeWykrywanie ikon systemowych i motywu Luna/monochrome.

libluna-render

rust · graf sceny
let mut scene = Scene::new();
scene.fill_rect(rect, color);
scene.fill_rounded_rect(rect, radius, color);
scene.stroke_rounded_rect(rect, radius, 1.0, border);
scene.push_clip(rect);
scene.text(
    TextRun::new(Point::new(24.0, 48.0), "Hello", 14.0)
        .with_weight(700)
        .with_color(color),
);
scene.pop_clip();

let mut renderer = SoftwareRenderer::new(800, 600);
renderer.draw(&scene, 1.0, background);
let png = renderer.encode_png();
ElementRola
SceneLista DrawCommand; kształty, clip, tekst, obrazy, tło.
TextRunTekst + origin (linia bazowa), rozmiar, waga, kolor.
TextEnginePomiar i rasteryzacja; TextEngine::system() i mono().
SoftwareRendererBackend CPU; new(w,h), draw, encode_png, data.
ImageDataBufor RGBA8888 dla Scene::image i background.
decode_svg, scene_to_svgRasteryzacja SVG i eksport sceny do SVG.

libluna-platform

ElementRola
run(config, |frame| …)Otwiera okno lub powierzchnię warstwową i woła domknięcie przy klatce.
AppConfignew(title), initial_size, app_id, settings, system_dark, layer, transparent, escape_to_exit, monospace.
Framescene, theme, text, size, scale, events, dt + metody okna, motywu i schowka.
LayerConfigtop_panel, overlay, top_chrome, lock_screen; pola anchor, margin, exclusive_zone.
InputRegionAuto (z kanału alfa) lub jawne Rects.
WakeHandlewake() z innego wątku — np. po zdarzeniu D-Bus.
rust · panel warstwowy
use libluna::platform::{Anchor, Layer, LayerConfig};

let config = AppConfig::new("Panel")
    .layer(LayerConfig::top_panel("moj-panel", 40, true))
    .transparent(true);

libluna-widgets

Rodziny widgetów dostępne w libluna::widgets:

RodzinaWidgety
AkcjeButton, ToggleButton, LinkButton, ColorButton, SplitButton, MenuButton.
FormularzeEntry, SearchEntry, PasswordEntry, TextView, SpinButton, Stepper, Slider, Switch, CheckButton, RadioGroup, DropDown, ToggleGroup, Calendar, ColorChooser, EmojiChooser.
NawigacjaViewSwitcher, NavList, NavigationRail, TabBar, TabView, PathBar, Pager, NavigationView, NavigationSplitView, OverlaySplitView, Sidebar, PopoverMenuBar, Menu.
UkładCard, PreferencesGroup, PreferencesPage, ActionRow, Row, Expander, FlowBox, Paned, Stack, Grid, Fixed, CenterBox, Bin, Clamp, AspectFrame, Frame, Overlay, Revealer, WrapBox, BreakpointBin, ButtonContent, ToolbarView, Viewport, WindowHandle, ActionBar.
KolekcjeItemView, ColumnView, ScrollView, Scrollbar, Adjustment.
MediaMediaControls, Picture, Image, Avatar, IconName.
InformacjeInfoBar, Banner, Toast, StatusPage, Statusbar, Popover, Tooltip, Spinner, ProgressBar, LevelBar.
OknaHeaderBar, WindowTitle, Dialog, AlertDialog, AboutDialog, ShortcutsDialog, PreferencesDialog, BottomSheet, Assistant.
rust · PaintCtx
let mut ctx = PaintCtx::new(scene, &theme, text);

let width = ctx.measure("Zapisz", 14.0, 400);
ctx.label_left(24.0, 48.0, "Zapisz", 14.0, 400, ctx.text_color());
ctx.label_center(160.0, 48.0, "Środek", 14.0, 700, ctx.accent());
ctx.label_right(296.0, 48.0, "Koniec", 14.0, 400, ctx.dim_text());

Layout

ElementRola
NodeFixed, Label, Spacer, VBox, HBox, Padding, Expanded, Center; helpery vbox, hbox, fixed, label, gap, padded.
Constraintsloose, tight, unconstrained, deflate, constrain.
LayoutCtxtheme + text; potrzebny do pomiaru etykiet.
Layoutnew(root), desired_size, fit(rect, ctx) -> Vec<Rect>.

libluna-i18n

ElementRola
Localenew(tag), from_env(), language().
set_locale(locale)Ustawia globalny język.
tr(key), tr_args(key, args)Tłumaczenie i podstawianie {name}.
t!Skrót makra: t!("Settings"), t!("Hello, {name}", name = "Ania").
Catalogparse(src), get(key), name().
load_catalogs_from_dirs()Doładowanie plików .lang z katalogów użytkownika i systemu.

Grupy metryk

Metrics dzieli się na 32 grupy. Każda jest dostępna jako pole theme.metrics.<grupa>.<klucz>.

  • headerbar
  • button
  • switch
  • slider
  • dropdown
  • menu
  • nav
  • segmented
  • tabs
  • sheet
  • pager
  • pathbar
  • entry
  • itemview
  • scrollview
  • stepper
  • check
  • radio
  • card
  • row
  • toast
  • status
  • spinner
  • tooltip
  • banner
  • avatar
  • shortcut
  • split
  • group
  • bar
  • container

Pełny indeks publicznych elementów

Indeks wygenerowany skryptem scripts/generate-api-index.py. Obejmuje struktury, enumy, traity, funkcje, metody, stałe, moduły i makra. Przy każdym wpisie jest crate, moduł, sygnatura i link do źródła.

Ładowanie…

Indeks jest indeksem „best effort” — pokazuje publiczne deklaracje znalezione w źródłach. Pełne sygnatury, implementacje traitów i powiązane typy są w rustdoc.

Pełne rustdoc

Rustdoc generuje się z tego samego kodu i zawiera linki między typami, implementacje i dokumentację modułów:

bash · generowanie dokumentacji
# z katalogu głównego repozytorium
make web-api

# albo ręcznie
cargo doc --manifest-path libluna/Cargo.toml --no-deps
# wynik: libluna/target/doc/libluna/index.html

Na stronie wynik jest publikowany pod /api/. Jeśli budujesz lokalnie, otwórz plik bezpośrednio z libluna/target/doc/libluna/index.html.