I have a tool bar which looks great on Mac OS X, using retina sized 64x64 icons (which scale down to 32x32). However, on Win32 builds the toolbar is gigantic.
I tried the following code at runtime to shrink the icons down to 32x32
// try making all the icons 1/2 size on windows
for i as integer = 0 to me.Count-1
dim t as ToolItem = me.Item(i)
dim tb as ToolButton = ToolButton(t)
if tb.Icon <> nil then
dim p as picture = tb.icon
dim p2 as new Picture (p.width/2,p.height/2, 32) // use old-style picture or else it crashes!
tb.icon = p2
But all I end up with is a tall toolbar with stretched pixellated images.
Is there any way to have a single toolbar item in my project that looks good on Windows too?
RetinaKit might help with managing the correct icons.
Plus, it’s part of this awesome bundle for a short time.
Tim, my question is about Windows 32 (Win32) builds, not OS X.
Ok, I figured it out.
- On Win32, the toolbar height seems set by the size of the icon in the IDE. Swapping out icons at runtime has no effect.
- In OSX Cocoa, the toolbar height adapts to the size of your icons at runtime.
So a workable solution:
- In the IDE, use the @1x sized icons, which will work fine on Win32 builds.
- In Toolbar.Open, swap out your icons for Cocoa at runtime:
me.ToolButton1.icon = icon2x // these should be the @2x resolution icon
me.ToolButton2.icon = anotherIcon2x
A neat thing about retina kit is that it handles windows and linux for you
It’s essentially the same effect as you described in your last post where you set @1x on the toolbar and then it gets changed at display time, but with rk it will handle the need for @2x on Mac and provide the image needed when not @2x.
Also, seems like the proper toolbar icon sizes are:
- Cocoa: 64x64
- Windows: 48x48
So I was wrong earlier saying that @1x and @2x sizes are workable.