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

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

Issue 8776035: Add PanelOverflowStrip to handle panel overflow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix 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_browser_view.h" 5 #include "chrome/browser/ui/panels/panel_browser_view.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/ui/panels/panel.h" 9 #include "chrome/browser/ui/panels/panel.h"
10 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" 10 #include "chrome/browser/ui/panels/panel_browser_frame_view.h"
11 #include "chrome/browser/ui/panels/panel_manager.h" 11 #include "chrome/browser/ui/panels/panel_manager.h"
12 #include "chrome/browser/ui/panels/panel_overflow_strip.h"
13 #include "chrome/browser/ui/panels/panel_strip.h"
12 #include "chrome/browser/ui/views/frame/browser_frame.h" 14 #include "chrome/browser/ui/views/frame/browser_frame.h"
13 #include "chrome/browser/ui/webui/task_manager_dialog.h" 15 #include "chrome/browser/ui/webui/task_manager_dialog.h"
14 #include "chrome/common/chrome_notification_types.h" 16 #include "chrome/common/chrome_notification_types.h"
15 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
16 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
17 #include "grit/chromium_strings.h" 19 #include "grit/chromium_strings.h"
18 #include "ui/base/animation/slide_animation.h" 20 #include "ui/base/animation/slide_animation.h"
19 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/views/controls/label.h" 22 #include "ui/views/controls/label.h"
21 #include "ui/views/widget/widget.h" 23 #include "ui/views/widget/widget.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 104 }
103 105
104 bool PanelBrowserView::CanMaximize() const { 106 bool PanelBrowserView::CanMaximize() const {
105 return false; 107 return false;
106 } 108 }
107 109
108 void PanelBrowserView::SetBounds(const gfx::Rect& bounds) { 110 void PanelBrowserView::SetBounds(const gfx::Rect& bounds) {
109 SetBoundsInternal(bounds, true); 111 SetBoundsInternal(bounds, true);
110 } 112 }
111 113
112 void PanelBrowserView::SetBoundsInternal(const gfx::Rect& bounds, 114 void PanelBrowserView::SetBoundsInternal(const gfx::Rect& new_bounds,
113 bool animate) { 115 bool animate) {
114 if (bounds_ == bounds) 116 if (bounds_ == new_bounds)
115 return; 117 return;
116 bounds_ = bounds; 118
119 // TODO(jianli): this is just a temporary hack to check if we need to show
jennb 2011/12/02 21:16:58 Could you create a crbug for this and put # here?
jianli 2011/12/02 23:23:46 Bug created. Yes, I think we need to put it in nat
120 // or hide the panel app icon in the taskbar.
121 int panel_strip_area_left =
jennb 2011/12/02 21:16:58 Isn't it easier to just do: ShowOrHidePanelAppIco
jianli 2011/12/02 23:23:46 I rather keep it this way since we're going to cle
122 panel()->manager()->panel_strip()->display_area().x();
123 bool app_icon_shown = bounds_.x() >= panel_strip_area_left;
124 bool app_icon_to_show = new_bounds.x() >= panel_strip_area_left;
125 if (app_icon_shown != app_icon_to_show)
126 ShowOrHidePanelAppIcon(app_icon_to_show);
127
128 bounds_ = new_bounds;
117 129
118 // No animation if the panel is being dragged. 130 // No animation if the panel is being dragged.
119 if (!animate || mouse_dragging_state_ == DRAGGING_STARTED) { 131 if (!animate || mouse_dragging_state_ == DRAGGING_STARTED) {
120 ::BrowserView::SetBounds(bounds); 132 ::BrowserView::SetBounds(new_bounds);
121 return; 133 return;
122 } 134 }
123 135
124 animation_start_bounds_ = GetBounds(); 136 animation_start_bounds_ = GetBounds();
125 137
126 if (!bounds_animator_.get()) { 138 if (!bounds_animator_.get()) {
127 bounds_animator_.reset(new ui::SlideAnimation(this)); 139 bounds_animator_.reset(new ui::SlideAnimation(this));
128 bounds_animator_->SetSlideDuration(kSetBoundsAnimationMs); 140 bounds_animator_->SetSlideDuration(kSetBoundsAnimationMs);
129 } 141 }
130 142
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 390
379 Browser* PanelBrowserView::GetPanelBrowser() const { 391 Browser* PanelBrowserView::GetPanelBrowser() const {
380 return browser(); 392 return browser();
381 } 393 }
382 394
383 void PanelBrowserView::DestroyPanelBrowser() { 395 void PanelBrowserView::DestroyPanelBrowser() {
384 DestroyBrowser(); 396 DestroyBrowser();
385 } 397 }
386 398
387 gfx::Size PanelBrowserView::IconOnlySize() const { 399 gfx::Size PanelBrowserView::IconOnlySize() const {
388 // TODO(jianli): to be implemented. 400 return GetFrameView()->IconOnlySize();
389 return gfx::Size();
390 } 401 }
391 402
392 void PanelBrowserView::EnsurePanelFullyVisible() { 403 void PanelBrowserView::EnsurePanelFullyVisible() {
393 // TODO(jianli): to be implemented. 404 #if defined(OS_WIN) && !defined(USE_AURA)
405 ::SetWindowPos(GetNativeHandle(), HWND_TOP, 0, 0, 0, 0,
406 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
407 #else
408 NOTIMPLEMENTED();
409 #endif
394 } 410 }
395 411
396 PanelBrowserFrameView* PanelBrowserView::GetFrameView() const { 412 PanelBrowserFrameView* PanelBrowserView::GetFrameView() const {
397 return static_cast<PanelBrowserFrameView*>(frame()->GetFrameView()); 413 return static_cast<PanelBrowserFrameView*>(frame()->GetFrameView());
398 } 414 }
399 415
400 bool PanelBrowserView::OnTitlebarMousePressed(const gfx::Point& location) { 416 bool PanelBrowserView::OnTitlebarMousePressed(const gfx::Point& location) {
401 // |location| is in the view's coordinate system. Convert it to the screen 417 // |location| is in the view's coordinate system. Convert it to the screen
402 // coordinate system. 418 // coordinate system.
403 mouse_location_ = location; 419 mouse_location_ = location;
404 views::View::ConvertPointToScreen(this, &mouse_location_); 420 views::View::ConvertPointToScreen(this, &mouse_location_);
405 421
406 mouse_pressed_ = true; 422 mouse_pressed_ = true;
407 mouse_pressed_time_ = base::TimeTicks::Now(); 423 mouse_pressed_time_ = base::TimeTicks::Now();
408 mouse_dragging_state_ = NO_DRAGGING; 424 mouse_dragging_state_ = NO_DRAGGING;
409 return true; 425 return true;
410 } 426 }
411 427
412 bool PanelBrowserView::OnTitlebarMouseDragged(const gfx::Point& location) { 428 bool PanelBrowserView::OnTitlebarMouseDragged(const gfx::Point& location) {
413 if (!mouse_pressed_) 429 if (!mouse_pressed_)
414 return false; 430 return false;
415 431
432 // Dragging is not supported for overflow panel.
433 if (panel_->expansion_state() == Panel::IN_OVERFLOW)
434 return true;
435
416 gfx::Point last_mouse_location = mouse_location_; 436 gfx::Point last_mouse_location = mouse_location_;
417 437
418 // |location| is in the view's coordinate system. Convert it to the screen 438 // |location| is in the view's coordinate system. Convert it to the screen
419 // coordinate system. 439 // coordinate system.
420 mouse_location_ = location; 440 mouse_location_ = location;
421 views::View::ConvertPointToScreen(this, &mouse_location_); 441 views::View::ConvertPointToScreen(this, &mouse_location_);
422 442
423 int delta_x = mouse_location_.x() - last_mouse_location.x(); 443 int delta_x = mouse_location_.x() - last_mouse_location.x();
424 int delta_y = mouse_location_.y() - last_mouse_location.y(); 444 int delta_y = mouse_location_.y() - last_mouse_location.y();
425 if (mouse_dragging_state_ == NO_DRAGGING && 445 if (mouse_dragging_state_ == NO_DRAGGING &&
(...skipping 20 matching lines...) Expand all
446 } 466 }
447 467
448 return EndDragging(false); 468 return EndDragging(false);
449 } 469 }
450 470
451 // If the panel drag was cancelled before the mouse is released, do not treat 471 // If the panel drag was cancelled before the mouse is released, do not treat
452 // this as a click. 472 // this as a click.
453 if (mouse_dragging_state_ != NO_DRAGGING) 473 if (mouse_dragging_state_ != NO_DRAGGING)
454 return true; 474 return true;
455 475
476 // If the panel is in overflow, move it to the normal strip.
477 if (panel_->expansion_state() == Panel::IN_OVERFLOW) {
478 panel_->manager()->panel_overflow_strip()->Remove(panel_.get());
479 panel_->manager()->panel_strip()->AddPanel(panel_.get());
480 return true;
481 }
482
456 // Do not minimize the panel when we just clear the attention state. This is 483 // Do not minimize the panel when we just clear the attention state. This is
457 // a hack to prevent the panel from being minimized when the user clicks on 484 // a hack to prevent the panel from being minimized when the user clicks on
458 // the title-bar to clear the attention. 485 // the title-bar to clear the attention.
459 if (panel_->expansion_state() == Panel::EXPANDED && 486 if (panel_->expansion_state() == Panel::EXPANDED &&
460 base::TimeTicks::Now() - attention_cleared_time_ < 487 base::TimeTicks::Now() - attention_cleared_time_ <
461 base::TimeDelta::FromMilliseconds(kSuspendMinimizeOnClickIntervalMs)) { 488 base::TimeDelta::FromMilliseconds(kSuspendMinimizeOnClickIntervalMs)) {
462 return true; 489 return true;
463 } 490 }
464 491
465 // Do not minimize the panel if it is long click. 492 // Do not minimize the panel if it is long click.
(...skipping 18 matching lines...) Expand all
484 // Only handle clicks that started in our window. 511 // Only handle clicks that started in our window.
485 if (!mouse_pressed_) 512 if (!mouse_pressed_)
486 return false; 513 return false;
487 mouse_pressed_ = false; 514 mouse_pressed_ = false;
488 515
489 mouse_dragging_state_ = DRAGGING_ENDED; 516 mouse_dragging_state_ = DRAGGING_ENDED;
490 panel_->manager()->EndDragging(cancelled); 517 panel_->manager()->EndDragging(cancelled);
491 return true; 518 return true;
492 } 519 }
493 520
521 void PanelBrowserView::ShowOrHidePanelAppIcon(bool show) {
522 #if defined(OS_WIN) && !defined(USE_AURA)
523 gfx::NativeWindow native_window = GetNativeHandle();
524 ::ShowWindow(native_window, SW_HIDE);
525 int style = ::GetWindowLong(native_window, GWL_EXSTYLE);
526 if (show)
527 style &= (~WS_EX_TOOLWINDOW);
528 else
529 style |= WS_EX_TOOLWINDOW;
530 ::SetWindowLong(native_window, GWL_EXSTYLE, style);
531 ::ShowWindow(native_window, SW_SHOWNA);
532 #else
533 NOTIMPLEMENTED();
534 #endif
535 }
536
494 // NativePanelTesting implementation. 537 // NativePanelTesting implementation.
495 class NativePanelTestingWin : public NativePanelTesting { 538 class NativePanelTestingWin : public NativePanelTesting {
496 public: 539 public:
497 explicit NativePanelTestingWin(PanelBrowserView* panel_browser_view); 540 explicit NativePanelTestingWin(PanelBrowserView* panel_browser_view);
498 541
499 private: 542 private:
500 virtual void PressLeftMouseButtonTitlebar( 543 virtual void PressLeftMouseButtonTitlebar(
501 const gfx::Point& point) OVERRIDE; 544 const gfx::Point& point) OVERRIDE;
502 virtual void ReleaseMouseButtonTitlebar() OVERRIDE; 545 virtual void ReleaseMouseButtonTitlebar() OVERRIDE;
503 virtual void DragTitlebar(int delta_x, int delta_y) OVERRIDE; 546 virtual void DragTitlebar(int delta_x, int delta_y) OVERRIDE;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 } 616 }
574 617
575 bool NativePanelTestingWin::IsWindowSizeKnown() const { 618 bool NativePanelTestingWin::IsWindowSizeKnown() const {
576 return true; 619 return true;
577 } 620 }
578 621
579 bool NativePanelTestingWin::IsAnimatingBounds() const { 622 bool NativePanelTestingWin::IsAnimatingBounds() const {
580 return panel_browser_view_->bounds_animator_.get() && 623 return panel_browser_view_->bounds_animator_.get() &&
581 panel_browser_view_->bounds_animator_->is_animating(); 624 panel_browser_view_->bounds_animator_->is_animating();
582 } 625 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698