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

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

Issue 390273002: Experimental app list banner now appears on top of launcher pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't show banner if not experimental. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « ui/app_list/views/app_list_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/app_list_view.h" 5 #include "ui/app_list/views/app_list_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/win/windows_version.h" 11 #include "base/win/windows_version.h"
12 #include "grit/ui_resources.h"
12 #include "ui/app_list/app_list_constants.h" 13 #include "ui/app_list/app_list_constants.h"
13 #include "ui/app_list/app_list_model.h" 14 #include "ui/app_list/app_list_model.h"
14 #include "ui/app_list/app_list_switches.h" 15 #include "ui/app_list/app_list_switches.h"
15 #include "ui/app_list/app_list_view_delegate.h" 16 #include "ui/app_list/app_list_view_delegate.h"
16 #include "ui/app_list/speech_ui_model.h" 17 #include "ui/app_list/speech_ui_model.h"
17 #include "ui/app_list/views/app_list_background.h" 18 #include "ui/app_list/views/app_list_background.h"
18 #include "ui/app_list/views/app_list_folder_view.h" 19 #include "ui/app_list/views/app_list_folder_view.h"
19 #include "ui/app_list/views/app_list_main_view.h" 20 #include "ui/app_list/views/app_list_main_view.h"
20 #include "ui/app_list/views/app_list_view_observer.h" 21 #include "ui/app_list/views/app_list_view_observer.h"
21 #include "ui/app_list/views/apps_container_view.h" 22 #include "ui/app_list/views/apps_container_view.h"
22 #include "ui/app_list/views/contents_view.h" 23 #include "ui/app_list/views/contents_view.h"
23 #include "ui/app_list/views/search_box_view.h" 24 #include "ui/app_list/views/search_box_view.h"
24 #include "ui/app_list/views/speech_view.h" 25 #include "ui/app_list/views/speech_view.h"
25 #include "ui/app_list/views/start_page_view.h" 26 #include "ui/app_list/views/start_page_view.h"
26 #include "ui/base/ui_base_switches.h" 27 #include "ui/base/ui_base_switches.h"
27 #include "ui/compositor/layer.h" 28 #include "ui/compositor/layer.h"
28 #include "ui/compositor/layer_animation_observer.h" 29 #include "ui/compositor/layer_animation_observer.h"
29 #include "ui/compositor/scoped_layer_animation_settings.h" 30 #include "ui/compositor/scoped_layer_animation_settings.h"
30 #include "ui/gfx/canvas.h" 31 #include "ui/gfx/canvas.h"
31 #include "ui/gfx/image/image_skia.h" 32 #include "ui/gfx/image/image_skia.h"
32 #include "ui/gfx/insets.h" 33 #include "ui/gfx/insets.h"
33 #include "ui/gfx/path.h" 34 #include "ui/gfx/path.h"
34 #include "ui/gfx/skia_util.h" 35 #include "ui/gfx/skia_util.h"
35 #include "ui/views/bubble/bubble_frame_view.h" 36 #include "ui/views/bubble/bubble_frame_view.h"
37 #include "ui/views/controls/image_view.h"
36 #include "ui/views/controls/textfield/textfield.h" 38 #include "ui/views/controls/textfield/textfield.h"
37 #include "ui/views/layout/fill_layout.h" 39 #include "ui/views/layout/fill_layout.h"
38 #include "ui/views/widget/widget.h" 40 #include "ui/views/widget/widget.h"
39 41
40 #if defined(USE_AURA) 42 #if defined(USE_AURA)
41 #include "ui/aura/window.h" 43 #include "ui/aura/window.h"
42 #include "ui/aura/window_tree_host.h" 44 #include "ui/aura/window_tree_host.h"
43 #include "ui/views/bubble/bubble_window_targeter.h" 45 #include "ui/views/bubble/bubble_window_targeter.h"
44 #if defined(OS_WIN) 46 #if defined(OS_WIN)
45 #include "ui/base/win/shell.h" 47 #include "ui/base/win/shell.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 DISALLOW_COPY_AND_ASSIGN(HideViewAnimationObserver); 143 DISALLOW_COPY_AND_ASSIGN(HideViewAnimationObserver);
142 }; 144 };
143 145
144 //////////////////////////////////////////////////////////////////////////////// 146 ////////////////////////////////////////////////////////////////////////////////
145 // AppListView: 147 // AppListView:
146 148
147 AppListView::AppListView(AppListViewDelegate* delegate) 149 AppListView::AppListView(AppListViewDelegate* delegate)
148 : delegate_(delegate), 150 : delegate_(delegate),
149 app_list_main_view_(NULL), 151 app_list_main_view_(NULL),
150 speech_view_(NULL), 152 speech_view_(NULL),
153 experimental_banner_view_(NULL),
151 overlay_view_(NULL), 154 overlay_view_(NULL),
152 animation_observer_(new HideViewAnimationObserver()) { 155 animation_observer_(new HideViewAnimationObserver()) {
153 CHECK(delegate); 156 CHECK(delegate);
154 157
155 delegate_->AddObserver(this); 158 delegate_->AddObserver(this);
156 delegate_->GetSpeechUI()->AddObserver(this); 159 delegate_->GetSpeechUI()->AddObserver(this);
157 } 160 }
158 161
159 AppListView::~AppListView() { 162 AppListView::~AppListView() {
160 delegate_->GetSpeechUI()->RemoveObserver(this); 163 delegate_->GetSpeechUI()->RemoveObserver(this);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 // Speech recognition is available only when the start page exists. 306 // Speech recognition is available only when the start page exists.
304 if (delegate_ && delegate_->IsSpeechRecognitionEnabled()) { 307 if (delegate_ && delegate_->IsSpeechRecognitionEnabled()) {
305 speech_view_ = new SpeechView(delegate_.get()); 308 speech_view_ = new SpeechView(delegate_.get());
306 speech_view_->SetVisible(false); 309 speech_view_->SetVisible(false);
307 speech_view_->SetPaintToLayer(true); 310 speech_view_->SetPaintToLayer(true);
308 speech_view_->SetFillsBoundsOpaquely(false); 311 speech_view_->SetFillsBoundsOpaquely(false);
309 speech_view_->layer()->SetOpacity(0.0f); 312 speech_view_->layer()->SetOpacity(0.0f);
310 AddChildView(speech_view_); 313 AddChildView(speech_view_);
311 } 314 }
312 315
316 if (app_list::switches::IsExperimentalAppListEnabled()) {
317 // Draw a banner in the corner of the experimental app list.
318 experimental_banner_view_ = new views::ImageView;
319 const gfx::ImageSkia& experimental_icon =
320 *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
321 IDR_APP_LIST_EXPERIMENTAL_ICON);
322 experimental_banner_view_->SetImage(experimental_icon);
323 experimental_banner_view_->SetPaintToLayer(true);
324 experimental_banner_view_->SetFillsBoundsOpaquely(false);
325 AddChildView(experimental_banner_view_);
326 }
327
313 OnProfilesChanged(); 328 OnProfilesChanged();
314 set_color(kContentsBackgroundColor); 329 set_color(kContentsBackgroundColor);
315 set_margins(gfx::Insets()); 330 set_margins(gfx::Insets());
316 set_parent_window(parent); 331 set_parent_window(parent);
317 set_close_on_deactivate(false); 332 set_close_on_deactivate(false);
318 set_close_on_esc(false); 333 set_close_on_esc(false);
319 set_anchor_view_insets(gfx::Insets(kArrowOffset + anchor_offset.y(), 334 set_anchor_view_insets(gfx::Insets(kArrowOffset + anchor_offset.y(),
320 kArrowOffset + anchor_offset.x(), 335 kArrowOffset + anchor_offset.x(),
321 kArrowOffset - anchor_offset.y(), 336 kArrowOffset - anchor_offset.y(),
322 kArrowOffset - anchor_offset.x())); 337 kArrowOffset - anchor_offset.x()));
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 465
451 if (speech_view_) { 466 if (speech_view_) {
452 gfx::Rect speech_bounds = contents_bounds; 467 gfx::Rect speech_bounds = contents_bounds;
453 int preferred_height = speech_view_->GetPreferredSize().height(); 468 int preferred_height = speech_view_->GetPreferredSize().height();
454 speech_bounds.Inset(kSpeechUIMargin, kSpeechUIMargin); 469 speech_bounds.Inset(kSpeechUIMargin, kSpeechUIMargin);
455 speech_bounds.set_height(std::min(speech_bounds.height(), 470 speech_bounds.set_height(std::min(speech_bounds.height(),
456 preferred_height)); 471 preferred_height));
457 speech_bounds.Inset(-speech_view_->GetInsets()); 472 speech_bounds.Inset(-speech_view_->GetInsets());
458 speech_view_->SetBoundsRect(speech_bounds); 473 speech_view_->SetBoundsRect(speech_bounds);
459 } 474 }
475
476 if (experimental_banner_view_) {
477 // Position the experimental banner in the lower right corner.
478 gfx::Rect image_bounds = experimental_banner_view_->GetImageBounds();
479 experimental_banner_view_->SetBoundsRect(image_bounds);
480 experimental_banner_view_->SetPosition(
481 gfx::Point(contents_bounds.width() - image_bounds.width(),
482 contents_bounds.height() - image_bounds.height()));
calamity 2014/07/15 08:57:58 You can avoid making two calls here. image_bounds
Matt Giuca 2014/07/16 00:18:07 Done.
483 }
460 } 484 }
461 485
462 void AppListView::SchedulePaintInRect(const gfx::Rect& rect) { 486 void AppListView::SchedulePaintInRect(const gfx::Rect& rect) {
463 BubbleDelegateView::SchedulePaintInRect(rect); 487 BubbleDelegateView::SchedulePaintInRect(rect);
464 if (GetBubbleFrameView()) 488 if (GetBubbleFrameView())
465 GetBubbleFrameView()->SchedulePaint(); 489 GetBubbleFrameView()->SchedulePaint();
466 } 490 }
467 491
468 void AppListView::OnWidgetDestroying(views::Widget* widget) { 492 void AppListView::OnWidgetDestroying(views::Widget* widget) {
469 BubbleDelegateView::OnWidgetDestroying(widget); 493 BubbleDelegateView::OnWidgetDestroying(widget);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 speech_view_->layer()->SetTransform(speech_transform); 562 speech_view_->layer()->SetTransform(speech_transform);
539 } 563 }
540 564
541 if (will_appear) 565 if (will_appear)
542 speech_view_->SetVisible(true); 566 speech_view_->SetVisible(true);
543 else 567 else
544 app_list_main_view_->SetVisible(true); 568 app_list_main_view_->SetVisible(true);
545 } 569 }
546 570
547 } // namespace app_list 571 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/app_list_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698