Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

ControlP5 Tabs Container for Non-ControlP5 objects

$
0
0

I tried using the solution given to a similar question years ago. However, when i tried using it a "The type new ControllerView(sketch) must implement the inherent abstract method at Line 20. I tried searching the net but unable to find one that is related to processing... What I want to achieve is add an image and headers inside my Controlp5 tabs.

Here is the code from sojamo : https://forum.processing.org/two/discussion/1380/controlp5-tabs

import controlP5.*;

// using processing 2.0, ControlP5 2.0.4

ControlP5 cp5;

PFont f1;

void setup() {
  size(400, 400);
  f1 = createFont("Helvetica" , 20);
  cp5 = new ControlP5(this);
  cp5.addTab("extra");
  Container c = new Container(cp5, "hello");
  c.setPosition(100, 100).moveTo("extra");

  // give controller hello a custom view - just draw
  // a white rectangle and a bit of text for a start.

  c.setView( new ControllerView<Container>() {
    public void display(PApplet p, Container o) {
      p.fill(255);
      p.rect(0, 0, random(100) + 100, 40);
      p.textFont(f1);
      p.text("Hello World" , 0 , 60);
    }
  }
  );
}


void draw() {
  background( 40 );
}

// an empty container controller
class Container extends Controller<Container> {
  Container(ControlP5 c, String theName) {
    super( c, theName, 0, 0, 0, 0 );
    c.register( null, theName, this );
  }
}

Cheers!


Viewing all articles
Browse latest Browse all 2896

Trending Articles