Skip to main content

Crate yog_kit

Crate yog_kit 

Source
Expand description

yog-kit — MVVM screens for Yog mods.

A screen is a .yui file with x:ViewModel="MyVm" plus a plain Rust view model. yog build compiles the markup into a View (widget tree, compiled {x:Bind ...} bindings, command dispatch) and this crate hosts it: it owns the view model, re-evaluates bindings after every change, routes input (clicks, hover, scrolling, text boxes, Tab focus, list keyboard selection, Esc) and draws the result.

ⓘ
// src/counter.rs, next to src/counter.yui
yog_api::ui_include!("counter");
use yog_kit::prelude::*;

#[derive(Default)]
pub struct CounterVm { count: u32 }
impl ViewModel for CounterVm {}
impl CounterVm {
    pub fn increment(&mut self) { self.count += 1 }
}

// src/lib.rs: counter::register(registry); ... counter::open();

The view model never touches widgets: the markup binds to its fields and methods, and commands call its methods. testing::TestHost drives a screen without the game.

Modules§

bind
Binding helpers used by generated .yui code: a Slot remembers a binding’s last value so widgets are only patched when it changes, and the conversion functions turn view-model values into widget values with readable compile errors.
items
Lists: an ItemsHost keeps one template instance per item of an ItemsControl / ListView / ContentPresenter, reconciled by key, so an update only patches what changed. With a fixed item_height only the rows in (and near) view are built — the rest are two spacers.
prelude
Everything a code-behind file needs.
testing
Driving a screen in unit tests — no game, no graphics.

Structs§

Action
A typed click target: owner 0 = the screen, k = items control k; slot = the command (or Action::SELECT); index = the item index inside an items control (0 elsewhere).
Cx
What a command or view-model hook can ask of its screen. Requests run right after the call returns.
ListPart
One list (ListView / ItemsControl) of a view.
Parts
The interactive parts of a view, created by View::build: scrollers, text boxes, lists, and the Tab focus order. Indices are the order they were added.
Screen
Hosts the compiled view W as a Yog screen.
ScreenHandle
A cloneable, thread-safe handle to a registered screen’s view model.
ScreenMeta
Static facts about a screen, from its <Screen> attributes.
ScrollerPart
One scrolling container of a view.
StateFlags
Interaction state bits of a widget — see Widget::state.
TextBoxPart
One text box of a view.
Update
What a View::update changed, plus what it can ask of the host.
Viewport
A scroller’s visible window during an update.
Widget
A single widget in the UI tree.

Enums§

Anchor
Where a screen’s content sits in the GUI.
ViewEvent
Input for a view’s View::dispatch, produced by the host.

Traits§

View
A compiled screen — implemented by .yui codegen only.
ViewModel
A screen’s state and logic. Implement it (often with no methods) for the type named by the .yui file’s x:ViewModel.

Functions§

handle_of
The handle of the registered screen W.