Chromium Code Reviews| Index: ash/ime/candidate_view.cc |
| diff --git a/ash/ime/candidate_view.cc b/ash/ime/candidate_view.cc |
| index 83c930f4b7465b5b68877f1ebb3fca16278e4a02..4071071255427cd0160e57c5d4e7ee5a6c52364f 100644 |
| --- a/ash/ime/candidate_view.cc |
| +++ b/ash/ime/candidate_view.cc |
| @@ -140,7 +140,10 @@ CandidateView::CandidateView( |
| shortcut_label_(NULL), |
| candidate_label_(NULL), |
| annotation_label_(NULL), |
| - infolist_icon_(NULL) { |
| + infolist_icon_(NULL), |
| + shortcut_width_(0), |
| + candidate_width_(0), |
| + highlighted_(false) { |
| SetBorder(views::Border::CreateEmptyBorder(1, 1, 1, 1)); |
| const ui::NativeTheme& theme = *GetNativeTheme(); |
| @@ -188,9 +191,12 @@ void CandidateView::SetInfolistIcon(bool enable) { |
| SchedulePaint(); |
| } |
| -void CandidateView::StateChanged() { |
| - shortcut_label_->SetEnabled(state() != STATE_DISABLED); |
| - if (state() == STATE_PRESSED) { |
| +void CandidateView::SetHighlighted(bool highlighted) { |
| + if (highlighted_ == highlighted) |
| + return; |
| + |
| + highlighted_ = highlighted; |
| + if (highlighted) { |
| ui::NativeTheme* theme = GetNativeTheme(); |
| set_background( |
| views::Background::CreateSolidBackground(theme->GetSystemColor( |
| @@ -203,13 +209,20 @@ void CandidateView::StateChanged() { |
| for (int i = 0; i < parent()->child_count(); ++i) { |
| CandidateView* view = |
| static_cast<CandidateView*>((parent()->child_at(i))); |
| - if (view != this && view->state() == STATE_PRESSED) |
| - view->SetState(STATE_NORMAL); |
| + if (view != this) |
| + view->SetHighlighted(false); |
| } |
| } else { |
| set_background(NULL); |
| SetBorder(views::Border::CreateEmptyBorder(1, 1, 1, 1)); |
| } |
| + SchedulePaint(); |
| +} |
| + |
| +void CandidateView::StateChanged() { |
| + shortcut_label_->SetEnabled(state() != STATE_DISABLED); |
| + if (state() == STATE_PRESSED) |
| + SetHighlighted(true); |
|
oshima
2014/04/23 23:50:07
shouldn't this be
SetHighlighted(state() == STAT
Jun Mukai
2014/04/23 23:58:02
No, state() can be changed to 'HOVER' and then 'NO
oshima
2014/04/24 00:05:37
Ah i see. Can you add test for this? It looks subt
Jun Mukai
2014/04/24 19:01:39
Done.
|
| } |
| bool CandidateView::OnMouseDragged(const ui::MouseEvent& event) { |
| @@ -218,14 +231,16 @@ bool CandidateView::OnMouseDragged(const ui::MouseEvent& event) { |
| gfx::Point location_in_widget(event.location()); |
| ConvertPointToWidget(this, &location_in_widget); |
| for (int i = 0; i < parent()->child_count(); ++i) { |
| - views::View* sibling = parent()->child_at(i); |
| + CandidateView* sibling = |
| + static_cast<CandidateView*>(parent()->child_at(i)); |
| if (sibling == this) |
| continue; |
| gfx::Point location_in_sibling(location_in_widget); |
| ConvertPointFromWidget(sibling, &location_in_sibling); |
| if (sibling->HitTestPoint(location_in_sibling)) { |
| GetWidget()->GetRootView()->SetMouseHandler(sibling); |
| - return sibling->OnMouseDragged(event); |
| + sibling->SetHighlighted(true); |
| + return sibling->OnMouseDragged(ui::MouseEvent(event, this, sibling)); |
| } |
| } |