Skip to content

v0.10.0

Latest

Choose a tag to compare

@github-actions github-actions released this 25 Nov 20:14

Added

  • Input methods: dead keys, and Chinese, Japanese and Korean IMEs.
    EventCtx::set_ime_area is how the focused widget says it takes text, and
    where its caret is; the runtime then lets the platform's input method at
    the keyboard — winit's on macOS, Windows and X11, zwp_text_input_v3 on
    Wayland — anchors its candidate window at the caret, and turns it off once
    the focus has moved on. Composed text arrives as Event::Ime: an
    Ime::Preedit to show at the caret while it is being composed, an
    Ime::Commit to insert. TextInput, NumberInput and TextEditor take
    it, showing the composition underlined at the caret; MockBackend's
    DispatchOutcome::ime_area and MockBackend::ime_area / probe_ime let
    a test see whether the input method would be on. (#121)
  • Native menu bars. App::with_menu_bar takes the app's main MenuBar
    rather than the widget tree: on macOS it becomes the system menu bar at the
    top of the screen, built from NSMenus, and the root gets the whole
    window; on Windows, X11 and Wayland the runtime puts it in the window above
    the root, as the app's own Column would have. On a Mac each item mirrors
    its MenuItem — title without the &, accelerator as its key equivalent
    (⌘ for primary), with_enabled and with_checked read live — and its
    callback runs with an EventCtx like any event's. The application menu
    (About, Settings…, Services, Hide, Quit) and a Window menu come with it;
    Quit closes the window as its close button does unless the app has a Quit
    item of its own. While a dialog or popup of saudade's is open the app's
    items are disabled, so ⌘C or ⌘V reach the dialog, and a disabled item lets
    its key go on to the focused widget, as an in-window accelerator does.
    (#120)
  • MenuItem::with_role and MenuRole (About, Preferences, Quit): on a
    Mac an item with a role moves into the application menu, as "About
    ", "Settings…" (⌘,) and "Quit " (⌘Q), taking the separators it
    would leave dangling with it. Elsewhere a role changes nothing. (#120)
  • MenuBar::with_app_name, the program's name in the macOS application menu
    — the executable's file name otherwise, for a program not run from a
    bundle. (#120)
  • MenuBar::above(root): the bar across the top of a window above root, as
    App::with_menu_bar puts it everywhere but macOS — to render such an app
    offscreen with MockBackend, or to keep the bar in the window on a Mac.
    (#120)
  • WindowConfig::position opens the window at a given spot on the desktop,
    and EventCtx::window_position tells where it is now, so an app can put
    its window back where the user left it. Both are in the platform's logical
    coordinates; Wayland has neither. (#118)
  • EventCtx::request_tick_at and request_tick_after: a timer. The runtime
    sleeps until the earliest deadline any widget asked for and dispatches one
    Event::Tick then, so a caret can blink, an autosave wait out a pause in
    the typing or a clock step once a second without the ~60 Hz tick stream of
    wants_ticks keeping the process awake. MockBackend's
    DispatchOutcome::tick_at reports the deadline a dispatch asked for. (#117)
  • Waker, from App::waker: wakes the event loop from another thread, or
    from a callback the operating system makes into the program, and has it
    dispatch an Event::Tick to the widget tree. (#117)
  • NamedKey::ContextMenu, the Menu key of PC keyboards, for opening a
    context menu from the keyboard. (#116)
  • Font::metrics (and FontMetrics) gives a face's ascent, descent and line
    gap at a size, to put text on a baseline and space lines the way the font
    wants. (#114)
  • Font::system hands out the system font the runtime draws a family in,
    loaded once and shared, so an app can measure text outside a paint pass —
    laying out a document while handling a key, say — with the very advances it
    will be drawn with. (#114)
  • SavedClip, the state Painter::push_clip hands back, is exported, so a
    widget that pushes a clip in one method and pops it in another can keep it
    in a field. (#113)
  • Painter::fill_polygon, fill_polygon_rings, line and fill_ellipse
    draw anti-aliased shapes at run time — slanted and curved edges, at any
    angle and scale — with the rasterizer include_svg! images are filled with.
    (#112)
  • The platform's keys for the far ends in TextEditor and TextInput. On
    macOS ⌘← / ⌘→ jump to the start / end of the line, and in a TextEditor
    ⌘↑ / ⌘↓ to the start / end of the text; elsewhere Ctrl+Home / Ctrl+End
    reach the ends of a TextEditor's text. Shift extends the selection, as
    with any move. ModifierScheme::arrow_jump_held and text_end_held tell
    a widget of your own which applies. (#108)
  • Theme::scroll_track, the ink of the checkerboard in a scrollbar's
    track. It defaults to black, as before; a theme that sets it to its
    highlight gets the paler track of later Windows. (#107)
  • TextEditor::with_unfocused_caret(false) and
    with_unfocused_selection(false) (or their set_ counterparts) hide the
    wedge an editor without the focus draws at its caret, and its selection,
    for windows where only the focused editor should show them, as on
    Windows. A hidden selection is kept and shows again with the focus. (#105)
  • TextEditor opens an editing menu on a right-click, as a Windows edit
    control does: Undo, Cut, Copy, Paste, Delete and Select All, greyed where
    they don't apply. TextEditor::with_context_menu(false) (or
    set_context_menu) turns it off. (#103)
  • Horizontal scrolling in TextEditor. The view now follows the caret
    sideways along a line wider than the field, and a trackpad's horizontal
    scroll moves it. TextEditor::with_horizontal_scrollbar(true) (or
    set_horizontal_scrollbar) adds a scrollbar along the bottom edge, with a
    blank square in the corner where it meets the vertical one. (#101)
  • Undo and redo in TextEditor: Ctrl+Z takes back the last edit and
    Ctrl+Shift+Z (or Ctrl+Y) restores it, with ⌘ in Ctrl's place on macOS —
    where ⌘Y is left alone. undo(), redo(), can_undo() and can_redo()
    do the same for an Edit menu. A run of typing, of Backspaces or of Deletes
    is one step; the history holds a thousand steps and is forgotten by
    set_text. The notepad example's Undo and Redo items now work. (#100)
  • TextEditor::delete, has_selection and is_empty, the rest of what an
    Edit menu needs: Delete removes the selection without going through the
    clipboard, and the two queries tell the menu which items to grey. (#102)
  • TextEditor::with_read_only / set_read_only / is_read_only: a
    read-only editor shows text the user can select, copy and scroll but not
    change — for output and log boxes. It still takes the focus and keeps its
    caret; set_text keeps working. Its paper is tinted a touch towards the
    theme's face, to tell it from an editable box. (#99)
  • On a Wayland compositor that leaves decorating windows to the program —
    GNOME's Mutter, and any without zxdg_decoration_manager_v1 — saudade draws
    the Canoe-style title bar, frame and drop shadow that render_framed puts
    around screenshots, around its windows and dialogs. They move, resize,
    minimize, maximize and close the window, and bring up the compositor's window
    menu. SAUDADE_DECORATIONS=client draws them where the compositor would draw
    its own. (#111)

Changed

  • Event has a new variant, Event::Ime, which a match without a
    catch-all has to handle; Event::is_keyboard counts it, so containers
    route it to the focused widget like Char. After a key, a click or a drop
    the runtime — and MockBackend::dispatch — now sends the focused widget
    the composition in progress as an Ime::Preedit (an empty one when there
    is none) to learn whether it still takes text: a widget that doesn't care
    ignores it. (#121)
  • MenuItem::Action has a role field. Code that builds the variant
    directly rather than through MenuItem::action has to give it one
    (role: None). (#120)
  • A Column nested in another container passes a focus change from its
    parent on to its focused child, so that child shows the focus going and
    coming back rather than keeping its caret while, say, a menu of the parent's
    owns the keyboard. (#120)
  • The notepad example hands its menu bar to App::with_menu_bar, gives its
    items the usual shortcuts and greys Cut and Copy without a selection.
    (#120)
  • The root widget's on_cancel now also runs when something other than the
    window's close button ends the app — ⌘Q in the default macOS application
    menu, a logout — so an app always gets a last chance to save. (#119)
  • WindowConfig has a new public field, position, so code that builds one
    as a struct literal must now set it; WindowConfig::new is unaffected.
    (#118)
  • NamedKey has a new variant, ContextMenu, which a match without a
    catch-all has to handle. (#116)
  • render_framed centers the window title on the title bar and sets it in
    bold, as Canoe does. (#111)

Fixed

  • Dead keys compose in text fields on macOS: ⌥E then E types é, as does
    the German layout's ´ then E, where they typed nothing or a plain e.
    winit only runs the Mac's text input for a window that allows an input
    method, which saudade's never did. (#121)
  • On macOS, text typed with the Option key reaches the widgets: ⌥L for @,
    ⌥5 for [ on a German keyboard and the like were dropped, Option counting
    as a command modifier. Modifiers::suppresses_text says which modifiers
    make a keystroke a command on the platform at hand. (#115)
  • A quick click shows. A tap on a trackpad set to tap-to-click reports its
    press and release together, so both reached the widgets before a frame
    was painted in between: a Button ran its action without ever looking
    pressed. A release that follows its press by less than 60 ms is now held
    back until the press has been on screen that long (macOS, Windows, X11).
    (#110)
  • With a menu open, Alt and another menu's letter now switch to that menu,
    as they open it from a closed bar. An open menu used to keep every letter
    for its own items, so Alt+E did nothing under File, or fired whichever
    File item had an E for a mnemonic. (#109)
  • A child's popup closed from the keyboard — Escape on an open Dropdown or
    context menu inside a Container, Row or Column — left that container
    holding the pointer for it. Until the pointer next moved, a menu bar's
    accelerators and a default button's Enter stayed switched off, and the
    first press went to the closed popup's owner instead of where it landed.
    (#104)
  • TextEditor::cut and paste — and the new delete, undo and redo —
    left the view where it was, so an edit made from an Edit menu or its
    accelerator could put the caret out of sight: paste a long text and the
    editor kept showing its top. They now scroll to the caret, as the same
    edits made from the keyboard always did. (#106)
  • TextEditor painted a line wider than the field straight across its right
    border, the scrollbar and whatever lay beyond. Text is now clipped to the
    inside of the field. (#101)