-
Notifications
You must be signed in to change notification settings - Fork 166
Image: add getSize() #2129
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
Comments
-1 for deprecating I think the The |
The proposal makes sense to me, but as usual, replacing such integral API is difficult. So we will likely have to maintain two methods for a long time then, but in this case there are at least rather simple.
The difference I see here is that Since @HannesWell has been working on improving APIs (also the one of Image), maybe you have an opinion on this? |
I think GC is actually a good example of why I have mixed feelings about this. SWT doesn't have a In my example, the GC method then has to be refactored to: Point p = image.getSize();
gc.fillRect(0, 0, p.x, p.y); Or alternatively, a new But semantically, this just doesn't work very well, because you now use Or to rephrase it: If I, as a user, have the choice between Edit: My point is: If a |
@ptziegler Your example only is a shortcut for those (rare?) case where you draw the image at (0, 0). OK, let's forget about deprecating |
You are right, the common usage of So to summarize, we would probably need some even larger change introducing a proper size/dimension representation in SWT before it makes sense to provide some |
This brings me to the thought:
I don't think, the introduction of |
That sounds like a good idea. It definitely makes the migration a lot easier. Just out of curiosity, what's the motivation behind touching the getBounds() method? |
I just noticed that |
So is it only about boilerplate code required due to abscence of |
I can try to draft a PR over the next few days, just to see how much change a new datatype would require. The main challenge I see is that this new datatype should also be returned by the already existing |
That's the case for |
Honestly, I don't expect that this is something we can do. You cannot make some Edit: note that it would not only be about |
You can't on a language level, but it's certainly possible to define bridge methods on a byte-code level to ensure compatibility... But I agree, this ship has sailed. So what's the plan instead? As mentioned, I'm not a huge fan of using Looking at Swing again, the |
OK, let's do |
I have not yet have a full picture, but try to get it soon.
Without knowing all the details, I'm really not sure if adding that many new methods is a good idea. |
Consider that for such library that's being available for decades, adding bunch of "helpful" methods is really not likely to get used by many consumers who are very unlikely to spend their time changing their already-working code to use methods that make their library compatible only with the latest version of SWT. Mixing the existing style with a "records" style also seems questionable to me. |
Image currently has just a method
getBounds()
returning a Rectangle with x and y always zero. IMHO it would make sense to addgetSize()
and deprecatedgetBounds()
.The text was updated successfully, but these errors were encountered: