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

Side by Side Diff: chrome/browser/chromeos/status/language_menu_button.cc

Issue 2767001: Don't use disabled (gray) state for the language indicator. (Closed)
Patch Set: fixed all Created 10 years, 6 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/chromeos/status/language_menu_button.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/language_menu_button.h" 5 #include "chrome/browser/chromeos/status/language_menu_button.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // in this class. Therefore, GetItemCount() have to return 0 when 142 // in this class. Therefore, GetItemCount() have to return 0 when
143 // |model_| is NULL. 143 // |model_| is NULL.
144 ALLOW_THIS_IN_INITIALIZER_LIST(language_menu_(this)), 144 ALLOW_THIS_IN_INITIALIZER_LIST(language_menu_(this)),
145 host_(host) { 145 host_(host) {
146 DCHECK(input_method_descriptors_.get() && 146 DCHECK(input_method_descriptors_.get() &&
147 !input_method_descriptors_->empty()); 147 !input_method_descriptors_->empty());
148 set_border(NULL); 148 set_border(NULL);
149 SetFont(ResourceBundle::GetSharedInstance().GetFont( 149 SetFont(ResourceBundle::GetSharedInstance().GetFont(
150 ResourceBundle::BaseFont).DeriveFont(1, gfx::Font::BOLD)); 150 ResourceBundle::BaseFont).DeriveFont(1, gfx::Font::BOLD));
151 SetEnabledColor(0xB3FFFFFF); // White with 70% Alpha 151 SetEnabledColor(0xB3FFFFFF); // White with 70% Alpha
152
153 // TODO(yusukes): Make the initial state "enabled" and delete SetDisabledColor
154 // when crosbug.com/3683 is fixed.
155 SetDisabledColor(0x4DFFFFFF); // White with 30% Alpha
156 SetEnabled(false); // Disable the button until the first FocusIn comes in.
157
158 SetShowHighlighted(false); 152 SetShowHighlighted(false);
159 // Update the model 153 // Update the model
160 RebuildModel(); 154 RebuildModel();
161 // Grab the real estate. 155 // Grab the real estate.
162 UpdateIcon(kSpacer, L"" /* no tooltip */); 156 UpdateIcon(kSpacer, L"" /* no tooltip */);
163 157
164 // Draw the default indicator "EN". The default indicator "EN" is used when 158 // Draw the default indicator "EN". The default indicator "EN" is used when
165 // |pref_service| is not available (for example, unit tests) or |pref_service| 159 // |pref_service| is not available (for example, unit tests) or |pref_service|
166 // is available, but Chrome preferences are not available (for example, 160 // is available, but Chrome preferences are not available (for example,
167 // initial OS boot). 161 // initial OS boot).
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 void LanguageMenuButton::LocaleChanged() { 420 void LanguageMenuButton::LocaleChanged() {
427 const chromeos::InputMethodDescriptor& input_method = 421 const chromeos::InputMethodDescriptor& input_method =
428 CrosLibrary::Get()->GetLanguageLibrary()->current_input_method(); 422 CrosLibrary::Get()->GetLanguageLibrary()->current_input_method();
429 const std::wstring name = FormatInputLanguage(input_method, false, false); 423 const std::wstring name = FormatInputLanguage(input_method, false, false);
430 const std::wstring tooltip = FormatInputLanguage(input_method, true, true); 424 const std::wstring tooltip = FormatInputLanguage(input_method, true, true);
431 UpdateIcon(name, tooltip); 425 UpdateIcon(name, tooltip);
432 Layout(); 426 Layout();
433 SchedulePaint(); 427 SchedulePaint();
434 } 428 }
435 429
436 void LanguageMenuButton::FocusChanged(LanguageLibrary* obj) {
437 // TODO(yusukes): Remove this function when crosbug.com/3683 is fixed.
438 LanguageLibrary* language_library = CrosLibrary::Get()->GetLanguageLibrary();
439 if (language_library->is_focused() && !IsEnabled()) {
440 // Enable the button on the first FocusIn event.
441 SetEnabled(true);
442 SchedulePaint();
443 }
444 }
445
446 void LanguageMenuButton::UpdateIcon( 430 void LanguageMenuButton::UpdateIcon(
447 const std::wstring& name, const std::wstring& tooltip) { 431 const std::wstring& name, const std::wstring& tooltip) {
448 if (!tooltip.empty()) { 432 if (!tooltip.empty()) {
449 SetTooltipText(tooltip); 433 SetTooltipText(tooltip);
450 } 434 }
451 SetText(name); 435 SetText(name);
452 set_alignment(TextButton::ALIGN_RIGHT); 436 set_alignment(TextButton::ALIGN_RIGHT);
453 SchedulePaint(); 437 SchedulePaint();
454 } 438 }
455 439
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 DCHECK(model_.get()); 527 DCHECK(model_.get());
544 if (index >= model_->GetItemCount()) { 528 if (index >= model_->GetItemCount()) {
545 return false; 529 return false;
546 } 530 }
547 531
548 return ((model_->GetTypeAt(index) == menus::MenuModel::TYPE_RADIO) && 532 return ((model_->GetTypeAt(index) == menus::MenuModel::TYPE_RADIO) &&
549 (model_->GetCommandIdAt(index) == COMMAND_ID_CUSTOMIZE_LANGUAGE)); 533 (model_->GetCommandIdAt(index) == COMMAND_ID_CUSTOMIZE_LANGUAGE));
550 } 534 }
551 535
552 } // namespace chromeos 536 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/status/language_menu_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698