Window Icon

Started by psiegel, July 10, 2003, 12:42:33

Previous topic - Next topic

kevglass

Yeah, an icon on linux is just a pixmap, which basically means it can be anysize, but it appears 32x32 is traditional.

Kev

tomb

Quote from: "kevglass"Yeah, an icon on linux is just a pixmap, which basically means it can be anysize, but it appears 32x32 is traditional.

Kev

But there is only one icon size used by the application?

What about tha api I suggested before:

int getRecommendedSmallIconSize()
int getRecommendedBigIconSize()
setSmallIcon(int data[], int width, int height)
setBigIcon(int data[], int width, int height)

Big icon is only used in windows when alt-tabbing. Otherwise small icon is used. The image passed in can be of any size, but it will be scaled if it don't fit the recommended size.

kevglass

Its fine by me, just like to get a standardised API sort so we can get something in. However, Small and Big doesn't really make sense. In this case what we're really saying is:

setWindowIcon()

and

setWinAltTabbingIcon()  :)

--

Also, this API means that I'll have ot put an OS check into my code to set the right size of icon, 16x16 on window, 32x32 on linux and up-to 128x128 on macos. :(

Kev

Matzon

I am still fond of the:
/**
 * Sets one or more icons for the Display.
 * <ul>
 * <li>On Windows you should supply at least one 16x16 icon and one 32x32.</li>
 * <li>Linux (and similar platforms) expect one 32x32 icon.</li>
 * <li>Mac OS X should be supplied one 128x128 icon</li>
 * </ul>
 * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform.
 * 
 * @param icons Array of icons in RGBA mode
 * @return number of icons used.
 */
public int Display.setIcon(ByteBuffer[] icons);

I see no reason for adding getMin/Max since these are known ahead of time. And in that same sense - one might argue the same with cursor...

kevglass

Looks good to me, OOI why return the number icons used?

Kev

tomb

QuoteI see no reason for adding getMin/Max since these are known ahead of time. And in that same sense - one might argue the same with cursor...

That is fine by me as long as it is fairly certain that there will never be any other sizes than 16, 32 and 128.

Quotepublic int Display.setIcon(ByteBuffer[] icons);

I think this is too unclear. I think it would be better to set by type or have 3 functions:
public int Display.setIcon16x16(ByteBuffer iconData, int width, int height);
public int Display.setIcon32x32(ByteBuffer iconData, int width, int height);
public int Display.setIcon128x128(ByteBuffer iconData, int width, int height);

The javadoc would make it clear that the functions would scale the image if it don't fit.

Matzon

Quote from: "kevglass"Looks good to me, OOI why return the number icons used?
if setIcon == 0, then an error occured - avoids the need for exceptions

Matzon

QuoteI think this is too unclear. I think it would be better to set by type or have 3 functions:
Code:

public int Display.setIcon16x16(ByteBuffer iconData, int width, int height);
public int Display.setIcon32x32(ByteBuffer iconData, int width, int height);
public int Display.setIcon128x128(ByteBuffer iconData, int width, int height);

The javadoc would make it clear that the functions would scale the image if it don't fit.
The problem with this, is that it's bloatish and I really prefer a cleaner api by not doing like cocoa (for example stringByAbbreviatingWithTildeInPath style method calls).
And forwarding a bit into the future, we would have 7 setIcon methods because of ports... whereas using 1 method would just require an updated javadoc

I am also a bit undecided whether or not an implementation should scale the images supplied, instead of forcing the developer to pass correct data. The former can lead to ugly icons and/or unexpected behaviour, wheread the latter will lead to the expected behaviour, but mean that the dev have to supply proper icons (which IMO is a good thing).

elias

Quote from: "Matzon"
Quote from: "kevglass"Looks good to me, OOI why return the number icons used?
if setIcon == 0, then an error occured - avoids the need for exceptions

Why avoid exceptions? I'd like to know when something went wrong :shock:.

- elias

Matzon

Exceptions are for tadaaa - exceptions!
if you supplied invalid icons sizes for specified platform then thats not an exception, it just means that the icon couldn't be used, thus 0.
If you passed something that couldn't be used (can't see how that would happen, since its just bytes) then thats an exception and will be thrown, but thats probably a runtime exception more than anything.

kevglass

Passing in byte buffers who size didn't give a square would be an exception circumstance. Or buffers that were empty I guess.

Kev