| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "views/controls/menu/menu_controller.h" | 5 #include "views/controls/menu/menu_controller.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/time.h" | 8 #include "base/time.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "ui/base/dragdrop/os_exchange_data.h" | 10 #include "ui/base/dragdrop/os_exchange_data.h" |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 SendMouseReleaseToActiveView(source, event, true); | 516 SendMouseReleaseToActiveView(source, event, true); |
| 517 return; | 517 return; |
| 518 } | 518 } |
| 519 } | 519 } |
| 520 | 520 |
| 521 // We can use Ctrl+click or the middle mouse button to recursively open urls | 521 // We can use Ctrl+click or the middle mouse button to recursively open urls |
| 522 // for selected folder menu items. If it's only a left click, show the | 522 // for selected folder menu items. If it's only a left click, show the |
| 523 // contents of the folder. | 523 // contents of the folder. |
| 524 if (!part.is_scroll() && part.menu && | 524 if (!part.is_scroll() && part.menu && |
| 525 !(part.menu->HasSubmenu() && | 525 !(part.menu->HasSubmenu() && |
| 526 (event.GetFlags() == MouseEvent::EF_LEFT_BUTTON_DOWN))) { | 526 (event.flags() == MouseEvent::EF_LEFT_BUTTON_DOWN))) { |
| 527 if (active_mouse_view_) { | 527 if (active_mouse_view_) { |
| 528 SendMouseReleaseToActiveView(source, event, false); | 528 SendMouseReleaseToActiveView(source, event, false); |
| 529 return; | 529 return; |
| 530 } | 530 } |
| 531 if (part.menu->GetDelegate()->IsTriggerableEvent(event)) { | 531 if (part.menu->GetDelegate()->IsTriggerableEvent(event)) { |
| 532 Accept(part.menu, event.GetFlags()); | 532 Accept(part.menu, event.flags()); |
| 533 return; | 533 return; |
| 534 } | 534 } |
| 535 } else if (part.type == MenuPart::MENU_ITEM) { | 535 } else if (part.type == MenuPart::MENU_ITEM) { |
| 536 // User either clicked on empty space, or a menu that has children. | 536 // User either clicked on empty space, or a menu that has children. |
| 537 SetSelection(part.menu ? part.menu : state_.item, | 537 SetSelection(part.menu ? part.menu : state_.item, |
| 538 SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY); | 538 SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY); |
| 539 } | 539 } |
| 540 SendMouseReleaseToActiveView(source, event, true); | 540 SendMouseReleaseToActiveView(source, event, true); |
| 541 } | 541 } |
| 542 | 542 |
| (...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1788 active_mouse_view_ = target; | 1788 active_mouse_view_ = target; |
| 1789 if (active_mouse_view_) { | 1789 if (active_mouse_view_) { |
| 1790 gfx::Point target_point(target_menu_loc); | 1790 gfx::Point target_point(target_menu_loc); |
| 1791 View::ConvertPointToView(target_menu, active_mouse_view_, &target_point); | 1791 View::ConvertPointToView(target_menu, active_mouse_view_, &target_point); |
| 1792 MouseEvent mouse_entered_event(MouseEvent::ET_MOUSE_ENTERED, | 1792 MouseEvent mouse_entered_event(MouseEvent::ET_MOUSE_ENTERED, |
| 1793 target_point.x(), target_point.y(), 0); | 1793 target_point.x(), target_point.y(), 0); |
| 1794 active_mouse_view_->OnMouseEntered(mouse_entered_event); | 1794 active_mouse_view_->OnMouseEntered(mouse_entered_event); |
| 1795 | 1795 |
| 1796 MouseEvent mouse_pressed_event(MouseEvent::ET_MOUSE_PRESSED, | 1796 MouseEvent mouse_pressed_event(MouseEvent::ET_MOUSE_PRESSED, |
| 1797 target_point.x(), target_point.y(), | 1797 target_point.x(), target_point.y(), |
| 1798 event.GetFlags()); | 1798 event.flags()); |
| 1799 active_mouse_view_->OnMousePressed(mouse_pressed_event); | 1799 active_mouse_view_->OnMousePressed(mouse_pressed_event); |
| 1800 } | 1800 } |
| 1801 } | 1801 } |
| 1802 | 1802 |
| 1803 if (active_mouse_view_) { | 1803 if (active_mouse_view_) { |
| 1804 gfx::Point target_point(target_menu_loc); | 1804 gfx::Point target_point(target_menu_loc); |
| 1805 View::ConvertPointToView(target_menu, active_mouse_view_, &target_point); | 1805 View::ConvertPointToView(target_menu, active_mouse_view_, &target_point); |
| 1806 MouseEvent mouse_dragged_event(MouseEvent::ET_MOUSE_DRAGGED, | 1806 MouseEvent mouse_dragged_event(MouseEvent::ET_MOUSE_DRAGGED, |
| 1807 target_point.x(), target_point.y(), | 1807 target_point.x(), target_point.y(), |
| 1808 event.GetFlags()); | 1808 event.flags()); |
| 1809 active_mouse_view_->OnMouseDragged(mouse_dragged_event); | 1809 active_mouse_view_->OnMouseDragged(mouse_dragged_event); |
| 1810 } | 1810 } |
| 1811 } | 1811 } |
| 1812 | 1812 |
| 1813 void MenuController::SendMouseReleaseToActiveView(SubmenuView* event_source, | 1813 void MenuController::SendMouseReleaseToActiveView(SubmenuView* event_source, |
| 1814 const MouseEvent& event, | 1814 const MouseEvent& event, |
| 1815 bool cancel) { | 1815 bool cancel) { |
| 1816 if (!active_mouse_view_) | 1816 if (!active_mouse_view_) |
| 1817 return; | 1817 return; |
| 1818 | 1818 |
| 1819 gfx::Point target_loc(event.location()); | 1819 gfx::Point target_loc(event.location()); |
| 1820 View::ConvertPointToScreen(event_source->GetScrollViewContainer(), | 1820 View::ConvertPointToScreen(event_source->GetScrollViewContainer(), |
| 1821 &target_loc); | 1821 &target_loc); |
| 1822 View::ConvertPointToView(NULL, active_mouse_view_, &target_loc); | 1822 View::ConvertPointToView(NULL, active_mouse_view_, &target_loc); |
| 1823 MouseEvent release_event(Event::ET_MOUSE_RELEASED, target_loc.x(), | 1823 MouseEvent release_event(Event::ET_MOUSE_RELEASED, target_loc.x(), |
| 1824 target_loc.y(), event.GetFlags()); | 1824 target_loc.y(), event.flags()); |
| 1825 // Reset the active_mouse_view_ before sending mouse released. That way if if | 1825 // Reset the active_mouse_view_ before sending mouse released. That way if if |
| 1826 // calls back to use we aren't in a weird state. | 1826 // calls back to use we aren't in a weird state. |
| 1827 View* active_view = active_mouse_view_; | 1827 View* active_view = active_mouse_view_; |
| 1828 active_mouse_view_ = NULL; | 1828 active_mouse_view_ = NULL; |
| 1829 active_view->OnMouseReleased(release_event, cancel); | 1829 active_view->OnMouseReleased(release_event, cancel); |
| 1830 } | 1830 } |
| 1831 | 1831 |
| 1832 void MenuController::SendMouseReleaseToActiveView() { | 1832 void MenuController::SendMouseReleaseToActiveView() { |
| 1833 if (!active_mouse_view_) | 1833 if (!active_mouse_view_) |
| 1834 return; | 1834 return; |
| 1835 | 1835 |
| 1836 MouseEvent release_event(Event::ET_MOUSE_RELEASED, -1, -1, 0); | 1836 MouseEvent release_event(Event::ET_MOUSE_RELEASED, -1, -1, 0); |
| 1837 // Reset the active_mouse_view_ before sending mouse released. That way if if | 1837 // Reset the active_mouse_view_ before sending mouse released. That way if if |
| 1838 // calls back to use we aren't in a weird state. | 1838 // calls back to use we aren't in a weird state. |
| 1839 View* active_view = active_mouse_view_; | 1839 View* active_view = active_mouse_view_; |
| 1840 active_mouse_view_ = NULL; | 1840 active_mouse_view_ = NULL; |
| 1841 active_view->OnMouseReleased(release_event, true); | 1841 active_view->OnMouseReleased(release_event, true); |
| 1842 } | 1842 } |
| 1843 | 1843 |
| 1844 } // namespace views | 1844 } // namespace views |
| OLD | NEW |