Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gestures #159

Merged
merged 41 commits into from
Nov 29, 2020
Merged

Gestures #159

merged 41 commits into from
Nov 29, 2020

Conversation

amolenaar
Copy link
Member

@amolenaar amolenaar commented Nov 19, 2020

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Documentation content changes

What is the current behavior?

A Gaphas view has it's own handling of events, through tools.

Issue Number: #72

What is the new behavior?

Tools are a lot like Gtk's EventControllers. Those will be used instead.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

  • Requires Gtk 3.24 or newer
  • To make use of EventControllers, I needed up upgrade the build servers to Ubuntu 20.04.
  • EventControllers are created with a widget reference.

I edited a bit of documentation. It will probably require something of a rewrite though. documentation updates I want to do in a later PR.

Now we can do "pinch-to-zoom".
It's outdated. Have a look at Gaphor for an example of how this can be
done.
@amolenaar amolenaar linked an issue Nov 19, 2020 that may be closed by this pull request
@amolenaar amolenaar added this to the 3.0 milestone Nov 19, 2020
@amolenaar amolenaar added this to In progress in Gaphas overhaul via automation Nov 19, 2020
@amolenaar amolenaar marked this pull request as draft November 19, 2020 22:44
This term is more consistent with Gtk.
Rename `InMotion` aspect to `Move`.
One tool to deal with everything item related
Can not remove HandleTool yet, since PlacementTool depends on it.
It's not suitable to use in combination with gestures
Make GuidePainter an ordinary painter.
It can not grab the event sequence, hence all events are propagated to
the other event controllers and it ends up at the rubberband tool.
It can be obtained from the controller.
The Gtk+ version provided by Ubunutu 18.04 is to old.
It does not support event controllers.
Make methods used on Line public methods
No longer used. Just create separate painters instead.
Amend HandleMove for lines with a merge-segment functionality.
@amolenaar amolenaar marked this pull request as ready for review November 25, 2020 20:51
Copy link
Member

@danyeaw danyeaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so awesome to upgrade Gaphas to use Gtk Gestures, really nice job @amolenaar! 🎉

gaphas/tool/hover.py Outdated Show resolved Hide resolved
gaphas/tool/itemtool.py Show resolved Hide resolved
Processing Dan's comments.
This keeps the Model/Canvas interface small.
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 29, 2020

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.16%.

Quality metrics Before After Change
Complexity 2.88 ⭐ 2.96 ⭐ 0.08 👎
Method Length 40.51 ⭐ 42.77 ⭐ 2.26 👎
Working memory 8.06 🙂 7.55 🙂 -0.51 👍
Quality 73.63% 🙂 73.79% 🙂 0.16% 👍
Other metrics Before After Change
Lines 3899 3111 -788
Changed files Quality Before Quality After Quality Change
examples/demo.py 59.35% 🙂 64.83% 🙂 5.48% 👍
gaphas/canvas.py 89.34% ⭐ 89.75% ⭐ 0.41% 👍
gaphas/guide.py 71.65% 🙂 71.87% 🙂 0.22% 👍
gaphas/item.py 83.03% ⭐ 82.69% ⭐ -0.34% 👎
gaphas/segment.py 62.45% 🙂 67.29% 🙂 4.84% 👍
gaphas/aspect/init.py % % %
gaphas/painter/init.py 78.01% ⭐ 88.18% ⭐ 10.17% 👍
gaphas/tool/init.py 68.46% 🙂 % %
gaphas/tool/hover.py 91.72% ⭐ 93.76% ⭐ 2.04% 👍
gaphas/tool/itemtool.py 76.65% ⭐ 66.07% 🙂 -10.58% 👎
gaphas/tool/placement.py 88.22% ⭐ 80.73% ⭐ -7.49% 👎
gaphas/tool/rubberband.py 79.16% ⭐ 79.97% ⭐ 0.81% 👍
gaphas/tool/zoom.py 65.10% 🙂 78.11% ⭐ 13.01% 👍
gaphas/view/gtkview.py 73.39% 🙂 73.47% 🙂 0.08% 👍
gaphas/view/selection.py 94.35% ⭐ 93.90% ⭐ -0.45% 👎
tests/test_aspect.py 86.44% ⭐ 85.80% ⭐ -0.64% 👎
tests/test_guide.py 73.61% 🙂 73.24% 🙂 -0.37% 👎
tests/test_segment.py 71.80% 🙂 71.18% 🙂 -0.62% 👎
tests/test_view.py 84.91% ⭐ 87.18% ⭐ 2.27% 👍

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
gaphas/view/gtkview.py GtkView.update_back_buffer 22 😞 240 ⛔ 11 😞 34.63% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
examples/demo.py create_window 9 🙂 799 ⛔ 11 😞 39.07% 😞 Try splitting into smaller methods. Extract out complex expressions
gaphas/tool/itemtool.py handle_at_point 18 🙂 151 😞 10 😞 46.38% 😞 Try splitting into smaller methods. Extract out complex expressions
gaphas/tool/itemtool.py on_drag_begin 8 ⭐ 139 😞 15 😞 48.40% 😞 Try splitting into smaller methods. Extract out complex expressions
gaphas/item.py Element.__init__ 0 ⭐ 210 ⛔ 15 😞 49.80% 😞 Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Let us know what you think of it by mentioning @sourcery-ai in a comment.

@amolenaar amolenaar merged commit b8e92fc into master Nov 29, 2020
Gaphas overhaul automation moved this from In progress to Done Nov 29, 2020
@amolenaar amolenaar deleted the gestures branch November 29, 2020 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Replace use of events by Gestures
2 participants