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

Side by Side Diff: ui/views/controls/menu/menu_controller.cc

Issue 1260453006: ui: events: Add a class to hold common touch and stylus properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address build problems, add accessor and unit tests. Created 5 years, 4 months 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
OLDNEW
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 #include "base/i18n/case_conversion.h" 7 #include "base/i18n/case_conversion.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 2241 matching lines...) Expand 10 before | Expand all | Expand 10 after
2252 } 2252 }
2253 View* active_mouse_view = GetActiveMouseView(); 2253 View* active_mouse_view = GetActiveMouseView();
2254 if (target != active_mouse_view) { 2254 if (target != active_mouse_view) {
2255 SendMouseCaptureLostToActiveView(); 2255 SendMouseCaptureLostToActiveView();
2256 active_mouse_view = target; 2256 active_mouse_view = target;
2257 SetActiveMouseView(active_mouse_view); 2257 SetActiveMouseView(active_mouse_view);
2258 if (active_mouse_view) { 2258 if (active_mouse_view) {
2259 gfx::Point target_point(target_menu_loc); 2259 gfx::Point target_point(target_menu_loc);
2260 View::ConvertPointToTarget( 2260 View::ConvertPointToTarget(
2261 target_menu, active_mouse_view, &target_point); 2261 target_menu, active_mouse_view, &target_point);
2262 ui::MouseEvent mouse_entered_event(ui::ET_MOUSE_ENTERED, target_point, 2262 ui::MouseEvent mouse_entered_event(
2263 target_point, ui::EventTimeForNow(), 0, 2263 ui::ET_MOUSE_ENTERED, target_point, target_point,
2264 0); 2264 ui::EventTimeForNow(), 0, 0,
2265 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
2265 active_mouse_view->OnMouseEntered(mouse_entered_event); 2266 active_mouse_view->OnMouseEntered(mouse_entered_event);
2266 2267
2267 ui::MouseEvent mouse_pressed_event( 2268 ui::MouseEvent mouse_pressed_event(
2268 ui::ET_MOUSE_PRESSED, target_point, target_point, 2269 ui::ET_MOUSE_PRESSED, target_point, target_point,
2269 ui::EventTimeForNow(), event.flags(), event.changed_button_flags()); 2270 ui::EventTimeForNow(), event.flags(), event.changed_button_flags(),
2271 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
2270 active_mouse_view->OnMousePressed(mouse_pressed_event); 2272 active_mouse_view->OnMousePressed(mouse_pressed_event);
2271 } 2273 }
2272 } 2274 }
2273 2275
2274 if (active_mouse_view) { 2276 if (active_mouse_view) {
2275 gfx::Point target_point(target_menu_loc); 2277 gfx::Point target_point(target_menu_loc);
2276 View::ConvertPointToTarget(target_menu, active_mouse_view, &target_point); 2278 View::ConvertPointToTarget(target_menu, active_mouse_view, &target_point);
2277 ui::MouseEvent mouse_dragged_event( 2279 ui::MouseEvent mouse_dragged_event(
2278 ui::ET_MOUSE_DRAGGED, target_point, target_point, ui::EventTimeForNow(), 2280 ui::ET_MOUSE_DRAGGED, target_point, target_point, ui::EventTimeForNow(),
2279 event.flags(), event.changed_button_flags()); 2281 event.flags(), event.changed_button_flags(),
2282 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
2280 active_mouse_view->OnMouseDragged(mouse_dragged_event); 2283 active_mouse_view->OnMouseDragged(mouse_dragged_event);
2281 } 2284 }
2282 } 2285 }
2283 2286
2284 void MenuController::SendMouseReleaseToActiveView(SubmenuView* event_source, 2287 void MenuController::SendMouseReleaseToActiveView(SubmenuView* event_source,
2285 const ui::MouseEvent& event) { 2288 const ui::MouseEvent& event) {
2286 View* active_mouse_view = GetActiveMouseView(); 2289 View* active_mouse_view = GetActiveMouseView();
2287 if (!active_mouse_view) 2290 if (!active_mouse_view)
2288 return; 2291 return;
2289 2292
2290 gfx::Point target_loc(event.location()); 2293 gfx::Point target_loc(event.location());
2291 View::ConvertPointToScreen(event_source->GetScrollViewContainer(), 2294 View::ConvertPointToScreen(event_source->GetScrollViewContainer(),
2292 &target_loc); 2295 &target_loc);
2293 View::ConvertPointFromScreen(active_mouse_view, &target_loc); 2296 View::ConvertPointFromScreen(active_mouse_view, &target_loc);
2294 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, target_loc, target_loc, 2297 ui::MouseEvent release_event(
2295 ui::EventTimeForNow(), event.flags(), 2298 ui::ET_MOUSE_RELEASED, target_loc, target_loc, ui::EventTimeForNow(),
2296 event.changed_button_flags()); 2299 event.flags(), event.changed_button_flags(),
2300 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
2297 // Reset active mouse view before sending mouse released. That way if it calls 2301 // Reset active mouse view before sending mouse released. That way if it calls
2298 // back to us, we aren't in a weird state. 2302 // back to us, we aren't in a weird state.
2299 SetActiveMouseView(NULL); 2303 SetActiveMouseView(NULL);
2300 active_mouse_view->OnMouseReleased(release_event); 2304 active_mouse_view->OnMouseReleased(release_event);
2301 } 2305 }
2302 2306
2303 void MenuController::SendMouseCaptureLostToActiveView() { 2307 void MenuController::SendMouseCaptureLostToActiveView() {
2304 View* active_mouse_view = GetActiveMouseView(); 2308 View* active_mouse_view = GetActiveMouseView();
2305 if (!active_mouse_view) 2309 if (!active_mouse_view)
2306 return; 2310 return;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2374 } 2378 }
2375 } 2379 }
2376 2380
2377 gfx::Screen* MenuController::GetScreen() { 2381 gfx::Screen* MenuController::GetScreen() {
2378 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; 2382 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL;
2379 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) 2383 return root ? gfx::Screen::GetScreenFor(root->GetNativeView())
2380 : gfx::Screen::GetNativeScreen(); 2384 : gfx::Screen::GetNativeScreen();
2381 } 2385 }
2382 2386
2383 } // namespace views 2387 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698