| 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 #include "chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h" | 5 #include "chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h" |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #import "chrome/browser/themes/theme_properties.h" | 8 #import "chrome/browser/themes/theme_properties.h" |
| 9 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 9 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 10 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 10 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
| 11 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 11 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| 12 #import "chrome/browser/ui/cocoa/themed_window.h" | 12 #import "chrome/browser/ui/cocoa/themed_window.h" |
| 13 #include "chrome/browser/ui/infobar_container_delegate.h" | 13 #include "chrome/browser/ui/infobar_container_delegate.h" |
| 14 #include "components/infobars/core/infobar.h" | 14 #include "components/infobars/core/infobar.h" |
| 15 #include "skia/ext/skia_utils_mac.h" | 15 #include "skia/ext/skia_utils_mac.h" |
| 16 #import "ui/base/cocoa/nsview_additions.h" | 16 #import "ui/base/cocoa/nsview_additions.h" |
| 17 #include "ui/base/material_design/material_design_controller.h" |
| 17 #include "ui/base/theme_provider.h" | 18 #include "ui/base/theme_provider.h" |
| 18 | 19 |
| 19 @implementation InfoBarGradientView | 20 @implementation InfoBarGradientView |
| 20 | 21 |
| 21 @synthesize arrowHeight = arrowHeight_; | 22 @synthesize arrowHeight = arrowHeight_; |
| 22 @synthesize arrowHalfWidth = arrowHalfWidth_; | 23 @synthesize arrowHalfWidth = arrowHalfWidth_; |
| 23 @synthesize arrowX = arrowX_; | 24 @synthesize arrowX = arrowX_; |
| 24 @synthesize hasTip = hasTip_; | 25 @synthesize hasTip = hasTip_; |
| 25 | 26 |
| 26 - (id)initWithFrame:(NSRect)frame { | 27 - (id)initWithFrame:(NSRect)frame { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 52 return [NSColor blackColor]; | 53 return [NSColor blackColor]; |
| 53 | 54 |
| 54 BOOL active = [[self window] isMainWindow]; | 55 BOOL active = [[self window] isMainWindow]; |
| 55 return themeProvider->GetNSColor( | 56 return themeProvider->GetNSColor( |
| 56 active ? ThemeProperties::COLOR_TOOLBAR_STROKE : | 57 active ? ThemeProperties::COLOR_TOOLBAR_STROKE : |
| 57 ThemeProperties::COLOR_TOOLBAR_STROKE_INACTIVE); | 58 ThemeProperties::COLOR_TOOLBAR_STROKE_INACTIVE); |
| 58 } | 59 } |
| 59 | 60 |
| 60 - (void)drawRect:(NSRect)rect { | 61 - (void)drawRect:(NSRect)rect { |
| 61 NSRect bounds = [self bounds]; | 62 NSRect bounds = [self bounds]; |
| 62 bounds.size.height = InfoBarContainerDelegate::kDefaultBarTargetHeight; | 63 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 63 | 64 bounds.size.height = InfoBarContainerDelegate::kDefaultBarTargetHeightMd; |
| 65 } else { |
| 66 bounds.size.height = InfoBarContainerDelegate::kDefaultBarTargetHeight; |
| 67 } |
| 64 CGFloat tipXOffset = arrowX_ - arrowHalfWidth_; | 68 CGFloat tipXOffset = arrowX_ - arrowHalfWidth_; |
| 65 | 69 |
| 66 // Around the bounds of the infobar, continue drawing the path into which the | 70 // Around the bounds of the infobar, continue drawing the path into which the |
| 67 // gradient will be drawn. | 71 // gradient will be drawn. |
| 68 NSBezierPath* infoBarPath = [NSBezierPath bezierPath]; | 72 NSBezierPath* infoBarPath = [NSBezierPath bezierPath]; |
| 69 [infoBarPath moveToPoint:NSMakePoint(NSMinX(bounds), NSMaxY(bounds))]; | 73 [infoBarPath moveToPoint:NSMakePoint(NSMinX(bounds), NSMaxY(bounds))]; |
| 70 | 74 |
| 71 // Draw the tip. | 75 // Draw the tip. |
| 72 if (hasTip_) { | 76 if (hasTip_) { |
| 73 [infoBarPath lineToPoint:NSMakePoint(tipXOffset, NSMaxY(bounds))]; | 77 [infoBarPath lineToPoint:NSMakePoint(tipXOffset, NSMaxY(bounds))]; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 } | 141 } |
| 138 | 142 |
| 139 - (void)setHasTip:(BOOL)hasTip { | 143 - (void)setHasTip:(BOOL)hasTip { |
| 140 if (hasTip_ == hasTip) | 144 if (hasTip_ == hasTip) |
| 141 return; | 145 return; |
| 142 hasTip_ = hasTip; | 146 hasTip_ = hasTip; |
| 143 [self setNeedsDisplay:YES]; | 147 [self setNeedsDisplay:YES]; |
| 144 } | 148 } |
| 145 | 149 |
| 146 @end | 150 @end |
| OLD | NEW |