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

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

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

Powered by Google App Engine
This is Rietveld 408576698