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

Side by Side Diff: mojo/examples/sample_app/gles2_client_impl.cc

Issue 478523002: mojo events: Add |screen_location| to LocationData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix crash observed locally because of synthesized aura events. Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "mojo/examples/sample_app/gles2_client_impl.h" 5 #include "mojo/examples/sample_app/gles2_client_impl.h"
6 6
7 #include <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 #include <GLES2/gl2ext.h> 8 #include <GLES2/gl2ext.h>
9 #include <math.h> 9 #include <math.h>
10 #include <stdlib.h> 10 #include <stdlib.h>
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 cube_.Init(size_.width, size_.height); 48 cube_.Init(size_.width, size_.height);
49 WantToDraw(); 49 WantToDraw();
50 } 50 }
51 51
52 void GLES2ClientImpl::HandleInputEvent(const mojo::Event& event) { 52 void GLES2ClientImpl::HandleInputEvent(const mojo::Event& event) {
53 switch (event.action) { 53 switch (event.action) {
54 case mojo::EVENT_TYPE_MOUSE_PRESSED: 54 case mojo::EVENT_TYPE_MOUSE_PRESSED:
55 case mojo::EVENT_TYPE_TOUCH_PRESSED: 55 case mojo::EVENT_TYPE_TOUCH_PRESSED:
56 if (event.flags & mojo::EVENT_FLAGS_RIGHT_MOUSE_BUTTON) 56 if (event.flags & mojo::EVENT_FLAGS_RIGHT_MOUSE_BUTTON)
57 break; 57 break;
58 capture_point_ = *event.location; 58 capture_point_ = *event.location_data->in_view_location;
59 last_drag_point_ = capture_point_; 59 last_drag_point_ = capture_point_;
60 drag_start_time_ = mojo::GetTimeTicksNow(); 60 drag_start_time_ = mojo::GetTimeTicksNow();
61 break; 61 break;
62 case mojo::EVENT_TYPE_MOUSE_DRAGGED: 62 case mojo::EVENT_TYPE_MOUSE_DRAGGED:
63 case mojo::EVENT_TYPE_TOUCH_MOVED: { 63 case mojo::EVENT_TYPE_TOUCH_MOVED: {
64 if (event.flags & mojo::EVENT_FLAGS_RIGHT_MOUSE_BUTTON) 64 if (event.flags & mojo::EVENT_FLAGS_RIGHT_MOUSE_BUTTON)
65 break; 65 break;
66 int direction = event.location->y < last_drag_point_.y || 66 int direction =
67 event.location->x > last_drag_point_.x 67 (event.location_data->in_view_location->y < last_drag_point_.y ||
68 ? 1 68 event.location_data->in_view_location->x > last_drag_point_.x)
69 : -1; 69 ? 1 : -1;
70 cube_.set_direction(direction); 70 cube_.set_direction(direction);
71 cube_.UpdateForDragDistance( 71 cube_.UpdateForDragDistance(CalculateDragDistance(
72 CalculateDragDistance(last_drag_point_, *event.location)); 72 last_drag_point_, *event.location_data->in_view_location));
73 WantToDraw(); 73 WantToDraw();
74 74
75 last_drag_point_ = *event.location; 75 last_drag_point_ = *event.location_data->in_view_location;
76 break; 76 break;
77 } 77 }
78 case mojo::EVENT_TYPE_MOUSE_RELEASED: 78 case mojo::EVENT_TYPE_MOUSE_RELEASED:
79 case mojo::EVENT_TYPE_TOUCH_RELEASED: { 79 case mojo::EVENT_TYPE_TOUCH_RELEASED: {
80 if (event.flags & mojo::EVENT_FLAGS_RIGHT_MOUSE_BUTTON) { 80 if (event.flags & mojo::EVENT_FLAGS_RIGHT_MOUSE_BUTTON) {
81 cube_.set_color(GetRandomColor(), GetRandomColor(), GetRandomColor()); 81 cube_.set_color(GetRandomColor(), GetRandomColor(), GetRandomColor());
82 break; 82 break;
83 } 83 }
84 MojoTimeTicks offset = mojo::GetTimeTicksNow() - drag_start_time_; 84 MojoTimeTicks offset = mojo::GetTimeTicksNow() - drag_start_time_;
85 float delta = static_cast<float>(offset) / 1000000.; 85 float delta = static_cast<float>(offset) / 1000000.;
86 cube_.SetFlingMultiplier( 86 cube_.SetFlingMultiplier(CalculateDragDistance(
87 CalculateDragDistance(capture_point_, *event.location), 87 capture_point_, *event.location_data->in_view_location), delta);
88 delta);
89 88
90 capture_point_ = last_drag_point_ = mojo::Point(); 89 capture_point_ = last_drag_point_ = mojo::Point();
91 WantToDraw(); 90 WantToDraw();
92 break; 91 break;
93 } 92 }
94 default: 93 default:
95 break; 94 break;
96 } 95 }
97 } 96 }
98 97
(...skipping 28 matching lines...) Expand all
127 float delta = static_cast<float>(offset) / 1000000.; 126 float delta = static_cast<float>(offset) / 1000000.;
128 last_time_ = now; 127 last_time_ = now;
129 cube_.UpdateForTimeDelta(delta); 128 cube_.UpdateForTimeDelta(delta);
130 cube_.Draw(); 129 cube_.Draw();
131 130
132 MojoGLES2SwapBuffers(); 131 MojoGLES2SwapBuffers();
133 WantToDraw(); 132 WantToDraw();
134 } 133 }
135 134
136 } // namespace examples 135 } // namespace examples
OLDNEW
« no previous file with comments | « mojo/examples/pepper_container_app/pepper_container_app.cc ('k') | mojo/examples/sample_app/sample_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698