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:
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
| Element | Sygnatura / rola |
|---|---|
Point, Size, Rect, Insets | Geometria w pikselach logicznych; Rect::from_xywh, contains, inflate, deflate, intersection. |
Color | Color::rgb, rgba, from_rgba8, from_hex, with_alpha, lerp. |
Scale | Scale::new(factor), to_physical, to_logical. |
Event | PointerButton, PointerMotion, PointerLeave, Scroll, Key, Text, Paste, Window. |
Theme | Theme::light(), Theme::dark(), accented(accent, fg); pola colors, spacing, radius, typography, metrics. |
Accent | ALL, name(), from_name(), color(), foreground(). |
ThemePreference | System, Light, Dark; resolve(system_dark, accent). |
ThemeSettings | Trwałe ustawienia: preferencja, akcent, styl; load()/save(). |
theme_file | ThemePatch, StyledTheme, available_themes(), load(id). |
motion | Easing, lerp, Animation::{animate_to, jump_to, advance}. |
IconSet, IconTheme | Wykrywanie ikon systemowych i motywu Luna/monochrome. |
libluna-render
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();
| Element | Rola |
|---|---|
Scene | Lista DrawCommand; kształty, clip, tekst, obrazy, tło. |
TextRun | Tekst + origin (linia bazowa), rozmiar, waga, kolor. |
TextEngine | Pomiar i rasteryzacja; TextEngine::system() i mono(). |
SoftwareRenderer | Backend CPU; new(w,h), draw, encode_png, data. |
ImageData | Bufor RGBA8888 dla Scene::image i background. |
decode_svg, scene_to_svg | Rasteryzacja SVG i eksport sceny do SVG. |
libluna-platform
| Element | Rola |
|---|---|
run(config, |frame| …) | Otwiera okno lub powierzchnię warstwową i woła domknięcie przy klatce. |
AppConfig | new(title), initial_size, app_id, settings, system_dark, layer, transparent, escape_to_exit, monospace. |
Frame | scene, theme, text, size, scale, events, dt + metody okna, motywu i schowka. |
LayerConfig | top_panel, overlay, top_chrome, lock_screen; pola anchor, margin, exclusive_zone. |
InputRegion | Auto (z kanału alfa) lub jawne Rects. |
WakeHandle | wake() z innego wątku — np. po zdarzeniu D-Bus. |
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:
| Rodzina | Widgety |
|---|---|
| Akcje | Button, ToggleButton, LinkButton, ColorButton, SplitButton, MenuButton. |
| Formularze | Entry, SearchEntry, PasswordEntry, TextView, SpinButton, Stepper, Slider, Switch, CheckButton, RadioGroup, DropDown, ToggleGroup, Calendar, ColorChooser, EmojiChooser. |
| Nawigacja | ViewSwitcher, NavList, NavigationRail, TabBar, TabView, PathBar, Pager, NavigationView, NavigationSplitView, OverlaySplitView, Sidebar, PopoverMenuBar, Menu. |
| Układ | Card, PreferencesGroup, PreferencesPage, ActionRow, Row, Expander, FlowBox, Paned, Stack, Grid, Fixed, CenterBox, Bin, Clamp, AspectFrame, Frame, Overlay, Revealer, WrapBox, BreakpointBin, ButtonContent, ToolbarView, Viewport, WindowHandle, ActionBar. |
| Kolekcje | ItemView, ColumnView, ScrollView, Scrollbar, Adjustment. |
| Media | MediaControls, Picture, Image, Avatar, IconName. |
| Informacje | InfoBar, Banner, Toast, StatusPage, Statusbar, Popover, Tooltip, Spinner, ProgressBar, LevelBar. |
| Okna | HeaderBar, WindowTitle, Dialog, AlertDialog, AboutDialog, ShortcutsDialog, PreferencesDialog, BottomSheet, Assistant. |
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
| Element | Rola |
|---|---|
Node | Fixed, Label, Spacer, VBox, HBox, Padding, Expanded, Center; helpery vbox, hbox, fixed, label, gap, padded. |
Constraints | loose, tight, unconstrained, deflate, constrain. |
LayoutCtx | theme + text; potrzebny do pomiaru etykiet. |
Layout | new(root), desired_size, fit(rect, ctx) -> Vec<Rect>. |
libluna-i18n
| Element | Rola |
|---|---|
Locale | new(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"). |
Catalog | parse(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>.
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.
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:
# 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.