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

CanvasView: Make the canvas the main element #111

Merged
merged 3 commits into from
Jul 25, 2020
Merged

Conversation

martinRenou
Copy link
Collaborator

@martinRenou martinRenou commented Jul 24, 2020

This removes the extra div container, and it means users can now apply the Layout property on the Canvas itself instead of the extra container.

This means that when the user does:

canvas.layout.width = '100%'  # Take all the available width
canvas.layout.height = 'auto'  # Automatically find a suitable height (respecting the ratio)

the canvas will have a "responsive" behavior that respects the available space AND the canvas size ratio.

When doing:

canvas.layout.width = 'auto' 
canvas.layout.height = 'auto'

which is the default, the canvas will respect its width and height properties.

And when doing:

canvas.width = 200
canvas.height = 200
canvas.layout.width = '100px'
canvas.layout.height = '100px'

the canvas will take 100x100 pixels on the screen, but will actually contain an image of size 200x200.

This should fix #110 and Kitware/ipyvtklink#2, which should both use the first approach.

This removes the extra div container, and it means users can now apply
the Layout property on the Canvas itself instead of the extra container.

Signed-off-by: martinRenou <martin.renou@gmail.com>
src/widget.ts Outdated Show resolved Hide resolved
@martinRenou
Copy link
Collaborator Author

The MultiCanvas will not behave the same way. We need to find a workaround for it.

Signed-off-by: martinRenou <martin.renou@gmail.com>
Signed-off-by: martinRenou <martin.renou@gmail.com>
@martinRenou
Copy link
Collaborator Author

Let's merge this as it is. And see what to do for the MultiCanvas later.

@martinRenou martinRenou merged commit eaa052a into master Jul 25, 2020
@martinRenou martinRenou deleted the sizing_logic branch July 25, 2020 09: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.

Automatic scaling of a canvas
1 participant