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

Unified Diff: chrome/browser/ui/panels/panel_strip.h

Issue 8744005: Refactor PanelManager to create PanelStrip. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address nits Created 9 years, 1 month 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/panel_mouse_watcher.h ('k') | chrome/browser/ui/panels/panel_strip.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/panels/panel_strip.h
diff --git a/chrome/browser/ui/panels/panel_manager.h b/chrome/browser/ui/panels/panel_strip.h
similarity index 54%
copy from chrome/browser/ui/panels/panel_manager.h
copy to chrome/browser/ui/panels/panel_strip.h
index ce78dbe50b283c9aff941975f9be4ffd31ed8dd7..a2a8d7680aa3f7e9eed621ae9c9d1a6ae6ff1b1c 100644
--- a/chrome/browser/ui/panels/panel_manager.h
+++ b/chrome/browser/ui/panels/panel_strip.h
@@ -2,42 +2,42 @@
// 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_PANEL_MANAGER_H_
-#define CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_
+#ifndef CHROME_BROWSER_UI_PANELS_PANEL_STRIP_H_
+#define CHROME_BROWSER_UI_PANELS_PANEL_STRIP_H_
#pragma once
#include <vector>
#include "base/basictypes.h"
-#include "base/lazy_instance.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/panels/auto_hiding_desktop_bar.h"
-#include "chrome/browser/ui/panels/panel.h"
#include "chrome/browser/ui/panels/panel_mouse_watcher_observer.h"
+#include "chrome/browser/ui/panels/panel.h"
#include "ui/gfx/rect.h"
class Browser;
-class Panel;
-class PanelMouseWatcher;
+class PanelManager;
-// This class manages a set of panels.
-// Note that the ref count is needed by using PostTask in the implementation.
-class PanelManager : public PanelMouseWatcherObserver,
- public AutoHidingDesktopBar::Observer {
+// This class manages a group of panels displayed in a horizontal strip,
+// positioning the panels and controlling how they are displayed.
+// Panels in the strip appear minimized, showing title-only or expanded.
+// All panels in the strip are contained within the bounds of the strip.
+class PanelStrip : public PanelMouseWatcherObserver {
public:
typedef std::vector<Panel*> Panels;
- // Returns a single instance.
- static PanelManager* GetInstance();
+ explicit PanelStrip(PanelManager* panel_manager);
+ virtual ~PanelStrip();
- // Called when the display is changed, i.e. work area is updated.
- void OnDisplayChanged();
+ // Sets the bounds of the panel strip.
+ // |bounds| is in screen coordinates.
+ void SetBounds(const gfx::Rect bounds);
- // Creates a panel and returns it. The panel might be queued for display
- // later.
- Panel* CreatePanel(Browser* browser);
+ // Adds a panel to the strip. The panel may be a newly created panel or one
+ // that is transitioning from another grouping of panels.
+ void AddPanel(Panel* panel);
- void Remove(Panel* panel);
+ // Returns |false| if the panel is not in the strip.
+ bool Remove(Panel* panel);
void RemoveAll();
// Drags the given panel.
@@ -67,11 +67,6 @@ class PanelManager : public PanelMouseWatcherObserver,
int GetBottomPositionForExpansionState(
Panel::ExpansionState expansion_state) const;
- // Returns the next browser window which could be either panel window or
- // tabbed window, to switch to if the given panel is going to be deactivated.
- // Returns NULL if such window cannot be found.
- BrowserWindow* GetNextBrowserWindowToActivate(Panel* panel) const;
-
int num_panels() const { return panels_.size(); }
bool is_dragging_panel() const;
const Panels& panels() const { return panels_; }
@@ -80,39 +75,16 @@ class PanelManager : public PanelMouseWatcherObserver,
int GetMaxPanelHeight() const;
int StartingRightPosition() const;
- // Moves a panel to the panel strip. The panel does not currently
- // belong in any other strip. This may cause other panels to be
- // bumped out of the panel strip.
- void MoveToPanelStrip(Panel* panel);
-
- // Moves a panel to the overflow strip. The panel does not currently
- // belong in any other strip.
- // |is_new| is true if the panel was just created.
- void MoveToOverflowStrip(Panel* panel, bool is_new);
-
// Overridden from PanelMouseWatcherObserver:
virtual void OnMouseMove(const gfx::Point& mouse_position) OVERRIDE;
+ void OnAutoHidingDesktopBarVisibilityChanged(
+ AutoHidingDesktopBar::Alignment alignment,
+ AutoHidingDesktopBar::Visibility visibility);
+
#ifdef UNIT_TEST
static int horizontal_spacing() { return kPanelsHorizontalSpacing; }
- const gfx::Rect& work_area() const {
- return work_area_;
- }
-
- void set_auto_hiding_desktop_bar(
- AutoHidingDesktopBar* auto_hiding_desktop_bar) {
- auto_hiding_desktop_bar_ = auto_hiding_desktop_bar;
- }
-
- void enable_auto_sizing(bool enabled) {
- auto_sizing_enabled_ = enabled;
- }
-
- void SetWorkAreaForTesting(const gfx::Rect& work_area) {
- SetWorkArea(work_area);
- }
-
void remove_delays_for_testing() {
remove_delays_for_testing_ = true;
}
@@ -120,38 +92,18 @@ class PanelManager : public PanelMouseWatcherObserver,
int minimized_panel_count() {
return minimized_panel_count_;
}
-
- // Tests should disable mouse watching if mouse movements will be simulated.
- void disable_mouse_watching() {
- mouse_watching_disabled_ = true;
- }
#endif
private:
- friend struct base::DefaultLazyInstanceTraits<PanelManager>;
- FRIEND_TEST_ALL_PREFIXES(PanelBrowserTest, SizeClamping);
-
enum TitlebarAction {
NO_ACTION,
BRING_UP,
BRING_DOWN
};
- PanelManager();
- virtual ~PanelManager();
-
- // Overridden from AutoHidingDesktopBar::Observer:
- virtual void OnAutoHidingDesktopBarThicknessChanged() OVERRIDE;
- virtual void OnAutoHidingDesktopBarVisibilityChanged(
- AutoHidingDesktopBar::Alignment alignment,
- AutoHidingDesktopBar::Visibility visibility) OVERRIDE;
-
- // Applies the new work area. This is called by OnDisplayChanged and the test
- // code.
- void SetWorkArea(const gfx::Rect& work_area);
-
- // Adjusts the work area to exclude the influence of auto-hiding desktop bars.
- void AdjustWorkAreaForAutoHidingDesktopBars();
+ // Helper functions to add a panel to the strip.
+ void AddNewPanel(Panel* panel);
+ void AddExistingPanel(Panel* panel);
// Keep track of the minimized panels to control mouse watching.
void IncrementMinimizedPanels();
@@ -180,29 +132,20 @@ class PanelManager : public PanelMouseWatcherObserver,
int GetRightMostAvailablePosition() const;
+ PanelManager* panel_manager_; // Weak, owns us.
+
+ // All panels in the panel strip must fit within this area.
+ gfx::Rect strip_bounds_;
+
Panels panels_;
// Stores the panels that are pending to remove. We want to delay the removal
// when we're in the process of the dragging.
Panels panels_pending_to_remove_;
- // Use a mouse watcher to know when to bring up titlebars to "peek" at
- // minimized panels. Mouse movement is only tracked when there is a minimized
- // panel.
- scoped_ptr<PanelMouseWatcher> panel_mouse_watcher_;
int minimized_panel_count_;
bool are_titlebars_up_;
- // The maximum work area avaialble. This area does not include the area taken
- // by the always-visible (non-auto-hiding) desktop bars.
- gfx::Rect work_area_;
-
- // The useable work area for computing the panel bounds. This area excludes
- // the potential area that could be taken by the auto-hiding desktop
- // bars (we only consider those bars that are aligned to bottom, left, and
- // right of the screen edges) when they become fully visible.
- gfx::Rect adjusted_work_area_;
-
// Panel to drag.
size_t dragging_panel_index_;
@@ -215,21 +158,12 @@ class PanelManager : public PanelMouseWatcherObserver,
// to when the dragging ends.
gfx::Rect dragging_panel_bounds_;
- scoped_refptr<AutoHidingDesktopBar> auto_hiding_desktop_bar_;
-
// Delayed transitions support. Sometimes transitions between minimized and
// title-only states are delayed, for better usability with Taskbars/Docks.
TitlebarAction delayed_titlebar_action_;
bool remove_delays_for_testing_;
// Owned by MessageLoop after posting.
- base::WeakPtrFactory<PanelManager> titlebar_action_factory_;
-
- // Whether or not bounds will be updated when the preferred content size is
- // changed. The testing code could set this flag to false so that other tests
- // will not be affected.
- bool auto_sizing_enabled_;
-
- bool mouse_watching_disabled_; // For tests to simulate mouse movements.
+ base::WeakPtrFactory<PanelStrip> titlebar_action_factory_;
static const int kPanelsHorizontalSpacing = 4;
@@ -239,7 +173,7 @@ class PanelManager : public PanelMouseWatcherObserver,
static const int kPanelMinWidth;
static const int kPanelMinHeight;
- DISALLOW_COPY_AND_ASSIGN(PanelManager);
+ DISALLOW_COPY_AND_ASSIGN(PanelStrip);
};
-#endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_
+#endif // CHROME_BROWSER_UI_PANELS_PANEL_STRIP_H_
« no previous file with comments | « chrome/browser/ui/panels/panel_mouse_watcher.h ('k') | chrome/browser/ui/panels/panel_strip.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698