-
Notifications
You must be signed in to change notification settings - Fork 42
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
Refactor and document Viewport #152
base: main
Are you sure you want to change the base?
Conversation
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.
The documentation additions here are good. The impact of the other changes is IMO negligible (a few single-line methods on Viewport aren't exactly a maintenance burden), but I will accept them (with the requested changes) if you're keen for them.
@@ -179,7 +179,7 @@ impl<Doc: DocumentLike> View<Doc> { | |||
let (width, height) = self.viewport.window_size; | |||
self.renderer.render( | |||
self.dom.as_ref(), | |||
self.viewport.scale_f64(), | |||
self.viewport.scale() as _, |
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.
Can we have an explicit type (f64
) here please. Makes it more obvious why a cast is being done. Some for other uses of _
let window_width = self.viewport.window_size.0 as f64 / self.viewport.scale() as f64; | ||
let window_height = self.viewport.window_size.1 as f64 / self.viewport.scale() as f64; | ||
let window_width = self.viewport.window_size.0 as f64 / self.viewport.hidpi_scale as f64; | ||
let window_height = self.viewport.window_size.1 as f64 / self.viewport.hidpi_scale as f64; |
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.
Was this change intentional? It's not equivalent to the previous code (which included the zoom
).
If not, then IMO this is actually quite a good argument for having the hidpi_scale
and zoom
field private as they were before, as it prevents this kind of accidental usage of the wrong value.
If it is, then can you provide a justification for the change?
Viewport::zoom
andViewport::set_zoom
with an exported fieldViewport::scale_f64
convenience method