| 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 menu_button_->GetBoundsInScreen().bottom_right() + | 194 menu_button_->GetBoundsInScreen().bottom_right() + |
| 195 gfx::Vector2d(kMenuXOffsetFromButton, kMenuYOffsetFromButton); | 195 gfx::Vector2d(kMenuXOffsetFromButton, kMenuYOffsetFromButton); |
| 196 menu_->RunMenuAt(menu_button_, menu_location); | 196 menu_->RunMenuAt(menu_button_, menu_location); |
| 197 } | 197 } |
| 198 | 198 |
| 199 void SearchBoxView::IconChanged() { | 199 void SearchBoxView::IconChanged() { |
| 200 icon_view_->SetImage(model_->search_box()->icon()); | 200 icon_view_->SetImage(model_->search_box()->icon()); |
| 201 } | 201 } |
| 202 | 202 |
| 203 void SearchBoxView::SpeechRecognitionButtonPropChanged() { | 203 void SearchBoxView::SpeechRecognitionButtonPropChanged() { |
| 204 const SearchBoxModel::ToggleButtonProperty* speech_button_prop = | 204 const SearchBoxModel::ButtonProperty* speech_button_prop = |
| 205 model_->search_box()->speech_button(); | 205 model_->search_box()->speech_button(); |
| 206 if (speech_button_prop) { | 206 if (speech_button_prop) { |
| 207 if (!speech_button_) { | 207 if (!speech_button_) { |
| 208 speech_button_ = new views::ToggleImageButton(this); | 208 speech_button_ = new views::ImageButton(this); |
| 209 AddChildView(speech_button_); | 209 AddChildView(speech_button_); |
| 210 } | 210 } |
| 211 speech_button_->SetImage(views::Button::STATE_NORMAL, | 211 speech_button_->SetImage(views::Button::STATE_NORMAL, |
| 212 &speech_button_prop->icon); | 212 &speech_button_prop->icon); |
| 213 speech_button_->SetToggledImage(views::Button::STATE_NORMAL, | |
| 214 &speech_button_prop->toggled_icon); | |
| 215 speech_button_->SetTooltipText(speech_button_prop->tooltip); | 213 speech_button_->SetTooltipText(speech_button_prop->tooltip); |
| 216 speech_button_->SetToggledTooltipText(speech_button_prop->toggled_tooltip); | |
| 217 } else { | 214 } else { |
| 218 if (speech_button_) { | 215 if (speech_button_) { |
| 219 // Deleting a view will detach it from its parent. | 216 // Deleting a view will detach it from its parent. |
| 220 delete speech_button_; | 217 delete speech_button_; |
| 221 speech_button_ = NULL; | 218 speech_button_ = NULL; |
| 222 } | 219 } |
| 223 } | 220 } |
| 224 } | 221 } |
| 225 | 222 |
| 226 void SearchBoxView::SetSpeechRecognitionButtonState(bool toggled) { | |
| 227 if (speech_button_) | |
| 228 speech_button_->SetToggled(toggled); | |
| 229 } | |
| 230 | |
| 231 void SearchBoxView::HintTextChanged() { | 223 void SearchBoxView::HintTextChanged() { |
| 232 search_box_->set_placeholder_text(model_->search_box()->hint_text()); | 224 search_box_->set_placeholder_text(model_->search_box()->hint_text()); |
| 233 } | 225 } |
| 234 | 226 |
| 235 void SearchBoxView::SelectionModelChanged() { | 227 void SearchBoxView::SelectionModelChanged() { |
| 236 search_box_->SelectSelectionModel(model_->search_box()->selection_model()); | 228 search_box_->SelectSelectionModel(model_->search_box()->selection_model()); |
| 237 } | 229 } |
| 238 | 230 |
| 239 void SearchBoxView::TextChanged() { | 231 void SearchBoxView::TextChanged() { |
| 240 search_box_->SetText(model_->search_box()->text()); | 232 search_box_->SetText(model_->search_box()->text()); |
| 241 NotifyQueryChanged(); | 233 NotifyQueryChanged(); |
| 242 } | 234 } |
| 243 | 235 |
| 244 } // namespace app_list | 236 } // namespace app_list |
| OLD | NEW |