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/docked_panel_strip.h" | 8 #include "chrome/browser/ui/panels/docked_panel_strip.h" |
| 9 #include "chrome/browser/ui/panels/panel_manager.h" | 9 #include "chrome/browser/ui/panels/panel_manager.h" |
| 10 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" | 10 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 } | 75 } |
| 76 | 76 |
| 77 void OverflowPanelStrip::UpdateCurrentWidth() { | 77 void OverflowPanelStrip::UpdateCurrentWidth() { |
| 78 current_display_width_ = are_overflow_titles_shown_ ? kOverflowAreaHoverWidth | 78 current_display_width_ = are_overflow_titles_shown_ ? kOverflowAreaHoverWidth |
| 79 : display_area_.width(); | 79 : display_area_.width(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void OverflowPanelStrip::AddPanel(Panel* panel) { | 82 void OverflowPanelStrip::AddPanel(Panel* panel) { |
| 83 // TODO(jianli): consider using other container to improve the perf for | 83 // TODO(jianli): consider using other container to improve the perf for |
| 84 // inserting to the front. http://crbug.com/106222 | 84 // inserting to the front. http://crbug.com/106222 |
| 85 DCHECK_EQ(this, panel->panel_strip()); | 85 DCHECK_NE(this, panel->panel_strip()); |
| 86 panel->SetPanelStrip(this); | |
| 87 | |
| 86 // Newly created panels that were temporarily in the panel strip | 88 // Newly created panels that were temporarily in the panel strip |
| 87 // 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 |
| 88 // 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 |
| 89 // of overflow. | 91 // of overflow. |
| 90 if (panel->has_temporary_layout()) { | 92 if (panel->has_temporary_layout()) { |
| 91 panel->set_has_temporary_layout(false); | 93 panel->set_has_temporary_layout(false); |
| 92 panels_.push_back(panel); | 94 panels_.push_back(panel); |
| 93 DoRefresh(panels_.size() - 1, panels_.size() - 1); | 95 DoRefresh(panels_.size() - 1, panels_.size() - 1); |
| 94 } else { | 96 } else { |
| 95 panels_.insert(panels_.begin(), panel); | 97 panels_.insert(panels_.begin(), panel); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 108 // Update the overflow indicator only when the number of overflow panels go | 110 // Update the overflow indicator only when the number of overflow panels go |
| 109 // beyond the maximum visible limit. | 111 // beyond the maximum visible limit. |
| 110 if (num_panels() > max_visible_panels_) { | 112 if (num_panels() > max_visible_panels_) { |
| 111 if (!overflow_indicator_.get()) { | 113 if (!overflow_indicator_.get()) { |
| 112 overflow_indicator_.reset(PanelOverflowIndicator::Create()); | 114 overflow_indicator_.reset(PanelOverflowIndicator::Create()); |
| 113 } | 115 } |
| 114 UpdateOverflowIndicatorCount(); | 116 UpdateOverflowIndicatorCount(); |
| 115 } | 117 } |
| 116 } | 118 } |
| 117 | 119 |
| 118 bool OverflowPanelStrip::RemovePanel(Panel* panel) { | 120 void OverflowPanelStrip::RemovePanel(Panel* panel) { |
| 121 DCHECK_EQ(this, panel->panel_strip()); | |
| 119 size_t index = 0; | 122 size_t index = 0; |
| 120 Panels::iterator iter = panels_.begin(); | 123 Panels::iterator iter = panels_.begin(); |
| 121 for (; iter != panels_.end(); ++iter, ++index) | 124 for (; iter != panels_.end(); ++iter, ++index) |
| 122 if (*iter == panel) | 125 if (*iter == panel) |
| 123 break; | 126 break; |
| 124 if (iter == panels_.end()) | 127 DCHECK(iter != panels_.end()); |
| 125 return false; | |
| 126 | 128 |
| 127 panels_.erase(iter); | 129 panels_.erase(iter); |
| 128 DoRefresh(index, panels_.size() - 1); | 130 DoRefresh(index, panels_.size() - 1); |
| 129 | 131 |
| 130 if (panels_.empty() && !panel_manager_->is_full_screen()) | 132 if (panels_.empty() && !panel_manager_->is_full_screen()) |
| 131 panel_manager_->mouse_watcher()->RemoveObserver(this); | 133 panel_manager_->mouse_watcher()->RemoveObserver(this); |
| 132 | 134 |
| 133 // Update the overflow indicator. If the number of overflow panels fall below | 135 // Update the overflow indicator. If the number of overflow panels fall below |
| 134 // the maximum visible limit, we do not need the overflow indicator any more. | 136 // the maximum visible limit, we do not need the overflow indicator any more. |
| 135 if (num_panels() < max_visible_panels_) | 137 if (num_panels() < max_visible_panels_) |
| 136 overflow_indicator_.reset(); | 138 overflow_indicator_.reset(); |
| 137 else | 139 else |
| 138 UpdateOverflowIndicatorCount(); | 140 UpdateOverflowIndicatorCount(); |
|
Andrei
2012/03/01 00:08:50
Same comment about SetPanelStrip() as for the dock
| |
| 139 | |
| 140 return true; | |
| 141 } | 141 } |
| 142 | 142 |
| 143 void OverflowPanelStrip::CloseAll() { | 143 void OverflowPanelStrip::CloseAll() { |
| 144 // Make a copy of the iterator as closing panels can modify the vector. | 144 // Make a copy of the iterator as closing panels can modify the vector. |
| 145 Panels panels_copy = panels_; | 145 Panels panels_copy = panels_; |
| 146 | 146 |
| 147 // Start from the bottom to avoid reshuffling. | 147 // Start from the bottom to avoid reshuffling. |
| 148 for (Panels::reverse_iterator iter = panels_copy.rbegin(); | 148 for (Panels::reverse_iterator iter = panels_copy.rbegin(); |
| 149 iter != panels_copy.rend(); ++iter) | 149 iter != panels_copy.rend(); ++iter) |
| 150 (*iter)->Close(); | 150 (*iter)->Close(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void OverflowPanelStrip::ResizePanelWindow( | 153 void OverflowPanelStrip::ResizePanelWindow( |
| 154 Panel* panel, const gfx::Size& preferred_window_size) { | 154 Panel* panel, const gfx::Size& preferred_window_size) { |
| 155 // Overflow uses its own panel window sizes. | 155 // Overflow uses its own panel window sizes. |
| 156 } | 156 } |
| 157 | 157 |
| 158 void OverflowPanelStrip::OnPanelAttentionStateChanged(Panel* panel) { | 158 void OverflowPanelStrip::OnPanelAttentionStateChanged(Panel* panel) { |
| 159 DCHECK_EQ(this, panel->panel_strip()); | 159 DCHECK_EQ(this, panel->panel_strip()); |
| 160 UpdateOverflowIndicatorAttention(); | 160 UpdateOverflowIndicatorAttention(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void OverflowPanelStrip::ActivatePanel(Panel* panel) { | 163 void OverflowPanelStrip::ActivatePanel(Panel* panel) { |
| 164 DCHECK_EQ(this, panel->panel_strip()); | 164 DCHECK_EQ(this, panel->panel_strip()); |
| 165 // Activating an overflow panel moves it to the docked panel strip. | 165 // Activating an overflow panel moves it to the docked panel strip. |
| 166 PanelStrip* docked_strip = panel_manager_->docked_strip(); | 166 panel_manager_->ChangePanelLayout(panel, PanelStrip::DOCKED); |
|
Andrei
2012/03/01 00:08:50
Ideally making sure a panel CAN be activated befor
jennb
2012/03/01 00:30:58
For this activation path, the panel can always be
| |
| 167 panel->MoveToStrip(docked_strip); | 167 panel->panel_strip()->ActivatePanel(panel); |
| 168 docked_strip->ActivatePanel(panel); | |
| 169 } | 168 } |
| 170 | 169 |
| 171 void OverflowPanelStrip::MinimizePanel(Panel* panel) { | 170 void OverflowPanelStrip::MinimizePanel(Panel* panel) { |
| 172 DCHECK_EQ(this, panel->panel_strip()); | 171 DCHECK_EQ(this, panel->panel_strip()); |
| 173 // Overflow is already a minimized mode for a panel. Nothing more to do. | 172 // Overflow is already a minimized mode for a panel. Nothing more to do. |
| 174 } | 173 } |
| 175 | 174 |
| 176 void OverflowPanelStrip::RestorePanel(Panel* panel) { | 175 void OverflowPanelStrip::RestorePanel(Panel* panel) { |
| 177 DCHECK_EQ(this, panel->panel_strip()); | 176 DCHECK_EQ(this, panel->panel_strip()); |
| 178 PanelStrip* docked_strip = panel_manager_->docked_strip(); | 177 panel_manager_->ChangePanelLayout(panel, PanelStrip::DOCKED); |
|
Andrei
2012/03/01 00:08:50
Same as above.
jennb
2012/03/01 00:30:58
Ditto above; this is always allowed.
| |
| 179 panel->MoveToStrip(docked_strip); | 178 panel->panel_strip()->RestorePanel(panel); |
| 180 docked_strip->RestorePanel(panel); | |
| 181 } | 179 } |
| 182 | 180 |
| 183 bool OverflowPanelStrip::CanShowPanelAsActive(const Panel* panel) const { | 181 bool OverflowPanelStrip::CanShowPanelAsActive(const Panel* panel) const { |
| 184 // All overflow panels cannot be shown as active. | 182 // All overflow panels cannot be shown as active. |
| 185 return false; | 183 return false; |
| 186 } | 184 } |
| 187 | 185 |
| 188 bool OverflowPanelStrip::CanDragPanel(const Panel* panel) const { | 186 bool OverflowPanelStrip::CanDragPanel(const Panel* panel) const { |
| 189 // All overflow panels are not draggable. | 187 // All overflow panels are not draggable. |
| 190 return false; | 188 return false; |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 395 // expanded overflow panels when in full screen mode so no need | 393 // expanded overflow panels when in full screen mode so no need |
| 396 // to detect when mouse hovers over the overflow strip. | 394 // to detect when mouse hovers over the overflow strip. |
| 397 if (is_full_screen) | 395 if (is_full_screen) |
| 398 panel_manager_->mouse_watcher()->RemoveObserver(this); | 396 panel_manager_->mouse_watcher()->RemoveObserver(this); |
| 399 else | 397 else |
| 400 panel_manager_->mouse_watcher()->AddObserver(this); | 398 panel_manager_->mouse_watcher()->AddObserver(this); |
| 401 | 399 |
| 402 for (size_t i = 0; i < panels_.size(); ++i) | 400 for (size_t i = 0; i < panels_.size(); ++i) |
| 403 panels_[i]->FullScreenModeChanged(is_full_screen); | 401 panels_[i]->FullScreenModeChanged(is_full_screen); |
| 404 } | 402 } |
| OLD | NEW |