Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: ui/app_list/views/search_box_view.cc

Issue 2951903004: Added back button when in folder view. (Closed)
Patch Set: Addressed comments and cached the feature flag. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/app_list/views/search_box_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 layout->set_cross_axis_alignment( 165 layout->set_cross_axis_alignment(
166 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); 166 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER);
167 layout->set_minimum_cross_axis_size(kPreferredHeight); 167 layout->set_minimum_cross_axis_size(kPreferredHeight);
168 168
169 search_box_->SetBorder(views::NullBorder()); 169 search_box_->SetBorder(views::NullBorder());
170 search_box_->SetTextColor(kSearchTextColor); 170 search_box_->SetTextColor(kSearchTextColor);
171 search_box_->SetBackgroundColor(kSearchBoxBackgroundDefault); 171 search_box_->SetBackgroundColor(kSearchBoxBackgroundDefault);
172 search_box_->set_controller(this); 172 search_box_->set_controller(this);
173 search_box_->SetTextInputType(ui::TEXT_INPUT_TYPE_SEARCH); 173 search_box_->SetTextInputType(ui::TEXT_INPUT_TYPE_SEARCH);
174 search_box_->SetTextInputFlags(ui::TEXT_INPUT_FLAG_AUTOCORRECT_OFF); 174 search_box_->SetTextInputFlags(ui::TEXT_INPUT_FLAG_AUTOCORRECT_OFF);
175 back_button_ = new SearchBoxImageButton(this);
176 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
177 back_button_->SetImage(views::ImageButton::STATE_NORMAL,
178 rb.GetImageSkiaNamed(IDR_APP_LIST_FOLDER_BACK_NORMAL));
179 back_button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER,
180 views::ImageButton::ALIGN_MIDDLE);
181 SetBackButtonLabel(false);
182 content_container_->AddChildView(back_button_);
183
175 if (is_fullscreen_app_list_enabled_) { 184 if (is_fullscreen_app_list_enabled_) {
176 google_icon_ = new views::ImageView(); 185 google_icon_ = new views::ImageView();
177 google_icon_->SetImage(gfx::CreateVectorIcon( 186 google_icon_->SetImage(gfx::CreateVectorIcon(
178 kIcGoogleBlackIcon, kGoogleIconSize, kDefaultSearchboxColor)); 187 kIcGoogleBlackIcon, kGoogleIconSize, kDefaultSearchboxColor));
179 content_container_->AddChildView(google_icon_); 188 content_container_->AddChildView(google_icon_);
180 189
181 search_box_->set_placeholder_text_color(kDefaultSearchboxColor); 190 search_box_->set_placeholder_text_color(kDefaultSearchboxColor);
182 search_box_->set_placeholder_text_draw_flags( 191 search_box_->set_placeholder_text_draw_flags(
183 gfx::Canvas::TEXT_ALIGN_CENTER); 192 gfx::Canvas::TEXT_ALIGN_CENTER);
184 search_box_->SetFontList(search_box_->GetFontList().DeriveWithSizeDelta(2)); 193 search_box_->SetFontList(search_box_->GetFontList().DeriveWithSizeDelta(2));
194 back_button_->SetVisible(false);
185 } else { 195 } 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_);
195
196 search_box_->set_placeholder_text_color(kHintTextColor); 196 search_box_->set_placeholder_text_color(kHintTextColor);
197 } 197 }
198 content_container_->AddChildView(search_box_); 198 content_container_->AddChildView(search_box_);
199 layout->SetFlexForView(search_box_, 1); 199 layout->SetFlexForView(search_box_, 1);
200 200
201 view_delegate_->GetSpeechUI()->AddObserver(this); 201 view_delegate_->GetSpeechUI()->AddObserver(this);
202 ModelChanged(); 202 ModelChanged();
203 } 203 }
204 204
205 SearchBoxView::~SearchBoxView() { 205 SearchBoxView::~SearchBoxView() {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 if (!back_button_) 325 if (!back_button_)
326 return; 326 return;
327 327
328 base::string16 back_button_label(l10n_util::GetStringUTF16( 328 base::string16 back_button_label(l10n_util::GetStringUTF16(
329 folder ? IDS_APP_LIST_FOLDER_CLOSE_FOLDER_ACCESSIBILE_NAME 329 folder ? IDS_APP_LIST_FOLDER_CLOSE_FOLDER_ACCESSIBILE_NAME
330 : IDS_APP_LIST_BACK)); 330 : IDS_APP_LIST_BACK));
331 back_button_->SetAccessibleName(back_button_label); 331 back_button_->SetAccessibleName(back_button_label);
332 back_button_->SetTooltipText(back_button_label); 332 back_button_->SetTooltipText(back_button_label);
333 } 333 }
334 334
335 void SearchBoxView::ShowBackOrGoogleIcon(bool show_back_button) {
336 if (!is_fullscreen_app_list_enabled_)
337 return;
338
339 google_icon_->SetVisible(!show_back_button);
340 back_button_->SetVisible(show_back_button);
341 content_container_->Layout();
342 }
343
335 bool SearchBoxView::OnMouseWheel(const ui::MouseWheelEvent& event) { 344 bool SearchBoxView::OnMouseWheel(const ui::MouseWheelEvent& event) {
336 if (contents_view_) 345 if (contents_view_)
337 return contents_view_->OnMouseWheel(event); 346 return contents_view_->OnMouseWheel(event);
338 347
339 return false; 348 return false;
340 } 349 }
341 350
342 void SearchBoxView::OnEnabledChanged() { 351 void SearchBoxView::OnEnabledChanged() {
343 search_box_->SetEnabled(enabled()); 352 search_box_->SetEnabled(enabled());
344 if (speech_button_) 353 if (speech_button_)
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 NotifyQueryChanged(); 498 NotifyQueryChanged();
490 } 499 }
491 500
492 void SearchBoxView::OnSpeechRecognitionStateChanged( 501 void SearchBoxView::OnSpeechRecognitionStateChanged(
493 SpeechRecognitionState new_state) { 502 SpeechRecognitionState new_state) {
494 SpeechRecognitionButtonPropChanged(); 503 SpeechRecognitionButtonPropChanged();
495 SchedulePaint(); 504 SchedulePaint();
496 } 505 }
497 506
498 } // namespace app_list 507 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/search_box_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698