| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_OVERFLOW_STRIP_H_ |
| 6 #define CHROME_BROWSER_UI_PANELS_PANEL_OVERFLOW_STRIP_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "chrome/browser/ui/panels/panel.h" |
| 10 #include "chrome/browser/ui/panels/panel_mouse_watcher_observer.h" |
| 11 #include "ui/base/animation/animation_delegate.h" |
| 12 |
| 13 class Browser; |
| 14 class PanelManager; |
| 15 namespace gfx { |
| 16 class Point; |
| 17 class Size; |
| 18 class Rect; |
| 19 } |
| 20 namespace ui { |
| 21 class SlideAnimation; |
| 22 } |
| 23 |
| 24 // Manipulates all the panels that are placed on the left-most overflow area. |
| 25 class PanelOverflowStrip : public PanelMouseWatcherObserver, |
| 26 public ui::AnimationDelegate { |
| 27 public: |
| 28 typedef std::vector<Panel*> Panels; |
| 29 |
| 30 explicit PanelOverflowStrip(PanelManager* panel_manager); |
| 31 ~PanelOverflowStrip(); |
| 32 |
| 33 // Sets the display area of the overflow strip. |
| 34 // |display_area| is in screen coordinates. |
| 35 void SetDisplayArea(const gfx::Rect& display_area); |
| 36 |
| 37 // Adds a panel to the strip. |is_new| indicates if the panel is a newly |
| 38 // created panel or one that is transitioning from another grouping of panels. |
| 39 void AddPanel(Panel* panel, bool is_new); |
| 40 |
| 41 // Returns |false| if the panel is not in the strip. |
| 42 bool Remove(Panel* panel); |
| 43 void RemoveAll(); |
| 44 |
| 45 // Updates the restored size of the given panel due to the preferred content |
| 46 // size change. |
| 47 void UpdatePanelRestoredSize(Panel* panel, const gfx::Size& restored_size); |
| 48 |
| 49 // called when a panel's expansion state changes. |
| 50 void OnPanelExpansionStateChanged( |
| 51 Panel* panel, Panel::ExpansionState old_state); |
| 52 |
| 53 // Refreshes the layouts for all panels to reflect any possible changes. |
| 54 void Refresh(); |
| 55 |
| 56 bool mouse_watcher_needed() const; |
| 57 int num_panels() const { return static_cast<int>(panels_.size()); } |
| 58 Panel* first_panel() const; |
| 59 |
| 60 #ifdef UNIT_TEST |
| 61 const Panels& panels() const { return panels_; } |
| 62 #endif |
| 63 |
| 64 private: |
| 65 // Overridden from PanelMouseWatcherObserver: |
| 66 virtual void OnMouseMove(const gfx::Point& mouse_position) OVERRIDE; |
| 67 |
| 68 // Overridden from AnimationDelegate: |
| 69 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; |
| 70 |
| 71 void DoRefresh(size_t start_index, size_t end_index); |
| 72 size_t FindPanelIndex(Panel* panel) const; |
| 73 |
| 74 // Computes the layout of the |index| panel to fit into the area. |
| 75 // Empty bounds will be returned if this is not possible due to no enough |
| 76 // space. |
| 77 gfx::Rect ComputeLayout(size_t index, |
| 78 const gfx::Size& iconified_size, |
| 79 const gfx::Size& restored_size) const; |
| 80 |
| 81 // Used to pop up the titles for overflow panels, when the mouse hovers over |
| 82 // the overflow area. |
| 83 bool ShouldShowOverflowTitles(const gfx::Point& mouse_position) const; |
| 84 void ShowOverflowTitles(bool show_overflow_titles); |
| 85 |
| 86 // Weak pointer since PanelManager owns PanelOverflowStrip instance. |
| 87 PanelManager* panel_manager_; |
| 88 |
| 89 // The queue for storing all panels. |
| 90 Panels panels_; |
| 91 |
| 92 // The overflow area where panels are iconified due to no available space |
| 93 // in the normal docking area. |
| 94 gfx::Rect display_area_; |
| 95 |
| 96 // For mouse hover-over effect. |
| 97 bool are_overflow_titles_shown_; |
| 98 scoped_ptr<ui::SlideAnimation> overflow_hover_animator_; |
| 99 int overflow_hover_animator_start_width_; |
| 100 int overflow_hover_animator_end_width_; |
| 101 |
| 102 // Invalid panel index. |
| 103 static const size_t kInvalidPanelIndex = static_cast<size_t>(-1); |
| 104 |
| 105 DISALLOW_COPY_AND_ASSIGN(PanelOverflowStrip); |
| 106 }; |
| 107 |
| 108 #endif // CHROME_BROWSER_UI_PANELS_PANEL_OVERFLOW_STRIP_H_ |
| OLD | NEW |