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

Side by Side Diff: chrome/browser/chromeos/login/update_view.cc

Issue 8221027: Make views::Label and views::Link auto-color themselves to be readable over their background colo... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/login/update_view.h" 5 #include "chrome/browser/chromeos/login/update_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/chromeos/login/helper.h" 12 #include "chrome/browser/chromeos/login/helper.h"
13 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" 13 #include "chrome/browser/chromeos/login/rounded_rect_painter.h"
14 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h" 14 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h"
15 #include "grit/chromium_strings.h" 15 #include "grit/chromium_strings.h"
16 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
17 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/gfx/color_utils.h"
19 #include "views/border.h" 20 #include "views/border.h"
20 #include "views/controls/label.h" 21 #include "views/controls/label.h"
21 #include "views/controls/progress_bar.h" 22 #include "views/controls/progress_bar.h"
22 #include "views/controls/throbber.h" 23 #include "views/controls/throbber.h"
23 #include "views/focus/focus_manager.h" 24 #include "views/focus/focus_manager.h"
24 #include "views/widget/widget.h" 25 #include "views/widget/widget.h"
25 26
26 using std::max; 27 using std::max;
27 using views::Background; 28 using views::Background;
28 using views::Label; 29 using views::Label;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 73 }
73 74
74 UpdateView::~UpdateView() { 75 UpdateView::~UpdateView() {
75 } 76 }
76 77
77 void UpdateView::Init() { 78 void UpdateView::Init() {
78 // Use rounded-rect background. 79 // Use rounded-rect background.
79 views::Painter* painter = chromeos::CreateWizardPainter( 80 views::Painter* painter = chromeos::CreateWizardPainter(
80 &chromeos::BorderDefinition::kScreenBorder); 81 &chromeos::BorderDefinition::kScreenBorder);
81 set_background(views::Background::CreateBackgroundPainter(true, painter)); 82 set_background(views::Background::CreateBackgroundPainter(true, painter));
83 SkColor background_color = color_utils::AlphaBlend(
84 BorderDefinition::kScreenBorder.top_color,
85 BorderDefinition::kScreenBorder.bottom_color, 128);
82 86
83 InitLabel(&installing_updates_label_); 87 installing_updates_label_ = InitLabel(background_color);
84 InitLabel(&preparing_updates_label_); 88 preparing_updates_label_ = InitLabel(background_color);
85 InitLabel(&reboot_label_);
86 InitLabel(&manual_reboot_label_);
87 preparing_updates_label_->SetVisible(false); 89 preparing_updates_label_->SetVisible(false);
90 reboot_label_ = InitLabel(background_color);
91 manual_reboot_label_ = InitLabel(background_color);
88 manual_reboot_label_->SetVisible(false); 92 manual_reboot_label_->SetVisible(false);
89 manual_reboot_label_->SetColor(kManualRebootLabelColor); 93 manual_reboot_label_->SetEnabledColor(kManualRebootLabelColor);
90 94
91 progress_bar_ = new views::ProgressBar(); 95 progress_bar_ = new views::ProgressBar();
92 AddChildView(progress_bar_); 96 AddChildView(progress_bar_);
93 progress_bar_->SetDisplayRange(0.0, 100.0); 97 progress_bar_->SetDisplayRange(0.0, 100.0);
94 98
95 // Curtain view. 99 // Curtain view.
96 InitLabel(&checking_label_); 100 checking_label_ = InitLabel(background_color);
97 throbber_ = CreateDefaultThrobber(); 101 throbber_ = CreateDefaultThrobber();
98 AddChildView(throbber_); 102 AddChildView(throbber_);
99 103
100 #if !defined(OFFICIAL_BUILD) 104 #if !defined(OFFICIAL_BUILD)
101 InitLabel(&escape_to_skip_label_); 105 escape_to_skip_label_ = InitLabel(background_color);
102 escape_to_skip_label_->SetColor(kSkipLabelColor); 106 escape_to_skip_label_->SetEnabledColor(kSkipLabelColor);
103 escape_to_skip_label_->SetText( 107 escape_to_skip_label_->SetText(
104 ASCIIToUTF16("Press ESCAPE to skip (Non-official builds only)")); 108 ASCIIToUTF16("Press ESCAPE to skip (Non-official builds only)"));
105 #endif 109 #endif
106 110
107 UpdateLocalizedStrings(); 111 UpdateLocalizedStrings();
108 UpdateVisibility(); 112 UpdateVisibility();
109 } 113 }
110 114
111 void UpdateView::Reset() { 115 void UpdateView::Reset() {
112 progress_bar_->SetValue(0.0); 116 progress_bar_->SetValue(0.0);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 checking_label_, x_center + (throbber_width + 1) / 2 + space_half, 211 checking_label_, x_center + (throbber_width + 1) / 2 + space_half,
208 vertical_center); 212 vertical_center);
209 #if !defined(OFFICIAL_BUILD) 213 #if !defined(OFFICIAL_BUILD)
210 escape_to_skip_label_->SizeToFit(max_width); 214 escape_to_skip_label_->SizeToFit(max_width);
211 escape_to_skip_label_->SetX(right_margin); 215 escape_to_skip_label_->SetX(right_margin);
212 escape_to_skip_label_->SetY(kEscapeToSkipLabelY); 216 escape_to_skip_label_->SetY(kEscapeToSkipLabelY);
213 #endif 217 #endif
214 SchedulePaint(); 218 SchedulePaint();
215 } 219 }
216 220
217 void UpdateView::InitLabel(views::Label** label) { 221 views::Label* UpdateView::InitLabel(SkColor background_color) {
218 *label = new views::Label(); 222 views::Label* label = new views::Label();
219 (*label)->SetColor(kLabelColor); 223 label->SetBackgroundColor(background_color);
220 (*label)->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 224 label->SetEnabledColor(kLabelColor);
221 (*label)->SetMultiLine(true); 225 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
226 label->SetMultiLine(true);
222 227
223 ResourceBundle& res_bundle = ResourceBundle::GetSharedInstance(); 228 ResourceBundle& res_bundle = ResourceBundle::GetSharedInstance();
224 gfx::Font label_font = res_bundle.GetFont(ResourceBundle::MediumFont); 229 gfx::Font label_font = res_bundle.GetFont(ResourceBundle::MediumFont);
225 (*label)->SetFont(label_font); 230 label->SetFont(label_font);
226 231
227 AddChildView(*label); 232 AddChildView(label);
233 return label;
228 } 234 }
229 235
230 void UpdateView::UpdateVisibility() { 236 void UpdateView::UpdateVisibility() {
231 installing_updates_label_->SetVisible(!show_curtain_ && 237 installing_updates_label_->SetVisible(!show_curtain_ &&
232 !show_manual_reboot_label_ && 238 !show_manual_reboot_label_ &&
233 !show_preparing_updates_label_); 239 !show_preparing_updates_label_);
234 preparing_updates_label_->SetVisible(!show_curtain_ && 240 preparing_updates_label_->SetVisible(!show_curtain_ &&
235 !show_manual_reboot_label_ && 241 !show_manual_reboot_label_ &&
236 show_preparing_updates_label_); 242 show_preparing_updates_label_);
237 reboot_label_->SetVisible(!show_curtain_&& !show_manual_reboot_label_); 243 reboot_label_->SetVisible(!show_curtain_&& !show_manual_reboot_label_);
(...skipping 21 matching lines...) Expand all
259 } else { 265 } else {
260 NOTREACHED(); 266 NOTREACHED();
261 } 267 }
262 const std::string text = 268 const std::string text =
263 label_spoken ? UTF16ToUTF8(label_spoken->GetText()) : std::string(); 269 label_spoken ? UTF16ToUTF8(label_spoken->GetText()) : std::string();
264 WizardAccessibilityHelper::GetInstance()->MaybeSpeak(text.c_str(), false, 270 WizardAccessibilityHelper::GetInstance()->MaybeSpeak(text.c_str(), false,
265 true); 271 true);
266 } 272 }
267 273
268 } // namespace chromeos 274 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/update_view.h ('k') | chrome/browser/chromeos/login/user_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698