Fixed flick gesture on wearable emulator and add drag gesture 22/209822/1
authore.czarnocki <e.czarnocki@samsung.com>
Wed, 10 Jul 2019 14:57:36 +0000 (16:57 +0200)
committere.czarnocki <e.czarnocki@samsung.com>
Thu, 11 Jul 2019 09:53:01 +0000 (11:53 +0200)
Change-Id: If1ab1c283fb4fc1f52885a8f4164844d80955683

src/batch/BatchRunner.cpp

index 3df5afeb9bed0ca314d7cbd0b04588d9653dfe4e..19a8f825575ef7b033968e0f261b6926914d00f4 100644 (file)
@@ -1035,8 +1035,8 @@ void BatchExecutor::insertMethods()
        variables["DOUBLE_TAP"] = generateTapFunction(2);
        variables["TRIPLE_TAP"] = generateTapFunction(3);
 
-       auto generateFlickFunction = [&](int dx, int dy) {
-               return EvaluationValueFunction{ [ &, dx, dy](EvaluationValue fingers) -> EvaluationValue {
+       auto generateFlickFunction = [&](int dx, int dy, int steps) {
+               return EvaluationValueFunction{ [ &, dx, dy, steps](EvaluationValue fingers) -> EvaluationValue {
                                auto root = getVisibleRoot();
                                if (!root) throw EvaluationFailure{} << "no visible root (context changed didn't happen)";
                                ASSERT(root->getObject());
@@ -1053,16 +1053,32 @@ void BatchExecutor::insertMethods()
                                        auto x1 = x0 + dx;
                                        auto y0 = mx.y - dy / 2;
                                        auto y1 = y0 + dy;
-                                       utils::generateDragGesture(x0, y0, x1, y1, 20, 0.0, fingerCount);
+                                       utils::generateDragGesture(x0, y0, x1, y1, steps, 0.0, fingerCount);
                                });
                                std::this_thread::sleep_for(std::chrono::milliseconds{ 600 });
                                return EvaluationValue{};
                        }, { { "fingers", 1 } } };
        };
-       variables["FLICK_RIGHT"] = generateFlickFunction(300, 0);
-       variables["FLICK_LEFT"] = generateFlickFunction(-300, 0);
-       variables["FLICK_UP"] = generateFlickFunction(0, -300);
-       variables["FLICK_DOWN"] = generateFlickFunction(0, 300);
+
+       auto size = Singleton<UniversalSwitch>::instance().getMainWindow()->getDimensions().size;
+
+       //      280 = 360 - 2 * 40 ( 40 - left margin to emulate regular flick but not flick from side of the screen )
+       //      250 = 360 - 2 * 55 ( 55 - top margin to emulate regular flick but not flick from side of the screen )
+       //      360 x 360 - dimensions of wearable screen
+       auto width = size.width * 280 / 360;
+       auto height = size.height *  250 / 360;
+
+       // For flick gesture we set the step value to 20.
+       variables["FLICK_RIGHT"] = generateFlickFunction(width, 0, 20);
+       variables["FLICK_LEFT"] = generateFlickFunction(-width, 0, 20);
+       variables["FLICK_UP"] = generateFlickFunction(0, -height, 20);
+       variables["FLICK_DOWN"] = generateFlickFunction(0, height, 20);
+
+       // For drag gesture we set the step value to 60.
+       variables["DRAG_RIGHT"] = generateFlickFunction(width, 0, 60);
+       variables["DRAG_LEFT"] = generateFlickFunction(-width, 0, 60);
+       variables["DRAG_UP"] = generateFlickFunction(0, -height, 60);
+       variables["DRAG_DOWN"] = generateFlickFunction(0, height, 60);
 
        auto generateWheelTurnFunction = [&]() {
                return EvaluationValueFunction{ [&](bool clockwise, int multiplicity) -> EvaluationValue {