OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_frame_view.h" | 5 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/themes/theme_service.h" | 10 #include "chrome/browser/themes/theme_service.h" |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 top_height, | 535 top_height, |
536 std::max(0, width() - (2 * border_thickness)), | 536 std::max(0, width() - (2 * border_thickness)), |
537 std::max(0, height() - top_height - border_thickness)); | 537 std::max(0, height() - top_height - border_thickness)); |
538 } | 538 } |
539 | 539 |
540 void PanelBrowserFrameView::GetAccessibleState(ui::AccessibleViewState* state) { | 540 void PanelBrowserFrameView::GetAccessibleState(ui::AccessibleViewState* state) { |
541 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR; | 541 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR; |
542 } | 542 } |
543 | 543 |
544 bool PanelBrowserFrameView::OnMousePressed(const views::MouseEvent& event) { | 544 bool PanelBrowserFrameView::OnMousePressed(const views::MouseEvent& event) { |
545 gfx::Point mouse_location = event.location(); | |
546 | |
547 if (CanResize() && | 545 if (CanResize() && |
548 IsHitTestValueForResizing(NonClientHitTest(mouse_location))) | 546 IsHitTestValueForResizing(NonClientHitTest(event.location()))) |
549 return BrowserNonClientFrameView::OnMousePressed(event); | 547 return BrowserNonClientFrameView::OnMousePressed(event); |
550 | 548 |
551 // |event.location| is in the view's coordinate system. Convert it to the | |
552 // screen coordinate system. | |
553 views::View::ConvertPointToScreen(this, &mouse_location); | |
554 | |
555 if (event.IsOnlyLeftMouseButton() && | 549 if (event.IsOnlyLeftMouseButton() && |
556 panel_browser_view_->OnTitlebarMousePressed(mouse_location)) { | 550 panel_browser_view_->OnTitlebarMousePressed(event)) { |
557 return true; | 551 return true; |
558 } | 552 } |
559 return BrowserNonClientFrameView::OnMousePressed(event); | 553 return BrowserNonClientFrameView::OnMousePressed(event); |
560 } | 554 } |
561 | 555 |
562 bool PanelBrowserFrameView::OnMouseDragged(const views::MouseEvent& event) { | 556 bool PanelBrowserFrameView::OnMouseDragged(const views::MouseEvent& event) { |
563 // |event.location| is in the view's coordinate system. Convert it to the | 557 if (panel_browser_view_->OnTitlebarMouseDragged(event)) |
564 // screen coordinate system. | |
565 gfx::Point mouse_location = event.location(); | |
566 views::View::ConvertPointToScreen(this, &mouse_location); | |
567 | |
568 if (panel_browser_view_->OnTitlebarMouseDragged(mouse_location)) | |
569 return true; | 558 return true; |
570 return BrowserNonClientFrameView::OnMouseDragged(event); | 559 return BrowserNonClientFrameView::OnMouseDragged(event); |
571 } | 560 } |
572 | 561 |
573 void PanelBrowserFrameView::OnMouseReleased(const views::MouseEvent& event) { | 562 void PanelBrowserFrameView::OnMouseReleased(const views::MouseEvent& event) { |
574 if (panel_browser_view_->OnTitlebarMouseReleased()) | 563 if (panel_browser_view_->OnTitlebarMouseReleased(event)) |
575 return; | 564 return; |
576 BrowserNonClientFrameView::OnMouseReleased(event); | 565 BrowserNonClientFrameView::OnMouseReleased(event); |
577 } | 566 } |
578 | 567 |
579 void PanelBrowserFrameView::OnMouseCaptureLost() { | 568 void PanelBrowserFrameView::OnMouseCaptureLost() { |
580 if (panel_browser_view_->OnTitlebarMouseCaptureLost()) | 569 if (panel_browser_view_->OnTitlebarMouseCaptureLost()) |
581 return; | 570 return; |
582 BrowserNonClientFrameView::OnMouseCaptureLost(); | 571 BrowserNonClientFrameView::OnMouseCaptureLost(); |
583 } | 572 } |
584 | 573 |
585 void PanelBrowserFrameView::ButtonPressed(views::Button* sender, | 574 void PanelBrowserFrameView::ButtonPressed(views::Button* sender, |
586 const views::Event& event) { | 575 const views::Event& event) { |
587 if (sender == close_button_) | 576 if (sender == close_button_) |
588 frame()->Close(); | 577 frame()->Close(); |
589 else if (sender == minimize_button_) | 578 else if (sender == minimize_button_) |
590 panel_browser_view_->panel()->Minimize(); | 579 panel_browser_view_->MinimizeButtonPressed(event); |
591 else if (sender == restore_button_) | 580 else if (sender == restore_button_) |
592 panel_browser_view_->panel()->Restore(); | 581 panel_browser_view_->RestoreButtonPressed(event); |
593 } | 582 } |
594 | 583 |
595 bool PanelBrowserFrameView::ShouldTabIconViewAnimate() const { | 584 bool PanelBrowserFrameView::ShouldTabIconViewAnimate() const { |
596 // This function is queried during the creation of the window as the | 585 // This function is queried during the creation of the window as the |
597 // TabIconView we host is initialized, so we need to NULL check the selected | 586 // TabIconView we host is initialized, so we need to NULL check the selected |
598 // WebContents because in this condition there is not yet a selected tab. | 587 // WebContents because in this condition there is not yet a selected tab. |
599 WebContents* current_tab = browser_view()->GetSelectedWebContents(); | 588 WebContents* current_tab = browser_view()->GetSelectedWebContents(); |
600 return current_tab ? current_tab->IsLoading() : false; | 589 return current_tab ? current_tab->IsLoading() : false; |
601 } | 590 } |
602 | 591 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 } | 800 } |
812 | 801 |
813 bool PanelBrowserFrameView::CanResize() const { | 802 bool PanelBrowserFrameView::CanResize() const { |
814 return panel_browser_view_->panel()->CanResizeByMouse() != | 803 return panel_browser_view_->panel()->CanResizeByMouse() != |
815 panel::NOT_RESIZABLE; | 804 panel::NOT_RESIZABLE; |
816 } | 805 } |
817 | 806 |
818 bool PanelBrowserFrameView::IsShowingTitlebarOnly() const { | 807 bool PanelBrowserFrameView::IsShowingTitlebarOnly() const { |
819 return height() <= kTitlebarHeight; | 808 return height() <= kTitlebarHeight; |
820 } | 809 } |
OLD | NEW |