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

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/bubble_decoration.mm

Issue 2077743005: [Mac][Material Design] Adjust (i) and lock Omnibox icons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes for non-Retina. Created 4 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
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 #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"
11 #import "chrome/browser/ui/cocoa/themed_window.h" 11 #import "chrome/browser/ui/cocoa/themed_window.h"
12 #include "skia/ext/skia_utils_mac.h" 12 #include "skia/ext/skia_utils_mac.h"
13 #import "ui/base/cocoa/nsview_additions.h" 13 #import "ui/base/cocoa/nsview_additions.h"
14 #include "ui/base/material_design/material_design_controller.h" 14 #include "ui/base/material_design/material_design_controller.h"
15 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
15 16
16 namespace { 17 namespace {
17 18
18 // This is used to increase the right margin of this decoration. 19 // This is used to increase the right margin of this decoration.
19 const CGFloat kRightSideMargin = 1.0; 20 const CGFloat kRightSideMargin = 1.0;
20 21
21 // Padding between the icon/label and bubble edges. 22 // Padding between the icon/label and bubble edges.
22 CGFloat BubblePadding() { 23 CGFloat BubblePadding() {
23 return ui::MaterialDesignController::IsModeMaterial() ? 8.0 : 3.0; 24 return ui::MaterialDesignController::IsModeMaterial() ? 8.0 : 3.0;
24 } 25 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 NSColor* text_color = 126 NSColor* text_color =
126 in_dark_mode 127 in_dark_mode
127 ? skia::SkColorToSRGBNSColor(kMaterialDarkModeTextColor) 128 ? skia::SkColorToSRGBNSColor(kMaterialDarkModeTextColor)
128 : GetBackgroundBorderColor(); 129 : GetBackgroundBorderColor();
129 SetTextColor(text_color); 130 SetTextColor(text_color);
130 } 131 }
131 132
132 if (label_) { 133 if (label_) {
133 NSRect textRect = frame; 134 NSRect textRect = frame;
134 textRect.origin.x = textOffset; 135 textRect.origin.x = textOffset;
135 textRect.origin.y += baseline_offset_;
136 textRect.size.width = NSMaxX(decoration_frame) - NSMinX(textRect); 136 textRect.size.width = NSMaxX(decoration_frame) - NSMinX(textRect);
137 // Transform the coordinate system to adjust the baseline. This is the only
138 // way to get fractional adjustments.
139 gfx::ScopedNSGraphicsContextSaveGState saveGraphicsState;
140 if (baseline_offset_) {
tapted 2016/06/22 05:40:38 Nothing currently calls SetBaselineOffset -- you c
shrike 2016/06/22 21:44:50 Acknowledged.
141 NSAffineTransform* transform = [NSAffineTransform transform];
142 [transform translateXBy:0 yBy:baseline_offset_];
143 [transform concat];
144 }
137 DrawLabel(label_, attributes_, textRect); 145 DrawLabel(label_, attributes_, textRect);
138 } 146 }
139 } 147 }
140 148
141 void BubbleDecoration::DrawWithBackgroundInFrame(NSRect background_frame, 149 void BubbleDecoration::DrawWithBackgroundInFrame(NSRect background_frame,
142 NSRect frame, 150 NSRect frame,
143 NSView* control_view) { 151 NSView* control_view) {
144 NSRect rect = NSInsetRect(background_frame, 0, 1); 152 NSRect rect = NSInsetRect(background_frame, 0, 1);
145 rect.size.width -= kRightSideMargin; 153 rect.size.width -= kRightSideMargin;
146 if (!ui::MaterialDesignController::IsModeMaterial()) { 154 if (!ui::MaterialDesignController::IsModeMaterial()) {
(...skipping 28 matching lines...) Expand all
175 [attributes_ setObject:text_color forKey:NSForegroundColorAttributeName]; 183 [attributes_ setObject:text_color forKey:NSForegroundColorAttributeName];
176 } 184 }
177 185
178 void BubbleDecoration::SetFont(NSFont* font) { 186 void BubbleDecoration::SetFont(NSFont* font) {
179 [attributes_ setObject:font forKey:NSFontAttributeName]; 187 [attributes_ setObject:font forKey:NSFontAttributeName];
180 } 188 }
181 189
182 void BubbleDecoration::SetBaselineOffset(CGFloat offset) { 190 void BubbleDecoration::SetBaselineOffset(CGFloat offset) {
183 baseline_offset_ = offset; 191 baseline_offset_ = offset;
184 } 192 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698