-
Notifications
You must be signed in to change notification settings - Fork 40
Add image viewer widget #565
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
base: main
Are you sure you want to change the base?
Conversation
91bf416 to
440bde3
Compare
|
Intention of adding an image magnifier and the ability to pan image. The image's image_scale, image_pan will always be set to default in draw_walk. Hence unable to dynamically scale and pan image. |
1b7875f to
ddd04b9
Compare
@alanpoon I just checked with Rik, and this line should not be present in the Image widget. It's some errant code left over from dealing with animations in a strange way. You can submit a PR to makepad that removes that line, and then continue with this issue here. |
|
Sure, the makepad PR is here: makepad/makepad#788 |
kevinaboos
left a comment
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.
Thanks Alan, nice work here.
My main comment is that we should decouple the ImageViewer widget from the RoomScreen. It doesn't need to know anything about the RoomScreen except for being able to access the RoomScreen's MediaCache instance (technically even that is not required, see Aarav's PR for an example of just passing the image data directly from the media fetch background task to the ImageViewer via an action).
Also, Aarav and I had a lot of discussions about using actions to communicate with the ImageViewer widget in PR#443. I think you can combine your approach (of storing images in the RoomScreen's MediaCache) with the action-based design from #443 (in which you emit an action including the image data/status instead of directly accessing the widget and calling a function on it). Actions are more idiomatic and also allow easy communication from any context, both in a background task and in a RoomScreen TimelineUpdate handler.
Co-authored-by: Kevin Boos <[email protected]>
Co-authored-by: Kevin Boos <[email protected]>
…into image_viewer#327
238c3e2 to
249a384
Compare
3f5eaca to
0c1fb66
Compare
src/home/room_image_viewer.rs
Outdated
| /// If the media is already cached, it will be immediately displayed. | ||
| /// If the media is not cached, it will be fetched from the server. | ||
| /// If the media fetch fails, an error message will be displayed. | ||
| /// | ||
| /// This function requires passing in a reference to `Cx`, which isn't used, but acts as a guarantee that this function must only be called by the main UI thread. |
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.
nit: you left out the bullet points in my suggested text, which means that it won't render as three separate lines/points.
GitHub has a "commit suggestion" button (or you can batch multiple suggestions at once), so you should use that when possible to avoid copy/paste accidents like this.
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.
what's the reason for all the version changes to windows-sys crates? Those are all unrelated to this PR.
src/shared/image_viewer.rs
Outdated
| flow: Right | ||
|
|
||
| top_left_container = <View> { | ||
| width: 150, height: Fit, |
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.
ok... that's a small improvement, but not a full fix.
Why not just allow it to fill the entire space as needed? You can just have two views: the metadata on the top left, and then the image name and size can be immediately to the right of that. If you make all content have a known width (either a number or Fit), then you can use flow: RightWrap to ensure that they'll automatically flow onto the next line if the screen isn't narrow enough, which removes the need to have special cases for Mobile view mode.
| avatar_placeholder = <View> { | ||
| width: 40, height: 40, | ||
| } |
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.
is there some particular reason (or benefit) for why you're using a placeholder instead of just directly putting the avatar here? Seems like it'd be a lot easier just to define an Avatar widget here as normal, and then you can get rid of all the complex logic for the placeholder rectangle and the avatar template.
| /// The avatar template to used to generate Avatar for image viewer modal. | ||
| #[live] avatar_template: Option<LivePtr> |
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.
this is not necessary — see my other comment.



Fixes #327

in replacement of #443
Waiting for this PR to be merged: makepad/makepad#788.