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

Unified 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: avoid panel_create_mode being unused_var in Ash 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/panels/detached_panel_strip.h ('k') | chrome/browser/ui/panels/panel_cocoa_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/panels/detached_panel_strip.cc
diff --git a/chrome/browser/ui/panels/detached_panel_strip.cc b/chrome/browser/ui/panels/detached_panel_strip.cc
index b3c6394fbc9a69bee9c85beae1b4ba8e1b7d357e..c9f59e5514fa5502632e8b42fe166cac924f915a 100644
--- a/chrome/browser/ui/panels/detached_panel_strip.cc
+++ b/chrome/browser/ui/panels/detached_panel_strip.cc
@@ -9,6 +9,12 @@
#include "chrome/browser/ui/panels/panel_drag_controller.h"
#include "chrome/browser/ui/panels/panel_manager.h"
+namespace {
+// How much horizontal and vertical offset there is between newly opened
+// detached panels.
+const int kPanelTilePixels = 10;
+} // namespace
+
DetachedPanelStrip::DetachedPanelStrip(PanelManager* panel_manager)
: PanelStrip(PanelStrip::DETACHED),
panel_manager_(panel_manager) {
@@ -66,6 +72,11 @@ void DetachedPanelStrip::AddPanel(Panel* panel,
DCHECK_NE(this, panel->panel_strip());
panel->set_panel_strip(this);
panels_.insert(panel);
+
+ // Offset the default position of the next detached panel if the current
+ // default position is used.
+ if (panel->GetBounds().origin() == default_panel_origin_)
+ ComputeNextDefaultPanelOrigin();
}
void DetachedPanelStrip::RemovePanel(Panel* panel) {
@@ -228,3 +239,22 @@ void DetachedPanelStrip::UpdatePanelOnStripChange(Panel* panel) {
void DetachedPanelStrip::OnPanelActiveStateChanged(Panel* panel) {
}
+gfx::Point DetachedPanelStrip::GetDefaultPanelOrigin() {
+ if (!default_panel_origin_.x() && !default_panel_origin_.y()) {
+ gfx::Rect display_area =
+ panel_manager_->display_settings_provider()->GetDisplayArea();
+ default_panel_origin_.SetPoint(kPanelTilePixels + display_area.x(),
+ kPanelTilePixels + display_area.y());
+ }
+ return default_panel_origin_;
+}
+
+void DetachedPanelStrip::ComputeNextDefaultPanelOrigin() {
+ default_panel_origin_.Offset(kPanelTilePixels, kPanelTilePixels);
+ gfx::Rect display_area =
+ panel_manager_->display_settings_provider()->GetDisplayArea();
+ if (!display_area.Contains(default_panel_origin_)) {
+ default_panel_origin_.SetPoint(kPanelTilePixels + display_area.x(),
+ kPanelTilePixels + display_area.y());
+ }
+}
« no previous file with comments | « chrome/browser/ui/panels/detached_panel_strip.h ('k') | chrome/browser/ui/panels/panel_cocoa_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698