| OLD | NEW |
| 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/panels/panel_mouse_watcher_win.h" | 11 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
| 12 #include "chrome/browser/ui/views/frame/browser_frame.h" | 12 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 13 #include "grit/chromium_strings.h" | 13 #include "grit/chromium_strings.h" |
| 14 #include "ui/base/animation/slide_animation.h" | 14 #include "ui/base/animation/slide_animation.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 16 #include "views/widget/widget.h" | 16 #include "views/widget/widget.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 // This value is experimental and subjective. | 19 // This value is experimental and subjective. |
| 20 const int kSetBoundsAnimationMs = 180; | 20 const int kSetBoundsAnimationMs = 180; |
| 21 | 21 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 44 restored_height_(bounds.height()), | 44 restored_height_(bounds.height()), |
| 45 closed_(false), | 45 closed_(false), |
| 46 focused_(false), | 46 focused_(false), |
| 47 mouse_pressed_(false), | 47 mouse_pressed_(false), |
| 48 mouse_dragging_state_(NO_DRAGGING), | 48 mouse_dragging_state_(NO_DRAGGING), |
| 49 is_drawing_attention_(false), | 49 is_drawing_attention_(false), |
| 50 old_focused_view_(NULL) { | 50 old_focused_view_(NULL) { |
| 51 } | 51 } |
| 52 | 52 |
| 53 PanelBrowserView::~PanelBrowserView() { | 53 PanelBrowserView::~PanelBrowserView() { |
| 54 if (PanelMouseWatcher::GetInstance()->IsSubscribed(this)) |
| 55 PanelMouseWatcher::GetInstance()->RemoveSubscriber(this); |
| 54 } | 56 } |
| 55 | 57 |
| 56 void PanelBrowserView::Init() { | 58 void PanelBrowserView::Init() { |
| 57 BrowserView::Init(); | 59 BrowserView::Init(); |
| 58 | 60 |
| 59 GetWidget()->SetAlwaysOnTop(true); | 61 GetWidget()->SetAlwaysOnTop(true); |
| 60 GetWidget()->non_client_view()->SetAccessibleName( | 62 GetWidget()->non_client_view()->SetAccessibleName( |
| 61 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 63 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 62 } | 64 } |
| 63 | 65 |
| 64 void PanelBrowserView::Close() { | 66 void PanelBrowserView::Close() { |
| 65 GetWidget()->RemoveObserver(this); | 67 GetWidget()->RemoveObserver(this); |
| 66 closed_ = true; | 68 closed_ = true; |
| 67 | 69 |
| 68 // Cancel any currently running animation since we're closing down. | 70 // Cancel any currently running animation since we're closing down. |
| 69 if (bounds_animator_.get()) | 71 if (bounds_animator_.get()) |
| 70 bounds_animator_.reset(); | 72 bounds_animator_.reset(); |
| 71 | 73 |
| 72 ::BrowserView::Close(); | 74 ::BrowserView::Close(); |
| 73 | |
| 74 // Stop the global mouse watcher only if we do not have any panels up. | |
| 75 #if defined(OS_WIN) | |
| 76 if (panel_->manager()->num_panels() == 1) | |
| 77 StopMouseWatcher(); | |
| 78 #endif | |
| 79 } | 75 } |
| 80 | 76 |
| 81 bool PanelBrowserView::CanResize() const { | 77 bool PanelBrowserView::CanResize() const { |
| 82 return false; | 78 return false; |
| 83 } | 79 } |
| 84 | 80 |
| 85 bool PanelBrowserView::CanMaximize() const { | 81 bool PanelBrowserView::CanMaximize() const { |
| 86 return false; | 82 return false; |
| 87 } | 83 } |
| 88 | 84 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 204 |
| 209 void PanelBrowserView::SetPanelBounds(const gfx::Rect& bounds) { | 205 void PanelBrowserView::SetPanelBounds(const gfx::Rect& bounds) { |
| 210 SetBounds(bounds); | 206 SetBounds(bounds); |
| 211 } | 207 } |
| 212 | 208 |
| 213 void PanelBrowserView::OnPanelExpansionStateChanged( | 209 void PanelBrowserView::OnPanelExpansionStateChanged( |
| 214 Panel::ExpansionState expansion_state) { | 210 Panel::ExpansionState expansion_state) { |
| 215 int height; | 211 int height; |
| 216 switch (expansion_state) { | 212 switch (expansion_state) { |
| 217 case Panel::EXPANDED: | 213 case Panel::EXPANDED: |
| 214 PanelMouseWatcher::GetInstance()->RemoveSubscriber(this); |
| 218 height = restored_height_; | 215 height = restored_height_; |
| 219 break; | 216 break; |
| 220 case Panel::TITLE_ONLY: | 217 case Panel::TITLE_ONLY: |
| 221 height = GetFrameView()->NonClientTopBorderHeight(); | 218 height = GetFrameView()->NonClientTopBorderHeight(); |
| 222 break; | 219 break; |
| 223 case Panel::MINIMIZED: | 220 case Panel::MINIMIZED: |
| 224 height = PanelManager::minimized_panel_height(); | 221 height = PanelManager::minimized_panel_height(); |
| 225 | 222 PanelMouseWatcher::GetInstance()->AddSubscriber(this); |
| 226 // Start the mouse watcher so that we can bring up the minimized panels. | |
| 227 // TODO(jianli): Need to support mouse watching in ChromeOS. | |
| 228 #if defined(OS_WIN) | |
| 229 EnsureMouseWatcherStarted(); | |
| 230 #endif | |
| 231 break; | 223 break; |
| 232 default: | 224 default: |
| 233 NOTREACHED(); | 225 NOTREACHED(); |
| 234 height = restored_height_; | 226 height = restored_height_; |
| 235 break; | 227 break; |
| 236 } | 228 } |
| 237 | 229 |
| 238 int bottom = panel_->manager()->GetBottomPositionForExpansionState( | 230 int bottom = panel_->manager()->GetBottomPositionForExpansionState( |
| 239 expansion_state); | 231 expansion_state); |
| 240 gfx::Rect bounds = bounds_; | 232 gfx::Rect bounds = bounds_; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 }; | 465 }; |
| 474 | 466 |
| 475 // static | 467 // static |
| 476 NativePanelTesting* NativePanelTesting::Create(NativePanel* native_panel) { | 468 NativePanelTesting* NativePanelTesting::Create(NativePanel* native_panel) { |
| 477 return new NativePanelTestingWin(static_cast<PanelBrowserView*>( | 469 return new NativePanelTestingWin(static_cast<PanelBrowserView*>( |
| 478 native_panel)); | 470 native_panel)); |
| 479 } | 471 } |
| 480 | 472 |
| 481 // static | 473 // static |
| 482 PanelMouseWatcher* NativePanelTesting::GetPanelMouseWatcherInstance() { | 474 PanelMouseWatcher* NativePanelTesting::GetPanelMouseWatcherInstance() { |
| 483 return NULL; | 475 return PanelMouseWatcher::GetInstance(); |
| 484 } | 476 } |
| 485 | 477 |
| 486 NativePanelTestingWin::NativePanelTestingWin( | 478 NativePanelTestingWin::NativePanelTestingWin( |
| 487 PanelBrowserView* panel_browser_view) : | 479 PanelBrowserView* panel_browser_view) : |
| 488 panel_browser_view_(panel_browser_view) { | 480 panel_browser_view_(panel_browser_view) { |
| 489 } | 481 } |
| 490 | 482 |
| 491 void NativePanelTestingWin::PressLeftMouseButtonTitlebar( | 483 void NativePanelTestingWin::PressLeftMouseButtonTitlebar( |
| 492 const gfx::Point& point) { | 484 const gfx::Point& point) { |
| 493 panel_browser_view_->OnTitlebarMousePressed(point); | 485 panel_browser_view_->OnTitlebarMousePressed(point); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 509 void NativePanelTestingWin::CancelDragTitlebar() { | 501 void NativePanelTestingWin::CancelDragTitlebar() { |
| 510 panel_browser_view_->OnTitlebarMouseCaptureLost(); | 502 panel_browser_view_->OnTitlebarMouseCaptureLost(); |
| 511 } | 503 } |
| 512 | 504 |
| 513 void NativePanelTestingWin::FinishDragTitlebar() { | 505 void NativePanelTestingWin::FinishDragTitlebar() { |
| 514 panel_browser_view_->OnTitlebarMouseReleased(); | 506 panel_browser_view_->OnTitlebarMouseReleased(); |
| 515 } | 507 } |
| 516 | 508 |
| 517 void NativePanelTestingWin::SetMousePositionForMinimizeRestore( | 509 void NativePanelTestingWin::SetMousePositionForMinimizeRestore( |
| 518 const gfx::Point& hover_point) { | 510 const gfx::Point& hover_point) { |
| 519 NOTIMPLEMENTED(); | 511 PanelMouseWatcher::GetInstance()->HandleMouseMovement(hover_point); |
| 512 MessageLoopForUI::current()->RunAllPending(); |
| 520 } | 513 } |
| 521 | 514 |
| 522 int NativePanelTestingWin::TitleOnlyHeight() const { | 515 int NativePanelTestingWin::TitleOnlyHeight() const { |
| 523 NOTIMPLEMENTED(); | 516 return panel_browser_view_->GetFrameView()->NonClientTopBorderHeight(); |
| 524 return -1; | |
| 525 } | 517 } |
| OLD | NEW |