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

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

Issue 276833002: Make the App Info Dialog appear modal (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added a GetAppListBounds method and moved the bounds logic into the controller Created 6 years, 7 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"
(...skipping 10 matching lines...) Expand all
21 #include "ui/app_list/views/app_list_view_observer.h" 21 #include "ui/app_list/views/app_list_view_observer.h"
22 #include "ui/app_list/views/apps_container_view.h" 22 #include "ui/app_list/views/apps_container_view.h"
23 #include "ui/app_list/views/contents_view.h" 23 #include "ui/app_list/views/contents_view.h"
24 #include "ui/app_list/views/search_box_view.h" 24 #include "ui/app_list/views/search_box_view.h"
25 #include "ui/app_list/views/signin_view.h" 25 #include "ui/app_list/views/signin_view.h"
26 #include "ui/app_list/views/speech_view.h" 26 #include "ui/app_list/views/speech_view.h"
27 #include "ui/base/ui_base_switches.h" 27 #include "ui/base/ui_base_switches.h"
28 #include "ui/compositor/layer.h" 28 #include "ui/compositor/layer.h"
29 #include "ui/compositor/layer_animation_observer.h" 29 #include "ui/compositor/layer_animation_observer.h"
30 #include "ui/compositor/scoped_layer_animation_settings.h" 30 #include "ui/compositor/scoped_layer_animation_settings.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"
36 #include "ui/views/bubble/bubble_window_targeter.h" 37 #include "ui/views/bubble/bubble_window_targeter.h"
37 #include "ui/views/controls/textfield/textfield.h" 38 #include "ui/views/controls/textfield/textfield.h"
38 #include "ui/views/layout/fill_layout.h" 39 #include "ui/views/layout/fill_layout.h"
39 #include "ui/views/widget/widget.h" 40 #include "ui/views/widget/widget.h"
40 41
(...skipping 30 matching lines...) Expand all
71 switches::kDisableDwmComposition)) { 72 switches::kDisableDwmComposition)) {
72 return false; 73 return false;
73 } 74 }
74 #elif defined(OS_LINUX) && !defined(USE_ASH) 75 #elif defined(OS_LINUX) && !defined(USE_ASH)
75 // Shadows are not supported on (non-ChromeOS) Linux. 76 // Shadows are not supported on (non-ChromeOS) Linux.
76 return false; 77 return false;
77 #endif 78 #endif
78 return true; 79 return true;
79 } 80 }
80 81
82 // An background for a view that appears as a colored rounded rectangle with the
83 // given radius and the same size as the target view.
84 class ColoredRoundRectBackground : public views::Background {
85 public:
86 ColoredRoundRectBackground(int corner_radius, SkColor color)
87 : corner_radius_(corner_radius), color_(color) {};
88 virtual ~ColoredRoundRectBackground() {};
89
90 virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE {
91 SkPaint paint;
92 paint.setStyle(SkPaint::kFill_Style);
93 paint.setColor(color_);
94 canvas->DrawRoundRect(view->GetContentsBounds(), corner_radius_, paint);
95 }
96
97 private:
98 const int corner_radius_;
99 const SkColor color_;
100 };
101
81 } // namespace 102 } // namespace
82 103
83 // An animation observer to hide the view at the end of the animation. 104 // An animation observer to hide the view at the end of the animation.
84 class HideViewAnimationObserver : public ui::ImplicitAnimationObserver { 105 class HideViewAnimationObserver : public ui::ImplicitAnimationObserver {
85 public: 106 public:
86 HideViewAnimationObserver() 107 HideViewAnimationObserver()
87 : frame_(NULL), 108 : frame_(NULL),
88 target_(NULL) { 109 target_(NULL) {
89 } 110 }
90 111
(...skipping 29 matching lines...) Expand all
120 }; 141 };
121 142
122 //////////////////////////////////////////////////////////////////////////////// 143 ////////////////////////////////////////////////////////////////////////////////
123 // AppListView: 144 // AppListView:
124 145
125 AppListView::AppListView(AppListViewDelegate* delegate) 146 AppListView::AppListView(AppListViewDelegate* delegate)
126 : delegate_(delegate), 147 : delegate_(delegate),
127 app_list_main_view_(NULL), 148 app_list_main_view_(NULL),
128 signin_view_(NULL), 149 signin_view_(NULL),
129 speech_view_(NULL), 150 speech_view_(NULL),
151 overlay_view_(NULL),
130 animation_observer_(new HideViewAnimationObserver()) { 152 animation_observer_(new HideViewAnimationObserver()) {
131 CHECK(delegate); 153 CHECK(delegate);
132 154
133 delegate_->AddObserver(this); 155 delegate_->AddObserver(this);
134 delegate_->GetSpeechUI()->AddObserver(this); 156 delegate_->GetSpeechUI()->AddObserver(this);
135 } 157 }
136 158
137 AppListView::~AppListView() { 159 AppListView::~AppListView() {
138 delegate_->GetSpeechUI()->RemoveObserver(this); 160 delegate_->GetSpeechUI()->RemoveObserver(this);
139 delegate_->RemoveObserver(this); 161 delegate_->RemoveObserver(this);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 209
188 void AppListView::Close() { 210 void AppListView::Close() {
189 app_list_main_view_->Close(); 211 app_list_main_view_->Close();
190 delegate_->Dismiss(); 212 delegate_->Dismiss();
191 } 213 }
192 214
193 void AppListView::UpdateBounds() { 215 void AppListView::UpdateBounds() {
194 SizeToContents(); 216 SizeToContents();
195 } 217 }
196 218
219 void AppListView::ShowAppListOverlay(bool visible) {
220 DCHECK(overlay_view_);
221 overlay_view_->SetVisible(visible);
222 }
223
197 bool AppListView::ShouldCenterWindow() const { 224 bool AppListView::ShouldCenterWindow() const {
198 return delegate_->ShouldCenterWindow(); 225 return delegate_->ShouldCenterWindow();
199 } 226 }
200 227
201 gfx::Size AppListView::GetPreferredSize() { 228 gfx::Size AppListView::GetPreferredSize() {
202 return app_list_main_view_->GetPreferredSize(); 229 return app_list_main_view_->GetPreferredSize();
203 } 230 }
204 231
205 void AppListView::Paint(gfx::Canvas* canvas, const views::CullSet& cull_set) { 232 void AppListView::Paint(gfx::Canvas* canvas, const views::CullSet& cull_set) {
206 views::BubbleDelegateView::Paint(canvas, cull_set); 233 views::BubbleDelegateView::Paint(canvas, cull_set);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 app_list_main_view_)); 354 app_list_main_view_));
328 355
329 // On non-aura the bubble has two widgets, and it's possible for the border 356 // On non-aura the bubble has two widgets, and it's possible for the border
330 // to be shown independently in odd situations. Explicitly hide the bubble 357 // to be shown independently in odd situations. Explicitly hide the bubble
331 // widget to ensure that any WM_WINDOWPOSCHANGED messages triggered by the 358 // widget to ensure that any WM_WINDOWPOSCHANGED messages triggered by the
332 // window manager do not have the SWP_SHOWWINDOW flag set which would cause 359 // window manager do not have the SWP_SHOWWINDOW flag set which would cause
333 // the border to be shown. See http://crbug.com/231687 . 360 // the border to be shown. See http://crbug.com/231687 .
334 GetWidget()->Hide(); 361 GetWidget()->Hide();
335 #endif 362 #endif
336 363
364 // The contents corner radius is 1px smaller than border corner radius.
calamity 2014/05/20 08:42:06 Mention that this is needed for platforms where th
365 const int kOverlayCornerRadius =
366 GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius() - 1;
367 const float kOverlayOpacity = 0.75f;
368
369 // To make the overlay view, construct a regular view with a solid white
370 // background, rather than a white rectangle on it. This is because we need
371 // overlay_view_ to be drawn to its own layer (so it appears correctly in the
372 // foreground).
373 overlay_view_ = new views::View();
374 overlay_view_->SetPaintToLayer(true);
375 overlay_view_->set_background(
376 new ColoredRoundRectBackground(kOverlayCornerRadius, SK_ColorWHITE));
377 overlay_view_->layer()->SetOpacity(kOverlayOpacity);
378 overlay_view_->SetBoundsRect(bounds());
379 overlay_view_->SetVisible(false);
380 AddChildView(overlay_view_);
381
337 if (delegate_) 382 if (delegate_)
338 delegate_->ViewInitialized(); 383 delegate_->ViewInitialized();
339 } 384 }
340 385
341 void AppListView::OnBeforeBubbleWidgetInit( 386 void AppListView::OnBeforeBubbleWidgetInit(
342 views::Widget::InitParams* params, 387 views::Widget::InitParams* params,
343 views::Widget* widget) const { 388 views::Widget* widget) const {
344 #if defined(USE_AURA) && !defined(OS_CHROMEOS) 389 #if defined(USE_AURA) && !defined(OS_CHROMEOS)
345 if (delegate_ && delegate_->ForceNativeDesktop()) 390 if (delegate_ && delegate_->ForceNativeDesktop())
346 params->native_widget = new views::DesktopNativeWidgetAura(widget); 391 params->native_widget = new views::DesktopNativeWidgetAura(widget);
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 #else 556 #else
512 speech_view_->SetVisible(recognizing); 557 speech_view_->SetVisible(recognizing);
513 app_list_main_view_->SetVisible(!recognizing); 558 app_list_main_view_->SetVisible(!recognizing);
514 559
515 // Needs to schedule paint of AppListView itself, to repaint the background. 560 // Needs to schedule paint of AppListView itself, to repaint the background.
516 GetBubbleFrameView()->SchedulePaint(); 561 GetBubbleFrameView()->SchedulePaint();
517 #endif 562 #endif
518 } 563 }
519 564
520 } // namespace app_list 565 } // 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