summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/panels
diff options
context:
space:
mode:
authornick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-13 23:21:26 +0000
committernick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-13 23:21:26 +0000
commitc3f64b5090840a5124cb7c929af6eb8e95dbd592 (patch)
tree66b03de2e73c73f0f001b35d025d22482bf88efb /chrome/browser/ui/panels
parenta785dab62712680006d9152b584a280ef0b97fcd (diff)
downloadchromium_src-c3f64b5090840a5124cb7c929af6eb8e95dbd592.zip
chromium_src-c3f64b5090840a5124cb7c929af6eb8e95dbd592.tar.gz
chromium_src-c3f64b5090840a5124cb7c929af6eb8e95dbd592.tar.bz2
[Reason for revert: broken the Linux build]
Revert 81502 - Panels: Fix where Browser::window_ is set. Fill in code to get work area.BUG=NoneTEST=NoneReview URL: http://codereview.chromium.org/6828003 TBR=jennb@chromium.org Review URL: http://codereview.chromium.org/6850004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81504 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/panels')
-rw-r--r--chrome/browser/ui/panels/display_settings.h16
-rw-r--r--chrome/browser/ui/panels/panel.h7
-rw-r--r--chrome/browser/ui/panels/panel_manager.cc32
-rw-r--r--chrome/browser/ui/panels/panel_manager.h10
4 files changed, 38 insertions, 27 deletions
diff --git a/chrome/browser/ui/panels/display_settings.h b/chrome/browser/ui/panels/display_settings.h
new file mode 100644
index 0000000..5c79f83
--- /dev/null
+++ b/chrome/browser/ui/panels/display_settings.h
@@ -0,0 +1,16 @@
+// Copyright (c) 2011 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_DISPLAY_SETTINGS_H_
+#define CHROME_BROWSER_UI_PANELS_DISPLAY_SETTINGS_H_
+#pragma once
+
+namespace gfx {
+class Rect;
+}
+
+// TODO (jianli): to be implemented.
+void GetMainScreenWorkArea(gfx::Rect* bounds) { }
+
+#endif // CHROME_BROWSER_UI_PANELS_DISPLAY_SETTINGS_H_
diff --git a/chrome/browser/ui/panels/panel.h b/chrome/browser/ui/panels/panel.h
index e692af19..eda3ad6 100644
--- a/chrome/browser/ui/panels/panel.h
+++ b/chrome/browser/ui/panels/panel.h
@@ -25,6 +25,7 @@ class PanelManager;
// other Panels. For example deleting a panel would rearrange other panels.
class Panel : public BrowserWindow {
public:
+ Panel(Browser* browser, const gfx::Rect& bounds);
virtual ~Panel();
// Returns the PanelManager associated with this panel.
@@ -132,15 +133,11 @@ class Panel : public BrowserWindow {
virtual void DestroyBrowser();
private:
- friend class PanelManager;
-
- // Panel can only be created using PanelManager::CreatePanel().
- Panel(Browser* browser, const gfx::Rect& bounds);
-
// Platform specifc BrowserWindow implementation for panels. It'd be one of
// PanelBrowserWindowGtk/PanelBrowserView/PanelBrowserWindowCocoa.
scoped_ptr<BrowserWindow> browser_window_;
+ // The bounds.
gfx::Rect bounds_;
// Is the panel minimized?
diff --git a/chrome/browser/ui/panels/panel_manager.cc b/chrome/browser/ui/panels/panel_manager.cc
index d78f84b..af63b35 100644
--- a/chrome/browser/ui/panels/panel_manager.cc
+++ b/chrome/browser/ui/panels/panel_manager.cc
@@ -8,8 +8,8 @@
#include "base/logging.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/panels/display_settings.h"
#include "chrome/browser/ui/panels/panel.h"
-#include "chrome/browser/ui/window_sizer.h"
namespace {
// Invalid panel index.
@@ -51,35 +51,32 @@ PanelManager::PanelManager()
bottom_edge_y_(0),
dragging_panel_index_(kInvalidPanelIndex),
dragging_panel_original_x_(0) {
- OnDisplayChanged();
+ OnDisplaySettingsChanged();
}
PanelManager::~PanelManager() {
- DCHECK(active_panels_.empty());
- DCHECK(pending_panels_.empty());
- DCHECK(panels_pending_to_remove_.empty());
}
-void PanelManager::OnDisplayChanged() {
- scoped_ptr<WindowSizer::MonitorInfoProvider> info_provider(
- WindowSizer::CreateDefaultMonitorInfoProvider());
- gfx::Rect work_area = info_provider->GetPrimaryMonitorWorkArea();
+void PanelManager::OnDisplaySettingsChanged() {
+ gfx::Rect work_area;
+ GetMainScreenWorkArea(&work_area);
min_x_ = work_area.x();
current_x_ = work_area.right();
bottom_edge_y_ = work_area.bottom();
+
max_width_ = static_cast<int>(work_area.width() * kPanelMaxWidthFactor);
max_height_ = static_cast<int>(work_area.height() * kPanelMaxHeightFactor);
Rearrange(active_panels_.begin());
}
-Panel* PanelManager::CreatePanel(Browser* browser) {
+Panel* PanelManager::Create(Browser* browser) {
gfx::Rect bounds = browser->override_bounds();
- bool is_within_bounds = ComputeBoundsForNextPanel(&bounds, true);
+ bool success = ComputeBoundsForNextPanel(&bounds, true);
Panel* panel = new Panel(browser, bounds);
- if (is_within_bounds)
+ if (success)
active_panels_.push_back(panel);
else
pending_panels_.push_back(panel);
@@ -91,11 +88,12 @@ void PanelManager::ProcessPending() {
while (!pending_panels_.empty()) {
Panel* panel = pending_panels_.front();
gfx::Rect bounds = panel->bounds();
- if (ComputeBoundsForNextPanel(&bounds, true)) {
- // TODO(jianli): More work to support displaying pending panels.
- active_panels_.push_back(panel);
- pending_panels_.pop_front();
- }
+ bool success = ComputeBoundsForNextPanel(&bounds, true);
+ if (!success)
+ return;
+ // TODO(jianli): More work to be done to support displaying pending panels.
+ active_panels_.push_back(panel);
+ pending_panels_.pop_front();
}
}
diff --git a/chrome/browser/ui/panels/panel_manager.h b/chrome/browser/ui/panels/panel_manager.h
index a209904..79689ec 100644
--- a/chrome/browser/ui/panels/panel_manager.h
+++ b/chrome/browser/ui/panels/panel_manager.h
@@ -23,12 +23,12 @@ class PanelManager {
~PanelManager();
- // Called when the display is changed, i.e. work area is updated.
- void OnDisplayChanged();
+ // Called when the display settings are changed, i.e. work area is updated.
+ void OnDisplaySettingsChanged();
// Creates a panel and returns it. The panel might be queued for display
// later.
- Panel* CreatePanel(Browser* browser);
+ Panel* Create(Browser* browser);
// Removes the given panel. Both active and pending panel lists are checked.
// If an active panel is removed, pending panels could put on display if we
@@ -79,8 +79,8 @@ class PanelManager {
// Computes the bounds for next panel.
// |allow_size_change| is used to indicate if the panel size can be changed to
- // fall within the size constraint, e.g., when the panel is created.
- // Returns true if computed bounds are within the displayable area.
+ // fall within the size constraint. This is the case we add the panel for the
+ // first time.
bool ComputeBoundsForNextPanel(gfx::Rect* bounds, bool allow_size_change);
// Help functions to drag the given panel.