summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-18 04:26:01 +0000
committerjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-18 04:26:01 +0000
commit460d3f08d72bd4cddc86d256812d24fc56a704a4 (patch)
tree670473a8e40c58f235586f6e781db8bf45a4c011
parent2c9889636c1234cb9f018ffe5d1dd7efcd2bd9c3 (diff)
downloadchromium_src-460d3f08d72bd4cddc86d256812d24fc56a704a4.zip
chromium_src-460d3f08d72bd4cddc86d256812d24fc56a704a4.tar.gz
chromium_src-460d3f08d72bd4cddc86d256812d24fc56a704a4.tar.bz2
Add StackedPanelCollection to prepare for panel stacking support.
This is almost just a dummy class. BUG=none TEST=none TBR=thakis@chromium.org Review URL: https://chromiumcodereview.appspot.com/11446052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173643 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/panels/detached_panel_collection.cc25
-rw-r--r--chrome/browser/ui/panels/detached_panel_collection.h6
-rw-r--r--chrome/browser/ui/panels/docked_panel_collection.cc21
-rw-r--r--chrome/browser/ui/panels/docked_panel_collection.h3
-rw-r--r--chrome/browser/ui/panels/panel_collection.h7
-rw-r--r--chrome/browser/ui/panels/panel_manager.cc15
-rw-r--r--chrome/browser/ui/panels/stacked_panel_collection.cc145
-rw-r--r--chrome/browser/ui/panels/stacked_panel_collection.h77
-rw-r--r--chrome/chrome_browser_ui.gypi2
9 files changed, 251 insertions, 50 deletions
diff --git a/chrome/browser/ui/panels/detached_panel_collection.cc b/chrome/browser/ui/panels/detached_panel_collection.cc
index b397db6..eb51ce2 100644
--- a/chrome/browser/ui/panels/detached_panel_collection.cc
+++ b/chrome/browser/ui/panels/detached_panel_collection.cc
@@ -24,18 +24,9 @@ DetachedPanelCollection::~DetachedPanelCollection() {
DCHECK(panels_.empty());
}
-gfx::Rect DetachedPanelCollection::GetDisplayArea() const {
- return display_area_;
-}
-
-void DetachedPanelCollection::SetDisplayArea(const gfx::Rect& display_area) {
- if (display_area_ == display_area)
- return;
- gfx::Rect old_display_area = display_area_;
- display_area_ = display_area;
-
- if (panels_.empty())
- return;
+void DetachedPanelCollection::OnDisplayAreaChanged(
+ const gfx::Rect& old_display_area) {
+ const gfx::Rect display_area = panel_manager_->display_area();
for (Panels::const_iterator iter = panels_.begin();
iter != panels_.end(); ++iter) {
@@ -46,16 +37,16 @@ void DetachedPanelCollection::SetDisplayArea(const gfx::Rect& display_area) {
continue;
// Update size if needed.
- panel->LimitSizeToDisplayArea(display_area_);
+ panel->LimitSizeToDisplayArea(display_area);
// Update bounds if needed.
gfx::Rect bounds = panel->GetBounds();
if (panel->full_size() != bounds.size()) {
bounds.set_size(panel->full_size());
- if (bounds.right() > display_area_.right())
- bounds.set_x(display_area_.right() - bounds.width());
- if (bounds.bottom() > display_area_.bottom())
- bounds.set_y(display_area_.bottom() - bounds.height());
+ if (bounds.right() > display_area.right())
+ bounds.set_x(display_area.right() - bounds.width());
+ if (bounds.bottom() > display_area.bottom())
+ bounds.set_y(display_area.bottom() - bounds.height());
panel->SetPanelBoundsInstantly(bounds);
}
}
diff --git a/chrome/browser/ui/panels/detached_panel_collection.h b/chrome/browser/ui/panels/detached_panel_collection.h
index 8497565..1953156 100644
--- a/chrome/browser/ui/panels/detached_panel_collection.h
+++ b/chrome/browser/ui/panels/detached_panel_collection.h
@@ -23,8 +23,7 @@ class DetachedPanelCollection : public PanelCollection {
virtual ~DetachedPanelCollection();
// PanelCollection OVERRIDES:
- virtual gfx::Rect GetDisplayArea() const OVERRIDE;
- virtual void SetDisplayArea(const gfx::Rect& display_area) OVERRIDE;
+ virtual void OnDisplayAreaChanged(const gfx::Rect& old_display_area) OVERRIDE;
virtual void RefreshLayout() OVERRIDE;
virtual void AddPanel(Panel* panel,
PositioningMask positioning_mask) OVERRIDE;
@@ -83,9 +82,6 @@ class DetachedPanelCollection : public PanelCollection {
PanelManager* panel_manager_; // Weak, owns us.
- // All panels in the collection must fit within this area.
- gfx::Rect display_area_;
-
// Collection of all panels.
Panels panels_;
diff --git a/chrome/browser/ui/panels/docked_panel_collection.cc b/chrome/browser/ui/panels/docked_panel_collection.cc
index c4489cb..0f6f616 100644
--- a/chrome/browser/ui/panels/docked_panel_collection.cc
+++ b/chrome/browser/ui/panels/docked_panel_collection.cc
@@ -20,6 +20,11 @@
#include "content/public/browser/notification_source.h"
namespace {
+// Width of spacing around panel collection and the left/right edges of the
+// screen.
+const int kPanelCollectionLeftMargin = 6;
+const int kPanelCollectionRightMargin = 24;
+
// Occasionally some system, like Windows, might not bring up or down the bottom
// bar when the mouse enters or leaves the bottom screen area. This is the
// maximum time we will wait for the bottom bar visibility change notification.
@@ -62,16 +67,12 @@ DockedPanelCollection::~DockedPanelCollection() {
panel_manager_->display_settings_provider()->RemoveDesktopBarObserver(this);
}
-gfx::Rect DockedPanelCollection::GetDisplayArea() const {
- return display_area_;
-}
-
-void DockedPanelCollection::SetDisplayArea(const gfx::Rect& display_area) {
- if (display_area_ == display_area)
- return;
-
- gfx::Rect old_area = display_area_;
- display_area_ = display_area;
+void DockedPanelCollection::OnDisplayAreaChanged(
+ const gfx::Rect& old_display_area) {
+ display_area_ = panel_manager_->display_area();
+ display_area_.set_x(display_area_.x() + kPanelCollectionLeftMargin);
+ display_area_.set_width(display_area_.width() -
+ kPanelCollectionLeftMargin - kPanelCollectionRightMargin);
if (panels_.empty())
return;
diff --git a/chrome/browser/ui/panels/docked_panel_collection.h b/chrome/browser/ui/panels/docked_panel_collection.h
index 3a3e42b..2acbeaf 100644
--- a/chrome/browser/ui/panels/docked_panel_collection.h
+++ b/chrome/browser/ui/panels/docked_panel_collection.h
@@ -30,8 +30,7 @@ class DockedPanelCollection :
virtual ~DockedPanelCollection();
// PanelCollection OVERRIDES:
- virtual gfx::Rect GetDisplayArea() const OVERRIDE;
- virtual void SetDisplayArea(const gfx::Rect& display_area) OVERRIDE;
+ virtual void OnDisplayAreaChanged(const gfx::Rect& old_display_area) OVERRIDE;
// Rearranges the positions of the panels in the collection
// and reduces their width when there is not enough room.
diff --git a/chrome/browser/ui/panels/panel_collection.h b/chrome/browser/ui/panels/panel_collection.h
index 8ba9ef7..3f020a9 100644
--- a/chrome/browser/ui/panels/panel_collection.h
+++ b/chrome/browser/ui/panels/panel_collection.h
@@ -19,6 +19,7 @@ class PanelCollection {
enum Type {
DETACHED, // free-floating panels
DOCKED, // panels are 'docked' along the window's edge
+ STACKED, // panels are stacked together
};
// Masks that control how the panel is added and positioned.
@@ -38,10 +39,8 @@ class PanelCollection {
Type type() const { return type_; }
- // Gets/Sets the bounds of the panel collection.
- // |display_area| is in screen coordinates.
- virtual gfx::Rect GetDisplayArea() const = 0;
- virtual void SetDisplayArea(const gfx::Rect& display_area) = 0;
+ // Called when the display area is changed.
+ virtual void OnDisplayAreaChanged(const gfx::Rect& old_display_area) = 0;
// Updates the positioning of all panels in the collection, usually as
// a result of removing or resizing a panel in collection.
diff --git a/chrome/browser/ui/panels/panel_manager.cc b/chrome/browser/ui/panels/panel_manager.cc
index 8ddd3e2..6be2d42 100644
--- a/chrome/browser/ui/panels/panel_manager.cc
+++ b/chrome/browser/ui/panels/panel_manager.cc
@@ -29,11 +29,6 @@
#endif
namespace {
-// Width of spacing around panel collection and the left/right edges of the
-// screen.
-const int kPanelCollectionLeftMargin = 6;
-const int kPanelCollectionRightMargin = 24;
-
// Maxmium width of a panel is based on a factor of the working area.
#if defined(OS_CHROMEOS)
// ChromeOS device screens are relatively small and limiting the width
@@ -129,15 +124,11 @@ gfx::Point PanelManager::GetDefaultDetachedPanelOrigin() {
void PanelManager::OnDisplayAreaChanged(const gfx::Rect& display_area) {
if (display_area == display_area_)
return;
+ gfx::Rect old_display_area = display_area_;
display_area_ = display_area;
- gfx::Rect dock_bounds = display_area;
- dock_bounds.set_x(display_area.x() + kPanelCollectionLeftMargin);
- dock_bounds.set_width(display_area.width() -
- kPanelCollectionLeftMargin - kPanelCollectionRightMargin);
- docked_collection_->SetDisplayArea(dock_bounds);
-
- detached_collection_->SetDisplayArea(display_area);
+ docked_collection_->OnDisplayAreaChanged(old_display_area);
+ detached_collection_->OnDisplayAreaChanged(old_display_area);
}
void PanelManager::OnFullScreenModeChanged(bool is_full_screen) {
diff --git a/chrome/browser/ui/panels/stacked_panel_collection.cc b/chrome/browser/ui/panels/stacked_panel_collection.cc
new file mode 100644
index 0000000..77de85f
--- /dev/null
+++ b/chrome/browser/ui/panels/stacked_panel_collection.cc
@@ -0,0 +1,145 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/panels/stacked_panel_collection.h"
+
+#include <algorithm>
+#include "base/logging.h"
+#include "chrome/browser/ui/panels/panel.h"
+#include "chrome/browser/ui/panels/panel_manager.h"
+
+StackedPanelCollection::StackedPanelCollection(PanelManager* panel_manager)
+ : PanelCollection(PanelCollection::STACKED),
+ panel_manager_(panel_manager) {
+}
+
+StackedPanelCollection::~StackedPanelCollection() {
+ DCHECK(panels_.empty());
+}
+
+void StackedPanelCollection::OnDisplayAreaChanged(
+ const gfx::Rect& old_display_area) {
+}
+
+void StackedPanelCollection::RefreshLayout() {
+}
+
+void StackedPanelCollection::AddPanel(Panel* panel,
+ PositioningMask positioning_mask) {
+ DCHECK_NE(this, panel->collection());
+ panel->set_collection(this);
+ panels_.push_back(panel);
+
+ RefreshLayout();
+}
+
+void StackedPanelCollection::RemovePanel(Panel* panel) {
+ panel->set_collection(NULL);
+ panels_.remove(panel);
+
+ RefreshLayout();
+}
+
+void StackedPanelCollection::CloseAll() {
+ // Make a copy as closing panels can modify the iterator.
+ Panels panels_copy = panels_;
+
+ for (Panels::const_iterator iter = panels_copy.begin();
+ iter != panels_copy.end(); ++iter)
+ (*iter)->Close();
+}
+
+void StackedPanelCollection::OnPanelAttentionStateChanged(Panel* panel) {
+}
+
+void StackedPanelCollection::OnPanelTitlebarClicked(
+ Panel* panel, panel::ClickModifier modifier) {
+}
+
+void StackedPanelCollection::ResizePanelWindow(
+ Panel* panel,
+ const gfx::Size& preferred_window_size) {
+}
+
+void StackedPanelCollection::ActivatePanel(Panel* panel) {
+}
+
+void StackedPanelCollection::MinimizePanel(Panel* panel) {
+}
+
+void StackedPanelCollection::RestorePanel(Panel* panel) {
+}
+
+void StackedPanelCollection::MinimizeAll() {
+}
+
+void StackedPanelCollection::RestoreAll() {
+}
+
+bool StackedPanelCollection::CanMinimizePanel(const Panel* panel) const {
+ return true;
+}
+
+bool StackedPanelCollection::IsPanelMinimized(const Panel* panel) const {
+ return false;
+}
+
+void StackedPanelCollection::SavePanelPlacement(Panel* panel) {
+}
+
+void StackedPanelCollection::RestorePanelToSavedPlacement() {
+}
+
+void StackedPanelCollection::DiscardSavedPanelPlacement() {
+}
+
+void StackedPanelCollection::StartDraggingPanelWithinCollection(Panel* panel) {
+ DCHECK(HasPanel(panel));
+}
+
+void StackedPanelCollection::DragPanelWithinCollection(
+ Panel* panel,
+ const gfx::Point& target_position) {
+}
+
+void StackedPanelCollection::EndDraggingPanelWithinCollection(Panel* panel,
+ bool aborted) {
+}
+
+void StackedPanelCollection::ClearDraggingStateWhenPanelClosed() {
+}
+
+panel::Resizability StackedPanelCollection::GetPanelResizability(
+ const Panel* panel) const {
+ return panel::RESIZABLE_ALL_SIDES;
+}
+
+void StackedPanelCollection::OnPanelResizedByMouse(
+ Panel* panel, const gfx::Rect& new_bounds) {
+}
+
+bool StackedPanelCollection::HasPanel(Panel* panel) const {
+ return std::find(panels_.begin(), panels_.end(), panel) != panels_.end();
+}
+
+void StackedPanelCollection::UpdatePanelOnCollectionChange(Panel* panel) {
+}
+
+void StackedPanelCollection::OnPanelActiveStateChanged(Panel* panel) {
+}
+
+Panel* StackedPanelCollection::GetPanelAbove(Panel* panel) const {
+ DCHECK(panel);
+
+ if (panels_.size() < 2)
+ return NULL;
+ Panels::const_iterator iter = panels_.begin();
+ Panel* above_panel = *iter;
+ for (; iter != panels_.end(); ++iter) {
+ if (*iter == panel)
+ return above_panel;
+ above_panel = *iter;
+ }
+ return NULL;
+}
diff --git a/chrome/browser/ui/panels/stacked_panel_collection.h b/chrome/browser/ui/panels/stacked_panel_collection.h
new file mode 100644
index 0000000..d998904
--- /dev/null
+++ b/chrome/browser/ui/panels/stacked_panel_collection.h
@@ -0,0 +1,77 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_PANELS_STACKED_PANEL_COLLECTION_H_
+#define CHROME_BROWSER_UI_PANELS_STACKED_PANEL_COLLECTION_H_
+
+#include <list>
+#include <vector>
+#include "base/basictypes.h"
+#include "chrome/browser/ui/panels/panel_collection.h"
+#include "ui/gfx/rect.h"
+
+class PanelManager;
+
+class StackedPanelCollection : public PanelCollection {
+ public:
+ typedef std::list<Panel*> Panels;
+
+ explicit StackedPanelCollection(PanelManager* panel_manager);
+ virtual ~StackedPanelCollection();
+
+ // PanelCollection OVERRIDES:
+ virtual void OnDisplayAreaChanged(const gfx::Rect& old_display_area) OVERRIDE;
+ virtual void RefreshLayout() OVERRIDE;
+ virtual void AddPanel(Panel* panel,
+ PositioningMask positioning_mask) OVERRIDE;
+ virtual void RemovePanel(Panel* panel) OVERRIDE;
+ virtual void CloseAll() OVERRIDE;
+ virtual void ResizePanelWindow(
+ Panel* panel,
+ const gfx::Size& preferred_window_size) OVERRIDE;
+ virtual panel::Resizability GetPanelResizability(
+ const Panel* panel) const OVERRIDE;
+ virtual void OnPanelResizedByMouse(Panel* panel,
+ const gfx::Rect& new_bounds) OVERRIDE;
+ virtual void OnPanelAttentionStateChanged(Panel* panel) OVERRIDE;
+ virtual void OnPanelTitlebarClicked(Panel* panel,
+ panel::ClickModifier modifier) OVERRIDE;
+ virtual void ActivatePanel(Panel* panel) OVERRIDE;
+ virtual void MinimizePanel(Panel* panel) OVERRIDE;
+ virtual void RestorePanel(Panel* panel) OVERRIDE;
+ virtual void MinimizeAll() OVERRIDE;
+ virtual void RestoreAll() OVERRIDE;
+ virtual bool CanMinimizePanel(const Panel* panel) const OVERRIDE;
+ virtual bool IsPanelMinimized(const Panel* panel) const OVERRIDE;
+ virtual void SavePanelPlacement(Panel* panel) OVERRIDE;
+ virtual void RestorePanelToSavedPlacement() OVERRIDE;
+ virtual void DiscardSavedPanelPlacement() OVERRIDE;
+ virtual void StartDraggingPanelWithinCollection(Panel* panel) OVERRIDE;
+ virtual void DragPanelWithinCollection(
+ Panel* panel,
+ const gfx::Point& target_position) OVERRIDE;
+ virtual void EndDraggingPanelWithinCollection(Panel* panel,
+ bool aborted) OVERRIDE;
+ virtual void ClearDraggingStateWhenPanelClosed() OVERRIDE;
+ virtual void UpdatePanelOnCollectionChange(Panel* panel) OVERRIDE;
+ virtual void OnPanelActiveStateChanged(Panel* panel) OVERRIDE;
+
+ Panel* GetPanelAbove(Panel* panel) const;
+ bool HasPanel(Panel* panel) const;
+
+ bool empty() const { return panels_.empty(); }
+ int num_panels() const { return panels_.size(); }
+ const Panels& panels() const { return panels_; }
+ Panel* top_panel() const { return panels_.front(); }
+ Panel* bottom_panel() const { return panels_.back(); }
+
+ private:
+ PanelManager* panel_manager_; // Weak, owns us.
+
+ Panels panels_; // The top panel is in the front of the list.
+
+ DISALLOW_COPY_AND_ASSIGN(StackedPanelCollection);
+};
+
+#endif // CHROME_BROWSER_UI_PANELS_STACKED_PANEL_COLLECTION_H_
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index 3022399..5b9d9da 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -1168,6 +1168,8 @@
'browser/ui/panels/panel_mouse_watcher.h',
'browser/ui/panels/panel_mouse_watcher_observer.h',
'browser/ui/panels/panel_mouse_watcher_timer.cc',
+ 'browser/ui/panels/stacked_panel_collection.cc',
+ 'browser/ui/panels/stacked_panel_collection.h',
'browser/ui/panels/taskbar_window_thumbnailer_win.cc',
'browser/ui/panels/taskbar_window_thumbnailer_win.h',
'browser/ui/pdf/open_pdf_in_reader_prompt_delegate.h',