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