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

Side by Side Diff: ui/message_center/cocoa/notification_controller.mm

Issue 1487373003: Reposition the settings button as part of the notification update method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "ui/message_center/cocoa/notification_controller.h" 5 #import "ui/message_center/cocoa/notification_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 } else { 450 } else {
451 message = notification->context_message(); 451 message = notification->context_message();
452 } 452 }
453 453
454 base::string16 elided = 454 base::string16 elided =
455 [self wrapText:message 455 [self wrapText:message
456 forFont:[contextMessage_ font] 456 forFont:[contextMessage_ font]
457 maxNumberOfLines:message_center::kContextMessageLineLimit]; 457 maxNumberOfLines:message_center::kContextMessageLineLimit];
458 [contextMessage_ setString:base::SysUTF16ToNSString(elided)]; 458 [contextMessage_ setString:base::SysUTF16ToNSString(elided)];
459 [contextMessage_ sizeToFit]; 459 [contextMessage_ sizeToFit];
460
460 NSRect contextMessageFrame = [contextMessage_ frame]; 461 NSRect contextMessageFrame = [contextMessage_ frame];
461 462
462 if (notification->context_message().empty() && 463 if (notification->context_message().empty() &&
463 !notification->UseOriginAsContextMessage()) { 464 !notification->UseOriginAsContextMessage()) {
464 [contextMessage_ setHidden:YES]; 465 [contextMessage_ setHidden:YES];
465 contextMessageFrame.origin.y = messageFrame.origin.y; 466 contextMessageFrame.origin.y = messageFrame.origin.y;
466 contextMessageFrame.size.height = 0; 467 contextMessageFrame.size.height = 0;
467 } else { 468 } else {
468 [contextMessage_ setHidden:NO]; 469 [contextMessage_ setHidden:NO];
469 contextMessageFrame.origin.y = 470 contextMessageFrame.origin.y =
470 NSMinY(messageFrame) - 471 NSMinY(messageFrame) -
471 contextMessagePadding - 472 contextMessagePadding -
472 NSHeight(contextMessageFrame); 473 NSHeight(contextMessageFrame);
473 contextMessageFrame.size.height = NSHeight([contextMessage_ frame]); 474 contextMessageFrame.size.height = NSHeight([contextMessage_ frame]);
474 } 475 }
475 476
477 NSRect settingsButtonFrame;
478 if (settingsButton_ != nil)
Robert Sesek 2015/12/02 15:59:38 You can skip the nil check here and on 669, since
Miguel Garcia 2015/12/02 16:37:00 Wow I am starting to like this ObjC business :)
479 settingsButtonFrame = [settingsButton_ frame];
480
476 // Create the list item views (up to a maximum). 481 // Create the list item views (up to a maximum).
477 [listView_ removeFromSuperview]; 482 [listView_ removeFromSuperview];
478 NSRect listFrame = NSZeroRect; 483 NSRect listFrame = NSZeroRect;
479 if (items.size() > 0) { 484 if (items.size() > 0) {
480 listFrame = [self currentContentRect]; 485 listFrame = [self currentContentRect];
481 listFrame.origin.y = 0; 486 listFrame.origin.y = 0;
482 listFrame.size.height = 0; 487 listFrame.size.height = 0;
483 listView_.reset([[NSView alloc] initWithFrame:listFrame]); 488 listView_.reset([[NSView alloc] initWithFrame:listFrame]);
484 [listView_ accessibilitySetOverrideValue:NSAccessibilityListRole 489 [listView_ accessibilitySetOverrideValue:NSAccessibilityListRole
485 forAttribute:NSAccessibilityRoleAttribute]; 490 forAttribute:NSAccessibilityRoleAttribute];
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 messageFrame.origin.y += bottomAdjust; 659 messageFrame.origin.y += bottomAdjust;
655 contextMessageFrame.origin.y += bottomAdjust; 660 contextMessageFrame.origin.y += bottomAdjust;
656 listFrame.origin.y += bottomAdjust; 661 listFrame.origin.y += bottomAdjust;
657 progressBarFrame.origin.y += bottomAdjust; 662 progressBarFrame.origin.y += bottomAdjust;
658 } 663 }
659 664
660 [[self view] setFrame:rootFrame]; 665 [[self view] setFrame:rootFrame];
661 [title_ setFrame:titleFrame]; 666 [title_ setFrame:titleFrame];
662 [message_ setFrame:messageFrame]; 667 [message_ setFrame:messageFrame];
663 [contextMessage_ setFrame:contextMessageFrame]; 668 [contextMessage_ setFrame:contextMessageFrame];
669 if (settingsButton_ != nil)
670 [settingsButton_ setFrame:settingsButtonFrame];
664 [listView_ setFrame:listFrame]; 671 [listView_ setFrame:listFrame];
665 [progressBarView_ setFrame:progressBarFrame]; 672 [progressBarView_ setFrame:progressBarFrame];
666 673
667 return rootFrame; 674 return rootFrame;
668 } 675 }
669 676
670 - (void)close:(id)sender { 677 - (void)close:(id)sender {
671 [closeButton_ setTarget:nil]; 678 [closeButton_ setTarget:nil];
672 messageCenter_->RemoveNotification([self notificationID], /*by_user=*/true); 679 messageCenter_->RemoveNotification([self notificationID], /*by_user=*/true);
673 } 680 }
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 forFont:(NSFont*)nsfont 964 forFont:(NSFont*)nsfont
958 maxNumberOfLines:(size_t)lines { 965 maxNumberOfLines:(size_t)lines {
959 size_t unused; 966 size_t unused;
960 return [self wrapText:text 967 return [self wrapText:text
961 forFont:nsfont 968 forFont:nsfont
962 maxNumberOfLines:lines 969 maxNumberOfLines:lines
963 actualLines:&unused]; 970 actualLines:&unused];
964 } 971 }
965 972
966 @end 973 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698