| 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 11 matching lines...) Expand all Loading... |
| 22 #include "ui/app_list/views/app_list_view.h" | 22 #include "ui/app_list/views/app_list_view.h" |
| 23 #include "ui/app_list/views/contents_view.h" | 23 #include "ui/app_list/views/contents_view.h" |
| 24 #include "ui/app_list/views/search_box_view_delegate.h" | 24 #include "ui/app_list/views/search_box_view_delegate.h" |
| 25 #include "ui/base/ime/text_input_flags.h" | 25 #include "ui/base/ime/text_input_flags.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| 27 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
| 28 #include "ui/events/event.h" | 28 #include "ui/events/event.h" |
| 29 #include "ui/gfx/canvas.h" | 29 #include "ui/gfx/canvas.h" |
| 30 #include "ui/gfx/color_utils.h" | 30 #include "ui/gfx/color_utils.h" |
| 31 #include "ui/gfx/geometry/insets.h" | 31 #include "ui/gfx/geometry/insets.h" |
| 32 #include "ui/gfx/geometry/vector2d_conversions.h" |
| 32 #include "ui/gfx/paint_vector_icon.h" | 33 #include "ui/gfx/paint_vector_icon.h" |
| 33 #include "ui/gfx/shadow_value.h" | 34 #include "ui/gfx/shadow_value.h" |
| 34 #include "ui/strings/grit/ui_strings.h" | 35 #include "ui/strings/grit/ui_strings.h" |
| 35 #include "ui/views/background.h" | 36 #include "ui/views/background.h" |
| 36 #include "ui/views/border.h" | 37 #include "ui/views/border.h" |
| 37 #include "ui/views/controls/button/image_button.h" | 38 #include "ui/views/controls/button/image_button.h" |
| 38 #include "ui/views/controls/image_view.h" | 39 #include "ui/views/controls/image_view.h" |
| 39 #include "ui/views/controls/textfield/textfield.h" | 40 #include "ui/views/controls/textfield/textfield.h" |
| 40 #include "ui/views/layout/box_layout.h" | 41 #include "ui/views/layout/box_layout.h" |
| 41 #include "ui/views/layout/fill_layout.h" | 42 #include "ui/views/layout/fill_layout.h" |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 if (speech_button_) | 270 if (speech_button_) |
| 270 speech_button_->SetSelected(false); | 271 speech_button_->SetSelected(false); |
| 271 | 272 |
| 272 switch (focused_view_) { | 273 switch (focused_view_) { |
| 273 case FOCUS_BACK_BUTTON: | 274 case FOCUS_BACK_BUTTON: |
| 274 focused_view_ = move_backwards ? FOCUS_BACK_BUTTON : FOCUS_SEARCH_BOX; | 275 focused_view_ = move_backwards ? FOCUS_BACK_BUTTON : FOCUS_SEARCH_BOX; |
| 275 break; | 276 break; |
| 276 case FOCUS_SEARCH_BOX: | 277 case FOCUS_SEARCH_BOX: |
| 277 if (move_backwards) { | 278 if (move_backwards) { |
| 278 focused_view_ = back_button_ && back_button_->visible() | 279 focused_view_ = back_button_ && back_button_->visible() |
| 279 ? FOCUS_BACK_BUTTON : FOCUS_SEARCH_BOX; | 280 ? FOCUS_BACK_BUTTON |
| 281 : FOCUS_SEARCH_BOX; |
| 280 } else { | 282 } else { |
| 281 focused_view_ = speech_button_ && speech_button_->visible() | 283 focused_view_ = speech_button_ && speech_button_->visible() |
| 282 ? FOCUS_MIC_BUTTON : FOCUS_CONTENTS_VIEW; | 284 ? FOCUS_MIC_BUTTON |
| 285 : FOCUS_CONTENTS_VIEW; |
| 283 } | 286 } |
| 284 break; | 287 break; |
| 285 case FOCUS_MIC_BUTTON: | 288 case FOCUS_MIC_BUTTON: |
| 286 focused_view_ = move_backwards ? FOCUS_SEARCH_BOX : FOCUS_CONTENTS_VIEW; | 289 focused_view_ = move_backwards ? FOCUS_SEARCH_BOX : FOCUS_CONTENTS_VIEW; |
| 287 break; | 290 break; |
| 288 case FOCUS_CONTENTS_VIEW: | 291 case FOCUS_CONTENTS_VIEW: |
| 289 focused_view_ = move_backwards | 292 focused_view_ = |
| 290 ? (speech_button_ && speech_button_->visible() ? | 293 move_backwards |
| 291 FOCUS_MIC_BUTTON : FOCUS_SEARCH_BOX) | 294 ? (speech_button_ && speech_button_->visible() ? FOCUS_MIC_BUTTON |
| 292 : FOCUS_CONTENTS_VIEW; | 295 : FOCUS_SEARCH_BOX) |
| 296 : FOCUS_CONTENTS_VIEW; |
| 293 break; | 297 break; |
| 294 default: | 298 default: |
| 295 DCHECK(false); | 299 DCHECK(false); |
| 296 } | 300 } |
| 297 | 301 |
| 298 switch (focused_view_) { | 302 switch (focused_view_) { |
| 299 case FOCUS_BACK_BUTTON: | 303 case FOCUS_BACK_BUTTON: |
| 300 if (back_button_) | 304 if (back_button_) |
| 301 back_button_->SetSelected(true); | 305 back_button_->SetSelected(true); |
| 302 break; | 306 break; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 348 |
| 345 void SearchBoxView::ShowBackOrGoogleIcon(bool show_back_button) { | 349 void SearchBoxView::ShowBackOrGoogleIcon(bool show_back_button) { |
| 346 if (!is_fullscreen_app_list_enabled_) | 350 if (!is_fullscreen_app_list_enabled_) |
| 347 return; | 351 return; |
| 348 | 352 |
| 349 google_icon_->SetVisible(!show_back_button); | 353 google_icon_->SetVisible(!show_back_button); |
| 350 back_button_->SetVisible(show_back_button); | 354 back_button_->SetVisible(show_back_button); |
| 351 content_container_->Layout(); | 355 content_container_->Layout(); |
| 352 } | 356 } |
| 353 | 357 |
| 358 void SearchBoxView::OnMouseEvent(ui::MouseEvent* event) { |
| 359 if (!is_fullscreen_app_list_enabled_) |
| 360 return; |
| 361 |
| 362 if (event->type() != ui::ET_MOUSEWHEEL) |
| 363 return; |
| 364 |
| 365 if (app_list_view_->HandleScroll(event)) |
| 366 event->SetHandled(); |
| 367 } |
| 368 |
| 354 bool SearchBoxView::OnMouseWheel(const ui::MouseWheelEvent& event) { | 369 bool SearchBoxView::OnMouseWheel(const ui::MouseWheelEvent& event) { |
| 355 if (contents_view_) | 370 if (contents_view_) |
| 356 return contents_view_->OnMouseWheel(event); | 371 return contents_view_->OnMouseWheel(event); |
| 357 | |
| 358 return false; | 372 return false; |
| 359 } | 373 } |
| 360 | 374 |
| 361 void SearchBoxView::OnEnabledChanged() { | 375 void SearchBoxView::OnEnabledChanged() { |
| 362 search_box_->SetEnabled(enabled()); | 376 search_box_->SetEnabled(enabled()); |
| 363 if (speech_button_) | 377 if (speech_button_) |
| 364 speech_button_->SetEnabled(enabled()); | 378 speech_button_->SetEnabled(enabled()); |
| 365 } | 379 } |
| 366 | 380 |
| 367 const char* SearchBoxView::GetClassName() const { | 381 const char* SearchBoxView::GetClassName() const { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 speech_button_->OnKeyReleased(key_event)) | 448 speech_button_->OnKeyReleased(key_event)) |
| 435 return true; | 449 return true; |
| 436 | 450 |
| 437 return contents_view_ && contents_view_->visible() && | 451 return contents_view_ && contents_view_->visible() && |
| 438 contents_view_->OnKeyReleased(key_event); | 452 contents_view_->OnKeyReleased(key_event); |
| 439 } | 453 } |
| 440 | 454 |
| 441 return false; | 455 return false; |
| 442 } | 456 } |
| 443 | 457 |
| 458 bool SearchBoxView::HandleMouseEvent(views::Textfield* sender, |
| 459 const ui::MouseEvent& mouse_event) { |
| 460 if (!is_fullscreen_app_list_enabled_) |
| 461 return false; |
| 462 |
| 463 if (mouse_event.type() != ui::ET_MOUSEWHEEL) |
| 464 return false; |
| 465 |
| 466 return app_list_view_->HandleScroll(&mouse_event); |
| 467 } |
| 468 |
| 444 void SearchBoxView::ButtonPressed(views::Button* sender, | 469 void SearchBoxView::ButtonPressed(views::Button* sender, |
| 445 const ui::Event& event) { | 470 const ui::Event& event) { |
| 446 if (back_button_ && sender == back_button_) | 471 if (back_button_ && sender == back_button_) |
| 447 delegate_->BackButtonPressed(); | 472 delegate_->BackButtonPressed(); |
| 448 else if (speech_button_ && sender == speech_button_) | 473 else if (speech_button_ && sender == speech_button_) |
| 449 view_delegate_->StartSpeechRecognition(); | 474 view_delegate_->StartSpeechRecognition(); |
| 450 else | 475 else |
| 451 NOTREACHED(); | 476 NOTREACHED(); |
| 452 } | 477 } |
| 453 | 478 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 SchedulePaint(); | 573 SchedulePaint(); |
| 549 } | 574 } |
| 550 | 575 |
| 551 void SearchBoxView::OnSpeechRecognitionStateChanged( | 576 void SearchBoxView::OnSpeechRecognitionStateChanged( |
| 552 SpeechRecognitionState new_state) { | 577 SpeechRecognitionState new_state) { |
| 553 SpeechRecognitionButtonPropChanged(); | 578 SpeechRecognitionButtonPropChanged(); |
| 554 SchedulePaint(); | 579 SchedulePaint(); |
| 555 } | 580 } |
| 556 | 581 |
| 557 } // namespace app_list | 582 } // namespace app_list |
| OLD | NEW |