OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/profiles/avatar_menu_bubble_controller.h" | 5 #import "chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.h" |
6 | 6 |
7 #include "base/mac/bundle_locations.h" | 7 #include "base/mac/bundle_locations.h" |
8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 CGFloat yOffset = kLinkSpacing; | 216 CGFloat yOffset = kLinkSpacing; |
217 CGFloat widthAdjust = 0; | 217 CGFloat widthAdjust = 0; |
218 | 218 |
219 if (menu_->ShouldShowAddNewProfileLink()) { | 219 if (menu_->ShouldShowAddNewProfileLink()) { |
220 // Since drawing happens bottom-up, start with the "New User" link. | 220 // Since drawing happens bottom-up, start with the "New User" link. |
221 NSButton* newButton = | 221 NSButton* newButton = |
222 [self configureNewUserButton:yOffset updateWidthAdjust:&widthAdjust]; | 222 [self configureNewUserButton:yOffset updateWidthAdjust:&widthAdjust]; |
223 [contentView addSubview:newButton]; | 223 [contentView addSubview:newButton]; |
224 yOffset += NSHeight([newButton frame]) + kVerticalSpacing; | 224 yOffset += NSHeight([newButton frame]) + kVerticalSpacing; |
225 | 225 |
226 NSBox* separator = [self separatorWithFrame: | 226 NSBox* separator = [self horizontalSeparatorWithFrame: |
227 NSMakeRect(10, yOffset, NSWidth([contentView frame]) - 20, 0)]; | 227 NSMakeRect(10, yOffset, NSWidth([contentView frame]) - 20, 0)]; |
228 [separator setAutoresizingMask:NSViewWidthSizable]; | 228 [separator setAutoresizingMask:NSViewWidthSizable]; |
229 [contentView addSubview:separator]; | 229 [contentView addSubview:separator]; |
230 | 230 |
231 yOffset += NSHeight([separator frame]); | 231 yOffset += NSHeight([separator frame]); |
232 } else { | 232 } else { |
233 yOffset = 7; | 233 yOffset = 7; |
234 } | 234 } |
235 | 235 |
236 // Loop over the profiles in reverse, constructing the menu items. | 236 // Loop over the profiles in reverse, constructing the menu items. |
(...skipping 17 matching lines...) Expand all Loading... |
254 // into the xib, and this gives a little more space to visually match. | 254 // into the xib, and this gives a little more space to visually match. |
255 CGFloat yOffset = kLinkSpacing; | 255 CGFloat yOffset = kLinkSpacing; |
256 CGFloat widthAdjust = 0; | 256 CGFloat widthAdjust = 0; |
257 | 257 |
258 // Since drawing happens bottom-up, start with the "Switch User" link. | 258 // Since drawing happens bottom-up, start with the "Switch User" link. |
259 NSButton* newButton = | 259 NSButton* newButton = |
260 [self configureSwitchUserButton:yOffset updateWidthAdjust:&widthAdjust]; | 260 [self configureSwitchUserButton:yOffset updateWidthAdjust:&widthAdjust]; |
261 [contentView addSubview:newButton]; | 261 [contentView addSubview:newButton]; |
262 yOffset += NSHeight([newButton frame]) + kVerticalSpacing; | 262 yOffset += NSHeight([newButton frame]) + kVerticalSpacing; |
263 | 263 |
264 NSBox* separator = [self separatorWithFrame: | 264 NSBox* separator = [self horizontalSeparatorWithFrame: |
265 NSMakeRect(10, yOffset, NSWidth([contentView frame]) - 20, 0)]; | 265 NSMakeRect(10, yOffset, NSWidth([contentView frame]) - 20, 0)]; |
266 [separator setAutoresizingMask:NSViewWidthSizable]; | 266 [separator setAutoresizingMask:NSViewWidthSizable]; |
267 [contentView addSubview:separator]; | 267 [contentView addSubview:separator]; |
268 | 268 |
269 yOffset += NSHeight([separator frame]) + kVerticalSpacing; | 269 yOffset += NSHeight([separator frame]) + kVerticalSpacing; |
270 | 270 |
271 // First init the active profile in order to determine the required width. We | 271 // First init the active profile in order to determine the required width. We |
272 // will have to adjust its frame later after adding general information about | 272 // will have to adjust its frame later after adding general information about |
273 // managed users. | 273 // managed users. |
274 AvatarMenuItemController* itemView = | 274 AvatarMenuItemController* itemView = |
275 [self initAvatarItem:menu_->GetActiveProfileIndex() | 275 [self initAvatarItem:menu_->GetActiveProfileIndex() |
276 updateWidthAdjust:&widthAdjust | 276 updateWidthAdjust:&widthAdjust |
277 setYOffset:yOffset]; | 277 setYOffset:yOffset]; |
278 | 278 |
279 // Don't increase the width too much (the total size should be at most | 279 // Don't increase the width too much (the total size should be at most |
280 // |kBubbleMaxWidth|). | 280 // |kBubbleMaxWidth|). |
281 widthAdjust = std::min(widthAdjust, kBubbleMaxWidth - kBubbleMinWidth); | 281 widthAdjust = std::min(widthAdjust, kBubbleMaxWidth - kBubbleMinWidth); |
282 CGFloat newWidth = kBubbleMinWidth + widthAdjust; | 282 CGFloat newWidth = kBubbleMinWidth + widthAdjust; |
283 | 283 |
284 // Add general information about managed users. | 284 // Add general information about managed users. |
285 NSView* info = [self configureManagedUserInformation:newWidth]; | 285 NSView* info = [self configureManagedUserInformation:newWidth]; |
286 [info setFrameOrigin:NSMakePoint(0, yOffset)]; | 286 [info setFrameOrigin:NSMakePoint(0, yOffset)]; |
287 [contentView addSubview:info]; | 287 [contentView addSubview:info]; |
288 yOffset += NSHeight([info frame]) + kVerticalSpacing; | 288 yOffset += NSHeight([info frame]) + kVerticalSpacing; |
289 | 289 |
290 separator = [self separatorWithFrame: | 290 separator = [self horizontalSeparatorWithFrame: |
291 NSMakeRect(10, yOffset, NSWidth([contentView frame]) - 20, 0)]; | 291 NSMakeRect(10, yOffset, NSWidth([contentView frame]) - 20, 0)]; |
292 [separator setAutoresizingMask:NSViewWidthSizable]; | 292 [separator setAutoresizingMask:NSViewWidthSizable]; |
293 [contentView addSubview:separator]; | 293 [contentView addSubview:separator]; |
294 | 294 |
295 yOffset += NSHeight([separator frame]); | 295 yOffset += NSHeight([separator frame]); |
296 | 296 |
297 // Now update the frame of the active profile and add it. | 297 // Now update the frame of the active profile and add it. |
298 NSRect frame = [[itemView view] frame]; | 298 NSRect frame = [[itemView view] frame]; |
299 frame.origin.y = yOffset; | 299 frame.origin.y = yOffset; |
300 [[itemView view] setFrame:frame]; | 300 [[itemView view] setFrame:frame]; |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 - (BOOL)accessibilityIsIgnored { | 710 - (BOOL)accessibilityIsIgnored { |
711 return YES; | 711 return YES; |
712 } | 712 } |
713 @end | 713 @end |
714 | 714 |
715 @implementation AccessibilityIgnoredTextFieldCell | 715 @implementation AccessibilityIgnoredTextFieldCell |
716 - (BOOL)accessibilityIsIgnored { | 716 - (BOOL)accessibilityIsIgnored { |
717 return YES; | 717 return YES; |
718 } | 718 } |
719 @end | 719 @end |
OLD | NEW |