G4P, extend control class?

All looks good to me :+1:

I do have a couple of questions about (7)
Can the strokeWeight & corner radius of the visual border be set by the user ? I’m not sure if you can with other G4P Controls ?
I presume that both border and opague bkgrd colours can be set using a user(color)palette.png ?

1 Like

No but it doesn’t mean they can’t be included.

G4P uses colour schemes but you can set individual colours - see the G4P guides on my website

At the moment I am concentrating on the control behaviour methods because they are the most complex algorithms to develop. Methods for controlling attributes which are easy-peasy :grin:

1 Like


Sorry, yes I meant colour schemes, have now found setLocalColor() that should do it.

1 Like

I was thinking about calling the class GControlRibbon rather than GControlPalette, ribbon is more 1D whereas palette suggests 2D arrangement. What do you think?

1 Like

Can kinda see your point with palette inferring 2D, though Ribbon to me doesn’t really give a clue to it’s function of holding other controls.

How about :
Shelf ? (what I was first thinking when trying to build one)
Drawer ? (maybe a bit 2D as well)
Rack ?
Could always have 1D and 2D Palettes ! :grin:

Your library your call really :wink:

1 Like

I will stick with GControlPalette for the moment. The class is written but needs testing, do you want to give it a workout? :smile:

If so you can download an archived sketch which I have been using for basic testing including adding / removing controls on the palette. You can download the sketch by clicking here

Once downloaded it should be unzipped into your sketchbook folder with your other sketches. Restart Processing and the sketch will use the version of G4P included in the downloaded sketch. It will not affect any other sketches because they will use the version you have installed.

Please try it out and see how it performs with other G4P controls.

1 Like

Do you intend to try this control out?

1 Like

Sorry Peter, Had downloaded the sketch in the week, tested the two Palettes in there, which all seem good.
Then intended to try with other controls and get back to you, but life got a bit hectic.
I have time today so will test further.

1 Like

NP just thought you might have missed the message. No rush I am working on numeric input field.

1 Like

What should the palette index for the GControlPalette background color and border color be when using .setLocalColor() ?
I took a guess at the same as GPanel… but doesn’t seem to have any effect.

What is the possible input range for border stroke weight and corner radius ?
I can see that corner radius is working within a small range but I can’t seem to get the border stroke weight to do anyting noticable.

What is the minimum padding value ? I tried to pack btns really close but seems the minimum is maybe around 4 ?

The palette icon: I haven’t really used the new Icons in 4.1 so please excuse any stupid questions in regard to these and I may have confused matters by using the word icon earlier and just meaning an image not an animated icon…so with that out the way.
How should you use a simple image as the tab ‘icon’ on the palette, I bodged in a singleimage .png to the GAnimicon and set nbrRows and nbrCols to 1 and left interval as 100.

1 Like

Border 3
Background 6

Couple of bugs - the radius was pegged at 2 * PADDING and the borderweight fixed at 1

The minimum padding is 2px all round the control but that makes 4px between controls.

Although I have used an animated icon (GAnimIcon) you can use simple static icons with (GIcon). The constructor accepts both GIcon and GAnimIcon

So far so good you have highlighted some issues which I have fixed in the source code.

Let me know how it the palette works with other controls on it.

Thanks for your help :smile:

1 Like

Thanks for the info, I hadn’t looked at GIcon at all…doh!

I have tested with image & imageToggle buttons, GCheckbox, GStick, GSlider2D and GKnob. These all seem to work as intended.

One thing that does not seem to work is a GTogglegroup (could maybe be my mistake) having built a group of 3 GOption, when added to the GPalette they are spaced out indivdually rather than as intended in the group stacked above each other (They should all have had same X pos but each have own Y pos i.e NORTH,CENTER,SOUTH)

What determines the ‘flipover’ point when the Palette tab moves from EAST to WEST ?

Other than the slider thats in your test and the number input field you’re working on I can’t really think of any other controls that I would be likely to put in a palette, I wouldn’t put any other textfields or drop lists in there.
So not bad so far except GToggleGroup possible problem.

1 Like

The GToggleGroup manages exclusive-or selection between GOption controls - so when one is selected it deselects the previous selection. They will work in the NORTH SOUTH orientation but not EW because the controls are stored in a list and are centred about the mid height for EW and mid width for NS alignments.

I will look ate ways round it but not certain yet.

When the GControlPalette the user specifies a preferred orientation. It will use this preferred orientation provided the entire palette can be displayed, otherwise it will show the opposite orientation. If neither is entirely visible then it shows as much or the preferred as possible.

1 Like

Tested and yes works fine :+1:

1 Like

You have not reported any problems with the GContolPalette control so I assume it is OK.

I have been experimenting with different approaches to users entering numeric input and there seems to be two approaches

  1. reject keys which would make the input an invalid number
  2. accept all keys but give a visual indication when the number is invalid

The first approach sounds good but is a nightmare to implement because you can have text which is not a valid number in itself but can become valid with additional input for example

Invalid            Valid
 -                   -2
 +                   +9 
 2.579E            2.579E2
 2.579E-           2.579E-2

Imagine typing in the number -2.579E-2 there are three intermediate invalid number states :unamused:

So the question is what do we do with these invalid inputs and there is no easy solution so I am looking at option (2) which would involve only minor changes to the GTextField class.

Any thoughts?

1 Like

I haven’t found any further problems with GControlPalette, all good thank you :+1:

The Numeric input field does seem to be more complex than I had originally thought.
I think your solution of option 2 may be the best for GControl.

That said, maybe I should try and better describe how I would use such a control and how I’m using my simple hacked up version.

  • No scientific number notation, I have never had to put this notation style in a UI and I haven’t used a UI other than a calculator that implemented it…I’m not really sure how often this notation style is likely to be used ?

  • The control does not need to do maths itself i.e no addition or subtraction calculated whilst inputting numbers… so no need for ‘+’.

  • The controls min and max values are defined at initialisation.

  • Integer or decimal defined at initialisation.

  • The number input field is a square divided into 3 rows, the middle row is the number display area, the top row and lower row are each for a label (see image attached).

  • If the cursor is anywhere over the input field the user may scroll the mouse wheel to increment/decrement the current value.
    My reason for wanting scroll input is that if you have UI that is mostly selecting objects, pressing buttons, dragging sliders,etc… then you come to a number field that only takes key input you probably have to take your hand off the mouse to type, then go back to the mouse to move onto the next button/field…all this chopping/changing slows things down.

  • My bodged version currenlty ignores anything that is not a number;
    if (keyChar >= '0' && keyChar <= '9') { }

The one thing I haven’t done is find a way to deal with keyed input of ‘-’ for negative numbers, that’s just because I haven’t needed to use them as 95% of the UI’s I make are for controlling external hardware that does not take a negative number as an input.

I’m not sure if any of the above helps at all, but hopefully you can see how I would use such a control :grinning:

1 Like

Thanks for the information it is useful to know where you are coming from. We might have been talking at cross purposes, what you are describing is a spinner control that accepts input via keyboard and/or mouse and possibly mouse wheel.

Image showing 3 spinners

and I was thinking in terms of a GTextField that accepts numeric input. :grinning:

1 Like

You could create this from two GLabels and a spinner control.

I will think about the requirements specification and come back to you, but if you have any others thoughts before then just post them here. :smile:

1 Like

Ah yes, a spinner with scrollwheel inc/dec ability, key input and 2 labels would do it! :grin:
Sorry for the confusion.

1 Like

This is a very long discussion so I have created a new topic to try and get some feedback on the new controls.

1 Like