Crates.io | dgews |
lib.rs | dgews |
version | 0.1.5 |
source | src |
created_at | 2022-09-03 17:33:29.029047 |
updated_at | 2022-11-09 15:53:50.249157 |
description | Easy multithreaded toy windowing system for learning purposes only |
homepage | https://github.com/MrTitanHearted/dgews |
repository | https://github.com/MrTitanHearted/dgews |
max_upload_size | |
id | 657982 |
size | 120,699 |
DGEWS is a simple multithreaded toy windowing system for only learning purposes.
[dependencies]
dgews="0.1.4"
DGEWS is an ordinary window manager for only Windows users. It is pretty simple and straightforward so that anyone can understand and sometimes learn something from it. Indead, my goal is actually to learn the cycle of programming a practical crates and the developement of them.
Usage
DGEWS usues the c++ win32 api library wrapper winapi to build its windows. Therefore, anyone else except for Windows OS users cannot use this crate. Currently, this crate is not stable and crashes sometimes, that is why it is better not to use it in production (though I think nobody will use it while winit crate is ready to use). But, if someone wants to use some of its features in their own projects, just take it as I have stated that it is only for educational purposes.
Example
Manager is a central point of this crate: it processes everything and users retrieve the event messages from it. Moreover, window or windows are created with that. The run() method accepts a closure that must be called in each event and users will be given events, the manager itself as well as the control flow of that main events loop
extern crate dgews;
use dgews::prelude::*; // prelude module contains everything
fn main() {
let mut manager = Manager::new(WindowBuilder::default()
.with_title("DGEWS Window")
.with_dimensions(800, 640)
.with_theme(Theme::Dark)
.with_resizable(true))
.add_window("Hooray", WindowBuilder::new()
.with_title("Finally")
.with_dimensions(400, 300)
.with_theme(Theme::Dark)
.with_pos(700, 700));
manager.run(|events, control_flow, manager| {
match events {
Events::WindowEvents { id, event } => match event {
WindowEvents::Create => println!("[INFO]: a new window with id: {} has been created", id),
WindowEvents::Close => {
println!("[INFO]: a window with id: {} has been closed", id);
*control_flow = ControlFlow::Exit; // to exit with panicing, use ControlFlow::ExitWithCode(<your number>) instead.
},
WindowEvents::SetFocus => println!("[INFO]: window with id: {} gained the focus", id),
WindowEvents::LostFocus => println!("[INFO]: window with id: {} Lost the focus", id),
_=> {}
},
Events::MouseEvents { id: _, event } => match event {
MouseEvents::MouseMove { x, y, last_x, last_y, dx, dy } => {
println!("[INFO]: mouse moved in the window with id {}: x={}, y={}, last_x={}, last_y={} dx={} dy={};", manager.window().unwrap().get_id(), x, y, last_x, last_y, dx, dy);
},
_=> {}
}
_=> *control_flow = ControlFlow::Continue,
}
if manager.get_key(Key::ESCAPE) == Action::Release {
println!("[INFO]: program is exiting");
*control_flow = ControlFlow::Exit;
}
});
}
Features
Contributions
Everyone is welcome who are willing to contribute even to the documentation. Thanks in advance. Contact me via:
I am a student of a lyceum that is why I think you won't get the response immediately, however, I will try my best to reply back as soon as possible.