Flutter Engine
The Flutter Engine
ClickHandlerSlide.cpp
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
9
11 skui::InputState clickState,
12 skui::ModifierKey modifierKeys) {
13 auto dispatch = [this](Click* c) {
14 return c->fHasFunc ? c->fFunc(c) : this->onClick(c);
15 };
16
17 switch (clickState) {
19 fClick = nullptr;
20 fClick.reset(this->onFindClickHandler(x, y, modifierKeys));
21 if (!fClick) {
22 return false;
23 }
24 fClick->fPrev = fClick->fCurr = fClick->fOrig = {x, y};
25 fClick->fState = skui::InputState::kDown;
26 fClick->fModifierKeys = modifierKeys;
27 dispatch(fClick.get());
28 return true;
30 if (fClick) {
31 fClick->fPrev = fClick->fCurr;
32 fClick->fCurr = {x, y};
33 fClick->fState = skui::InputState::kMove;
34 fClick->fModifierKeys = modifierKeys;
35 return dispatch(fClick.get());
36 }
37 return false;
39 if (fClick) {
40 fClick->fPrev = fClick->fCurr;
41 fClick->fCurr = {x, y};
42 fClick->fState = skui::InputState::kUp;
43 fClick->fModifierKeys = modifierKeys;
44 bool result = dispatch(fClick.get());
45 fClick = nullptr;
46 return result;
47 }
48 return false;
49 default:
50 // Ignore other cases
51 SK_ABORT("Unexepected InputState");
52 }
53
55}
#define SkUNREACHABLE
Definition: SkAssert.h:135
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
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
float SkScalar
Definition: extension.cpp:12
GAsyncResult * result
double y
double x
InputState
Definition: InputState.h:6
ModifierKey
Definition: ModifierKey.h:9