use of spacegraph.space2d.Surface in project narchy by automenta.
the class MutableContainer method set.
/**
* returns the existing value that was replaced
*/
public Surface set(int index, Surface next) {
Surface existing;
synchronized (children) {
if (children.size() - 1 < index)
throw new RuntimeException("index out of bounds");
existing = get(index);
if (existing != next) {
existing.stop();
children.set(index, next);
if (this.parent != null)
next.start(this);
}
}
layout();
return existing;
}
use of spacegraph.space2d.Surface in project narchy by automenta.
the class Splitting method doLayout.
@Override
public void doLayout(int dtMS) {
if (!vertical)
throw new TODO();
float X = x();
float Y = y();
float h = h();
float w = w();
float Ysplit = Y + split * h;
Surface top = T();
if (top != null) {
top.pos(X, Ysplit, X + w, Y + h);
}
Surface bottom = B();
if (bottom != null) {
bottom.pos(X, Y, X + w, Ysplit);
}
super.doLayout(dtMS);
}
use of spacegraph.space2d.Surface in project narchy by automenta.
the class Switching method state.
/**
* selects the active state
*/
public Switching state(int next) {
synchronized (this) {
if (switched == next)
return this;
Surface prevSurface = this.current;
Surface nextSurface = (current = (states[switched = next].get()));
if (prevSurface != null)
prevSurface.stop();
if (parent != null) {
nextSurface.start(this);
}
}
layout();
return this;
}
use of spacegraph.space2d.Surface in project narchy by automenta.
the class Windo method onTouch.
@Override
public Surface onTouch(Finger finger, short[] buttons) {
if (dragMode != null && dragMode.isStopped()) {
// System.out.println(this + " dragMode " + dragMode + " stopped");
dragMode = null;
}
Surface other = null;
if (/*dragMode==null && */
finger != null) {
Surface c = super.onTouch(finger, buttons);
other = c;
// if (!fingerable() || fingeringWindow(c)) {
// // this.dragMode = null;
// // this.potentialDragMode = null;
// other = c; //something else or a child inside of the content
// }
}
if (other != null && other != this) {
this.dragMode = null;
this.potentialDragMode = null;
this.hover = false;
return other;
} else if (finger == null || !fingeringBounds(finger)) {
this.dragMode = null;
this.potentialDragMode = null;
this.hover = false;
return null;
} else {
DragEdit potentialDragMode = null;
// if (moveable()) System.out.println(bounds + "\thit=" + finger.hit + "\thitGlobal=" + finger.hitGlobal);
v2 hitPoint = windowHitPointRel(finger);
this.hover = true;
// if (dragMode == null && !finger.prevButtonDown[ZoomOrtho.PAN_BUTTON] /* && hitPoint.x >= 0 && hitPoint.y >= 0 && hitPoint.x <= 1f && hitPoint.y <= 1f*/) {
{
if (potentialDragMode == null && hitPoint.x >= 0.5f - resizeBorder / 2f && hitPoint.x <= 0.5f + resizeBorder / 2) {
if (potentialDragMode == null && hitPoint.y <= resizeBorder) {
potentialDragMode = DragEdit.RESIZE_S;
}
if (potentialDragMode == null && hitPoint.y >= 1f - resizeBorder) {
potentialDragMode = DragEdit.RESIZE_N;
}
}
if (potentialDragMode == null && hitPoint.y >= 0.5f - resizeBorder / 2f && hitPoint.y <= 0.5f + resizeBorder / 2) {
if (potentialDragMode == null && hitPoint.x <= resizeBorder) {
potentialDragMode = DragEdit.RESIZE_W;
}
if (potentialDragMode == null && hitPoint.x >= 1f - resizeBorder) {
potentialDragMode = DragEdit.RESIZE_E;
}
}
if (potentialDragMode == null && hitPoint.x <= resizeBorder) {
if (potentialDragMode == null && hitPoint.y <= resizeBorder) {
potentialDragMode = DragEdit.RESIZE_SW;
}
if (potentialDragMode == null && hitPoint.y >= 1f - resizeBorder) {
potentialDragMode = DragEdit.RESIZE_NW;
}
}
if (potentialDragMode == null && hitPoint.x >= 1f - resizeBorder) {
if (potentialDragMode == null && hitPoint.y <= resizeBorder) {
potentialDragMode = DragEdit.RESIZE_SE;
}
if (potentialDragMode == null && hitPoint.y >= 1f - resizeBorder) {
potentialDragMode = DragEdit.RESIZE_NE;
}
}
if (!fingerable(potentialDragMode))
potentialDragMode = null;
if (potentialDragMode == null) {
if (fingerable(MOVE))
potentialDragMode = MOVE;
}
}
// System.out.println(this + " POTENTIAL " + potentialDragMode);
this.potentialDragMode = potentialDragMode;
if (buttons != null && buttons.length > 0 && buttons[ZoomOrtho.PAN_BUTTON] == 1) {
// actual drag mode enabled
FingerDragging d = potentialDragMode != null ? (FingerDragging) fingering(potentialDragMode) : null;
if (d != null && finger.tryFingering(d)) {
// System.out.println(this + " ON " + d);
this.dragMode = d;
} else {
this.dragMode = null;
}
}
return null;
}
}
use of spacegraph.space2d.Surface in project narchy by automenta.
the class AutoSurface method start.
@Override
public void start(@Nullable SurfaceBase parent) {
synchronized (this) {
seen.clear();
ons = new Ons();
List<Surface> l = new FasterList();
collect(obj, l, 0);
super.start(parent);
set(l);
}
}
Aggregations