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

Fix the view to origin #343

Merged
merged 2 commits into from
Oct 1, 2021
Merged

Fix the view to origin #343

merged 2 commits into from
Oct 1, 2021

Conversation

amolenaar
Copy link
Member

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?

Currently the view is "dynamic". It's supposed to have no origin, only elements on it. However, when opening a diagram, it always shows (0, 0) as the upper-left corner.

Issue Number: gaphor/gaphor#1004

What is the new behavior?

The origin (0, 0) is always taken into account when calculating the bounding box for the viewed content (in view coordinates).

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

This should prevent surprising scroll behavior, since (0, 0) is always in the view bounding box.

The canvas can grow by moving items further away from the origin, but origin
remains the anchor point. Also, origin is put in the upper left when opening a
diagram.
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Sep 27, 2021

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 7.65 ⭐ 4.55 ⭐ -3.10 👍
Method Length 37.93 ⭐ 37.02 ⭐ -0.91 👍
Working memory 7.13 🙂 6.77 🙂 -0.36 👍
Quality 71.92% 🙂 77.11% 5.19% 👍
Other metrics Before After Change
Lines 440 445 5
Changed files Quality Before Quality After Quality Change
gaphas/view/gtkview.py 71.92% 🙂 77.11% ⭐ 5.19% 👍

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 15 🙂 188 😞 10 😞 45.29% 😞 Try splitting into smaller methods. Extract out complex expressions
gaphas/view/gtkview.py GtkView.update_bounding_box 8 ⭐ 159 😞 14 😞 47.53% 😞 Try splitting into smaller methods. Extract out complex expressions
gaphas/view/gtkview.py GtkView.__init__ 6 ⭐ 172 😞 14 😞 48.20% 😞 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!

Help us improve this quality report!

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.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants