| 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/panel_mouse_watcher.h" | 9 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
| 10 #include "chrome/browser/ui/panels/panel_overflow_indicator.h" | 10 #include "chrome/browser/ui/panels/panel_overflow_indicator.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 kHeightRatioForMaxVisibleOverflowPanelsOnHover * | 71 kHeightRatioForMaxVisibleOverflowPanelsOnHover * |
| 72 display_area_.height() / | 72 display_area_.height() / |
| 73 panels_.front()->IconOnlySize().height(); | 73 panels_.front()->IconOnlySize().height(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void OverflowPanelStrip::UpdateCurrentWidth() { | 76 void OverflowPanelStrip::UpdateCurrentWidth() { |
| 77 current_display_width_ = are_overflow_titles_shown_ ? kOverflowAreaHoverWidth | 77 current_display_width_ = are_overflow_titles_shown_ ? kOverflowAreaHoverWidth |
| 78 : display_area_.width(); | 78 : display_area_.width(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void OverflowPanelStrip::AddPanel(Panel* panel) { | 81 void OverflowPanelStrip::AddPanel(Panel* panel, |
| 82 PositioningMask positioning_mask) { |
| 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->SetPanelStrip(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()) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } | 159 } |
| 159 | 160 |
| 160 void OverflowPanelStrip::OnPanelAttentionStateChanged(Panel* panel) { | 161 void OverflowPanelStrip::OnPanelAttentionStateChanged(Panel* panel) { |
| 161 DCHECK_EQ(this, panel->panel_strip()); | 162 DCHECK_EQ(this, panel->panel_strip()); |
| 162 UpdateOverflowIndicatorAttention(); | 163 UpdateOverflowIndicatorAttention(); |
| 163 } | 164 } |
| 164 | 165 |
| 165 void OverflowPanelStrip::ActivatePanel(Panel* panel) { | 166 void OverflowPanelStrip::ActivatePanel(Panel* panel) { |
| 166 DCHECK_EQ(this, panel->panel_strip()); | 167 DCHECK_EQ(this, panel->panel_strip()); |
| 167 // Activating an overflow panel moves it to the docked panel strip. | 168 // Activating an overflow panel moves it to the docked panel strip. |
| 168 panel_manager_->MovePanelToStrip(panel, PanelStrip::DOCKED); | 169 panel_manager_->MovePanelToStrip(panel, |
| 170 PanelStrip::DOCKED, |
| 171 PanelStrip::DEFAULT_POSITION); |
| 169 panel->panel_strip()->ActivatePanel(panel); | 172 panel->panel_strip()->ActivatePanel(panel); |
| 170 } | 173 } |
| 171 | 174 |
| 172 void OverflowPanelStrip::MinimizePanel(Panel* panel) { | 175 void OverflowPanelStrip::MinimizePanel(Panel* panel) { |
| 173 DCHECK_EQ(this, panel->panel_strip()); | 176 DCHECK_EQ(this, panel->panel_strip()); |
| 174 // Overflow is already a minimized mode for a panel. Nothing more to do. | 177 // Overflow is already a minimized mode for a panel. Nothing more to do. |
| 175 } | 178 } |
| 176 | 179 |
| 177 void OverflowPanelStrip::RestorePanel(Panel* panel) { | 180 void OverflowPanelStrip::RestorePanel(Panel* panel) { |
| 178 DCHECK_EQ(this, panel->panel_strip()); | 181 DCHECK_EQ(this, panel->panel_strip()); |
| 179 panel_manager_->MovePanelToStrip(panel, PanelStrip::DOCKED); | 182 panel_manager_->MovePanelToStrip(panel, |
| 183 PanelStrip::DOCKED, |
| 184 PanelStrip::DEFAULT_POSITION); |
| 180 panel->panel_strip()->RestorePanel(panel); | 185 panel->panel_strip()->RestorePanel(panel); |
| 181 } | 186 } |
| 182 | 187 |
| 183 bool OverflowPanelStrip::IsPanelMinimized(const Panel* panel) const { | 188 bool OverflowPanelStrip::IsPanelMinimized(const Panel* panel) const { |
| 184 // All overflow panels are considered minimized. | 189 // All overflow panels are considered minimized. |
| 185 return true; | 190 return true; |
| 186 } | 191 } |
| 187 | 192 |
| 188 bool OverflowPanelStrip::CanShowPanelAsActive(const Panel* panel) const { | 193 bool OverflowPanelStrip::CanShowPanelAsActive(const Panel* panel) const { |
| 189 // All overflow panels cannot be shown as active. | 194 // All overflow panels cannot be shown as active. |
| 190 return false; | 195 return false; |
| 191 } | 196 } |
| 192 | 197 |
| 198 void OverflowPanelStrip::SavePanelPlacement(Panel* panel) { |
| 199 NOTREACHED(); |
| 200 } |
| 201 |
| 202 void OverflowPanelStrip::RestorePanelToSavedPlacement() { |
| 203 NOTREACHED(); |
| 204 } |
| 205 |
| 206 void OverflowPanelStrip::DiscardSavedPanelPlacement() { |
| 207 NOTREACHED(); |
| 208 } |
| 209 |
| 193 bool OverflowPanelStrip::CanDragPanel(const Panel* panel) const { | 210 bool OverflowPanelStrip::CanDragPanel(const Panel* panel) const { |
| 194 // All overflow panels are not draggable. | 211 // All overflow panels are not draggable. |
| 195 return false; | 212 return false; |
| 196 } | 213 } |
| 197 | 214 |
| 198 void OverflowPanelStrip::StartDraggingPanel(Panel* panel) { | 215 void OverflowPanelStrip::StartDraggingPanelWithinStrip(Panel* panel) { |
| 199 NOTREACHED(); | 216 NOTREACHED(); |
| 200 } | 217 } |
| 201 | 218 |
| 202 void OverflowPanelStrip::DragPanel(Panel* panel, int delta_x, int delta_y) { | 219 void OverflowPanelStrip::DragPanelWithinStrip(Panel* panel, |
| 220 int delta_x, |
| 221 int delta_y) { |
| 203 NOTREACHED(); | 222 NOTREACHED(); |
| 204 } | 223 } |
| 205 | 224 |
| 206 void OverflowPanelStrip::EndDraggingPanel(Panel* panel, bool cancelled) { | 225 void OverflowPanelStrip::EndDraggingPanelWithinStrip(Panel* panel, |
| 226 bool aborted) { |
| 207 NOTREACHED(); | 227 NOTREACHED(); |
| 208 } | 228 } |
| 209 | 229 |
| 210 void OverflowPanelStrip::RefreshLayout() { | 230 void OverflowPanelStrip::RefreshLayout() { |
| 211 if (panels_.empty()) | 231 if (panels_.empty()) |
| 212 return; | 232 return; |
| 213 DoRefresh(0, panels_.size() - 1); | 233 DoRefresh(0, panels_.size() - 1); |
| 214 } | 234 } |
| 215 | 235 |
| 216 void OverflowPanelStrip::DoRefresh(size_t start_index, size_t end_index) { | 236 void OverflowPanelStrip::DoRefresh(size_t start_index, size_t end_index) { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 // expanded overflow panels when in full screen mode so no need | 429 // expanded overflow panels when in full screen mode so no need |
| 410 // to detect when mouse hovers over the overflow strip. | 430 // to detect when mouse hovers over the overflow strip. |
| 411 if (is_full_screen) | 431 if (is_full_screen) |
| 412 panel_manager_->mouse_watcher()->RemoveObserver(this); | 432 panel_manager_->mouse_watcher()->RemoveObserver(this); |
| 413 else | 433 else |
| 414 panel_manager_->mouse_watcher()->AddObserver(this); | 434 panel_manager_->mouse_watcher()->AddObserver(this); |
| 415 | 435 |
| 416 for (size_t i = 0; i < panels_.size(); ++i) | 436 for (size_t i = 0; i < panels_.size(); ++i) |
| 417 panels_[i]->FullScreenModeChanged(is_full_screen); | 437 panels_[i]->FullScreenModeChanged(is_full_screen); |
| 418 } | 438 } |
| OLD | NEW |