@@ -13,21 +13,24 @@ pub struct WindowBuilder {
1313}
1414
1515impl WindowBuilder {
16- /// Construct a new window window builder.
16+ /// A new window builder will be 480x360 by default and have the name
17+ /// "Window". After customizing the window with whatever properties your
18+ /// application needs, you can supply it an event loop to process the
19+ /// events that will be generated by the window.
1720 pub fn new ( ) -> Self {
1821 return Self {
19- name : "Window" . to_string ( ) ,
22+ name : String :: from ( "Window" ) ,
2023 dimensions : ( 480 , 360 ) ,
2124 } ;
2225 }
2326
24- /// The name of the window (Will also appear as the title of the window/application)
27+ /// The name to be displayed in the title bar of the window.
2528 pub fn with_name ( mut self , name : & str ) -> Self {
2629 self . name = name. to_string ( ) ;
2730 return self ;
2831 }
2932
30- /// Specify the dimensions for the window (Defaults to 480 x 360)
33+ /// Specify the dimensions for the window (Defaults to 480 x 360).
3134 pub fn with_dimensions ( mut self , width : u32 , height : u32 ) -> Self {
3235 self . dimensions = ( width, height) ;
3336 return self ;
@@ -50,9 +53,13 @@ impl Window {
5053 dimensions : ( u32 , u32 ) ,
5154 event_loop : & mut Loop < Events > ,
5255 ) -> Self {
53- let monitor_handle = event_loop
54- . get_primary_monitor ( )
55- . unwrap_or ( event_loop. get_any_available_monitors ( ) ) ;
56+ // Attempt to get the primary monitor first and then falls back to the first
57+ // available monitor if that isn't found.
58+ let monitor_handle = event_loop. get_primary_monitor ( ) . unwrap_or (
59+ event_loop
60+ . get_any_available_monitors ( )
61+ . expect ( "No monitors available" ) ,
62+ ) ;
5663
5764 let window_properties = WindowProperties {
5865 name : name. to_string ( ) ,
@@ -77,7 +84,7 @@ impl Window {
7784 return & self . window_handle ;
7885 }
7986
80- /// Returns the dimensions of the current window.
87+ /// Returns the dimensions of the current window. (width, height)
8188 pub fn dimensions ( & self ) -> ( u32 , u32 ) {
8289 return (
8390 self . window_handle . size . width ,
0 commit comments