LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to customize slider fill Stretch vs reveal

Hi all,

 

I am trying to make my User interface Pretty with some custom sliders.

 

For reasons I don't want to go into, I want a triangular slider that gets wider the higher it goes.

 

The control may end up on a background of any colour so the the classic method of hiding a rectangle behind a triangle won't work.

 

When I import an image of a triangle It "Stretches" as the value increases, I am looking for something more like a reveal:

 

This is how a Graduated Bar works (The lines on the bar are actualy transparent).

 

Slide Empty.pngSlide Full.png

 

Slide try Empty.pngSlide try full.png

 

My attempt above has lost it's transparency and compresses the image as the level changes.

 

Any thoughts, Tricks, suggestions to get around this.

 

I can get around transparency using paint.net instead of ms paint.

iTm - Senior Systems Engineer
uses: LABVIEW 2012 SP1 x86 on Windows 7 x64. cFP, cRIO, PXI-RT
0 Kudos
Message 1 of 9
(4,139 Views)

Hi Timmar,

 

use a (2D) picture indicator to draw the gauge on your own. That way you can draw any shape you want and you can also draw some pictures into the indicator. By drawing a picture you can copy the background image into the picture indicator to make it look like being transparent...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(4,129 Views)

If the issue is only with solid BG colors, then you can still use the hiding method. You just need to set the color of the triangle dynamically.

 

One option is to use a decoration, but getting the reference of a decoration can be annoying.

 

Another option is to use a picture control with a transparent BG and draw the rectangle yourself.

 

A third option is to take a color box and customize it, so that you replace the fill with a triangle (either a decoration or an external image) and then color its BG transparent. If you use a decoration, you will probably need some tricks to hide it properly, because there are no right triangles in LV's decorations. I would suggest a tab control where you disable the auto-grow and then place the color box in such a way that it now you only see the left side of the triangle.


___________________
Try to take over the world!
0 Kudos
Message 3 of 9
(4,116 Views)

Thanks Gerd and tst for the workaround suggestions.

 

I guess I left out a bit more information:

 

 

I need to make the fill colour to be dynamic.

I need it to be easy!

 

I like the 2d picture idea but am reluctant to put the programming time in.

 

I have "lifted" the perfect shape from the Bin slider in the DSC module.

I was hoping that there is a way to "reveal" instead of stretch.

 

The more I investigated, the more I suspect that the LV graphics are setup as layers and that there are a some attributes embedded in the image.

From memory you can embed masks in some images.

 

I tried Gimp and Paint.net but couldn't get enough information.

 

Another thing I observed is that the "graduated bar" slider has a seemingly infinite image.

iTm - Senior Systems Engineer
uses: LABVIEW 2012 SP1 x86 on Windows 7 x64. cFP, cRIO, PXI-RT
0 Kudos
Message 4 of 9
(4,088 Views)

The suggestions would create a dynamic color. You just have to set it in code when the BG changes. Not as easy as not having to do it, but easier than creating it in code using the picture control or creating an external window for the slide, embedding it as a child window and then setting part of it to be transparent, which is the only option that comes to mind to do exactly what you want.

 

If you have a right-angle triangle decoration, then just use it to replace the image of the color in the color box (in the customize mode of the control editor) and make the BG transparent. That's it. There's no need to change the size of the control at run-time.


___________________
Try to take over the world!
0 Kudos
Message 5 of 9
(4,079 Views)

This seemed like an interesting challenge.

 

slider.png

 

 

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 6 of 9
(3,984 Views)

Oops, I tried to edit the previous post to attach an updated VI that could dynamically update the color too but it was incomplete.

The previous VI doesn't have the angle on it (because I forgot to include the angle mask) and it also doesn't appear to go to the top because the control it is using for the image source wasn't set to 100% as the default value.

 

The original simple version used a picture constant but therefore couldn't update the color dynamically.

 

This one does both.

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 7 of 9
(3,973 Views)

Hi

 

My turn to play. I don't know if you want to keep the transparent lines in the triangle or not. Here is my solution, with nearly no code to be implemented to be used.

 

I hope it will help 

Giuliano Franchetto
Student at the l'Ecole Nationale Supérieure des Mines de Saint-Etienne, cycle ISMIN (FRANCE)
0 Kudos
Message 8 of 9
(3,961 Views)

Sorry for the double post

 

i added the possibility to have a single color instead of the rainbow colors.

Giuliano Franchetto
Student at the l'Ecole Nationale Supérieure des Mines de Saint-Etienne, cycle ISMIN (FRANCE)
0 Kudos
Message 9 of 9
(3,954 Views)