Files
ltk/CHANGELOG.md
Pedro M. de Echanove Pasquin 1fd697aa6d
Some checks failed
CI / build + test (push) Has been cancelled
CI / cargo audit (push) Has been cancelled
docs overhaul, orientation API, fluid-sizing fixes, examples made honest
Documentation pass: every claim in docs/ and the meta files was audited against the source and the drift fixed — around ninety corrections. CONTRIBUTING and the CI workflow now run cargo test with --features test-support (the gated test_support module made both the documented commands and the CI build fail to compile), make example becomes make examples, make doctest-md and the debhelper requirement of make clean are documented, and patch shape asks for a CHANGELOG entry. theming.md loses the nonexistent surface.backdrop, gains the real gradient defaults (linear-rgb, oklab), the six slot variants including typography, the ten-field palette, a truthful effects-consumer table, the ThemePreference/from_hour API and a responsive-sizing note; the stale docstrings in src/theme that fed the drift are fixed too. architecture.md's "Known gaps" section is rewritten against reality (multi-touch slots, xdg-activation, a11y live regions and SetValue/Increment/Decrement are implemented), gains a module map, subsurfaces and window-lifecycle coverage, and correct crustace/loginmanager paths. widgets.md fixes the ten factual errors (stateless spinner, toast/combo via overlays(), tooltip hover contract, row has no max_width, scroll axes, multiline text_edit, dialog panic wording) and now states the column() 16 px default padding — the recurring ambush — plus row's differing 0 default and dialog's max_width. onboarding, README and cookbook get the remaining sweep: build/test instructions, complete example lists, img_widget, clipping-parity honesty, ~30 Hz software cap, read_rgba_pixels signature, tab indentation in snippets, and rustdoc-style links that rendered literally are gone everywhere. CHANGELOG is restructured per Keep a Changelog with the missing entries (window_resizable, claims_raw_touch, Row::align_top/fill_height, caret fixes, dependency pins) and the pad_v Added/Changed contradiction resolved.
New adaptive-layout API: ltk::orientation() with the Orientation enum, backed by viewport_size()/set_viewport_size — the runtime records the main surface's physical dimensions on every configure, before App::on_resize, so view() can branch a layout on portrait vs landscape without hand-tracking resizes. The portrait rule matches Length::orient (square counts as portrait); embedders driving core::UiSurface call set_viewport_size themselves. Documented in the crate root's responsive-design section and architecture.md.
Fluid-vs-fixed sizing fixes in widgets, all the same disease — fluid content inside a fixed-pixel box. TextEdit::fixed_width takes impl Into<Length> (f32 call sites keep compiling as px) and the time picker's digit fields move to Length::fluid( 72.0 ), matching their fluid font so digits can no longer outgrow the box. Dialog::max_width takes impl Into<Length> with a Length::fluid( 480.0 ) default so the card scales with the stock buttons inside it, and the card's interior no longer stacks the column() default 16 px padding on top of CARD_PADDING — that double inset squeezed the action row until its buttons clipped on narrow windows. App::on_pointer_axis now triggers a view rebuild and repaint; previously state mutated in the hook did not paint until the next unrelated event.
Examples reworked to be honest demos: responsive's mode/density controls become stock buttons in a grid/column so they follow the modes they demonstrate instead of overflowing; dialog's openers stack vertically, and the example gains the app-level ESC handler so the ESC chain closes an open dialog first and quits second; widgets' tab strip now switches real per-tab pages; carousel gains pointer/touch drag through the horizontal-swipe hooks (crustace's pager pattern), one-tile-per-detent mouse wheel, and snap math driven by the real surface width from on_resize instead of a hardcoded 800; clip_path arranges its cells by ltk::orientation() and sizes them from the counter-axis of the flow.
2026-07-30 19:28:26 +02:00

11 KiB

Changelog

All notable changes to ltk are documented here. The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Unreleased

Added

  • ListItem::trailing_icon( rgba, w, h ) — right-aligned icon slot (disclosure arrow) drawn at TRAILING_ICON_SIZE (21 px) and vertically centered, alongside the existing leading icon. Coexists with trailing text, which shifts to the icon's left. Symbolic icons should be pre-tinted by the caller (tint_symbolic), matching the leading-icon contract.
  • ListItem::pad_h( impl Into<Length> ) — per-item override of the horizontal inset between the row edge and its content; without it the theme default (16 px) applies.
  • Row::align_top() / Row::fill_height() — pin children to the row's top edge instead of the default vertical centering, or stretch every non-spacer child to the row's inner height (the row itself is still sized by its tallest child), for siblings whose natural heights differ by a few font-metric pixels.
  • App::window_resizable() — return false to keep the min_size == max_size pin from window_size_hint for the toplevel's lifetime, declaring a fixed-size window compositors must not resize. Default true.
  • App::claims_raw_touch() — return true to receive the primary finger through the raw on_touch_down / move / up stream, bypassing the built-in single-slot gesture machine entirely (widget presses, taps and swipes stop working on touch), for surfaces that are one self-contained input consumer such as an embedded WebView or a game canvas.
  • Responsive sizing system with two selectable modes via WidgetScaling (Fluid / Physical; set_widget_scaling / widget_scaling, default Fluid). New Length constructors — orient( portrait, landscape ) (a percentage of the width in portrait, of the height in landscape), fluid( px ) (surface-proportional, calibrated against set_fluid_reference and bounded by FLUID_MIN / FLUID_MAX), dp( px ) (constant physical size scaled by set_density / density), and widget( px ) (picks fluid or dp per the active mode). Canvas::geom_px (geometry, physical layout space) and Canvas::font_px (font, bridging the logical / physical split per mode) give widgets and apps one resolution path.
  • Button::font_size / height / width and TextEdit::height builders, all impl Into<Length>, so control boxes scale with the surface. Text::line_height( mult ) opens the gap between wrapped lines. Separator::pad_v (with Length::px( 0.0 ) for a flush divider).
  • Performance guardrails: opt-in diagnostics via LTK_PERF_WARN=1 (stuck animation, sustained software-render animation, low poll_interval) and a ~30 Hz software-animation cap overridable with App::cap_software_animation.
  • ltk::orientation() / viewport_size() / set_viewport_size and the Orientation enum — the runtime records the main surface's physical dimensions on every configure, so view() can branch a layout on portrait vs landscape (match ltk::orientation() { … }) without tracking on_resize by hand; the portrait/landscape rule matches Length::orient (square counts as portrait). Embedders driving core::UiSurface directly call set_viewport_size themselves. examples/clip_path.rs demonstrates it.
  • test-support Cargo feature gates the test_support module so third-party builds never see it (ltk's own make test enables it).

Changed

  • OverlaySpec::size is now ( Length, Length ) (was ( u32, u32 )), resolved against the main surface when the overlay is materialized; wrap existing sizes in Length::px( … ) for the old fixed behaviour.
  • TextEdit::font_size, TextEdit::fixed_width and Separator::thickness now take impl Into<Length> (were f32), resolved like the button label (font space) / geometry space; the f32 sentinels are gone (f32 call sites still compile via Into<Length>).
  • Dependency pins: fontdue = "=0.9.3" and ignore = "=0.4.23" are pinned exactly because newer releases require a rustc newer than the declared Rust 1.85 MSRV (Debian stable's toolchain).
  • Renamed set_design_reference / design_referenceset_fluid_reference / fluid_reference. Length::dp changed meaning — it used to be a surface-proportional value, and that behaviour now lives on Length::fluid; dp is the constant-physical-size unit.
  • Widget struct fields are now pub( crate ) (configured through builders), except the value / state types apps read or construct (Time, Date, ComboState).

Fixed

  • Text inputs no longer insert mid-string when the value grows after focus. Focusing a text input pinned the cursor to a snapshot of value.len(); if the value kept growing without the widget seeing keystrokes (a field fed over IPC), the first normally-delivered key inserted at the stale position. The focus-time cursor is now an end-of-value sentinel that every consumer clamps to the current value length, collapsing to a concrete position on the first real keystroke or click.
  • Single-line caret height now follows the text line. The caret spanned rect.height - 16, so a field taller than its text line grew an oversized caret; it now measures font_size + 4 and is vertically centered like the text, matching the multiline caret.
  • Dialog action buttons no longer overflow the card on large surfaces. The card's width cap was a fixed 480 px while the stock buttons inside grow fluidly with the surface, so on windows past the design size the right-aligned action row ran off the card's right edge. Dialog::max_width now takes impl Into<Length> (f32 call sites keep compiling as fixed px) and the default is Length::fluid( 480.0 ), matching the buttons' scaling curve.
  • App::on_pointer_axis now triggers a view rebuild and repaint. The raw axis hook (wheel/touchpad outside any ltk scroll viewport) fired the app callback but never requested a redraw, so state mutated there (a wheel-stepped carousel, an embedder-scrolled canvas) did not repaint until the next unrelated event.
  • Dialog cards no longer double-pad their interior. The inner card column carried the column() 16 px default padding on top of the container's CARD_PADDING (24 px), giving the content 40 px of interior inset per side and squeezing the action row until its buttons clipped on narrow windows. The inner column is now flush and the interior inset is CARD_PADDING alone; the centering column's margin to the surface edges is explicit.
  • Time-picker digits no longer overflow their boxes. The editable digit fields paired a fluid font (font_size_fluid) with a fixed 72 px box, so on any surface where the fluid font resolved larger than its design size the glyphs outgrew the field. The box is now Length::fluid( 72.0 ) — the same curve and clamp factors as the font, so both scale in lockstep.
  • Content inside a scroll no longer renders smaller than the rest of the surface. Scroll viewports draw their child into a sub-canvas sized to the viewport rect, and fluid Length resolution (Canvas::geom_px / font_px — icon sizes, row heights, paddings, font sizes) resolved against that smaller canvas instead of the surface, shrinking everything inside any scroll by the width ratio (~13 % in a 360 px window with 24 px margins). Sub-canvases now inherit the root canvas's layout viewport (viewport_layout / viewport_logical), propagated through nested sub-canvases, so geometry resolves identically inside and outside offscreen content.

0.2.0 - 2026-06-25

This release adds the primitives an embedder needs to drive ltk as the render backend for a retained, externally-owned widget tree (for example projecting an Android view hierarchy onto an ltk surface). Each is kept general rather than tied to one consumer.

Added

  • Canvas::set_clip_path — anti-aliased clipping to an arbitrary vector path (&[PathCmd]) on both backends. The software backend installs a tiny-skia coverage mask; the GLES backend captures the clipped draws into an offscreen layer and composites them back through an anti-aliased coverage mask. Complements the existing rect clip (set_clip_rects) for shaped clips such as a circular avatar, a rounded card or a VectorDrawable mask. See examples/clip_path.rs.
  • Canvas::fill_path / Canvas::stroke_path over a new PathCmd command list (MoveTo / LineTo / QuadTo / CubicTo / Close, in surface coordinates) — renders an arbitrary vector path, a Path, a VectorDrawable or a Lottie frame. The software backend rasterises directly with tiny-skia; the GLES backend rasterises into a tiny-skia pixmap and uploads it, so both backends share the same path rasteriser and stay at visual parity.
  • Canvas::read_rgba_pixels — reads any canvas into tightly packed straight-alpha RGBA8 (top-left row first), on both the GLES and software backends (the software path un-premultiplies its pixmap). Canvas::is_software lets a caller branch on the backend (e.g. honour a real path clip on software but only a bounding rect on GLES).
  • measure_text( text, size ) (re-exported at the crate root) — measures one line with the default UI font and the system fallback chain, returning (width, line_height) in pixels without a live Canvas, for an embedder's measure pass that must match the renderer's metrics. Backed by a process-wide cached primary-font handle.
  • Stack::push_placed — appends a child at an exact rect, bypassing alignment and intrinsic sizing, so a view tree whose geometry is computed elsewhere can be projected onto a Stack in paint order. Stack::push_placed_clipped additionally clips the child's subtree to a rect (Android's clipChildren): overflowing content is not painted.
  • ExternalSource::Cpu and the External::cpu constructor — an immediate-mode CPU drawing closure invoked once per frame with the canvas and the widget's laid-out rect, working on both backends. Hosts a custom View.onDraw straight onto the ltk canvas without a GL texture round-trip, unlike the existing Texture source which only renders on GLES.
  • RichText widget — wrapped paragraph text carrying a Msg per clickable link range; the layout pass emits one hit rect per link line so taps land on the link rather than the whole paragraph. The ltk side of an Android Spanned carrying URLSpan / ClickableSpan.

Fixed

  • GLES clip-layer composite no longer renders path-clipped content vertically flipped: the offscreen layer was sampled at the inverted screen Y. The software backend was unaffected.
  • Gesture: the horizontal pager is driven only once the swipe axis locks horizontal. Previously the pre-lock lateral drift of a vertical gesture could arm the consumer's pager without a matching release event, which could freeze the surface until an unrelated gesture reset it.
  • Software/GLES parity: the software backend now snaps glyph pen positions and image destinations to integer pixels (rounding to nearest), matching the GLES backend. Previously it truncated, so text and 1:1 images could land up to half a pixel off between backends and sample ~1 px softer.

Changed

  • Default theme launcher SVGs replaced with renderer-compatible versions.

0.1.0 - 2026-03-10

Added

  • Initial release.