| 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 | |
| 123 if (label_) { | 103 if (label_) { |
| 124 NSRect textRect = frame; | 104 NSRect textRect = frame; |
| 125 textRect.origin.x = textOffset; | 105 textRect.origin.x = textOffset; |
| 126 textRect.origin.y += baseline_offset_; | 106 textRect.origin.y += baseline_offset_; |
| 127 textRect.size.width = NSMaxX(decoration_frame) - NSMinX(textRect); | 107 textRect.size.width = NSMaxX(decoration_frame) - NSMinX(textRect); |
| 128 DrawLabel(label_, attributes_, textRect); | 108 DrawLabel(label_, attributes_, textRect); |
| 129 } | 109 } |
| 130 } | 110 } |
| 131 | 111 |
| 132 void BubbleDecoration::DrawWithBackgroundInFrame(NSRect background_frame, | 112 void BubbleDecoration::DrawWithBackgroundInFrame(NSRect background_frame, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 [attributes_ setObject:text_color forKey:NSForegroundColorAttributeName]; | 161 [attributes_ setObject:text_color forKey:NSForegroundColorAttributeName]; |
| 182 } | 162 } |
| 183 | 163 |
| 184 void BubbleDecoration::SetFont(NSFont* font) { | 164 void BubbleDecoration::SetFont(NSFont* font) { |
| 185 [attributes_ setObject:font forKey:NSFontAttributeName]; | 165 [attributes_ setObject:font forKey:NSFontAttributeName]; |
| 186 } | 166 } |
| 187 | 167 |
| 188 void BubbleDecoration::SetBaselineOffset(CGFloat offset) { | 168 void BubbleDecoration::SetBaselineOffset(CGFloat offset) { |
| 189 baseline_offset_ = offset; | 169 baseline_offset_ = offset; |
| 190 } | 170 } |
| OLD | NEW |