Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
TouchGesture.h
Go to the documentation of this file.
1
2/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8#ifndef TouchGesture_DEFINED
9#define TouchGesture_DEFINED
10
13#include "include/core/SkRect.h"
16
18public:
21
22 void touchBegin(void* owner, float x, float y);
23 void touchMoved(void* owner, float x, float y);
24 void touchEnd(void* owner);
25 void reset();
26 void resetTouchState();
27
28 bool isActive() { return fFlinger.isActive(); }
29 void stop() { fFlinger.stop(); }
30 bool isBeingTouched() { return kEmpty_State != fState; }
31 bool isFling(SkPoint* dir);
32
33 void startZoom();
34 void updateZoom(float scale, float startX, float startY, float lastX, float lastY);
35 void endZoom();
36
37 const SkMatrix& localM();
38 const SkMatrix& globalM() const { return fGlobalM; }
39
40 void setTransLimit(const SkRect& contentRect, const SkRect& windowRect,
41 const SkMatrix& preTouchM);
42
43private:
44 enum State {
45 kEmpty_State,
46 kTranslate_State,
47 kZoom_State,
48 };
49
50 struct Rec {
51 void* fOwner;
52 float fStartX, fStartY;
53 float fPrevX, fPrevY;
54 float fLastX, fLastY;
55 float fPrevT, fLastT;
56 };
57 SkTDArray<Rec> fTouches;
58
59 State fState;
60 SkMatrix fLocalM, fGlobalM, fPreTouchM;
61
62 struct FlingState {
63 FlingState() : fActive(false) {}
64
65 bool isActive() const { return fActive; }
66 void stop() { fActive = false; }
67
68 void reset(float sx, float sy);
69 bool evaluateMatrix(SkMatrix* matrix);
70
71 void get(SkPoint* dir, SkScalar* speed) {
72 *dir = fDirection;
73 *speed = fSpeed0;
74 }
75
76 private:
77 SkPoint fDirection;
78 SkScalar fSpeed0;
79 double fTime0;
80 bool fActive;
81 };
82 FlingState fFlinger;
83 double fLastUpMillis;
84 SkPoint fLastUpP;
85
86 // The following rects are used to limit the translation so the content never leaves the window
87 SkRect fContentRect, fWindowRect;
88 bool fIsTransLimited = false;
89
90 void limitTrans(); // here we only limit the translation with respect to globalM
91 void flushLocalM();
92 int findRec(void* owner) const;
93 void appendNewRec(void* owner, float x, float y);
94 float computePinch(const Rec&, const Rec&);
95 bool handleDblTap(float, float);
96};
97
98#endif
void setTransLimit(const SkRect &contentRect, const SkRect &windowRect, const SkMatrix &preTouchM)
void touchEnd(void *owner)
bool isBeingTouched()
bool isFling(SkPoint *dir)
bool isActive()
void touchBegin(void *owner, float x, float y)
void touchMoved(void *owner, float x, float y)
const SkMatrix & localM()
void resetTouchState()
const SkMatrix & globalM() const
void updateZoom(float scale, float startX, float startY, float lastX, float lastY)
float SkScalar
Definition extension.cpp:12
double y
double x
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets dir
Definition switches.h:145
const myers::Point & get(const myers::Segment &)
const Scalar scale