UI Interest Group Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

Unusual shaped controls

AnneC asked here...

Hi - Is there any way to build controls with unusual shapes?  For example, if I try to make a custom control with a nice curvy swoosh, I can import the graphic onto the control, but the outline of the control remains the original shape, for example a square, and if the user clicks anywhere in the square it reacts - I would like the user to only be able to click in the curvy shape.  Perhaps I've missed an option for building controls?  Or is this not possible in Labview?  Thanks!

This document was generated from the following discussion: Unusual shaped controls


There is a way to build a control with an unusual shape but it is quite difficult. See attached for an example of an 'S' shaped control that works the way you want it to.

curvycontrol.png

LabVIEW doesn't really allow you to do it easily as you have discovered. You haven't missed an option, it just isn't there...yet!

Start with a classic flat square button and open it in the control editor (Right-click > Advanced > Customize)

Import and paste an image of how you want the control to look then move it to the back.

Change to customize mode by clicking the little spanner symbol.

Now add a bunch of flat decorations from the modern/decorations palette.

Use different shapes and move and resize them till you cover all the 'active' regions but none of the 'inactive' regions.

S shape example:

Sdecor.png

Because the shapes are vector graphics from the decoration palette only the vector shape region will be active, not the rectangular extremities.

Now delete the background image and make all the shapes invisible. You now have an invisible control in the shape you want.

Close the control editor and return to the Front Panel.

Insert a classic picture ring and load it with all the actual images of the control you want to use, then make the ring control part invisible.

Disable the picture ring (Right-click > Advanced > Enabled State > Disable). It is for display purposes only, you don't actually want the user to be able to click on it.

Now move the invisible control over the picture ring.

To make the control and picture ring work together as though it is one control you need to use events to change the image displayed by the picture ring depending on the user interaction.

I have attached a basic example to demonstrate this (curvy control.vi).

I have now attached another example that shows how this concept works well with controls that would have overlapping boundaries. (YinYang.vi)

If you want to be able to create fancy controls like this easily, LabVIEW needs to support using vector images as control images.

Vector image controls already exist in LabVIEW, such as the modern toggle control, but you can't make them yourself.

Vote for this idea in the NI Idea Exchange.

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
Download All
Comments
Laurens_
Member
Member
on

Hi AnneC & TroyK,

An other way to approach this is by looking at the pixel values.

This is more precise and it is easily reproduced when there are multiple controls like this.

Because it is paced in the a User Event I don't think it is very CPU consuming, but did not check this.

See attached file (LV 2011). Hummm, wanted to attach the VI for the code, but can not find the attach file button here... sorry.

Snippet results in broken arrow, you will have to do with an image for now.


Cheerz, Laurens

Curvy solution.PNG

zou
Trusted Enthusiast
Trusted Enthusiast
on

 Yin & Yang are NOT an unusual shape if you know how to draw it. Smiley Happy

It can be created with a combination of circular buttons.

See my implementation of Yin Yang in my NI Week 2018 demo:

Leveraging the Windows API to Extend LabVIEW GUI Capabilities

 

George Zou
Contributors