G4P, extend control class?

Just a quick question, assume we have a GControlPalette control. with an icon[I] and three controls A, B and C and the preferred side is EAST, then when the mouse is over the icon we will get something like

[I](A B C)

Now if we change the side to WEST, perhaps because we have dragged the icon too close to the right side then we have two options

(A B C)[I] or (C B A )[I]

The same argument also applies to NORTH and SOUTH

I have a personal preference but I would like to know what you think before I make a decision.

1 Like

For me it would be
(C B A)[I]
As I would likely organise the controls so that the most used was always closest to the icon.

1 Like

Glad to see we are in agreement :wink:

1 Like

I have made some changes to the user requirements and incorporated your ideas and I have renamed the panel part as the palette part

Requirements specification for the GControlPalette

  1. This control would represent a rectangular area containing 1 or more G4P controls
  2. The control will have two principal parts, the tab and the palette.
  3. The controls would laid out either horizontally or vertically on the palette
  4. The palette will only be visible when the control is active
  5. The control is activated when the mouse passes over the tab part
  6. The control remains active (visible palette) while the mouse is over the tab or palette
  7. When visible the palette part will have a visual border and an optional opaque background
  8. The tab would be a small rectangular area containing an icon. Its size would be the same as image.
  9. The user can set the preferred side of the tab for the palette to appear. This preferred position would be used unless it means that part of the panel is off window.
  10. The control can be moved by dragging the tab
  11. The user can lock the controls position at any time to prevent dragging
  12. The palette size will be determined by the size of the controls added
  13. No provision will be made if the control’s width and/or height exceed the window’s width and/or height e.g. the window has been resized or too many controls have been added.
  14. The order controls on the palette is determined by the user and will be displayed radially starting from the tab.
1 Like

This video shows where I am upto with the development

3 Likes

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

:+1:

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