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

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

Issue 2972593002: Mac: Fix up location bar decoration bubble anchoring. (Closed)
Patch Set: Created 3 years, 5 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
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/star_decoration.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #import "chrome/browser/ui/cocoa/themed_window.h"
(...skipping 23 matching lines...) Expand all
34 StarDecoration::~StarDecoration() { 34 StarDecoration::~StarDecoration() {
35 } 35 }
36 36
37 void StarDecoration::SetStarred(bool starred, bool location_bar_is_dark) { 37 void StarDecoration::SetStarred(bool starred, bool location_bar_is_dark) {
38 starred_ = starred; 38 starred_ = starred;
39 const int tip_id = starred ? IDS_TOOLTIP_STARRED : IDS_TOOLTIP_STAR; 39 const int tip_id = starred ? IDS_TOOLTIP_STARRED : IDS_TOOLTIP_STAR;
40 SetImage(GetMaterialIcon(location_bar_is_dark)); 40 SetImage(GetMaterialIcon(location_bar_is_dark));
41 tooltip_.reset([l10n_util::GetNSStringWithFixup(tip_id) retain]); 41 tooltip_.reset([l10n_util::GetNSStringWithFixup(tip_id) retain]);
42 } 42 }
43 43
44 NSPoint StarDecoration::GetBubblePointInFrame(NSRect frame) { 44 NSPoint StarDecoration::GetStarBubblePointInFrame(NSRect draw_frame) {
45 const NSRect draw_frame = GetDrawRectInFrame(frame);
46 return NSMakePoint(NSMidX(draw_frame), 45 return NSMakePoint(NSMidX(draw_frame),
47 NSMaxY(draw_frame) - kStarPointYOffset); 46 NSMaxY(draw_frame) - kStarPointYOffset);
48 } 47 }
49 48
50 bool StarDecoration::AcceptsMousePress() { 49 bool StarDecoration::AcceptsMousePress() {
51 return true; 50 return true;
52 } 51 }
53 52
54 bool StarDecoration::OnMousePressed(NSRect frame, NSPoint location) { 53 bool StarDecoration::OnMousePressed(NSRect frame, NSPoint location) {
55 command_updater_->ExecuteCommand(IDC_BOOKMARK_PAGE); 54 command_updater_->ExecuteCommand(IDC_BOOKMARK_PAGE);
56 return true; 55 return true;
57 } 56 }
58 57
59 NSString* StarDecoration::GetToolTip() { 58 NSString* StarDecoration::GetToolTip() {
60 return tooltip_.get(); 59 return tooltip_.get();
61 } 60 }
62 61
62 NSPoint StarDecoration::GetBubblePointInFrame(NSRect frame) {
63 return GetStarBubblePointInFrame(GetDrawRectInFrame(frame));
64 }
65
63 SkColor StarDecoration::GetMaterialIconColor(bool location_bar_is_dark) const { 66 SkColor StarDecoration::GetMaterialIconColor(bool location_bar_is_dark) const {
64 if (location_bar_is_dark) { 67 if (location_bar_is_dark) {
65 return starred_ ? gfx::kGoogleBlue300 : SkColorSetA(SK_ColorWHITE, 0xCC); 68 return starred_ ? gfx::kGoogleBlue300 : SkColorSetA(SK_ColorWHITE, 0xCC);
66 } 69 }
67 return starred_ ? gfx::kGoogleBlue500 : gfx::kChromeIconGrey; 70 return starred_ ? gfx::kGoogleBlue500 : gfx::kChromeIconGrey;
68 } 71 }
69 72
70 const gfx::VectorIcon* StarDecoration::GetMaterialVectorIcon() const { 73 const gfx::VectorIcon* StarDecoration::GetMaterialVectorIcon() const {
71 return starred_ ? &toolbar::kStarActiveIcon : &toolbar::kStarIcon; 74 return starred_ ? &toolbar::kStarActiveIcon : &toolbar::kStarIcon;
72 } 75 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/star_decoration.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698