Skip to content

CPUI 0.1.4

Latest

Choose a tag to compare

@github-actions github-actions released this 06 Dec 07:29
· 1 commit to dev since this release
ab9f150

Text shaped by the full OpenType rules, segmented controls, reorderable lists, undo in text inputs, 2D vector paths, pinch to zoom, rounded clipping, desktop portal file dialogs on Linux, system font smoothing on Windows, and frameless, transparent and background-running apps.

Added

  • Ui::reorderable shows a list the user reorders by dragging an item past the middle of its neighbors, which slide out of its way, or with Alt and an arrow key; Escape puts it back, the list scrolls at an edge, and each item answers as one control, so that tabs are clicked and dragged. (#250)
  • Ui::segmented chooses exactly one of a few options side by side, with a card that slides to the chosen one; segments take icons and badges, and narrow away or widen back when hidden or shown; it comes in three sizes, equally wide with w_fill, and screen readers read it as a radio group. (#246)
  • ToggleGroup::aria_label names a toggle group for screen readers, as Segmented::aria_label does. (#246)
  • Options::app_id identifies the application to the desktop: the Wayland app_id and X11 WM_CLASS that match its .desktop file on Linux, and the AppUserModelID of the taskbar on Windows. Without it, Wayland now also takes the executable's name, as X11 did, so the desktop shows the application's icon and keeps it pinned. (#245)
  • Ui::file_dialog_outcome tells how a file dialog closed: with the chosen paths, cancelled, or unavailable where the system cannot show one. (#243)
  • Text inputs undo and redo with Command / Ctrl + Z and Command / Ctrl + Shift + Z, or Control + Y outside Apple platforms, which Key::Undo and Key::Redo name. (#231)
  • Ui::copy_image writes an image to the clipboard on Windows, macOS, iOS and Linux, made with ClipboardImage::from_png or, with the png feature, ClipboardImage::from_bitmap. (#226)
  • Tree::selection selects several items of a tree into a BTreeSet, with the clicks and keys of Table::selection. (#226)
  • Bitmap::from_webp, behind the optional webp feature, decodes lossy, lossless and animated (first frame) WebP images to 8-bit RGBA. (#226)
  • Ui::pinch_on gives a widget a two-finger pinch on a touch screen or a macOS or Windows trackpad, or Command (Control outside Apple platforms) with the wheel, as a factor and a center to zoom about. (#225)
  • Container::both_axes makes a scroll area scroll down and across at once, moved diagonally by a trackpad or finger, and Ui::scroll_offset_x and Ui::set_scroll_offset_x read and set how far across. (#225)
  • Painter::fill_path and Painter::stroke_path, and the same methods on Frame, draw a Path of lines, Bézier curves and arcs, filled by a FillRule or stroked with a StrokeStyle of width, caps, joins and dashes. (#146)
  • Shortcut::to_text writes a shortcut as Shortcut::parse and keymaps read it, such as mod-shift-s, for a library that registers system-wide shortcuts or menu accelerators; a key without a name gives None. (#214)
  • Ui::request_repaint_after draws a frame once a delay has passed and none before it, for a clock or a time such as "5 min ago", instead of drawing every frame. (#204)
  • Ui::hover_card shows rich content, such as a person's details, while the pointer rests on a trigger or the keyboard focuses it, and stays open while the pointer moves into it. (#204)
  • Ui::set_toast_insets keeps toasts clear of bars the app draws along the edges of the window, such as a title bar of its own. (#204)
  • AppControl::focus_window brings an open window to the front from App::update, such as on a click on a tray icon, restoring it if minimized. Opening a window that is already open also restores it now, and on macOS brings the app forward, unless it was opened with Options::focused(false), which comes back without taking the keyboard. (#193)
  • middle_clicked_key on rich text returns the key of a link or tag clicked with the middle button, such as to open it in a new tab, without taking focus, and key_with_response returns the key of either click with the paragraph's Response, whose clicked tells which. (#201)
  • Ui::scroll_offset tells how far a scroll area or list is scrolled, and Ui::set_scroll_offset scrolls it to a given offset in the same frame, for example to open it where the user left off. (#196)
  • Ui::minimize_window, Ui::set_window_maximized, Ui::window_maximized and Ui::window_focused let a title bar of the app's own, in a window opened with Options::decorations(false), minimize, maximize and restore the window and show whether it is maximized or active, as the system's does. (#157)
  • Ui::clipboard_image reads an image on the clipboard, such as a screenshot, as PNG with its size on Windows, macOS, Linux and iOS, and Response::pasted and Ime::pasted report a paste into a text input or a canvas that takes text even when the clipboard holds no text, so a message box can take pasted images. (#156)
  • Ui::drag_source and Ui::drop_target drag a value from one widget onto another in a window, such as to reorder tabs, starting from a long press on a touch screen; a drag near the edge of a scroll area scrolls it, and Ui::take_dropped_outside takes one dropped outside the window. (#147)
  • Ui::submenu declares a row of a menu or popover that opens another menu beside it, on hover, a click or the arrow keys; crossing other rows on the way to it keeps it open. (#145)
  • Options::zoom and Ui::set_zoom scale the whole interface in every window, from 0.5 to 3, as the zoom of an editor does. (#145)
  • CursorIcon has the system's other pointer shapes, such as diagonal resizing, moving, a crosshair, waiting and zooming; where a system has no such shape, the arrow shows. (#145)
  • middle_clicked on a widget and its Response reports a click of the middle button, such as one that closes a tab, and a list or table reports one on any of its rows. (#144)
  • Ui::back_pressed and Ui::forward_pressed report the Back and Forward buttons of a mouse or a keyboard. (#144)
  • Key::Insert is the Insert key, and outside Apple platforms Control + Insert copies, Shift + Insert pastes and Shift + Delete cuts in text. (#144)
  • Text follows the system's text size on Windows, Android, iOS and GNOME under Wayland: font sizes, line heights and the heights of controls and rows grow with it, headings less than body text; Options::text_scale and Ui::set_text_scale fix it instead, and Theme::with_text_scale scales a theme the same way. (#134)
  • line_clamp on text and rich text wraps them to at most a given number of lines, ending the last with an ellipsis when the text goes on, such as in a message preview. (#131)
  • An app, such as one in the tray or menu bar, can start without a window with run_in_background, keep running after its windows close, and open them again from App::update, including when its Dock icon is clicked on macOS. (#130)
  • line_height on text, rich text and containers sets the height of each line of text, so that a layout can match a given line spacing; headings and the text of built-in widgets keep their own. (#128)
  • Options::decorations(false) opens a window without the system's title bar and border, which is still resized by its edges and moved with Container::drag_window. (#133)
  • Options::transparent(true) opens a window that shows what is behind it wherever the interface draws nothing, on Windows, macOS and X11 with a compositing manager, and Renderer::set_transparent makes a renderer keep per-pixel alpha. (#133)
  • Options::click_through and Ui::set_click_through let the pointer through a window to what is behind it, as for an overlay. (#133)
  • Ui::window_position, Ui::set_window_position and Ui::set_window_size tell where a window is and move and resize it, for example to open it where it was last. (#133)
  • Options::focused(false) opens a window without giving it the keyboard focus on Windows and macOS, and Options::skip_taskbar(true) leaves it out of the taskbar on Windows. (#133)
  • Offscreen::new_transparent creates a target that draws no window background and keeps per-pixel alpha, for a host that composites the interface itself, such as a texture over a game scene. (#121)
  • On Linux, text also follows the desktop's font settings, such as those its settings app changes, and updates as soon as they change, while fontconfig's rules for a font still take precedence. (#123)
  • On Linux, text follows fontconfig's settings for each font and size, including subpixel antialiasing on LCD displays, and Ui::set_text_antialias chooses grayscale or subpixel text for a window. (#107)
  • Ui::with_theme builds and paints part of the window with another theme, such as a denser toolbar, without changing the app's themes or costing another build pass. (#105)
  • Renderer::scroll_next_frame declares that the pixels of an area move in the next frame, so that they are copied instead of drawn again, and only what comes into view is drawn. (#97)

Changed

  • On Windows, text following the system takes its font smoothing: ClearType in the chosen stripe order, standard smoothing in grayscale, or none, and follows changes at once. (#244)
  • On Linux, file dialogs open through the desktop portal, which also works in Flatpak, over their window on X11 and Wayland and titled in the app's language (Locale::open_file, open_folder and save_file), and fall back to zenity or kdialog; their filters match extensions in any case, as elsewhere. (#243)
  • Clipping containers (overflow_hidden, scroll areas and lists) with a corner radius now clip their children to the rounded corners, inside any border. (#238)
  • Lines break where the Unicode line breaking rules allow, also after hyphens and at zero-width spaces, and never inside numbers such as 1,000.5 or at no-break spaces; Chinese and Japanese keep their strict rules for punctuation and small kana. (#230)
  • Emoji follow Unicode 18: newer emoji show in color, and a skin tone joins only an emoji that takes one. (#230)
  • Bitmap::from_png and ClipboardImage::from_bitmap no longer need the png feature, which now does nothing: PNG images are decoded and encoded without another dependency. (#230)
  • Text is shaped by the full OpenType and Apple layout rules: Indic, Sinhala, Khmer, Myanmar, Thai and other scripts join and place their marks as the system does, Thai on macOS uses the system's own font, and the hello executable grows from 2.4 MB to 2.8 MB. (#230)
  • In a scroll area or list inside another, a wheel, trackpad or touch gesture that reaches its edge stops there, and the next one moves the area around it; scrolling inside a popup or dialog still never moves the page under it. (#225)
  • Blending a capture, as a dialog does while it fades and zooms, no longer allocates each frame. (#212)
  • Wrapped labels keep their measured widths and lines from one frame to the next until their text, font or width changes, so a frame of 2,000 unchanged ones takes 0.4 ms instead of 6.4, and scrolling a feed of cards takes a third of the time. (#210)
  • Soft shadows blend the part of each row at full strength in one go, and on x86-64 the rest with AVX2 where the processor has it: at 2×, a shadow the size of the window draws in about 1.1 ms instead of 3 on Apple silicon and 11 on x86-64, where a frame of 800 small cards with shadows also takes 31 ms instead of 66. (#210)
  • Scrolling content covered largely by shadows copies the pixels already drawn at any display scale, such as 1.25×, 1.5× and 3×, not only at 1×, 2× and 4×: on a 3.25× phone screen, a frame of a scrolling feed of cards takes about 0.9 ms instead of 2.1. (#190)
  • A transparent window or offscreen target redraws only what changed, and draws it once instead of twice, so it costs about as much as an opaque one: at 1920 × 1080 and 2×, changing one label takes 0.2 ms instead of 31 ms. (#175)
  • A mouse wheel scrolls smoothly: each notch eases over 125 ms instead of jumping, notches in a row add up, and a press stops the scrolling where it is. Trackpads scroll as before, and with the theme's motion at 0 a notch jumps. (#200)
  • On Android, a frame paints and copies into the window only what changed, instead of the whole window through softbuffer, so on a 1080 × 2424 screen a frame takes about 8 ms instead of 16, enough for 120 Hz. (#153)
  • Wrapping text with few spaces, such as Chinese, measures most of it once instead of twice, so a frame of 2,000 Chinese labels takes about a third less time. (#125)
  • A finger no longer hovers: controls under it show no hover look and their hovered() stays false, and a scrollbar shows only while its area scrolls; a mouse hovers again as soon as it moves. (#102)
  • Scrolling with a finger, or scrolling a page that holds other scroll areas, builds each frame once instead of twice. (#99)
  • Scrolling content covered largely by shadows, such as a feed of cards, at a scale of 1, 2 or 4, copies the pixels already drawn and draws only what comes into view, which makes it more than 4 times faster at 6K. (#97)

Fixed

  • Devanagari text with a reph, such as र्क, no longer drops the reph or panics, and emoji joined into one, such as families, show as one picture on Windows. (#230)
  • Variable fonts with an optical-size axis are drawn at the size the font maps each text size to, instead of past the end of the axis for text smaller than the font's smallest optical size. (#230)
  • On Windows and Linux, text keeps an even weight from size to size at scales such as 125% and 175%, and in large Chinese, Japanese and Korean text: glyphs are hinted only at whole pixel sizes where the font asks for it. (#228)
  • Alert dialogs keep the chosen button focused after a click on the backdrop or empty padding, so Enter and Space continue to activate it. (#213)
  • Checkerboards draw squares at least a pixel and at most the whole area wide, opaque or translucent, instead of panicking on very large squares or stalling on very small ones. (#213)
  • Toasts at the top of the window no longer cover an integrated title bar. (#204)
  • A table whose rows shrink past its selected row deselects it, instead of selecting the record that later takes that place. (#204)
  • Images drawn smaller than their bitmap, such as photo thumbnails, are smooth instead of grainy, and redraw as fast as before: each size is made once and kept while shown. (#159)
  • An arc drawn with Stroke::Arc at angles more than a turn and a half from 0, as a spinner's become, is drawn whole instead of as its two round ends. (#202)
  • A box with a plain background drawn over something declared before it, in a stack or moved with .offset(), covers it instead of showing it through its background. (#202)
  • On macOS, a window opened with Options::focused(false) no longer takes the keyboard when it appears. (#193)
  • Screen readers can switch and focus a checked menu item, and read its text once instead of twice. (#201)
  • A click in text on a letter written with a combining accent, or on an emoji made of several, such as a family, places the caret before or after it instead of inside it, where typing split it apart. (#201)
  • A click on an image, icon, avatar, badge or key in a card or row clicked as a whole clicks the card, as one on its text does, instead of nothing; they still show their tooltips. (#196)
  • Calling Ui::scroll_to_row or Ui::scroll_to_end every frame, such as to keep a selected row in view, lets the window idle instead of drawing frame after frame. (#200)
  • A table row, list row or combobox option taller than the visible area shows its start, not its end, when it is selected or scrolled to. (#200)
  • Slowly scrolling away from the end of a stick_to_end scroll area or list no longer snaps back to the end when a frame's step is within one logical pixel. (#200)
  • On Linux, large text copied in another app, which it sends in parts, is pasted instead of nothing. (#156)
  • On Windows, Hangul shows in Malgun Gothic instead of as empty boxes when the fonts in use lack it. (#155)
  • Text drawn as outlines with OutlineFonts, such as in SVG images, shows scripts no requested or fallback font has, such as Thai or Devanagari, in the font the system picks for them, as other text does. (#155)
  • On Android, keys an input method sends as key events reach the text input instead of being dropped: Enter, Backspace, characters such as digits, the arrows, Home, End, Page Up, Page Down, forward Delete and Tab. (#152)
  • Tapping or long-pressing outside a flinging scroll area, or on an overlay above it, no longer stops the fling or swallows the press. (#151)
  • Scrolled content on half physical pixels, such as at quarter logical pixels at 2×, stays on the pixels a full redraw puts it on as it scrolls past the top or left of the window, instead of one pixel off. (#100)
  • What the interface shows from Input::shift or Input::command, such as a hint while Shift is held, also updates when the key is released on its own. (#144)
  • A table without selected bound keeps the row last chosen: it stays highlighted, the arrow keys move from it, Enter activates it, and choosing it again is not a change. (#138)
  • A press on a widget over a combobox, such as a field in a dialog or popup, or over a combobox scrolled out of view, goes to that widget instead of focusing the combobox. (#136)
  • A click on the arrow of a select or combobox, or on the check of a chosen option or menu item, acts as a click elsewhere on the field or the row. (#136)
  • A number input in a row sized to its content is as wide as its widest value, instead of narrowing to a sliver that hides the value. (#134)
  • A frame redrawn whole after Offscreen::invalidate or a change of fonts or text antialiasing reports its whole area in FrameOutput::damaged instead of 0. (#133)
  • On Android, request_repaint redraws on each display refresh instead of on a 60 Hz timer, and on Windows and Linux the time between animation frames no longer grows by the time a frame takes to draw. (#132)
  • The Copy icon draws its back sheet's edges at full length, so it reads as two stacked sheets at small sizes, as the Files icon does. (#129)
  • A canvas or custom area declared opaque inside a container with opacity below 1 blends over the window background instead of black or an earlier frame. (#122)
  • Clicking the close button on a toast with an action no longer triggers its action, conflates hover and focus between the two buttons, or hides the close button from assistive technology. (#104)
  • Images rebuilt in the same pixel allocation now show their new pixels immediately. (#117)
  • Starting input method composition or moving to the end of a line after trailing spaces in a multiline text input no longer panics or places the caret before the spaces. (#94)
  • Starting to scroll with a finger on a text input or another control no longer presses or focuses it, and a control now looks pressed while a finger rests on it and briefly after a tap. (#98)
  • Shift selection in a table starts at the new target after the previous anchor row is removed. (#118)
  • A space after an emoji is as wide as other spaces, and text drawn or measured in parts with Frame::text_in, Frame::measure_in or Frame::advances_in adds up to the whole, keeping kerning and squeezed punctuation across the parts. (#96)
  • After Renderer::set_fonts, text in a variable font with an optical-size axis uses the optical sizes of the new font, not those cached for the old one. (#96)
  • A drawer stays open while its grip is held outside the window and returns to rest if the drag is cancelled. (#119)