| 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_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ |
| 6 #define CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ | 6 #define CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_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/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/timer.h" |
| 12 #include "chrome/browser/ui/panels/panel.h" | 13 #include "chrome/browser/ui/panels/panel.h" |
| 13 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
| 14 | 15 |
| 15 class Browser; | 16 class Browser; |
| 16 class Panel; | 17 class Panel; |
| 17 | 18 |
| 18 // This class manages a set of panels. | 19 // This class manages a set of panels. |
| 19 class PanelManager { | 20 class PanelManager { |
| 20 public: | 21 public: |
| 21 // Returns a single instance. | 22 // Returns a single instance. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 36 // Drags the given panel. | 37 // Drags the given panel. |
| 37 void StartDragging(Panel* panel); | 38 void StartDragging(Panel* panel); |
| 38 void Drag(int delta_x); | 39 void Drag(int delta_x); |
| 39 void EndDragging(bool cancelled); | 40 void EndDragging(bool cancelled); |
| 40 | 41 |
| 41 // Should we bring up the titlebar, given the current mouse point? | 42 // Should we bring up the titlebar, given the current mouse point? |
| 42 bool ShouldBringUpTitleBarForAllMinimizedPanels(int mouse_x, | 43 bool ShouldBringUpTitleBarForAllMinimizedPanels(int mouse_x, |
| 43 int mouse_y) const; | 44 int mouse_y) const; |
| 44 | 45 |
| 45 // Brings up or down the title-bar for all minimized panels. | 46 // Brings up or down the title-bar for all minimized panels. |
| 46 void BringUpOrDownTitleBarForAllMinimizedPanels(bool bring_up); | 47 void BringUpTitleBar(); |
| 48 void BringDownTitleBar(); |
| 49 |
| 50 // Returns the bottom position for the panel per its expansion state. If auto- |
| 51 // hide bottom bar is present, we want to move the minimized panel to the |
| 52 // bottom of the screen, not the bottom of the work area. |
| 53 int GetBottomPositionPerExpansionState( |
| 54 Panel::ExpansionState expansion_state) const; |
| 47 | 55 |
| 48 int num_panels() const { return panels_.size(); } | 56 int num_panels() const { return panels_.size(); } |
| 49 | 57 |
| 50 private: | 58 private: |
| 51 friend class PanelBrowserTest; | 59 friend class PanelBrowserTest; |
| 60 friend class PanelBrowserViewTest; |
| 52 | 61 |
| 53 typedef std::vector<Panel*> Panels; | 62 typedef std::vector<Panel*> Panels; |
| 54 | 63 |
| 55 PanelManager(); | 64 PanelManager(); |
| 56 | 65 |
| 57 // Applies the new work area. This is called by OnDisplayChanged and the test | 66 // Applies the new work area. This is called by OnDisplayChanged and the test |
| 58 // code. | 67 // code. |
| 59 void SetWorkArea(const gfx::Rect& work_area); | 68 void SetWorkArea(const gfx::Rect& work_area, int bottom_bar_height); |
| 60 | 69 |
| 61 // Handles all the panels that're delayed to be removed. | 70 // Handles all the panels that're delayed to be removed. |
| 62 void DelayedRemove(); | 71 void DelayedRemove(); |
| 63 | 72 |
| 64 // Does the remove. Called from Remove and DelayedRemove. | 73 // Does the remove. Called from Remove and DelayedRemove. |
| 65 void DoRemove(Panel* panel); | 74 void DoRemove(Panel* panel); |
| 66 | 75 |
| 67 // Rearranges the positions of the panels starting from the given iterator. | 76 // Rearranges the positions of the panels starting from the given iterator. |
| 68 // This is called when the display space has been changed, i.e. working | 77 // This is called when the display space has been changed, i.e. working |
| 69 // area being changed or a panel being closed. | 78 // area being changed or a panel being closed. |
| 70 void Rearrange(Panels::iterator iter_to_start); | 79 void Rearrange(Panels::iterator iter_to_start); |
| 71 | 80 |
| 72 // Computes the bounds for next panel. | 81 // Computes the bounds for next panel. |
| 73 // |allow_size_change| is used to indicate if the panel size can be changed to | 82 // |allow_size_change| is used to indicate if the panel size can be changed to |
| 74 // fall within the size constraint, e.g., when the panel is created. | 83 // fall within the size constraint, e.g., when the panel is created. |
| 75 // Returns true if computed bounds are within the displayable area. | 84 // Returns true if computed bounds are within the displayable area. |
| 76 bool ComputeBoundsForNextPanel(gfx::Rect* bounds, bool allow_size_change); | 85 bool ComputeBoundsForNextPanel(gfx::Rect* bounds, bool allow_size_change); |
| 77 | 86 |
| 78 // Finds one panel to close so that we may have space for the new panel | 87 // Finds one panel to close so that we may have space for the new panel |
| 79 // created by |extension|. | 88 // created by |extension|. |
| 80 void FindAndClosePanelOnOverflow(const Extension* extension); | 89 void FindAndClosePanelOnOverflow(const Extension* extension); |
| 81 | 90 |
| 82 // Help functions to drag the given panel. | 91 // Help functions to drag the given panel. |
| 83 void DragLeft(); | 92 void DragLeft(); |
| 84 void DragRight(); | 93 void DragRight(); |
| 85 | 94 |
| 95 void DoBringUpOrDownTitleBar(bool bring_up); |
| 96 |
| 86 Panels panels_; | 97 Panels panels_; |
| 87 | 98 |
| 88 // Stores the panels that are pending to remove. We want to delay the removal | 99 // Stores the panels that are pending to remove. We want to delay the removal |
| 89 // when we're in the process of the dragging. | 100 // when we're in the process of the dragging. |
| 90 Panels panels_pending_to_remove_; | 101 Panels panels_pending_to_remove_; |
| 91 | 102 |
| 92 // Current work area used in computing the panel bounds. | 103 // Current work area used in computing the panel bounds. |
| 104 // If the top-most bottom bar, like Windows taskbar or MacOSX dock, is always |
| 105 // visible, it should not be included in the work area. Otherwise, the work |
| 106 // area includes the potential area that would be taken by the bottom bar |
| 107 // when it becomes visible. |
| 93 gfx::Rect work_area_; | 108 gfx::Rect work_area_; |
| 94 | 109 |
| 110 // The height of the top-most bottom bar if it is auto-hidden. Otherwise, this |
| 111 // value is 0. |
| 112 int auto_hide_bottom_bar_height_; |
| 113 |
| 95 // Used in computing the bounds of the next panel. | 114 // Used in computing the bounds of the next panel. |
| 96 int max_width_; | 115 int max_width_; |
| 97 int max_height_; | 116 int max_height_; |
| 98 int min_x_; | |
| 99 int current_x_; | 117 int current_x_; |
| 100 int bottom_edge_y_; | |
| 101 | 118 |
| 102 // Panel to drag. | 119 // Panel to drag. |
| 103 size_t dragging_panel_index_; | 120 size_t dragging_panel_index_; |
| 104 | 121 |
| 105 // Original x coordinate of the panel to drag. This is used to get back to | 122 // Original x coordinate of the panel to drag. This is used to get back to |
| 106 // the original position when we cancel the dragging. | 123 // the original position when we cancel the dragging. |
| 107 int dragging_panel_original_x_; | 124 int dragging_panel_original_x_; |
| 108 | 125 |
| 109 // Bounds of the panel to drag. It is first set to the original bounds when | 126 // Bounds of the panel to drag. It is first set to the original bounds when |
| 110 // the dragging happens. Then it is updated to the position that will be set | 127 // the dragging happens. Then it is updated to the position that will be set |
| 111 // to when the dragging ends. | 128 // to when the dragging ends. |
| 112 gfx::Rect dragging_panel_bounds_; | 129 gfx::Rect dragging_panel_bounds_; |
| 113 | 130 |
| 131 // Timer to check the visibility of auto-hide bottom bar to decide when to |
| 132 // bring up or down the titlebar. |
| 133 base::RepeatingTimer<PanelManager> bring_up_or_down_titlebar_timer_; |
| 134 |
| 135 // This is only used by the testing code to disable the above check. |
| 136 bool should_check_auto_hide_bottom_bar_on_titlebar_change_; |
| 137 |
| 114 DISALLOW_COPY_AND_ASSIGN(PanelManager); | 138 DISALLOW_COPY_AND_ASSIGN(PanelManager); |
| 115 }; | 139 }; |
| 116 | 140 |
| 117 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ | 141 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ |
| OLD | NEW |