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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 if (is_fullscreen_app_list_enabled_) { | 175 if (is_fullscreen_app_list_enabled_) { |
176 google_icon_ = new views::ImageView(); | 176 google_icon_ = new views::ImageView(); |
177 google_icon_->SetImage(gfx::CreateVectorIcon( | 177 google_icon_->SetImage(gfx::CreateVectorIcon( |
178 kIcGoogleBlackIcon, kGoogleIconSize, kDefaultSearchboxColor)); | 178 kIcGoogleBlackIcon, kGoogleIconSize, kDefaultSearchboxColor)); |
179 content_container_->AddChildView(google_icon_); | 179 content_container_->AddChildView(google_icon_); |
180 | 180 |
181 search_box_->set_placeholder_text_color(kDefaultSearchboxColor); | 181 search_box_->set_placeholder_text_color(kDefaultSearchboxColor); |
182 search_box_->set_placeholder_text_draw_flags( | 182 search_box_->set_placeholder_text_draw_flags( |
183 gfx::Canvas::TEXT_ALIGN_CENTER); | 183 gfx::Canvas::TEXT_ALIGN_CENTER); |
184 search_box_->SetFontList(search_box_->GetFontList().DeriveWithSizeDelta(2)); | 184 search_box_->SetFontList(search_box_->GetFontList().DeriveWithSizeDelta(2)); |
185 } | |
186 back_button_ = new SearchBoxImageButton(this); | |
187 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
188 back_button_->SetImage(views::ImageButton::STATE_NORMAL, | |
189 rb.GetImageSkiaNamed(IDR_APP_LIST_FOLDER_BACK_NORMAL)); | |
190 back_button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, | |
191 views::ImageButton::ALIGN_MIDDLE); | |
192 SetBackButtonLabel(false); | |
193 | |
194 if (is_fullscreen_app_list_enabled_) { | |
195 content_container_->AddChildView(google_icon_); | |
185 } else { | 196 } else { |
186 back_button_ = new SearchBoxImageButton(this); | |
187 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
188 back_button_->SetImage( | |
189 views::ImageButton::STATE_NORMAL, | |
190 rb.GetImageSkiaNamed(IDR_APP_LIST_FOLDER_BACK_NORMAL)); | |
191 back_button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, | |
192 views::ImageButton::ALIGN_MIDDLE); | |
193 SetBackButtonLabel(false); | |
194 content_container_->AddChildView(back_button_); | 197 content_container_->AddChildView(back_button_); |
195 | |
196 search_box_->set_placeholder_text_color(kHintTextColor); | 198 search_box_->set_placeholder_text_color(kHintTextColor); |
197 } | 199 } |
198 content_container_->AddChildView(search_box_); | 200 content_container_->AddChildView(search_box_); |
199 layout->SetFlexForView(search_box_, 1); | 201 layout->SetFlexForView(search_box_, 1); |
200 | 202 |
201 view_delegate_->GetSpeechUI()->AddObserver(this); | 203 view_delegate_->GetSpeechUI()->AddObserver(this); |
202 ModelChanged(); | 204 ModelChanged(); |
203 } | 205 } |
204 | 206 |
205 SearchBoxView::~SearchBoxView() { | 207 SearchBoxView::~SearchBoxView() { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
325 if (!back_button_) | 327 if (!back_button_) |
326 return; | 328 return; |
327 | 329 |
328 base::string16 back_button_label(l10n_util::GetStringUTF16( | 330 base::string16 back_button_label(l10n_util::GetStringUTF16( |
329 folder ? IDS_APP_LIST_FOLDER_CLOSE_FOLDER_ACCESSIBILE_NAME | 331 folder ? IDS_APP_LIST_FOLDER_CLOSE_FOLDER_ACCESSIBILE_NAME |
330 : IDS_APP_LIST_BACK)); | 332 : IDS_APP_LIST_BACK)); |
331 back_button_->SetAccessibleName(back_button_label); | 333 back_button_->SetAccessibleName(back_button_label); |
332 back_button_->SetTooltipText(back_button_label); | 334 back_button_->SetTooltipText(back_button_label); |
333 } | 335 } |
334 | 336 |
337 void SearchBoxView::SwapGoogleIconWithBackButton(bool show_back_button) { | |
vadimt
2017/06/22 00:36:12
"ShowBackOrGoogleIcon"
BTW, do we show Google ico
newcomer
2017/06/22 16:49:07
Done, and I opened a dialogue with our pm/ux crew.
| |
338 if (!is_fullscreen_app_list_enabled_) | |
339 return; | |
340 | |
341 if (show_back_button) { | |
342 content_container_->AddChildViewAt( | |
343 back_button_, content_container_->GetIndexOf(google_icon_)); | |
344 content_container_->RemoveChildView(google_icon_); | |
345 } else { | |
346 content_container_->AddChildViewAt( | |
347 google_icon_, content_container_->GetIndexOf(back_button_)); | |
348 content_container_->RemoveChildView(back_button_); | |
349 } | |
350 content_container_->Layout(); | |
351 } | |
352 | |
335 bool SearchBoxView::OnMouseWheel(const ui::MouseWheelEvent& event) { | 353 bool SearchBoxView::OnMouseWheel(const ui::MouseWheelEvent& event) { |
336 if (contents_view_) | 354 if (contents_view_) |
337 return contents_view_->OnMouseWheel(event); | 355 return contents_view_->OnMouseWheel(event); |
338 | 356 |
339 return false; | 357 return false; |
340 } | 358 } |
341 | 359 |
342 void SearchBoxView::OnEnabledChanged() { | 360 void SearchBoxView::OnEnabledChanged() { |
343 search_box_->SetEnabled(enabled()); | 361 search_box_->SetEnabled(enabled()); |
344 if (speech_button_) | 362 if (speech_button_) |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
489 NotifyQueryChanged(); | 507 NotifyQueryChanged(); |
490 } | 508 } |
491 | 509 |
492 void SearchBoxView::OnSpeechRecognitionStateChanged( | 510 void SearchBoxView::OnSpeechRecognitionStateChanged( |
493 SpeechRecognitionState new_state) { | 511 SpeechRecognitionState new_state) { |
494 SpeechRecognitionButtonPropChanged(); | 512 SpeechRecognitionButtonPropChanged(); |
495 SchedulePaint(); | 513 SchedulePaint(); |
496 } | 514 } |
497 | 515 |
498 } // namespace app_list | 516 } // namespace app_list |
OLD | NEW |