-
Notifications
You must be signed in to change notification settings - Fork 236
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
Conversation
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Merging this for now as the suggestions above are more a different way of doing things without any impact on the desired result. |
* drop font option since style.font is always used
* drop font option since style.font is always used
Besides properly rescaling the NagView overlay on scale changes this PR also drops the font option because:
style.font
is always used on the core for the buttonsChecked 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:
After: