Expand description
A window library in Rust for Windows.
wita is a library that create a window and run an event loop.
It is only for Windows.
§Example
struct Application;
impl Application {
fn new() -> Result<Self, wita::ApiError> {
wita::Window::builder()
.title("hello, world!")
.build()?;
Ok(Self)
}
}
impl wita::EventHandler for Application {
fn closed(&mut self, _: wita::event::Closed) {
println!("closed");
}
}
fn main() {
wita::run(wita::RunType::Wait, Application::new).unwrap();
}§Event handling
You must implement EventHandler for the your defined object, and can handle events in the impl EventHandler.
Next, pass the your defined object to run.
struct Foo {}
impl Foo {
fn new() -> Result<Self, wita::ApiError> {
wita::Window::builder().build()?;
Ok(Self {})
}
}
impl wita::EventHandler for Foo {
// You define handlers.
// For example, handle the event that closed the window.
fn closed(&mut self, _: wita::event::Closed) {
// write handling codes
}
}
wita::run(wita::RunType::Wait, Foo::new).unwrap();§Drawing on the window
There are directly no any methods for drawing on a Window in wita.
However, a Window provides the raw_handle that return a pointer which is HWND.
You can create a drawing context by using the raw_handle such as DirectX, Vulkan, etc.
Modules§
- event
- EventHandler trait and event parameter structures.
- ime
- An IME composition string and a candidate list
- raw_
input raw_input - Provides raw input data.
Structs§
- ApiError
- Represents an Win32 API error.
- Borderless
Style - Represents the borderless window style.
- Inner
Window Builder - The object to build a window into the parent window.
- KeyCode
- A virtual key and a scan code.
- Logical
- Logical coordinate.
- Monitor
- Describes monitor info.
- Mouse
State - A mouse cursor position and pressed mouse buttons.
- Physical
- Physical coordinate.
- Position
- A generic position
- Scan
Code - A keyboard scan code
- Screen
- Screen coordinate.
- Size
- A generic size
- Window
- Represents a window.
- Window
Builder - The object to build a window.
- Window
Style - Represents a window style.
Enums§
- Cursor
- Describes a mouse cursor icon.
- Icon
- Describes a icon.
- KeyState
- Describes the state of a keyboard key and a mouse button.
- Mouse
Button - Describes mouse buttons.
- Mouse
Wheel Axis - Describes a mouse wheel axis.
- Resizing
Edge - Describes the edge of the resizing window.
- RunType
- Describes event loop types.
- Virtual
Key - Describes keyboard key names.
Constants§
- DEFAULT_
DPI - The value is an unit in logical coordinates.
- WHEEL_
DELTA - The distance when the mouse wheel rotated expressed in multiples or factors of this value.
Traits§
- Event
Handler - Trait that must implements for handling events.
- Style
- A window style and the borderless window style.
- ToLogical
Position - Converts to a logical position.
- ToLogical
Size - Converts to a logical size.
- ToPhysical
Position - Converts to a physical position.
- ToPhysical
Size - Converts to a physical size.
Functions§
- get_
key_ state - Get the current key state;
- get_
monitors - Return monitors info.
- keyboard_
state - Get current key states.
- monitor_
from_ point - A screen position to a monitor.
- run
- Run the event loop.
Type Aliases§
- Logical
Position - A position in logical coordinate.
- Logical
Size - A size in logical coordinate.
- Physical
Position - A position in physical coordinate.
- Physical
Size - A size in physical coordinate.
- Screen
Position - A position in screen coordinate.