OLD | NEW |
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 #include "chrome/browser/chromeos/status/status_area_button.h" | 5 #include "chrome/browser/chromeos/status/status_area_button.h" |
6 | 6 |
7 #include "grit/theme_resources.h" | 7 #include "grit/theme_resources.h" |
8 #include "ui/base/resource/resource_bundle.h" | 8 #include "ui/base/resource/resource_bundle.h" |
9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
10 #include "ui/gfx/skbitmap_operations.h" | 10 #include "ui/gfx/skbitmap_operations.h" |
11 #include "ui/views/border.h" | 11 #include "ui/views/border.h" |
12 #include "ui/views/view.h" | 12 #include "ui/views/view.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 // Colors for different text styles. | 16 // Colors for different text styles. |
17 const SkColor kWhitePlainTextColor = 0x99ffffff; | 17 const SkColor kWhitePlainTextColor = 0x99ffffff; |
18 const SkColor kGrayPlainTextColor = 0x99666666; | 18 const SkColor kGrayPlainTextColor = 0xff666666; |
19 const SkColor kWhiteHaloedTextColor = 0xb3ffffff; | 19 const SkColor kWhiteHaloedTextColor = 0xb3ffffff; |
20 const SkColor kWhiteHaloedHaloColor = 0xb3000000; | 20 const SkColor kWhiteHaloedHaloColor = 0xb3000000; |
21 const SkColor kGrayEmbossedTextColor = 0xff4c4c4c; | 21 const SkColor kGrayEmbossedTextColor = 0xff4c4c4c; |
22 const SkColor kGrayEmbossedShadowColor = 0x80ffffff; | 22 const SkColor kGrayEmbossedShadowColor = 0x80ffffff; |
23 | 23 |
24 // Status area font is bigger. | 24 // Status area font is bigger. |
25 const int kFontSizeDelta = 3; | 25 const int kFontSizeDelta = 3; |
26 | 26 |
27 // Pad for status icons. | 27 // Pad for status icons. |
28 const int kIconHorizontalPad = 2; | 28 const int kIconHorizontalPad = 2; |
29 | 29 |
30 } | 30 } |
31 | 31 |
32 //////////////////////////////////////////////////////////////////////////////// | 32 //////////////////////////////////////////////////////////////////////////////// |
33 // StatusAreaButton | 33 // StatusAreaButton |
34 | 34 |
35 StatusAreaButton::StatusAreaButton(Delegate* button_delegate, | 35 StatusAreaButton::StatusAreaButton(Delegate* button_delegate, |
36 views::ViewMenuDelegate* menu_delegate) | 36 views::ViewMenuDelegate* menu_delegate) |
37 : MenuButton(NULL, string16(), menu_delegate, false), | 37 : MenuButton(NULL, string16(), menu_delegate, false), |
38 menu_active_(true), | 38 menu_active_(true), |
39 delegate_(button_delegate) { | 39 delegate_(button_delegate) { |
40 set_border(NULL); | 40 set_border(NULL); |
41 | 41 |
42 gfx::Font font = | 42 light_font_ = |
43 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont); | 43 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont). |
44 font = font.DeriveFont(kFontSizeDelta); | 44 DeriveFont(kFontSizeDelta); |
45 font = delegate_->GetStatusAreaFont(font); | 45 bold_font_ = light_font_.DeriveFont(0, gfx::Font::BOLD); |
46 SetFont(font); | |
47 | 46 |
48 SetShowMultipleIconStates(false); | 47 SetShowMultipleIconStates(false); |
49 set_alignment(TextButton::ALIGN_CENTER); | 48 set_alignment(TextButton::ALIGN_CENTER); |
50 set_border(views::Border::CreateEmptyBorder( | 49 set_border(views::Border::CreateEmptyBorder( |
51 0, kIconHorizontalPad, 0, kIconHorizontalPad)); | 50 0, kIconHorizontalPad, 0, kIconHorizontalPad)); |
52 | 51 |
53 // Use an offset that is top aligned with toolbar. | 52 // Use an offset that is top aligned with toolbar. |
54 set_menu_offset(0, 4); | 53 set_menu_offset(0, 4); |
55 | 54 |
56 UpdateTextStyle(); | 55 UpdateTextStyle(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 return MenuButton::HitTest(point); | 128 return MenuButton::HitTest(point); |
130 } | 129 } |
131 | 130 |
132 void StatusAreaButton::SetMenuActive(bool active) { | 131 void StatusAreaButton::SetMenuActive(bool active) { |
133 menu_active_ = active; | 132 menu_active_ = active; |
134 } | 133 } |
135 | 134 |
136 void StatusAreaButton::UpdateTextStyle() { | 135 void StatusAreaButton::UpdateTextStyle() { |
137 ClearEmbellishing(); | 136 ClearEmbellishing(); |
138 switch (delegate_->GetStatusAreaTextStyle()) { | 137 switch (delegate_->GetStatusAreaTextStyle()) { |
139 case WHITE_PLAIN: | 138 case WHITE_PLAIN_BOLD: |
| 139 SetFont(bold_font_); |
140 SetEnabledColor(kWhitePlainTextColor); | 140 SetEnabledColor(kWhitePlainTextColor); |
141 break; | 141 break; |
142 case GRAY_PLAIN: | 142 case GRAY_PLAIN_LIGHT: |
| 143 SetFont(light_font_); |
143 SetEnabledColor(kGrayPlainTextColor); | 144 SetEnabledColor(kGrayPlainTextColor); |
144 break; | 145 break; |
145 case WHITE_HALOED: | 146 case WHITE_HALOED_BOLD: |
| 147 SetFont(bold_font_); |
146 SetEnabledColor(kWhiteHaloedTextColor); | 148 SetEnabledColor(kWhiteHaloedTextColor); |
147 SetTextHaloColor(kWhiteHaloedHaloColor); | 149 SetTextHaloColor(kWhiteHaloedHaloColor); |
148 break; | 150 break; |
149 case GRAY_EMBOSSED: | 151 case GRAY_EMBOSSED_BOLD: |
| 152 SetFont(bold_font_); |
150 SetEnabledColor(kGrayEmbossedTextColor); | 153 SetEnabledColor(kGrayEmbossedTextColor); |
151 SetTextShadowColors(kGrayEmbossedShadowColor, kGrayEmbossedShadowColor); | 154 SetTextShadowColors(kGrayEmbossedShadowColor, kGrayEmbossedShadowColor); |
152 SetTextShadowOffset(0, 1); | 155 SetTextShadowOffset(0, 1); |
153 break; | 156 break; |
154 } | 157 } |
155 SchedulePaint(); | 158 SchedulePaint(); |
156 } | 159 } |
157 | 160 |
158 int StatusAreaButton::icon_height() { | 161 int StatusAreaButton::icon_height() { |
159 return 24; | 162 return 24; |
160 } | 163 } |
161 | 164 |
162 int StatusAreaButton::icon_width() { | 165 int StatusAreaButton::icon_width() { |
163 return 23; | 166 return 23; |
164 } | 167 } |
165 | 168 |
166 int StatusAreaButton::horizontal_padding() { | 169 int StatusAreaButton::horizontal_padding() { |
167 return 1; | 170 return 1; |
168 } | 171 } |
OLD | NEW |