Flutter Windows Embedder
flutter::DirectManipulationEventHandler Class Reference

#include <direct_manipulation.h>

Inheritance diagram for flutter::DirectManipulationEventHandler:

Public Member Functions

 DirectManipulationEventHandler (DirectManipulationOwner *owner)
 
STDMETHODIMP QueryInterface (REFIID iid, void **ppv) override
 
ULONG STDMETHODCALLTYPE AddRef () override
 
ULONG STDMETHODCALLTYPE Release () override
 
HRESULT STDMETHODCALLTYPE OnViewportStatusChanged (IDirectManipulationViewport *viewport, DIRECTMANIPULATION_STATUS current, DIRECTMANIPULATION_STATUS previous) override
 
HRESULT STDMETHODCALLTYPE OnViewportUpdated (IDirectManipulationViewport *viewport) override
 
HRESULT STDMETHODCALLTYPE OnContentUpdated (IDirectManipulationViewport *viewport, IDirectManipulationContent *content) override
 
HRESULT STDMETHODCALLTYPE OnInteraction (IDirectManipulationViewport2 *viewport, DIRECTMANIPULATION_INTERACTION_TYPE interaction) override
 

Friends

class DirectManipulationOwner
 

Detailed Description

Definition at line 67 of file direct_manipulation.h.

Constructor & Destructor Documentation

◆ DirectManipulationEventHandler()

flutter::DirectManipulationEventHandler::DirectManipulationEventHandler ( DirectManipulationOwner owner)
inlineexplicit

Definition at line 76 of file direct_manipulation.h.

77  : owner_(owner) {}

Member Function Documentation

◆ AddRef()

ULONG STDMETHODCALLTYPE flutter::DirectManipulationEventHandler::AddRef ( )
override

Definition at line 166 of file direct_manipulation.cc.

166  {
167  RefCountedThreadSafe::AddRef();
168  return 0;
169 }

Referenced by QueryInterface().

◆ OnContentUpdated()

HRESULT flutter::DirectManipulationEventHandler::OnContentUpdated ( IDirectManipulationViewport *  viewport,
IDirectManipulationContent *  content 
)
override

Definition at line 134 of file direct_manipulation.cc.

136  {
137  float transform[6];
138  HRESULT hr = content->GetContentTransform(transform, ARRAYSIZE(transform));
139  if (FAILED(hr)) {
140  FML_LOG(ERROR) << "GetContentTransform failed";
141  return S_OK;
142  }
143  if (!during_synthesized_reset_) {
144  GestureData data = ConvertToGestureData(transform);
145  float scale = data.scale / initial_gesture_data_.scale;
146  float pan_x = data.pan_x - initial_gesture_data_.pan_x;
147  float pan_y = data.pan_y - initial_gesture_data_.pan_y;
148  last_pan_delta_x_ = pan_x - last_pan_x_;
149  last_pan_delta_y_ = pan_y - last_pan_y_;
150  last_pan_x_ = pan_x;
151  last_pan_y_ = pan_y;
152  if (owner_->binding_handler_delegate && !during_inertia_) {
154  GetDeviceId(), pan_x, pan_y, scale, 0);
155  }
156  }
157  return S_OK;
158 }
WindowBindingHandlerDelegate * binding_handler_delegate
virtual void OnPointerPanZoomUpdate(int32_t device_id, double pan_x, double pan_y, double scale, double rotation)=0
union flutter::testing::@93::KeyboardChange::@0 content

References flutter::DirectManipulationOwner::binding_handler_delegate, content, and flutter::WindowBindingHandlerDelegate::OnPointerPanZoomUpdate().

◆ OnInteraction()

HRESULT flutter::DirectManipulationEventHandler::OnInteraction ( IDirectManipulationViewport2 *  viewport,
DIRECTMANIPULATION_INTERACTION_TYPE  interaction 
)
override

Definition at line 160 of file direct_manipulation.cc.

162  {
163  return S_OK;
164 }

◆ OnViewportStatusChanged()

HRESULT flutter::DirectManipulationEventHandler::OnViewportStatusChanged ( IDirectManipulationViewport *  viewport,
DIRECTMANIPULATION_STATUS  current,
DIRECTMANIPULATION_STATUS  previous 
)
override

Definition at line 65 of file direct_manipulation.cc.

68  {
69  if (during_synthesized_reset_) {
70  during_synthesized_reset_ = current != DIRECTMANIPULATION_READY;
71  return S_OK;
72  }
73  during_inertia_ = current == DIRECTMANIPULATION_INERTIA;
74  if (current == DIRECTMANIPULATION_RUNNING) {
75  IDirectManipulationContent* content;
76  HRESULT hr = viewport->GetPrimaryContent(IID_PPV_ARGS(&content));
77  if (SUCCEEDED(hr)) {
78  float transform[6];
79  hr = content->GetContentTransform(transform, ARRAYSIZE(transform));
80  if (SUCCEEDED(hr)) {
81  initial_gesture_data_ = ConvertToGestureData(transform);
82  } else {
83  FML_LOG(ERROR) << "GetContentTransform failed";
84  }
85  } else {
86  FML_LOG(ERROR) << "GetPrimaryContent failed";
87  }
88  if (owner_->binding_handler_delegate) {
89  owner_->binding_handler_delegate->OnPointerPanZoomStart(GetDeviceId());
90  }
91  } else if (previous == DIRECTMANIPULATION_RUNNING) {
92  // Reset deltas to ensure only inertia values will be compared later.
93  last_pan_delta_x_ = 0.0;
94  last_pan_delta_y_ = 0.0;
95  if (owner_->binding_handler_delegate) {
96  owner_->binding_handler_delegate->OnPointerPanZoomEnd(GetDeviceId());
97  }
98  } else if (previous == DIRECTMANIPULATION_INERTIA) {
99  if (owner_->binding_handler_delegate &&
100  (std::max)(std::abs(last_pan_delta_x_), std::abs(last_pan_delta_y_)) >
101  0.01) {
102  owner_->binding_handler_delegate->OnScrollInertiaCancel(GetDeviceId());
103  }
104  // Need to reset the content transform to its original position
105  // so that we are ready for the next gesture.
106  // Use during_synthesized_reset_ flag to prevent sending reset also to the
107  // framework.
108  during_synthesized_reset_ = true;
109  last_pan_x_ = 0.0;
110  last_pan_y_ = 0.0;
111  last_pan_delta_x_ = 0.0;
112  last_pan_delta_y_ = 0.0;
113  RECT rect;
114  HRESULT hr = viewport->GetViewportRect(&rect);
115  if (FAILED(hr)) {
116  FML_LOG(ERROR) << "Failed to get the current viewport rect";
117  return E_FAIL;
118  }
119  hr = viewport->ZoomToRect(rect.left, rect.top, rect.right, rect.bottom,
120  false);
121  if (FAILED(hr)) {
122  FML_LOG(ERROR) << "Failed to reset the gesture using ZoomToRect";
123  return E_FAIL;
124  }
125  }
126  return S_OK;
127 }
virtual void OnPointerPanZoomStart(int32_t device_id)=0
virtual void OnPointerPanZoomEnd(int32_t device_id)=0
virtual void OnScrollInertiaCancel(int32_t device_id)=0

References flutter::DirectManipulationOwner::binding_handler_delegate, content, flutter::WindowBindingHandlerDelegate::OnPointerPanZoomEnd(), flutter::WindowBindingHandlerDelegate::OnPointerPanZoomStart(), and flutter::WindowBindingHandlerDelegate::OnScrollInertiaCancel().

◆ OnViewportUpdated()

HRESULT flutter::DirectManipulationEventHandler::OnViewportUpdated ( IDirectManipulationViewport *  viewport)
override

Definition at line 129 of file direct_manipulation.cc.

130  {
131  return S_OK;
132 }

◆ QueryInterface()

STDMETHODIMP flutter::DirectManipulationEventHandler::QueryInterface ( REFIID  iid,
void **  ppv 
)
override

Definition at line 34 of file direct_manipulation.cc.

35  {
36  if ((iid == IID_IUnknown) ||
37  (iid == IID_IDirectManipulationViewportEventHandler)) {
38  *ppv = static_cast<IDirectManipulationViewportEventHandler*>(this);
39  AddRef();
40  return S_OK;
41  } else if (iid == IID_IDirectManipulationInteractionEventHandler) {
42  *ppv = static_cast<IDirectManipulationInteractionEventHandler*>(this);
43  AddRef();
44  return S_OK;
45  }
46  return E_NOINTERFACE;
47 }
ULONG STDMETHODCALLTYPE AddRef() override

References AddRef().

◆ Release()

ULONG STDMETHODCALLTYPE flutter::DirectManipulationEventHandler::Release ( )
override

Definition at line 171 of file direct_manipulation.cc.

171  {
172  RefCountedThreadSafe::Release();
173  return 0;
174 }

Friends And Related Function Documentation

◆ DirectManipulationOwner

friend class DirectManipulationOwner
friend

Definition at line 71 of file direct_manipulation.h.


The documentation for this class was generated from the following files: