Draw an image on a toolbar?

Is it possible to place an image on a toolbar? Trying to achieve this look:

Button Button Button                     Long-Horizontal-Logo                      Button

Everything I’ve tried using a canvas has resulted in the image being drawn underneath the toolbar, i.e., invisible.

I suspect this is impossible, but does anyone know a way to do it?

You could perhaps use the method employed by Jim McKay to put a canvas over the window bar, in

https://forum.xojo.com/10914-black-windows/0

In his post from Apr 11, 2014:

http://www.pidog.com/share/blackwindowFinal3.xojo_binary_project

Michel, thank you for those suggestions, but they seem to be related to drawing in the title bar of a metal window, while I’m trying to draw an image on top of a toolbar in a regular window. I’m not sure if drawing in the title bar is applicable to drawing in a toolbar.

There are several options.

  1. Put the canvas into the Toolbar, if you don’t have the MBS plugin I can provide the code.

  2. Make the Toolbar background transparent, move the window content up behind the toolbar and draw there. You could even insert a NSVisualEffectView into the window, under your canvas to bring the Toolbar background back.

  3. is a lot easier, go with number 1.

Switch the window to Document, add a toolbar, and all you have to do is to position the canvas on top of the toolbar, and draw the picture where you want it.

I just did that in 5 minutes by modifying Jim’s project.

Amazing what preconceptions can do to programers :confused:

[quote=463253:@Michel Bujardet]Switch the window to Document, add a toolbar, and all you have to do is to position the canvas on top of the toolbar, and draw the picture where you want it.

I just did that in 5 minutes by modifying Jim’s project.

Amazing what preconceptions can do to programers :/[/quote]

Obviously I tried positioning a canvas on top of the toolbar and drawing it where I wanted it. That would be the first thing you would try, wouldn’t it?

It turns out the issue is dark mode. I neglected to mention I’m running in dark mode (and will need a solution that works in both dark and light mode), and you apparently had the preconceptions that I was using light mode and that anything that works in light mode will work the same way in dark mode.

Evidently you can’t position a canvas on top of a toolbar in dark mode and have it visible. The toolbar will always cover the canvas. Or at least I haven’t discovered a way to make that not happen.

[quote=463251:@Sam Rowlands]There are several options.

  1. Put the canvas into the Toolbar, if you don’t have the MBS plugin I can provide the code.

  2. Make the Toolbar background transparent, move the window content up behind the toolbar and draw there. You could even insert a NSVisualEffectView into the window, under your canvas to bring the Toolbar background back.

  3. is a lot easier, go with number 1.[/quote]

Thanks, Sam. I do have the MBS plugin, but I was hoping to figure out a way to make it work with Xojo’s built-in toolbar and I believe the MBS plugin route means junking the Xojo toolbar and replacing it with a Cocoa control. Is that right?

Might have to go that route, but that also means having to do a completely different toolbar on Windows (and finding a way to display a canvas in it).

I don’t know how I’d go about making the toolbar background transparent. A declare? Setting “me.transparent = true” has no effect.

Sorry for trying to help.

No need to apologize, Michel. It was my mistake.

BTW, I just verified that the canvas seems to stay on top of the toolbar in dark mode under Catalina…

2019R2

Interesting… Must be only a Mojave problem then, and increases the chance it’s an Apple thing rather than a Xojo thing.

I don’t use the MBS plugins myself, so I can’t comment. I do most of it directly with declares, as of yet, I’ve not had to replace the Xojo toolbar to be able to hack it.

Again, I have very little experience with Windows, so I can’t make a sound judgement. However my gut tells me that you may want to consider dropping the built-in toolbar and faking it if you want this kind of functionality x-plat.

A couple of declares will do it. I can share them with you if you.

I use them https://www.ohanaware.com/hdr/, so I can place controls in the toolbar area, without being forced to lock them to Apple’s toolbar specifics.