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

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

Issue 8776035: Add PanelOverflowStrip to handle panel overflow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Prepare for final landing 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
« no previous file with comments | « chrome/browser/ui/panels/panel.h ('k') | chrome/browser/ui/panels/panel_browser_frame_view.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) 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.h" 5 #include "chrome/browser/ui/panels/panel.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/extensions/extension_prefs.h" 8 #include "chrome/browser/extensions/extension_prefs.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/tabs/tab_strip_model.h" 11 #include "chrome/browser/tabs/tab_strip_model.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/panels/native_panel.h" 13 #include "chrome/browser/ui/panels/native_panel.h"
14 #include "chrome/browser/ui/panels/panel_manager.h" 14 #include "chrome/browser/ui/panels/panel_manager.h"
15 #include "chrome/browser/ui/panels/panel_overflow_strip.h"
16 #include "chrome/browser/ui/panels/panel_strip.h"
15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
16 #include "chrome/browser/ui/window_sizer.h" 18 #include "chrome/browser/ui/window_sizer.h"
17 #include "chrome/browser/web_applications/web_app.h" 19 #include "chrome/browser/web_applications/web_app.h"
18 #include "chrome/common/extensions/extension.h" 20 #include "chrome/common/extensions/extension.h"
19 #include "content/browser/renderer_host/render_view_host.h" 21 #include "content/browser/renderer_host/render_view_host.h"
20 #include "content/browser/tab_contents/tab_contents.h" 22 #include "content/browser/tab_contents/tab_contents.h"
21 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
22 #include "content/public/browser/notification_source.h" 24 #include "content/public/browser/notification_source.h"
23 #include "content/public/browser/notification_types.h" 25 #include "content/public/browser/notification_types.h"
24 #include "ui/gfx/rect.h" 26 #include "ui/gfx/rect.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 DCHECK(min_size.height() <= max_size.height()); 116 DCHECK(min_size.height() <= max_size.height());
115 min_size_ = min_size; 117 min_size_ = min_size;
116 max_size_ = max_size; 118 max_size_ = max_size;
117 119
118 ConfigureAutoResize(browser()->GetSelectedTabContents()); 120 ConfigureAutoResize(browser()->GetSelectedTabContents());
119 } 121 }
120 122
121 void Panel::SetExpansionState(ExpansionState new_state) { 123 void Panel::SetExpansionState(ExpansionState new_state) {
122 if (expansion_state_ == new_state) 124 if (expansion_state_ == new_state)
123 return; 125 return;
124
125 ExpansionState old_state = expansion_state_; 126 ExpansionState old_state = expansion_state_;
126 expansion_state_ = new_state; 127 expansion_state_ = new_state;
127 128
128 int height; 129 manager()->OnPanelExpansionStateChanged(this, old_state);
129 switch (expansion_state_) {
130 case EXPANDED:
131 height = restored_size_.height();
132 break;
133 case TITLE_ONLY:
134 height = native_panel_->TitleOnlyHeight();
135 break;
136 case MINIMIZED:
137 height = kMinimizedPanelHeight;
138 break;
139 default:
140 NOTREACHED();
141 height = restored_size_.height();
142 break;
143 }
144
145 int bottom = manager()->GetBottomPositionForExpansionState(expansion_state_);
146 gfx::Rect bounds = native_panel_->GetPanelBounds();
147 bounds.set_y(bottom - height);
148 bounds.set_height(height);
149 SetPanelBounds(bounds);
150
151 manager()->OnPanelExpansionStateChanged(old_state, new_state);
152 130
153 // The minimized panel should not get the focus. 131 // The minimized panel should not get the focus.
154 if (expansion_state_ == MINIMIZED) 132 if (expansion_state_ == MINIMIZED)
155 Deactivate(); 133 Deactivate();
156 134
157 content::NotificationService::current()->Notify( 135 content::NotificationService::current()->Notify(
158 chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE, 136 chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE,
159 content::Source<Panel>(this), 137 content::Source<Panel>(this),
160 content::NotificationService::NoDetails()); 138 content::NotificationService::NoDetails());
161 } 139 }
(...skipping 20 matching lines...) Expand all
182 160
183 bool Panel::IsDrawingAttention() const { 161 bool Panel::IsDrawingAttention() const {
184 return native_panel_->IsDrawingAttention(); 162 return native_panel_->IsDrawingAttention();
185 } 163 }
186 164
187 void Panel::FullScreenModeChanged(bool is_full_screen) { 165 void Panel::FullScreenModeChanged(bool is_full_screen) {
188 native_panel_->FullScreenModeChanged(is_full_screen); 166 native_panel_->FullScreenModeChanged(is_full_screen);
189 } 167 }
190 168
191 void Panel::Show() { 169 void Panel::Show() {
192 native_panel_->ShowPanel(); 170 // Don't show panel as active if it is in overflow state.
171 if (expansion_state_ == IN_OVERFLOW)
172 ShowInactive();
173 else
174 native_panel_->ShowPanel();
193 } 175 }
194 176
195 void Panel::ShowInactive() { 177 void Panel::ShowInactive() {
196 native_panel_->ShowPanelInactive(); 178 native_panel_->ShowPanelInactive();
197 } 179 }
198 180
199 void Panel::SetBounds(const gfx::Rect& bounds) { 181 void Panel::SetBounds(const gfx::Rect& bounds) {
200 // Ignore any SetBounds requests since the bounds are completely controlled 182 // Ignore any SetBounds requests since the bounds are completely controlled
201 // by panel manager. 183 // by panel manager.
202 } 184 }
203 185
204 // Close() may be called multiple times if the browser window is not ready to 186 // Close() may be called multiple times if the browser window is not ready to
205 // close on the first attempt. 187 // close on the first attempt.
206 void Panel::Close() { 188 void Panel::Close() {
207 native_panel_->ClosePanel(); 189 native_panel_->ClosePanel();
208 } 190 }
209 191
192 void Panel::MoveOutOfOverflow() {
193 if (expansion_state_ != Panel::IN_OVERFLOW)
194 return;
195 manager()->panel_overflow_strip()->Remove(this);
196 manager()->panel_strip()->AddPanel(this);
197 }
198
210 void Panel::Activate() { 199 void Panel::Activate() {
200 MoveOutOfOverflow();
201
211 // Make sure the panel is expanded when activated programmatically, 202 // Make sure the panel is expanded when activated programmatically,
212 // so the user input does not go into collapsed window. 203 // so the user input does not go into collapsed window.
213 SetExpansionState(Panel::EXPANDED); 204 SetExpansionState(Panel::EXPANDED);
214 native_panel_->ActivatePanel(); 205 native_panel_->ActivatePanel();
215 } 206 }
216 207
217 void Panel::Deactivate() { 208 void Panel::Deactivate() {
218 native_panel_->DeactivatePanel(); 209 native_panel_->DeactivatePanel();
219 } 210 }
220 211
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 bounds.set_y(bounds.bottom() - restored_size_.height()); 262 bounds.set_y(bounds.bottom() - restored_size_.height());
272 bounds.set_x(bounds.right() - restored_size_.width()); 263 bounds.set_x(bounds.right() - restored_size_.width());
273 bounds.set_size(restored_size_); 264 bounds.set_size(restored_size_);
274 return bounds; 265 return bounds;
275 } 266 }
276 267
277 gfx::Rect Panel::GetBounds() const { 268 gfx::Rect Panel::GetBounds() const {
278 return native_panel_->GetPanelBounds(); 269 return native_panel_->GetPanelBounds();
279 } 270 }
280 271
272 int Panel::TitleOnlyHeight() const {
273 return native_panel_->TitleOnlyHeight();
274 }
275
276 gfx::Size Panel::IconOnlySize() const {
277 return native_panel_->IconOnlySize();
278 }
279
280 void Panel::EnsureFullyVisible() {
281 native_panel_->EnsurePanelFullyVisible();
282 }
283
281 bool Panel::IsMaximized() const { 284 bool Panel::IsMaximized() const {
282 // Size of panels is managed by PanelManager, they are never 'zoomed'. 285 // Size of panels is managed by PanelManager, they are never 'zoomed'.
283 return false; 286 return false;
284 } 287 }
285 288
286 bool Panel::IsMinimized() const { 289 bool Panel::IsMinimized() const {
287 return expansion_state_ != EXPANDED; 290 return expansion_state_ != EXPANDED;
288 } 291 }
289 292
290 void Panel::Maximize() { 293 void Panel::Maximize() {
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 native_panel_->ContentSizeFromWindowSize(max_size_)); 632 native_panel_->ContentSizeFromWindowSize(max_size_));
630 } 633 }
631 634
632 void Panel::OnWindowSizeAvailable() { 635 void Panel::OnWindowSizeAvailable() {
633 ConfigureAutoResize(browser()->GetSelectedTabContents()); 636 ConfigureAutoResize(browser()->GetSelectedTabContents());
634 } 637 }
635 638
636 void Panel::DestroyBrowser() { 639 void Panel::DestroyBrowser() {
637 native_panel_->DestroyPanelBrowser(); 640 native_panel_->DestroyPanelBrowser();
638 } 641 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel.h ('k') | chrome/browser/ui/panels/panel_browser_frame_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698