sk_app, Sample: Unify InputState enum.

replace() {
      if git grep -q "$1")";
      then sed -i -e "s#${1}#${2}#g" $(git grep -l "$1");
      fi
    }
    replace 'k\([A-Za-z]*\)_InputState' 'InputState::k\1'
    replace '\(\(sk_app::\|\)Window\|Sample\|\)::InputState' 'InputState'

Change-Id: I4cc18814fb1fbdd1f240aabba05aae79c54a4841
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/227642
Commit-Queue: Hal Canary <halcanary@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Auto-Submit: Hal Canary <halcanary@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
This commit is contained in:
Hal Canary 2019-07-16 09:58:43 -04:00 committed by Skia Commit-Bot
parent c714ce0e7a
commit ff2e8fe65f
24 changed files with 90 additions and 90 deletions

View File

@ -48,7 +48,7 @@ static void debug_on_char(SkUnichar c, ModifierKey modifiers) {
}
}
static void debug_on_key(sk_app::Window::Key key, sk_app::Window::InputState, ModifierKey modi) {
static void debug_on_key(sk_app::Window::Key key, InputState, ModifierKey modi) {
SkDebugf("key: %s%s\n", key_name(key), modifiers_desc(modi).c_str());
}
#endif // SK_EDITOR_DEBUG_OUT
@ -152,8 +152,8 @@ struct EditorLayer : public sk_app::Window::Layer {
return true;
}
bool onMouse(int x, int y, sk_app::Window::InputState state, ModifierKey modifiers) override {
if (sk_app::Window::kDown_InputState == state) {
bool onMouse(int x, int y, InputState state, ModifierKey modifiers) override {
if (InputState::kDown == state) {
y += fPos;
editor::Editor::TextPosition pos = fEditor.getPosition(SkIPoint{x, y});
#ifdef SK_EDITOR_DEBUG_OUT
@ -232,9 +232,9 @@ struct EditorLayer : public sk_app::Window::Layer {
return true;
}
bool onKey(sk_app::Window::Key key,
sk_app::Window::InputState state,
InputState state,
ModifierKey modifiers) override {
if (state == sk_app::Window::kDown_InputState) {
if (state == InputState::kDown) {
switch (key) {
case sk_app::Window::Key::kPageDown:
return this->scroll(fHeight * 4 / 5);

View File

@ -14,6 +14,7 @@
#include "include/core/SkString.h"
#include "include/private/SkMacros.h"
#include "src/utils/SkMetaData.h"
#include "tools/InputState.h"
#include "tools/ModifierKey.h"
#include "tools/Registry.h"
@ -52,8 +53,6 @@ public:
virtual bool onChar(SkUnichar) { return false; }
// Click handling
// TODO: unify Sample::InputState and sk_app::Window::InputState
enum class InputState { kDown, kUp, kMove };
class Click {
public:
virtual ~Click() = default;

10
tools/InputState.h Normal file
View File

@ -0,0 +1,10 @@
// Copyright 2019 Google LLC.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#ifndef InputState_DEFINED
#define InputState_DEFINED
enum class InputState {
kDown,
kUp,
kMove // only valid for mouse
};
#endif // InputState_DEFINED

View File

@ -35,8 +35,8 @@ void CommandSet::attach(Window* window) {
fWindow = window;
}
bool CommandSet::onKey(Window::Key key, Window::InputState state, ModifierKey modifiers) {
if (Window::kDown_InputState == state) {
bool CommandSet::onKey(Window::Key key, InputState state, ModifierKey modifiers) {
if (InputState::kDown == state) {
for (Command& cmd : fCommands) {
if (Command::kKey_CommandType == cmd.fType && key == cmd.fKey) {
cmd.fFunction();

View File

@ -41,7 +41,7 @@ public:
CommandSet();
void attach(Window* window);
bool onKey(sk_app::Window::Key key, sk_app::Window::InputState state, ModifierKey modifiers);
bool onKey(sk_app::Window::Key key, InputState state, ModifierKey modifiers);
bool onChar(SkUnichar, ModifierKey modifiers);
bool onSoftkey(const SkString& softkey);

View File

@ -11,6 +11,7 @@
#include "include/core/SkRect.h"
#include "include/core/SkTypes.h"
#include "include/private/SkTDArray.h"
#include "tools/InputState.h"
#include "tools/ModifierKey.h"
#include "tools/sk_app/DisplayParams.h"
@ -121,12 +122,6 @@ public:
};
static const int kKeyCount = static_cast<int>(Key::kLast) + 1;
enum InputState {
kDown_InputState,
kUp_InputState,
kMove_InputState // only valid for mouse
};
class Layer {
public:
Layer() : fActive(true) {}

View File

@ -59,13 +59,13 @@ static const std::unordered_map<int, Window::Key> ANDROID_TO_WINDOW_KEYMAP({
{AKEYCODE_SOFT_RIGHT, Window::Key::kRight}
});
static const std::unordered_map<int, Window::InputState> ANDROID_TO_WINDOW_STATEMAP({
{AMOTION_EVENT_ACTION_DOWN, Window::kDown_InputState},
{AMOTION_EVENT_ACTION_POINTER_DOWN, Window::kDown_InputState},
{AMOTION_EVENT_ACTION_UP, Window::kUp_InputState},
{AMOTION_EVENT_ACTION_POINTER_UP, Window::kUp_InputState},
{AMOTION_EVENT_ACTION_MOVE, Window::kMove_InputState},
{AMOTION_EVENT_ACTION_CANCEL, Window::kUp_InputState},
static const std::unordered_map<int, InputState> ANDROID_TO_WINDOW_STATEMAP({
{AMOTION_EVENT_ACTION_DOWN, InputState::kDown},
{AMOTION_EVENT_ACTION_POINTER_DOWN, InputState::kDown},
{AMOTION_EVENT_ACTION_UP, InputState::kUp},
{AMOTION_EVENT_ACTION_POINTER_UP, InputState::kUp},
{AMOTION_EVENT_ACTION_MOVE, InputState::kMove},
{AMOTION_EVENT_ACTION_CANCEL, InputState::kUp},
});
SkiaAndroidApp::SkiaAndroidApp(JNIEnv* env, jobject androidApp) {
@ -166,8 +166,8 @@ int SkiaAndroidApp::message_callback(int fd, int events, void* data) {
auto it = ANDROID_TO_WINDOW_KEYMAP.find(message.fKeycode);
SkASSERT(it != ANDROID_TO_WINDOW_KEYMAP.end());
// No modifier is supported so far
skiaAndroidApp->fWindow->onKey(it->second, Window::kDown_InputState, ModifierKey::kNone);
skiaAndroidApp->fWindow->onKey(it->second, Window::kUp_InputState, ModifierKey::kNone);
skiaAndroidApp->fWindow->onKey(it->second, InputState::kDown, ModifierKey::kNone);
skiaAndroidApp->fWindow->onKey(it->second, InputState::kUp, ModifierKey::kNone);
break;
}
case kTouched: {

View File

@ -196,19 +196,19 @@ bool Window_ios::handleEvent(const SDL_Event& event) {
break;
case SDL_FINGERDOWN:
this->onTouch(event.tfinger.fingerId, Window::kDown_InputState,
this->onTouch(event.tfinger.fingerId, InputState::kDown,
(int)(this->width()*event.tfinger.x),
(int)(this->height()*event.tfinger.y));
break;
case SDL_FINGERUP:
this->onTouch(event.tfinger.fingerId, Window::kUp_InputState,
this->onTouch(event.tfinger.fingerId, InputState::kUp,
(int)(this->width()*event.tfinger.x),
(int)(this->height()*event.tfinger.y));
break;
case SDL_FINGERMOTION:
this->onTouch(event.tfinger.fingerId, Window::kMove_InputState,
this->onTouch(event.tfinger.fingerId, InputState::kMove,
(int)(this->width()*event.tfinger.x),
(int)(this->height()*event.tfinger.y));
break;
@ -216,7 +216,7 @@ bool Window_ios::handleEvent(const SDL_Event& event) {
case SDL_KEYDOWN: {
Window::Key key = get_key(event.key.keysym);
if (key != Window::Key::kNONE) {
if (!this->onKey(key, Window::kDown_InputState, get_modifiers(event))) {
if (!this->onKey(key, InputState::kDown, get_modifiers(event))) {
if (event.key.keysym.sym == SDLK_ESCAPE) {
return true;
}
@ -227,7 +227,7 @@ bool Window_ios::handleEvent(const SDL_Event& event) {
case SDL_KEYUP: {
Window::Key key = get_key(event.key.keysym);
if (key != Window::Key::kNONE) {
(void) this->onKey(key, Window::kUp_InputState,
(void) this->onKey(key, InputState::kUp,
get_modifiers(event));
}
} break;

View File

@ -307,7 +307,7 @@ static ModifierKey get_modifiers(const NSEvent* event) {
- (void)keyDown:(NSEvent *)event {
Window::Key key = get_key([event keyCode]);
if (key != Window::Key::kNONE) {
if (!fWindow->onKey(key, Window::kDown_InputState, get_modifiers(event))) {
if (!fWindow->onKey(key, InputState::kDown, get_modifiers(event))) {
if (Window::Key::kEscape == key) {
[NSApp terminate:fWindow->window()];
}
@ -329,21 +329,21 @@ static ModifierKey get_modifiers(const NSEvent* event) {
- (void)keyUp:(NSEvent *)event {
Window::Key key = get_key([event keyCode]);
if (key != Window::Key::kNONE) {
(void) fWindow->onKey(key, Window::kUp_InputState, get_modifiers(event));
(void) fWindow->onKey(key, InputState::kUp, get_modifiers(event));
}
}
- (void)mouseDown:(NSEvent *)event {
const NSPoint pos = [event locationInWindow];
const NSRect rect = [fWindow->window().contentView frame];
fWindow->onMouse(pos.x, rect.size.height - pos.y, Window::kDown_InputState,
fWindow->onMouse(pos.x, rect.size.height - pos.y, InputState::kDown,
get_modifiers(event));
}
- (void)mouseUp:(NSEvent *)event {
const NSPoint pos = [event locationInWindow];
const NSRect rect = [fWindow->window().contentView frame];
fWindow->onMouse(pos.x, rect.size.height - pos.y, Window::kUp_InputState,
fWindow->onMouse(pos.x, rect.size.height - pos.y, InputState::kUp,
get_modifiers(event));
}
@ -354,7 +354,7 @@ static ModifierKey get_modifiers(const NSEvent* event) {
- (void)mouseMoved:(NSEvent *)event {
const NSPoint pos = [event locationInWindow];
const NSRect rect = [fWindow->window().contentView frame];
fWindow->onMouse(pos.x, rect.size.height - pos.y, Window::kMove_InputState,
fWindow->onMouse(pos.x, rect.size.height - pos.y, InputState::kMove,
get_modifiers(event));
}

View File

@ -268,7 +268,7 @@ bool Window_unix::handleEvent(const XEvent& event) {
switch (event.xbutton.button) {
case Button1:
this->onMouse(event.xbutton.x, event.xbutton.y,
Window::kDown_InputState, get_modifiers(event));
InputState::kDown, get_modifiers(event));
break;
case Button4:
this->onMouseWheel(1.0f, get_modifiers(event));
@ -282,13 +282,13 @@ bool Window_unix::handleEvent(const XEvent& event) {
case ButtonRelease:
if (event.xbutton.button == Button1) {
this->onMouse(event.xbutton.x, event.xbutton.y,
Window::kUp_InputState, get_modifiers(event));
InputState::kUp, get_modifiers(event));
}
break;
case MotionNotify:
this->onMouse(event.xmotion.x, event.xmotion.y,
Window::kMove_InputState, get_modifiers(event));
InputState::kMove, get_modifiers(event));
break;
case KeyPress: {
@ -296,7 +296,7 @@ bool Window_unix::handleEvent(const XEvent& event) {
KeySym keysym = XkbKeycodeToKeysym(fDisplay, event.xkey.keycode, 0, shiftLevel);
Window::Key key = get_key(keysym);
if (key != Window::Key::kNONE) {
if (!this->onKey(key, Window::kDown_InputState, get_modifiers(event))) {
if (!this->onKey(key, InputState::kDown, get_modifiers(event))) {
if (keysym == XK_Escape) {
return true;
}
@ -314,7 +314,7 @@ bool Window_unix::handleEvent(const XEvent& event) {
KeySym keysym = XkbKeycodeToKeysym(fDisplay, event.xkey.keycode,
0, shiftLevel);
Window::Key key = get_key(keysym);
(void) this->onKey(key, Window::kUp_InputState,
(void) this->onKey(key, InputState::kUp,
get_modifiers(event));
} break;

View File

@ -251,13 +251,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
eventHandled = window->onKey(get_key(wParam), Window::kDown_InputState,
eventHandled = window->onKey(get_key(wParam), InputState::kDown,
get_modifiers(message, wParam, lParam));
break;
case WM_KEYUP:
case WM_SYSKEYUP:
eventHandled = window->onKey(get_key(wParam), Window::kUp_InputState,
eventHandled = window->onKey(get_key(wParam), InputState::kUp,
get_modifiers(message, wParam, lParam));
break;
@ -274,8 +274,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
// yPos -= rc.top;
//}
Window::InputState istate = ((wParam & MK_LBUTTON) != 0) ? Window::kDown_InputState
: Window::kUp_InputState;
InputState istate = ((wParam & MK_LBUTTON) != 0) ? InputState::kDown
: InputState::kUp;
eventHandled = window->onMouse(xPos, yPos, istate,
get_modifiers(message, wParam, lParam));
@ -293,7 +293,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
// yPos -= rc.top;
//}
eventHandled = window->onMouse(xPos, yPos, Window::kMove_InputState,
eventHandled = window->onMouse(xPos, yPos, InputState::kMove,
get_modifiers(message, wParam, lParam));
} break;
@ -311,13 +311,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
ClientToScreen(hWnd, &topLeft);
for (uint16_t i = 0; i < numInputs; ++i) {
TOUCHINPUT ti = inputs[i];
Window::InputState state;
InputState state;
if (ti.dwFlags & TOUCHEVENTF_DOWN) {
state = Window::kDown_InputState;
state = InputState::kDown;
} else if (ti.dwFlags & TOUCHEVENTF_MOVE) {
state = Window::kMove_InputState;
state = InputState::kMove;
} else if (ti.dwFlags & TOUCHEVENTF_UP) {
state = Window::kUp_InputState;
state = InputState::kUp;
} else {
continue;
}

View File

@ -70,13 +70,13 @@ void ImGuiLayer::onAttach(Window* window) {
fWindow = window;
}
bool ImGuiLayer::onMouse(int x, int y, Window::InputState state, ModifierKey modifiers) {
bool ImGuiLayer::onMouse(int x, int y, InputState state, ModifierKey modifiers) {
ImGuiIO& io = ImGui::GetIO();
io.MousePos.x = static_cast<float>(x);
io.MousePos.y = static_cast<float>(y);
if (Window::kDown_InputState == state) {
if (InputState::kDown == state) {
io.MouseDown[0] = true;
} else if (Window::kUp_InputState == state) {
} else if (InputState::kUp == state) {
io.MouseDown[0] = false;
}
return io.WantCaptureMouse;
@ -184,9 +184,9 @@ void ImGuiLayer::onPaint(SkSurface* surface) {
fSkiaWidgetFuncs.reset();
}
bool ImGuiLayer::onKey(sk_app::Window::Key key, sk_app::Window::InputState state, ModifierKey modifiers) {
bool ImGuiLayer::onKey(sk_app::Window::Key key, InputState state, ModifierKey modifiers) {
ImGuiIO& io = ImGui::GetIO();
io.KeysDown[static_cast<int>(key)] = (Window::kDown_InputState == state);
io.KeysDown[static_cast<int>(key)] = (InputState::kDown == state);
return io.WantCaptureKeyboard;
}

View File

@ -123,9 +123,9 @@ public:
void onAttach(sk_app::Window* window) override;
void onPrePaint() override;
void onPaint(SkSurface*) override;
bool onMouse(int x, int y, sk_app::Window::InputState state, ModifierKey modifiers) override;
bool onMouse(int x, int y, InputState state, ModifierKey modifiers) override;
bool onMouseWheel(float delta, ModifierKey modifiers) override;
bool onKey(sk_app::Window::Key key, sk_app::Window::InputState state, ModifierKey modifiers) override;
bool onKey(sk_app::Window::Key key, InputState state, ModifierKey modifiers) override;
bool onChar(SkUnichar c, ModifierKey modifiers) override;
private:

View File

@ -347,9 +347,9 @@ bool ParticlesSlide::animate(double nanos) {
return true;
}
bool ParticlesSlide::onMouse(SkScalar x, SkScalar y, Window::InputState state, ModifierKey modifiers) {
bool ParticlesSlide::onMouse(SkScalar x, SkScalar y, InputState state, ModifierKey modifiers) {
if (gDragIndex == -1) {
if (state == Window::kDown_InputState) {
if (state == InputState::kDown) {
float bestDistance = kDragSize;
SkPoint mousePt = { x, y };
for (int i = 0; i < gDragPoints.count(); ++i) {
@ -365,7 +365,7 @@ bool ParticlesSlide::onMouse(SkScalar x, SkScalar y, Window::InputState state, M
// Currently dragging
SkASSERT(gDragIndex < gDragPoints.count());
gDragPoints[gDragIndex]->set(x, y);
if (state == Window::kUp_InputState) {
if (state == InputState::kUp) {
gDragIndex = -1;
}
return true;

View File

@ -28,7 +28,7 @@ public:
void draw(SkCanvas* canvas) override;
bool animate(double) override;
bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState state,
bool onMouse(SkScalar x, SkScalar y, InputState state,
ModifierKey modifiers) override;
private:

View File

@ -44,10 +44,6 @@ bool SampleSlide::onChar(SkUnichar c) {
return fSample && fSample->onChar(c);
}
bool SampleSlide::onMouse(SkScalar x, SkScalar y, Window::InputState state,
ModifierKey modifierKeys) {
static_assert((Sample::InputState)Window::kDown_InputState == Sample::InputState::kDown, "");
static_assert((Sample::InputState)Window::kUp_InputState == Sample::InputState::kUp, "");
static_assert((Sample::InputState)Window::kMove_InputState == Sample::InputState::kMove, "");
return fSample && fSample->mouse({x, y}, (Sample::InputState)state, modifierKeys);
bool SampleSlide::onMouse(SkScalar x, SkScalar y, InputState state, ModifierKey modifierKeys) {
return fSample && fSample->mouse({x, y}, state, modifierKeys);
}

View File

@ -27,7 +27,7 @@ public:
bool animate(double) override;
bool onChar(SkUnichar c) override;
bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState state,
bool onMouse(SkScalar x, SkScalar y, InputState state,
ModifierKey modifiers) override;
private:

View File

@ -163,9 +163,9 @@ bool SkottieSlide::onChar(SkUnichar c) {
return INHERITED::onChar(c);
}
bool SkottieSlide::onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState state, ModifierKey) {
bool SkottieSlide::onMouse(SkScalar x, SkScalar y, InputState state, ModifierKey) {
switch (state) {
case sk_app::Window::kUp_InputState:
case InputState::kUp:
fShowAnimationInval = !fShowAnimationInval;
fShowAnimationStats = !fShowAnimationStats;
fAnimation->setShowInval(fShowAnimationInval);

View File

@ -29,7 +29,7 @@ public:
bool animate(double) override;
bool onChar(SkUnichar) override;
bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState, ModifierKey modifiers) override;
bool onMouse(SkScalar x, SkScalar y, InputState, ModifierKey modifiers) override;
private:
SkString fPath;

View File

@ -29,7 +29,7 @@ public:
virtual void unload() {}
virtual bool onChar(SkUnichar c) { return false; }
virtual bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState state,
virtual bool onMouse(SkScalar x, SkScalar y, InputState state,
ModifierKey modifiers) { return false; }
virtual bool onGetControls(SkMetaData*) { return false; }

View File

@ -158,7 +158,7 @@ public:
fState = State::kUnfocusing;
}
bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState state, ModifierKey modifiers) {
bool onMouse(SkScalar x, SkScalar y, InputState state, ModifierKey modifiers) {
SkASSERT(fTarget);
if (!fRect.contains(x, y)) {
@ -379,9 +379,9 @@ bool SlideDir::onChar(SkUnichar c) {
return false;
}
bool SlideDir::onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState state,
bool SlideDir::onMouse(SkScalar x, SkScalar y, InputState state,
ModifierKey modifiers) {
if (state == sk_app::Window::kMove_InputState || ModifierKeyIsSet(modifiers))
if (state == InputState::kMove || ModifierKeyIsSet(modifiers))
return false;
if (fFocusController->hasFocus()) {
@ -395,11 +395,11 @@ bool SlideDir::onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState state,
static constexpr SkScalar kClickMoveTolerance = 4;
switch (state) {
case sk_app::Window::kDown_InputState:
case InputState::kDown:
fTrackingCell = cell;
fTrackingPos = SkPoint::Make(x, y);
break;
case sk_app::Window::kUp_InputState:
case InputState::kUp:
if (cell == fTrackingCell &&
SkPoint::Distance(fTrackingPos, SkPoint::Make(x, y)) < kClickMoveTolerance) {
fFocusController->startFocus(cell);

View File

@ -36,7 +36,7 @@ protected:
bool animate(double) override;
bool onChar(SkUnichar) override;
bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState, ModifierKey modifiers) override;
bool onMouse(SkScalar x, SkScalar y, InputState, ModifierKey modifiers) override;
private:
struct Rec;

View File

@ -1369,7 +1369,7 @@ SkPoint Viewer::mapEvent(float x, float y) {
return inv.mapXY(x, y);
}
bool Viewer::onTouch(intptr_t owner, Window::InputState state, float x, float y) {
bool Viewer::onTouch(intptr_t owner, InputState state, float x, float y) {
if (GestureDevice::kMouse == fGestureDevice) {
return false;
}
@ -1382,7 +1382,7 @@ bool Viewer::onTouch(intptr_t owner, Window::InputState state, float x, float y)
void* castedOwner = reinterpret_cast<void*>(owner);
switch (state) {
case Window::kUp_InputState: {
case InputState::kUp: {
fGesture.touchEnd(castedOwner);
#if defined(SK_BUILD_FOR_IOS)
// TODO: move IOS swipe detection higher up into the platform code
@ -1403,11 +1403,11 @@ bool Viewer::onTouch(intptr_t owner, Window::InputState state, float x, float y)
#endif
break;
}
case Window::kDown_InputState: {
case InputState::kDown: {
fGesture.touchBegin(castedOwner, x, y);
break;
}
case Window::kMove_InputState: {
case InputState::kMove: {
fGesture.touchMoved(castedOwner, x, y);
break;
}
@ -1417,7 +1417,7 @@ bool Viewer::onTouch(intptr_t owner, Window::InputState state, float x, float y)
return true;
}
bool Viewer::onMouse(int x, int y, Window::InputState state, ModifierKey modifiers) {
bool Viewer::onMouse(int x, int y, InputState state, ModifierKey modifiers) {
if (GestureDevice::kTouch == fGestureDevice) {
return false;
}
@ -1429,22 +1429,22 @@ bool Viewer::onMouse(int x, int y, Window::InputState state, ModifierKey modifie
}
switch (state) {
case Window::kUp_InputState: {
case InputState::kUp: {
fGesture.touchEnd(nullptr);
break;
}
case Window::kDown_InputState: {
case InputState::kDown: {
fGesture.touchBegin(nullptr, x, y);
break;
}
case Window::kMove_InputState: {
case InputState::kMove: {
fGesture.touchMoved(nullptr, x, y);
break;
}
}
fGestureDevice = fGesture.isBeingTouched() ? GestureDevice::kMouse : GestureDevice::kNone;
if (state != Window::kMove_InputState || fGesture.isBeingTouched()) {
if (state != InputState::kMove || fGesture.isBeingTouched()) {
fWindow->inval();
}
return true;
@ -2341,7 +2341,7 @@ void Viewer::onUIStateChanged(const SkString& stateName, const SkString& stateVa
}
}
bool Viewer::onKey(sk_app::Window::Key key, sk_app::Window::InputState state, ModifierKey modifiers) {
bool Viewer::onKey(sk_app::Window::Key key, InputState state, ModifierKey modifiers) {
return fCommands.onKey(key, state, modifiers);
}

View File

@ -37,10 +37,10 @@ public:
void onBackendCreated() override;
void onPaint(SkSurface*) override;
void onResize(int width, int height) override;
bool onTouch(intptr_t owner, sk_app::Window::InputState state, float x, float y) override;
bool onMouse(int x, int y, sk_app::Window::InputState state, ModifierKey modifiers) override;
bool onTouch(intptr_t owner, InputState state, float x, float y) override;
bool onMouse(int x, int y, InputState state, ModifierKey modifiers) override;
void onUIStateChanged(const SkString& stateName, const SkString& stateValue) override;
bool onKey(sk_app::Window::Key key, sk_app::Window::InputState state, ModifierKey modifiers) override;
bool onKey(sk_app::Window::Key key, InputState state, ModifierKey modifiers) override;
bool onChar(SkUnichar c, ModifierKey modifiers) override;
struct SkFontFields {