aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorTomaka17 <pierre.krieger1708@gmail.com>2014-08-02 11:23:32 +0200
committerTomaka17 <pierre.krieger1708@gmail.com>2014-08-02 11:23:32 +0200
commitb0d9d0b87f8884639001d69f3a79d4bb41f019f4 (patch)
tree98cb97f274a55ea3c18b04fef76d28f34a91d771 /src/lib.rs
parentabceca11210ec8cdd869d4b134dc1a58dbce0075 (diff)
downloadglutin-b0d9d0b87f8884639001d69f3a79d4bb41f019f4.tar.gz
glutin-b0d9d0b87f8884639001d69f3a79d4bb41f019f4.zip
Dimensions will now match the monitor's in case of fullscreen
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 7a4c644..7fbb0ff 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -26,7 +26,7 @@ pub struct MonitorID(winimpl::MonitorID);
/// Object that allows you to build windows.
pub struct WindowBuilder {
- dimensions: (uint, uint),
+ dimensions: Option<(uint, uint)>,
title: String,
monitor: Option<winimpl::MonitorID>,
gl_version: Option<(uint, uint)>,
@@ -36,7 +36,7 @@ impl WindowBuilder {
/// Initializes a new `WindowBuilder` with default values.
pub fn new() -> WindowBuilder {
WindowBuilder {
- dimensions: (1024, 768),
+ dimensions: None,
title: String::new(),
monitor: None,
gl_version: None,
@@ -47,7 +47,7 @@ impl WindowBuilder {
///
/// Width and height are in pixels.
pub fn with_dimensions(mut self, width: uint, height: uint) -> WindowBuilder {
- self.dimensions = (width, height);
+ self.dimensions = Some((width, height));
self
}
@@ -58,6 +58,8 @@ impl WindowBuilder {
}
/// Requests fullscreen mode.
+ ///
+ /// If you don't specify dimensions for the window, it will match the monitor's.
pub fn with_fullscreen(mut self, monitor: MonitorID) -> WindowBuilder {
let MonitorID(monitor) = monitor;
self.monitor = Some(monitor);
@@ -77,7 +79,18 @@ impl WindowBuilder {
///
/// Error should be very rare and only occur in case of permission denied, incompatible system,
/// out of memory, etc.
- pub fn build(self) -> Result<Window, String> {
+ pub fn build(mut self) -> Result<Window, String> {
+ // resizing the window to the dimensions of the monitor when fullscreen
+ if self.dimensions.is_none() && self.monitor.is_some() {
+ self.dimensions = Some(self.monitor.as_ref().unwrap().get_dimensions())
+ }
+
+ // default dimensions
+ if self.dimensions.is_none() {
+ self.dimensions = Some((1024, 768));
+ }
+
+ // building
winimpl::Window::new(self).map(|w| Window { window: w })
}
}