Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setVisible works? #213

Open
x3sp3d3s opened this issue Jan 13, 2015 · 1 comment
Open

setVisible works? #213

x3sp3d3s opened this issue Jan 13, 2015 · 1 comment

Comments

@x3sp3d3s
Copy link

Hi again,

public void setVisible(boolean enabled)

Enable or disable drawing for this zone and its children. This will not disable pick-drawing nor touching. See setPickable( boolean) for and setTouchable( boolean), respectively.

Does it works?? because I use this in my parent zone, and the children remain visible.
Can anybody help me??
THX.

@mshancock
Copy link
Collaborator

This seems to work for me. Here's a code example that demonstrates the expected behaviour (try pressing the Show/Hide buttons to see):

import vialab.SMT.*;

Zone parentZone;
Zone childZone;

boolean parentVisible = true;
boolean childVisible = true;

void setup() {
  size( displayWidth, displayHeight, SMT.RENDERER);
  SMT.init( this, TouchSource.AUTOMATIC);

  // a parent zone
  parentZone = new Zone( "MyZone", 10, 10, 100, 100);
  SMT.add( parentZone);

  // a child zone
  childZone = new Zone("ChildZone", 20, 20, 50, 50);
  parentZone.add(childZone);

  // buttons to toggle visibility
  SMT.add(new ButtonZone("ToggleParent", 200,0,150,60, "Show/Hide Outer"));
  SMT.add(new ButtonZone("ToggleChild", 200,70,150,60, "Show/Hide Inner"));
}

void draw() {
  background( 30);
}

// white parent
void drawMyZone( Zone zone) {
  fill( #ffffff);
  rect( 0, 0, 100, 100);
}

// parent zone can rotate-scale-translate with 2 fingers
void touchMyZone(Zone zone) {
  zone.rst();
}

// green-ish child
void drawChildZone( Zone zone) {
  fill( #88dd88);
  rect( 0, 0, zone.width, zone.height);
}

// child zone can only scale and translate inside
void touchChildZone(Zone zone) {
  zone.rst(false, true, true);
}

// Toggle button behaviour (where set visible happens)
void pressToggleParent() {
  parentVisible = !parentVisible;
  parentZone.setVisible(parentVisible);
}

void pressToggleChild() {
  childVisible = !childVisible;
  childZone.setVisible(childVisible);
}

If something is still not working, perhaps you could share a code snippet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants