File > Examples > Contributed Libraries > ControlP5 > controllers > ControlP5tab
I think moveTo will only place the controller in a single tab, so to have a controller in multiple tabs but not all tabs would require some manual tweaking. The idea you mention and don't want to use, seems a sensible workaround. Of course the downside is that you have to specify whether or not a controller is visible for each single tab, but on the upside: it works. Perhaps andreas can come up with a better way, but for future reference let me just post the multi-tab method here...
Proof-of-concept
- import controlP5.*;
- ControlP5 cp5;
-
- void setup() {
- size(700, 400);
- cp5 = new ControlP5(this);
-
- cp5.addTab("tab_ONE");
- cp5.addTab("tab_TWO");
- cp5.addTab("tab_THREE");
- cp5.addTab("tab_FOUR");
-
- cp5.getTab("tab_ONE").activateEvent(true).setId(1);
- cp5.getTab("tab_TWO").activateEvent(true).setId(2);
- cp5.getTab("tab_THREE").activateEvent(true).setId(3);
- cp5.getTab("tab_FOUR").activateEvent(true).setId(4);
-
- cp5.addSlider("sliderValue").setPosition(100, 100).setSize(500, 200).moveTo("global");
- }
-
- void draw() {
- background(255);
- }
-
- void controlEvent(ControlEvent theControlEvent) {
- if (theControlEvent.isTab()) {
- showMultiTabControllers( theControlEvent.getTab().getId() );
- }
- }
-
- void showMultiTabControllers(int selectedTab) {
- switch(selectedTab) {
- case 0: cp5.getController("sliderValue").show(); break;
- case 1: cp5.getController("sliderValue").hide(); break;
- case 2: cp5.getController("sliderValue").show(); break;
- case 3: cp5.getController("sliderValue").hide(); break;
- case 4: cp5.getController("sliderValue").show(); break;
- }
- }