From 9316771f64842533181cfb04a27aa9ae809cc435 Mon Sep 17 00:00:00 2001 From: Tuomas Siipola Date: Sat, 6 May 2017 08:45:23 -0700 Subject: Add window padding option Padding can be configured by using the `padding` field in the config file, like so: padding: x: 2 y: 2 which would result in a 2px padding within each side of the window. --- src/display.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/display.rs') diff --git a/src/display.rs b/src/display.rs index c2636e7e..73bb0fce 100644 --- a/src/display.rs +++ b/src/display.rs @@ -149,7 +149,7 @@ impl Display { let rasterizer = font::Rasterizer::new(dpi.x(), dpi.y(), dpr, config.use_thin_strokes())?; // Create renderer - let mut renderer = QuadRenderer::new(size)?; + let mut renderer = QuadRenderer::new(&config, size)?; // Initialize glyph cache let glyph_cache = { @@ -182,15 +182,21 @@ impl Display { let size = Size { width: Pixels(width), height: Pixels(height) }; info!("set_inner_size: {}", size); - window.set_inner_size(size); - renderer.resize(*size.width as _, *size.height as _); + let viewport_size = Size { + width: Pixels(width + 2 * config.padding().x as u32), + height: Pixels(width + 2 * config.padding().y as u32), + }; + window.set_inner_size(&viewport_size); + renderer.resize(viewport_size.width.0 as _, viewport_size.height.0 as _); info!("Cell Size: ({} x {})", cell_width, cell_height); let size_info = SizeInfo { - width: *size.width as f32, - height: *size.height as f32, + width: viewport_size.width.0 as f32, + height: viewport_size.height.0 as f32, cell_width: cell_width as f32, - cell_height: cell_height as f32 + cell_height: cell_height as f32, + padding_x: config.padding().x.floor(), + padding_y: config.padding().y.floor(), }; // Channel for resize events -- cgit v1.2.3-54-g00ecf