Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/extensions/browser_actions_controller.h" | 5 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 675 inFrame:frame | 675 inFrame:frame |
| 676 animate:animate]; | 676 animate:animate]; |
| 677 } | 677 } |
| 678 | 678 |
| 679 - (void)updateChevronPositionInFrame:(NSRect)frame { | 679 - (void)updateChevronPositionInFrame:(NSRect)frame { |
| 680 CGFloat xPos = NSWidth(frame) - kChevronWidth; | 680 CGFloat xPos = NSWidth(frame) - kChevronWidth; |
| 681 NSRect buttonFrame = NSMakeRect(xPos, | 681 NSRect buttonFrame = NSMakeRect(xPos, |
| 682 kBrowserActionOriginYOffset, | 682 kBrowserActionOriginYOffset, |
| 683 kChevronWidth, | 683 kChevronWidth, |
| 684 ToolbarActionsBar::IconHeight()); | 684 ToolbarActionsBar::IconHeight()); |
| 685 [chevronAnimation_ stopAnimation]; | |
| 685 [chevronMenuButton_ setFrame:buttonFrame]; | 686 [chevronMenuButton_ setFrame:buttonFrame]; |
| 686 } | 687 } |
| 687 | 688 |
| 688 - (void)setChevronHidden:(BOOL)hidden | 689 - (void)setChevronHidden:(BOOL)hidden |
| 689 inFrame:(NSRect)frame | 690 inFrame:(NSRect)frame |
| 690 animate:(BOOL)animate { | 691 animate:(BOOL)animate { |
| 691 if (hidden == [self chevronIsHidden]) | 692 if (hidden == [self chevronIsHidden]) |
| 692 return; | 693 return; |
| 693 | 694 |
| 694 if (!chevronMenuButton_.get()) { | 695 if (!chevronMenuButton_.get()) { |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 715 [self updateChevronPositionInFrame:frame]; | 716 [self updateChevronPositionInFrame:frame]; |
| 716 | 717 |
| 717 // Stop any running animation. | 718 // Stop any running animation. |
| 718 [chevronAnimation_ stopAnimation]; | 719 [chevronAnimation_ stopAnimation]; |
| 719 | 720 |
| 720 if (!animate) { | 721 if (!animate) { |
| 721 [chevronMenuButton_ setHidden:hidden]; | 722 [chevronMenuButton_ setHidden:hidden]; |
| 722 return; | 723 return; |
| 723 } | 724 } |
| 724 | 725 |
| 725 NSDictionary* animationDictionary; | 726 NSString* animationEffect; |
| 726 if (hidden) { | 727 if (hidden) { |
| 727 animationDictionary = [NSDictionary dictionaryWithObjectsAndKeys: | 728 animationEffect = NSViewAnimationFadeOutEffect; |
| 728 chevronMenuButton_.get(), NSViewAnimationTargetKey, | |
| 729 NSViewAnimationFadeOutEffect, NSViewAnimationEffectKey, | |
| 730 nil]; | |
| 731 } else { | 729 } else { |
| 732 [chevronMenuButton_ setHidden:NO]; | 730 [chevronMenuButton_ setHidden:NO]; |
| 733 animationDictionary = [NSDictionary dictionaryWithObjectsAndKeys: | 731 animationEffect = NSViewAnimationFadeInEffect; |
| 734 chevronMenuButton_.get(), NSViewAnimationTargetKey, | |
| 735 NSViewAnimationFadeInEffect, NSViewAnimationEffectKey, | |
| 736 nil]; | |
| 737 } | 732 } |
| 733 NSDictionary* animationDictionary = | |
| 734 [NSDictionary dictionaryWithObjectsAndKeys: | |
| 735 chevronMenuButton_.get(), NSViewAnimationTargetKey, | |
| 736 animationEffect, NSViewAnimationEffectKey, | |
| 737 nil]; | |
|
Avi (use Gerrit)
2014/11/20 00:46:48
NSDictionary* animationDictionary = @{
NSViewAni
Devlin
2014/11/20 21:13:02
ah, right, fancy new literals. Done.
| |
| 738 [chevronAnimation_ setViewAnimations: | 738 [chevronAnimation_ setViewAnimations: |
| 739 [NSArray arrayWithObject:animationDictionary]]; | 739 [NSArray arrayWithObject:animationDictionary]]; |
| 740 [chevronAnimation_ startAnimation]; | 740 [chevronAnimation_ startAnimation]; |
| 741 } | 741 } |
| 742 | 742 |
| 743 - (void)chevronItemSelected:(id)menuItem { | 743 - (void)chevronItemSelected:(id)menuItem { |
| 744 [self browserActionClicked:[menuItem representedObject]]; | 744 [self browserActionClicked:[menuItem representedObject]]; |
| 745 } | 745 } |
| 746 | 746 |
| 747 - (void)updateGrippyCursors { | 747 - (void)updateGrippyCursors { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 759 | 759 |
| 760 - (BrowserActionButton*)buttonWithIndex:(NSUInteger)index { | 760 - (BrowserActionButton*)buttonWithIndex:(NSUInteger)index { |
| 761 const std::vector<ToolbarActionViewController*>& toolbar_actions = | 761 const std::vector<ToolbarActionViewController*>& toolbar_actions = |
| 762 toolbarActionsBar_->toolbar_actions(); | 762 toolbarActionsBar_->toolbar_actions(); |
| 763 if (index < toolbar_actions.size()) | 763 if (index < toolbar_actions.size()) |
| 764 return [self buttonForId:toolbar_actions[index]->GetId()]; | 764 return [self buttonForId:toolbar_actions[index]->GetId()]; |
| 765 return nil; | 765 return nil; |
| 766 } | 766 } |
| 767 | 767 |
| 768 @end | 768 @end |
| OLD | NEW |