Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: chrome/browser/ui/panels/overflow_panel_strip.cc

Issue 9560002: Cleanup to keep panel from manipulating its panel strip assignment directly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed final nits Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/panels/overflow_panel_strip.h ('k') | chrome/browser/ui/panels/panel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
9 #include "chrome/browser/ui/panels/panel_manager.h" 8 #include "chrome/browser/ui/panels/panel_manager.h"
10 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" 9 #include "chrome/browser/ui/panels/panel_mouse_watcher.h"
11 #include "chrome/browser/ui/panels/panel_overflow_indicator.h" 10 #include "chrome/browser/ui/panels/panel_overflow_indicator.h"
12 #include "chrome/common/chrome_notification_types.h" 11 #include "chrome/common/chrome_notification_types.h"
13 #include "content/public/browser/notification_service.h" 12 #include "content/public/browser/notification_service.h"
14 #include "ui/base/animation/slide_animation.h" 13 #include "ui/base/animation/slide_animation.h"
15 14
16 namespace { 15 namespace {
17 // The width of the overflow area that is expanded to show more info, i.e. 16 // The width of the overflow area that is expanded to show more info, i.e.
18 // titles, when the mouse hovers over the area. 17 // titles, when the mouse hovers over the area.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 74 }
76 75
77 void OverflowPanelStrip::UpdateCurrentWidth() { 76 void OverflowPanelStrip::UpdateCurrentWidth() {
78 current_display_width_ = are_overflow_titles_shown_ ? kOverflowAreaHoverWidth 77 current_display_width_ = are_overflow_titles_shown_ ? kOverflowAreaHoverWidth
79 : display_area_.width(); 78 : display_area_.width();
80 } 79 }
81 80
82 void OverflowPanelStrip::AddPanel(Panel* panel) { 81 void OverflowPanelStrip::AddPanel(Panel* panel) {
83 // TODO(jianli): consider using other container to improve the perf for 82 // TODO(jianli): consider using other container to improve the perf for
84 // inserting to the front. http://crbug.com/106222 83 // inserting to the front. http://crbug.com/106222
85 DCHECK_EQ(this, panel->panel_strip()); 84 DCHECK_NE(this, panel->panel_strip());
85 panel->set_panel_strip(this);
86
86 // Newly created panels that were temporarily in the panel strip 87 // Newly created panels that were temporarily in the panel strip
87 // are added to the back of the overflow, whereas panels that are 88 // 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 89 // bumped from the panel strip by other panels go to the front
89 // of overflow. 90 // of overflow.
90 if (panel->has_temporary_layout()) { 91 if (panel->has_temporary_layout()) {
91 panel->set_has_temporary_layout(false); 92 panel->set_has_temporary_layout(false);
92 panels_.push_back(panel); 93 panels_.push_back(panel);
93 DoRefresh(panels_.size() - 1, panels_.size() - 1); 94 DoRefresh(panels_.size() - 1, panels_.size() - 1);
94 } else { 95 } else {
95 panels_.insert(panels_.begin(), panel); 96 panels_.insert(panels_.begin(), panel);
(...skipping 12 matching lines...) Expand all
108 // Update the overflow indicator only when the number of overflow panels go 109 // Update the overflow indicator only when the number of overflow panels go
109 // beyond the maximum visible limit. 110 // beyond the maximum visible limit.
110 if (num_panels() > max_visible_panels_) { 111 if (num_panels() > max_visible_panels_) {
111 if (!overflow_indicator_.get()) { 112 if (!overflow_indicator_.get()) {
112 overflow_indicator_.reset(PanelOverflowIndicator::Create()); 113 overflow_indicator_.reset(PanelOverflowIndicator::Create());
113 } 114 }
114 UpdateOverflowIndicatorCount(); 115 UpdateOverflowIndicatorCount();
115 } 116 }
116 } 117 }
117 118
118 bool OverflowPanelStrip::RemovePanel(Panel* panel) { 119 void OverflowPanelStrip::RemovePanel(Panel* panel) {
120 DCHECK_EQ(this, panel->panel_strip());
121 panel->set_panel_strip(NULL);
122
119 size_t index = 0; 123 size_t index = 0;
120 Panels::iterator iter = panels_.begin(); 124 Panels::iterator iter = panels_.begin();
121 for (; iter != panels_.end(); ++iter, ++index) 125 for (; iter != panels_.end(); ++iter, ++index)
122 if (*iter == panel) 126 if (*iter == panel)
123 break; 127 break;
124 if (iter == panels_.end()) 128 DCHECK(iter != panels_.end());
125 return false;
126 129
127 panels_.erase(iter); 130 panels_.erase(iter);
128 DoRefresh(index, panels_.size() - 1); 131 DoRefresh(index, panels_.size() - 1);
129 132
130 if (panels_.empty() && !panel_manager_->is_full_screen()) 133 if (panels_.empty() && !panel_manager_->is_full_screen())
131 panel_manager_->mouse_watcher()->RemoveObserver(this); 134 panel_manager_->mouse_watcher()->RemoveObserver(this);
132 135
133 // Update the overflow indicator. If the number of overflow panels fall below 136 // 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. 137 // the maximum visible limit, we do not need the overflow indicator any more.
135 if (num_panels() < max_visible_panels_) 138 if (num_panels() < max_visible_panels_)
136 overflow_indicator_.reset(); 139 overflow_indicator_.reset();
137 else 140 else
138 UpdateOverflowIndicatorCount(); 141 UpdateOverflowIndicatorCount();
139
140 return true;
141 } 142 }
142 143
143 void OverflowPanelStrip::CloseAll() { 144 void OverflowPanelStrip::CloseAll() {
144 // Make a copy of the iterator as closing panels can modify the vector. 145 // Make a copy of the iterator as closing panels can modify the vector.
145 Panels panels_copy = panels_; 146 Panels panels_copy = panels_;
146 147
147 // Start from the bottom to avoid reshuffling. 148 // Start from the bottom to avoid reshuffling.
148 for (Panels::reverse_iterator iter = panels_copy.rbegin(); 149 for (Panels::reverse_iterator iter = panels_copy.rbegin();
149 iter != panels_copy.rend(); ++iter) 150 iter != panels_copy.rend(); ++iter)
150 (*iter)->Close(); 151 (*iter)->Close();
151 } 152 }
152 153
153 void OverflowPanelStrip::ResizePanelWindow( 154 void OverflowPanelStrip::ResizePanelWindow(
154 Panel* panel, const gfx::Size& preferred_window_size) { 155 Panel* panel, const gfx::Size& preferred_window_size) {
155 // Overflow uses its own panel window sizes. 156 // Overflow uses its own panel window sizes.
156 } 157 }
157 158
158 void OverflowPanelStrip::OnPanelAttentionStateChanged(Panel* panel) { 159 void OverflowPanelStrip::OnPanelAttentionStateChanged(Panel* panel) {
159 DCHECK_EQ(this, panel->panel_strip()); 160 DCHECK_EQ(this, panel->panel_strip());
160 UpdateOverflowIndicatorAttention(); 161 UpdateOverflowIndicatorAttention();
161 } 162 }
162 163
163 void OverflowPanelStrip::ActivatePanel(Panel* panel) { 164 void OverflowPanelStrip::ActivatePanel(Panel* panel) {
164 DCHECK_EQ(this, panel->panel_strip()); 165 DCHECK_EQ(this, panel->panel_strip());
165 // Activating an overflow panel moves it to the docked panel strip. 166 // Activating an overflow panel moves it to the docked panel strip.
166 PanelStrip* docked_strip = panel_manager_->docked_strip(); 167 panel_manager_->MovePanelToStrip(panel, PanelStrip::DOCKED);
167 panel->MoveToStrip(docked_strip); 168 panel->panel_strip()->ActivatePanel(panel);
168 docked_strip->ActivatePanel(panel);
169 } 169 }
170 170
171 void OverflowPanelStrip::MinimizePanel(Panel* panel) { 171 void OverflowPanelStrip::MinimizePanel(Panel* panel) {
172 DCHECK_EQ(this, panel->panel_strip()); 172 DCHECK_EQ(this, panel->panel_strip());
173 // Overflow is already a minimized mode for a panel. Nothing more to do. 173 // Overflow is already a minimized mode for a panel. Nothing more to do.
174 } 174 }
175 175
176 void OverflowPanelStrip::RestorePanel(Panel* panel) { 176 void OverflowPanelStrip::RestorePanel(Panel* panel) {
177 DCHECK_EQ(this, panel->panel_strip()); 177 DCHECK_EQ(this, panel->panel_strip());
178 PanelStrip* docked_strip = panel_manager_->docked_strip(); 178 panel_manager_->MovePanelToStrip(panel, PanelStrip::DOCKED);
179 panel->MoveToStrip(docked_strip); 179 panel->panel_strip()->RestorePanel(panel);
180 docked_strip->RestorePanel(panel); 180 }
181
182 bool OverflowPanelStrip::IsPanelMinimized(const Panel* panel) const {
183 // All overflow panels are considered minimized.
184 return true;
181 } 185 }
182 186
183 bool OverflowPanelStrip::CanShowPanelAsActive(const Panel* panel) const { 187 bool OverflowPanelStrip::CanShowPanelAsActive(const Panel* panel) const {
184 // All overflow panels cannot be shown as active. 188 // All overflow panels cannot be shown as active.
185 return false; 189 return false;
186 } 190 }
187 191
188 bool OverflowPanelStrip::CanDragPanel(const Panel* panel) const { 192 bool OverflowPanelStrip::CanDragPanel(const Panel* panel) const {
189 // All overflow panels are not draggable. 193 // All overflow panels are not draggable.
190 return false; 194 return false;
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 // expanded overflow panels when in full screen mode so no need 399 // expanded overflow panels when in full screen mode so no need
396 // to detect when mouse hovers over the overflow strip. 400 // to detect when mouse hovers over the overflow strip.
397 if (is_full_screen) 401 if (is_full_screen)
398 panel_manager_->mouse_watcher()->RemoveObserver(this); 402 panel_manager_->mouse_watcher()->RemoveObserver(this);
399 else 403 else
400 panel_manager_->mouse_watcher()->AddObserver(this); 404 panel_manager_->mouse_watcher()->AddObserver(this);
401 405
402 for (size_t i = 0; i < panels_.size(); ++i) 406 for (size_t i = 0; i < panels_.size(); ++i)
403 panels_[i]->FullScreenModeChanged(is_full_screen); 407 panels_[i]->FullScreenModeChanged(is_full_screen);
404 } 408 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/overflow_panel_strip.h ('k') | chrome/browser/ui/panels/panel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698