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

Side by Side Diff: ash/sticky_keys/sticky_keys_overlay.cc

Issue 341713002: Remove Label::PaintText overrides. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and rebase. Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ash/sticky_keys/sticky_keys_overlay.h" 5 #include "ash/sticky_keys/sticky_keys_overlay.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_window_ids.h" 8 #include "ash/shell_window_ids.h"
9 #include "ash/sticky_keys/sticky_keys_controller.h" 9 #include "ash/sticky_keys/sticky_keys_controller.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 public: 47 public:
48 explicit StickyKeyOverlayLabel(const std::string& key_name); 48 explicit StickyKeyOverlayLabel(const std::string& key_name);
49 49
50 virtual ~StickyKeyOverlayLabel(); 50 virtual ~StickyKeyOverlayLabel();
51 51
52 StickyKeyState state() const { return state_; } 52 StickyKeyState state() const { return state_; }
53 53
54 void SetKeyState(StickyKeyState state); 54 void SetKeyState(StickyKeyState state);
55 55
56 private: 56 private:
57 // views::Label overrides:
58 virtual void PaintText(gfx::Canvas* canvas,
59 const base::string16& text,
60 const gfx::Rect& text_bounds,
61 int flags) OVERRIDE;
62
63 StickyKeyState state_; 57 StickyKeyState state_;
64 58
65 DISALLOW_COPY_AND_ASSIGN(StickyKeyOverlayLabel); 59 DISALLOW_COPY_AND_ASSIGN(StickyKeyOverlayLabel);
66 }; 60 };
67 61
68 StickyKeyOverlayLabel::StickyKeyOverlayLabel(const std::string& key_name) 62 StickyKeyOverlayLabel::StickyKeyOverlayLabel(const std::string& key_name)
69 : state_(STICKY_KEY_STATE_DISABLED) { 63 : state_(STICKY_KEY_STATE_DISABLED) {
70 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 64 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
71 65
72 SetText(base::UTF8ToUTF16(key_name)); 66 SetText(base::UTF8ToUTF16(key_name));
73 SetHorizontalAlignment(gfx::ALIGN_LEFT); 67 SetHorizontalAlignment(gfx::ALIGN_LEFT);
74 SetFontList(rb->GetFontList(kKeyLabelFontStyle)); 68 SetFontList(rb->GetFontList(kKeyLabelFontStyle));
75 SetAutoColorReadabilityEnabled(false); 69 SetAutoColorReadabilityEnabled(false);
76 SetFocusable(false); 70 SetFocusable(false);
77 SetEnabledColor(SkColorSetARGB(0x80, 0xFF, 0xFF, 0xFF)); 71 SetEnabledColor(SkColorSetARGB(0x80, 0xFF, 0xFF, 0xFF));
78 SetDisabledColor(SkColorSetARGB(0x80, 0xFF, 0xFF, 0xFF)); 72 SetDisabledColor(SkColorSetARGB(0x80, 0xFF, 0xFF, 0xFF));
73 set_subpixel_rendering_enabled(false);
79 } 74 }
80 75
81 StickyKeyOverlayLabel::~StickyKeyOverlayLabel() { 76 StickyKeyOverlayLabel::~StickyKeyOverlayLabel() {
82 } 77 }
83 78
84 void StickyKeyOverlayLabel::SetKeyState(StickyKeyState state) { 79 void StickyKeyOverlayLabel::SetKeyState(StickyKeyState state) {
85 state_ = state; 80 state_ = state;
86 SkColor label_color; 81 SkColor label_color;
87 int style; 82 int style;
88 switch (state) { 83 switch (state) {
89 case STICKY_KEY_STATE_ENABLED: 84 case STICKY_KEY_STATE_ENABLED:
90 style = gfx::Font::NORMAL; 85 style = gfx::Font::NORMAL;
91 label_color = SkColorSetA(enabled_color(), 0xFF); 86 label_color = SkColorSetA(enabled_color(), 0xFF);
92 break; 87 break;
93 case STICKY_KEY_STATE_LOCKED: 88 case STICKY_KEY_STATE_LOCKED:
94 style = gfx::Font::UNDERLINE; 89 style = gfx::Font::UNDERLINE;
95 label_color = SkColorSetA(enabled_color(), 0xFF); 90 label_color = SkColorSetA(enabled_color(), 0xFF);
96 break; 91 break;
97 default: 92 default:
98 style = gfx::Font::NORMAL; 93 style = gfx::Font::NORMAL;
99 label_color = SkColorSetA(enabled_color(), 0x80); 94 label_color = SkColorSetA(enabled_color(), 0x80);
100 } 95 }
101 96
102 SetEnabledColor(label_color); 97 SetEnabledColor(label_color);
103 SetDisabledColor(label_color); 98 SetDisabledColor(label_color);
104 SetFontList(font_list().DeriveWithStyle(style)); 99 SetFontList(font_list().DeriveWithStyle(style));
105 } 100 }
106 101
107 void StickyKeyOverlayLabel::PaintText(gfx::Canvas* canvas,
108 const base::string16& text,
109 const gfx::Rect& text_bounds,
110 int flags) {
111 views::Label::PaintText(canvas,
112 text,
113 text_bounds,
114 flags | gfx::Canvas::NO_SUBPIXEL_RENDERING);
115 }
116
117
118 /////////////////////////////////////////////////////////////////////////////// 102 ///////////////////////////////////////////////////////////////////////////////
119 // StickyKeyOverlayLabel 103 // StickyKeysOverlayView
120 class StickyKeysOverlayView : public views::WidgetDelegateView { 104 class StickyKeysOverlayView : public views::WidgetDelegateView {
121 public: 105 public:
122 StickyKeysOverlayView(); 106 StickyKeysOverlayView();
123 107
124 virtual ~StickyKeysOverlayView(); 108 virtual ~StickyKeysOverlayView();
125 109
126 // views::WidgetDelegateView overrides: 110 // views::WidgetDelegateView overrides:
127 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 111 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
128 112
129 void SetKeyState(ui::EventFlags modifier, StickyKeyState state); 113 void SetKeyState(ui::EventFlags modifier, StickyKeyState state);
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 ui::LayerAnimator* animator = overlay_widget_->GetLayer()->GetAnimator(); 296 ui::LayerAnimator* animator = overlay_widget_->GetLayer()->GetAnimator();
313 if (animator) 297 if (animator)
314 animator->RemoveObserver(this); 298 animator->RemoveObserver(this);
315 } 299 }
316 300
317 void StickyKeysOverlay::OnLayerAnimationScheduled( 301 void StickyKeysOverlay::OnLayerAnimationScheduled(
318 ui::LayerAnimationSequence* sequence) { 302 ui::LayerAnimationSequence* sequence) {
319 } 303 }
320 304
321 } // namespace ash 305 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/exit_warning_handler.cc ('k') | chrome/browser/ui/views/frame/opaque_browser_frame_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698