Browse Source

make pixels_per_point optional in RawInput (default 1)

readable-ids
Emil Ernerfeldt 5 years ago
parent
commit
896d87c804
  1. 6
      emigui/src/input.rs
  2. 2
      example_glium/src/main.rs
  3. 3
      example_wasm/src/lib.rs

6
emigui/src/input.rs

@ -21,7 +21,7 @@ pub struct RawInput {
pub screen_size: Vec2,
/// Also known as device pixel ratio, > 1 for HDPI screens.
pub pixels_per_point: f32,
pub pixels_per_point: Option<f32>,
/// Time in seconds. Relative to whatever. Used for animation.
pub time: f64,
@ -165,7 +165,7 @@ impl GuiInput {
mouse_velocity,
scroll_delta: new.scroll_delta,
screen_size: new.screen_size,
pixels_per_point: new.pixels_per_point,
pixels_per_point: new.pixels_per_point.unwrap_or(1.0),
time: new.time,
dt,
seconds_since_midnight: new.seconds_since_midnight,
@ -186,7 +186,7 @@ impl RawInput {
ui.add(label!("mouse_pos: {:.1?}", self.mouse_pos));
ui.add(label!("scroll_delta: {:?}", self.scroll_delta));
ui.add(label!("screen_size: {:?}", self.screen_size));
ui.add(label!("pixels_per_point: {}", self.pixels_per_point));
ui.add(label!("pixels_per_point: {:?}", self.pixels_per_point));
ui.add(label!("time: {:.3} s", self.time));
ui.add(label!("events: {:?}", self.events));
ui.add(label!("dropped_files: {:?}", self.dropped_files));

2
example_glium/src/main.rs

@ -72,7 +72,7 @@ fn main() {
let (width, height) = display.get_framebuffer_dimensions();
vec2(width as f32, height as f32) / pixels_per_point
},
pixels_per_point,
pixels_per_point: Some(pixels_per_point),
..Default::default()
};

3
example_wasm/src/lib.rs

@ -37,7 +37,6 @@ impl State {
fn run(&mut self, raw_input: RawInput) -> Result<Output, JsValue> {
let everything_start = now_sec();
let pixels_per_point = raw_input.pixels_per_point;
self.ctx.begin_frame(raw_input);
let mut ui = self.ctx.fullscreen_ui();
@ -87,7 +86,7 @@ impl State {
bg_color,
batches,
self.ctx.texture(),
pixels_per_point,
self.ctx.pixels_per_point(),
)?;
emigui_wasm::save_memory(&self.ctx); // TODO: don't save every frame

Loading…
Cancel
Save