-
-
Notifications
You must be signed in to change notification settings - Fork 138
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
Added the option for image to take its original size #815
Conversation
Because i am not if there is a way to do this without this change if you use image from URL. You can of course just write your own function that fetches the image and gets the size, but whats the point of ImageWithURLWidget? I was also thinking about adding a option to set a size constraint and just scale the image while keeping the aspect ratio to fit the constraint. It would be nice if you shared some feedback, thanks! |
I have also thought about replacing the behavior when passing in (-1, -1) to Size with this, because the current one kinda sucks and just stretches the Image. |
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.
Hi! Thank you for your PR.
I think this is very good idea and I'm wondering why it isn't there already 😁
Just a few things:
Made it default behavior, ran the CI on my fork, everything seems fine to me. You can test the new behavior using the provided code snippet (you have to download the image): func loop() {
g.SingleWindow().Layout(
g.Style().SetFontSize(20).To(
g.Label("Default behavior:"),
),
g.Label("Image with URL:"),
g.ImageWithURL("https://go.dev/blog/gopher/header.jpg"),
g.Label("Image with file:"),
g.ImageWithFile("./header.png"),
g.Dummy(0, 100),
g.Style().SetFontSize(20).To(
g.Label("Custom size:"),
),
g.Label("Image with URL:"),
g.ImageWithURL("https://go.dev/blog/gopher/header.jpg").Size(200, 200),
g.Label("Image with file:"),
g.ImageWithFile("./header.png").Size(200, 200),
)
}
func main() {
wnd := g.NewMasterWindow("New img behavior test", 1000, 1000, 0)
wnd.Run(loop)
} |
And would you be able to recommend me some things to work on in this project? I find it quite cool and would like to contribute some more. 😄 |
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.
2 more things:
- could you wite a comment over ImageWidget (and probably ImageWithURL and other Image*
type definition and describe what
0` does - there is still one liner issue
@MisustinIvan generally, we have 3 types of issues:
|
Added the comments and fixed linter complaint, everything should be fine. |
Bruh does the linter really want comments to end with period... |
Check passed, everything seems fine to me! |
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.
nice, thank you
you can use |
thanks, will try that next time! |
btw what is the best practice, github is asking me if I want to delete the feature branch. Should i delete it or keep it? |
I thing you should delete. these commits are in master anyway and if you keep every branch, you'll have hundreds of them some day 😄 |
you can now do .Size(0,0) and the image takes its original size