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

Side by Side Diff: ash/common/wm/overview/window_grid.cc

Issue 2627153006: [ash-md] Uses a solid color layer for overview mode shield (Closed)
Patch Set: [ash-md] Uses a solid color layer for overview mode shield Created 3 years, 11 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 | « no previous file | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ash/common/wm/overview/window_grid.h" 5 #include "ash/common/wm/overview/window_grid.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 } 219 }
220 return vector; 220 return vector;
221 } 221 }
222 222
223 // Creates and returns a background translucent widget parented in 223 // Creates and returns a background translucent widget parented in
224 // |root_window|'s default container and having |background_color|. 224 // |root_window|'s default container and having |background_color|.
225 // When |border_thickness| is non-zero, a border is created having 225 // When |border_thickness| is non-zero, a border is created having
226 // |border_color|, otherwise |border_color| parameter is ignored. 226 // |border_color|, otherwise |border_color| parameter is ignored.
227 // The new background widget starts with |initial_opacity| and then fades in. 227 // The new background widget starts with |initial_opacity| and then fades in.
228 views::Widget* CreateBackgroundWidget(WmWindow* root_window, 228 views::Widget* CreateBackgroundWidget(WmWindow* root_window,
229 ui::LayerType layer_type,
229 SkColor background_color, 230 SkColor background_color,
230 int border_thickness, 231 int border_thickness,
231 int border_radius, 232 int border_radius,
232 SkColor border_color, 233 SkColor border_color,
233 float initial_opacity) { 234 float initial_opacity) {
234 views::Widget* widget = new views::Widget; 235 views::Widget* widget = new views::Widget;
235 views::Widget::InitParams params; 236 views::Widget::InitParams params;
236 params.type = views::Widget::InitParams::TYPE_POPUP; 237 params.type = views::Widget::InitParams::TYPE_POPUP;
237 params.keep_on_top = false; 238 params.keep_on_top = false;
238 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 239 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
239 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 240 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
241 params.layer_type = layer_type;
240 params.accept_events = false; 242 params.accept_events = false;
241 widget->set_focus_on_creation(false); 243 widget->set_focus_on_creation(false);
242 // Parenting in kShellWindowId_WallpaperContainer allows proper layering of 244 // Parenting in kShellWindowId_WallpaperContainer allows proper layering of
243 // the shield and selection widgets. Since that container is created with 245 // the shield and selection widgets. Since that container is created with
244 // USE_LOCAL_COORDINATES BoundsInScreenBehavior local bounds in |root_window_| 246 // USE_LOCAL_COORDINATES BoundsInScreenBehavior local bounds in |root_window_|
245 // need to be provided. 247 // need to be provided.
246 root_window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( 248 root_window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer(
247 widget, kShellWindowId_WallpaperContainer, &params); 249 widget, kShellWindowId_WallpaperContainer, &params);
248 widget->Init(params); 250 widget->Init(params);
249 WmWindow* widget_window = WmLookup::Get()->GetWindowForWidget(widget); 251 WmWindow* widget_window = WmLookup::Get()->GetWindowForWidget(widget);
250 // Disable the "bounce in" animation when showing the window. 252 // Disable the "bounce in" animation when showing the window.
251 widget_window->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); 253 widget_window->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE);
252 // The background widget should not activate the shelf when passing under it. 254 // The background widget should not activate the shelf when passing under it.
253 widget_window->GetWindowState()->set_ignored_by_shelf(true); 255 widget_window->GetWindowState()->set_ignored_by_shelf(true);
254 256 if (params.layer_type == ui::LAYER_SOLID_COLOR) {
255 views::View* content_view = 257 widget_window->GetLayer()->SetColor(background_color);
256 new RoundedRectView(border_radius, SK_ColorTRANSPARENT); 258 } else {
257 content_view->set_background(new BackgroundWith1PxBorder( 259 views::View* content_view =
258 background_color, border_color, border_thickness, border_radius)); 260 new RoundedRectView(border_radius, SK_ColorTRANSPARENT);
259 widget->SetContentsView(content_view); 261 content_view->set_background(new BackgroundWith1PxBorder(
262 background_color, border_color, border_thickness, border_radius));
263 widget->SetContentsView(content_view);
264 }
260 widget_window->GetParent()->StackChildAtTop(widget_window); 265 widget_window->GetParent()->StackChildAtTop(widget_window);
261 widget->Show(); 266 widget->Show();
262 widget_window->SetOpacity(initial_opacity); 267 widget_window->SetOpacity(initial_opacity);
263 return widget; 268 return widget;
264 } 269 }
265 270
266 bool IsMinimizedStateType(wm::WindowStateType type) { 271 bool IsMinimizedStateType(wm::WindowStateType type) {
267 return type == wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED || 272 return type == wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED ||
268 type == wm::WINDOW_STATE_TYPE_MINIMIZED; 273 type == wm::WINDOW_STATE_TYPE_MINIMIZED;
269 } 274 }
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 641
637 void WindowGrid::InitShieldWidget() { 642 void WindowGrid::InitShieldWidget() {
638 // TODO(varkha): The code assumes that SHELF_BACKGROUND_MAXIMIZED is 643 // TODO(varkha): The code assumes that SHELF_BACKGROUND_MAXIMIZED is
639 // synonymous with a black shelf background. Update this code if that 644 // synonymous with a black shelf background. Update this code if that
640 // assumption is no longer valid. 645 // assumption is no longer valid.
641 const float initial_opacity = 646 const float initial_opacity =
642 (WmShelf::ForWindow(root_window_)->GetBackgroundType() == 647 (WmShelf::ForWindow(root_window_)->GetBackgroundType() ==
643 SHELF_BACKGROUND_MAXIMIZED) 648 SHELF_BACKGROUND_MAXIMIZED)
644 ? 1.f 649 ? 1.f
645 : 0.f; 650 : 0.f;
646 shield_widget_.reset(CreateBackgroundWidget( 651 shield_widget_.reset(
647 root_window_, kShieldColor, 0, 0, SK_ColorTRANSPARENT, initial_opacity)); 652 CreateBackgroundWidget(root_window_, ui::LAYER_SOLID_COLOR, kShieldColor,
648 653 0, 0, SK_ColorTRANSPARENT, initial_opacity));
649 WmWindow* widget_window = 654 WmWindow* widget_window =
650 WmLookup::Get()->GetWindowForWidget(shield_widget_.get()); 655 WmLookup::Get()->GetWindowForWidget(shield_widget_.get());
651 const gfx::Rect bounds = widget_window->GetParent()->GetBounds(); 656 const gfx::Rect bounds = widget_window->GetParent()->GetBounds();
652 widget_window->SetBounds(bounds); 657 widget_window->SetBounds(bounds);
653 widget_window->SetName("OverviewModeShield"); 658 widget_window->SetName("OverviewModeShield");
654 659
655 ui::ScopedLayerAnimationSettings animation_settings( 660 ui::ScopedLayerAnimationSettings animation_settings(
656 widget_window->GetLayer()->GetAnimator()); 661 widget_window->GetLayer()->GetAnimator());
657 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( 662 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
658 kOverviewSelectorTransitionMilliseconds)); 663 kOverviewSelectorTransitionMilliseconds));
659 animation_settings.SetTweenType(gfx::Tween::EASE_IN); 664 animation_settings.SetTweenType(gfx::Tween::EASE_IN);
660 animation_settings.SetPreemptionStrategy( 665 animation_settings.SetPreemptionStrategy(
661 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 666 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
662 shield_widget_->SetOpacity(kShieldOpacity); 667 shield_widget_->SetOpacity(kShieldOpacity);
663 } 668 }
664 669
665 void WindowGrid::InitSelectionWidget(WindowSelector::Direction direction) { 670 void WindowGrid::InitSelectionWidget(WindowSelector::Direction direction) {
666 selection_widget_.reset(CreateBackgroundWidget( 671 selection_widget_.reset(CreateBackgroundWidget(
667 root_window_, kWindowSelectionColor, kWindowSelectionBorderThickness, 672 root_window_, ui::LAYER_TEXTURED, kWindowSelectionColor,
668 kWindowSelectionRadius, kWindowSelectionBorderColor, 0.f)); 673 kWindowSelectionBorderThickness, kWindowSelectionRadius,
674 kWindowSelectionBorderColor, 0.f));
669 WmWindow* widget_window = 675 WmWindow* widget_window =
670 WmLookup::Get()->GetWindowForWidget(selection_widget_.get()); 676 WmLookup::Get()->GetWindowForWidget(selection_widget_.get());
671 const gfx::Rect target_bounds = 677 const gfx::Rect target_bounds =
672 root_window_->ConvertRectFromScreen(SelectedWindow()->target_bounds()); 678 root_window_->ConvertRectFromScreen(SelectedWindow()->target_bounds());
673 gfx::Vector2d fade_out_direction = 679 gfx::Vector2d fade_out_direction =
674 GetSlideVectorForFadeIn(direction, target_bounds); 680 GetSlideVectorForFadeIn(direction, target_bounds);
675 widget_window->SetBounds(target_bounds - fade_out_direction); 681 widget_window->SetBounds(target_bounds - fade_out_direction);
676 widget_window->SetName("OverviewModeSelector"); 682 widget_window->SetName("OverviewModeSelector");
677 683
678 selector_shadow_.reset(new ::wm::Shadow()); 684 selector_shadow_.reset(new ::wm::Shadow());
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 *min_right = left; 839 *min_right = left;
834 if (*max_right < left) 840 if (*max_right < left)
835 *max_right = left; 841 *max_right = left;
836 } 842 }
837 *max_bottom = top + height; 843 *max_bottom = top + height;
838 } 844 }
839 return windows_fit; 845 return windows_fit;
840 } 846 }
841 847
842 } // namespace ash 848 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698