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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm

Issue 738213002: [Extensions Toolbar Mac] Fix chevron position after animation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avi's Created 6 years, 1 month 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) 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
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
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 NSViewAnimationTargetKey : chevronMenuButton_.get(),
735 NSViewAnimationEffectKey : animationEffect
736 };
738 [chevronAnimation_ setViewAnimations: 737 [chevronAnimation_ setViewAnimations:
739 [NSArray arrayWithObject:animationDictionary]]; 738 [NSArray arrayWithObject:animationDictionary]];
740 [chevronAnimation_ startAnimation]; 739 [chevronAnimation_ startAnimation];
741 } 740 }
742 741
743 - (void)chevronItemSelected:(id)menuItem { 742 - (void)chevronItemSelected:(id)menuItem {
744 [self browserActionClicked:[menuItem representedObject]]; 743 [self browserActionClicked:[menuItem representedObject]];
745 } 744 }
746 745
747 - (void)updateGrippyCursors { 746 - (void)updateGrippyCursors {
(...skipping 11 matching lines...) Expand all
759 758
760 - (BrowserActionButton*)buttonWithIndex:(NSUInteger)index { 759 - (BrowserActionButton*)buttonWithIndex:(NSUInteger)index {
761 const std::vector<ToolbarActionViewController*>& toolbar_actions = 760 const std::vector<ToolbarActionViewController*>& toolbar_actions =
762 toolbarActionsBar_->toolbar_actions(); 761 toolbarActionsBar_->toolbar_actions();
763 if (index < toolbar_actions.size()) 762 if (index < toolbar_actions.size())
764 return [self buttonForId:toolbar_actions[index]->GetId()]; 763 return [self buttonForId:toolbar_actions[index]->GetId()];
765 return nil; 764 return nil;
766 } 765 }
767 766
768 @end 767 @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