| 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/search_box_view.h" | 5 #include "ui/app_list/search_box_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ui/app_list/search_box_model.h" | 9 #include "ui/app_list/search_box_model.h" |
| 10 #include "ui/app_list/search_box_view_delegate.h" | 10 #include "ui/app_list/search_box_view_delegate.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 const SkColor kHintTextColor = SkColorSetRGB(0xA0, 0xA0, 0xA0); | 25 const SkColor kHintTextColor = SkColorSetRGB(0xA0, 0xA0, 0xA0); |
| 26 | 26 |
| 27 } // namespace | 27 } // namespace |
| 28 | 28 |
| 29 SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate) | 29 SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate) |
| 30 : delegate_(delegate), | 30 : delegate_(delegate), |
| 31 model_(NULL), | 31 model_(NULL), |
| 32 icon_view_(NULL), | 32 icon_view_(NULL), |
| 33 search_box_(NULL), | 33 search_box_(NULL), |
| 34 grid_view_(NULL), | 34 contents_view_(NULL) { |
| 35 results_view_(NULL) { | |
| 36 icon_view_ = new views::ImageView; | 35 icon_view_ = new views::ImageView; |
| 37 AddChildView(icon_view_); | 36 AddChildView(icon_view_); |
| 38 | 37 |
| 39 search_box_ = new views::Textfield; | 38 search_box_ = new views::Textfield; |
| 40 search_box_->RemoveBorder(); | 39 search_box_->RemoveBorder(); |
| 41 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 40 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 42 search_box_->SetFont(gfx::Font( | 41 search_box_->SetFont(gfx::Font( |
| 43 rb.GetFont(ResourceBundle::BaseFont).GetFontName(), | 42 rb.GetFont(ResourceBundle::BaseFont).GetFontName(), |
| 44 kFontSize)); | 43 kFontSize)); |
| 45 search_box_->set_placeholder_text_color(kHintTextColor); | 44 search_box_->set_placeholder_text_color(kHintTextColor); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 if (has_query && key_event.key_code() == ui::VKEY_ESCAPE) { | 116 if (has_query && key_event.key_code() == ui::VKEY_ESCAPE) { |
| 118 search_box_->SetText(string16()); | 117 search_box_->SetText(string16()); |
| 119 // Updates model and fires query changed manually because SetText above | 118 // Updates model and fires query changed manually because SetText above |
| 120 // does not generate ContentsChanged notification. | 119 // does not generate ContentsChanged notification. |
| 121 UpdateModel(); | 120 UpdateModel(); |
| 122 NotifyQueryChanged(); | 121 NotifyQueryChanged(); |
| 123 return true; | 122 return true; |
| 124 } | 123 } |
| 125 | 124 |
| 126 bool handled = false; | 125 bool handled = false; |
| 127 if (has_query) { | 126 if (contents_view_ && contents_view_->visible()) |
| 128 if (results_view_ && results_view_->visible()) | 127 handled = contents_view_->OnKeyPressed(key_event); |
| 129 handled = results_view_->OnKeyPressed(key_event); | |
| 130 } else { | |
| 131 if (grid_view_ && grid_view_->visible()) | |
| 132 handled = grid_view_->OnKeyPressed(key_event); | |
| 133 } | |
| 134 | 128 |
| 135 return handled; | 129 return handled; |
| 136 } | 130 } |
| 137 | 131 |
| 138 void SearchBoxView::IconChanged() { | 132 void SearchBoxView::IconChanged() { |
| 139 icon_view_->SetImage(model_->icon()); | 133 icon_view_->SetImage(model_->icon()); |
| 140 } | 134 } |
| 141 | 135 |
| 142 void SearchBoxView::HintTextChanged() { | 136 void SearchBoxView::HintTextChanged() { |
| 143 search_box_->set_placeholder_text(model_->hint_text()); | 137 search_box_->set_placeholder_text(model_->hint_text()); |
| 144 } | 138 } |
| 145 | 139 |
| 146 void SearchBoxView::SelectionModelChanged() { | 140 void SearchBoxView::SelectionModelChanged() { |
| 147 search_box_->SelectSelectionModel(model_->selection_model()); | 141 search_box_->SelectSelectionModel(model_->selection_model()); |
| 148 } | 142 } |
| 149 | 143 |
| 150 void SearchBoxView::TextChanged() { | 144 void SearchBoxView::TextChanged() { |
| 151 search_box_->SetText(model_->text()); | 145 search_box_->SetText(model_->text()); |
| 152 } | 146 } |
| 153 | 147 |
| 154 } // namespace app_list | 148 } // namespace app_list |
| 155 | 149 |
| OLD | NEW |