Chromium Code Reviews| Index: chrome/browser/ui/panels/panel_overflow_strip.h |
| diff --git a/chrome/browser/ui/panels/panel_overflow_strip.h b/chrome/browser/ui/panels/panel_overflow_strip.h |
| index 32ff32c3f284c49308147c28e890a148701dbd0b..b6f1f3c670e798e3768445b468b0bf542b083f8e 100644 |
| --- a/chrome/browser/ui/panels/panel_overflow_strip.h |
| +++ b/chrome/browser/ui/panels/panel_overflow_strip.h |
| @@ -9,17 +9,21 @@ |
| #include <vector> |
| #include "chrome/browser/ui/panels/panel.h" |
| #include "chrome/browser/ui/panels/panel_mouse_watcher_observer.h" |
| +#include "content/public/browser/notification_observer.h" |
| +#include "content/public/browser/notification_registrar.h" |
| #include "ui/base/animation/animation_delegate.h" |
| class Browser; |
| class PanelManager; |
| +class PanelOverflowIndicator; |
| namespace ui { |
| class SlideAnimation; |
| } |
| // Manipulates all the panels that are placed on the left-most overflow area. |
| class PanelOverflowStrip : public PanelMouseWatcherObserver, |
| - public ui::AnimationDelegate { |
| + public ui::AnimationDelegate, |
| + public content::NotificationObserver { |
| public: |
| typedef std::vector<Panel*> Panels; |
| @@ -41,6 +45,9 @@ class PanelOverflowStrip : public PanelMouseWatcherObserver, |
| void OnPanelExpansionStateChanged( |
| Panel* panel, Panel::ExpansionState old_state); |
| + // Called when a panel is starting/stopping drawing an attention. |
| + void OnPanelAttentionStateChanged(Panel* panel); |
|
jennb
2011/12/20 02:08:23
You already have to make this class an observer in
jianli
2011/12/20 22:08:10
As discussed, we do not need to use the observer a
|
| + |
| // Refreshes the layouts for all panels to reflect any possible changes. |
| void Refresh(); |
| @@ -55,9 +62,17 @@ class PanelOverflowStrip : public PanelMouseWatcherObserver, |
| #ifdef UNIT_TEST |
| int current_display_width() const { return current_display_width_; } |
| + PanelOverflowIndicator* overflow_indicator() const { |
|
jennb
2011/12/20 02:08:23
Comment. Does this return NULL sometimes?
jianli
2011/12/20 22:08:10
Done.
|
| + return overflow_indicator_.get(); |
| + } |
| + |
| void set_max_visible_panels(int max_visible_panels) { |
| max_visible_panels_ = max_visible_panels; |
| } |
| + |
| + void set_max_visible_panels_on_hover(int max_visible_panels_on_hover) { |
| + max_visible_panels_on_hover_ = max_visible_panels_on_hover; |
| + } |
| #endif |
| private: |
| @@ -68,10 +83,18 @@ class PanelOverflowStrip : public PanelMouseWatcherObserver, |
| virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; |
| virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; |
| + // Overridden from NotificationObserver: |
| + virtual void Observe(int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) OVERRIDE; |
| + |
| + void UpdateMaxVisibkePanelsOnHover(); |
|
jennb
2011/12/20 02:08:23
typo
jianli
2011/12/20 22:08:10
Done.
|
| void UpdateCurrentWidth(); |
| void DoRefresh(size_t start_index, size_t end_index); |
| + void UpdateOverflowIndicator(int width); |
|
jennb
2011/12/20 02:08:23
Comment. I was expecting the param to be 'count'.
jianli
2011/12/20 22:08:10
'width' parameter is not needed any more.
|
| + |
| // Computes the layout of the |index| panel to fit into the area. |
| // Empty bounds will be returned if this is not possible due to not enough |
| // space. |
| @@ -83,6 +106,11 @@ class PanelOverflowStrip : public PanelMouseWatcherObserver, |
| bool ShouldShowOverflowTitles(const gfx::Point& mouse_position) const; |
| void ShowOverflowTitles(bool show_overflow_titles); |
| + int max_visible_panels() const { |
| + return are_overflow_titles_shown_ ? max_visible_panels_on_hover_ |
| + : max_visible_panels_; |
| + } |
| + |
| // Weak pointer since PanelManager owns PanelOverflowStrip instance. |
| PanelManager* panel_manager_; |
| @@ -98,15 +126,27 @@ class PanelOverflowStrip : public PanelMouseWatcherObserver, |
| // the panel showing more info when the mouse hovers over it. |
| int current_display_width_; |
| - // Maximium number of overflow panels allowed to be shown. |
| + // Maximium number of overflow panels allowed to be shown when the mouse |
| + // does not hover over the overflow area. |
| int max_visible_panels_; |
| + // Maximium number of overflow panels allowed to be shown when the mouse |
| + // hovers over the overflow area and cause it to be expanded. |
|
jennb
2011/12/20 02:08:23
s/cause/causes
jianli
2011/12/20 22:08:10
Done.
|
| + int max_visible_panels_on_hover_; |
| + |
| + // User to show "+N" indicator when number of overflow panels exceed |
|
jennb
2011/12/20 02:08:23
s/User/Used
jianli
2011/12/20 22:08:10
Done.
|
| + // |max_visible_panels_|. |
| + scoped_ptr<PanelOverflowIndicator> overflow_indicator_; |
| + |
| // For mouse hover-over effect. |
| bool are_overflow_titles_shown_; |
| scoped_ptr<ui::SlideAnimation> overflow_hover_animator_; |
| int overflow_hover_animator_start_width_; |
| int overflow_hover_animator_end_width_; |
| + // Registrar for receiving the shut down notification. |
| + content::NotificationRegistrar registrar_; |
| + |
| // Invalid panel index. |
| static const size_t kInvalidPanelIndex = static_cast<size_t>(-1); |