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 "grit/ui_resources.h" | 9 #include "grit/ui_resources.h" |
10 #include "ui/app_list/app_list_model.h" | 10 #include "ui/app_list/app_list_model.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 menu_button_ = new views::MenuButton(NULL, base::string16(), this, false); | 57 menu_button_ = new views::MenuButton(NULL, base::string16(), this, false); |
58 menu_button_->set_border(NULL); | 58 menu_button_->set_border(NULL); |
59 menu_button_->SetIcon(*rb.GetImageSkiaNamed(IDR_APP_LIST_TOOLS_NORMAL)); | 59 menu_button_->SetIcon(*rb.GetImageSkiaNamed(IDR_APP_LIST_TOOLS_NORMAL)); |
60 menu_button_->SetHoverIcon(*rb.GetImageSkiaNamed(IDR_APP_LIST_TOOLS_HOVER)); | 60 menu_button_->SetHoverIcon(*rb.GetImageSkiaNamed(IDR_APP_LIST_TOOLS_HOVER)); |
61 menu_button_->SetPushedIcon(*rb.GetImageSkiaNamed( | 61 menu_button_->SetPushedIcon(*rb.GetImageSkiaNamed( |
62 IDR_APP_LIST_TOOLS_PRESSED)); | 62 IDR_APP_LIST_TOOLS_PRESSED)); |
63 AddChildView(menu_button_); | 63 AddChildView(menu_button_); |
64 #endif | 64 #endif |
65 | 65 |
66 search_box_->RemoveBorder(); | 66 search_box_->RemoveBorder(); |
67 search_box_->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont)); | 67 search_box_->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); |
68 search_box_->set_placeholder_text_color(kHintTextColor); | 68 search_box_->set_placeholder_text_color(kHintTextColor); |
69 search_box_->SetController(this); | 69 search_box_->SetController(this); |
70 AddChildView(search_box_); | 70 AddChildView(search_box_); |
71 | 71 |
72 ModelChanged(); | 72 ModelChanged(); |
73 } | 73 } |
74 | 74 |
75 SearchBoxView::~SearchBoxView() { | 75 SearchBoxView::~SearchBoxView() { |
76 model_->search_box()->RemoveObserver(this); | 76 model_->search_box()->RemoveObserver(this); |
77 } | 77 } |
78 | 78 |
79 void SearchBoxView::ModelChanged() { | 79 void SearchBoxView::ModelChanged() { |
80 if (model_) | 80 if (model_) |
81 model_->search_box()->RemoveObserver(this); | 81 model_->search_box()->RemoveObserver(this); |
82 | 82 |
83 model_ = view_delegate_->GetModel(); | 83 model_ = view_delegate_->GetModel(); |
84 DCHECK(model_); | 84 DCHECK(model_); |
85 model_->search_box()->AddObserver(this); | 85 model_->search_box()->AddObserver(this); |
86 IconChanged(); | 86 IconChanged(); |
87 SpeechRecognitionButtonPropChanged(); | 87 SpeechRecognitionButtonPropChanged(); |
88 HintTextChanged(); | 88 HintTextChanged(); |
89 } | 89 } |
90 | 90 |
91 bool SearchBoxView::HasSearch() const { | 91 bool SearchBoxView::HasSearch() const { |
92 return !search_box_->text().empty(); | 92 return !search_box_->GetText().empty(); |
93 } | 93 } |
94 | 94 |
95 void SearchBoxView::ClearSearch() { | 95 void SearchBoxView::ClearSearch() { |
96 search_box_->SetText(base::string16()); | 96 search_box_->SetText(base::string16()); |
97 // Updates model and fires query changed manually because SetText() above | 97 // Updates model and fires query changed manually because SetText() above |
98 // does not generate ContentsChanged() notification. | 98 // does not generate ContentsChanged() notification. |
99 UpdateModel(); | 99 UpdateModel(); |
100 NotifyQueryChanged(); | 100 NotifyQueryChanged(); |
101 } | 101 } |
102 | 102 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 bool SearchBoxView::OnMouseWheel(const ui::MouseWheelEvent& event) { | 155 bool SearchBoxView::OnMouseWheel(const ui::MouseWheelEvent& event) { |
156 if (contents_view_) | 156 if (contents_view_) |
157 return contents_view_->OnMouseWheel(event); | 157 return contents_view_->OnMouseWheel(event); |
158 | 158 |
159 return false; | 159 return false; |
160 } | 160 } |
161 | 161 |
162 void SearchBoxView::UpdateModel() { | 162 void SearchBoxView::UpdateModel() { |
163 // Temporarily remove from observer to ignore notifications caused by us. | 163 // Temporarily remove from observer to ignore notifications caused by us. |
164 model_->search_box()->RemoveObserver(this); | 164 model_->search_box()->RemoveObserver(this); |
165 model_->search_box()->SetText(search_box_->text()); | 165 model_->search_box()->SetText(search_box_->GetText()); |
166 model_->search_box()->SetSelectionModel(search_box_->GetSelectionModel()); | 166 model_->search_box()->SetSelectionModel(search_box_->GetSelectionModel()); |
167 model_->search_box()->AddObserver(this); | 167 model_->search_box()->AddObserver(this); |
168 } | 168 } |
169 | 169 |
170 void SearchBoxView::NotifyQueryChanged() { | 170 void SearchBoxView::NotifyQueryChanged() { |
171 DCHECK(delegate_); | 171 DCHECK(delegate_); |
172 delegate_->QueryChanged(this); | 172 delegate_->QueryChanged(this); |
173 } | 173 } |
174 | 174 |
175 void SearchBoxView::ContentsChanged(views::Textfield* sender, | 175 void SearchBoxView::ContentsChanged(views::Textfield* sender, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 void SearchBoxView::SelectionModelChanged() { | 234 void SearchBoxView::SelectionModelChanged() { |
235 search_box_->SelectSelectionModel(model_->search_box()->selection_model()); | 235 search_box_->SelectSelectionModel(model_->search_box()->selection_model()); |
236 } | 236 } |
237 | 237 |
238 void SearchBoxView::TextChanged() { | 238 void SearchBoxView::TextChanged() { |
239 search_box_->SetText(model_->search_box()->text()); | 239 search_box_->SetText(model_->search_box()->text()); |
240 NotifyQueryChanged(); | 240 NotifyQueryChanged(); |
241 } | 241 } |
242 | 242 |
243 } // namespace app_list | 243 } // namespace app_list |
OLD | NEW |