Merge remote-tracking branch 'origin/master' into feat/multi-window-support
# Conflicts: # Cargo.toml # core/src/window/icon.rs # core/src/window/id.rs # core/src/window/position.rs # core/src/window/settings.rs # examples/integration/src/main.rs # examples/integration_opengl/src/main.rs # glutin/src/application.rs # native/src/subscription.rs # native/src/window.rs # runtime/src/window/action.rs # src/lib.rs # src/window.rs # winit/Cargo.toml # winit/src/application.rs # winit/src/icon.rs # winit/src/settings.rs # winit/src/window.rs
This commit is contained in:
commit
633f405f3f
394 changed files with 17278 additions and 13290 deletions
|
|
@ -1,6 +1,11 @@
|
|||
use crate::application::{self, StyleSheet as _};
|
||||
use crate::conversion;
|
||||
use crate::{Application, Color, Debug, Point, Size, Viewport};
|
||||
use crate::core;
|
||||
use crate::core::mouse;
|
||||
use crate::core::{Color, Size};
|
||||
use crate::graphics::Viewport;
|
||||
use crate::runtime::Debug;
|
||||
use crate::Application;
|
||||
|
||||
use std::marker::PhantomData;
|
||||
use winit::event::{Touch, WindowEvent};
|
||||
|
|
@ -10,22 +15,22 @@ use winit::window::Window;
|
|||
#[allow(missing_debug_implementations)]
|
||||
pub struct State<A: Application>
|
||||
where
|
||||
<A::Renderer as crate::Renderer>::Theme: application::StyleSheet,
|
||||
<A::Renderer as core::Renderer>::Theme: application::StyleSheet,
|
||||
{
|
||||
title: String,
|
||||
scale_factor: f64,
|
||||
viewport: Viewport,
|
||||
viewport_version: usize,
|
||||
cursor_position: winit::dpi::PhysicalPosition<f64>,
|
||||
cursor_position: Option<winit::dpi::PhysicalPosition<f64>>,
|
||||
modifiers: winit::event::ModifiersState,
|
||||
theme: <A::Renderer as crate::Renderer>::Theme,
|
||||
theme: <A::Renderer as core::Renderer>::Theme,
|
||||
appearance: application::Appearance,
|
||||
application: PhantomData<A>,
|
||||
}
|
||||
|
||||
impl<A: Application> State<A>
|
||||
where
|
||||
<A::Renderer as crate::Renderer>::Theme: application::StyleSheet,
|
||||
<A::Renderer as core::Renderer>::Theme: application::StyleSheet,
|
||||
{
|
||||
/// Creates a new [`State`] for the provided [`Application`] and window.
|
||||
pub fn new(application: &A, window: &Window) -> Self {
|
||||
|
|
@ -48,8 +53,7 @@ where
|
|||
scale_factor,
|
||||
viewport,
|
||||
viewport_version: 0,
|
||||
// TODO: Encode cursor availability in the type-system
|
||||
cursor_position: winit::dpi::PhysicalPosition::new(-1.0, -1.0),
|
||||
cursor_position: None,
|
||||
modifiers: winit::event::ModifiersState::default(),
|
||||
theme,
|
||||
appearance,
|
||||
|
|
@ -85,11 +89,16 @@ where
|
|||
}
|
||||
|
||||
/// Returns the current cursor position of the [`State`].
|
||||
pub fn cursor_position(&self) -> Point {
|
||||
conversion::cursor_position(
|
||||
self.cursor_position,
|
||||
self.viewport.scale_factor(),
|
||||
)
|
||||
pub fn cursor(&self) -> mouse::Cursor {
|
||||
self.cursor_position
|
||||
.map(|cursor_position| {
|
||||
conversion::cursor_position(
|
||||
cursor_position,
|
||||
self.viewport.scale_factor(),
|
||||
)
|
||||
})
|
||||
.map(mouse::Cursor::Available)
|
||||
.unwrap_or(mouse::Cursor::Unavailable)
|
||||
}
|
||||
|
||||
/// Returns the current keyboard modifiers of the [`State`].
|
||||
|
|
@ -98,7 +107,7 @@ where
|
|||
}
|
||||
|
||||
/// Returns the current theme of the [`State`].
|
||||
pub fn theme(&self) -> &<A::Renderer as crate::Renderer>::Theme {
|
||||
pub fn theme(&self) -> &<A::Renderer as core::Renderer>::Theme {
|
||||
&self.theme
|
||||
}
|
||||
|
||||
|
|
@ -149,12 +158,10 @@ where
|
|||
| WindowEvent::Touch(Touch {
|
||||
location: position, ..
|
||||
}) => {
|
||||
self.cursor_position = *position;
|
||||
self.cursor_position = Some(*position);
|
||||
}
|
||||
WindowEvent::CursorLeft { .. } => {
|
||||
// TODO: Encode cursor availability in the type-system
|
||||
self.cursor_position =
|
||||
winit::dpi::PhysicalPosition::new(-1.0, -1.0);
|
||||
self.cursor_position = None;
|
||||
}
|
||||
WindowEvent::ModifiersChanged(new_modifiers) => {
|
||||
self.modifiers = *new_modifiers;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue