mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
Fix moving the map and resizing
This commit is contained in:
parent
7278829910
commit
6fab04c70f
@ -138,10 +138,10 @@ impl<ET: 'static> EventLoop<ET> for WinitEventLoop<ET> {
|
|||||||
..
|
..
|
||||||
} => *control_flow = ControlFlow::Exit,
|
} => *control_flow = ControlFlow::Exit,
|
||||||
WindowEvent::Resized(physical_size) => {
|
WindowEvent::Resized(physical_size) => {
|
||||||
// FIXME map.resize(physical_size.width, physical_size.height);
|
map.context_mut().resize(physical_size.width, physical_size.height);
|
||||||
}
|
}
|
||||||
WindowEvent::ScaleFactorChanged { new_inner_size, .. } => {
|
WindowEvent::ScaleFactorChanged { new_inner_size, .. } => {
|
||||||
// FIXME map.resize(new_inner_size.width, new_inner_size.height);
|
map.context_mut().resize(new_inner_size.width, new_inner_size.height);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@ -152,7 +152,7 @@ impl<ET: 'static> EventLoop<ET> for WinitEventLoop<ET> {
|
|||||||
let dt = now - last_render_time;
|
let dt = now - last_render_time;
|
||||||
last_render_time = now;
|
last_render_time = now;
|
||||||
|
|
||||||
// FIXME input_controller.update_state(map.view_state_mut(), dt);
|
input_controller.update_state(map.context_mut().world.view_state_mut(), dt);
|
||||||
|
|
||||||
match map.run_schedule() {
|
match map.run_schedule() {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
|
|||||||
@ -17,7 +17,7 @@ use maplibre::{
|
|||||||
use winit::window::WindowBuilder;
|
use winit::window::WindowBuilder;
|
||||||
|
|
||||||
use super::{RawWinitEventLoop, RawWinitWindow, WinitMapWindow, WinitMapWindowConfig};
|
use super::{RawWinitEventLoop, RawWinitWindow, WinitMapWindow, WinitMapWindowConfig};
|
||||||
use crate::winit::{WinitEnvironment, WinitEventLoop};
|
use crate::{WinitEnvironment, WinitEventLoop};
|
||||||
|
|
||||||
impl<T> MapWindow for WinitMapWindow<T> {
|
impl<T> MapWindow for WinitMapWindow<T> {
|
||||||
fn size(&self) -> WindowSize {
|
fn size(&self) -> WindowSize {
|
||||||
|
|||||||
@ -1,4 +1,8 @@
|
|||||||
use crate::{render::Renderer, style::Style, world::World};
|
use crate::{
|
||||||
|
render::Renderer,
|
||||||
|
style::Style,
|
||||||
|
world::{ViewState, World},
|
||||||
|
};
|
||||||
|
|
||||||
/// Stores the context of the map.
|
/// Stores the context of the map.
|
||||||
pub struct MapContext {
|
pub struct MapContext {
|
||||||
|
|||||||
@ -57,4 +57,12 @@ impl<E: Environment> Map<E> {
|
|||||||
self.schedule.run(&mut self.map_context);
|
self.schedule.run(&mut self.map_context);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn context(&self) -> &MapContext {
|
||||||
|
&self.map_context
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn context_mut(&mut self) -> &mut MapContext {
|
||||||
|
&mut self.map_context
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ use std::ops::{Deref, DerefMut};
|
|||||||
use cgmath::{Angle, Point3};
|
use cgmath::{Angle, Point3};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
context::MapContext,
|
||||||
coords::{LatLon, ViewRegion, WorldCoords, Zoom, ZoomLevel, TILE_SIZE},
|
coords::{LatLon, ViewRegion, WorldCoords, Zoom, ZoomLevel, TILE_SIZE},
|
||||||
io::tile_repository::TileRepository,
|
io::tile_repository::TileRepository,
|
||||||
render::camera::{Camera, Perspective, ViewProjection},
|
render::camera::{Camera, Perspective, ViewProjection},
|
||||||
@ -52,6 +53,14 @@ impl World {
|
|||||||
tile_repository,
|
tile_repository,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn view_state(&self) -> &ViewState {
|
||||||
|
&self.view_state
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn view_state_mut(&mut self) -> &mut ViewState {
|
||||||
|
&mut self.view_state
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stores the camera configuration.
|
/// Stores the camera configuration.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user