JFLib

plat/settings.rs#

Source: lib/plat/settings.rs

settings -- the user's system settings the UI follows

  sys_settings() -> SysSettings       the system's (Windows: system calls and the registry;
                                      Linux: the settings portal, at most 300 ms; elsewhere
                                      the defaults), then the jfgui_* overrides
  sys_settings_env() -> SysSettings   the defaults and the overrides only (headless runs)

Overrides (tests, shots, users): jfgui_THEME=dark|light, jfgui_ACCENT=RRGGBB,
jfgui_CONTRAST=high|normal, jfgui_REDUCE_MOTION=1|0, jfgui_TEXT_SCALE=PERCENT,
jfgui_DOUBLE_CLICK_MS=N, jfgui_CARET_BLINK_MS=N (0: a steady caret),
jfgui_FONT_AA=1|0, jfgui_FONT_HINTING=none|slight|medium|full,
jfgui_FONT_RGBA=none|rgb|bgr|vrgb|vbgr, jfgui_WHEEL_LINES=N|page, jfgui_WHEEL_CHARS=N.

The wheel (wheel_lines, wheel_chars: what a notch scrolls): Windows SPI_GETWHEELSCROLLLINES
(WHEEL_PAGESCROLL: a page) and SPI_GETWHEELSCROLLCHARS; KDE's [KDE] WheelScrollLines of
kdeglobals; GNOME, macOS, the browser and Android have no such setting (3 and 3).

Font rendering (font_aa, font_hinting, font_rgba; None: the system says nothing): Windows
SPI_GETFONTSMOOTHING, SPI_GETFONTSMOOTHINGTYPE (ClearType: subpixels) and
SPI_GETFONTSMOOTHINGORIENTATION; Linux the portal's org.gnome.desktop.interface
font-antialiasing / font-hinting / font-rgba-order, else what fontconfig's conf.d turns on
(10-hinting-*.conf, 10-sub-pixel-*.conf, 10-no-antialias.conf, 10-yes-antialias.conf).

The title bar the library draws (titlebar: the buttons and what clicks on the bar do): Linux
GNOME's org.gnome.desktop.wm.preferences button-layout, action-double-click-titlebar,
action-middle-click-titlebar, action-right-click-titlebar (the portal), else GTK's
gtk-decoration-layout / gtk-titlebar-*-click (settings.ini); Windows has none (its own title
bar and the system's snap / caption behaviour).  Overrides: jfgui_BUTTON_LAYOUT=LAYOUT (GNOME's
syntax, e.g. "close,minimize,maximize:"), jfgui_TITLEBAR_DOUBLE_CLICK / _MIDDLE_CLICK /
_RIGHT_CLICK=toggle-maximize|minimize|lower|menu|none.
  • struct HcColors the colours of a high-contrast scheme (0xRRGGBB)
    • bg: u32
    • text: u32
    • highlight: u32 -- selection, accent fills
    • highlight_text: u32
    • button: u32
    • button_text: u32
    • disabled: u32
    • link: u32

impl HcColors

  • const BLACK: HcColors = HcColors { bg: 0x000000, text: 0xFFFFFF, highlight: 0x1AE ... white on black (Windows "Night sky" / "HC Black")
  • const WHITE: HcColors = HcColors { bg: 0xFFFFFF, text: 0x000000, highlight: 0x370 ... black on white (Windows "Desert" / "HC White")
/// SysSettings::font_hinting
FONT_HINT_NONE: u8 = 0
FONT_HINT_SLIGHT: u8 = 1
FONT_HINT_MEDIUM: u8 = 2
FONT_HINT_FULL: u8 = 3
/// SysSettings::font_rgba: the order of a pixel's subpixels (none: greyscale smoothing)
FONT_RGBA_NONE: u8 = 0
FONT_RGBA_RGB: u8 = 1
FONT_RGBA_BGR: u8 = 2
FONT_RGBA_VRGB: u8 = 3
FONT_RGBA_VBGR: u8 = 4
  • fn font_hint_parse(s: &str) -> Option<u8> a FONT_HINT_* name ("none", "slight", "medium", "full"; also "hintnone" ... of fontconfig)

  • fn font_rgba_parse(s: &str) -> Option<u8> a FONT_RGBA_* name ("none", "rgb", "bgr", "vrgb", "vbgr"; "grayscale" is none)

/// Titlebar::buttons: the caption buttons of a title bar the library draws
TB_BTN_CLOSE: u8 = 1
TB_BTN_MIN: u8 = 2
TB_BTN_MAX: u8 = 3
/// Titlebar::double / middle / right: what a click on the empty part of the bar does
TB_ACT_NONE: u8 = 0
/// maximize, or restore a maximized window
TB_ACT_MAXIMIZE: u8 = 1
TB_ACT_MINIMIZE: u8 = 2
/// below the other windows (X11; Wayland has no request for it: nothing)
TB_ACT_LOWER: u8 = 3
/// the window manager's window menu (move, resize, always on top, ...)
TB_ACT_MENU: u8 = 4
  • struct Titlebar the buttons and click actions of a title bar the library draws (SysSettings::titlebar)

    • buttons: Option<([u8; 3], [u8; 3])> -- the buttons at the left end and at the right end, each side left to right (TB_BTN_*, 0 ends a side; each button at most once); None: the style's places
    • double: u8 -- TB_ACT_* of a double click, a middle click and a right click
    • middle: u8
    • right: u8
  • fn titlebar_layout_parse(s: &str) -> ([u8; 3], [u8; 3]) a button layout in GNOME's button-layout syntax (GTK's gtk-decoration-layout): the left side, ':', the right side, names separated by ','. close, minimize and maximize are kept, other names (appmenu, icon, menu, spacer) and repeats skipped; without ':' everything is the left side (as GTK reads it)

  • fn titlebar_action_parse(s: &str) -> Option<u8> a title bar action as GNOME names it (GDesktopTitlebarAction): toggle-maximize (also -horizontally / -vertically, which xdg-shell can not do: GTK treats them alike), minimize, lower, menu, none; toggle-shade is none (no compositor shades client-side windows)

  • struct SysSettings what the system says (see the module comment)

    • dark: Option<bool> -- None: no preference
    • accent: Option<u32> -- 0xRRGGBB
    • high_contrast: bool
    • contrast_colors: Option<HcColors> -- Windows: the colours of the active high-contrast scheme
    • reduce_motion: bool
    • text_scale: u32 -- percent, 100 = normal
    • double_click_ms: u32
    • caret_blink_ms: u32 -- one phase of the caret (on or off); 0 = steady
    • font_aa: Option<bool> -- font smoothing: Some(false) = off (sharp black-and-white glyphs)
    • font_hinting: Option<u8> -- FONT_HINT_*
    • font_rgba: Option<u8> -- FONT_RGBA_* (subpixel smoothing and its order)
    • titlebar: Titlebar -- the title bar the library draws (Linux client-side decorations, AF_CUSTOM_TITLEBAR)
    • wheel_lines: u32 -- lines a notch of the wheel scrolls (1..=100), WHEEL_PAGE: a page (Windows SPI_GETWHEELSCROLLLINES, KDE's WheelScrollLines; elsewhere 3)
    • wheel_chars: u32 -- characters a notch of the horizontal wheel scrolls (1..=100; Windows SPI_GETWHEELSCROLLCHARS; elsewhere 3)
/// SysSettings::wheel_lines: a notch of the wheel scrolls a page
WHEEL_PAGE: u32 = u32::MAX
  • fn wheel_amount(n: u32) -> u32 a number of lines or characters per notch as the system says it: 1..=100, the page (WHEEL_PAGE, Windows' WHEEL_PAGESCROLL) kept; 0 (Windows: the wheel does not scroll) is 1

  • fn sys_settings() -> SysSettings the system's settings and the jfgui_* overrides

  • fn sys_settings_env() -> SysSettings the defaults and the jfgui_* overrides only (headless runs stay the same everywhere)

Source: docs/API.md in the JFLib repository.