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

Side by Side Diff: chrome/browser/cocoa/toolbar_controller.mm

Issue 2863013: [Mac] UI changes for the Browser Actions toolbar container.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/cocoa/extensions/browser_actions_controller.mm ('k') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/cocoa/toolbar_controller.h" 5 #import "chrome/browser/cocoa/toolbar_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/l10n_util_mac.h" 9 #include "app/l10n_util_mac.h"
10 #include "base/mac_util.h" 10 #include "base/mac_util.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 NSString* const kBackButtonImageName = @"back_Template.pdf"; 48 NSString* const kBackButtonImageName = @"back_Template.pdf";
49 NSString* const kForwardButtonImageName = @"forward_Template.pdf"; 49 NSString* const kForwardButtonImageName = @"forward_Template.pdf";
50 NSString* const kReloadButtonReloadImageName = @"reload_Template.pdf"; 50 NSString* const kReloadButtonReloadImageName = @"reload_Template.pdf";
51 NSString* const kReloadButtonStopImageName = @"stop_Template.pdf"; 51 NSString* const kReloadButtonStopImageName = @"stop_Template.pdf";
52 NSString* const kHomeButtonImageName = @"home_Template.pdf"; 52 NSString* const kHomeButtonImageName = @"home_Template.pdf";
53 NSString* const kWrenchButtonImageName = @"menu_chrome_Template.pdf"; 53 NSString* const kWrenchButtonImageName = @"menu_chrome_Template.pdf";
54 54
55 // Height of the toolbar in pixels when the bookmark bar is closed. 55 // Height of the toolbar in pixels when the bookmark bar is closed.
56 const CGFloat kBaseToolbarHeight = 36.0; 56 const CGFloat kBaseToolbarHeight = 36.0;
57 57
58 // The distance from the location bar to the Browser Actions container
59 // in pixels.
60 const CGFloat kBrowserActionsContainerLeftPadding = 5.0;
61
62 // The minimum width of the location bar in pixels. 58 // The minimum width of the location bar in pixels.
63 const CGFloat kMinimumLocationBarWidth = 100.0; 59 const CGFloat kMinimumLocationBarWidth = 100.0;
64 60
65 // The duration of any animation that occurs within the toolbar in seconds. 61 // The duration of any animation that occurs within the toolbar in seconds.
66 const CGFloat kAnimationDuration = 0.2; 62 const CGFloat kAnimationDuration = 0.2;
67 63
68 } // namespace 64 } // namespace
69 65
70 @interface ToolbarController(Private) 66 @interface ToolbarController(Private)
71 - (void)addAccessibilityDescriptions; 67 - (void)addAccessibilityDescriptions;
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 [[NSNotificationCenter defaultCenter] 547 [[NSNotificationCenter defaultCenter]
552 addObserver:self 548 addObserver:self
553 selector:@selector(adjustBrowserActionsContainerForNewWindow:) 549 selector:@selector(adjustBrowserActionsContainerForNewWindow:)
554 name:NSWindowDidBecomeKeyNotification 550 name:NSWindowDidBecomeKeyNotification
555 object:[[self view] window]]; 551 object:[[self view] window]];
556 } 552 }
557 CGFloat containerWidth = [browserActionsContainerView_ isHidden] ? 0.0 : 553 CGFloat containerWidth = [browserActionsContainerView_ isHidden] ? 0.0 :
558 NSWidth([browserActionsContainerView_ frame]); 554 NSWidth([browserActionsContainerView_ frame]);
559 if (containerWidth > 0.0) 555 if (containerWidth > 0.0)
560 [self adjustLocationSizeBy:(containerWidth * -1) animate:NO]; 556 [self adjustLocationSizeBy:(containerWidth * -1) animate:NO];
561 // Right border should always be visible because wrench menu can no longer
562 // hide.
563 [browserActionsContainerView_ setRightBorderShown:YES];
564 } 557 }
565 558
566 - (void)adjustBrowserActionsContainerForNewWindow: 559 - (void)adjustBrowserActionsContainerForNewWindow:
567 (NSNotification*)notification { 560 (NSNotification*)notification {
568 [self toolbarFrameChanged]; 561 [self toolbarFrameChanged];
569 [[NSNotificationCenter defaultCenter] 562 [[NSNotificationCenter defaultCenter]
570 removeObserver:self 563 removeObserver:self
571 name:NSWindowDidBecomeKeyNotification 564 name:NSWindowDidBecomeKeyNotification
572 object:[[self view] window]]; 565 object:[[self view] window]];
573 } 566 }
(...skipping 11 matching lines...) Expand all
585 [browserActionsController_ resizeContainerAndAnimate:YES]; 578 [browserActionsController_ resizeContainerAndAnimate:YES];
586 [self pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:YES]; 579 [self pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:YES];
587 } 580 }
588 581
589 - (void)browserActionsVisibilityChanged:(NSNotification*)notification { 582 - (void)browserActionsVisibilityChanged:(NSNotification*)notification {
590 [self pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:NO]; 583 [self pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:NO];
591 } 584 }
592 585
593 - (void)pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate { 586 - (void)pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate {
594 CGFloat locationBarXPos = NSMaxX([locationBar_ frame]); 587 CGFloat locationBarXPos = NSMaxX([locationBar_ frame]);
595 CGFloat leftPadding; 588 CGFloat leftDistance;
596 589
597 if ([browserActionsContainerView_ isHidden]) { 590 if ([browserActionsContainerView_ isHidden]) {
598 CGFloat edgeXPos = [wrenchButton_ frame].origin.x; 591 CGFloat edgeXPos = [wrenchButton_ frame].origin.x;
599 leftPadding = edgeXPos - locationBarXPos; 592 leftDistance = edgeXPos - locationBarXPos;
600 } else { 593 } else {
601 NSRect containerFrame = animate ? 594 NSRect containerFrame = animate ?
602 [browserActionsContainerView_ animationEndFrame] : 595 [browserActionsContainerView_ animationEndFrame] :
603 [browserActionsContainerView_ frame]; 596 [browserActionsContainerView_ frame];
604 597
605 leftPadding = containerFrame.origin.x - locationBarXPos; 598 leftDistance = containerFrame.origin.x - locationBarXPos;
606 } 599 }
607 if (leftPadding != kBrowserActionsContainerLeftPadding) { 600 if (leftDistance != 0.0)
608 CGFloat dX = leftPadding - kBrowserActionsContainerLeftPadding; 601 [self adjustLocationSizeBy:leftDistance animate:animate];
609 [self adjustLocationSizeBy:dX animate:animate];
610 }
611 } 602 }
612 603
613 - (void)maintainMinimumLocationBarWidth { 604 - (void)maintainMinimumLocationBarWidth {
614 CGFloat locationBarWidth = NSWidth([locationBar_ frame]); 605 CGFloat locationBarWidth = NSWidth([locationBar_ frame]);
615 locationBarAtMinSize_ = locationBarWidth <= kMinimumLocationBarWidth; 606 locationBarAtMinSize_ = locationBarWidth <= kMinimumLocationBarWidth;
616 if (locationBarAtMinSize_) { 607 if (locationBarAtMinSize_) {
617 CGFloat dX = kMinimumLocationBarWidth - locationBarWidth; 608 CGFloat dX = kMinimumLocationBarWidth - locationBarWidth;
618 [self adjustLocationSizeBy:dX animate:NO]; 609 [self adjustLocationSizeBy:dX animate:NO];
619 } 610 }
620 } 611 }
621 612
622 - (void)toolbarFrameChanged { 613 - (void)toolbarFrameChanged {
623 // Do nothing if the frame changes but no Browser Action Controller is 614 // Do nothing if the frame changes but no Browser Action Controller is
624 // present. 615 // present.
625 if (!browserActionsController_.get()) 616 if (!browserActionsController_.get())
626 return; 617 return;
627 618
628 [self maintainMinimumLocationBarWidth]; 619 [self maintainMinimumLocationBarWidth];
629 620
630 if (locationBarAtMinSize_) { 621 if (locationBarAtMinSize_) {
631 // Once the grippy is pinned, leave it until it is explicity un-pinned. 622 // Once the grippy is pinned, leave it until it is explicity un-pinned.
632 [browserActionsContainerView_ setGrippyPinned:YES]; 623 [browserActionsContainerView_ setGrippyPinned:YES];
633 NSRect containerFrame = [browserActionsContainerView_ frame]; 624 NSRect containerFrame = [browserActionsContainerView_ frame];
634 // Determine how much the container needs to move in case it's overlapping 625 // Determine how much the container needs to move in case it's overlapping
635 // with the location bar. 626 // with the location bar.
636 CGFloat dX = NSMaxX([locationBar_ frame]) - 627 CGFloat dX = NSMaxX([locationBar_ frame]) - containerFrame.origin.x;
637 containerFrame.origin.x + kBrowserActionsContainerLeftPadding;
638 containerFrame = NSOffsetRect(containerFrame, dX, 0); 628 containerFrame = NSOffsetRect(containerFrame, dX, 0);
639 containerFrame.size.width -= dX; 629 containerFrame.size.width -= dX;
640 [browserActionsContainerView_ setFrame:containerFrame]; 630 [browserActionsContainerView_ setFrame:containerFrame];
641 } else if (!locationBarAtMinSize_ && 631 } else if (!locationBarAtMinSize_ &&
642 [browserActionsContainerView_ grippyPinned]) { 632 [browserActionsContainerView_ grippyPinned]) {
643 // Expand out the container until it hits the saved size, then unpin the 633 // Expand out the container until it hits the saved size, then unpin the
644 // grippy. 634 // grippy.
645 // Add 0.1 pixel so that it doesn't hit the minimum width codepath above. 635 // Add 0.1 pixel so that it doesn't hit the minimum width codepath above.
646 CGFloat dX = NSWidth([locationBar_ frame]) - 636 CGFloat dX = NSWidth([locationBar_ frame]) -
647 (kMinimumLocationBarWidth + 0.1); 637 (kMinimumLocationBarWidth + 0.1);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point { 728 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point {
739 // Do nothing. 729 // Do nothing.
740 } 730 }
741 731
742 // (URLDropTargetController protocol) 732 // (URLDropTargetController protocol)
743 - (void)hideDropURLsIndicatorInView:(NSView*)view { 733 - (void)hideDropURLsIndicatorInView:(NSView*)view {
744 // Do nothing. 734 // Do nothing.
745 } 735 }
746 736
747 @end 737 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/extensions/browser_actions_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698