Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
ClickHandlerSlide.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef ClickHandlerSlide_DEFINED
9#define ClickHandlerSlide_DEFINED
10
11#include "tools/SkMetaData.h"
12#include "tools/viewer/Slide.h"
13
15
16#include <functional>
17
18/**
19 * Provides a higher level abstraction for click handling than the Slide base class. A Click object
20 * is is used to track the state of the mouse over time.
21 */
22class ClickHandlerSlide : public Slide {
23public:
24 // Click handling
25 class Click {
26 public:
27 Click() {}
28 Click(std::function<bool(Click*)> f) : fFunc(std::move(f)), fHasFunc(true) {}
29 virtual ~Click() = default;
30
31 SkPoint fOrig = {0, 0};
32 SkPoint fPrev = {0, 0};
33 SkPoint fCurr = {0, 0};
34
37
39
40 std::function<bool(Click*)> fFunc;
41
42 bool fHasFunc = false;
43 };
44
46 skui::InputState clickState,
47 skui::ModifierKey modifierKeys) final;
48
49protected:
50 /**
51 * Return a Click object to handle the click. onClick will be called repeatedly with the latest
52 * mouse state tracked on the Click object until it returns false.
53 */
55
56 /** Override to track clicks. Return true as long as you want to track the pen/mouse. */
57 virtual bool onClick(Click*) = 0;
58
59private:
60 std::unique_ptr<Click> fClick;
61};
62
63#endif
virtual ~Click()=default
std::function< bool(Click *)> fFunc
Click(std::function< bool(Click *)> f)
skui::ModifierKey fModifierKeys
virtual bool onClick(Click *)=0
bool onMouse(SkScalar x, SkScalar y, skui::InputState clickState, skui::ModifierKey modifierKeys) final
virtual Click * onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey modi)=0
Definition Slide.h:29
float SkScalar
Definition extension.cpp:12
double y
double x
InputState
Definition InputState.h:6
ModifierKey
Definition ModifierKey.h:9
Definition ref_ptr.h:256