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

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

Issue 2119033002: [Material][Mac] Implement Omnibox Verbose State Chips (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 years, 3 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 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
16 16
17 namespace { 17 namespace {
18 18
19 // This is used to increase the right margin of this decoration. 19 // This is used to increase the right margin of this decoration.
20 const CGFloat kRightSideMargin = 1.0; 20 const CGFloat kRightSideMargin = 1.0;
21 21
22 // Padding between the icon/label and bubble edges. 22 // Padding between the icon/label and bubble edges.
23 CGFloat BubblePadding() { 23 CGFloat BubblePadding() {
24 return ui::MaterialDesignController::IsModeMaterial() ? 8.0 : 3.0; 24 return ui::MaterialDesignController::IsModeMaterial() ? 8.0 : 3.0;
25 } 25 }
26 26
27 // Additional padding between the divider between the omnibox text and the 27 // Additional padding between the divider and the label.
28 // divider. The desired value is 8px. We get 3px by subtracting the existing 28 const CGFloat kDividerPadding = 2.0;
29 // padding in location_bar_view from 8px.
30 CGFloat DividerPadding() {
31 return ui::MaterialDesignController::IsModeMaterial() ? 2.0 : 0.0;
32 }
33 29
34 // Padding between the icon and label. 30 // Padding between the icon and label.
35 CGFloat kIconLabelPadding = 4.0; 31 CGFloat kIconLabelPadding = 4.0;
36 32
37 // Inset for the background. 33 // Inset for the background.
38 const CGFloat kBackgroundYInset = 4.0; 34 const CGFloat kBackgroundYInset = 4.0;
39 35
40 } // namespace 36 } // namespace
41 37
42 BubbleDecoration::BubbleDecoration() : retina_baseline_offset_(0) { 38 BubbleDecoration::BubbleDecoration() : retina_baseline_offset_(0) {
43 attributes_.reset([[NSMutableDictionary alloc] init]); 39 attributes_.reset([[NSMutableDictionary alloc] init]);
44 [attributes_ setObject:LocationBarDecoration::GetFont() 40 [attributes_ setObject:LocationBarDecoration::GetFont()
45 forKey:NSFontAttributeName]; 41 forKey:NSFontAttributeName];
46 } 42 }
47 43
48 BubbleDecoration::~BubbleDecoration() { 44 BubbleDecoration::~BubbleDecoration() {
49 } 45 }
50 46
47 CGFloat BubbleDecoration::DividerPadding() const {
48 return ui::MaterialDesignController::IsModeMaterial() ? kDividerPadding : 0.0;
49 }
50
51 CGFloat BubbleDecoration::GetWidthForImageAndLabel(NSImage* image, 51 CGFloat BubbleDecoration::GetWidthForImageAndLabel(NSImage* image,
52 NSString* label) { 52 NSString* label) {
53 if (!image && !label) 53 if (!image && !label)
54 return kOmittedWidth; 54 return kOmittedWidth;
55 55
56 const CGFloat image_width = image ? [image size].width : 0.0; 56 const CGFloat image_width = image ? [image size].width : 0.0;
57 if (!label) 57 if (!label)
58 return BubblePadding() + image_width; 58 return BubblePadding() + image_width;
59 59
60 // The bubble needs to take up an integral number of pixels. 60 // The bubble needs to take up an integral number of pixels.
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 [attributes_ setObject:text_color forKey:NSForegroundColorAttributeName]; 186 [attributes_ setObject:text_color forKey:NSForegroundColorAttributeName];
187 } 187 }
188 188
189 void BubbleDecoration::SetFont(NSFont* font) { 189 void BubbleDecoration::SetFont(NSFont* font) {
190 [attributes_ setObject:font forKey:NSFontAttributeName]; 190 [attributes_ setObject:font forKey:NSFontAttributeName];
191 } 191 }
192 192
193 void BubbleDecoration::SetRetinaBaselineOffset(CGFloat offset) { 193 void BubbleDecoration::SetRetinaBaselineOffset(CGFloat offset) {
194 retina_baseline_offset_ = offset; 194 retina_baseline_offset_ = offset;
195 } 195 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/bubble_decoration.h ('k') | chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698