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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 shortcut_label->SetDisabledColor(theme.GetSystemColor( | 67 shortcut_label->SetDisabledColor(theme.GetSystemColor( |
68 ui::NativeTheme::kColorId_LabelDisabledColor)); | 68 ui::NativeTheme::kColorId_LabelDisabledColor)); |
69 | 69 |
70 // Setup paddings. | 70 // Setup paddings. |
71 const gfx::Insets kVerticalShortcutLabelInsets(1, 6, 1, 6); | 71 const gfx::Insets kVerticalShortcutLabelInsets(1, 6, 1, 6); |
72 const gfx::Insets kHorizontalShortcutLabelInsets(1, 3, 1, 0); | 72 const gfx::Insets kHorizontalShortcutLabelInsets(1, 3, 1, 0); |
73 const gfx::Insets insets = | 73 const gfx::Insets insets = |
74 (orientation == ui::CandidateWindow::VERTICAL ? | 74 (orientation == ui::CandidateWindow::VERTICAL ? |
75 kVerticalShortcutLabelInsets : | 75 kVerticalShortcutLabelInsets : |
76 kHorizontalShortcutLabelInsets); | 76 kHorizontalShortcutLabelInsets); |
77 shortcut_label->SetBorder(views::Border::CreateEmptyBorder( | 77 shortcut_label->SetBorder(views::CreateEmptyBorder( |
78 insets.top(), insets.left(), insets.bottom(), insets.right())); | 78 insets.top(), insets.left(), insets.bottom(), insets.right())); |
79 | 79 |
80 // Add decoration based on the orientation. | 80 // Add decoration based on the orientation. |
81 if (orientation == ui::CandidateWindow::VERTICAL) { | 81 if (orientation == ui::CandidateWindow::VERTICAL) { |
82 // Set the background color. | 82 // Set the background color. |
83 SkColor blackish = color_utils::AlphaBlend( | 83 SkColor blackish = color_utils::AlphaBlend( |
84 SK_ColorBLACK, | 84 SK_ColorBLACK, |
85 theme.GetSystemColor(ui::NativeTheme::kColorId_WindowBackground), | 85 theme.GetSystemColor(ui::NativeTheme::kColorId_WindowBackground), |
86 0x40); | 86 0x40); |
87 SkColor transparent_blakish = color_utils::AlphaBlend( | 87 SkColor transparent_blakish = color_utils::AlphaBlend( |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 ui::CandidateWindow::Orientation orientation) | 143 ui::CandidateWindow::Orientation orientation) |
144 : views::CustomButton(listener), | 144 : views::CustomButton(listener), |
145 orientation_(orientation), | 145 orientation_(orientation), |
146 shortcut_label_(NULL), | 146 shortcut_label_(NULL), |
147 candidate_label_(NULL), | 147 candidate_label_(NULL), |
148 annotation_label_(NULL), | 148 annotation_label_(NULL), |
149 infolist_icon_(NULL), | 149 infolist_icon_(NULL), |
150 shortcut_width_(0), | 150 shortcut_width_(0), |
151 candidate_width_(0), | 151 candidate_width_(0), |
152 highlighted_(false) { | 152 highlighted_(false) { |
153 SetBorder(views::Border::CreateEmptyBorder(1, 1, 1, 1)); | 153 SetBorder(views::CreateEmptyBorder(1, 1, 1, 1)); |
154 | 154 |
155 const ui::NativeTheme& theme = *GetNativeTheme(); | 155 const ui::NativeTheme& theme = *GetNativeTheme(); |
156 shortcut_label_ = CreateShortcutLabel(orientation, theme); | 156 shortcut_label_ = CreateShortcutLabel(orientation, theme); |
157 candidate_label_ = CreateCandidateLabel(orientation); | 157 candidate_label_ = CreateCandidateLabel(orientation); |
158 annotation_label_ = CreateAnnotationLabel(orientation, theme); | 158 annotation_label_ = CreateAnnotationLabel(orientation, theme); |
159 | 159 |
160 AddChildView(shortcut_label_); | 160 AddChildView(shortcut_label_); |
161 AddChildView(candidate_label_); | 161 AddChildView(candidate_label_); |
162 AddChildView(annotation_label_); | 162 AddChildView(annotation_label_); |
163 | 163 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 void CandidateView::SetHighlighted(bool highlighted) { | 200 void CandidateView::SetHighlighted(bool highlighted) { |
201 if (highlighted_ == highlighted) | 201 if (highlighted_ == highlighted) |
202 return; | 202 return; |
203 | 203 |
204 highlighted_ = highlighted; | 204 highlighted_ = highlighted; |
205 if (highlighted) { | 205 if (highlighted) { |
206 ui::NativeTheme* theme = GetNativeTheme(); | 206 ui::NativeTheme* theme = GetNativeTheme(); |
207 set_background( | 207 set_background( |
208 views::Background::CreateSolidBackground(theme->GetSystemColor( | 208 views::Background::CreateSolidBackground(theme->GetSystemColor( |
209 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused))); | 209 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused))); |
210 SetBorder(views::Border::CreateSolidBorder( | 210 SetBorder(views::CreateSolidBorder( |
211 1, | 211 1, |
212 theme->GetSystemColor(ui::NativeTheme::kColorId_FocusedBorderColor))); | 212 theme->GetSystemColor(ui::NativeTheme::kColorId_FocusedBorderColor))); |
213 | 213 |
214 // Cancel currently focused one. | 214 // Cancel currently focused one. |
215 for (int i = 0; i < parent()->child_count(); ++i) { | 215 for (int i = 0; i < parent()->child_count(); ++i) { |
216 CandidateView* view = | 216 CandidateView* view = |
217 static_cast<CandidateView*>((parent()->child_at(i))); | 217 static_cast<CandidateView*>((parent()->child_at(i))); |
218 if (view != this) | 218 if (view != this) |
219 view->SetHighlighted(false); | 219 view->SetHighlighted(false); |
220 } | 220 } |
221 } else { | 221 } else { |
222 set_background(NULL); | 222 set_background(NULL); |
223 SetBorder(views::Border::CreateEmptyBorder(1, 1, 1, 1)); | 223 SetBorder(views::CreateEmptyBorder(1, 1, 1, 1)); |
224 } | 224 } |
225 SchedulePaint(); | 225 SchedulePaint(); |
226 } | 226 } |
227 | 227 |
228 void CandidateView::StateChanged() { | 228 void CandidateView::StateChanged() { |
229 shortcut_label_->SetEnabled(state() != STATE_DISABLED); | 229 shortcut_label_->SetEnabled(state() != STATE_DISABLED); |
230 if (state() == STATE_PRESSED) | 230 if (state() == STATE_PRESSED) |
231 SetHighlighted(true); | 231 SetHighlighted(true); |
232 } | 232 } |
233 | 233 |
(...skipping 68 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 |