| 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/ime/candidate_view.h" | 5 #include "ash/ime/candidate_view.h" |
| 6 | 6 |
| 7 #include "ash/ime/candidate_window_constants.h" | 7 #include "ash/ime/candidate_window_constants.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "ui/base/ime/candidate_window.h" | 9 #include "ui/base/ime/candidate_window.h" |
| 10 #include "ui/gfx/color_utils.h" | 10 #include "ui/gfx/color_utils.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 shortcut_label->SetDisabledColor(theme.GetSystemColor( | 66 shortcut_label->SetDisabledColor(theme.GetSystemColor( |
| 67 ui::NativeTheme::kColorId_LabelDisabledColor)); | 67 ui::NativeTheme::kColorId_LabelDisabledColor)); |
| 68 | 68 |
| 69 // Setup paddings. | 69 // Setup paddings. |
| 70 const gfx::Insets kVerticalShortcutLabelInsets(1, 6, 1, 6); | 70 const gfx::Insets kVerticalShortcutLabelInsets(1, 6, 1, 6); |
| 71 const gfx::Insets kHorizontalShortcutLabelInsets(1, 3, 1, 0); | 71 const gfx::Insets kHorizontalShortcutLabelInsets(1, 3, 1, 0); |
| 72 const gfx::Insets insets = | 72 const gfx::Insets insets = |
| 73 (orientation == ui::CandidateWindow::VERTICAL ? | 73 (orientation == ui::CandidateWindow::VERTICAL ? |
| 74 kVerticalShortcutLabelInsets : | 74 kVerticalShortcutLabelInsets : |
| 75 kHorizontalShortcutLabelInsets); | 75 kHorizontalShortcutLabelInsets); |
| 76 shortcut_label->set_border(views::Border::CreateEmptyBorder( | 76 shortcut_label->SetBorder(views::Border::CreateEmptyBorder( |
| 77 insets.top(), insets.left(), insets.bottom(), insets.right())); | 77 insets.top(), insets.left(), insets.bottom(), insets.right())); |
| 78 | 78 |
| 79 // Add decoration based on the orientation. | 79 // Add decoration based on the orientation. |
| 80 if (orientation == ui::CandidateWindow::VERTICAL) { | 80 if (orientation == ui::CandidateWindow::VERTICAL) { |
| 81 // Set the background color. | 81 // Set the background color. |
| 82 SkColor blackish = color_utils::AlphaBlend( | 82 SkColor blackish = color_utils::AlphaBlend( |
| 83 SK_ColorBLACK, | 83 SK_ColorBLACK, |
| 84 theme.GetSystemColor(ui::NativeTheme::kColorId_WindowBackground), | 84 theme.GetSystemColor(ui::NativeTheme::kColorId_WindowBackground), |
| 85 0x40); | 85 0x40); |
| 86 SkColor transparent_blakish = color_utils::AlphaBlend( | 86 SkColor transparent_blakish = color_utils::AlphaBlend( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 137 |
| 138 CandidateView::CandidateView( | 138 CandidateView::CandidateView( |
| 139 views::ButtonListener* listener, | 139 views::ButtonListener* listener, |
| 140 ui::CandidateWindow::Orientation orientation) | 140 ui::CandidateWindow::Orientation orientation) |
| 141 : views::CustomButton(listener), | 141 : views::CustomButton(listener), |
| 142 orientation_(orientation), | 142 orientation_(orientation), |
| 143 shortcut_label_(NULL), | 143 shortcut_label_(NULL), |
| 144 candidate_label_(NULL), | 144 candidate_label_(NULL), |
| 145 annotation_label_(NULL), | 145 annotation_label_(NULL), |
| 146 infolist_icon_(NULL) { | 146 infolist_icon_(NULL) { |
| 147 set_border(views::Border::CreateEmptyBorder(1, 1, 1, 1)); | 147 SetBorder(views::Border::CreateEmptyBorder(1, 1, 1, 1)); |
| 148 | 148 |
| 149 const ui::NativeTheme& theme = *GetNativeTheme(); | 149 const ui::NativeTheme& theme = *GetNativeTheme(); |
| 150 shortcut_label_ = CreateShortcutLabel(orientation, theme); | 150 shortcut_label_ = CreateShortcutLabel(orientation, theme); |
| 151 candidate_label_ = CreateCandidateLabel(orientation); | 151 candidate_label_ = CreateCandidateLabel(orientation); |
| 152 annotation_label_ = CreateAnnotationLabel(orientation, theme); | 152 annotation_label_ = CreateAnnotationLabel(orientation, theme); |
| 153 | 153 |
| 154 AddChildView(shortcut_label_); | 154 AddChildView(shortcut_label_); |
| 155 AddChildView(candidate_label_); | 155 AddChildView(candidate_label_); |
| 156 AddChildView(annotation_label_); | 156 AddChildView(annotation_label_); |
| 157 | 157 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 SchedulePaint(); | 191 SchedulePaint(); |
| 192 } | 192 } |
| 193 | 193 |
| 194 void CandidateView::StateChanged() { | 194 void CandidateView::StateChanged() { |
| 195 shortcut_label_->SetEnabled(state() != STATE_DISABLED); | 195 shortcut_label_->SetEnabled(state() != STATE_DISABLED); |
| 196 if (state() == STATE_PRESSED) { | 196 if (state() == STATE_PRESSED) { |
| 197 ui::NativeTheme* theme = GetNativeTheme(); | 197 ui::NativeTheme* theme = GetNativeTheme(); |
| 198 set_background( | 198 set_background( |
| 199 views::Background::CreateSolidBackground(theme->GetSystemColor( | 199 views::Background::CreateSolidBackground(theme->GetSystemColor( |
| 200 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused))); | 200 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused))); |
| 201 set_border(views::Border::CreateSolidBorder( | 201 SetBorder(views::Border::CreateSolidBorder( |
| 202 1, theme->GetSystemColor( | 202 1, |
| 203 ui::NativeTheme::kColorId_FocusedBorderColor))); | 203 theme->GetSystemColor(ui::NativeTheme::kColorId_FocusedBorderColor))); |
| 204 | 204 |
| 205 // Cancel currently focused one. | 205 // Cancel currently focused one. |
| 206 for (int i = 0; i < parent()->child_count(); ++i) { | 206 for (int i = 0; i < parent()->child_count(); ++i) { |
| 207 CandidateView* view = | 207 CandidateView* view = |
| 208 static_cast<CandidateView*>((parent()->child_at(i))); | 208 static_cast<CandidateView*>((parent()->child_at(i))); |
| 209 if (view != this && view->state() == STATE_PRESSED) | 209 if (view != this && view->state() == STATE_PRESSED) |
| 210 view->SetState(STATE_NORMAL); | 210 view->SetState(STATE_NORMAL); |
| 211 } | 211 } |
| 212 } else { | 212 } else { |
| 213 set_background(NULL); | 213 set_background(NULL); |
| 214 set_border(views::Border::CreateEmptyBorder(1, 1, 1, 1)); | 214 SetBorder(views::Border::CreateEmptyBorder(1, 1, 1, 1)); |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 | 217 |
| 218 bool CandidateView::OnMouseDragged(const ui::MouseEvent& event) { | 218 bool CandidateView::OnMouseDragged(const ui::MouseEvent& event) { |
| 219 if (!HitTestPoint(event.location())) { | 219 if (!HitTestPoint(event.location())) { |
| 220 // Moves the drag target to the sibling view. | 220 // Moves the drag target to the sibling view. |
| 221 gfx::Point location_in_widget(event.location()); | 221 gfx::Point location_in_widget(event.location()); |
| 222 ConvertPointToWidget(this, &location_in_widget); | 222 ConvertPointToWidget(this, &location_in_widget); |
| 223 for (int i = 0; i < parent()->child_count(); ++i) { | 223 for (int i = 0; i < parent()->child_count(); ++i) { |
| 224 views::View* sibling = parent()->child_at(i); | 224 views::View* sibling = parent()->child_at(i); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 } | 280 } |
| 281 | 281 |
| 282 // Reserves the margin for infolist_icon even if it's not visible. | 282 // Reserves the margin for infolist_icon even if it's not visible. |
| 283 size.Enlarge( | 283 size.Enlarge( |
| 284 kInfolistIndicatorIconWidth + kInfolistIndicatorIconPadding * 2, 0); | 284 kInfolistIndicatorIconWidth + kInfolistIndicatorIconPadding * 2, 0); |
| 285 return size; | 285 return size; |
| 286 } | 286 } |
| 287 | 287 |
| 288 } // namespace ime | 288 } // namespace ime |
| 289 } // namespace ash | 289 } // namespace ash |
| OLD | NEW |