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

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

Issue 10919046: Allow panels to be created as detached panels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced Created 8 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
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/detached_panel_strip.h" 5 #include "chrome/browser/ui/panels/detached_panel_strip.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/ui/panels/panel_drag_controller.h" 9 #include "chrome/browser/ui/panels/panel_drag_controller.h"
10 #include "chrome/browser/ui/panels/panel_manager.h" 10 #include "chrome/browser/ui/panels/panel_manager.h"
11 11
12 namespace {
13 // How much horizontal and vertical offset there is between newly opened
14 // detached panels.
15 const int kPanelTilePixels = 10;
16 } // namespace
17
12 DetachedPanelStrip::DetachedPanelStrip(PanelManager* panel_manager) 18 DetachedPanelStrip::DetachedPanelStrip(PanelManager* panel_manager)
13 : PanelStrip(PanelStrip::DETACHED), 19 : PanelStrip(PanelStrip::DETACHED),
14 panel_manager_(panel_manager) { 20 panel_manager_(panel_manager) {
15 } 21 }
16 22
17 DetachedPanelStrip::~DetachedPanelStrip() { 23 DetachedPanelStrip::~DetachedPanelStrip() {
18 DCHECK(panels_.empty()); 24 DCHECK(panels_.empty());
19 } 25 }
20 26
21 gfx::Rect DetachedPanelStrip::GetDisplayArea() const { 27 gfx::Rect DetachedPanelStrip::GetDisplayArea() const {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // Nothing needds to be done here: detached panels always stay 65 // Nothing needds to be done here: detached panels always stay
60 // where the user dragged them. 66 // where the user dragged them.
61 } 67 }
62 68
63 void DetachedPanelStrip::AddPanel(Panel* panel, 69 void DetachedPanelStrip::AddPanel(Panel* panel,
64 PositioningMask positioning_mask) { 70 PositioningMask positioning_mask) {
65 // positioning_mask is ignored since the detached panel is free-floating. 71 // positioning_mask is ignored since the detached panel is free-floating.
66 DCHECK_NE(this, panel->panel_strip()); 72 DCHECK_NE(this, panel->panel_strip());
67 panel->set_panel_strip(this); 73 panel->set_panel_strip(this);
68 panels_.insert(panel); 74 panels_.insert(panel);
75
76 // Offset the default position of the next detached panel if the current
77 // default position is used.
78 if (panel->GetBounds().origin() == default_panel_origin_)
79 default_panel_origin_.Offset(kPanelTilePixels, kPanelTilePixels);
jianli 2012/09/04 21:58:47 What if next default panel origin is out of screen
jennb 2012/09/04 23:02:44 Will modify to "wrap-around". Detached panel bound
69 } 80 }
70 81
71 void DetachedPanelStrip::RemovePanel(Panel* panel) { 82 void DetachedPanelStrip::RemovePanel(Panel* panel) {
72 DCHECK_EQ(this, panel->panel_strip()); 83 DCHECK_EQ(this, panel->panel_strip());
73 panel->set_panel_strip(NULL); 84 panel->set_panel_strip(NULL);
74 panels_.erase(panel); 85 panels_.erase(panel);
75 } 86 }
76 87
77 void DetachedPanelStrip::CloseAll() { 88 void DetachedPanelStrip::CloseAll() {
78 // Make a copy as closing panels can modify the iterator. 89 // Make a copy as closing panels can modify the iterator.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 static_cast<Panel::AttentionMode>(Panel::USE_PANEL_ATTENTION | 232 static_cast<Panel::AttentionMode>(Panel::USE_PANEL_ATTENTION |
222 Panel::USE_SYSTEM_ATTENTION)); 233 Panel::USE_SYSTEM_ATTENTION));
223 panel->SetAlwaysOnTop(false); 234 panel->SetAlwaysOnTop(false);
224 panel->EnableResizeByMouse(true); 235 panel->EnableResizeByMouse(true);
225 panel->UpdateMinimizeRestoreButtonVisibility(); 236 panel->UpdateMinimizeRestoreButtonVisibility();
226 } 237 }
227 238
228 void DetachedPanelStrip::OnPanelActiveStateChanged(Panel* panel) { 239 void DetachedPanelStrip::OnPanelActiveStateChanged(Panel* panel) {
229 } 240 }
230 241
242 const gfx::Point& DetachedPanelStrip::GetDefaultPanelOrigin() {
243 if (!default_panel_origin_.x() && !default_panel_origin_.y()) {
244 gfx::Rect display_area =
245 panel_manager_->display_settings_provider()->GetDisplayArea();
246 default_panel_origin_.SetPoint(kPanelTilePixels + display_area.x(),
247 kPanelTilePixels + display_area.y());
248 }
249 return default_panel_origin_;
250 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698