Crate wiard

Crate wiard 

Source
Expand description

Window handing library for Windows in Rust

§Simple examples

§sync version
fn main() {
    let mut event_rx = wiard::EventReceiver::new();
    let _window = wiard::Window::builder(&event_rx)
        .build()
        .unwrap();
    loop {
        let Some((event, _)) = event_rx.recv() else {
            break;
        };
        println!("{event:?}");
    }
}
§async version
#[tokio::main]
async fn main() {
    let mut event_rx = wiard::AsyncEventReceiver::new();
    let _window = wiard::Window::builder(&event_rx)
        .await
        .unwrap();
    loop {
        let Some((event, _)) = event_rx.recv().await else {
            break;
        };
        println!("{event:?}");
    }
}

§Note

wiard use WM_APP. Don’t post directly WM_APP to wiard’s UI thread.

Modules§

api
collision
event
geometry
ime
keyboard
menu
mouse
notify_icon
style
utility

Structs§

AsyncEventReceiver
This object which receives an event from UI thread.
AsyncInnerWindow
Represents an inner window of async version.
AsyncWindow
Represents a window of async version.
BorderlessStyle
Represents a borderless window style.
Builder
EventReceiver
This object which receives an event from UI thread.
FileDialogOptions
Represents options of dialogs.
FileOpenDialog
A dialog for specifying a file (or files) to open.
FileSaveDialog
A dialog for specifying a file to save.
FilterSpec
For specifying an extension in dialogs.
InnerWindow
Represents an inner window.
InnerWindowBuilder
Builds a inner window.
KeyCode
Menu
Represents a vertical menu.
MenuBar
Represents a horizontal menu.
MenuBarItem
Represents a item for MenuBar.
MenuHandle
Represents a menu handle. MenuHandle can compare with a MenuBar and a Menu.
MouseButtons
MouseState
MouseStateVirtualKeys
NotifyIcon
Position
Rect
ScanCode
Size
UiThread
Represents UI Thread.
Window
Represents a window.
WindowBuilder
Builds a window.
WindowHandle
WindowStyle
Represents a window style.

Enums§

AsyncWindowKind
Represents AsyncWindow or AsyncInnerWindow
ColorMode
Represents a color mode.
ColorModeState
Represents a color mode state.
Cursor
Represents mouse cursors.
Error
The error type for Windows apis, std::io and an UI thread state.
Event
Represents a event.
Icon
Represents icons.
KeyState
MenuItem
Represents a item for a Menu.
MouseButton
MouseWheelAxis
NcHitTestValue
Values which can return from WM_NCHITTEST
NotifyIconEvent
ResizingEdge
An moving edge of window when resizing.
TryRecvError
The error type for EventReceiver and AsyncEventReceiver.
VirtualKey
WindowKind
Represents Window or InnerWindow

Constants§

DEFAULT_DPI
WHEEL_DELTA
This value is a multiple of wheel value.

Traits§

Collision
FilterSpecs
For specifying extensions in dialogs.
IsReceiver
EventReceive and AsyncEventReceiver are implement this trait.
IsWindow
Window and AsyncWindow are implement this trait.
Style
Window styles are implement this trait.
ToLogical
ToPhysical

Functions§

client_to_screen
contains
get_cursor_pos
is_crossing
is_system_dark_mode
Check the dark mode in Windows.
screen_to_client
shutdown
Shutdown UI thread.

Type Aliases§

AsyncRecvEvent
The async version type of receiving event from UI thread.
ButtonState
LogicalPosition
LogicalRect
LogicalSize
PhysicalPosition
PhysicalRect
PhysicalSize
RecvEvent
The type of receiving event from UI thread.
Result
This type is Result<T, wiard::Error>.
ScreenPosition
TryRecvResult
This type is Result<T, wiard::TryRecvError>.