Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/ui/panels/overflow_panel_strip.h" | 5 #include "chrome/browser/ui/panels/overflow_panel_strip.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/ui/panels/panel_manager.h" | 8 #include "chrome/browser/ui/panels/panel_manager.h" |
| 9 #include "chrome/browser/ui/panels/native_panel.h" | |
|
jennb
2012/03/07 18:30:49
delete
| |
| 9 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" | 10 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
| 10 #include "chrome/browser/ui/panels/panel_overflow_indicator.h" | 11 #include "chrome/browser/ui/panels/panel_overflow_indicator.h" |
| 11 #include "chrome/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
| 12 #include "content/public/browser/notification_service.h" | 13 #include "content/public/browser/notification_service.h" |
| 13 #include "ui/base/animation/slide_animation.h" | 14 #include "ui/base/animation/slide_animation.h" |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 // The width of the overflow area that is expanded to show more info, i.e. | 17 // The width of the overflow area that is expanded to show more info, i.e. |
| 17 // titles, when the mouse hovers over the area. | 18 // titles, when the mouse hovers over the area. |
| 18 static const int kOverflowAreaHoverWidth = 200; | 19 static const int kOverflowAreaHoverWidth = 200; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 | 76 |
| 76 void OverflowPanelStrip::UpdateCurrentWidth() { | 77 void OverflowPanelStrip::UpdateCurrentWidth() { |
| 77 current_display_width_ = are_overflow_titles_shown_ ? kOverflowAreaHoverWidth | 78 current_display_width_ = are_overflow_titles_shown_ ? kOverflowAreaHoverWidth |
| 78 : display_area_.width(); | 79 : display_area_.width(); |
| 79 } | 80 } |
| 80 | 81 |
| 81 void OverflowPanelStrip::AddPanel(Panel* panel) { | 82 void OverflowPanelStrip::AddPanel(Panel* panel) { |
| 82 // TODO(jianli): consider using other container to improve the perf for | 83 // TODO(jianli): consider using other container to improve the perf for |
| 83 // inserting to the front. http://crbug.com/106222 | 84 // inserting to the front. http://crbug.com/106222 |
| 84 DCHECK_NE(this, panel->panel_strip()); | 85 DCHECK_NE(this, panel->panel_strip()); |
| 85 panel->set_panel_strip(this); | 86 panel->SetPanelStrip(this); |
| 86 | 87 |
| 87 // Newly created panels that were temporarily in the panel strip | 88 // Newly created panels that were temporarily in the panel strip |
| 88 // are added to the back of the overflow, whereas panels that are | 89 // are added to the back of the overflow, whereas panels that are |
| 89 // bumped from the panel strip by other panels go to the front | 90 // bumped from the panel strip by other panels go to the front |
| 90 // of overflow. | 91 // of overflow. |
| 91 if (panel->has_temporary_layout()) { | 92 if (panel->has_temporary_layout()) { |
| 92 panel->set_has_temporary_layout(false); | 93 panel->set_has_temporary_layout(false); |
| 93 panels_.push_back(panel); | 94 panels_.push_back(panel); |
| 94 DoRefresh(panels_.size() - 1, panels_.size() - 1); | 95 DoRefresh(panels_.size() - 1, panels_.size() - 1); |
| 95 } else { | 96 } else { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 111 if (num_panels() > max_visible_panels_) { | 112 if (num_panels() > max_visible_panels_) { |
| 112 if (!overflow_indicator_.get()) { | 113 if (!overflow_indicator_.get()) { |
| 113 overflow_indicator_.reset(PanelOverflowIndicator::Create()); | 114 overflow_indicator_.reset(PanelOverflowIndicator::Create()); |
| 114 } | 115 } |
| 115 UpdateOverflowIndicatorCount(); | 116 UpdateOverflowIndicatorCount(); |
| 116 } | 117 } |
| 117 } | 118 } |
| 118 | 119 |
| 119 void OverflowPanelStrip::RemovePanel(Panel* panel) { | 120 void OverflowPanelStrip::RemovePanel(Panel* panel) { |
| 120 DCHECK_EQ(this, panel->panel_strip()); | 121 DCHECK_EQ(this, panel->panel_strip()); |
| 121 panel->set_panel_strip(NULL); | 122 panel->SetPanelStrip(NULL); |
| 122 | 123 |
| 123 size_t index = 0; | 124 size_t index = 0; |
| 124 Panels::iterator iter = panels_.begin(); | 125 Panels::iterator iter = panels_.begin(); |
| 125 for (; iter != panels_.end(); ++iter, ++index) | 126 for (; iter != panels_.end(); ++iter, ++index) |
| 126 if (*iter == panel) | 127 if (*iter == panel) |
| 127 break; | 128 break; |
| 128 DCHECK(iter != panels_.end()); | 129 DCHECK(iter != panels_.end()); |
| 129 | 130 |
| 130 panels_.erase(iter); | 131 panels_.erase(iter); |
| 131 DoRefresh(index, panels_.size() - 1); | 132 DoRefresh(index, panels_.size() - 1); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 // expanded overflow panels when in full screen mode so no need | 401 // expanded overflow panels when in full screen mode so no need |
| 401 // to detect when mouse hovers over the overflow strip. | 402 // to detect when mouse hovers over the overflow strip. |
| 402 if (is_full_screen) | 403 if (is_full_screen) |
| 403 panel_manager_->mouse_watcher()->RemoveObserver(this); | 404 panel_manager_->mouse_watcher()->RemoveObserver(this); |
| 404 else | 405 else |
| 405 panel_manager_->mouse_watcher()->AddObserver(this); | 406 panel_manager_->mouse_watcher()->AddObserver(this); |
| 406 | 407 |
| 407 for (size_t i = 0; i < panels_.size(); ++i) | 408 for (size_t i = 0; i < panels_.size(); ++i) |
| 408 panels_[i]->FullScreenModeChanged(is_full_screen); | 409 panels_[i]->FullScreenModeChanged(is_full_screen); |
| 409 } | 410 } |
| OLD | NEW |