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

Side by Side Diff: ash/wm/overview/window_selector_panels.cc

Issue 23654037: Add panels as a single group of windows per display for overview window cycling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix restored panel relayout when some panels minimized. Created 7 years, 3 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 | « ash/wm/overview/window_selector_panels.h ('k') | ash/wm/overview/window_selector_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/wm/overview/window_selector_panels.h"
6
7 #include "ash/screen_ash.h"
8 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h"
10 #include "ash/wm/overview/scoped_transform_overview_window.h"
11 #include "ash/wm/panels/panel_layout_manager.h"
12 #include "ui/aura/client/screen_position_client.h"
13 #include "ui/aura/window.h"
14 #include "ui/compositor/layer.h"
15 #include "ui/compositor/layer_animation_observer.h"
16 #include "ui/compositor/layer_animation_sequence.h"
17 #include "ui/views/widget/widget.h"
18
19 namespace ash {
20
21 namespace {
22
23 const int kPanelCalloutFadeInDurationMilliseconds = 50;
24
25 // This class extends ScopedTransformOverviewMode to hide and show the callout
26 // widget for a panel window when entering / leaving overview mode.
27 class ScopedTransformPanelWindow : public ScopedTransformOverviewWindow {
28 public:
29 ScopedTransformPanelWindow(aura::Window* window);
30 virtual ~ScopedTransformPanelWindow();
31
32 protected:
33 virtual void OnOverviewStarted() OVERRIDE;
34
35 private:
36 // Returns the callout widget for the transformed panel.
37 views::Widget* GetCalloutWidget();
38
39 // Restores the callout visibility.
40 void RestoreCallout();
41
42 // Trigger relayout
43 void Relayout();
44
45 bool callout_visible_;
46
47 DISALLOW_COPY_AND_ASSIGN(ScopedTransformPanelWindow);
48 };
49
50 ScopedTransformPanelWindow::ScopedTransformPanelWindow(aura::Window* window)
51 : ScopedTransformOverviewWindow(window) {
52 }
53
54 ScopedTransformPanelWindow::~ScopedTransformPanelWindow() {
55 // window() will be NULL if the window was destroyed.
56 if (window())
57 RestoreCallout();
58 }
59
60 void ScopedTransformPanelWindow::OnOverviewStarted() {
61 ScopedTransformOverviewWindow::OnOverviewStarted();
62 GetCalloutWidget()->GetLayer()->SetOpacity(0.0f);
63 }
64
65 views::Widget* ScopedTransformPanelWindow::GetCalloutWidget() {
66 DCHECK(window()->parent()->id() == internal::kShellWindowId_PanelContainer);
67 internal::PanelLayoutManager* panel_layout_manager =
68 static_cast<internal::PanelLayoutManager*>(
69 window()->parent()->layout_manager());
70 return panel_layout_manager->GetCalloutWidgetForPanel(window());
71 }
72
73 void ScopedTransformPanelWindow::RestoreCallout() {
74 scoped_ptr<ui::LayerAnimationSequence> sequence(
75 new ui::LayerAnimationSequence);
76 ui::LayerAnimationElement::AnimatableProperties paused_properties;
77 paused_properties.insert(ui::LayerAnimationElement::OPACITY);
78 sequence->AddElement(ui::LayerAnimationElement::CreatePauseElement(
79 paused_properties, base::TimeDelta::FromMilliseconds(
80 ScopedTransformOverviewWindow::kTransitionMilliseconds)));
81 sequence->AddElement(ui::LayerAnimationElement::CreateOpacityElement(1,
82 base::TimeDelta::FromMilliseconds(
83 kPanelCalloutFadeInDurationMilliseconds)));
84 GetCalloutWidget()->GetLayer()->GetAnimator()->StartAnimation(
85 sequence.release());
86 }
87
88 } // namespace
89
90 WindowSelectorPanels::WindowSelectorPanels() {
91 }
92
93 WindowSelectorPanels::~WindowSelectorPanels() {
94 }
95
96 void WindowSelectorPanels::AddWindow(aura::Window* window) {
97 transform_windows_.push_back(new ScopedTransformPanelWindow(window));
98 }
99
100 const aura::RootWindow* WindowSelectorPanels::GetRootWindow() const {
101 return transform_windows_.front()->window()->GetRootWindow();
102 }
103
104 aura::Window* WindowSelectorPanels::TargetedWindow(
105 const aura::Window* target) const {
106 for (WindowList::const_iterator iter = transform_windows_.begin();
107 iter != transform_windows_.end(); ++iter) {
108 if ((*iter)->Contains(target))
109 return (*iter)->window();
110 }
111 return NULL;
112 }
113
114 void WindowSelectorPanels::RestoreWindowOnExit(aura::Window* window) {
115 for (WindowList::iterator iter = transform_windows_.begin();
116 iter != transform_windows_.end(); ++iter) {
117 if ((*iter)->Contains(window)) {
118 (*iter)->RestoreWindowOnExit();
119 break;
120 }
121 }
122 }
123
124 aura::Window* WindowSelectorPanels::SelectionWindow() const {
125 return transform_windows_.front()->window();
126 }
127
128 void WindowSelectorPanels::RemoveWindow(const aura::Window* window) {
129 for (WindowList::iterator iter = transform_windows_.begin();
130 iter != transform_windows_.end(); ++iter) {
131 if ((*iter)->Contains(window)) {
132 (*iter)->OnWindowDestroyed();
133 transform_windows_.erase(iter);
134 break;
135 }
136 }
137 }
138
139 bool WindowSelectorPanels::empty() const {
140 return transform_windows_.empty();
141 }
142
143 void WindowSelectorPanels::SetItemBounds(aura::RootWindow* root_window,
144 const gfx::Rect& target_bounds) {
145 // Panel windows affect the position of each other. Restore all panel windows
146 // first in order to have the correct layout.
147 for (WindowList::iterator iter = transform_windows_.begin();
148 iter != transform_windows_.end(); ++iter) {
149 (*iter)->RestoreWindow();
150 }
151 gfx::Rect bounding_rect;
152 for (WindowList::iterator iter = transform_windows_.begin();
153 iter != transform_windows_.end(); ++iter) {
154 aura::Window* panel = (*iter)->window();
155 gfx::Rect bounds = ScreenAsh::ConvertRectToScreen(
156 panel->parent(), panel->GetTargetBounds());
157 bounding_rect.Union(bounds);
158 }
159 gfx::Transform bounding_transform =
160 ScopedTransformOverviewWindow::GetTransformForRectPreservingAspectRatio(
161 bounding_rect, target_bounds);
162 for (WindowList::iterator iter = transform_windows_.begin();
163 iter != transform_windows_.end(); ++iter) {
164 gfx::Transform transform;
165 aura::Window* panel = (*iter)->window();
166 gfx::Rect bounds = ScreenAsh::ConvertRectToScreen(
167 panel->parent(), panel->GetTargetBounds());
168 transform.Translate(bounding_rect.x() - bounds.x(),
169 bounding_rect.y() - bounds.y());
170 transform.PreconcatTransform(bounding_transform);
171 transform.Translate(bounds.x() - bounding_rect.x(),
172 bounds.y() - bounding_rect.y());
173 (*iter)->SetTransform(root_window, transform);
174 }
175 }
176
177 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/overview/window_selector_panels.h ('k') | ash/wm/overview/window_selector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698