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

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

Issue 7242017: Support minimizing the panel into 3-pixel line on Windows. Also support bringing up/down the titl... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 6 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
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_browser_view.h" 5 #include "chrome/browser/ui/panels/panel_browser_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/ui/panels/panel.h" 8 #include "chrome/browser/ui/panels/panel.h"
9 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" 9 #include "chrome/browser/ui/panels/panel_browser_frame_view.h"
10 #include "chrome/browser/ui/panels/panel_manager.h" 10 #include "chrome/browser/ui/panels/panel_manager.h"
11 #include "chrome/browser/ui/views/frame/browser_frame.h" 11 #include "chrome/browser/ui/views/frame/browser_frame.h"
12 #include "grit/chromium_strings.h" 12 #include "grit/chromium_strings.h"
13 #include "ui/base/animation/slide_animation.h" 13 #include "ui/base/animation/slide_animation.h"
14 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
15 #include "views/widget/widget.h" 15 #include "views/widget/widget.h"
16 16
17 namespace { 17 namespace {
18 // This value is experimental and subjective. 18 // This value is experimental and subjective.
19 const int kSetBoundsAnimationMs = 200; 19 const int kSetBoundsAnimationMs = 200;
20
21 // The panel can be fully minimized to 3-pixel lines.
22 const int kFullyMinimizedHeight = 3;
20 } 23 }
21 24
22 NativePanel* Panel::CreateNativePanel(Browser* browser, Panel* panel, 25 NativePanel* Panel::CreateNativePanel(Browser* browser, Panel* panel,
23 const gfx::Rect& bounds) { 26 const gfx::Rect& bounds) {
24 PanelBrowserView* view = new PanelBrowserView(browser, panel, bounds); 27 PanelBrowserView* view = new PanelBrowserView(browser, panel, bounds);
25 (new BrowserFrame(view))->InitBrowserFrame(); 28 BrowserFrame* frame = new BrowserFrame(view);
29 frame->set_frame_type(views::Widget::FRAME_TYPE_FORCE_CUSTOM);
jennb 2011/06/27 23:18:02 Curious - why did set_frame_type have to be moved
jianli 2011/06/29 01:28:12 Not needed now. Reverted.
30 frame->InitBrowserFrame();
26 return view; 31 return view;
27 } 32 }
28 33
29 PanelBrowserView::PanelBrowserView(Browser* browser, Panel* panel, 34 PanelBrowserView::PanelBrowserView(Browser* browser, Panel* panel,
30 const gfx::Rect& bounds) 35 const gfx::Rect& bounds)
31 : BrowserView(browser), 36 : BrowserView(browser),
32 panel_(panel), 37 panel_(panel),
33 bounds_(bounds), 38 bounds_(bounds),
34 original_height_(bounds.height()), 39 original_height_(bounds.height()),
35 minimized_(false), 40 expand_state_(FULLY_RESTORED),
36 closed_(false), 41 closed_(false),
37 focused_(false), 42 focused_(false),
38 mouse_pressed_(false), 43 mouse_pressed_(false),
39 mouse_dragging_(false) { 44 mouse_dragging_(false) {
40 } 45 }
41 46
42 PanelBrowserView::~PanelBrowserView() { 47 PanelBrowserView::~PanelBrowserView() {
43 } 48 }
44 49
45 void PanelBrowserView::Init() { 50 void PanelBrowserView::Init() {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 151
147 gfx::Rect PanelBrowserView::GetPanelBounds() const { 152 gfx::Rect PanelBrowserView::GetPanelBounds() const {
148 return bounds_; 153 return bounds_;
149 } 154 }
150 155
151 void PanelBrowserView::SetPanelBounds(const gfx::Rect& bounds) { 156 void PanelBrowserView::SetPanelBounds(const gfx::Rect& bounds) {
152 SetBounds(bounds); 157 SetBounds(bounds);
153 } 158 }
154 159
155 void PanelBrowserView::MinimizePanel() { 160 void PanelBrowserView::MinimizePanel() {
156 if (minimized_) 161 if (expand_state_ == FULLY_MINIMIZED)
157 return; 162 return;
163 expand_state_ = FULLY_MINIMIZED;
158 164
159 minimized_ = true; 165 AdjustHeight(kFullyMinimizedHeight);
160 gfx::Rect bounds = GetPanelBounds();
161 original_height_ = bounds.height();
162 bounds.set_height(GetFrameView()->NonClientTopBorderHeight());
163 bounds.set_y(bounds.y() + original_height_ - bounds.height());
164 SetPanelBounds(bounds);
165 } 166 }
166 167
167 void PanelBrowserView::RestorePanel() { 168 void PanelBrowserView::RestorePanel(bool titlebar_only) {
168 if (!minimized_) 169 if (titlebar_only) {
169 return; 170 // It is not allowed to "restore" from full height to titlebar height.
170 171 if (expand_state_ != FULLY_MINIMIZED)
jennb 2011/06/27 23:18:02 Should this be a DCHECK instead?
jianli 2011/06/29 01:28:12 Not needed due to logic change.
171 minimized_ = false; 172 return;
172 gfx::Rect bounds = GetPanelBounds(); 173 expand_state_ = TITLEBAR_RESTORED;
173 bounds.set_y(bounds.y() - original_height_ + bounds.height()); 174 AdjustHeight(GetFrameView()->NonClientTopBorderHeight());
174 bounds.set_height(original_height_); 175 } else {
175 SetPanelBounds(bounds); 176 if (expand_state_ == FULLY_RESTORED)
177 return;
178 expand_state_ = FULLY_RESTORED;
179 AdjustHeight(original_height_);
180 }
176 } 181 }
177 182
178 void PanelBrowserView::ClosePanel() { 183 void PanelBrowserView::ClosePanel() {
179 Close(); 184 Close();
180 } 185 }
181 186
182 void PanelBrowserView::ActivatePanel() { 187 void PanelBrowserView::ActivatePanel() {
183 Activate(); 188 Activate();
184 } 189 }
185 190
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 mouse_pressed_ = false; 267 mouse_pressed_ = false;
263 268
264 if (!mouse_dragging_) 269 if (!mouse_dragging_)
265 cancelled = true; 270 cancelled = true;
266 mouse_dragging_ = false; 271 mouse_dragging_ = false;
267 panel_->manager()->EndDragging(cancelled); 272 panel_->manager()->EndDragging(cancelled);
268 return true; 273 return true;
269 } 274 }
270 275
271 void PanelBrowserView::MinimizeOrRestore() { 276 void PanelBrowserView::MinimizeOrRestore() {
272 if (minimized_) 277 if (expand_state_ != FULLY_RESTORED)
273 panel_->Restore(); 278 panel_->manager()->Restore(panel_.get(), false);
274 else 279 else
275 panel_->Minimize(); 280 panel_->manager()->Minimize(panel_.get());
276 } 281 }
282
283 void PanelBrowserView::AdjustHeight(int height) {
284 gfx::Rect bounds = bounds_;
285 bounds.set_y(bounds.y() + bounds.height() - height);
286 bounds.set_height(height);
287 SetBounds(bounds);
288 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698