by majortom
GUI system can become very robust if you want to include all kinds of controls like: buttons, sliders, counters, knobs, etc. Specially if you want to control different types of data like: Values, Colors, Strings... I have tried that and very soon I have found myself in a serious mess. I had a lot of subpatches connecting to all other and number of feedback connections forming crazy loops that soon enough rendered my patch unreadable. There was only one way out: Ctrl-A and Delete.
To start clean I deviced several rules for working GUI:
I have patched some modules for preview of the system. I tried to follow the rules but some modules are not so strict yet. Since this is an open project, you are welcomed to contribute on vvvvorum.
To start, download this patch (open TRY_GUI_modular.v4p):
http://www.vvvv.org/tiki-download_file.php?fileId=1201TRY_GUI_modular.zip (103.93 Kb)</a>
Several things to note about this patch:
Updates:
(Some definitions to follow while patching all modules.)
The core of the system is GUI CS module with its inputs and outputs. The structure of the input and output spreads should be defined in a certain way all other modules could follow.
Internaly, GUI CS takes care of controls' properties and slice counts.
| ~~#ddd:.............................~~ | ~~#ddd:...............~~ | ~~#ddd:...............~~ | ~~#ddd:..........................................................................~~ | |
| Pin (Data) | ::Count:: | ::Type:: | description |
| Input Data | ::n*3:: | Value | ::float:: | control value Count |
::integer:: | spread count Update |
::bool:: | forcing update of control value ~~#ddd:.............................~~ |
~~#ddd:...............~~ | ~~#ddd:...............~~ | ~~#ddd:..........................................................................~~ |
n is total number of controls. Each control would take 3 slices in Input Data spread: value of current slice, total spread count and update flag. Update flag would bang '1' each time control value should be updated - for example when slice index changes.
According to order in the spread, each control will have its unique index - refered to as Control CH (Control channel) later in this text.
| ~~#ddd:.............................~~ | ~~#ddd:...............~~ | ~~#ddd:...............~~ | ~~#ddd:..........................................................................~~ | |
| Pin (Data) | ::Count:: | ::Type:: | description |
| CTRL In | ::c:: | Value | ::float:: | output of controller modules ~~#ddd:.............................~~ |
~~#ddd:...............~~ | ~~#ddd:...............~~ | ~~#ddd:..........................................................................~~ |
c is total number of controller channels.
MouseCTRL module could map mouse_x, mouse_y, mousewheel, leftbutton and mouse_y offset to five different channels.
Controller channel will be refered to as CTRL CH later in this text.
| ~~#ddd:.............................~~ | ~~#ddd:...............~~ | ~~#ddd:...............~~ | ~~#ddd:..........................................................................~~ | |
| Pin (Data) | ::Count:: | ::Type:: | description |
| Map | ::var*3:: | CTRL CH | ::integer:: | Control CH | ::integer:: | Data | ::enum:: | (Value, Slice) |
Focus |
::n:: | ::bool:: | ~~#ddd:.............................~~ | ~~#ddd:...............~~ | ~~#ddd:...............~~ | ~~#ddd:..........................................................................~~ |
The map describes which control is listening to which CTRL CH and also sets if either control value or slice index shoud be controlled.
The map changes dinamicaly and it has variable (var) number of entries.
If we want to do something like in the basic concept patch, HoverCTRL module would listen certain CTRL CHs for mouse position and append one mapping for mousewheel (Slice) and one for mouse_y offset (Value) when leftbutton is pressed, both binding CTRL CHs to the same Control CH of control in focus.
Controlling several controls at once can also be achieved through mapping (to change slice index for grouped controls like vectors or colors), but this should also be possible using other modules on the output side as well.
Focus spread is normaly recieved from Hover controllers and copied to Control Data spreads. GUI CS module doesn't care about focus.
CTRL/Control Map can also hold default mappings, if for example we want to set one CTRL CH to change slice indices for all controls. This would be done by setting the Control CH to -1. Separate Mapping module should be used for more complex GUI setups.
Output Value is just a spread of float values with n slices - one for each control.
| ~~#ddd:.............................~~ | ~~#ddd:...............~~ | ~~#ddd:...............~~ | ~~#ddd:..........................................................................~~ | |
| Pin (Data) | ::Count:: | ::Type:: | description |
| Control Out | ::n*3:: | Control Value | ::float:: | Output Value * Ratio Focus |
::bool:: | is in focus? Bound |
::bool:: | is value controlled?
CH Data |
::n*2:: | Count | ::Integer:: | Slice | ::Integer:: | ~~#ddd:.............................~~ | ~~#ddd:...............~~ | ~~#ddd:...............~~ | ~~#ddd:..........................................................................~~ |
Control Data streams are used as inputs for display and other output modules. Ratio is control property.
| ~~#ddd:.............................~~ | ~~#ddd:...............~~ | ~~#ddd:...............~~ | ~~#ddd:..........................................................................~~ | |
| Pin (Data) | ::Count:: | ::Type:: | description |
| I/O Control | ::n*2:: | Output Value | ::float:: | Slice | ::integer:: | ~~#ddd:.............................~~ | ~~#ddd:...............~~ | ~~#ddd:...............~~ | ~~#ddd:..........................................................................~~ |
I/O Control Data spread is used to control input modules (like SpreadControl module)
There are several properties that should be set for each control.
| ~~#ddd:.............................~~ | ~~#ddd:...............~~ | ~~#ddd:...............~~ | ~~#ddd:..........................................................................~~ | |
| Pin (Data) | ::Count:: | ::Type:: | description |
| Type | ::n:: | ::enum:: | (Copy, Slide, Push-Pull, Toggle, Bang) Bounds |
::n*2:: | Min | ::float:: | Max | ::float:: | Behaviour | ::n:: | ::enum:: | (Float, Wrap, Mirror, Clamp) Ratio |
::n:: | ::float:: | Ratio between Output Value and Control Value ~~#ddd:.............................~~ |
~~#ddd:...............~~ | ~~#ddd:...............~~ | ~~#ddd:..........................................................................~~ |
For more complex GUI systems we could use separate module that would allow us to set default properties for groups of controls and tune or override some properties for certain controls.
SpreadControl module grants control to GUI CS module over choosen slice from input spread and stores all changes in output spread.
| ~~#ddd:.............................~~ | ~~#ddd:...............~~ | ~~#ddd:...............~~ | ~~#ddd:..........................................................................~~ | |
| Pin (Data) | ::Count:: | ::Type:: | description |
| Input | ::var:: | ::float:: | Input spread
Input Data |
::n*3:: | n: number of Control channels Value |
::float:: | control value Count |
::integer:: | spread count Update |
::bool:: | forcing update of control value
I/O Control |
::n*2:: | (from GUI CS module) Output Value |
::float:: | Slice | ::integer:: |
Reset |
::1:: | ::bool:: | resets output to input values
Control CH |
::1:: | ::integer:: | existing Control channel to use ~~#ddd:.............................~~ |
~~#ddd:...............~~ | ~~#ddd:...............~~ | ~~#ddd:..........................................................................~~ |
| ~~#ddd:.............................~~ | ~~#ddd:...............~~ | ~~#ddd:...............~~ | ~~#ddd:..........................................................................~~ | |
| Pin (Data) | ::Count:: | ::Type:: | description |
| Input Data | ::n*3:: | Value | ::float:: | control value Count |
::integer:: | spread count Update |
::bool:: | forcing update of control value
I/O Control |
::n*2:: | copy of input pin Output Value |
::float:: | Slice | ::integer:: |
Reset |
::1:: | ::bool:: | copy of input pin
Slice |
::1:: | ::integer:: | current slice
Output |
::var:: | ::float:: | Output spread ~~#ddd:.............................~~ |
~~#ddd:...............~~ | ~~#ddd:...............~~ | ~~#ddd:..........................................................................~~ |
Input Data pin connects to the next input module or to GUI CS module. Data of choosen Control CH are changed.
...under construction ...
Controller modules send controller output values to CTRL stream.
| ~~#ddd:.............................~~ | ~~#ddd:...............~~ | ~~#ddd:...............~~ | ~~#ddd:..........................................................................~~ | |
| Pin (Data) | ::Count:: | ::Type:: | description |
| CTRL In | ::var:: | ::float:: | CTRL spread
Ratio |
::var:: | ::float:: |
CTRL CH |
::var:: | ::integer:: | one or more channels to use ~~#ddd:.............................~~ |
~~#ddd:...............~~ | ~~#ddd:...............~~ | ~~#ddd:..........................................................................~~ |
...and other controller specific input pins like MIDI channel, mouse_x, etc.
Outputs
| ~~#ddd:.............................~~ | ~~#ddd:...............~~ | ~~#ddd:...............~~ | ~~#ddd:..........................................................................~~ | |
| Pin (Data) | ::Count:: | ::Type:: | description |
| CTRL Out | ::var:: | ::float:: | CTRL spread ~~#ddd:.............................~~ |
~~#ddd:...............~~ | ~~#ddd:...............~~ | ~~#ddd:..........................................................................~~ |
Feel free to use this template for new controller modules:http://www.vvvv.org/tiki-download_file.php?fileId=1228TemplateCTRL.v4p (6.28 Kb)</a>
http://www.vvvv.org/tiki-download_file.php?fileId=1229MouseGlobalCTRL.v4p (9.44 Kb)</a>
http://www.vvvv.org/tiki-download_file.php?fileId=1230MouseWindowCTRL.v4p (8.94 Kb)</a>
anonymous user login
~8h ago
~8h ago
~8h ago
~10h ago
~10h ago
~10h ago
~13h ago
~13h ago
~15h ago