Changeset 11098
- Timestamp:
- 03/13/10 05:54:59 (2 years ago)
- Location:
- trunk/Padre
- Files:
-
- 3 edited
-
Changes (modified) (1 diff)
-
lib/Padre/Wx/Display.pm (modified) (3 diffs)
-
lib/Padre/Wx/Main.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Padre/Changes
r11081 r11098 15 15 - Add language names/translated texts to select_language list (SEWI) 16 16 - Fixed ticket #865 Wrong document type in View Document As (PLAVEN) 17 - New Padre::Wx::Display screen geometry library for handling multiple 18 screens, weird geometry setups and other weird stuff that coders 19 have on their development setups. Padre's main window uses this to 20 calculate an elegant golden-ratio uniform-margin default position 21 and size (ADAMK) 17 22 18 23 0.58 2010.03.08 **WARNING Still not stable** -
trunk/Padre/lib/Padre/Wx/Display.pm
r11096 r11098 67 67 sub primary_default { 68 68 my $primary = primary(); 69 return _rect_scale( 70 _rect_golden( 71 $primary->GetClientArea 69 return _rect_golden( 70 _rect_scale_margin( 71 $primary->GetClientArea, 72 0.9, 72 73 ), 73 0.8,74 74 ); 75 75 } … … 104 104 my $ratio = shift; 105 105 my $margin = (1 - $ratio) / 2; 106 $rect->width( int( $rect->width * $ratio ) ); 107 $rect->height( int( $rect->height * $ratio ) ); 106 108 $rect->x( $rect->x + int($rect->width * $margin) ); 107 109 $rect->y( $rect->y + int($rect->height * $margin) ); 108 $rect->width( int( $rect->width * $ratio ) ); 109 $rect->height( int( $rect->height * $ratio ) ); 110 return $rect; 111 } 112 113 # Scale a rect by some ration at the centre, 114 # while retaining a consistent margin. 115 sub _rect_scale_margin { 116 my $rect = shift; 117 my $ratio = shift; 118 my $marginr = (1 - $ratio) / 2; 119 my $marginx = int($rect->width * $marginr); 120 my $marginy = int($rect->height * $marginr); 121 my $margin = ($marginx > $marginy) ? $marginy : $marginx; 122 $rect->width( $rect->width - $margin * 2 ); 123 $rect->height( $rect->height - $margin * 2 ); 124 $rect->x( $rect->x + $margin ); 125 $rect->y( $rect->y + $margin ); 110 126 return $rect; 111 127 } … … 114 130 sub _rect_golden { 115 131 my $rect = shift; 116 if ( $rect->width > $rect->height * GOLDEN) {132 if ( $rect->width > ($rect->height * GOLDEN) ) { 117 133 # Shrink left from the right 118 $rect->width( int($rect->height *GOLDEN) );134 $rect->width( int($rect->height / GOLDEN) ); 119 135 } else { 120 136 # Shrink up from the bottom 121 $rect->height( int($rect->width *GOLDEN) );137 $rect->height( int($rect->width / GOLDEN) ); 122 138 } 123 139 return $rect; -
trunk/Padre/lib/Padre/Wx/Main.pm
r11094 r11098 100 100 Wx::InitAllImageHandlers(); 101 101 102 # Determine the initial frame style 103 my $config = $ide->config; 104 my $style = Wx::wxDEFAULT_FRAME_STYLE; 102 # Initialise the style and position 103 my $config = $ide->config; 104 my $size = [ $config->main_width, $config->main_height ]; 105 my $position = [ $config->main_left, $config->main_top ]; 106 my $style = Wx::wxDEFAULT_FRAME_STYLE; 107 108 # If we closed while maximized on the previous run, 109 # the previous size is completely suspect. 105 110 if ( $config->main_maximized ) { 106 $style |= Wx::wxMAXIMIZE; 111 $style |= Wx::wxMAXIMIZE; 112 $size = [ -1, -1 ]; 113 $position = [ -1, -1 ]; 114 } 115 116 # Generate a smarter default size than Wx does 117 if ( $size->[0] == -1 ) { 118 require Padre::Wx::Display; 119 my $rect = Padre::Wx::Display::primary_default(); 120 $size = $rect->GetSize; 121 $position = $rect->GetPosition; 107 122 } 108 123 109 124 # Create the underlying Wx frame 110 125 my $self = $class->SUPER::new( 111 undef, -1, 'Padre: New window', 112 [ $config->main_left, $config->main_top, ], 113 [ $config->main_width, $config->main_height, ], $style, 126 undef, -1, 127 'Padre', 128 $position, 129 $size, 130 $style, 114 131 ); 115 132
Note: See TracChangeset
for help on using the changeset viewer.
