Page 1 of 2

How to display a round object?

Posted: Sunday 8th December 2019 7:14pm
by issboss
I'm creating a control panel and can't seem to find any way to display a round image. The image is one of a rotary switch (with a white dot as an indicator) with small hash marks at the stopping points around the periphery (outside the image). I am using a PictureBox and setting "Picture" to the image. That works well, but there are four corners to the image that blot out the tick marks around the sides.

Is there a way to make a round area, which will NOT be clickable or used by the operator, but simply show the rotating image as buttons around the image are clicked. My attempts at making the four corners transparent have not been successful although there is supposed to be a way to make that happen in Gimp. Even then, I'm not sure it will cause the underlying "panel" behind the image show once more.

A screenshot is attached showing what I mean.

Bill

Re: How to display a round object?

Posted: Sunday 8th December 2019 7:39pm
by Technopeasant
As far as I know, all Gambas controls are rectangles. Is your image for the dial transparent? What I would do is have the dial as the bottom control, and then the ticks as the top control and let transparency do the rest.

Also, what toolkit are you using? I only use Qt 5 as the transparency in all of the others is non-functional.

Re: How to display a round object?

Posted: Sunday 8th December 2019 8:13pm
by issboss
I'm using QT5 and QT5 Extension. I don't see anything about transparent for a picturebox, though. I've been trying all morning to make the four corners (the areas in Gray) transparent, but haven't had any luck. I'm not proficient in Gimp enough to extract the circular switch and leave the rest transparent. Could it be because I'm using JPGs instead of something else?

Bill

Re: How to display a round object?

Posted: Sunday 8th December 2019 9:20pm
by issboss
Seems as if I've solved the problem from way outside the box (no pun intended). I just made the buttons for the register letters larger than they would have been to include the short marker line and overlay a picture onto the button that covers the four "skirts" of gray nicely.

Are any of the devs thinking of creating a round control? Seems it would be right handy to a lot of people - including me for the toggle switches I have to animate.

Bill

Re: How to display a round object?

Posted: Monday 9th December 2019 3:31am
by Technopeasant
For future reference, as far as I know JPEG has no transparency support, so you would need to use GIF or PNG.

Re: How to display a round object?

Posted: Monday 9th December 2019 5:17am
by Got2BeFree
Bill, if you send me your image file I can create a new png image for you.

The example image I created using your rotary example is a png with transparent corners.
Rotary Example.png
Rotary Example.png (21.63 KiB) Viewed 9879 times

Re: How to display a round object?

Posted: Monday 9th December 2019 2:41pm
by jornmo
You might get some ideas from this?!

viewtopic.php?f=6&t=12

Re: How to display a round object?

Posted: Monday 9th December 2019 4:03pm
by issboss
Great suggestions. Last first:

@Jornmo: I saw the gauge and fiddled with it for an hour or so. If I were making a continuous rotating object, it would be fine, but I needed snap-to steps of 30 degrees. Individual pictures seemed the best way to go, displayed as the perimeter letters were clicked.

@Got2befree: Much thanks. I should take the time to figure out how to do this myself. You image worked perfectly. Thank goodness for the Stretch property.

@Technopeasant: I knew JPGs didn't have but one channel, but they were the easiest to work with. I'm in the process of converting all of them to at least flat PNGs as that format seems to display better for some reason. Probably because it isn't a lossy format.

My thanks to all.

Bill

Re: How to display a round object?

Posted: Monday 9th December 2019 8:01pm
by Cedron
issboss wrote: Sunday 8th December 2019 9:20pm Seems as if I've solved the problem from way outside the box (no pun intended). I just made the buttons for the register letters larger than they would have been to include the short marker line and overlay a picture onto the button that covers the four "skirts" of gray nicely.

Are any of the devs thinking of creating a round control? Seems it would be right handy to a lot of people - including me for the toggle switches I have to animate.

Bill
Did some one say "way outside the box" and something about animated controls?

You might enjoy the programming examples from this thread: "Programming is supposed to be fun"

viewtopic.php?p=1517

Re: How to display a round object?

Posted: Monday 9th December 2019 8:58pm
by issboss
Interesting thread, Cedron. The Author in me couldn't resist a little editing. In the last post of the thread: "run it up the flag pool" ??? Sorry. it's my OCD kicking in.

Bill