Package react

Examples of react.UnitSlot


        Group buttons = new Group(
            AxisLayout.horizontal(),
            Styles.make(Style.BACKGROUND.is(Background.solid(0xFFFFFFFF).inset(5))));

        for (final String edge : Panel.EDGES) {
            buttons.add(new Button(edge).onClick(new UnitSlot() {
                @Override public void onEmit () {
                    _panel.toggleEdge(edge);
                }
            }));
        }

        buttons.add(new Shim(10, 1)).add(new Button("Toggle Gaps").onClick(new UnitSlot() {
            @Override public void onEmit () {
                setPanel(_panel.useGroups, _panel.gaps == 0 ? 5 : 0);
            }
        }));

        buttons.add(new Shim(10, 1)).add(new Button("Toggle Sizing").onClick(new UnitSlot() {
            @Override public void onEmit () {
                setPanel(!_panel.useGroups, _panel.gaps);
            }
        }));
View Full Code Here


    protected static Button getSizer (SizableGroup g, String text, float dw, float dh) {
        return new Button(text).onClick(getSizer(g.preferredSize, dw, dh));
    }

    protected static UnitSlot getSizer (final DimensionValue base, final float dw, final float dh) {
        return new UnitSlot() {
            @Override public void onEmit () {
                base.update(Math.max(0, base.get().width() + dw),
                            Math.max(0, base.get().height() + dh));
            }
        };
View Full Code Here

    @Override protected Group createIface () {
        final int [] lastTab = {0};
        final Tabs tabs = new Tabs().addStyles(Style.BACKGROUND.is(
            Background.bordered(Colors.WHITE, Colors.BLACK, 1).inset(1)));
        final Button moveRight = new Button("Move Right").onClick(new UnitSlot() {
            @Override public void onEmit () {
                Tabs.Tab tab = tabs.selected.get();
                if (movable(tab)) {
                    tabs.repositionTab(tab, tab.index() + 1);
                }
            }
        }).setEnabled(false);
        final Button hide = new Button("Hide").onClick(new UnitSlot() {
            @Override public void onEmit () {
                Tabs.Tab tab = tabs.selected.get();
                if (tab != null) {
                    tab.setVisible(false);
                }
            }
        }).setEnabled(false);
        tabs.selected.connect(new Slot<Tabs.Tab>() {
            @Override public void onEmit (Tabs.Tab tab) {
                moveRight.setEnabled(movable(tab));
                hide.setEnabled(tab != null);
            }
        });
        return new Group(AxisLayout.vertical().offStretch()).add(
            new Group(AxisLayout.horizontal()).add(
                new Button("Add").onClick(new UnitSlot() {
                    @Override public void onEmit () {
                        String label = _prefix + ++lastTab[0];
                        tabs.add(label, tabContent(label));
                    }
                }),
                new Button("Remove...").onClick(new TabSelector(tabs) {
                    @Override public void handle (Tabs.Tab tab) {
                        tabs.destroyTab(tab);
                    }
                }),
                new Button("Highlight...").onClick(new TabSelector(tabs) {
                    @Override public void handle (Tabs.Tab tab) {
                        tabs.highlighter().highlight(tab, true);
                    }
                }), moveRight, hide, new Button("Show All").onClick(new UnitSlot() {
                    @Override public void onEmit () {
                        for (int ii = 0; ii < tabs.tabCount(); ii++) {
                            tabs.tabAt(ii).setVisible(true);
                        }
                    }
View Full Code Here

        final Content content = new Content();
        final Scroller scroll = new Scroller(content);
        final Label click = new Label();

        // updates the size of the content
        final UnitSlot updateSize = new UnitSlot() {
            @Override public void onEmit () {
                ((Content)scroll.content).preferredSize.update(
                    width.value.get(), height.value.get());
            }
        };
        width.value.connect(updateSize);
        height.value.connect(updateSize);

        // updates the scroll offset
        UnitSlot updatePos = new UnitSlot() {
            @Override public void onEmit () {
                float x = xpos.value.get() * scroll.hrange.max();
                float y = ypos.value.get() * scroll.vrange.max();
                scroll.scroll(x, y);
            }
        };
        xpos.value.connect(updatePos);
        ypos.value.connect(updatePos);

        Button beh = new Button(Behavior.BOTH.name()).onClick(new Slot<Button>() {
            @Override public void onEmit (Button source) {
                Behavior[] behs = Behavior.values();
                Behavior beh = Behavior.valueOf(source.text.get());
                beh = behs[(beh.ordinal() + 1) % behs.length];
                scroll.setBehavior(beh);
                source.text.update(beh.name());
                xpos.setVisible(beh.hasHorizontal());
                ypos.setVisible(beh.hasVertical());
                updateSize.onEmit();
            }
        });

        scroll.contentClicked().connect(new Slot<Pointer.Event>() {
            @Override public void onEmit (Event e) {
                Point pt = Layer.Util.screenToLayer(content.layer, e.x(), e.y());
                click.text.update(pt.x + ", " + pt.y);
            }
        });

        scroll.addListener(new Scroller.Listener() {
            @Override public void viewChanged (IDimension contentSize, IDimension scrollSize) {}
            @Override public void positionChanged (float x, float y) {
                update(xpos, x, scroll.hrange);
                update(ypos, y, scroll.vrange);
            }

            void update (Slider pos, float val, Scroller.Range range) {
                if (range.max() > 0) pos.value.update(val / range.max());
            }
        });

        // background so we can see when the content is smaller
        scroll.addStyles(Style.BACKGROUND.is(Background.solid(Colors.LIGHT_GRAY).inset(10)));

        updatePos.onEmit();
        updateSize.onEmit();

        return new Group(AxisLayout.vertical().offStretch()).add(
            new Group(AxisLayout.horizontal()).add(
                new Label("Size:"), new Shim(15, 1), width, new Label("x"), height, beh),
View Full Code Here

        final Group panel = new Group(new FlowLayout(), Styles.make(Style.BACKGROUND.is(
            Background.bordered(0xFFFFFFFF, 0xff000000, 2).inset(4))));

        Group buttons = new Group(AxisLayout.horizontal());
        for (final ElemType type : ElemType.values()) {
            buttons.add(new Button("Add " + type.toString()).onClick(new UnitSlot() {
                @Override public void onEmit () { panel.add(create(type)); }
            }));
        }
        root.add(buttons);

        buttons = new Group(AxisLayout.horizontal());
        buttons.add(new Label("HAlign:"));
        for (final Style.HAlign halign : Style.HAlign.values()) {
            buttons.add(new Button(halign.toString().substring(0, 1)).onClick(new UnitSlot() {
                @Override public void onEmit () { panel.addStyles(Style.HALIGN.is(halign)); }
            }));
        }

        buttons.add(new Label("VAlign:"));
        for (final Style.VAlign valign : Style.VAlign.values()) {
            buttons.add(new Button(valign.toString().substring(0, 1)).onClick(new UnitSlot() {
                @Override public void onEmit () { panel.addStyles(Style.VALIGN.is(valign)); }
            }));
        }
        root.add(buttons);
View Full Code Here

        }).setDepth(1));
        group.addStyles(Style.BACKGROUND.is(Background.solid(Colors.WHITE)));
        final Group widget = new Group(AxisLayout.horizontal()).addStyles(
            Style.BACKGROUND.is(Background.solid(Colors.CYAN)));
        group.add(widget);
        UnitSlot updateConstraint = new UnitSlot() {
            @Override public void onEmit () {
                widget.setConstraint(new AbsoluteLayout.Constraint(
                    position.point.get(), origin.point.get(),
                    new Dimension(width.value.get(), height.value.get())));
            }
        };
        width.value.connect(updateConstraint);
        height.value.connect(updateConstraint);
        position.point.connect(updateConstraint);
        origin.point.connect(updateConstraint);
        updateConstraint.onEmit();
        return new Group(AxisLayout.vertical().offStretch()).add(
            new Label("Move the sliders to play with the constraint"),
            new Group(AxisLayout.horizontal()).add(position, origin),
            sizeCtrl, group.setConstraint(AxisLayout.stretched()));
    }
View Full Code Here

        float tx = 100 + rando.getFloat(graphics().width()-200);
        float ty = 100 + rando.getFloat(graphics().height()-200);
        explode1.layer.setTranslation(tx, ty);
        explode2.layer.setTranslation(tx, ty);

        explode1.onEmpty.connect(new UnitSlot() {
          @Override public void onEmit () {
            float tx = 100 + rando.getFloat(graphics().width()-200);
            float ty = 100 + rando.getFloat(graphics().height()-200);
            explode1.layer.setTranslation(tx, ty);
            explode2.layer.setTranslation(tx, ty);
View Full Code Here

        public BoxPointWidget (String label) {
            setLayout(AxisLayout.vertical());
            initChildren(new Label(label),
                new Group(AxisLayout.horizontal()).add(new Label("N:"), nx, ny),
                new Group(AxisLayout.horizontal()).add(new Label("O:"), ox, oy));
            UnitSlot update = new UnitSlot() {
                @Override public void onEmit () {
                    point.update(new BoxPoint(
                        nx.value.get(), ny.value.get(), ox.value.get(), oy.value.get()));
                }
            };
View Full Code Here

            top, historyBox.setConstraint(AxisLayout.stretched())).addStyles(
            Style.BACKGROUND.is(Background.blank().inset(5)));
    }

    protected UnitSlot addSome (final HistoryGroup.Labels group, final Field prefix, final int num) {
        return new UnitSlot() {
            @Override public void onEmit () {
                for (int ii = 0; ii < num; ++ii) {
                    group.addItem(prefix.text.get() + String.valueOf(++_lastNum));
                }
            }
View Full Code Here

    }

    protected void addUI (final Screen screen, Elements<?> root, final int depth) {
        root.add(new Label("Screen " + depth));

        root.add(new Button("Slide").onClick(new UnitSlot() { public void onEmit () {
            _stack.push(createScreen(depth+1), _stack.slide());
        }}));
        root.add(new Button("Turn").onClick(new UnitSlot() { public void onEmit () {
            _stack.push(createScreen(depth+1), _stack.pageTurn());
        }}));
        root.add(new Button("Flip").onClick(new UnitSlot() { public void onEmit () {
            _stack.push(createScreen(depth+1), _stack.flip());
        }}));

        if (depth > 0) {
            root.add(new Button("Replace").onClick(new UnitSlot() { public void onEmit () {
                _stack.replace(createScreen(depth+1), _stack.slide().left());
            }}));
            root.add(new Button("Back").onClick(new UnitSlot() { public void onEmit () {
                _stack.remove(screen, _stack.flip().unflip());
            }}));
            root.add(new Button("Top").onClick(new UnitSlot() { public void onEmit () {
                _stack.popTo(ScreensDemo.this, _stack.slide().right());
            }}));
        }
    }
View Full Code Here

TOP

Related Classes of react.UnitSlot

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.