| 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/infobars/infobar_utilities.h" | 5 #import "chrome/browser/ui/cocoa/infobars/infobar_utilities.h" |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #import "chrome/browser/infobars/infobar.h" |
| 8 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 9 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
| 9 #import "chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h" | 10 #import "chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h" |
| 10 | 11 |
| 11 namespace InfoBarUtilities { | 12 namespace InfoBarUtilities { |
| 12 | 13 |
| 13 // Move the |toMove| view |spacing| pixels before/after the |anchor| view. | 14 // Move the |toMove| view |spacing| pixels before/after the |anchor| view. |
| 14 // |after| signifies the side of |anchor| on which to place |toMove|. | 15 // |after| signifies the side of |anchor| on which to place |toMove|. |
| 15 void MoveControl(NSView* anchor, NSView* toMove, int spacing, bool after) { | 16 void MoveControl(NSView* anchor, NSView* toMove, int spacing, bool after) { |
| 16 NSRect anchorFrame = [anchor frame]; | 17 NSRect anchorFrame = [anchor frame]; |
| 17 NSRect toMoveFrame = [toMove frame]; | 18 NSRect toMoveFrame = [toMove frame]; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 40 | 41 |
| 41 // Vertically center |toMove| in its container. | 42 // Vertically center |toMove| in its container. |
| 42 void VerticallyCenterView(NSView* toMove) { | 43 void VerticallyCenterView(NSView* toMove) { |
| 43 NSRect superViewFrame = [[toMove superview] frame]; | 44 NSRect superViewFrame = [[toMove superview] frame]; |
| 44 NSRect viewFrame = [toMove frame]; | 45 NSRect viewFrame = [toMove frame]; |
| 45 // If the superview is the infobar view, then subtract out the anti-spoof | 46 // If the superview is the infobar view, then subtract out the anti-spoof |
| 46 // height so that the content is centered in the content area of the infobar, | 47 // height so that the content is centered in the content area of the infobar, |
| 47 // rather than in the total height (which includes the bulge). | 48 // rather than in the total height (which includes the bulge). |
| 48 CGFloat superHeight = NSHeight(superViewFrame); | 49 CGFloat superHeight = NSHeight(superViewFrame); |
| 49 if ([[toMove superview] isKindOfClass:[InfoBarGradientView class]]) | 50 if ([[toMove superview] isKindOfClass:[InfoBarGradientView class]]) |
| 50 superHeight = infobars::kBaseHeight; | 51 superHeight = InfoBar::kDefaultBarTargetHeight; |
| 51 viewFrame.origin.y = | 52 viewFrame.origin.y = |
| 52 floor((superHeight - NSHeight(viewFrame)) / 2.0); | 53 floor((superHeight - NSHeight(viewFrame)) / 2.0); |
| 53 [toMove setFrame:viewFrame]; | 54 [toMove setFrame:viewFrame]; |
| 54 } | 55 } |
| 55 | 56 |
| 56 // Creates a label control in the style we need for the infobar's labels | 57 // Creates a label control in the style we need for the infobar's labels |
| 57 // within |bounds|. | 58 // within |bounds|. |
| 58 NSTextField* CreateLabel(NSRect bounds) { | 59 NSTextField* CreateLabel(NSRect bounds) { |
| 59 NSTextField* ret = [[NSTextField alloc] initWithFrame:bounds]; | 60 NSTextField* ret = [[NSTextField alloc] initWithFrame:bounds]; |
| 60 [ret setEditable:NO]; | 61 [ret setEditable:NO]; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 77 [menu addItem:item]; | 78 [menu addItem:item]; |
| 78 [item setTarget:target]; | 79 [item setTarget:target]; |
| 79 if (checked) | 80 if (checked) |
| 80 [item setState:NSOnState]; | 81 [item setState:NSOnState]; |
| 81 if (!enabled) | 82 if (!enabled) |
| 82 [item setEnabled:NO]; | 83 [item setEnabled:NO]; |
| 83 } | 84 } |
| 84 } | 85 } |
| 85 | 86 |
| 86 } // namespace InfoBarUtilities | 87 } // namespace InfoBarUtilities |
| OLD | NEW |