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_OVERFLOW_STRIP_H_ | 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_OVERFLOW_STRIP_H_ |
6 #define CHROME_BROWSER_UI_PANELS_PANEL_OVERFLOW_STRIP_H_ | 6 #define CHROME_BROWSER_UI_PANELS_PANEL_OVERFLOW_STRIP_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 #include "chrome/browser/ui/panels/panel.h" | 10 #include "chrome/browser/ui/panels/panel.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 | 44 |
45 // Refreshes the layouts for all panels to reflect any possible changes. | 45 // Refreshes the layouts for all panels to reflect any possible changes. |
46 void Refresh(); | 46 void Refresh(); |
47 | 47 |
48 void OnFullScreenModeChanged(bool is_full_screen); | 48 void OnFullScreenModeChanged(bool is_full_screen); |
49 | 49 |
50 int num_panels() const { return static_cast<int>(panels_.size()); } | 50 int num_panels() const { return static_cast<int>(panels_.size()); } |
51 Panel* first_panel() const { | 51 Panel* first_panel() const { |
52 return panels_.empty() ? NULL : panels_.front(); | 52 return panels_.empty() ? NULL : panels_.front(); |
53 } | 53 } |
54 const Panels& panels() const { return panels_; } | |
54 | 55 |
55 #ifdef UNIT_TEST | 56 #ifdef UNIT_TEST |
56 const Panels& panels() const { return panels_; } | 57 void set_max_visible_panels(int max_visible_panels) { |
58 max_visible_panels_ = max_visible_panels; | |
59 } | |
60 | |
61 bool TestShouldShowOverflowTitles(const gfx::Point& mouse_position) const { | |
jennb
2011/12/08 23:52:00
Use a TestPanelMouseWatcher instance and simulate
jianli
2011/12/09 22:39:07
I've already used TestPanelMouseWatcher that. But
| |
62 return ShouldShowOverflowTitles(mouse_position); | |
63 } | |
57 #endif | 64 #endif |
58 | 65 |
66 // The width of the overflow area that is expanded to show more info, i.e. | |
67 // titles, when the mouse hovers over the area. | |
68 static const int kOverflowAreaHoverWidth = 200; | |
69 | |
59 private: | 70 private: |
60 // Overridden from PanelMouseWatcherObserver: | 71 // Overridden from PanelMouseWatcherObserver: |
61 virtual void OnMouseMove(const gfx::Point& mouse_position) OVERRIDE; | 72 virtual void OnMouseMove(const gfx::Point& mouse_position) OVERRIDE; |
62 | 73 |
63 // Overridden from AnimationDelegate: | 74 // Overridden from AnimationDelegate: |
75 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | |
64 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 76 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; |
65 | 77 |
66 void DoRefresh(size_t start_index, size_t end_index); | 78 void DoRefresh(size_t start_index, size_t end_index); |
67 | 79 |
68 // Computes the layout of the |index| panel to fit into the area. | 80 // Computes the layout of the |index| panel to fit into the area. |
69 // Empty bounds will be returned if this is not possible due to not enough | 81 // Empty bounds will be returned if this is not possible due to not enough |
70 // space. | 82 // space. |
71 gfx::Rect ComputeLayout(size_t index, | 83 gfx::Rect ComputeLayout(size_t index, |
72 const gfx::Size& iconified_size) const; | 84 const gfx::Size& iconified_size) const; |
73 | 85 |
74 // Used to pop up the titles for overflow panels when the mouse hovers over | 86 // Used to pop up the titles for overflow panels when the mouse hovers over |
75 // the overflow area. | 87 // the overflow area. |
76 bool ShouldShowOverflowTitles(const gfx::Point& mouse_position) const; | 88 bool ShouldShowOverflowTitles(const gfx::Point& mouse_position) const; |
77 void ShowOverflowTitles(bool show_overflow_titles); | 89 void ShowOverflowTitles(bool show_overflow_titles); |
78 | 90 |
79 // Weak pointer since PanelManager owns PanelOverflowStrip instance. | 91 // Weak pointer since PanelManager owns PanelOverflowStrip instance. |
80 PanelManager* panel_manager_; | 92 PanelManager* panel_manager_; |
81 | 93 |
82 // The queue for storing all panels. | 94 // The queue for storing all panels. |
83 Panels panels_; | 95 Panels panels_; |
84 | 96 |
85 // The overflow area where panels are iconified due to insufficient space | 97 // The overflow area where panels are iconified due to insufficient space |
86 // in the panel strip. | 98 // in the panel strip. |
87 gfx::Rect display_area_; | 99 gfx::Rect display_area_; |
88 | 100 |
101 // Maximium number of overflow panels allowed to be shown. | |
102 int max_visible_panels_; | |
103 | |
89 // For mouse hover-over effect. | 104 // For mouse hover-over effect. |
90 bool are_overflow_titles_shown_; | 105 bool are_overflow_titles_shown_; |
91 scoped_ptr<ui::SlideAnimation> overflow_hover_animator_; | 106 scoped_ptr<ui::SlideAnimation> overflow_hover_animator_; |
92 int overflow_hover_animator_start_width_; | 107 int overflow_hover_animator_start_width_; |
93 int overflow_hover_animator_end_width_; | 108 int overflow_hover_animator_end_width_; |
94 | 109 |
95 // Invalid panel index. | 110 // Invalid panel index. |
96 static const size_t kInvalidPanelIndex = static_cast<size_t>(-1); | 111 static const size_t kInvalidPanelIndex = static_cast<size_t>(-1); |
97 | 112 |
98 DISALLOW_COPY_AND_ASSIGN(PanelOverflowStrip); | 113 DISALLOW_COPY_AND_ASSIGN(PanelOverflowStrip); |
99 }; | 114 }; |
100 | 115 |
101 #endif // CHROME_BROWSER_UI_PANELS_PANEL_OVERFLOW_STRIP_H_ | 116 #endif // CHROME_BROWSER_UI_PANELS_PANEL_OVERFLOW_STRIP_H_ |
OLD | NEW |