Bevelbuttons - with auto-resizing icons

Just wondering if this has come up before.

For ages I found annoying that BevelButtons display icons at some peculiar scale and don’t automagically rescale the icon to suit their width/height. It’s all the more tedious having to rework my library of icons in the even I want some a few pixels taller/shorter.

So… I based my icons on 512 x 512 vector graphics saved as PNG’s, the result being they render nicely on a variety of platforms and their size is not excessive.

Then I rolled my own subclass of desktopBevelButton, with a couple of extra properties - margin (Integer) and scaleableIcon (Picture). Both of these are also exposed in the Xojo IDE, so you can assign any icon you like to the scaleableIcon property.

In the Opening event handler, the following will set the icon accordingly - and hey presto, automagically resizing icons to suit your buttons.

Now if only Xojo had this behaviour baked in …

2 Likes

can you put the code as text instead of image??
look like a great code to have.
I was having problem with my app when the image stay tiny when the button is bigger

Here you are:


var p as new Picture (Width, height) var scale as double
if scaleablelcon <> nil then
scale = min((width-margin*2)/scaleablelcon.width, (height-margin*2)/scaleablelcon.height)
p.Graphics. DrawPicture scaleablelcon, margin, margin, scale*scaleablelcon.width, scale*scaleablelcon.height, 0,0, scaleablelcon.width, scaleablelcon.height
icon = o
end if

Thanks to LiveText (macOS)

I just try live text on ios … didn’t know about that

I do not knew about LiveText (on MacOS) either until I wanted to move an image (displayed with … Selection then space in the Finder) with a Mouse Drag and see the text inside the image “selected” !

Then, I learned that Apple now calls LiveText what was know earlier as OCR (Optical Character Recognition).

We learn new things all the time ! And this one is a good one… (also available on Windows 11 some said…)

1 Like

I simply do a long press on the image and the menu come out with share, save to photos, copy and show text

I click on ‘show text’ and then ‘copy all’

So, they are now bitmaps…

Why don’t you save them to pdf (and check they really stays as Vectors), then use that in your UI ?

the last line is bad ocrized. it is icon = p and not icon = o !

1 Like