OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef CHROME_BROWSER_UI_VIEWS_PANELS_PANEL_STACK_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PANELS_PANEL_STACK_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_PANELS_PANEL_STACK_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PANELS_PANEL_STACK_VIEW_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "chrome/browser/ui/panels/native_panel_stack_window.h" | 12 #include "chrome/browser/ui/panels/native_panel_stack_window.h" |
13 #include "ui/base/animation/animation_delegate.h" | 13 #include "ui/base/animation/animation_delegate.h" |
14 #include "ui/views/focus/widget_focus_manager.h" | 14 #include "ui/views/focus/widget_focus_manager.h" |
15 #include "ui/views/widget/widget_delegate.h" | 15 #include "ui/views/widget/widget_delegate.h" |
16 #include "ui/views/widget/widget_observer.h" | 16 #include "ui/views/widget/widget_observer.h" |
17 | 17 |
18 class TaskbarWindowThumbnailerWin; | 18 #if defined(OS_WIN) |
| 19 #include "chrome/browser/ui/views/panels/taskbar_window_thumbnailer_win.h" |
| 20 #endif |
| 21 |
19 namespace ui { | 22 namespace ui { |
20 class LinearAnimation; | 23 class LinearAnimation; |
21 } | 24 } |
22 namespace views { | 25 namespace views { |
23 class Widget; | 26 class Widget; |
24 } | 27 } |
25 | 28 |
26 // A native window that acts as the owner of all panels in the stack, in order | 29 // A native window that acts as the owner of all panels in the stack, in order |
27 // to make all panels appear as a single window on the taskbar or launcher. | 30 // to make all panels appear as a single window on the taskbar or launcher. |
28 class PanelStackView : public NativePanelStackWindow, | 31 class PanelStackView : public NativePanelStackWindow, |
29 public views::WidgetObserver, | 32 public views::WidgetObserver, |
30 public views::WidgetDelegateView, | 33 public views::WidgetDelegateView, |
31 public views::WidgetFocusChangeListener, | 34 public views::WidgetFocusChangeListener, |
| 35 #if defined(OS_WIN) |
| 36 public TaskbarWindowThumbnailerDelegateWin, |
| 37 #endif |
32 public ui::AnimationDelegate { | 38 public ui::AnimationDelegate { |
33 public: | 39 public: |
34 explicit PanelStackView(NativePanelStackWindowDelegate* delegate); | 40 explicit PanelStackView(NativePanelStackWindowDelegate* delegate); |
35 virtual ~PanelStackView(); | 41 virtual ~PanelStackView(); |
36 | 42 |
37 protected: | 43 protected: |
38 // Overridden from NativePanelStackWindow: | 44 // Overridden from NativePanelStackWindow: |
39 virtual void Close() OVERRIDE; | 45 virtual void Close() OVERRIDE; |
40 virtual void AddPanel(Panel* panel) OVERRIDE; | 46 virtual void AddPanel(Panel* panel) OVERRIDE; |
41 virtual void RemovePanel(Panel* panel) OVERRIDE; | 47 virtual void RemovePanel(Panel* panel) OVERRIDE; |
(...skipping 20 matching lines...) Expand all Loading... |
62 // Overridden from views::WidgetDelegate: | 68 // Overridden from views::WidgetDelegate: |
63 virtual string16 GetWindowTitle() const OVERRIDE; | 69 virtual string16 GetWindowTitle() const OVERRIDE; |
64 virtual gfx::ImageSkia GetWindowAppIcon() OVERRIDE; | 70 virtual gfx::ImageSkia GetWindowAppIcon() OVERRIDE; |
65 virtual gfx::ImageSkia GetWindowIcon() OVERRIDE; | 71 virtual gfx::ImageSkia GetWindowIcon() OVERRIDE; |
66 virtual views::Widget* GetWidget() OVERRIDE; | 72 virtual views::Widget* GetWidget() OVERRIDE; |
67 virtual const views::Widget* GetWidget() const OVERRIDE; | 73 virtual const views::Widget* GetWidget() const OVERRIDE; |
68 virtual void DeleteDelegate() OVERRIDE; | 74 virtual void DeleteDelegate() OVERRIDE; |
69 | 75 |
70 // Overridden from views::WidgetObserver: | 76 // Overridden from views::WidgetObserver: |
71 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; | 77 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; |
72 virtual void OnWidgetActivationChanged(views::Widget* widget, | |
73 bool active) OVERRIDE; | |
74 | 78 |
75 // Overridden from views::WidgetFocusChangeListener: | 79 // Overridden from views::WidgetFocusChangeListener: |
76 virtual void OnNativeFocusChange(gfx::NativeView focused_before, | 80 virtual void OnNativeFocusChange(gfx::NativeView focused_before, |
77 gfx::NativeView focused_now) OVERRIDE; | 81 gfx::NativeView focused_now) OVERRIDE; |
78 | 82 |
79 // Overridden from AnimationDelegate: | 83 // Overridden from AnimationDelegate: |
80 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 84 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; |
81 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 85 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; |
82 | 86 |
83 // Updates the bounds of panels as specified in batch update data. | 87 // Updates the bounds of panels as specified in batch update data. |
84 void UpdatePanelsBounds(); | 88 void UpdatePanelsBounds(); |
85 | 89 |
| 90 // Notifies the delegate that the updates of the panel bounds are completed. |
| 91 void NotifyBoundsUpdateCompleted(); |
| 92 |
86 // Computes/updates the minimum bounds that could fit all panels. | 93 // Computes/updates the minimum bounds that could fit all panels. |
87 gfx::Rect GetStackWindowBounds() const; | 94 gfx::Rect GetStackWindowBounds() const; |
88 void UpdateStackWindowBounds(); | 95 void UpdateStackWindowBounds(); |
89 | 96 |
90 views::Widget* CreateWindowWithBounds(const gfx::Rect& bounds); | 97 views::Widget* CreateWindowWithBounds(const gfx::Rect& bounds); |
91 void EnsureWindowCreated(); | 98 void EnsureWindowCreated(); |
92 | 99 |
93 // Makes the stack window own the panel window such that multiple panels | 100 // Makes the stack window own the panel window such that multiple panels |
94 // stacked together could appear as a single window on the taskbar or | 101 // stacked together could appear as a single window on the taskbar or |
95 // launcher. | 102 // launcher. |
96 static void MakeStackWindowOwnPanelWindow(Panel* panel, | 103 static void MakeStackWindowOwnPanelWindow(Panel* panel, |
97 PanelStackView* stack_window); | 104 PanelStackView* stack_window); |
98 | 105 |
99 #if defined(OS_WIN) | 106 #if defined(OS_WIN) |
100 // Capture the thumbnail of the whole stack and provide it to live preview | 107 // Overridden from TaskbarWindowThumbnailerDelegateWin: |
101 // (available since Windows 7). | 108 virtual std::vector<HWND> GetSnapshotWindowHandles() const OVERRIDE; |
102 void CaptureThumbnailForLivePreview(); | 109 |
| 110 // Updates the live preview snapshot when something changes, like |
| 111 // adding/removing/moving/resizing a stacked panel. |
| 112 void RefreshLivePreviewThumbnail(); |
103 | 113 |
104 // Updates the bounds of the widget window in a deferred way. | 114 // Updates the bounds of the widget window in a deferred way. |
105 void DeferUpdateNativeWindowBounds(HDWP defer_window_pos_info, | 115 void DeferUpdateNativeWindowBounds(HDWP defer_window_pos_info, |
106 views::Widget* window, | 116 views::Widget* window, |
107 const gfx::Rect& bounds); | 117 const gfx::Rect& bounds); |
108 #endif | 118 #endif |
109 | 119 |
110 NativePanelStackWindowDelegate* delegate_; | 120 NativePanelStackWindowDelegate* delegate_; |
111 | 121 |
112 views::Widget* window_; // Weak pointer, own us. | 122 views::Widget* window_; // Weak pointer, own us. |
113 | 123 |
114 bool is_closing_; | 124 bool is_closing_; |
115 | 125 |
116 // Tracks all panels that are enclosed by this window. | 126 // Tracks all panels that are enclosed by this window. |
117 Panels panels_; | 127 Panels panels_; |
118 | 128 |
119 // Is the taskbar icon of the underlying window being flashed in order to | 129 // Is the taskbar icon of the underlying window being flashed in order to |
120 // draw the user's attention? | 130 // draw the user's attention? |
121 bool is_drawing_attention_; | 131 bool is_drawing_attention_; |
122 | 132 |
123 #if defined(OS_WIN) | 133 #if defined(OS_WIN) |
124 // Used to provide custom taskbar thumbnail for Windows 7 and later. | 134 // The custom live preview snapshot is always provided for the stack window. |
| 135 // This is because the system might not show the snapshot correctly for |
| 136 // a small window, like collapsed panel. |
125 scoped_ptr<TaskbarWindowThumbnailerWin> thumbnailer_; | 137 scoped_ptr<TaskbarWindowThumbnailerWin> thumbnailer_; |
126 #endif | 138 #endif |
127 | 139 |
128 // For batch bounds update. | 140 // For batch bounds update. |
129 bool animate_bounds_updates_; | 141 bool animate_bounds_updates_; |
130 bool bounds_updates_started_; | 142 bool bounds_updates_started_; |
131 BoundsUpdates bounds_updates_; | 143 BoundsUpdates bounds_updates_; |
132 | 144 |
133 // Used to animate the bounds changes at a synchronized pace. | 145 // Used to animate the bounds changes at a synchronized pace. |
134 scoped_ptr<ui::LinearAnimation> bounds_animator_; | 146 scoped_ptr<ui::LinearAnimation> bounds_animator_; |
135 | 147 |
136 DISALLOW_COPY_AND_ASSIGN(PanelStackView); | 148 DISALLOW_COPY_AND_ASSIGN(PanelStackView); |
137 }; | 149 }; |
138 | 150 |
139 #endif // CHROME_BROWSER_UI_VIEWS_PANELS_PANEL_STACK_VIEW_H_ | 151 #endif // CHROME_BROWSER_UI_VIEWS_PANELS_PANEL_STACK_VIEW_H_ |
OLD | NEW |