OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/panels/panel_manager.h" | 5 #include "chrome/browser/ui/panels/panel_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "chrome/browser/fullscreen.h" | |
13 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_list.h" | 15 #include "chrome/browser/ui/browser_list.h" |
15 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" | 16 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
16 #include "chrome/browser/ui/window_sizer.h" | 17 #include "chrome/browser/ui/window_sizer.h" |
17 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
18 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
19 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
20 | 21 |
21 namespace { | 22 namespace { |
22 // Invalid panel index. | 23 // Invalid panel index. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 | 63 |
63 PanelManager::PanelManager() | 64 PanelManager::PanelManager() |
64 : minimized_panel_count_(0), | 65 : minimized_panel_count_(0), |
65 are_titlebars_up_(false), | 66 are_titlebars_up_(false), |
66 dragging_panel_index_(kInvalidPanelIndex), | 67 dragging_panel_index_(kInvalidPanelIndex), |
67 dragging_panel_original_x_(0), | 68 dragging_panel_original_x_(0), |
68 delayed_titlebar_action_(NO_ACTION), | 69 delayed_titlebar_action_(NO_ACTION), |
69 remove_delays_for_testing_(false), | 70 remove_delays_for_testing_(false), |
70 titlebar_action_factory_(this), | 71 titlebar_action_factory_(this), |
71 auto_sizing_enabled_(true), | 72 auto_sizing_enabled_(true), |
72 mouse_watching_disabled_(false) { | 73 mouse_watching_disabled_(false), |
74 is_full_screen_mode_on_(false) { | |
73 panel_mouse_watcher_.reset(PanelMouseWatcher::Create()); | 75 panel_mouse_watcher_.reset(PanelMouseWatcher::Create()); |
74 auto_hiding_desktop_bar_ = AutoHidingDesktopBar::Create(this); | 76 auto_hiding_desktop_bar_ = AutoHidingDesktopBar::Create(this); |
75 OnDisplayChanged(); | 77 OnDisplayChanged(); |
76 } | 78 } |
77 | 79 |
78 PanelManager::~PanelManager() { | 80 PanelManager::~PanelManager() { |
79 DCHECK(panels_.empty()); | 81 DCHECK(panels_.empty()); |
80 DCHECK(panels_pending_to_remove_.empty()); | 82 DCHECK(panels_pending_to_remove_.empty()); |
81 DCHECK_EQ(0, minimized_panel_count_); | 83 DCHECK_EQ(0, minimized_panel_count_); |
82 } | 84 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 int x = GetRightMostAvailablePosition() - width; | 147 int x = GetRightMostAvailablePosition() - width; |
146 panel->Initialize(gfx::Rect(x, y, width, height)); | 148 panel->Initialize(gfx::Rect(x, y, width, height)); |
147 | 149 |
148 panels_.push_back(panel); | 150 panels_.push_back(panel); |
149 | 151 |
150 content::NotificationService::current()->Notify( | 152 content::NotificationService::current()->Notify( |
151 chrome::NOTIFICATION_PANEL_ADDED, | 153 chrome::NOTIFICATION_PANEL_ADDED, |
152 content::Source<Panel>(panel), | 154 content::Source<Panel>(panel), |
153 content::NotificationService::NoDetails()); | 155 content::NotificationService::NoDetails()); |
154 | 156 |
157 if (num_panels() == 1) { | |
dcheng
2011/11/30 01:07:28
Use panels_.size() -- it makes the connection more
jennb
2011/11/30 02:06:27
panels_ is going away. use num_panels().
prasadt
2011/11/30 02:38:47
Done.
prasadt
2011/11/30 02:38:47
See Jenn's comment.
| |
158 full_screen_mode_timer_.Start(FROM_HERE, | |
159 base::TimeDelta::FromMilliseconds(kFullScreenModeCheckInterval), | |
160 this, &PanelManager::CheckFullScreenMode); | |
161 } | |
162 | |
155 return panel; | 163 return panel; |
156 } | 164 } |
157 | 165 |
158 int PanelManager::GetMaxPanelWidth() const { | 166 int PanelManager::GetMaxPanelWidth() const { |
159 return static_cast<int>(adjusted_work_area_.width() * kPanelMaxWidthFactor); | 167 return static_cast<int>(adjusted_work_area_.width() * kPanelMaxWidthFactor); |
160 } | 168 } |
161 | 169 |
162 int PanelManager::GetMaxPanelHeight() const { | 170 int PanelManager::GetMaxPanelHeight() const { |
163 return static_cast<int>(adjusted_work_area_.height() * kPanelMaxHeightFactor); | 171 return static_cast<int>(adjusted_work_area_.height() * kPanelMaxHeightFactor); |
164 } | 172 } |
165 | 173 |
166 int PanelManager::StartingRightPosition() const { | 174 int PanelManager::StartingRightPosition() const { |
167 return adjusted_work_area_.right() - kRightScreenEdgeSpacingWidth; | 175 return adjusted_work_area_.right() - kRightScreenEdgeSpacingWidth; |
168 } | 176 } |
169 | 177 |
170 int PanelManager::GetRightMostAvailablePosition() const { | 178 int PanelManager::GetRightMostAvailablePosition() const { |
171 return panels_.empty() ? StartingRightPosition() : | 179 return panels_.empty() ? StartingRightPosition() : |
172 (panels_.back()->GetBounds().x() - kPanelsHorizontalSpacing); | 180 (panels_.back()->GetBounds().x() - kPanelsHorizontalSpacing); |
173 } | 181 } |
174 | 182 |
183 void PanelManager::CheckFullScreenMode() { | |
184 bool is_full_screen_mode_on_new = IsFullScreenMode(); | |
185 if (is_full_screen_mode_on_ == is_full_screen_mode_on_new) | |
186 return; | |
187 | |
188 is_full_screen_mode_on_ = is_full_screen_mode_on_new; | |
189 for (size_t i = 0; i < panels_.size(); ++i) | |
190 panels_[i]->FullScreenModeChanged(is_full_screen_mode_on_); | |
Dmitry Titov
2011/11/30 01:35:53
if you do panel->native_panel()->FooBar() here, yo
prasadt
2011/11/30 02:38:47
Currently PanelManager does not access native_pane
Dmitry Titov
2011/12/01 04:04:26
What would be the reason for such separation? Nati
prasadt
2011/12/01 04:20:48
Done.
NativePanel interface is currently protecte
jennb
2011/12/01 21:22:09
Another reason for the separation is that the Pane
prasadt
2011/12/01 21:35:16
Now that I think about it, this makes sense to me.
| |
191 } | |
192 | |
175 void PanelManager::Remove(Panel* panel) { | 193 void PanelManager::Remove(Panel* panel) { |
176 // If we're in the process of dragging, delay the removal. | 194 // If we're in the process of dragging, delay the removal. |
177 if (dragging_panel_index_ != kInvalidPanelIndex) { | 195 if (dragging_panel_index_ != kInvalidPanelIndex) { |
178 panels_pending_to_remove_.push_back(panel); | 196 panels_pending_to_remove_.push_back(panel); |
179 return; | 197 return; |
180 } | 198 } |
181 | 199 |
182 DoRemove(panel); | 200 DoRemove(panel); |
183 } | 201 } |
184 | 202 |
(...skipping 11 matching lines...) Expand all Loading... | |
196 if (panel->expansion_state() != Panel::EXPANDED) | 214 if (panel->expansion_state() != Panel::EXPANDED) |
197 DecrementMinimizedPanels(); | 215 DecrementMinimizedPanels(); |
198 | 216 |
199 gfx::Rect bounds = (*iter)->GetBounds(); | 217 gfx::Rect bounds = (*iter)->GetBounds(); |
200 Rearrange(panels_.erase(iter), bounds.right()); | 218 Rearrange(panels_.erase(iter), bounds.right()); |
201 | 219 |
202 content::NotificationService::current()->Notify( | 220 content::NotificationService::current()->Notify( |
203 chrome::NOTIFICATION_PANEL_REMOVED, | 221 chrome::NOTIFICATION_PANEL_REMOVED, |
204 content::Source<Panel>(panel), | 222 content::Source<Panel>(panel), |
205 content::NotificationService::NoDetails()); | 223 content::NotificationService::NoDetails()); |
224 | |
225 if (num_panels() == 0) | |
dcheng
2011/11/30 01:07:28
Use panels_.empty().
jennb
2011/11/30 02:06:27
Ditto.
prasadt
2011/11/30 02:38:47
Done.
prasadt
2011/11/30 02:38:47
See Jenn's comment.
| |
226 full_screen_mode_timer_.Stop(); | |
206 } | 227 } |
207 | 228 |
208 void PanelManager::StartDragging(Panel* panel) { | 229 void PanelManager::StartDragging(Panel* panel) { |
209 for (size_t i = 0; i < panels_.size(); ++i) { | 230 for (size_t i = 0; i < panels_.size(); ++i) { |
210 if (panels_[i] == panel) { | 231 if (panels_[i] == panel) { |
211 dragging_panel_index_ = i; | 232 dragging_panel_index_ = i; |
212 dragging_panel_bounds_ = panel->GetBounds(); | 233 dragging_panel_bounds_ = panel->GetBounds(); |
213 dragging_panel_original_x_ = dragging_panel_bounds_.x(); | 234 dragging_panel_original_x_ = dragging_panel_bounds_.x(); |
214 break; | 235 break; |
215 } | 236 } |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
644 | 665 |
645 // Start from the bottom to avoid reshuffling. | 666 // Start from the bottom to avoid reshuffling. |
646 for (Panels::reverse_iterator iter = panels_copy.rbegin(); | 667 for (Panels::reverse_iterator iter = panels_copy.rbegin(); |
647 iter != panels_copy.rend(); ++iter) | 668 iter != panels_copy.rend(); ++iter) |
648 (*iter)->Close(); | 669 (*iter)->Close(); |
649 } | 670 } |
650 | 671 |
651 bool PanelManager::is_dragging_panel() const { | 672 bool PanelManager::is_dragging_panel() const { |
652 return dragging_panel_index_ != kInvalidPanelIndex; | 673 return dragging_panel_index_ != kInvalidPanelIndex; |
653 } | 674 } |
OLD | NEW |