ferroui_controls/window_resized_event_args.rs
1use ferroui_base::Size;
2
3/// Specifies the reason for a window resize.
4#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
5#[repr(i32)]
6pub enum WindowResizeReason {
7 /// The resize reason is unknown or unspecified.
8 #[default]
9 Unspecified = 0,
10
11 /// The resize was due to the user resizing the window, for example by
12 /// dragging the window frame.
13 User = 1,
14
15 /// The resize was initiated by the application, for example by setting
16 /// one of the sizing-related properties on the window.
17 Application = 2,
18
19 /// The resize was initiated by the layout system.
20 Layout = 3,
21
22 /// The resize was due to a change in DPI.
23 DpiChange = 4,
24}
25
26/// Provides data for the window resized event.
27#[derive(Clone, Copy, Debug, PartialEq)]
28pub struct WindowResizedEventArgs {
29 client_size: Size,
30 reason: WindowResizeReason,
31}
32
33impl WindowResizedEventArgs {
34 /// Creates the event args. Only the windowing classes raise the event.
35 pub fn new(client_size: Size, reason: WindowResizeReason) -> Self {
36 Self { client_size, reason }
37 }
38
39 /// The new client size of the window in device-independent pixels.
40 pub fn client_size(&self) -> Size {
41 self.client_size
42 }
43
44 /// The reason for the resize.
45 pub fn reason(&self) -> WindowResizeReason {
46 self.reason
47 }
48}