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 "base/macros.h" | 5 #include "base/macros.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "ui/base/ime/candidate_window.h" | 7 #include "ui/base/ime/candidate_window.h" |
8 #include "ui/chromeos/ime/candidate_view.h" | 8 #include "ui/chromeos/ime/candidate_view.h" |
9 #include "ui/chromeos/ime/candidate_window_constants.h" | 9 #include "ui/chromeos/ime/candidate_window_constants.h" |
10 #include "ui/gfx/color_utils.h" | 10 #include "ui/gfx/color_utils.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // Creates the shortcut label, and returns it (never returns NULL). | 46 // Creates the shortcut label, and returns it (never returns NULL). |
47 // The label text is not set in this function. | 47 // The label text is not set in this function. |
48 views::Label* CreateShortcutLabel( | 48 views::Label* CreateShortcutLabel( |
49 ui::CandidateWindow::Orientation orientation, | 49 ui::CandidateWindow::Orientation orientation, |
50 const ui::NativeTheme& theme) { | 50 const ui::NativeTheme& theme) { |
51 // Create the shortcut label. The label will be owned by | 51 // Create the shortcut label. The label will be owned by |
52 // |wrapped_shortcut_label|, hence it's deleted when | 52 // |wrapped_shortcut_label|, hence it's deleted when |
53 // |wrapped_shortcut_label| is deleted. | 53 // |wrapped_shortcut_label| is deleted. |
54 views::Label* shortcut_label = new views::Label; | 54 views::Label* shortcut_label = new views::Label; |
55 | 55 |
| 56 // TODO(tapted): Get this FontList from views::style. |
56 if (orientation == ui::CandidateWindow::VERTICAL) { | 57 if (orientation == ui::CandidateWindow::VERTICAL) { |
57 shortcut_label->SetFontList(shortcut_label->font_list().Derive( | 58 shortcut_label->SetFontList(shortcut_label->font_list().Derive( |
58 kFontSizeDelta, gfx::Font::NORMAL, gfx::Font::Weight::BOLD)); | 59 kFontSizeDelta, gfx::Font::NORMAL, gfx::Font::Weight::BOLD)); |
59 } else { | 60 } else { |
60 shortcut_label->SetFontList( | 61 shortcut_label->SetFontList( |
61 shortcut_label->font_list().DeriveWithSizeDelta(kFontSizeDelta)); | 62 shortcut_label->font_list().DeriveWithSizeDelta(kFontSizeDelta)); |
62 } | 63 } |
63 // TODO(satorux): Maybe we need to use language specific fonts for | 64 // TODO(satorux): Maybe we need to use language specific fonts for |
64 // candidate_label, like Chinese font for Chinese input method? | 65 // candidate_label, like Chinese font for Chinese input method? |
65 shortcut_label->SetEnabledColor(theme.GetSystemColor( | |
66 ui::NativeTheme::kColorId_LabelEnabledColor)); | |
67 shortcut_label->SetDisabledColor(theme.GetSystemColor( | |
68 ui::NativeTheme::kColorId_LabelDisabledColor)); | |
69 | 66 |
70 // Setup paddings. | 67 // Setup paddings. |
71 const gfx::Insets kVerticalShortcutLabelInsets(1, 6, 1, 6); | 68 const gfx::Insets kVerticalShortcutLabelInsets(1, 6, 1, 6); |
72 const gfx::Insets kHorizontalShortcutLabelInsets(1, 3, 1, 0); | 69 const gfx::Insets kHorizontalShortcutLabelInsets(1, 3, 1, 0); |
73 const gfx::Insets insets = | 70 const gfx::Insets insets = |
74 (orientation == ui::CandidateWindow::VERTICAL ? | 71 (orientation == ui::CandidateWindow::VERTICAL ? |
75 kVerticalShortcutLabelInsets : | 72 kVerticalShortcutLabelInsets : |
76 kHorizontalShortcutLabelInsets); | 73 kHorizontalShortcutLabelInsets); |
77 shortcut_label->SetBorder(views::CreateEmptyBorder( | 74 shortcut_label->SetBorder(views::CreateEmptyBorder( |
78 insets.top(), insets.left(), insets.bottom(), insets.right())); | 75 insets.top(), insets.left(), insets.bottom(), insets.right())); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 view->SetHighlighted(false); | 216 view->SetHighlighted(false); |
220 } | 217 } |
221 } else { | 218 } else { |
222 set_background(NULL); | 219 set_background(NULL); |
223 SetBorder(views::CreateEmptyBorder(1, 1, 1, 1)); | 220 SetBorder(views::CreateEmptyBorder(1, 1, 1, 1)); |
224 } | 221 } |
225 SchedulePaint(); | 222 SchedulePaint(); |
226 } | 223 } |
227 | 224 |
228 void CandidateView::StateChanged(ButtonState old_state) { | 225 void CandidateView::StateChanged(ButtonState old_state) { |
229 shortcut_label_->SetEnabled(state() != STATE_DISABLED); | 226 int text_style = state() == STATE_DISABLED ? views::style::STYLE_DISABLED |
| 227 : views::style::STYLE_PRIMARY; |
| 228 shortcut_label_->SetEnabledColor(views::style::GetColor( |
| 229 views::style::CONTEXT_LABEL, text_style, GetNativeTheme())); |
230 if (state() == STATE_PRESSED) | 230 if (state() == STATE_PRESSED) |
231 SetHighlighted(true); | 231 SetHighlighted(true); |
232 } | 232 } |
233 | 233 |
234 const char* CandidateView::GetClassName() const { | 234 const char* CandidateView::GetClassName() const { |
235 return "CandidateView"; | 235 return "CandidateView"; |
236 } | 236 } |
237 | 237 |
238 bool CandidateView::OnMouseDragged(const ui::MouseEvent& event) { | 238 bool CandidateView::OnMouseDragged(const ui::MouseEvent& event) { |
239 if (!HitTestPoint(event.location())) { | 239 if (!HitTestPoint(event.location())) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 } | 302 } |
303 | 303 |
304 // Reserves the margin for infolist_icon even if it's not visible. | 304 // Reserves the margin for infolist_icon even if it's not visible. |
305 size.Enlarge( | 305 size.Enlarge( |
306 kInfolistIndicatorIconWidth + kInfolistIndicatorIconPadding * 2, 0); | 306 kInfolistIndicatorIconWidth + kInfolistIndicatorIconPadding * 2, 0); |
307 return size; | 307 return size; |
308 } | 308 } |
309 | 309 |
310 } // namespace ime | 310 } // namespace ime |
311 } // namespace ui | 311 } // namespace ui |
OLD | NEW |