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

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

Issue 8885019: Fix 2 panel overflow related bugs on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_strip.h" 10 #include "chrome/browser/ui/panels/panel_strip.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 DCHECK(panel->expansion_state() == Panel::IN_OVERFLOW); 95 DCHECK(panel->expansion_state() == Panel::IN_OVERFLOW);
96 } 96 }
97 97
98 void PanelOverflowStrip::Refresh() { 98 void PanelOverflowStrip::Refresh() {
99 if (panels_.empty()) 99 if (panels_.empty())
100 return; 100 return;
101 DoRefresh(0, panels_.size() - 1); 101 DoRefresh(0, panels_.size() - 1);
102 } 102 }
103 103
104 void PanelOverflowStrip::DoRefresh(size_t start_index, size_t end_index) { 104 void PanelOverflowStrip::DoRefresh(size_t start_index, size_t end_index) {
105 if (panels_.empty()) 105 if (panels_.empty() || start_index == panels_.size())
jennb 2011/12/08 20:05:46 Sufficient to just check start_index >= end_index?
106 return; 106 return;
107 107
108 DCHECK(start_index < panels_.size()); 108 DCHECK(start_index < panels_.size());
109 DCHECK(end_index < panels_.size()); 109 DCHECK(end_index < panels_.size());
110 110
111 for (size_t index = start_index; index <= end_index; ++index) { 111 for (size_t index = start_index; index <= end_index; ++index) {
112 Panel* panel = panels_[index]; 112 Panel* panel = panels_[index];
113 gfx::Rect new_bounds = ComputeLayout(index, 113 gfx::Rect new_bounds = ComputeLayout(index,
114 panel->IconOnlySize()); 114 panel->IconOnlySize());
115 DCHECK(!new_bounds.IsEmpty());
116 panel->SetPanelBounds(new_bounds); 115 panel->SetPanelBounds(new_bounds);
117 } 116 }
118 } 117 }
119 118
120 gfx::Rect PanelOverflowStrip::ComputeLayout( 119 gfx::Rect PanelOverflowStrip::ComputeLayout(
121 size_t index, const gfx::Size& iconified_size) const { 120 size_t index, const gfx::Size& iconified_size) const {
122 DCHECK(index != kInvalidPanelIndex); 121 DCHECK(index != kInvalidPanelIndex);
123 122
124 gfx::Rect bounds; 123 gfx::Rect bounds;
125 int bottom = (index == 0) ? display_area_.bottom() : 124 int bottom = (index == 0) ? display_area_.bottom() :
(...skipping 22 matching lines...) Expand all
148 void PanelOverflowStrip::OnMouseMove(const gfx::Point& mouse_position) { 147 void PanelOverflowStrip::OnMouseMove(const gfx::Point& mouse_position) {
149 bool show_overflow_titles = ShouldShowOverflowTitles(mouse_position); 148 bool show_overflow_titles = ShouldShowOverflowTitles(mouse_position);
150 ShowOverflowTitles(show_overflow_titles); 149 ShowOverflowTitles(show_overflow_titles);
151 } 150 }
152 151
153 bool PanelOverflowStrip::ShouldShowOverflowTitles( 152 bool PanelOverflowStrip::ShouldShowOverflowTitles(
154 const gfx::Point& mouse_position) const { 153 const gfx::Point& mouse_position) const {
155 if (panels_.empty()) 154 if (panels_.empty())
156 return false; 155 return false;
157 156
158 int width = are_overflow_titles_shown_ ? kOverflowAreaHoverWidth 157 int width;
159 : display_area_.width(); 158 Panel* top_visible_panel;
159 if (are_overflow_titles_shown_) {
160 width = kOverflowAreaHoverWidth;
161 top_visible_panel = panels_.back();
162 } else {
163 width = display_area_.width();
164 top_visible_panel = num_panels() >= kMaxVisibleOverflowPanelsAllowed ?
165 panels_[kMaxVisibleOverflowPanelsAllowed - 1] : panels_.back();
166 }
160 return mouse_position.x() <= display_area_.x() + width && 167 return mouse_position.x() <= display_area_.x() + width &&
161 panels_.back()->GetBounds().y() <= mouse_position.y() && 168 top_visible_panel->GetBounds().y() <= mouse_position.y() &&
162 mouse_position.y() <= display_area_.bottom(); 169 mouse_position.y() <= display_area_.bottom();
163 } 170 }
164 171
165 void PanelOverflowStrip::ShowOverflowTitles(bool show_overflow_titles) { 172 void PanelOverflowStrip::ShowOverflowTitles(bool show_overflow_titles) {
166 if (show_overflow_titles == are_overflow_titles_shown_) 173 if (show_overflow_titles == are_overflow_titles_shown_)
167 return; 174 return;
168 are_overflow_titles_shown_ = show_overflow_titles; 175 are_overflow_titles_shown_ = show_overflow_titles;
169 176
177 if (panels_.empty())
178 return;
179
170 if (show_overflow_titles) { 180 if (show_overflow_titles) {
171 overflow_hover_animator_start_width_ = display_area_.width(); 181 overflow_hover_animator_start_width_ = display_area_.width();
172 overflow_hover_animator_end_width_ = kOverflowAreaHoverWidth; 182 overflow_hover_animator_end_width_ = kOverflowAreaHoverWidth;
173 183
174 // We need to bring all overflow panels to the top of z-order since the 184 // We need to bring all overflow panels to the top of z-order since the
175 // active panel might obscure the expanded overflow panels. 185 // active panel might obscure the expanded overflow panels.
176 for (Panels::iterator iter = panels_.begin(); 186 for (Panels::iterator iter = panels_.begin();
177 iter != panels_.end(); ++iter) { 187 iter != panels_.end(); ++iter) {
178 (*iter)->EnsureFullyVisible(); 188 (*iter)->EnsureFullyVisible();
179 } 189 }
(...skipping 30 matching lines...) Expand all
210 } 220 }
211 221
212 overflow_panel->SetPanelBoundsInstantly(bounds); 222 overflow_panel->SetPanelBoundsInstantly(bounds);
213 } 223 }
214 } 224 }
215 225
216 void PanelOverflowStrip::OnFullScreenModeChanged(bool is_full_screen) { 226 void PanelOverflowStrip::OnFullScreenModeChanged(bool is_full_screen) {
217 for (size_t i = 0; i < panels_.size(); ++i) 227 for (size_t i = 0; i < panels_.size(); ++i)
218 panels_[i]->FullScreenModeChanged(is_full_screen); 228 panels_[i]->FullScreenModeChanged(is_full_screen);
219 } 229 }
OLDNEW
« chrome/browser/ui/panels/panel_manager.cc ('K') | « chrome/browser/ui/panels/panel_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698