| OLD | NEW |
| 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 #include <cmath> | 5 #include <cmath> |
| 6 | 6 |
| 7 #import "chrome/browser/ui/cocoa/location_bar/bubble_decoration.h" | 7 #import "chrome/browser/ui/cocoa/location_bar/bubble_decoration.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 imageRect.size = imageSize; | 93 imageRect.size = imageSize; |
| 94 [image_ drawInRect:imageRect | 94 [image_ drawInRect:imageRect |
| 95 fromRect:NSZeroRect // Entire image | 95 fromRect:NSZeroRect // Entire image |
| 96 operation:NSCompositeSourceOver | 96 operation:NSCompositeSourceOver |
| 97 fraction:1.0 | 97 fraction:1.0 |
| 98 respectFlipped:YES | 98 respectFlipped:YES |
| 99 hints:nil]; | 99 hints:nil]; |
| 100 textOffset = NSMaxX(imageRect) + kIconLabelPadding; | 100 textOffset = NSMaxX(imageRect) + kIconLabelPadding; |
| 101 } | 101 } |
| 102 | 102 |
| 103 // Draw the divider and set the text color. |
| 104 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 105 NSBezierPath* line = [NSBezierPath bezierPath]; |
| 106 [line setLineWidth:1]; |
| 107 [line moveToPoint:NSMakePoint(NSMaxX(decoration_frame) - DividerPadding(), |
| 108 NSMinY(decoration_frame))]; |
| 109 [line lineToPoint:NSMakePoint(NSMaxX(decoration_frame) - DividerPadding(), |
| 110 NSMaxY(decoration_frame))]; |
| 111 |
| 112 bool in_dark_mode = [[control_view window] inIncognitoModeWithSystemTheme]; |
| 113 [GetDividerColor(in_dark_mode) set]; |
| 114 [line stroke]; |
| 115 |
| 116 NSColor* text_color = |
| 117 in_dark_mode |
| 118 ? skia::SkColorToSRGBNSColor(kMaterialDarkModeTextColor) |
| 119 : GetBackgroundBorderColor(); |
| 120 SetTextColor(text_color); |
| 121 } |
| 122 |
| 103 if (label_) { | 123 if (label_) { |
| 104 NSRect textRect = frame; | 124 NSRect textRect = frame; |
| 105 textRect.origin.x = textOffset; | 125 textRect.origin.x = textOffset; |
| 106 textRect.origin.y += baseline_offset_; | 126 textRect.origin.y += baseline_offset_; |
| 107 textRect.size.width = NSMaxX(decoration_frame) - NSMinX(textRect); | 127 textRect.size.width = NSMaxX(decoration_frame) - NSMinX(textRect); |
| 108 DrawLabel(label_, attributes_, textRect); | 128 DrawLabel(label_, attributes_, textRect); |
| 109 } | 129 } |
| 110 } | 130 } |
| 111 | 131 |
| 112 void BubbleDecoration::DrawWithBackgroundInFrame(NSRect background_frame, | 132 void BubbleDecoration::DrawWithBackgroundInFrame(NSRect background_frame, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 [attributes_ setObject:text_color forKey:NSForegroundColorAttributeName]; | 181 [attributes_ setObject:text_color forKey:NSForegroundColorAttributeName]; |
| 162 } | 182 } |
| 163 | 183 |
| 164 void BubbleDecoration::SetFont(NSFont* font) { | 184 void BubbleDecoration::SetFont(NSFont* font) { |
| 165 [attributes_ setObject:font forKey:NSFontAttributeName]; | 185 [attributes_ setObject:font forKey:NSFontAttributeName]; |
| 166 } | 186 } |
| 167 | 187 |
| 168 void BubbleDecoration::SetBaselineOffset(CGFloat offset) { | 188 void BubbleDecoration::SetBaselineOffset(CGFloat offset) { |
| 169 baseline_offset_ = offset; | 189 baseline_offset_ = offset; |
| 170 } | 190 } |
| OLD | NEW |