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/panel_overflow_strip.h" | 5 #include "chrome/browser/ui/panels/panel_overflow_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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 74 } |
75 | 75 |
76 void PanelOverflowStrip::UpdateCurrentWidth() { | 76 void PanelOverflowStrip::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 PanelOverflowStrip::AddPanel(Panel* panel) { | 81 void PanelOverflowStrip::AddPanel(Panel* panel) { |
82 // TODO(jianli): consider using other container to improve the perf for | 82 // TODO(jianli): consider using other container to improve the perf for |
83 // inserting to the front. http://crbug.com/106222 | 83 // inserting to the front. http://crbug.com/106222 |
84 DCHECK_EQ(Panel::IN_OVERFLOW, panel->expansion_state()); | 84 DCHECK_EQ(Panel::IN_OVERFLOW, panel->layout_state()); |
85 // Newly created panels that were temporarily in the panel strip | 85 // Newly created panels that were temporarily in the panel strip |
86 // are added to the back of the overflow, whereas panels that are | 86 // are added to the back of the overflow, whereas panels that are |
87 // bumped from the panel strip by other panels go to the front | 87 // bumped from the panel strip by other panels go to the front |
88 // of overflow. | 88 // of overflow. |
89 if (panel->has_temporary_layout()) { | 89 if (panel->has_temporary_layout()) { |
90 panel->set_has_temporary_layout(false); | 90 panel->set_has_temporary_layout(false); |
91 panels_.push_back(panel); | 91 panels_.push_back(panel); |
92 DoRefresh(panels_.size() - 1, panels_.size() - 1); | 92 DoRefresh(panels_.size() - 1, panels_.size() - 1); |
93 } else { | 93 } else { |
94 panels_.insert(panels_.begin(), panel); | 94 panels_.insert(panels_.begin(), panel); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 void PanelOverflowStrip::RemoveAll() { | 139 void PanelOverflowStrip::RemoveAll() { |
140 // Make a copy of the iterator as closing panels can modify the vector. | 140 // Make a copy of the iterator as closing panels can modify the vector. |
141 Panels panels_copy = panels_; | 141 Panels panels_copy = panels_; |
142 | 142 |
143 // Start from the bottom to avoid reshuffling. | 143 // Start from the bottom to avoid reshuffling. |
144 for (Panels::reverse_iterator iter = panels_copy.rbegin(); | 144 for (Panels::reverse_iterator iter = panels_copy.rbegin(); |
145 iter != panels_copy.rend(); ++iter) | 145 iter != panels_copy.rend(); ++iter) |
146 (*iter)->Close(); | 146 (*iter)->Close(); |
147 } | 147 } |
148 | 148 |
149 void PanelOverflowStrip::OnPanelExpansionStateChanged(Panel* panel) { | 149 void PanelOverflowStrip::OnPanelLayoutStateChanged( |
| 150 Panel* panel, Panel::LayoutState old_state) { |
150 // Only care about new state being overflow. | 151 // Only care about new state being overflow. |
151 if (panel->expansion_state() != Panel::IN_OVERFLOW) | 152 if (panel->layout_state() != Panel::IN_OVERFLOW) |
152 return; | 153 return; |
153 | 154 |
154 panel_manager_->panel_strip()->Remove(panel); | 155 panel_manager_->panel_strip()->Remove(panel); |
155 AddPanel(panel); | 156 AddPanel(panel); |
156 panel->SetAppIconVisibility(false); | 157 panel->SetAppIconVisibility(false); |
157 panel->set_draggable(false); | 158 panel->set_draggable(false); |
158 } | 159 } |
159 | 160 |
160 void PanelOverflowStrip::OnPanelAttentionStateChanged(Panel* panel) { | 161 void PanelOverflowStrip::OnPanelAttentionStateChanged(Panel* panel) { |
161 DCHECK(panel->expansion_state() == Panel::IN_OVERFLOW); | 162 DCHECK_EQ(Panel::IN_OVERFLOW, panel->layout_state()); |
162 UpdateOverflowIndicatorAttention(); | 163 UpdateOverflowIndicatorAttention(); |
163 } | 164 } |
164 | 165 |
165 void PanelOverflowStrip::Refresh() { | 166 void PanelOverflowStrip::Refresh() { |
166 if (panels_.empty()) | 167 if (panels_.empty()) |
167 return; | 168 return; |
168 DoRefresh(0, panels_.size() - 1); | 169 DoRefresh(0, panels_.size() - 1); |
169 } | 170 } |
170 | 171 |
171 void PanelOverflowStrip::DoRefresh(size_t start_index, size_t end_index) { | 172 void PanelOverflowStrip::DoRefresh(size_t start_index, size_t end_index) { |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 bounds.set_width(current_display_width); | 345 bounds.set_width(current_display_width); |
345 overflow_indicator_->SetBounds(bounds); | 346 overflow_indicator_->SetBounds(bounds); |
346 overflow_indicator_->SetCount(num_panels() - max_visible_panels); | 347 overflow_indicator_->SetCount(num_panels() - max_visible_panels); |
347 } | 348 } |
348 } | 349 } |
349 | 350 |
350 void PanelOverflowStrip::OnFullScreenModeChanged(bool is_full_screen) { | 351 void PanelOverflowStrip::OnFullScreenModeChanged(bool is_full_screen) { |
351 for (size_t i = 0; i < panels_.size(); ++i) | 352 for (size_t i = 0; i < panels_.size(); ++i) |
352 panels_[i]->FullScreenModeChanged(is_full_screen); | 353 panels_[i]->FullScreenModeChanged(is_full_screen); |
353 } | 354 } |
OLD | NEW |