| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_DOCKED_PANEL_STRIP_H_ | 5 #ifndef CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_STRIP_H_ |
| 6 #define CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_STRIP_H_ | 6 #define CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_STRIP_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 virtual void CloseAll() OVERRIDE; | 47 virtual void CloseAll() OVERRIDE; |
| 48 virtual void ResizePanelWindow( | 48 virtual void ResizePanelWindow( |
| 49 Panel* panel, | 49 Panel* panel, |
| 50 const gfx::Size& preferred_window_size) OVERRIDE; | 50 const gfx::Size& preferred_window_size) OVERRIDE; |
| 51 virtual void OnPanelAttentionStateChanged(Panel* panel) OVERRIDE; | 51 virtual void OnPanelAttentionStateChanged(Panel* panel) OVERRIDE; |
| 52 virtual void ActivatePanel(Panel* panel) OVERRIDE; | 52 virtual void ActivatePanel(Panel* panel) OVERRIDE; |
| 53 virtual void MinimizePanel(Panel* panel) OVERRIDE; | 53 virtual void MinimizePanel(Panel* panel) OVERRIDE; |
| 54 virtual void RestorePanel(Panel* panel) OVERRIDE; | 54 virtual void RestorePanel(Panel* panel) OVERRIDE; |
| 55 virtual bool IsPanelMinimized(const Panel* panel) const OVERRIDE; | 55 virtual bool IsPanelMinimized(const Panel* panel) const OVERRIDE; |
| 56 virtual bool CanShowPanelAsActive(const Panel* panel) const OVERRIDE; | 56 virtual bool CanShowPanelAsActive(const Panel* panel) const OVERRIDE; |
| 57 virtual void SavePanelPlacement(Panel* panel) OVERRIDE; |
| 58 virtual void RestorePanelToSavedPlacement() OVERRIDE; |
| 59 virtual void DiscardSavedPanelPlacement() OVERRIDE; |
| 57 virtual bool CanDragPanel(const Panel* panel) const OVERRIDE; | 60 virtual bool CanDragPanel(const Panel* panel) const OVERRIDE; |
| 58 virtual void StartDraggingPanel(Panel* panel) OVERRIDE; | 61 virtual void StartDraggingPanelWithinStrip(Panel* panel) OVERRIDE; |
| 59 virtual void DragPanel(Panel* panel, int delta_x, int delta_y) OVERRIDE; | 62 virtual void DragPanelWithinStrip(Panel* panel, |
| 60 virtual void EndDraggingPanel(Panel* panel, bool cancelled) OVERRIDE; | 63 int delta_x, |
| 64 int delta_y) OVERRIDE; |
| 65 virtual void EndDraggingPanelWithinStrip(Panel* panel, |
| 66 bool aborted) OVERRIDE; |
| 61 | 67 |
| 62 // Invoked when a panel's expansion state changes. | 68 // Invoked when a panel's expansion state changes. |
| 63 void OnPanelExpansionStateChanged(Panel* panel); | 69 void OnPanelExpansionStateChanged(Panel* panel); |
| 64 | 70 |
| 65 // Returns true if we should bring up the titlebars, given the current mouse | 71 // Returns true if we should bring up the titlebars, given the current mouse |
| 66 // point. | 72 // point. |
| 67 bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const; | 73 bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const; |
| 68 | 74 |
| 69 // Brings up or down the titlebars for all minimized panels. | 75 // Brings up or down the titlebars for all minimized panels. |
| 70 void BringUpOrDownTitlebars(bool bring_up); | 76 void BringUpOrDownTitlebars(bool bring_up); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 } | 108 } |
| 103 #endif | 109 #endif |
| 104 | 110 |
| 105 private: | 111 private: |
| 106 enum TitlebarAction { | 112 enum TitlebarAction { |
| 107 NO_ACTION, | 113 NO_ACTION, |
| 108 BRING_UP, | 114 BRING_UP, |
| 109 BRING_DOWN | 115 BRING_DOWN |
| 110 }; | 116 }; |
| 111 | 117 |
| 118 struct PanelPlacement { |
| 119 Panel* panel; |
| 120 // Used to remember the panel to the left of |panel|, if any, for use when |
| 121 // restoring the position of |panel|. Will be updated if this panel is |
| 122 // closed. |
| 123 Panel* left_panel_; |
| 124 |
| 125 PanelPlacement() : panel(NULL) { } |
| 126 }; |
| 127 |
| 112 // Overridden from PanelMouseWatcherObserver: | 128 // Overridden from PanelMouseWatcherObserver: |
| 113 virtual void OnMouseMove(const gfx::Point& mouse_position) OVERRIDE; | 129 virtual void OnMouseMove(const gfx::Point& mouse_position) OVERRIDE; |
| 114 | 130 |
| 131 // Helper methods to put the panel to the collection. |
| 132 void InsertPreviewedPanel(Panel* panel); |
| 133 void InsertExistingPanel(Panel* panel); |
| 134 void InsertNewlyCreatedPanel(Panel* panel); |
| 135 |
| 136 // Ensures that there is sufficient space in the strip to add a panel with |
| 137 // the specified width. We might need to bump panels in the strip to make |
| 138 // room for this panel. |
| 139 void EnsureAvailableSpace(int width); |
| 140 |
| 115 // Keep track of the minimized panels to control mouse watching. | 141 // Keep track of the minimized panels to control mouse watching. |
| 116 void IncrementMinimizedPanels(); | 142 void IncrementMinimizedPanels(); |
| 117 void DecrementMinimizedPanels(); | 143 void DecrementMinimizedPanels(); |
| 118 | 144 |
| 119 // Help functions to drag the given panel. | 145 // Help functions to drag the given panel. |
| 120 void DragLeft(Panel* dragging_panel); | 146 void DragLeft(Panel* dragging_panel); |
| 121 void DragRight(Panel* dragging_panel); | 147 void DragRight(Panel* dragging_panel); |
| 122 | 148 |
| 123 // Does the real job of bringing up or down the titlebars. | 149 // Does the real job of bringing up or down the titlebars. |
| 124 void DoBringUpOrDownTitlebars(bool bring_up); | 150 void DoBringUpOrDownTitlebars(bool bring_up); |
| 125 // The callback for a delyed task, checks if it still need to perform | 151 // The callback for a delyed task, checks if it still need to perform |
| 126 // the delayed action. | 152 // the delayed action. |
| 127 void DelayedBringUpOrDownTitlebarsCheck(); | 153 void DelayedBringUpOrDownTitlebarsCheck(); |
| 128 | 154 |
| 129 int GetRightMostAvailablePosition() const; | 155 int GetRightMostAvailablePosition() const; |
| 130 | 156 |
| 131 // Determines position in strip where a panel of |width| will fit. | 157 // Determines position in strip where a panel of |width| will fit. |
| 132 // Other panels in the strip may be moved to overflow to make room. | 158 // Other panels in the strip may be moved to overflow to make room. |
| 133 // Returns x position where a panel of |width| wide can fit. | 159 // Returns x position where a panel of |width| wide can fit. |
| 134 // |width| is in screen coordinates. | 160 // |width| is in screen coordinates. |
| 135 int FitPanelWithWidth(int width); | 161 int FitPanelWithWidth(int width); |
| 136 | 162 |
| 137 // Called by AddPanel() after a delay to move a newly created panel from | 163 // Called by AddPanel() after a delay to move a newly created panel from |
| 138 // the panel strip to overflow because the panel could not fit | 164 // the panel strip to overflow because the panel could not fit |
| 139 // within the bounds of the panel strip. New panels are first displayed | 165 // within the bounds of the panel strip. New panels are first displayed |
| 140 // in the panel strip, then moved to overflow so that all created | 166 // in the panel strip, then moved to overflow so that all created |
| 141 // panels are (at least briefly) visible before entering overflow. | 167 // panels are (at least briefly) visible before entering overflow. |
| 142 void DelayedMovePanelToOverflow(Panel* panel); | 168 void DelayedMovePanelToOverflow(Panel* panel); |
| 143 | 169 |
| 144 Panel* dragging_panel() const; | |
| 145 | |
| 146 PanelManager* panel_manager_; // Weak, owns us. | 170 PanelManager* panel_manager_; // Weak, owns us. |
| 147 | 171 |
| 148 // All panels in the panel strip must fit within this area. | 172 // All panels in the panel strip must fit within this area. |
| 149 gfx::Rect display_area_; | 173 gfx::Rect display_area_; |
| 150 | 174 |
| 151 Panels panels_; | 175 Panels panels_; |
| 152 | 176 |
| 153 // Stores newly created panels that have a temporary layout until they | 177 // Stores newly created panels that have a temporary layout until they |
| 154 // are moved to overflow after a delay. | 178 // are moved to overflow after a delay. |
| 155 std::set<Panel*> panels_in_temporary_layout_; | 179 std::set<Panel*> panels_in_temporary_layout_; |
| 156 | 180 |
| 157 int minimized_panel_count_; | 181 int minimized_panel_count_; |
| 158 bool are_titlebars_up_; | 182 bool are_titlebars_up_; |
| 159 | 183 |
| 160 // Referring to current position in |panels_| where the dragging panel | 184 // Referring to current position in |panels_| where the dragging panel |
| 161 // resides. | 185 // resides. |
| 162 Panels::iterator dragging_panel_current_iterator_; | 186 Panels::iterator dragging_panel_current_iterator_; |
| 163 | 187 |
| 164 // Referring to original position in |panels_| where the dragging panel | |
| 165 // resides. | |
| 166 Panels::iterator dragging_panel_original_iterator_; | |
| 167 | |
| 168 // Delayed transitions support. Sometimes transitions between minimized and | 188 // Delayed transitions support. Sometimes transitions between minimized and |
| 169 // title-only states are delayed, for better usability with Taskbars/Docks. | 189 // title-only states are delayed, for better usability with Taskbars/Docks. |
| 170 TitlebarAction delayed_titlebar_action_; | 190 TitlebarAction delayed_titlebar_action_; |
| 171 | 191 |
| 172 // Owned by MessageLoop after posting. | 192 // Owned by MessageLoop after posting. |
| 173 base::WeakPtrFactory<DockedPanelStrip> titlebar_action_factory_; | 193 base::WeakPtrFactory<DockedPanelStrip> titlebar_action_factory_; |
| 174 | 194 |
| 195 // Used to save the placement information for a panel. |
| 196 PanelPlacement saved_panel_placement_; |
| 197 |
| 175 static const int kPanelsHorizontalSpacing = 4; | 198 static const int kPanelsHorizontalSpacing = 4; |
| 176 | 199 |
| 177 // Absolute minimum width and height for panels, including non-client area. | 200 // Absolute minimum width and height for panels, including non-client area. |
| 178 // Should only be big enough to accomodate a close button on the reasonably | 201 // Should only be big enough to accomodate a close button on the reasonably |
| 179 // recognisable titlebar. | 202 // recognisable titlebar. |
| 180 static const int kPanelMinWidth; | 203 static const int kPanelMinWidth; |
| 181 static const int kPanelMinHeight; | 204 static const int kPanelMinHeight; |
| 182 | 205 |
| 183 DISALLOW_COPY_AND_ASSIGN(DockedPanelStrip); | 206 DISALLOW_COPY_AND_ASSIGN(DockedPanelStrip); |
| 184 }; | 207 }; |
| 185 | 208 |
| 186 #endif // CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_STRIP_H_ | 209 #endif // CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_STRIP_H_ |
| OLD | NEW |