Search in sources :

Example 6 with Surface

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;
}
Also used : Surface(spacegraph.space2d.Surface)

Example 7 with Surface

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);
}
Also used : TODO(jcog.TODO) Surface(spacegraph.space2d.Surface)

Example 8 with Surface

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;
}
Also used : Surface(spacegraph.space2d.Surface)

Example 9 with Surface

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;
    }
}
Also used : spacegraph.util.math.v2(spacegraph.util.math.v2) Surface(spacegraph.space2d.Surface)

Example 10 with Surface

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);
    }
}
Also used : Ons(jcog.event.Ons) FasterList(jcog.list.FasterList) Surface(spacegraph.space2d.Surface)

Aggregations

Surface (spacegraph.space2d.Surface)24 Util (jcog.Util)7 GL2 (com.jogamp.opengl.GL2)5 Gridding (spacegraph.space2d.container.Gridding)5 List (java.util.List)4 FasterList (jcog.list.FasterList)4 Label (spacegraph.space2d.widget.text.Label)4 spacegraph.util.math.v2 (spacegraph.util.math.v2)4 Draw (spacegraph.video.Draw)4 Function (java.util.function.Function)3 IntStream (java.util.stream.IntStream)3 RectFloat2D (jcog.tree.rtree.rect.RectFloat2D)3 CheckBox (spacegraph.space2d.widget.button.CheckBox)3 AutoSurface (spacegraph.space2d.widget.meta.AutoSurface)3 LoopPanel (spacegraph.space2d.widget.meta.LoopPanel)3 java.awt (java.awt)2 Collectors (java.util.stream.Collectors)2 TODO (jcog.TODO)2 MapNodeGraph (jcog.data.graph.MapNodeGraph)2 NodeGraph (jcog.data.graph.NodeGraph)2