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

Side by Side Diff: ui/views/controls/label.cc

Issue 10270021: Make all the menu UI consitent with the new chromeos menu spec. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Give back the text_color initialization in menu_config.cc. Created 8 years, 7 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
« no previous file with comments | « ui/gfx/native_theme_win.cc ('k') | ui/views/controls/menu/menu_config_views.cc » ('j') | 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) 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 "ui/views/controls/label.h" 5 #include "ui/views/controls/label.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/i18n/rtl.h" 12 #include "base/i18n/rtl.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/string_split.h" 14 #include "base/string_split.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "ui/base/accessibility/accessible_view_state.h" 17 #include "ui/base/accessibility/accessible_view_state.h"
18 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/base/text/text_elider.h" 19 #include "ui/base/text/text_elider.h"
20 #include "ui/gfx/canvas.h" 20 #include "ui/gfx/canvas.h"
21 #include "ui/gfx/color_utils.h" 21 #include "ui/gfx/color_utils.h"
22 #include "ui/gfx/font.h" 22 #include "ui/gfx/font.h"
23 #include "ui/gfx/insets.h" 23 #include "ui/gfx/insets.h"
24 #include "ui/gfx/native_theme.h"
24 #include "ui/views/background.h" 25 #include "ui/views/background.h"
25 26
26 namespace views { 27 namespace views {
27 28
28 // static 29 // static
29 const char Label::kViewClassName[] = "views/Label"; 30 const char Label::kViewClassName[] = "views/Label";
30 31
31 const int Label::kFocusBorderPadding = 1; 32 const int Label::kFocusBorderPadding = 1;
32 33
33 Label::Label() { 34 Label::Label() {
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 if (bg) 349 if (bg)
349 bg->Paint(canvas, this); 350 bg->Paint(canvas, this);
350 } 351 }
351 352
352 // static 353 // static
353 gfx::Font Label::GetDefaultFont() { 354 gfx::Font Label::GetDefaultFont() {
354 return ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont); 355 return ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont);
355 } 356 }
356 357
357 void Label::Init(const string16& text, const gfx::Font& font) { 358 void Label::Init(const string16& text, const gfx::Font& font) {
358 static bool initialized = false;
359 static SkColor kDefaultEnabledColor;
360 static SkColor kDefaultDisabledColor;
361 static SkColor kDefaultBackgroundColor;
362 if (!initialized) {
363 #if defined(OS_WIN)
364 kDefaultEnabledColor = color_utils::GetSysSkColor(COLOR_WINDOWTEXT);
365 kDefaultDisabledColor = color_utils::GetSysSkColor(COLOR_GRAYTEXT);
366 kDefaultBackgroundColor = color_utils::GetSysSkColor(COLOR_WINDOW);
367 #else
368 // TODO(beng): source from theme provider.
369 kDefaultEnabledColor = SK_ColorBLACK;
370 kDefaultDisabledColor = SK_ColorGRAY;
371 kDefaultBackgroundColor = SK_ColorWHITE;
372 #endif
373
374 initialized = true;
375 }
376
377 contains_mouse_ = false; 359 contains_mouse_ = false;
378 font_ = font; 360 font_ = font;
379 text_size_valid_ = false; 361 text_size_valid_ = false;
380 requested_enabled_color_ = kDefaultEnabledColor; 362 requested_enabled_color_ = gfx::NativeTheme::instance()->GetSystemColor(
381 requested_disabled_color_ = kDefaultDisabledColor; 363 gfx::NativeTheme::kColorId_LabelEnabledColor);
382 background_color_ = kDefaultBackgroundColor; 364 requested_disabled_color_ = gfx::NativeTheme::instance()->GetSystemColor(
365 gfx::NativeTheme::kColorId_LabelDisabledColor);
366 background_color_ = gfx::NativeTheme::instance()->GetSystemColor(
367 gfx::NativeTheme::kColorId_LabelBackgroundColor);
383 auto_color_readability_ = true; 368 auto_color_readability_ = true;
384 RecalculateColors(); 369 RecalculateColors();
385 horiz_alignment_ = ALIGN_CENTER; 370 horiz_alignment_ = ALIGN_CENTER;
386 is_multi_line_ = false; 371 is_multi_line_ = false;
387 allow_character_break_ = false; 372 allow_character_break_ = false;
388 elide_in_middle_ = false; 373 elide_in_middle_ = false;
389 is_email_ = false; 374 is_email_ = false;
390 collapse_when_hidden_ = false; 375 collapse_when_hidden_ = false;
391 directionality_mode_ = USE_UI_DIRECTIONALITY; 376 directionality_mode_ = USE_UI_DIRECTIONALITY;
392 paint_as_focused_ = false; 377 paint_as_focused_ = false;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 ui::ELIDE_IN_MIDDLE); 518 ui::ELIDE_IN_MIDDLE);
534 } else { 519 } else {
535 *paint_text = text_; 520 *paint_text = text_;
536 } 521 }
537 522
538 *text_bounds = GetTextBounds(); 523 *text_bounds = GetTextBounds();
539 *flags = ComputeDrawStringFlags(); 524 *flags = ComputeDrawStringFlags();
540 } 525 }
541 526
542 } // namespace views 527 } // namespace views
OLDNEW
« no previous file with comments | « ui/gfx/native_theme_win.cc ('k') | ui/views/controls/menu/menu_config_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698