Crate wita[−][src]
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() -> Self { wita::WindowBuilder::new() .title("hello, world!") .build(); Self } } impl wita::EventHandler for Application { fn closed(&mut self, _: &wita::Window) { println!("closed"); } } fn main() { wita::initialize::<Application>(); wita::run(wita::RunType::Wait, Application); }
Event handling
You must implement EventHandler
for the your defined object, and can handle events in the impl EventHandler
.
struct Foo {} impl Foo { fn new() -> Self { // Self {} } } impl wita::EventHandler for Foo { // You define handlers. // For example, handle the event that closed the window. fn closed(&mut self, _: &wita::Window) { // write handling codes } }
Next, pass the your defined object to run
.
wita::initialize::<Foo>(); wita::run(wita::RunType::Wait, Foo::new());
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
ime | An IME composition string and a candidate list |
raw_input | Provides raw input data. |
Structs
BorderlessStyle | Represents the borderless window style. |
KeyCode | A virtual key and a scan code. |
LogicalPosition | A position in logical coordinate. |
LogicalSize | A size in logical coordinate. |
Monitor | Describes monitor info. |
MouseState | A mouse cursor position and pressed mouse buttons. |
PhysicalPosition | A position in physical coordinate. |
PhysicalSize | A size in physical coordinate. |
ScanCode | A keyboard scan code |
ScreenPosition | A position in screen coordinate. |
Window | The object is like Window, can send to other threads. |
WindowBuilder | The object that allows you to build windows. |
WindowStyle | Represents a window style. |
Enums
Icon | Describes a icon. |
KeyState | Describes the state of a keyboard key and a mouse button. |
MouseButton | Describes mouse buttons. |
RunType | Describes event loop types. |
VirtualKey | Describes keyboard key names. |
Constants
DEFAULT_DPI | The value is an unit in logical coordinates. |
Traits
EventHandler | Trait that must implements for handling events. |
Style | A window style and the borderless window style. |
ToLogicalPosition | Converts to a logical position. |
ToLogicalSize | Converts to a logical size. |
ToPhysicalPosition | Converts to a physical position. |
ToPhysicalSize | Converts to a physical size. |
Functions
get_monitors | Return monitors info. |
initialize | Initialize |
keyboard_state | Get current key states. |
monitor_from_point | A screen position to a monitor. |
run | Run the event loop. |