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>
diff --git a/experimental/editor/editor_application.cpp b/experimental/editor/editor_application.cpp
index 0577d6a..88ac070 100644
--- a/experimental/editor/editor_application.cpp
+++ b/experimental/editor/editor_application.cpp
@@ -48,7 +48,7 @@
}
}
-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 @@
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 @@
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);
diff --git a/samplecode/Sample.h b/samplecode/Sample.h
index 390ac4c..390cb78 100644
--- a/samplecode/Sample.h
+++ b/samplecode/Sample.h
@@ -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 @@
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;
diff --git a/tools/InputState.h b/tools/InputState.h
new file mode 100644
index 0000000..ae3d217
--- /dev/null
+++ b/tools/InputState.h
@@ -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
diff --git a/tools/sk_app/CommandSet.cpp b/tools/sk_app/CommandSet.cpp
index b2bb2ad..954eed2 100644
--- a/tools/sk_app/CommandSet.cpp
+++ b/tools/sk_app/CommandSet.cpp
@@ -35,8 +35,8 @@
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();
diff --git a/tools/sk_app/CommandSet.h b/tools/sk_app/CommandSet.h
index 7e99e3c..7350bb7 100644
--- a/tools/sk_app/CommandSet.h
+++ b/tools/sk_app/CommandSet.h
@@ -41,7 +41,7 @@
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);
diff --git a/tools/sk_app/Window.h b/tools/sk_app/Window.h
index 81b13f9..8e2681b 100644
--- a/tools/sk_app/Window.h
+++ b/tools/sk_app/Window.h
@@ -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 @@
};
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) {}
diff --git a/tools/sk_app/android/surface_glue_android.cpp b/tools/sk_app/android/surface_glue_android.cpp
index 690da75..a19b74e 100644
--- a/tools/sk_app/android/surface_glue_android.cpp
+++ b/tools/sk_app/android/surface_glue_android.cpp
@@ -59,13 +59,13 @@
{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 @@
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: {
diff --git a/tools/sk_app/ios/Window_ios.cpp b/tools/sk_app/ios/Window_ios.cpp
index 2eb683f..25c4f50 100644
--- a/tools/sk_app/ios/Window_ios.cpp
+++ b/tools/sk_app/ios/Window_ios.cpp
@@ -196,19 +196,19 @@
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 @@
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 @@
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;
diff --git a/tools/sk_app/mac/Window_mac.mm b/tools/sk_app/mac/Window_mac.mm
index 7fe48ea..a3404a0 100644
--- a/tools/sk_app/mac/Window_mac.mm
+++ b/tools/sk_app/mac/Window_mac.mm
@@ -307,7 +307,7 @@
- (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 @@
- (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 @@
- (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));
}
diff --git a/tools/sk_app/unix/Window_unix.cpp b/tools/sk_app/unix/Window_unix.cpp
index 6236193..ece4128 100644
--- a/tools/sk_app/unix/Window_unix.cpp
+++ b/tools/sk_app/unix/Window_unix.cpp
@@ -268,7 +268,7 @@
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 @@
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 @@
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 @@
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;
diff --git a/tools/sk_app/win/Window_win.cpp b/tools/sk_app/win/Window_win.cpp
index 7a1af00..9655fbe 100644
--- a/tools/sk_app/win/Window_win.cpp
+++ b/tools/sk_app/win/Window_win.cpp
@@ -251,13 +251,13 @@
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 @@
// 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 @@
// 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 @@
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;
}
diff --git a/tools/viewer/ImGuiLayer.cpp b/tools/viewer/ImGuiLayer.cpp
index 790a040..82f0352 100644
--- a/tools/viewer/ImGuiLayer.cpp
+++ b/tools/viewer/ImGuiLayer.cpp
@@ -70,13 +70,13 @@
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 @@
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;
}
diff --git a/tools/viewer/ImGuiLayer.h b/tools/viewer/ImGuiLayer.h
index dfd383b..3f22e3a 100644
--- a/tools/viewer/ImGuiLayer.h
+++ b/tools/viewer/ImGuiLayer.h
@@ -123,9 +123,9 @@
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:
diff --git a/tools/viewer/ParticlesSlide.cpp b/tools/viewer/ParticlesSlide.cpp
index 64a748a..9943e9b 100644
--- a/tools/viewer/ParticlesSlide.cpp
+++ b/tools/viewer/ParticlesSlide.cpp
@@ -347,9 +347,9 @@
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 @@
// Currently dragging
SkASSERT(gDragIndex < gDragPoints.count());
gDragPoints[gDragIndex]->set(x, y);
- if (state == Window::kUp_InputState) {
+ if (state == InputState::kUp) {
gDragIndex = -1;
}
return true;
diff --git a/tools/viewer/ParticlesSlide.h b/tools/viewer/ParticlesSlide.h
index 4782562..6adf553 100644
--- a/tools/viewer/ParticlesSlide.h
+++ b/tools/viewer/ParticlesSlide.h
@@ -28,7 +28,7 @@
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:
diff --git a/tools/viewer/SampleSlide.cpp b/tools/viewer/SampleSlide.cpp
index 1710915..df0ad3e 100644
--- a/tools/viewer/SampleSlide.cpp
+++ b/tools/viewer/SampleSlide.cpp
@@ -44,10 +44,6 @@
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);
}
diff --git a/tools/viewer/SampleSlide.h b/tools/viewer/SampleSlide.h
index 700b07e..28ed237 100644
--- a/tools/viewer/SampleSlide.h
+++ b/tools/viewer/SampleSlide.h
@@ -27,7 +27,7 @@
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:
diff --git a/tools/viewer/SkottieSlide.cpp b/tools/viewer/SkottieSlide.cpp
index 113ca06..22e0502 100644
--- a/tools/viewer/SkottieSlide.cpp
+++ b/tools/viewer/SkottieSlide.cpp
@@ -163,9 +163,9 @@
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);
diff --git a/tools/viewer/SkottieSlide.h b/tools/viewer/SkottieSlide.h
index f784229..d7181bf 100644
--- a/tools/viewer/SkottieSlide.h
+++ b/tools/viewer/SkottieSlide.h
@@ -29,7 +29,7 @@
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;
diff --git a/tools/viewer/Slide.h b/tools/viewer/Slide.h
index 910cfd1..564081b 100644
--- a/tools/viewer/Slide.h
+++ b/tools/viewer/Slide.h
@@ -29,7 +29,7 @@
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; }
diff --git a/tools/viewer/SlideDir.cpp b/tools/viewer/SlideDir.cpp
index 5c1aa37..cdfed78 100644
--- a/tools/viewer/SlideDir.cpp
+++ b/tools/viewer/SlideDir.cpp
@@ -158,7 +158,7 @@
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 @@
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 @@
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);
diff --git a/tools/viewer/SlideDir.h b/tools/viewer/SlideDir.h
index 2c930c1..8c80f95 100644
--- a/tools/viewer/SlideDir.h
+++ b/tools/viewer/SlideDir.h
@@ -36,7 +36,7 @@
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;
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 607d6f4..55de6f8 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -1369,7 +1369,7 @@
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 @@
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 @@
#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 @@
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 @@
}
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 @@
}
}
-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);
}
diff --git a/tools/viewer/Viewer.h b/tools/viewer/Viewer.h
index a1b9910..1ebc927 100644
--- a/tools/viewer/Viewer.h
+++ b/tools/viewer/Viewer.h
@@ -37,10 +37,10 @@
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 {