Chromium Code Reviews| Index: chrome/browser/ui/panels/panel_overflow_strip.cc |
| diff --git a/chrome/browser/ui/panels/panel_overflow_strip.cc b/chrome/browser/ui/panels/panel_overflow_strip.cc |
| index c0d0a880beec359a30b524b9123c1e5f0f5ddb29..f0397c18a5fd47bc5c1d867224670d78302579d8 100644 |
| --- a/chrome/browser/ui/panels/panel_overflow_strip.cc |
| +++ b/chrome/browser/ui/panels/panel_overflow_strip.cc |
| @@ -8,13 +8,11 @@ |
| #include "chrome/browser/ui/panels/panel_manager.h" |
| #include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
| #include "chrome/browser/ui/panels/panel_strip.h" |
| +#include "chrome/common/chrome_notification_types.h" |
| +#include "content/public/browser/notification_service.h" |
| #include "ui/base/animation/slide_animation.h" |
| namespace { |
| -// The width of the overflow area that is expanded to show more info, i.e. |
| -// titles, when the mouse hovers over the area. |
| -const int kOverflowAreaHoverWidth = 200; |
| - |
| // Maximium number of overflow panels allowed to be shown. |
| const size_t kMaxVisibleOverflowPanelsAllowed = 6; |
| @@ -24,6 +22,7 @@ const int kOverflowHoverAnimationMs = 180; |
| PanelOverflowStrip::PanelOverflowStrip(PanelManager* panel_manager) |
| : panel_manager_(panel_manager), |
| + max_visible_panels_(kMaxVisibleOverflowPanelsAllowed), |
| are_overflow_titles_shown_(false), |
| overflow_hover_animator_start_width_(0), |
| overflow_hover_animator_end_width_(0) { |
| @@ -105,7 +104,6 @@ void PanelOverflowStrip::DoRefresh(size_t start_index, size_t end_index) { |
| if (panels_.empty() || start_index == panels_.size()) |
|
jennb
2011/12/08 23:52:00
Why do we need these extra checks? The condition i
jianli
2011/12/09 22:39:07
We need this because when last is being removed, s
|
| return; |
| - DCHECK(start_index < panels_.size()); |
| DCHECK(end_index < panels_.size()); |
| for (size_t index = start_index; index <= end_index; ++index) { |
| @@ -131,7 +129,7 @@ gfx::Rect PanelOverflowStrip::ComputeLayout( |
| // area. |
| bounds.set_width(kOverflowAreaHoverWidth); |
| bounds.set_height(iconified_size.height()); |
| - } else if (index < kMaxVisibleOverflowPanelsAllowed) { |
| + } else if (static_cast<int>(index) < max_visible_panels_) { |
| // Only the icon is visible. |
| bounds.set_width(iconified_size.width()); |
| bounds.set_height(iconified_size.height()); |
| @@ -161,8 +159,8 @@ bool PanelOverflowStrip::ShouldShowOverflowTitles( |
| top_visible_panel = panels_.back(); |
| } else { |
| width = display_area_.width(); |
| - top_visible_panel = panels_.size() >= kMaxVisibleOverflowPanelsAllowed ? |
| - panels_[kMaxVisibleOverflowPanelsAllowed - 1] : panels_.back(); |
| + top_visible_panel = num_panels() >= max_visible_panels_ ? |
|
jennb
2011/12/08 23:52:00
Why switch to num_panels()? Elsewhere in file, pan
jianli
2011/12/09 22:39:07
To avoid writing sth like "static_cast<int>(panels
|
| + panels_[max_visible_panels_ - 1] : panels_.back(); |
| } |
| return mouse_position.x() <= display_area_.x() + width && |
| top_visible_panel->GetBounds().y() <= mouse_position.y() && |
| @@ -201,6 +199,13 @@ void PanelOverflowStrip::ShowOverflowTitles(bool show_overflow_titles) { |
| overflow_hover_animator_->Show(); |
| } |
| +void PanelOverflowStrip::AnimationEnded(const ui::Animation* animation) { |
| + content::NotificationService::current()->Notify( |
| + chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, |
| + content::Source<PanelOverflowStrip>(this), |
| + content::NotificationService::NoDetails()); |
| +} |
| + |
| void PanelOverflowStrip::AnimationProgressed(const ui::Animation* animation) { |
| int current_width = overflow_hover_animator_->CurrentValueBetween( |
| overflow_hover_animator_start_width_, overflow_hover_animator_end_width_); |
| @@ -211,7 +216,7 @@ void PanelOverflowStrip::AnimationProgressed(const ui::Animation* animation) { |
| Panel* overflow_panel = panels_[i]; |
| gfx::Rect bounds = overflow_panel->GetBounds(); |
| - if (i >= kMaxVisibleOverflowPanelsAllowed && end_of_shrinking) { |
| + if (static_cast<int>(i) >= max_visible_panels_ && end_of_shrinking) { |
| bounds.set_width(0); |
| bounds.set_height(0); |
| } else { |