From 05175c1d800a3b5303118834d342ebbfd44ecc8d Mon Sep 17 00:00:00 2001 From: Sven Nilsen Date: Sat, 25 Jul 2015 13:40:33 +0200 Subject: Split `get_inner_size` Closes https://github.com/tomaka/glutin/issues/542 * Splits `get_inner_size` into `get_inner_size_points` and `get_inner_size_pixels` This is a breaking change. --- src/window.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/window.rs b/src/window.rs index ac52ed7..655c54f 100644 --- a/src/window.rs +++ b/src/window.rs @@ -301,10 +301,25 @@ impl Window { /// /// Returns `None` if the window no longer exists. #[inline] - pub fn get_inner_size(&self) -> Option<(u32, u32)> { + pub fn get_inner_size_points(&self) -> Option<(u32, u32)> { self.window.get_inner_size() } + /// Returns the size in pixels of the client area of the window. + /// + /// The client area is the content of the window, excluding the title bar and borders. + /// These are the dimensions of the frame buffer, and the dimensions that you should use + /// when you call `glViewport`. + /// + /// Returns `None` if the window no longer exists. + #[inline] + pub fn get_inner_size_pixels(&self) -> Option<(u32, u32)> { + self.window.get_inner_size().map(|(x, y)| { + let hidpi = self.hidpi_factor(); + ((x as f32 * hidpi) as u32, (y as f32 * hidpi) as u32) + }) + } + /// Returns the size in pixels of the window. /// /// These dimensions include title bar and borders. If you don't want these, you should use -- cgit v1.2.3 From 79b8cf2cc87ccf013254afb44d287a47eea6fe44 Mon Sep 17 00:00:00 2001 From: Sven Nilsen Date: Sat, 25 Jul 2015 13:57:52 +0200 Subject: Keep existing function for backward compatibility --- src/window.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/window.rs b/src/window.rs index 655c54f..00174d3 100644 --- a/src/window.rs +++ b/src/window.rs @@ -294,6 +294,19 @@ impl Window { self.window.set_position(x, y) } + /// Returns the size in points of the client area of the window. + /// + /// The client area is the content of the window, excluding the title bar and borders. + /// To get the dimensions of the frame buffer when calling `glViewport`, multiply with hidpi factor. + /// + /// Returns `None` if the window no longer exists. + /// + /// DEPRECATED + #[inline] + pub fn get_inner_size(&self) -> Option<(u32, u32)> { + self.window.get_inner_size() + } + /// Returns the size in points of the client area of the window. /// /// The client area is the content of the window, excluding the title bar and borders. @@ -305,6 +318,7 @@ impl Window { self.window.get_inner_size() } + /// Returns the size in pixels of the client area of the window. /// /// The client area is the content of the window, excluding the title bar and borders. -- cgit v1.2.3