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

Side by Side Diff: ash/ime/candidate_window_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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/ime/candidate_view_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_window_view.h" 5 #include "ash/ime/candidate_window_view.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "ash/ime/candidate_view.h" 9 #include "ash/ime/candidate_view.h"
10 #include "ash/ime/candidate_window_constants.h" 10 #include "ash/ime/candidate_window_constants.h"
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 int max_candidate_width = 0; 276 int max_candidate_width = 0;
277 for (size_t i = 0; i < candidate_views_.size(); ++i) { 277 for (size_t i = 0; i < candidate_views_.size(); ++i) {
278 const size_t index_in_page = i; 278 const size_t index_in_page = i;
279 const size_t candidate_index = start_from + index_in_page; 279 const size_t candidate_index = start_from + index_in_page;
280 CandidateView* candidate_view = candidate_views_[index_in_page]; 280 CandidateView* candidate_view = candidate_views_[index_in_page];
281 // Set the candidate text. 281 // Set the candidate text.
282 if (candidate_index < new_candidate_window.candidates().size()) { 282 if (candidate_index < new_candidate_window.candidates().size()) {
283 const ui::CandidateWindow::Entry& entry = 283 const ui::CandidateWindow::Entry& entry =
284 new_candidate_window.candidates()[candidate_index]; 284 new_candidate_window.candidates()[candidate_index];
285 candidate_view->SetEntry(entry); 285 candidate_view->SetEntry(entry);
286 candidate_view->SetState(views::Button::STATE_NORMAL); 286 candidate_view->SetEnabled(true);
287 candidate_view->SetInfolistIcon(!entry.description_title.empty()); 287 candidate_view->SetInfolistIcon(!entry.description_title.empty());
288 } else { 288 } else {
289 // Disable the empty row. 289 // Disable the empty row.
290 candidate_view->SetEntry(ui::CandidateWindow::Entry()); 290 candidate_view->SetEntry(ui::CandidateWindow::Entry());
291 candidate_view->SetState(views::Button::STATE_DISABLED); 291 candidate_view->SetEnabled(false);
292 candidate_view->SetInfolistIcon(false); 292 candidate_view->SetInfolistIcon(false);
293 } 293 }
294 if (new_candidate_window.orientation() == ui::CandidateWindow::VERTICAL) { 294 if (new_candidate_window.orientation() == ui::CandidateWindow::VERTICAL) {
295 int shortcut_width = 0; 295 int shortcut_width = 0;
296 int candidate_width = 0; 296 int candidate_width = 0;
297 candidate_views_[i]->GetPreferredWidths( 297 candidate_views_[i]->GetPreferredWidths(
298 &shortcut_width, &candidate_width); 298 &shortcut_width, &candidate_width);
299 max_shortcut_width = std::max(max_shortcut_width, shortcut_width); 299 max_shortcut_width = std::max(max_shortcut_width, shortcut_width);
300 max_candidate_width = std::max(max_candidate_width, candidate_width); 300 max_candidate_width = std::max(max_candidate_width, candidate_width);
301 } 301 }
(...skipping 19 matching lines...) Expand all
321 if (candidate_window_.page_size()) { 321 if (candidate_window_.page_size()) {
322 const int current_candidate_in_page = 322 const int current_candidate_in_page =
323 candidate_window_.cursor_position() % candidate_window_.page_size(); 323 candidate_window_.cursor_position() % candidate_window_.page_size();
324 SelectCandidateAt(current_candidate_in_page); 324 SelectCandidateAt(current_candidate_in_page);
325 } 325 }
326 } else { 326 } else {
327 // Unselect the currently selected candidate. 327 // Unselect the currently selected candidate.
328 if (0 <= selected_candidate_index_in_page_ && 328 if (0 <= selected_candidate_index_in_page_ &&
329 static_cast<size_t>(selected_candidate_index_in_page_) < 329 static_cast<size_t>(selected_candidate_index_in_page_) <
330 candidate_views_.size()) { 330 candidate_views_.size()) {
331 candidate_views_[selected_candidate_index_in_page_]->SetState( 331 candidate_views_[selected_candidate_index_in_page_]->SetHighlighted(
332 views::Button::STATE_NORMAL); 332 false);
333 selected_candidate_index_in_page_ = -1; 333 selected_candidate_index_in_page_ = -1;
334 } 334 }
335 } 335 }
336 336
337 // Updates auxiliary text 337 // Updates auxiliary text
338 auxiliary_text_->SetVisible(candidate_window_.is_auxiliary_text_visible()); 338 auxiliary_text_->SetVisible(candidate_window_.is_auxiliary_text_visible());
339 auxiliary_text_->SetText(base::UTF8ToUTF16( 339 auxiliary_text_->SetText(base::UTF8ToUTF16(
340 candidate_window_.auxiliary_text())); 340 candidate_window_.auxiliary_text()));
341 } 341 }
342 342
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 if (cursor_absolute_index < 0 || 381 if (cursor_absolute_index < 0 ||
382 candidate_window_.candidates().size() <= 382 candidate_window_.candidates().size() <=
383 static_cast<size_t>(cursor_absolute_index)) { 383 static_cast<size_t>(cursor_absolute_index)) {
384 return; 384 return;
385 } 385 }
386 386
387 // Remember the currently selected candidate index in the current page. 387 // Remember the currently selected candidate index in the current page.
388 selected_candidate_index_in_page_ = index_in_page; 388 selected_candidate_index_in_page_ = index_in_page;
389 389
390 // Select the candidate specified by index_in_page. 390 // Select the candidate specified by index_in_page.
391 candidate_views_[index_in_page]->SetState(views::Button::STATE_PRESSED); 391 candidate_views_[index_in_page]->SetHighlighted(true);
392 392
393 // Update the cursor indexes in the model. 393 // Update the cursor indexes in the model.
394 candidate_window_.set_cursor_position(cursor_absolute_index); 394 candidate_window_.set_cursor_position(cursor_absolute_index);
395 } 395 }
396 396
397 void CandidateWindowView::ButtonPressed(views::Button* sender, 397 void CandidateWindowView::ButtonPressed(views::Button* sender,
398 const ui::Event& event) { 398 const ui::Event& event) {
399 for (size_t i = 0; i < candidate_views_.size(); ++i) { 399 for (size_t i = 0; i < candidate_views_.size(); ++i) {
400 if (sender == candidate_views_[i]) { 400 if (sender == candidate_views_[i]) {
401 FOR_EACH_OBSERVER(Observer, observers_, OnCandidateCommitted(i)); 401 FOR_EACH_OBSERVER(Observer, observers_, OnCandidateCommitted(i));
402 return; 402 return;
403 } 403 }
404 } 404 }
405 } 405 }
406 406
407 } // namespace ime 407 } // namespace ime
408 } // namespace ash 408 } // namespace ash
OLDNEW
« no previous file with comments | « ash/ime/candidate_view_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698