mirror of
https://github.com/danbulant/appit
synced 2026-05-24 12:26:14 +00:00
Supporting both inner and outer position
This commit is contained in:
parent
35e011dc92
commit
6c59e6942f
2 changed files with 24 additions and 9 deletions
|
|
@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- `PendingApp::new_with_event_callback`
|
- `PendingApp::new_with_event_callback`
|
||||||
- `WindowBehavior::run_witH_event_callback`
|
- `WindowBehavior::run_witH_event_callback`
|
||||||
- `WindowBehavior::run_witH_context_and_event_callback`
|
- `WindowBehavior::run_witH_context_and_event_callback`
|
||||||
|
- `RunningWindow::position` has been split into `RunningWindow::inner_position`
|
||||||
|
and `RunningWindow::outer_position`. `RunningWindow::set_position` has been
|
||||||
|
renamed to `RunningWindow::set_outer_position`.
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -239,7 +239,8 @@ where
|
||||||
focused: winit.has_focus(),
|
focused: winit.has_focus(),
|
||||||
inner_size: winit.inner_size(),
|
inner_size: winit.inner_size(),
|
||||||
outer_size: winit.outer_size(),
|
outer_size: winit.outer_size(),
|
||||||
position: winit.inner_position().unwrap_or_default(),
|
inner_position: winit.inner_position().unwrap_or_default(),
|
||||||
|
outer_position: winit.outer_position().unwrap_or_default(),
|
||||||
scale: winit.scale_factor(),
|
scale: winit.scale_factor(),
|
||||||
theme: winit.theme().unwrap_or(Theme::Dark),
|
theme: winit.theme().unwrap_or(Theme::Dark),
|
||||||
window: winit,
|
window: winit,
|
||||||
|
|
@ -292,7 +293,8 @@ where
|
||||||
app: App<AppMessage>,
|
app: App<AppMessage>,
|
||||||
inner_size: PhysicalSize<u32>,
|
inner_size: PhysicalSize<u32>,
|
||||||
outer_size: PhysicalSize<u32>,
|
outer_size: PhysicalSize<u32>,
|
||||||
position: PhysicalPosition<i32>,
|
outer_position: PhysicalPosition<i32>,
|
||||||
|
inner_position: PhysicalPosition<i32>,
|
||||||
cursor_position: Option<PhysicalPosition<f64>>,
|
cursor_position: Option<PhysicalPosition<f64>>,
|
||||||
mouse_buttons: HashSet<MouseButton>,
|
mouse_buttons: HashSet<MouseButton>,
|
||||||
keys: HashSet<PhysicalKey>,
|
keys: HashSet<PhysicalKey>,
|
||||||
|
|
@ -402,14 +404,20 @@ where
|
||||||
self.outer_size
|
self.outer_size
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the current position of the window, in pixels.
|
/// Returns the current outer position of the window, in pixels.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn position(&self) -> PhysicalPosition<i32> {
|
pub const fn outer_position(&self) -> PhysicalPosition<i32> {
|
||||||
self.position
|
self.outer_position
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the current inner position of the window, in pixels.
|
||||||
|
#[must_use]
|
||||||
|
pub const fn inner_position(&self) -> PhysicalPosition<i32> {
|
||||||
|
self.inner_position
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the current position of the window, in pixels.
|
/// Sets the current position of the window, in pixels.
|
||||||
pub fn set_position(&self, new_position: PhysicalPosition<i32>) {
|
pub fn set_outer_position(&self, new_position: PhysicalPosition<i32>) {
|
||||||
self.window.set_outer_position(new_position);
|
self.window.set_outer_position(new_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -592,9 +600,13 @@ where
|
||||||
behavior.resized(self);
|
behavior.resized(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WindowEvent::Moved(position) => {
|
WindowEvent::Moved(outer_position) => {
|
||||||
if self.position != position {
|
let inner_position = self.window.inner_position().unwrap_or_default();
|
||||||
self.position = position;
|
if self.outer_position != outer_position
|
||||||
|
|| self.inner_position != inner_position
|
||||||
|
{
|
||||||
|
self.outer_position = outer_position;
|
||||||
|
self.inner_position = inner_position;
|
||||||
behavior.moved(self);
|
behavior.moved(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue