Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Unified Diff: ash/ime/candidate_view.cc

Issue 258463002: Introduces 'highlighted' property to candidate view. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/ime/candidate_view.h ('k') | ash/ime/candidate_view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
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));
}
}
« no previous file with comments | « ash/ime/candidate_view.h ('k') | ash/ime/candidate_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698