Rebase, remove legacy pointerevents
diff --git a/include/rive/artboard.hpp b/include/rive/artboard.hpp
index 70fa6b2..1e483d4 100644
--- a/include/rive/artboard.hpp
+++ b/include/rive/artboard.hpp
@@ -7,7 +7,6 @@
#include "rive/generated/artboard_base.hpp"
#include "rive/hit_info.hpp"
#include "rive/message.hpp"
-#include "rive/pointer_event.hpp"
#include "rive/math/aabb.hpp"
#include "rive/renderer.hpp"
#include "rive/shapes/shape_paint_container.hpp"
@@ -85,11 +84,6 @@
bool advance(double elapsedSeconds);
- // Call this to forward pointer events to the artboard
- // They will be processed when advance() is called.
- //
- void postPointerEvent(const PointerEvent&);
-
// Returns true iff calling popMessage() will return true.
bool hasMessages() const;
diff --git a/skia/viewer/src/main.cpp b/skia/viewer/src/main.cpp
index 138a94c..e297964 100644
--- a/skia/viewer/src/main.cpp
+++ b/skia/viewer/src/main.cpp
@@ -154,51 +154,12 @@
initAnimation(0);
}
-// returns the mouse position, transforming it through the inverse of
-// the canvas' CTM -- which may have been altered to scale/translate
-// the artboard into the window.
-//
-static void post_mouse_event(rive::Artboard* artboard, const SkMatrix& ctm) {
- static ImVec2 gPrevMousePos = {-1000, -1000};
- const auto mouse = ImGui::GetMousePos();
-
- static bool gPrevMouseButtonDown = false;
- const bool isDown = ImGui::IsMouseDown(ImGuiMouseButton_Left);
-
- if (mouse.x == gPrevMousePos.x && mouse.y == gPrevMousePos.y && isDown == gPrevMouseButtonDown)
- {
- return;
- }
-
- auto evtType = rive::PointerEventType::move;
- if (isDown && !gPrevMouseButtonDown) {
- evtType = rive::PointerEventType::down; // we just went down
- } else if (!isDown && gPrevMouseButtonDown) {
- evtType = rive::PointerEventType::up; // we just went up
- }
-
- gPrevMousePos = mouse;
- gPrevMouseButtonDown = isDown;
-
- SkMatrix inv;
- (void)ctm.invert(&inv);
-
- // scale by 2 for the DPI of a high-res monitor
- const auto pt = inv.mapXY(mouse.x * 2, mouse.y * 2);
-
- const int pointerIndex = 0; // til we track more than one button/mouse
- rive::PointerEvent evt = {
- evtType,
- {pt.fX, pt.fY},
- pointerIndex,
- };
- artboard->postPointerEvent(evt);
-}
-
static void test_messages(rive::Artboard* artboard) {
rive::Message msg;
int i = 0;
+#ifdef DEBUG
bool hasAny = artboard->hasMessages();
+#endif
while (artboard->nextMessage(&msg)) {
printf("-- message[%d]: '%s'\n", i, msg.m_Str.c_str());
diff --git a/src/artboard.cpp b/src/artboard.cpp
index e8ffc53..37a3745 100644
--- a/src/artboard.cpp
+++ b/src/artboard.cpp
@@ -575,46 +575,6 @@
return result;
}
-void Artboard::postPointerEvent(const PointerEvent& evt) {
- if (true) {
- static bool gButtonIsDown;
-
- switch (evt.m_Type) {
- case PointerEventType::down:
- assert(!gButtonIsDown);
- gButtonIsDown = true;
- break;
- case PointerEventType::up:
- assert(gButtonIsDown);
- gButtonIsDown = false;
- break;
- default:
- break;
- }
-
-#if 0
- const char* typeNames[] = {
- "down", "move", "up ",
- };
- printf("pointer: %s [%g %g] %s\n",
- typeNames[(int)evt.m_Type],
- evt.m_Position.x(), evt.m_Position.y(),
- gButtonIsDown ? "DOWN" : "UP");
-#endif
- }
-
-#if 0
- // TESTING ONLY
- // This is the sort of message that the Artboard would post...
- // e.g. if the down AND up were inside the same clickable shape.
- if (evt.m_Type == PointerEventType::up) {
- Message msg;
- msg.m_Str = "ClickEvent";
- this->testing_only_enque_message(msg);
- }
-#endif
-}
-
void Artboard::testing_only_enque_message(const Message& msg) { m_MessageQueue.push(msg); }
bool Artboard::hasMessages() const { return !m_MessageQueue.empty(); }
diff --git a/test/state_machine_event_test.cpp b/test/state_machine_event_test.cpp
index 95a01ae..ad9e4d3 100644
--- a/test/state_machine_event_test.cpp
+++ b/test/state_machine_event_test.cpp
@@ -19,9 +19,9 @@
#include <cstdio>
TEST_CASE("file with state machine events be read", "[file]") {
- RiveFileReader reader("../../test/assets/bullet_man.riv");
+ auto file = ReadRiveFile("../../test/assets/bullet_man.riv");
- auto artboard = reader.file()->artboard("Bullet Man");
+ auto artboard = file->artboard("Bullet Man");
REQUIRE(artboard != nullptr);
REQUIRE(artboard->stateMachineCount() == 1);
@@ -61,9 +61,9 @@
}
TEST_CASE("hit testing via a state machine works", "[file]") {
- RiveFileReader reader("../../test/assets/bullet_man.riv");
+ auto file = ReadRiveFile("../../test/assets/bullet_man.riv");
- auto artboard = reader.file()->artboard("Bullet Man")->instance();
+ auto artboard = file->artboard("Bullet Man")->instance();
REQUIRE(artboard != nullptr);
REQUIRE(artboard->stateMachineCount() == 1);