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 "ui/views/controls/menu/menu_controller.h" | 5 #include "ui/views/controls/menu/menu_controller.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windowsx.h> | 8 #include <windowsx.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 2212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2223 if (target != active_mouse_view) { | 2223 if (target != active_mouse_view) { |
2224 SendMouseCaptureLostToActiveView(); | 2224 SendMouseCaptureLostToActiveView(); |
2225 active_mouse_view = target; | 2225 active_mouse_view = target; |
2226 SetActiveMouseView(active_mouse_view); | 2226 SetActiveMouseView(active_mouse_view); |
2227 if (active_mouse_view) { | 2227 if (active_mouse_view) { |
2228 gfx::Point target_point(target_menu_loc); | 2228 gfx::Point target_point(target_menu_loc); |
2229 View::ConvertPointToTarget( | 2229 View::ConvertPointToTarget( |
2230 target_menu, active_mouse_view, &target_point); | 2230 target_menu, active_mouse_view, &target_point); |
2231 ui::MouseEvent mouse_entered_event(ui::ET_MOUSE_ENTERED, | 2231 ui::MouseEvent mouse_entered_event(ui::ET_MOUSE_ENTERED, |
2232 target_point, target_point, | 2232 target_point, target_point, |
2233 0); | 2233 0, 0); |
2234 active_mouse_view->OnMouseEntered(mouse_entered_event); | 2234 active_mouse_view->OnMouseEntered(mouse_entered_event); |
2235 | 2235 |
2236 ui::MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED, | 2236 ui::MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED, |
2237 target_point, target_point, | 2237 target_point, target_point, |
2238 event.flags()); | 2238 event.flags(), |
| 2239 event.changed_button_flags()); |
2239 active_mouse_view->OnMousePressed(mouse_pressed_event); | 2240 active_mouse_view->OnMousePressed(mouse_pressed_event); |
2240 } | 2241 } |
2241 } | 2242 } |
2242 | 2243 |
2243 if (active_mouse_view) { | 2244 if (active_mouse_view) { |
2244 gfx::Point target_point(target_menu_loc); | 2245 gfx::Point target_point(target_menu_loc); |
2245 View::ConvertPointToTarget(target_menu, active_mouse_view, &target_point); | 2246 View::ConvertPointToTarget(target_menu, active_mouse_view, &target_point); |
2246 ui::MouseEvent mouse_dragged_event(ui::ET_MOUSE_DRAGGED, | 2247 ui::MouseEvent mouse_dragged_event(ui::ET_MOUSE_DRAGGED, |
2247 target_point, target_point, | 2248 target_point, target_point, |
2248 event.flags()); | 2249 event.flags(), |
| 2250 event.changed_button_flags()); |
2249 active_mouse_view->OnMouseDragged(mouse_dragged_event); | 2251 active_mouse_view->OnMouseDragged(mouse_dragged_event); |
2250 } | 2252 } |
2251 } | 2253 } |
2252 | 2254 |
2253 void MenuController::SendMouseReleaseToActiveView(SubmenuView* event_source, | 2255 void MenuController::SendMouseReleaseToActiveView(SubmenuView* event_source, |
2254 const ui::MouseEvent& event) { | 2256 const ui::MouseEvent& event) { |
2255 View* active_mouse_view = GetActiveMouseView(); | 2257 View* active_mouse_view = GetActiveMouseView(); |
2256 if (!active_mouse_view) | 2258 if (!active_mouse_view) |
2257 return; | 2259 return; |
2258 | 2260 |
2259 gfx::Point target_loc(event.location()); | 2261 gfx::Point target_loc(event.location()); |
2260 View::ConvertPointToScreen(event_source->GetScrollViewContainer(), | 2262 View::ConvertPointToScreen(event_source->GetScrollViewContainer(), |
2261 &target_loc); | 2263 &target_loc); |
2262 View::ConvertPointFromScreen(active_mouse_view, &target_loc); | 2264 View::ConvertPointFromScreen(active_mouse_view, &target_loc); |
2263 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, target_loc, target_loc, | 2265 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, target_loc, target_loc, |
2264 event.flags()); | 2266 event.flags(), event.changed_button_flags()); |
2265 // Reset active mouse view before sending mouse released. That way if it calls | 2267 // Reset active mouse view before sending mouse released. That way if it calls |
2266 // back to us, we aren't in a weird state. | 2268 // back to us, we aren't in a weird state. |
2267 SetActiveMouseView(NULL); | 2269 SetActiveMouseView(NULL); |
2268 active_mouse_view->OnMouseReleased(release_event); | 2270 active_mouse_view->OnMouseReleased(release_event); |
2269 } | 2271 } |
2270 | 2272 |
2271 void MenuController::SendMouseCaptureLostToActiveView() { | 2273 void MenuController::SendMouseCaptureLostToActiveView() { |
2272 View* active_mouse_view = GetActiveMouseView(); | 2274 View* active_mouse_view = GetActiveMouseView(); |
2273 if (!active_mouse_view) | 2275 if (!active_mouse_view) |
2274 return; | 2276 return; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2335 (!pending_state_.item->HasSubmenu() || | 2337 (!pending_state_.item->HasSubmenu() || |
2336 !pending_state_.item->GetSubmenu()->IsShowing())) { | 2338 !pending_state_.item->GetSubmenu()->IsShowing())) { |
2337 // On exit if the user hasn't selected an item with a submenu, move the | 2339 // On exit if the user hasn't selected an item with a submenu, move the |
2338 // selection back to the parent menu item. | 2340 // selection back to the parent menu item. |
2339 SetSelection(pending_state_.item->GetParentMenuItem(), | 2341 SetSelection(pending_state_.item->GetParentMenuItem(), |
2340 SELECTION_OPEN_SUBMENU); | 2342 SELECTION_OPEN_SUBMENU); |
2341 } | 2343 } |
2342 } | 2344 } |
2343 | 2345 |
2344 } // namespace views | 2346 } // namespace views |
OLD | NEW |