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

feat(Status): move thread lines to snapshoting #1315

Merged
merged 1 commit into from
Jan 31, 2025

Conversation

GeopJr
Copy link
Owner

@GeopJr GeopJr commented Jan 31, 2025

fix: #633

This should improve performance a bit too.

Here's how thread lines used to work:

  • Tootle

Thread line was a single GtkImage that changed its alignment and margins based on the ROLE (start, middle, end)

  • Tuba before this PR

I had experimented with different approaches without completely moving away from Tootle's and ended up with one GtkImage for the line above the avatar and one for below. They changed visibility based on ROLE (start = bottom visible, middle = both visible, end = top visible)

Now there were two GtkImages when it should be none. The pos over Tootle's approach was better alignment and easier to maintain than guessing margins.

  • Tuba after this PR

Using snapshoting, it draws a line based on the ROLE and the avatar's position.

It should be faster and have better alignment as we control how and where it gets drawn.

There are comments describing the maths and thought process but the gist is:

  • get avatar's point based on the status widget
  • increase its x position by the avatar's width / 2 + the thread line width / 2, this way the thread line will be drawn exactly at the center of the avatar
  • based on the role calculate the thread line height, but increase it a bit or start at a negative value so it fills the whole status (border and all) because it looks better that way
  • set opacity, get color from widget, push pop
  • redraw when needed

@GeopJr GeopJr merged commit 62b8dc0 into main Jan 31, 2025
3 of 5 checks passed
@GeopJr GeopJr deleted the feat/status/thread-line-snapshoting branch January 31, 2025 10:54
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.

[Bug]: When opening a post's thread, GtkImage reported min height -17 (or -16), but sizes must be >= 0
1 participant