canonical / mir-ci

Mir CI helpers
1 stars 1 forks source link

Add embedded args #93

Closed hbatagelo closed 4 months ago

hbatagelo commented 5 months ago

Fixes #83.

Modified keywords:

Move Pointer To ${destination}, where ${destination} can be either the name of an image template, or an xy-point. Walk Pointer From ${source} To ${destination}, where ${source} and ${destination} can be the name of image templates, or points.

Examples:

# Move to (100, 200)
${p}=    Evaluate    {"x":100, "y":200}
Move Pointer To ${p}

# Move to the center of the first region where the template matches
Move Pointer To "template.png"

An optional argument, ${proportional}, can be used to move to a position proportional to the dimensions of the output. For instance, to move to the center of the output:

${p}=    Evaluate    {"x":0.5, "y":0.5}
Move Pointer To ${p}    proportional=True

or simply

Move Pointer To ${{{"x":0.5, "y":0.5}}}    proportional=True

Examples with Walk Pointer:

Walk Pointer From "template0.png" To "template1.png"
Walk Pointer From ${p} To "template.png"
Walk Pointer From "template.png" To ${p}
Walk Pointer From ${p0} To ${p1}

Walk Pointer has proportional_source and proportional_destination optional arguments:

${center}=          Evaluate    {"x":0.5, "y":0.5}
${bottom_right}=    Evaluate    {"x":1, "y":1}
Walk Pointer From ${center} To ${bottom_right}    proportional_source=True    proportional_destination=True

PS. The names Move Pointer To Proportional and Move Pointer To Absolute from WaylandHid may be shadowed by Move Pointer. A solution is to use underscores or the keyword's full name:

Move_Pointer_To_Proportional    ${p}[x]    ${p}[y]               # OK
WaylandHid.Move Pointer To Proportional    ${p}[x]    ${p}[y]    # OK
Move Pointer To Proportional    ${p}[x]    ${p}[y]               # Error: calls `Move Pointer To`
codecov[bot] commented 5 months ago

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (97766d3) 64.05% compared to head (baa7e3c) 63.88%. Report is 12 commits behind head on main.

Files Patch % Lines
mir-ci/mir_ci/virtual_pointer.py 0.00% 4 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #93 +/- ## ========================================== - Coverage 64.05% 63.88% -0.18% ========================================== Files 11 11 Lines 740 742 +2 Branches 103 103 ========================================== Hits 474 474 - Misses 241 243 +2 Partials 25 25 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

hbatagelo commented 4 months ago

Yeah, choosing the behavior based on argument types would resolve the issue and keep the keywords concise. However, I'd prefer using strong types instead of differentiating solely between int and float.

To keep things simple, perhaps we could just use Move Pointer To [Proportional] point and Walk Pointer From [Proportional] point_a To [Proportional] point_b. If the optional [Proportional] word is not used, it would default to absolute positioning.

I see very little use in these, as there's going to be a limited number of use cases warranting moving to the source without modifying the button states?

True, I was thinking of gestures and multi-step drawing/dragging, but we can always get the destination position from a previous move/walk and use it as the source position for the next command.

hbatagelo commented 4 months ago

I've removed the proportional optional arguments. Now we have the following keywords which should be enough for most use cases: