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/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" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "grit/ash_strings.h" | 12 #include "grit/ash_strings.h" |
13 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
14 #include "ui/base/resource/resource_bundle.h" | |
14 #include "ui/compositor/scoped_layer_animation_settings.h" | 15 #include "ui/compositor/scoped_layer_animation_settings.h" |
15 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
16 #include "ui/gfx/font_list.h" | 17 #include "ui/gfx/font_list.h" |
17 #include "ui/views/border.h" | 18 #include "ui/views/border.h" |
18 #include "ui/views/controls/label.h" | 19 #include "ui/views/controls/label.h" |
19 #include "ui/views/layout/box_layout.h" | 20 #include "ui/views/layout/box_layout.h" |
20 #include "ui/views/view.h" | 21 #include "ui/views/view.h" |
21 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
22 #include "ui/views/widget/widget_delegate.h" | 23 #include "ui/views/widget/widget_delegate.h" |
23 | 24 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 | 65 |
65 StickyKeyState state_; | 66 StickyKeyState state_; |
66 | 67 |
67 DISALLOW_COPY_AND_ASSIGN(StickyKeyOverlayLabel); | 68 DISALLOW_COPY_AND_ASSIGN(StickyKeyOverlayLabel); |
68 }; | 69 }; |
69 | 70 |
70 StickyKeyOverlayLabel::StickyKeyOverlayLabel(const std::string& key_name) | 71 StickyKeyOverlayLabel::StickyKeyOverlayLabel(const std::string& key_name) |
71 : state_(STICKY_KEY_STATE_DISABLED) { | 72 : state_(STICKY_KEY_STATE_DISABLED) { |
72 SetText(base::UTF8ToUTF16(key_name)); | 73 SetText(base::UTF8ToUTF16(key_name)); |
73 SetHorizontalAlignment(gfx::ALIGN_LEFT); | 74 SetHorizontalAlignment(gfx::ALIGN_LEFT); |
74 SetFontList( | 75 SetFontList(font_list().DeriveWithSizeDelta(4)); |
Alexei Svitkine (slow)
2014/01/23 18:47:54
Can you comment where the 4 comes from? Are you su
Yuki
2014/01/24 10:23:20
The default font size depends on platforms and use
Alexei Svitkine (slow)
2014/01/24 15:53:41
I agree with the motivation and also agree that if
Yuki
2014/01/27 07:03:49
Here are screenshots (on Pixel). I took screensho
Alexei Svitkine (slow)
2014/01/27 16:00:38
Thanks for checking!
Switching to LargeFont indee
| |
75 font_list().DeriveFontListWithSize(18)); | |
76 SetAutoColorReadabilityEnabled(false); | 76 SetAutoColorReadabilityEnabled(false); |
77 SetFocusable(false); | 77 SetFocusable(false); |
78 SetEnabledColor(SkColorSetARGB(0x80, 0xFF, 0xFF, 0xFF)); | 78 SetEnabledColor(SkColorSetARGB(0x80, 0xFF, 0xFF, 0xFF)); |
79 SetDisabledColor(SkColorSetARGB(0x80, 0xFF, 0xFF, 0xFF)); | 79 SetDisabledColor(SkColorSetARGB(0x80, 0xFF, 0xFF, 0xFF)); |
80 } | 80 } |
81 | 81 |
82 StickyKeyOverlayLabel::~StickyKeyOverlayLabel() { | 82 StickyKeyOverlayLabel::~StickyKeyOverlayLabel() { |
83 } | 83 } |
84 | 84 |
85 void StickyKeyOverlayLabel::SetKeyState(StickyKeyState state) { | 85 void StickyKeyOverlayLabel::SetKeyState(StickyKeyState state) { |
86 state_ = state; | 86 state_ = state; |
87 SkColor label_color; | 87 SkColor label_color; |
88 int style; | 88 int style; |
89 switch (state) { | 89 switch (state) { |
90 case STICKY_KEY_STATE_ENABLED: | 90 case STICKY_KEY_STATE_ENABLED: |
91 style = gfx::Font::NORMAL; | 91 style = gfx::Font::NORMAL; |
92 label_color = SkColorSetA(enabled_color(), 0xFF); | 92 label_color = SkColorSetA(enabled_color(), 0xFF); |
93 break; | 93 break; |
94 case STICKY_KEY_STATE_LOCKED: | 94 case STICKY_KEY_STATE_LOCKED: |
95 style = gfx::Font::UNDERLINE; | 95 style = gfx::Font::UNDERLINE; |
96 label_color = SkColorSetA(enabled_color(), 0xFF); | 96 label_color = SkColorSetA(enabled_color(), 0xFF); |
97 break; | 97 break; |
98 default: | 98 default: |
99 style = gfx::Font::NORMAL; | 99 style = gfx::Font::NORMAL; |
100 label_color = SkColorSetA(enabled_color(), 0x80); | 100 label_color = SkColorSetA(enabled_color(), 0x80); |
101 } | 101 } |
102 | 102 |
103 SetEnabledColor(label_color); | 103 SetEnabledColor(label_color); |
104 SetDisabledColor(label_color); | 104 SetDisabledColor(label_color); |
105 SetFontList(font_list().DeriveFontListWithSizeDeltaAndStyle(0, style)); | 105 SetFontList(font_list().Derive(0, style)); |
106 } | 106 } |
107 | 107 |
108 void StickyKeyOverlayLabel::PaintText(gfx::Canvas* canvas, | 108 void StickyKeyOverlayLabel::PaintText(gfx::Canvas* canvas, |
109 const base::string16& text, | 109 const base::string16& text, |
110 const gfx::Rect& text_bounds, | 110 const gfx::Rect& text_bounds, |
111 int flags) { | 111 int flags) { |
112 views::Label::PaintText(canvas, | 112 views::Label::PaintText(canvas, |
113 text, | 113 text, |
114 text_bounds, | 114 text_bounds, |
115 flags | gfx::Canvas::NO_SUBPIXEL_RENDERING); | 115 flags | gfx::Canvas::NO_SUBPIXEL_RENDERING); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 ui::LayerAnimator* animator = overlay_widget_->GetLayer()->GetAnimator(); | 274 ui::LayerAnimator* animator = overlay_widget_->GetLayer()->GetAnimator(); |
275 if (animator) | 275 if (animator) |
276 animator->RemoveObserver(this); | 276 animator->RemoveObserver(this); |
277 } | 277 } |
278 | 278 |
279 void StickyKeysOverlay::OnLayerAnimationScheduled( | 279 void StickyKeysOverlay::OnLayerAnimationScheduled( |
280 ui::LayerAnimationSequence* sequence) { | 280 ui::LayerAnimationSequence* sequence) { |
281 } | 281 } |
282 | 282 |
283 } // namespace ash | 283 } // namespace ash |
OLD | NEW |