Crate egui_multiwin
source ·Expand description
This crate is based on the work by vivlim (https://github.com/vivlim) and repository located (https://github.com/vivlim/egui-glow-multiwin). Vivlim’s example repository combines the work at https://github.com/shivshank/mini_gl_fb/blob/master/examples/multi_window.rs and egui to form a nice package. This crate makes some modifications to make it useful as an external crate by defining a few traits for users to implement on their custom structs.
There are several examples (https://github.com/uglyoldbob/egui-multiwin/tree/master/examples) that show how to use this crate in your project.
The majority of the code is created by the pair of macros named multi_window
and tracked_window
The main struct for this crate is defined by the multi_window
macro.
Generally you will create a struct for data that is common to all windows, implement the CommonEventHandler
trait on it.
It will be useful to run cargo doc --open
on your application to fully see the documentation for this module. This is because the majority of the code is generated by a pair of macros.
See the examples in the repository for example applications that can be used to start your application.
Check github issues to see if wayland (linux) still has a problem with the clipboard. That issue should give a temporary solution to a segfault that occurs after closing a window in your program.
In your main event, create an event loop, create an event loop proxy (if desired). The event loop proxy can be cloned and sent to other threads, allowing custom logic to send events that can create windows and modify the common state of the application as required. Create a multiwindow instance, then create window requests to make initial windows, and add them to the multiwindow with the add function. Create an instance of your common data structure, and finally call run of your multiwindow instance.
Re-exports§
pub use arboard;
pub use egui;
pub use egui_glow;
pub use enum_dispatch;
pub use glutin;
pub use raw_window_handle;
pub use raw_window_handle_5;
pub use thiserror;
pub use winit;
Modules§
- This defines the MultiWindow struct. This is the main struct used in the main function of a user application.
- This module covers definition and functionality for an individual window.
Macros§
- This macro creates a dynamic definition of the multi_window module. It has the same arguments as the
tracked_window
macro. - Create the dynamic tracked_window module for a egui_multiwin application. Takes three arguments. First argument is the type name of the common data structure for your application. Second argument is the type for custom events (or egui_multiwin::NoEvent if that functionality is not desired). Third argument is the enum of all windows. It needs to be enum_dispatch.
Structs§
- A generic non-event providing struct that users can use when they don’t need custom events.