OLD | NEW |
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/public/cpp/shell_window_ids.h" | 7 #include "ash/public/cpp/shell_window_ids.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/sticky_keys/sticky_keys_controller.h" | 9 #include "ash/sticky_keys/sticky_keys_controller.h" |
10 #include "ash/strings/grit/ash_strings.h" | 10 #include "ash/strings/grit/ash_strings.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 // Vertical offset of the overlay from the top left of the screen. | 32 // Vertical offset of the overlay from the top left of the screen. |
33 const int kVerticalOverlayOffset = 18; | 33 const int kVerticalOverlayOffset = 18; |
34 | 34 |
35 // Font style used for modifier key labels. | 35 // Font style used for modifier key labels. |
36 const ui::ResourceBundle::FontStyle kKeyLabelFontStyle = | 36 const ui::ResourceBundle::FontStyle kKeyLabelFontStyle = |
37 ui::ResourceBundle::LargeFont; | 37 ui::ResourceBundle::LargeFont; |
38 | 38 |
39 // Duration of slide animation when overlay is shown or hidden. | 39 // Duration of slide animation when overlay is shown or hidden. |
40 const int kSlideAnimationDurationMs = 100; | 40 const int kSlideAnimationDurationMs = 100; |
41 } | |
42 | 41 |
43 /////////////////////////////////////////////////////////////////////////////// | 42 /////////////////////////////////////////////////////////////////////////////// |
44 // StickyKeyOverlayLabel | 43 // StickyKeyOverlayLabel |
45 class StickyKeyOverlayLabel : public views::Label { | 44 class StickyKeyOverlayLabel : public views::Label { |
46 public: | 45 public: |
47 explicit StickyKeyOverlayLabel(const std::string& key_name); | 46 explicit StickyKeyOverlayLabel(const std::string& key_name); |
48 | 47 |
49 ~StickyKeyOverlayLabel() override; | 48 ~StickyKeyOverlayLabel() override; |
50 | 49 |
51 StickyKeyState state() const { return state_; } | 50 StickyKeyState state() const { return state_; } |
52 | 51 |
53 void SetKeyState(StickyKeyState state); | 52 void SetKeyState(StickyKeyState state); |
54 | 53 |
55 private: | 54 private: |
56 StickyKeyState state_; | 55 StickyKeyState state_; |
57 | 56 |
58 DISALLOW_COPY_AND_ASSIGN(StickyKeyOverlayLabel); | 57 DISALLOW_COPY_AND_ASSIGN(StickyKeyOverlayLabel); |
59 }; | 58 }; |
60 | 59 |
61 StickyKeyOverlayLabel::StickyKeyOverlayLabel(const std::string& key_name) | 60 StickyKeyOverlayLabel::StickyKeyOverlayLabel(const std::string& key_name) |
62 : state_(STICKY_KEY_STATE_DISABLED) { | 61 : state_(STICKY_KEY_STATE_DISABLED) { |
63 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 62 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
64 | 63 |
65 SetText(base::UTF8ToUTF16(key_name)); | 64 SetText(base::UTF8ToUTF16(key_name)); |
66 SetHorizontalAlignment(gfx::ALIGN_LEFT); | 65 SetHorizontalAlignment(gfx::ALIGN_LEFT); |
67 SetFontList(rb->GetFontList(kKeyLabelFontStyle)); | 66 SetFontList(rb->GetFontList(kKeyLabelFontStyle)); |
68 SetAutoColorReadabilityEnabled(false); | 67 SetAutoColorReadabilityEnabled(false); |
69 SetEnabledColor(SkColorSetARGB(0x80, 0xFF, 0xFF, 0xFF)); | 68 SetEnabledColor(SkColorSetARGB(0x80, 0xFF, 0xFF, 0xFF)); |
70 SetDisabledColor(SkColorSetARGB(0x80, 0xFF, 0xFF, 0xFF)); | |
71 SetSubpixelRenderingEnabled(false); | 69 SetSubpixelRenderingEnabled(false); |
72 } | 70 } |
73 | 71 |
74 StickyKeyOverlayLabel::~StickyKeyOverlayLabel() {} | 72 StickyKeyOverlayLabel::~StickyKeyOverlayLabel() {} |
75 | 73 |
76 void StickyKeyOverlayLabel::SetKeyState(StickyKeyState state) { | 74 void StickyKeyOverlayLabel::SetKeyState(StickyKeyState state) { |
77 state_ = state; | 75 state_ = state; |
78 SkColor label_color; | 76 SkColor label_color; |
79 int style; | 77 int style; |
80 switch (state) { | 78 switch (state) { |
81 case STICKY_KEY_STATE_ENABLED: | 79 case STICKY_KEY_STATE_ENABLED: |
82 style = gfx::Font::NORMAL; | 80 style = gfx::Font::NORMAL; |
83 label_color = SkColorSetA(enabled_color(), 0xFF); | 81 label_color = SkColorSetA(enabled_color(), 0xFF); |
84 break; | 82 break; |
85 case STICKY_KEY_STATE_LOCKED: | 83 case STICKY_KEY_STATE_LOCKED: |
86 style = gfx::Font::UNDERLINE; | 84 style = gfx::Font::UNDERLINE; |
87 label_color = SkColorSetA(enabled_color(), 0xFF); | 85 label_color = SkColorSetA(enabled_color(), 0xFF); |
88 break; | 86 break; |
89 default: | 87 default: |
90 style = gfx::Font::NORMAL; | 88 style = gfx::Font::NORMAL; |
91 label_color = SkColorSetA(enabled_color(), 0x80); | 89 label_color = SkColorSetA(enabled_color(), 0x80); |
92 } | 90 } |
93 | 91 |
94 SetEnabledColor(label_color); | 92 SetEnabledColor(label_color); |
95 SetDisabledColor(label_color); | |
96 SetFontList(font_list().DeriveWithStyle(style)); | 93 SetFontList(font_list().DeriveWithStyle(style)); |
97 } | 94 } |
98 | 95 |
| 96 } // namespace |
| 97 |
99 /////////////////////////////////////////////////////////////////////////////// | 98 /////////////////////////////////////////////////////////////////////////////// |
100 // StickyKeysOverlayView | 99 // StickyKeysOverlayView |
101 class StickyKeysOverlayView : public views::View { | 100 class StickyKeysOverlayView : public views::View { |
102 public: | 101 public: |
103 // This object is not owned by the views hiearchy or by the widget. The | 102 // This object is not owned by the views hiearchy or by the widget. The |
104 // StickyKeysOverlay is the only class that should create and destroy this | 103 // StickyKeysOverlay is the only class that should create and destroy this |
105 // view. | 104 // view. |
106 StickyKeysOverlayView(); | 105 StickyKeysOverlayView(); |
107 | 106 |
108 ~StickyKeysOverlayView() override; | 107 ~StickyKeysOverlayView() override; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 ui::LayerAnimationSequence* sequence) { | 305 ui::LayerAnimationSequence* sequence) { |
307 ui::LayerAnimator* animator = overlay_widget_->GetLayer()->GetAnimator(); | 306 ui::LayerAnimator* animator = overlay_widget_->GetLayer()->GetAnimator(); |
308 if (animator) | 307 if (animator) |
309 animator->RemoveObserver(this); | 308 animator->RemoveObserver(this); |
310 } | 309 } |
311 | 310 |
312 void StickyKeysOverlay::OnLayerAnimationScheduled( | 311 void StickyKeysOverlay::OnLayerAnimationScheduled( |
313 ui::LayerAnimationSequence* sequence) {} | 312 ui::LayerAnimationSequence* sequence) {} |
314 | 313 |
315 } // namespace ash | 314 } // namespace ash |
OLD | NEW |