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

Side by Side Diff: ash/common/system/tray/tray_popup_item_style.cc

Issue 2734653002: chromeos: Move files in //ash/common to //ash (Closed)
Patch Set: fix a11y tests, fix docs Created 3 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/common/system/tray/tray_popup_item_style.h"
6
7 #include "third_party/skia/include/core/SkColor.h"
8 #include "ui/gfx/color_palette.h"
9 #include "ui/gfx/font.h"
10 #include "ui/gfx/font_list.h"
11 #include "ui/native_theme/native_theme.h"
12 #include "ui/views/controls/label.h"
13
14 namespace ash {
15 namespace {
16
17 const int kInactiveAlpha = 0x8A;
18 const int kDisabledAlpha = 0x61;
19
20 } // namespace
21
22 // static
23 SkColor TrayPopupItemStyle::GetIconColor(ColorStyle color_style) {
24 switch (color_style) {
25 case ColorStyle::ACTIVE:
26 return gfx::kChromeIconGrey;
27 case ColorStyle::INACTIVE:
28 return SkColorSetA(gfx::kChromeIconGrey, kInactiveAlpha);
29 case ColorStyle::DISABLED:
30 return SkColorSetA(gfx::kChromeIconGrey, kDisabledAlpha);
31 case ColorStyle::CONNECTED:
32 return gfx::kPlaceholderColor;
33 }
34 NOTREACHED();
35 return gfx::kPlaceholderColor;
36 }
37
38 TrayPopupItemStyle::TrayPopupItemStyle(FontStyle font_style)
39 : font_style_(font_style), color_style_(ColorStyle::ACTIVE) {
40 if (font_style_ == FontStyle::SYSTEM_INFO)
41 color_style_ = ColorStyle::INACTIVE;
42 }
43
44 TrayPopupItemStyle::~TrayPopupItemStyle() {}
45
46 SkColor TrayPopupItemStyle::GetTextColor() const {
47 const SkColor kBaseTextColor = SkColorSetA(SK_ColorBLACK, 0xDE);
48
49 switch (color_style_) {
50 case ColorStyle::ACTIVE:
51 return kBaseTextColor;
52 case ColorStyle::INACTIVE:
53 return SkColorSetA(kBaseTextColor, kInactiveAlpha);
54 case ColorStyle::DISABLED:
55 return SkColorSetA(kBaseTextColor, kDisabledAlpha);
56 case ColorStyle::CONNECTED:
57 return gfx::kGoogleGreen700;
58 }
59 NOTREACHED();
60 return gfx::kPlaceholderColor;
61 }
62
63 SkColor TrayPopupItemStyle::GetIconColor() const {
64 return GetIconColor(color_style_);
65 }
66
67 void TrayPopupItemStyle::SetupLabel(views::Label* label) const {
68 label->SetEnabledColor(GetTextColor());
69
70 const gfx::FontList& base_font_list = views::Label::GetDefaultFontList();
71 switch (font_style_) {
72 case FontStyle::TITLE:
73 label->SetFontList(base_font_list.Derive(2, gfx::Font::NORMAL,
74 gfx::Font::Weight::MEDIUM));
75 break;
76 case FontStyle::DEFAULT_VIEW_LABEL:
77 label->SetFontList(base_font_list.Derive(2, gfx::Font::NORMAL,
78 gfx::Font::Weight::NORMAL));
79 break;
80 case FontStyle::SUB_HEADER:
81 label->SetFontList(base_font_list.Derive(1, gfx::Font::NORMAL,
82 gfx::Font::Weight::MEDIUM));
83 label->SetEnabledColor(label->GetNativeTheme()->GetSystemColor(
84 ui::NativeTheme::kColorId_ProminentButtonColor));
85 label->SetAutoColorReadabilityEnabled(false);
86 break;
87 case FontStyle::DETAILED_VIEW_LABEL:
88 case FontStyle::SYSTEM_INFO:
89 label->SetFontList(base_font_list.Derive(1, gfx::Font::NORMAL,
90 gfx::Font::Weight::NORMAL));
91 break;
92 case FontStyle::BUTTON:
93 label->SetFontList(base_font_list.Derive(0, gfx::Font::NORMAL,
94 gfx::Font::Weight::MEDIUM));
95 break;
96 case FontStyle::CAPTION:
97 label->SetFontList(base_font_list.Derive(0, gfx::Font::NORMAL,
98 gfx::Font::Weight::NORMAL));
99 break;
100 }
101 }
102
103 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray/tray_popup_item_style.h ('k') | ash/common/system/tray/tray_popup_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698