Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: chrome/browser/ui/cocoa/constrained_window/constrained_window_alert.mm

Issue 11077006: Correct padding and focus ring for frameless constrained window dialog (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix mac build, part 2 Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_alert.h" 5 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_alert.h"
6 6
7 #import "base/logging.h" 7 #import "base/logging.h"
8 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" 8 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h"
9 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_control_u tils.h" 9 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_control_u tils.h"
10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_wi ndow.h" 10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_wi ndow.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // Window width. 138 // Window width.
139 CGFloat windowWidth = buttonWidth; 139 CGFloat windowWidth = buttonWidth;
140 if (accessoryView_.get()) 140 if (accessoryView_.get())
141 windowWidth = std::max(windowWidth, NSWidth([accessoryView_ frame])); 141 windowWidth = std::max(windowWidth, NSWidth([accessoryView_ frame]));
142 windowWidth += ConstrainedWindow::kHorizontalPadding * 2; 142 windowWidth += ConstrainedWindow::kHorizontalPadding * 2;
143 windowWidth = std::max(windowWidth, kWindowMinWidth); 143 windowWidth = std::max(windowWidth, kWindowMinWidth);
144 144
145 // Layout controls. 145 // Layout controls.
146 [self layoutButtonsWithWindowWidth:windowWidth]; 146 [self layoutButtonsWithWindowWidth:windowWidth];
147 CGFloat curY = [buttons_ count] ? NSMaxY([[buttons_ lastObject] frame]) 147 CGFloat curY = [buttons_ count] ? NSMaxY([[buttons_ lastObject] frame])
148 : ConstrainedWindow::kVerticalPadding; 148 : ConstrainedWindow::kClientBottomPadding;
149 curY = [self layoutAccessoryViewAtYPos:curY]; 149 curY = [self layoutAccessoryViewAtYPos:curY];
150 curY = [self layoutTextField:informativeTextField_ 150 curY = [self layoutTextField:informativeTextField_
151 yPos:curY 151 yPos:curY
152 windowWidth:windowWidth]; 152 windowWidth:windowWidth];
153 CGFloat availableMessageWidth = 153 CGFloat availableMessageWidth =
154 windowWidth - ConstrainedWindow::GetCloseButtonSize() - kButtonGap; 154 windowWidth - ConstrainedWindow::GetCloseButtonSize() - kButtonGap;
155 curY = [self layoutTextField:messageTextField_ 155 curY = [self layoutTextField:messageTextField_
156 yPos:curY 156 yPos:curY
157 windowWidth:availableMessageWidth]; 157 windowWidth:availableMessageWidth];
158 [self layoutCloseButtonWithWindowWidth:windowWidth]; 158 [self layoutCloseButtonWithWindowWidth:windowWidth];
159 159
160 // Update window frame. 160 // Update window frame.
161 curY += ConstrainedWindow::kVerticalPadding; 161 curY += ConstrainedWindow::kTitleTopPadding;
162 [window_ setFrame:NSMakeRect(0, 0, windowWidth, curY) 162 [window_ setFrame:NSMakeRect(0, 0, windowWidth, curY)
163 display:NO]; 163 display:NO];
164 } 164 }
165 165
166 - (void)layoutButtonsWithWindowWidth:(CGFloat)windowWidth { 166 - (void)layoutButtonsWithWindowWidth:(CGFloat)windowWidth {
167 // Layout first 2 button right to left. 167 // Layout first 2 button right to left.
168 CGFloat curX = windowWidth - ConstrainedWindow::kHorizontalPadding; 168 CGFloat curX = windowWidth - ConstrainedWindow::kHorizontalPadding;
169 const int buttonCount = [buttons_ count]; 169 const int buttonCount = [buttons_ count];
170 for (int i = 0; i < std::min(2, buttonCount); ++i) { 170 for (int i = 0; i < std::min(2, buttonCount); ++i) {
171 NSButton* button = [buttons_ objectAtIndex:i]; 171 NSButton* button = [buttons_ objectAtIndex:i];
172 NSRect rect = [button frame]; 172 NSRect rect = [button frame];
173 rect.origin.x = curX - NSWidth(rect); 173 rect.origin.x = curX - NSWidth(rect);
174 rect.origin.y = ConstrainedWindow::kVerticalPadding; 174 rect.origin.y = ConstrainedWindow::kClientBottomPadding;
175 [button setFrameOrigin:rect.origin]; 175 [button setFrameOrigin:rect.origin];
176 curX = NSMinX(rect) - kButtonGap; 176 curX = NSMinX(rect) - kButtonGap;
177 } 177 }
178 178
179 // Layout remaining buttons left to right. 179 // Layout remaining buttons left to right.
180 curX = ConstrainedWindow::kHorizontalPadding; 180 curX = ConstrainedWindow::kHorizontalPadding;
181 for (int i = buttonCount - 1; i >= 2; --i) { 181 for (int i = buttonCount - 1; i >= 2; --i) {
182 NSButton* button = [buttons_ objectAtIndex:i]; 182 NSButton* button = [buttons_ objectAtIndex:i];
183 [button setFrameOrigin: 183 [button setFrameOrigin:
184 NSMakePoint(curX, ConstrainedWindow::kVerticalPadding)]; 184 NSMakePoint(curX, ConstrainedWindow::kClientBottomPadding)];
185 curX += NSMaxX([button frame]) + kButtonGap; 185 curX += NSMaxX([button frame]) + kButtonGap;
186 } 186 }
187 } 187 }
188 188
189 - (CGFloat)layoutTextField:(NSTextField*)textField 189 - (CGFloat)layoutTextField:(NSTextField*)textField
190 yPos:(CGFloat)yPos 190 yPos:(CGFloat)yPos
191 windowWidth:(CGFloat)windowWidth { 191 windowWidth:(CGFloat)windowWidth {
192 if (![[textField stringValue] length]) { 192 if (![[textField stringValue] length]) {
193 [textField setHidden:YES]; 193 [textField setHidden:YES];
194 return yPos; 194 return yPos;
(...skipping 24 matching lines...) Expand all
219 NSRect frame; 219 NSRect frame;
220 frame.size.width = ConstrainedWindow::GetCloseButtonSize(); 220 frame.size.width = ConstrainedWindow::GetCloseButtonSize();
221 frame.size.height = ConstrainedWindow::GetCloseButtonSize(); 221 frame.size.height = ConstrainedWindow::GetCloseButtonSize();
222 frame.origin.x = 222 frame.origin.x =
223 windowWidth - ConstrainedWindow::kHorizontalPadding - NSWidth(frame); 223 windowWidth - ConstrainedWindow::kHorizontalPadding - NSWidth(frame);
224 frame.origin.y = NSMaxY([messageTextField_ frame]) - NSHeight(frame); 224 frame.origin.y = NSMaxY([messageTextField_ frame]) - NSHeight(frame);
225 [closeButton_ setFrame:frame]; 225 [closeButton_ setFrame:frame];
226 } 226 }
227 227
228 @end 228 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698