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

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

Issue 2939693004: Added HALF, FULLSCREEN_ALL_APPS, and FULLSCREEN_SEARCH. (Closed)
Patch Set: Rebased. Created 3 years, 6 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
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 const int kInnerPadding = 24; 46 const int kInnerPadding = 24;
47 const int kPreferredWidth = 360; 47 const int kPreferredWidth = 360;
48 const int kPreferredWidthFullscreen = 544; 48 const int kPreferredWidthFullscreen = 544;
49 const int kPreferredHeight = 48; 49 const int kPreferredHeight = 48;
50 50
51 const SkColor kHintTextColor = SkColorSetRGB(0xA0, 0xA0, 0xA0); 51 const SkColor kHintTextColor = SkColorSetRGB(0xA0, 0xA0, 0xA0);
52 52
53 const int kBackgroundBorderCornerRadius = 2; 53 const int kBackgroundBorderCornerRadius = 2;
54 const int kBackgroundBorderCornerRadiusFullscreen = 20; 54 const int kBackgroundBorderCornerRadiusFullscreen = 20;
55 55
56 bool IsFullscreenAppListEnabled() {
57 // Cache this value to avoid repeated lookup.
58 static bool cached_value = features::IsFullscreenAppListEnabled();
59 return cached_value;
60 }
61
62 // A background that paints a solid white rounded rect with a thin grey border. 56 // A background that paints a solid white rounded rect with a thin grey border.
63 class SearchBoxBackground : public views::Background { 57 class SearchBoxBackground : public views::Background {
64 public: 58 public:
65 SearchBoxBackground() 59 SearchBoxBackground()
66 : background_border_corner_radius_( 60 : background_border_corner_radius_(
67 IsFullscreenAppListEnabled() 61 features::IsFullscreenAppListEnabled()
68 ? kBackgroundBorderCornerRadiusFullscreen 62 ? kBackgroundBorderCornerRadiusFullscreen
69 : kBackgroundBorderCornerRadius) {} 63 : kBackgroundBorderCornerRadius) {}
70 ~SearchBoxBackground() override {} 64 ~SearchBoxBackground() override {}
71 65
72 private: 66 private:
73 // views::Background overrides: 67 // views::Background overrides:
74 void Paint(gfx::Canvas* canvas, views::View* view) const override { 68 void Paint(gfx::Canvas* canvas, views::View* view) const override {
75 gfx::Rect bounds = view->GetContentsBounds(); 69 gfx::Rect bounds = view->GetContentsBounds();
76 70
77 cc::PaintFlags flags; 71 cc::PaintFlags flags;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 AppListView* app_list_view) 129 AppListView* app_list_view)
136 : delegate_(delegate), 130 : delegate_(delegate),
137 view_delegate_(view_delegate), 131 view_delegate_(view_delegate),
138 model_(NULL), 132 model_(NULL),
139 content_container_(new views::View), 133 content_container_(new views::View),
140 back_button_(NULL), 134 back_button_(NULL),
141 speech_button_(NULL), 135 speech_button_(NULL),
142 search_box_(new views::Textfield), 136 search_box_(new views::Textfield),
143 contents_view_(NULL), 137 contents_view_(NULL),
144 app_list_view_(app_list_view), 138 app_list_view_(app_list_view),
145 focused_view_(FOCUS_SEARCH_BOX) { 139 focused_view_(FOCUS_SEARCH_BOX),
140 is_fullscreen_app_list_enabled_(features::IsFullscreenAppListEnabled()) {
146 SetLayoutManager(new views::FillLayout); 141 SetLayoutManager(new views::FillLayout);
147 SetPreferredSize(gfx::Size(IsFullscreenAppListEnabled() 142 SetPreferredSize(gfx::Size(is_fullscreen_app_list_enabled_
148 ? kPreferredWidthFullscreen 143 ? kPreferredWidthFullscreen
149 : kPreferredWidth, 144 : kPreferredWidth,
150 kPreferredHeight)); 145 kPreferredHeight));
151 AddChildView(content_container_); 146 AddChildView(content_container_);
152 147
153 SetShadow(GetShadowForZHeight(2)); 148 SetShadow(GetShadowForZHeight(2));
154 back_button_ = new SearchBoxImageButton(this); 149 back_button_ = new SearchBoxImageButton(this);
155 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 150 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
156 back_button_->SetImage(views::ImageButton::STATE_NORMAL, 151 back_button_->SetImage(views::ImageButton::STATE_NORMAL,
157 rb.GetImageSkiaNamed(IDR_APP_LIST_FOLDER_BACK_NORMAL)); 152 rb.GetImageSkiaNamed(IDR_APP_LIST_FOLDER_BACK_NORMAL));
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 void SearchBoxView::NotifyQueryChanged() { 333 void SearchBoxView::NotifyQueryChanged() {
339 DCHECK(delegate_); 334 DCHECK(delegate_);
340 delegate_->QueryChanged(this); 335 delegate_->QueryChanged(this);
341 } 336 }
342 337
343 void SearchBoxView::ContentsChanged(views::Textfield* sender, 338 void SearchBoxView::ContentsChanged(views::Textfield* sender,
344 const base::string16& new_contents) { 339 const base::string16& new_contents) {
345 UpdateModel(); 340 UpdateModel();
346 view_delegate_->AutoLaunchCanceled(); 341 view_delegate_->AutoLaunchCanceled();
347 NotifyQueryChanged(); 342 NotifyQueryChanged();
348 343 if (is_fullscreen_app_list_enabled_)
349 if (IsFullscreenAppListEnabled() && !app_list_view_->is_fullscreen()) { 344 app_list_view_->SetStateFromSearchBoxView(search_box_->text().empty());
350 // If the app list is in the peeking state, switch it to fullscreen.
351 app_list_view_->SetState(AppListView::FULLSCREEN);
352 }
353 } 345 }
354 346
355 bool SearchBoxView::HandleKeyEvent(views::Textfield* sender, 347 bool SearchBoxView::HandleKeyEvent(views::Textfield* sender,
356 const ui::KeyEvent& key_event) { 348 const ui::KeyEvent& key_event) {
357 if (key_event.type() == ui::ET_KEY_PRESSED) { 349 if (key_event.type() == ui::ET_KEY_PRESSED) {
358 if (key_event.key_code() == ui::VKEY_TAB && 350 if (key_event.key_code() == ui::VKEY_TAB &&
359 focused_view_ != FOCUS_CONTENTS_VIEW && 351 focused_view_ != FOCUS_CONTENTS_VIEW &&
360 MoveTabFocus(key_event.IsShiftDown())) 352 MoveTabFocus(key_event.IsShiftDown()))
361 return true; 353 return true;
362 354
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 NotifyQueryChanged(); 450 NotifyQueryChanged();
459 } 451 }
460 452
461 void SearchBoxView::OnSpeechRecognitionStateChanged( 453 void SearchBoxView::OnSpeechRecognitionStateChanged(
462 SpeechRecognitionState new_state) { 454 SpeechRecognitionState new_state) {
463 SpeechRecognitionButtonPropChanged(); 455 SpeechRecognitionButtonPropChanged();
464 SchedulePaint(); 456 SchedulePaint();
465 } 457 }
466 458
467 } // namespace app_list 459 } // namespace app_list
OLDNEW
« ui/app_list/views/app_list_view.cc ('K') | « 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