OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/app_list/views/search_box_view.h" | 5 #include "ui/app_list/views/search_box_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 if (speech_button_) | 269 if (speech_button_) |
270 speech_button_->SetSelected(false); | 270 speech_button_->SetSelected(false); |
271 | 271 |
272 switch (focused_view_) { | 272 switch (focused_view_) { |
273 case FOCUS_BACK_BUTTON: | 273 case FOCUS_BACK_BUTTON: |
274 focused_view_ = move_backwards ? FOCUS_BACK_BUTTON : FOCUS_SEARCH_BOX; | 274 focused_view_ = move_backwards ? FOCUS_BACK_BUTTON : FOCUS_SEARCH_BOX; |
275 break; | 275 break; |
276 case FOCUS_SEARCH_BOX: | 276 case FOCUS_SEARCH_BOX: |
277 if (move_backwards) { | 277 if (move_backwards) { |
278 focused_view_ = back_button_ && back_button_->visible() | 278 focused_view_ = back_button_ && back_button_->visible() |
279 ? FOCUS_BACK_BUTTON : FOCUS_SEARCH_BOX; | 279 ? FOCUS_BACK_BUTTON |
280 : FOCUS_SEARCH_BOX; | |
280 } else { | 281 } else { |
281 focused_view_ = speech_button_ && speech_button_->visible() | 282 focused_view_ = speech_button_ && speech_button_->visible() |
282 ? FOCUS_MIC_BUTTON : FOCUS_CONTENTS_VIEW; | 283 ? FOCUS_MIC_BUTTON |
284 : FOCUS_CONTENTS_VIEW; | |
283 } | 285 } |
284 break; | 286 break; |
285 case FOCUS_MIC_BUTTON: | 287 case FOCUS_MIC_BUTTON: |
286 focused_view_ = move_backwards ? FOCUS_SEARCH_BOX : FOCUS_CONTENTS_VIEW; | 288 focused_view_ = move_backwards ? FOCUS_SEARCH_BOX : FOCUS_CONTENTS_VIEW; |
287 break; | 289 break; |
288 case FOCUS_CONTENTS_VIEW: | 290 case FOCUS_CONTENTS_VIEW: |
289 focused_view_ = move_backwards | 291 focused_view_ = |
290 ? (speech_button_ && speech_button_->visible() ? | 292 move_backwards |
291 FOCUS_MIC_BUTTON : FOCUS_SEARCH_BOX) | 293 ? (speech_button_ && speech_button_->visible() ? FOCUS_MIC_BUTTON |
292 : FOCUS_CONTENTS_VIEW; | 294 : FOCUS_SEARCH_BOX) |
295 : FOCUS_CONTENTS_VIEW; | |
293 break; | 296 break; |
294 default: | 297 default: |
295 DCHECK(false); | 298 DCHECK(false); |
296 } | 299 } |
297 | 300 |
298 switch (focused_view_) { | 301 switch (focused_view_) { |
299 case FOCUS_BACK_BUTTON: | 302 case FOCUS_BACK_BUTTON: |
300 if (back_button_) | 303 if (back_button_) |
301 back_button_->SetSelected(true); | 304 back_button_->SetSelected(true); |
302 break; | 305 break; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
344 | 347 |
345 void SearchBoxView::ShowBackOrGoogleIcon(bool show_back_button) { | 348 void SearchBoxView::ShowBackOrGoogleIcon(bool show_back_button) { |
346 if (!is_fullscreen_app_list_enabled_) | 349 if (!is_fullscreen_app_list_enabled_) |
347 return; | 350 return; |
348 | 351 |
349 google_icon_->SetVisible(!show_back_button); | 352 google_icon_->SetVisible(!show_back_button); |
350 back_button_->SetVisible(show_back_button); | 353 back_button_->SetVisible(show_back_button); |
351 content_container_->Layout(); | 354 content_container_->Layout(); |
352 } | 355 } |
353 | 356 |
357 void SearchBoxView::OnMouseEvent(ui::MouseEvent* event) { | |
358 if (!is_fullscreen_app_list_enabled_) | |
359 return; | |
360 | |
361 if (event->type() != ui::ET_MOUSEWHEEL) | |
362 return; | |
363 | |
364 if (app_list_view_->HandleScroll(event)) | |
khmel
2017/07/14 18:10:01
nit:
if (!app_list_view_->HandleScroll(event))
newcomer
2017/07/17 21:38:10
Done.
| |
365 event->SetHandled(); | |
366 } | |
367 | |
354 bool SearchBoxView::OnMouseWheel(const ui::MouseWheelEvent& event) { | 368 bool SearchBoxView::OnMouseWheel(const ui::MouseWheelEvent& event) { |
355 if (contents_view_) | 369 if (contents_view_) |
356 return contents_view_->OnMouseWheel(event); | 370 return contents_view_->OnMouseWheel(event); |
357 | |
358 return false; | 371 return false; |
359 } | 372 } |
360 | 373 |
361 void SearchBoxView::OnEnabledChanged() { | 374 void SearchBoxView::OnEnabledChanged() { |
362 search_box_->SetEnabled(enabled()); | 375 search_box_->SetEnabled(enabled()); |
363 if (speech_button_) | 376 if (speech_button_) |
364 speech_button_->SetEnabled(enabled()); | 377 speech_button_->SetEnabled(enabled()); |
365 } | 378 } |
366 | 379 |
367 const char* SearchBoxView::GetClassName() const { | 380 const char* SearchBoxView::GetClassName() const { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
434 speech_button_->OnKeyReleased(key_event)) | 447 speech_button_->OnKeyReleased(key_event)) |
435 return true; | 448 return true; |
436 | 449 |
437 return contents_view_ && contents_view_->visible() && | 450 return contents_view_ && contents_view_->visible() && |
438 contents_view_->OnKeyReleased(key_event); | 451 contents_view_->OnKeyReleased(key_event); |
439 } | 452 } |
440 | 453 |
441 return false; | 454 return false; |
442 } | 455 } |
443 | 456 |
457 bool SearchBoxView::HandleMouseEvent(views::Textfield* sender, | |
458 const ui::MouseEvent& mouse_event) { | |
459 if (!is_fullscreen_app_list_enabled_) | |
460 return false; | |
461 | |
462 if (mouse_event.type() != ui::ET_MOUSEWHEEL) | |
463 return false; | |
464 | |
465 return app_list_view_->HandleScroll(&mouse_event); | |
466 } | |
467 | |
444 void SearchBoxView::ButtonPressed(views::Button* sender, | 468 void SearchBoxView::ButtonPressed(views::Button* sender, |
445 const ui::Event& event) { | 469 const ui::Event& event) { |
446 if (back_button_ && sender == back_button_) | 470 if (back_button_ && sender == back_button_) |
447 delegate_->BackButtonPressed(); | 471 delegate_->BackButtonPressed(); |
448 else if (speech_button_ && sender == speech_button_) | 472 else if (speech_button_ && sender == speech_button_) |
449 view_delegate_->StartSpeechRecognition(); | 473 view_delegate_->StartSpeechRecognition(); |
450 else | 474 else |
451 NOTREACHED(); | 475 NOTREACHED(); |
452 } | 476 } |
453 | 477 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
548 SchedulePaint(); | 572 SchedulePaint(); |
549 } | 573 } |
550 | 574 |
551 void SearchBoxView::OnSpeechRecognitionStateChanged( | 575 void SearchBoxView::OnSpeechRecognitionStateChanged( |
552 SpeechRecognitionState new_state) { | 576 SpeechRecognitionState new_state) { |
553 SpeechRecognitionButtonPropChanged(); | 577 SpeechRecognitionButtonPropChanged(); |
554 SchedulePaint(); | 578 SchedulePaint(); |
555 } | 579 } |
556 | 580 |
557 } // namespace app_list | 581 } // namespace app_list |
OLD | NEW |