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

Side by Side Diff: ui/message_center/cocoa/status_item_view.mm

Issue 564953002: Add support for dark theme in Mac Notification Center (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "ui/message_center/cocoa/status_item_view.h" 5 #import "ui/message_center/cocoa/status_item_view.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/mac/sdk_forward_declarations.h"
10 #include "ui/base/resource/resource_bundle.h" 11 #include "ui/base/resource/resource_bundle.h"
11 #include "ui/resources/grit/ui_resources.h" 12 #include "ui/resources/grit/ui_resources.h"
12 13
13 // The width of the status bar item when it's just the icon. 14 // The width of the status bar item when it's just the icon.
14 const CGFloat kStatusItemLength = 26; 15 const CGFloat kStatusItemLength = 26;
15 16
16 // The amount of space between the left and right edges and the content of the 17 // The amount of space between the left and right edges and the content of the
17 // status item. 18 // status item.
18 const CGFloat kMargin = 5; 19 const CGFloat kMargin = 5;
19 20
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 142
142 // Private ///////////////////////////////////////////////////////////////////// 143 // Private /////////////////////////////////////////////////////////////////////
143 144
144 - (BOOL)shouldHighlight { 145 - (BOOL)shouldHighlight {
145 return highlight_ || inMouseEventSequence_; 146 return highlight_ || inMouseEventSequence_;
146 } 147 }
147 148
148 - (int)getTrayResourceId { 149 - (int)getTrayResourceId {
149 BOOL highlight = [self shouldHighlight]; 150 BOOL highlight = [self shouldHighlight];
150 BOOL hasUnreadItems = unreadCount_ > 0; 151 BOOL hasUnreadItems = unreadCount_ > 0;
151 int kResourceIds[2][2][2] = { 152 BOOL dark = NO;
153
154 Class nsAppearanceClass = NSClassFromString(@"NSAppearance");
155 if ([self respondsToSelector:@selector(effectiveAppearance)] &&
156 [nsAppearanceClass
157 instancesRespondToSelector:@selector(appearanceNamed:)]) {
Robert Sesek 2014/09/24 17:15:00 Tested. This does need to change back to -responds
dewittj 2014/09/25 18:21:39 Is this what you mean? It compiles on my 10.9 box
Robert Sesek 2014/09/25 18:23:27 Yup. I'm not sure why it produced a compiler error
158 id<NSObject> darkAppearance =
159 [nsAppearanceClass appearanceNamed:NSAppearanceNameVibrantDark];
160 dark = [[self effectiveAppearance] isEqual:darkAppearance];
161 }
162
163 int kResourceIds[2][2][2][2] = {
152 { 164 {
153 { IDR_TRAY_EMPTY, IDR_TRAY_EMPTY_PRESSED }, 165 {
154 { IDR_TRAY_ATTENTION, IDR_TRAY_ATTENTION_PRESSED }, 166 { IDR_TRAY_EMPTY, IDR_TRAY_EMPTY_PRESSED },
167 { IDR_TRAY_ATTENTION, IDR_TRAY_ATTENTION_PRESSED },
168 },
169 {
170 { IDR_TRAY_DO_NOT_DISTURB_EMPTY,
171 IDR_TRAY_DO_NOT_DISTURB_EMPTY_PRESSED },
172 { IDR_TRAY_DO_NOT_DISTURB_ATTENTION,
173 IDR_TRAY_DO_NOT_DISTURB_ATTENTION_PRESSED },
174 },
155 }, 175 },
156 { 176 {
157 { IDR_TRAY_DO_NOT_DISTURB_EMPTY, 177 {
158 IDR_TRAY_DO_NOT_DISTURB_EMPTY_PRESSED }, 178 // We chose not to support the empty version of the pressed
159 { IDR_TRAY_DO_NOT_DISTURB_ATTENTION, 179 // resource for the dark theme, so we use the same resource
160 IDR_TRAY_DO_NOT_DISTURB_ATTENTION_PRESSED }, 180 // for both "pressed" options.
161 }, 181 { IDR_DARK_TRAY_EMPTY, IDR_DARK_TRAY_PRESSED },
182 { IDR_DARK_TRAY_ATTENTION, IDR_DARK_TRAY_PRESSED },
183 },
184 {
185 { IDR_DARK_TRAY_DO_NOT_DISTURB_EMPTY,
186 IDR_DARK_TRAY_DO_NOT_DISTURB_PRESSED },
187 { IDR_DARK_TRAY_DO_NOT_DISTURB_ATTENTION,
188 IDR_DARK_TRAY_DO_NOT_DISTURB_PRESSED },
189 },
190 }
162 }; 191 };
163 return kResourceIds[quietMode_][hasUnreadItems][highlight]; 192 return kResourceIds[dark][quietMode_][hasUnreadItems][highlight];
164 } 193 }
165 194
166 @end 195 @end
OLDNEW
« no previous file with comments | « base/mac/sdk_forward_declarations.mm ('k') | ui/resources/default_100_percent/mac/notification_dark_tray_attention.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698