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

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

Issue 1680773006: Implement Material Design for Mac toolbar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@md_master
Patch Set: Change button hover and pressed styles. Created 4 years, 9 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) 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 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h" 5 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h"
6 6
7 #include "chrome/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/command_updater.h" 8 #include "chrome/browser/command_updater.h"
9 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" 9 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
10 #import "chrome/browser/ui/cocoa/themed_window.h"
10 #include "chrome/grit/generated_resources.h" 11 #include "chrome/grit/generated_resources.h"
11 #include "grit/components_strings.h" 12 #include "grit/components_strings.h"
12 #include "grit/theme_resources.h" 13 #include "grit/theme_resources.h"
13 #include "ui/base/l10n/l10n_util_mac.h" 14 #include "ui/base/l10n/l10n_util_mac.h"
15 #include "ui/base/material_design/material_design_controller.h"
16 #include "ui/gfx/image/image_skia_util_mac.h"
17 #include "ui/gfx/paint_vector_icon.h"
18 #include "ui/gfx/vector_icons_public.h"
14 19
15 namespace { 20 namespace {
16 21
17 // The info-bubble point should look like it points to the point 22 // The info-bubble point should look like it points to the point
18 // between the star's lower tips. The popup should be where the 23 // between the star's lower tips. The popup should be where the
19 // Omnibox popup ends up (2px below field). Determined via Pixie.app 24 // Omnibox popup ends up (2px below field). Determined via Pixie.app
20 // magnification. 25 // magnification.
21 const CGFloat kStarPointYOffset = 2.0; 26 const CGFloat kStarPointYOffset = 2.0;
22 27
23 } // namespace 28 } // namespace
24 29
25 StarDecoration::StarDecoration(CommandUpdater* command_updater) 30 StarDecoration::StarDecoration(CommandUpdater* command_updater)
26 : command_updater_(command_updater) { 31 : command_updater_(command_updater) {
27 SetVisible(true); 32 SetVisible(true);
28 SetStarred(false); 33 SetStarred(false, false);
29 } 34 }
30 35
31 StarDecoration::~StarDecoration() { 36 StarDecoration::~StarDecoration() {
32 } 37 }
33 38
34 void StarDecoration::SetStarred(bool starred) { 39 void StarDecoration::SetStarred(bool starred, bool locationBarIsDark) {
35 starred_ = starred; 40 starred_ = starred;
36 const int image_id = starred ? IDR_STAR_LIT : IDR_STAR; 41 const int image_id = starred ? IDR_STAR_LIT : IDR_STAR;
37 const int tip_id = starred ? IDS_TOOLTIP_STARRED : IDS_TOOLTIP_STAR; 42 const int tip_id = starred ? IDS_TOOLTIP_STARRED : IDS_TOOLTIP_STAR;
38 SetImage(OmniboxViewMac::ImageForResource(image_id)); 43 if (ui::MaterialDesignController::IsModeMaterial()) {
44 NSImage* theImage;
45 gfx::VectorIconId iconId = starred_ ?
46 gfx::VectorIconId::LOCATION_BAR_STAR_ACTIVE :
47 gfx::VectorIconId::LOCATION_BAR_STAR;
48 if (locationBarIsDark) {
49 theImage = NSImageFromImageSkia(gfx::CreateVectorIcon(
50 iconId, 16, SK_ColorWHITE));
51 } else {
52 theImage = NSImageFromImageSkia(gfx::CreateVectorIcon(
53 iconId, 16, SkColorSetARGB(0xFF, 0x5A, 0x5A, 0x5A)));
54 }
55 SetImage(theImage);
56 } else {
57 SetImage(OmniboxViewMac::ImageForResource(image_id));
58 }
39 tooltip_.reset([l10n_util::GetNSStringWithFixup(tip_id) retain]); 59 tooltip_.reset([l10n_util::GetNSStringWithFixup(tip_id) retain]);
40 } 60 }
41 61
42 NSPoint StarDecoration::GetBubblePointInFrame(NSRect frame) { 62 NSPoint StarDecoration::GetBubblePointInFrame(NSRect frame) {
43 const NSRect draw_frame = GetDrawRectInFrame(frame); 63 const NSRect draw_frame = GetDrawRectInFrame(frame);
44 return NSMakePoint(NSMidX(draw_frame), 64 return NSMakePoint(NSMidX(draw_frame),
45 NSMaxY(draw_frame) - kStarPointYOffset); 65 NSMaxY(draw_frame) - kStarPointYOffset);
46 } 66 }
47 67
48 bool StarDecoration::AcceptsMousePress() { 68 bool StarDecoration::AcceptsMousePress() {
49 return true; 69 return true;
50 } 70 }
51 71
52 bool StarDecoration::OnMousePressed(NSRect frame, NSPoint location) { 72 bool StarDecoration::OnMousePressed(NSRect frame, NSPoint location) {
53 command_updater_->ExecuteCommand(IDC_BOOKMARK_PAGE); 73 command_updater_->ExecuteCommand(IDC_BOOKMARK_PAGE);
54 return true; 74 return true;
55 } 75 }
56 76
57 NSString* StarDecoration::GetToolTip() { 77 NSString* StarDecoration::GetToolTip() {
58 return tooltip_.get(); 78 return tooltip_.get();
59 } 79 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/star_decoration.h ('k') | chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698