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

Side by Side Diff: chrome/browser/ui/panels/panel_manager.cc

Issue 11669018: Support dragging panels to stack and snap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix CrOS build for relanding Created 7 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 | Annotate | Revision Log
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 "chrome/browser/ui/panels/panel_manager.h" 5 #include "chrome/browser/ui/panels/panel_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "chrome/browser/ui/panels/detached_panel_collection.h" 12 #include "chrome/browser/ui/panels/detached_panel_collection.h"
13 #include "chrome/browser/ui/panels/docked_panel_collection.h" 13 #include "chrome/browser/ui/panels/docked_panel_collection.h"
14 #include "chrome/browser/ui/panels/panel_drag_controller.h" 14 #include "chrome/browser/ui/panels/panel_drag_controller.h"
15 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" 15 #include "chrome/browser/ui/panels/panel_mouse_watcher.h"
16 #include "chrome/browser/ui/panels/panel_resize_controller.h" 16 #include "chrome/browser/ui/panels/panel_resize_controller.h"
17 #include "chrome/browser/ui/panels/stacked_panel_collection.h"
17 #include "chrome/common/chrome_notification_types.h" 18 #include "chrome/common/chrome_notification_types.h"
18 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/chrome_version_info.h" 20 #include "chrome/common/chrome_version_info.h"
20 #include "content/public/browser/notification_service.h" 21 #include "content/public/browser/notification_service.h"
21 #include "content/public/browser/notification_source.h" 22 #include "content/public/browser/notification_source.h"
22 23
23 #if defined(TOOLKIT_GTK) 24 #if defined(TOOLKIT_GTK)
24 #include "ui/base/x/x11_util.h" 25 #include "ui/base/x/x11_util.h"
25 #endif 26 #endif
26 27
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 133 }
133 134
134 void PanelManager::OnDisplayAreaChanged(const gfx::Rect& display_area) { 135 void PanelManager::OnDisplayAreaChanged(const gfx::Rect& display_area) {
135 if (display_area == display_area_) 136 if (display_area == display_area_)
136 return; 137 return;
137 gfx::Rect old_display_area = display_area_; 138 gfx::Rect old_display_area = display_area_;
138 display_area_ = display_area; 139 display_area_ = display_area;
139 140
140 docked_collection_->OnDisplayAreaChanged(old_display_area); 141 docked_collection_->OnDisplayAreaChanged(old_display_area);
141 detached_collection_->OnDisplayAreaChanged(old_display_area); 142 detached_collection_->OnDisplayAreaChanged(old_display_area);
143 for (Stacks::const_iterator iter = stacks_.begin();
144 iter != stacks_.end(); iter++)
145 (*iter)->OnDisplayAreaChanged(old_display_area);
142 } 146 }
143 147
144 void PanelManager::OnFullScreenModeChanged(bool is_full_screen) { 148 void PanelManager::OnFullScreenModeChanged(bool is_full_screen) {
145 docked_collection_->OnFullScreenModeChanged(is_full_screen); 149 docked_collection_->OnFullScreenModeChanged(is_full_screen);
146 } 150 }
147 151
148 int PanelManager::GetMaxPanelWidth() const { 152 int PanelManager::GetMaxPanelWidth() const {
149 return static_cast<int>(display_area_.width() * kPanelMaxWidthFactor); 153 return static_cast<int>(display_area_.width() * kPanelMaxWidthFactor);
150 } 154 }
151 155
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 drag_controller_->OnPanelClosed(panel); 239 drag_controller_->OnPanelClosed(panel);
236 resize_controller_->OnPanelClosed(panel); 240 resize_controller_->OnPanelClosed(panel);
237 panel->collection()->RemovePanel(panel); 241 panel->collection()->RemovePanel(panel);
238 242
239 content::NotificationService::current()->Notify( 243 content::NotificationService::current()->Notify(
240 chrome::NOTIFICATION_PANEL_CLOSED, 244 chrome::NOTIFICATION_PANEL_CLOSED,
241 content::Source<Panel>(panel), 245 content::Source<Panel>(panel),
242 content::NotificationService::NoDetails()); 246 content::NotificationService::NoDetails());
243 } 247 }
244 248
249 StackedPanelCollection* PanelManager::CreateStack() {
250 StackedPanelCollection* stack = new StackedPanelCollection(this);
251 stacks_.push_back(stack);
252 return stack;
253 }
254
255 void PanelManager::RemoveStack(StackedPanelCollection* stack) {
256 DCHECK_EQ(0, stack->num_panels());
257 stacks_.remove(stack);
258 stack->CloseAll();
259 }
260
245 void PanelManager::StartDragging(Panel* panel, 261 void PanelManager::StartDragging(Panel* panel,
246 const gfx::Point& mouse_location) { 262 const gfx::Point& mouse_location) {
247 drag_controller_->StartDragging(panel, mouse_location); 263 drag_controller_->StartDragging(panel, mouse_location);
248 } 264 }
249 265
250 void PanelManager::Drag(const gfx::Point& mouse_location) { 266 void PanelManager::Drag(const gfx::Point& mouse_location) {
251 drag_controller_->Drag(mouse_location); 267 drag_controller_->Drag(mouse_location);
252 } 268 }
253 269
254 void PanelManager::EndDragging(bool cancelled) { 270 void PanelManager::EndDragging(bool cancelled) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 324 }
309 325
310 void PanelManager::CloseAll() { 326 void PanelManager::CloseAll() {
311 DCHECK(!drag_controller_->is_dragging()); 327 DCHECK(!drag_controller_->is_dragging());
312 328
313 detached_collection_->CloseAll(); 329 detached_collection_->CloseAll();
314 docked_collection_->CloseAll(); 330 docked_collection_->CloseAll();
315 } 331 }
316 332
317 int PanelManager::num_panels() const { 333 int PanelManager::num_panels() const {
318 return detached_collection_->num_panels() + docked_collection_->num_panels(); 334 int count = detached_collection_->num_panels() +
335 docked_collection_->num_panels();
336 for (Stacks::const_iterator iter = stacks_.begin();
337 iter != stacks_.end(); iter++)
338 count += (*iter)->num_panels();
339 return count;
319 } 340 }
320 341
321 std::vector<Panel*> PanelManager::panels() const { 342 std::vector<Panel*> PanelManager::panels() const {
322 std::vector<Panel*> panels; 343 std::vector<Panel*> panels;
323 for (DetachedPanelCollection::Panels::const_iterator iter = 344 for (DetachedPanelCollection::Panels::const_iterator iter =
324 detached_collection_->panels().begin(); 345 detached_collection_->panels().begin();
325 iter != detached_collection_->panels().end(); ++iter) 346 iter != detached_collection_->panels().end(); ++iter)
326 panels.push_back(*iter); 347 panels.push_back(*iter);
327 for (DockedPanelCollection::Panels::const_iterator iter = 348 for (DockedPanelCollection::Panels::const_iterator iter =
328 docked_collection_->panels().begin(); 349 docked_collection_->panels().begin();
329 iter != docked_collection_->panels().end(); ++iter) 350 iter != docked_collection_->panels().end(); ++iter)
330 panels.push_back(*iter); 351 panels.push_back(*iter);
352 for (Stacks::const_iterator stack_iter = stacks_.begin();
353 stack_iter != stacks_.end(); stack_iter++) {
354 for (StackedPanelCollection::Panels::const_iterator iter =
355 (*stack_iter)->panels().begin();
356 iter != (*stack_iter)->panels().end(); ++stack_iter) {
357 panels.push_back(*iter);
358 }
359 }
331 return panels; 360 return panels;
332 } 361 }
333 362
363 std::vector<Panel*> PanelManager::GetDetachedAndStackedPanels() const {
364 std::vector<Panel*> panels;
365 for (DetachedPanelCollection::Panels::const_iterator iter =
366 detached_collection_->panels().begin();
367 iter != detached_collection_->panels().end(); ++iter)
368 panels.push_back(*iter);
369 for (Stacks::const_iterator stack_iter = stacks_.begin();
370 stack_iter != stacks_.end(); stack_iter++) {
371 for (StackedPanelCollection::Panels::const_iterator iter =
372 (*stack_iter)->panels().begin();
373 iter != (*stack_iter)->panels().end(); ++iter) {
374 panels.push_back(*iter);
375 }
376 }
377 return panels;
378 }
379
334 void PanelManager::SetMouseWatcher(PanelMouseWatcher* watcher) { 380 void PanelManager::SetMouseWatcher(PanelMouseWatcher* watcher) {
335 panel_mouse_watcher_.reset(watcher); 381 panel_mouse_watcher_.reset(watcher);
336 } 382 }
337 383
338 void PanelManager::OnPanelAnimationEnded(Panel* panel) { 384 void PanelManager::OnPanelAnimationEnded(Panel* panel) {
339 content::NotificationService::current()->Notify( 385 content::NotificationService::current()->Notify(
340 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, 386 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
341 content::Source<Panel>(panel), 387 content::Source<Panel>(panel),
342 content::NotificationService::NoDetails()); 388 content::NotificationService::NoDetails());
343 } 389 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_manager.h ('k') | chrome/browser/ui/panels/stacked_panel_collection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698