OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_STRIP_H_ | 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_STRIP_H_ |
6 #define CHROME_BROWSER_UI_PANELS_PANEL_STRIP_H_ | 6 #define CHROME_BROWSER_UI_PANELS_PANEL_STRIP_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "chrome/browser/ui/panels/auto_hiding_desktop_bar.h" | 12 #include "chrome/browser/ui/panels/auto_hiding_desktop_bar.h" |
| 13 #include "chrome/browser/ui/panels/panel.h" |
13 #include "chrome/browser/ui/panels/panel_mouse_watcher_observer.h" | 14 #include "chrome/browser/ui/panels/panel_mouse_watcher_observer.h" |
14 #include "chrome/browser/ui/panels/panel.h" | |
15 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
16 | 16 |
17 class Browser; | 17 class Browser; |
18 class PanelManager; | 18 class PanelManager; |
19 | 19 |
20 // This class manages a group of panels displayed in a horizontal strip, | 20 // This class manages a group of panels displayed in a horizontal strip, |
21 // positioning the panels and controlling how they are displayed. | 21 // positioning the panels and controlling how they are displayed. |
22 // Panels in the strip appear minimized, showing title-only or expanded. | 22 // Panels in the strip appear minimized, showing title-only or expanded. |
23 // All panels in the strip are contained within the bounds of the strip. | 23 // All panels in the strip are contained within the bounds of the strip. |
24 class PanelStrip : public PanelMouseWatcherObserver { | 24 class PanelStrip : public PanelMouseWatcherObserver { |
25 public: | 25 public: |
26 typedef std::vector<Panel*> Panels; | 26 typedef std::vector<Panel*> Panels; |
27 | 27 |
28 explicit PanelStrip(PanelManager* panel_manager); | 28 explicit PanelStrip(PanelManager* panel_manager); |
29 virtual ~PanelStrip(); | 29 virtual ~PanelStrip(); |
30 | 30 |
31 // Sets the bounds of the panel strip. | 31 // Sets the bounds of the panel strip. |
32 // |bounds| is in screen coordinates. | 32 // |area| is in screen coordinates. |
33 void SetDisplayArea(const gfx::Rect& area); | 33 void SetDisplayArea(const gfx::Rect& area); |
34 | 34 |
35 // Adds a panel to the strip. The panel may be a newly created panel or one | 35 // Adds a panel to the strip. The panel may be a newly created panel or one |
36 // that is transitioning from another grouping of panels. | 36 // that is transitioning from another grouping of panels. |
37 void AddPanel(Panel* panel); | 37 void AddPanel(Panel* panel); |
38 | 38 |
39 // Returns |false| if the panel is not in the strip. | 39 // Returns |false| if the panel is not in the strip. |
40 bool Remove(Panel* panel); | 40 bool Remove(Panel* panel); |
41 void RemoveAll(); | 41 void RemoveAll(); |
42 | 42 |
43 // Drags the given panel. | 43 // Drags the given panel. |
44 void StartDragging(Panel* panel); | 44 void StartDragging(Panel* panel); |
45 void Drag(int delta_x); | 45 void Drag(int delta_x); |
46 void EndDragging(bool cancelled); | 46 void EndDragging(bool cancelled); |
47 | 47 |
48 // Invoked when a panel's expansion state changes. | 48 // Invoked when a panel's expansion state changes. |
49 void OnPanelExpansionStateChanged(Panel::ExpansionState old_state, | 49 void OnPanelExpansionStateChanged(Panel* panel, |
50 Panel::ExpansionState new_state); | 50 Panel::ExpansionState old_state); |
51 | 51 |
52 // Invoked when the preferred window size of the given panel might need to | 52 // Invoked when the preferred window size of the given panel might need to |
53 // get changed. | 53 // get changed. |
54 void OnPreferredWindowSizeChanged( | 54 void OnPreferredWindowSizeChanged( |
55 Panel* panel, const gfx::Size& preferred_window_size); | 55 Panel* panel, const gfx::Size& preferred_window_size); |
56 | 56 |
57 // Returns true if we should bring up the titlebars, given the current mouse | 57 // Returns true if we should bring up the titlebars, given the current mouse |
58 // point. | 58 // point. |
59 bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const; | 59 bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const; |
60 | 60 |
61 // Brings up or down the titlebars for all minimized panels. | 61 // Brings up or down the titlebars for all minimized panels. |
62 void BringUpOrDownTitlebars(bool bring_up); | 62 void BringUpOrDownTitlebars(bool bring_up); |
63 | 63 |
64 // Returns the bottom position for the panel per its expansion state. If auto- | 64 // Returns the bottom position for the panel per its expansion state. If auto- |
65 // hide bottom bar is present, we want to move the minimized panel to the | 65 // hide bottom bar is present, we want to move the minimized panel to the |
66 // bottom of the screen, not the bottom of the work area. | 66 // bottom of the screen, not the bottom of the work area. |
67 int GetBottomPositionForExpansionState( | 67 int GetBottomPositionForExpansionState( |
68 Panel::ExpansionState expansion_state) const; | 68 Panel::ExpansionState expansion_state) const; |
69 | 69 |
70 int num_panels() const { return panels_.size(); } | 70 int num_panels() const { return panels_.size(); } |
71 bool is_dragging_panel() const; | 71 bool is_dragging_panel() const; |
72 const Panels& panels() const { return panels_; } | 72 const Panels& panels() const { return panels_; } |
| 73 gfx::Rect display_area() const { return display_area_; } |
73 | 74 |
74 int GetMaxPanelWidth() const; | 75 int GetMaxPanelWidth() const; |
75 int GetMaxPanelHeight() const; | 76 int GetMaxPanelHeight() const; |
76 int StartingRightPosition() const; | 77 int StartingRightPosition() const; |
77 | 78 |
78 // Overridden from PanelMouseWatcherObserver: | |
79 virtual void OnMouseMove(const gfx::Point& mouse_position) OVERRIDE; | |
80 | |
81 void OnAutoHidingDesktopBarVisibilityChanged( | 79 void OnAutoHidingDesktopBarVisibilityChanged( |
82 AutoHidingDesktopBar::Alignment alignment, | 80 AutoHidingDesktopBar::Alignment alignment, |
83 AutoHidingDesktopBar::Visibility visibility); | 81 AutoHidingDesktopBar::Visibility visibility); |
84 | 82 |
85 void OnFullScreenModeChanged(bool is_full_screen); | 83 void OnFullScreenModeChanged(bool is_full_screen); |
86 | 84 |
87 #ifdef UNIT_TEST | 85 #ifdef UNIT_TEST |
88 static int horizontal_spacing() { return kPanelsHorizontalSpacing; } | 86 static int horizontal_spacing() { return kPanelsHorizontalSpacing; } |
89 | 87 |
90 void remove_delays_for_testing() { | 88 void remove_delays_for_testing() { |
91 remove_delays_for_testing_ = true; | 89 remove_delays_for_testing_ = true; |
92 } | 90 } |
93 | 91 |
94 int minimized_panel_count() { | 92 int minimized_panel_count() { |
95 return minimized_panel_count_; | 93 return minimized_panel_count_; |
96 } | 94 } |
97 #endif | 95 #endif |
98 | 96 |
99 private: | 97 private: |
100 enum TitlebarAction { | 98 enum TitlebarAction { |
101 NO_ACTION, | 99 NO_ACTION, |
102 BRING_UP, | 100 BRING_UP, |
103 BRING_DOWN | 101 BRING_DOWN |
104 }; | 102 }; |
105 | 103 |
| 104 // Overridden from PanelMouseWatcherObserver: |
| 105 virtual void OnMouseMove(const gfx::Point& mouse_position) OVERRIDE; |
| 106 |
106 // Keep track of the minimized panels to control mouse watching. | 107 // Keep track of the minimized panels to control mouse watching. |
107 void IncrementMinimizedPanels(); | 108 void IncrementMinimizedPanels(); |
108 void DecrementMinimizedPanels(); | 109 void DecrementMinimizedPanels(); |
109 | 110 |
110 // Handles all the panels that're delayed to be removed. | 111 // Handles all the panels that're delayed to be removed. |
111 void DelayedRemove(); | 112 void DelayedRemove(); |
112 | 113 |
113 // Does the actual remove. Caller is responsible for rearranging | 114 // Does the actual remove. Caller is responsible for rearranging |
114 // the panel strip if necessary. | 115 // the panel strip if necessary. |
115 // Returns |false| if panel is not in the strip. | 116 // Returns |false| if panel is not in the strip. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 // Absolute minimum width and height for panels, including non-client area. | 186 // Absolute minimum width and height for panels, including non-client area. |
186 // Should only be big enough to accomodate a close button on the reasonably | 187 // Should only be big enough to accomodate a close button on the reasonably |
187 // recognisable titlebar. | 188 // recognisable titlebar. |
188 static const int kPanelMinWidth; | 189 static const int kPanelMinWidth; |
189 static const int kPanelMinHeight; | 190 static const int kPanelMinHeight; |
190 | 191 |
191 DISALLOW_COPY_AND_ASSIGN(PanelStrip); | 192 DISALLOW_COPY_AND_ASSIGN(PanelStrip); |
192 }; | 193 }; |
193 | 194 |
194 #endif // CHROME_BROWSER_UI_PANELS_PANEL_STRIP_H_ | 195 #endif // CHROME_BROWSER_UI_PANELS_PANEL_STRIP_H_ |
OLD | NEW |