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

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

Issue 2622613002: Revert of [Mac] Flip toolbar in RTL (Closed)
Patch Set: Created 3 years, 11 months 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/strings/sys_string_conversions.h" 13 #include "base/strings/sys_string_conversions.h"
14 #include "chrome/browser/extensions/extension_message_bubble_controller.h" 14 #include "chrome/browser/extensions/extension_message_bubble_controller.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_window.h" 16 #include "chrome/browser/ui/browser_window.h"
17 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 17 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
18 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h" 18 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h"
19 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h" 19 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h"
20 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" 20 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h"
21 #import "chrome/browser/ui/cocoa/extensions/toolbar_actions_bar_bubble_mac.h" 21 #import "chrome/browser/ui/cocoa/extensions/toolbar_actions_bar_bubble_mac.h"
22 #import "chrome/browser/ui/cocoa/image_button_cell.h" 22 #import "chrome/browser/ui/cocoa/image_button_cell.h"
23 #import "chrome/browser/ui/cocoa/l10n_util.h"
24 #import "chrome/browser/ui/cocoa/menu_button.h" 23 #import "chrome/browser/ui/cocoa/menu_button.h"
25 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 24 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
26 #include "chrome/browser/ui/extensions/extension_message_bubble_bridge.h" 25 #include "chrome/browser/ui/extensions/extension_message_bubble_bridge.h"
27 #include "chrome/browser/ui/tabs/tab_strip_model.h" 26 #include "chrome/browser/ui/tabs/tab_strip_model.h"
28 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" 27 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
29 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" 28 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h"
30 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_delegate.h" 29 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_delegate.h"
31 #include "chrome/grit/theme_resources.h" 30 #include "chrome/grit/theme_resources.h"
32 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h " 31 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h "
33 #include "ui/base/cocoa/appkit_utils.h" 32 #include "ui/base/cocoa/appkit_utils.h"
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 - (void)updateButtonPositions { 574 - (void)updateButtonPositions {
576 for (NSUInteger index = 0; index < [buttons_ count]; ++index) { 575 for (NSUInteger index = 0; index < [buttons_ count]; ++index) {
577 BrowserActionButton* button = [buttons_ objectAtIndex:index]; 576 BrowserActionButton* button = [buttons_ objectAtIndex:index];
578 NSRect buttonFrame = [self frameForIndex:index]; 577 NSRect buttonFrame = [self frameForIndex:index];
579 578
580 // If the button is at the proper position (or animating to it), then we 579 // If the button is at the proper position (or animating to it), then we
581 // don't need to update its position. 580 // don't need to update its position.
582 if (NSMinX([button frameAfterAnimation]) == NSMinX(buttonFrame)) 581 if (NSMinX([button frameAfterAnimation]) == NSMinX(buttonFrame))
583 continue; 582 continue;
584 583
585 // In LTR, We set the x-origin by calculating the proper distance from the 584 // We set the x-origin by calculating the proper distance from the right
586 // right edge in the container so that, if the container is animating, the 585 // edge in the container so that, if the container is animating, the
587 // button appears stationary. 586 // button appears stationary.
588 if (!cocoa_l10n_util::ShouldDoExperimentalRTLLayout()) { 587 buttonFrame.origin.x = NSWidth([containerView_ frame]) -
589 buttonFrame.origin.x = NSWidth([containerView_ frame]) - 588 (toolbarActionsBar_->GetPreferredSize().width() - NSMinX(buttonFrame));
590 (toolbarActionsBar_->GetPreferredSize().width() -
591 NSMinX(buttonFrame));
592 }
593 [button setFrame:buttonFrame animate:NO]; 589 [button setFrame:buttonFrame animate:NO];
594 } 590 }
595 } 591 }
596 592
597 - (BrowserActionButton*)buttonForId:(const std::string&)id { 593 - (BrowserActionButton*)buttonForId:(const std::string&)id {
598 for (BrowserActionButton* button in buttons_.get()) { 594 for (BrowserActionButton* button in buttons_.get()) {
599 if ([button viewController]->GetId() == id) 595 if ([button viewController]->GetId() == id)
600 return button; 596 return button;
601 } 597 }
602 return nil; 598 return nil;
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 [button setFrame:buttonFrame 776 [button setFrame:buttonFrame
781 animate:!toolbarActionsBar_->suppress_animation() && !isOverflow_]; 777 animate:!toolbarActionsBar_->suppress_animation() && !isOverflow_];
782 } 778 }
783 } 779 }
784 780
785 - (BOOL)browserActionClicked:(BrowserActionButton*)button { 781 - (BOOL)browserActionClicked:(BrowserActionButton*)button {
786 return [button viewController]->ExecuteAction(true); 782 return [button viewController]->ExecuteAction(true);
787 } 783 }
788 784
789 - (void)updateGrippyCursors { 785 - (void)updateGrippyCursors {
790 BOOL canClose = [self visibleButtonCount] > 0;
791 BOOL canOpen = toolbarActionsBar_->GetIconCount() != [buttons_ count];
792 [containerView_ 786 [containerView_
793 setCanDragLeft:cocoa_l10n_util::ShouldDoExperimentalRTLLayout() 787 setCanDragLeft:toolbarActionsBar_->GetIconCount() != [buttons_ count]];
794 ? canClose 788 [containerView_ setCanDragRight:[self visibleButtonCount] > 0];
795 : canOpen];
796 [containerView_
797 setCanDragRight:cocoa_l10n_util::ShouldDoExperimentalRTLLayout()
798 ? canOpen
799 : canClose];
800 [[containerView_ window] invalidateCursorRectsForView:containerView_]; 789 [[containerView_ window] invalidateCursorRectsForView:containerView_];
801 } 790 }
802 791
803 - (ToolbarController*)toolbarController { 792 - (ToolbarController*)toolbarController {
804 return [[BrowserWindowController browserWindowControllerForWindow: 793 return [[BrowserWindowController browserWindowControllerForWindow:
805 browser_->window()->GetNativeWindow()] toolbarController]; 794 browser_->window()->GetNativeWindow()] toolbarController];
806 } 795 }
807 796
808 - (void)createMessageBubble: 797 - (void)createMessageBubble:
809 (std::unique_ptr<ToolbarActionsBarBubbleDelegate>)delegate { 798 (std::unique_ptr<ToolbarActionsBarBubbleDelegate>)delegate {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 } 840 }
852 841
853 #pragma mark - 842 #pragma mark -
854 #pragma mark Testing Methods 843 #pragma mark Testing Methods
855 844
856 - (BrowserActionButton*)buttonWithIndex:(NSUInteger)index { 845 - (BrowserActionButton*)buttonWithIndex:(NSUInteger)index {
857 return index < [buttons_ count] ? [buttons_ objectAtIndex:index] : nil; 846 return index < [buttons_ count] ? [buttons_ objectAtIndex:index] : nil;
858 } 847 }
859 848
860 @end 849 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698