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

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

Issue 2951903004: Added back button when in folder view. (Closed)
Patch Set: Added back button when in folder view. 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 content_container_->AddChildView(back_button_);
194 if (is_fullscreen_app_list_enabled_) {
195 content_container_->AddChildView(google_icon_);
196 content_container_->child_at(content_container_->GetIndexOf(back_button_))
197 ->SetVisible(false);
185 } else { 198 } 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); 199 search_box_->set_placeholder_text_color(kHintTextColor);
197 } 200 }
198 content_container_->AddChildView(search_box_); 201 content_container_->AddChildView(search_box_);
199 layout->SetFlexForView(search_box_, 1); 202 layout->SetFlexForView(search_box_, 1);
200 203
201 view_delegate_->GetSpeechUI()->AddObserver(this); 204 view_delegate_->GetSpeechUI()->AddObserver(this);
202 ModelChanged(); 205 ModelChanged();
203 } 206 }
204 207
205 SearchBoxView::~SearchBoxView() { 208 SearchBoxView::~SearchBoxView() {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 if (!back_button_) 328 if (!back_button_)
326 return; 329 return;
327 330
328 base::string16 back_button_label(l10n_util::GetStringUTF16( 331 base::string16 back_button_label(l10n_util::GetStringUTF16(
329 folder ? IDS_APP_LIST_FOLDER_CLOSE_FOLDER_ACCESSIBILE_NAME 332 folder ? IDS_APP_LIST_FOLDER_CLOSE_FOLDER_ACCESSIBILE_NAME
330 : IDS_APP_LIST_BACK)); 333 : IDS_APP_LIST_BACK));
331 back_button_->SetAccessibleName(back_button_label); 334 back_button_->SetAccessibleName(back_button_label);
332 back_button_->SetTooltipText(back_button_label); 335 back_button_->SetTooltipText(back_button_label);
333 } 336 }
334 337
338 void SearchBoxView::ShowBackOrGoogleIcon(bool show_back_button) {
339 if (!is_fullscreen_app_list_enabled_)
340 return;
341
342 int google_icon_index = content_container_->GetIndexOf(google_icon_);
vadimt 2017/06/24 00:16:26 Converting to index and back to view.
newcomer 2017/06/24 00:50:05 Acknowledged.
343 int back_button_index = content_container_->GetIndexOf(back_button_);
344 content_container_->child_at(google_icon_index)
345 ->SetVisible(show_back_button ? false : true);
vadimt 2017/06/24 00:16:26 !show_back_button
newcomer 2017/06/24 00:50:05 Done.
346 content_container_->child_at(back_button_index)
347 ->SetVisible(show_back_button ? true : false);
vadimt 2017/06/24 00:16:26 show_back_button ? true : false => show_back_butto
newcomer 2017/06/24 00:50:05 Done.
348 content_container_->Layout();
349 }
350
335 bool SearchBoxView::OnMouseWheel(const ui::MouseWheelEvent& event) { 351 bool SearchBoxView::OnMouseWheel(const ui::MouseWheelEvent& event) {
336 if (contents_view_) 352 if (contents_view_)
337 return contents_view_->OnMouseWheel(event); 353 return contents_view_->OnMouseWheel(event);
338 354
339 return false; 355 return false;
340 } 356 }
341 357
342 void SearchBoxView::OnEnabledChanged() { 358 void SearchBoxView::OnEnabledChanged() {
343 search_box_->SetEnabled(enabled()); 359 search_box_->SetEnabled(enabled());
344 if (speech_button_) 360 if (speech_button_)
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 NotifyQueryChanged(); 505 NotifyQueryChanged();
490 } 506 }
491 507
492 void SearchBoxView::OnSpeechRecognitionStateChanged( 508 void SearchBoxView::OnSpeechRecognitionStateChanged(
493 SpeechRecognitionState new_state) { 509 SpeechRecognitionState new_state) {
494 SpeechRecognitionButtonPropChanged(); 510 SpeechRecognitionButtonPropChanged();
495 SchedulePaint(); 511 SchedulePaint();
496 } 512 }
497 513
498 } // namespace app_list 514 } // 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