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

NagView: properly rescale on scale change #1379

Merged
merged 2 commits into from
Feb 6, 2023

Conversation

jgmdev
Copy link
Member

@jgmdev jgmdev commented Feb 2, 2023

Besides properly rescaling the NagView overlay on scale changes this PR also drops the font option because:

  1. its usage was unnecessary since the style.font is always used on the core for the buttons
  2. creates unnecessary references to fonts when the user sets a different style.font
  3. because of point 2 the font set on the options never scales when using the scale plugin because it goes unmanaged if the style.font changed at some point after the nagview options were set.

Checked the lite-xl-plugins repo and it seems no plugin is affected with the font option removal since none of the plugin is making use of core.nag_view

Before:
Screenshot_2023-02-01_19-26-48

After:
Screenshot_2023-02-01_19-45-37

Comment on lines +248 to +256
function NagView:on_scale_change(new_scale, old_scale)
BORDER_WIDTH = common.round(1 * new_scale)
UNDERLINE_WIDTH = common.round(2 * new_scale)
UNDERLINE_MARGIN = common.round(1 * new_scale)
self.target_height = math.max(
self:get_message_height(),
self:get_buttons_height()
)
end
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it would be better to just move those values to their own function that calculates them on demand.

Copy link
Member Author

@jgmdev jgmdev Feb 2, 2023

Choose a reason for hiding this comment

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

It is actually more efficient to calculate at least self.target_height only when needed and not on each rendering pass or update.

Copy link
Member

Choose a reason for hiding this comment

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

It would still only be called when the NagView is visible, and I'm sure the calculations required are not that complex, as the most complex thing needed is NagView:get_message_height which I'm just noticing could be simplified quite a bit.

@jgmdev
Copy link
Member Author

jgmdev commented Feb 6, 2023

Merging this for now as the suggestions above are more a different way of doing things without any impact on the desired result.

@jgmdev jgmdev merged commit d784133 into lite-xl:master Feb 6, 2023
takase1121 pushed a commit to takase1121/lite-xl that referenced this pull request Aug 19, 2023
* drop font option since style.font is always used
takase1121 pushed a commit to takase1121/lite-xl that referenced this pull request Aug 19, 2023
* drop font option since style.font is always used
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants