Package tripleplay.ui

Examples of tripleplay.ui.Label


                if ((flags & 2) != 0) g.add(getSizer(g, "H+", 0, 10), getSizer(g, "H-", 0, -10));
                e = g.setConstraint(constraint);

            } else {
                Background colorBg = Background.solid(bgColor).inset(5);
                e = new Label(text).addStyles(Style.BACKGROUND.is(colorBg)).
                    setConstraint(constraint);
            }
            edges.put(text, e);
            return e;
        }
View Full Code Here


    @Override protected Group createIface () {
        Image testBg = PlayN.assets().getImage("images/background.png");

        // Have to do async shenanigans with scale9 backgrounds
        final Label scale9Labels[] = {
            label("Scale 9", Background.blank()),
            label("Scale 9\nSomewhat\nTaller\nAnd\nWider", Background.blank()),
        };
        PlayN.assets().getImage("images/scale9.png").addCallback(new Callback<Image>() {
            public void onSuccess (Image image) {
                for (Label label : scale9Labels) {
                    label.addStyles(Style.BACKGROUND.is(Background.scale9(image).inset(5)));
                }
            }

            public void onFailure (Throwable cause) { }
        });

        return new Group(new TableLayout(3).gaps(5, 5)).add(
            label("Beveled", Background.beveled(0xFFCCFF99, 0xFFEEFFBB, 0xFFAADD77).inset(10)),
            label("Beveled (no inset)", Background.beveled(0xFFCCFF99, 0xFFEEFFBB, 0xFFAADD77)),
            label("Composite", Background.composite(
                Background.solid(Colors.BLUE).inset(5),
                Background.bordered(Colors.WHITE, Colors.BLACK, 2).inset(12),
                Background.image(testBg).inset(5))),
            label("Solid", Background.solid(0xFFCCFF99).inset(10)),
            label("Solid (no inset)", Background.solid(0xFFCCFF99)),
            new Label(),
            label("Null", Background.blank().inset(10)),
            label("Null (no inset)", Background.blank()),
            new Label(),
            label("Image", Background.image(testBg).inset(10)),
            label("Image (no inset)", Background.image(testBg)),
            new Label(),
            scale9Labels[0],
            scale9Labels[1],
            new Label(),
            label("Bordered (inset 10)", Background.bordered(0xFFEEEEEE, 0xFFFFFF00, 2).inset(10)),
            label("Bordered (inset 2)", Background.bordered(0xFFEEEEEE, 0xFFFFFF00, 2).inset(2)),
            label("Bordered (no inset)", Background.bordered(0xFFEEEEEE, 0xFFFFFF00, 2)),
            label("Round rect", Background.roundRect(0xFFEEEEEE, 10, 0xFFFFFF00, 5).inset(10)),
            label("Round rect (no inset)", Background.roundRect(0xFFEEEEEE, 10, 0xFFFFFF00, 5)),
View Full Code Here

            label("Round rect (no inset)", Background.roundRect(0xFFEEEEEE, 10, 0xFFFFFF00, 5)),
            label("Round rect (no border)", Background.roundRect(0xFFEEEEEE, 10).inset(10)));
    }

    protected Label label (String text, Background bg) {
        return new Label(text).addStyles(Style.HALIGN.center, Style.BACKGROUND.is(bg),
            Style.TEXT_WRAP.on);
    }
View Full Code Here

        String font = Style.FONT.getDefault(main).name();
        Style.Binding<Font> hdr = Style.FONT.is(graphics().createFont(font, Font.Style.BOLD, 14));
        main.setStylesheet(Stylesheet.builder().add(Label.class,
            Style.FONT.is(graphics().createFont(font, Font.Style.PLAIN, 12))).create());

        main.add(new Label("Simple").addStyles(hdr));
        main.add(new Label("A single parent with buttons - at most one is selected."));
        main.add(buttons = new Group(AxisLayout.horizontal()).add(
            mkButt("A"), mkButt("B"), mkButt("C")));
        sel = new Selector(buttons, buttons.childAt(0));
        main.add(hookup("Selection:", sel));
        main.add(new Shim(10, 10));

        main.add(new Label("Mixed").addStyles(hdr));
        main.add(new Label("A single parent with two groups - one from each may be selected."));
        main.add(buttons = new Group(AxisLayout.horizontal()).add(
            mkButt("Alvin"), mkButt("Simon"), mkButt("Theodore"),
            mkButt("Alpha"), mkButt("Sigma"), mkButt("Theta")));
        sel = new Selector().add(buttons.childAt(0), buttons.childAt(1), buttons.childAt(2));
        main.add(hookup("Chipmunk:", sel));
        sel = new Selector().add(buttons.childAt(3), buttons.childAt(4), buttons.childAt(5));
        main.add(hookup("Greek Letter:", sel));
        main.add(new Shim(10, 10));

        Style.Binding<Background> box = Style.BACKGROUND.is(
            Background.bordered(0xffffffff, 0xff000000, 1).inset(5));
        main.add(new Label("Multiple parents").addStyles(hdr));
        main.add(new Label("At most one button may be selected."));
        main.add(buttons = new Group(AxisLayout.horizontal()).add(
            new Group(AxisLayout.vertical(), box).add(mkButt("R1C1"), mkButt("R2C1")),
            new Group(AxisLayout.vertical(), box).add(mkButt("R1C2"), mkButt("R2C2"))));
        sel = new Selector().add((Group)buttons.childAt(0)).add((Group)buttons.childAt(1));
        main.add(hookup("Selection:", sel));
View Full Code Here

        return main;
    }

    protected Group hookup (String name, Selector sel) {
        final Label label = new Label();
        sel.selected.connect(new Slot<Element<?>>() {
            @Override public void onEmit (Element<?> event) {
                update(label, (ToggleButton)event);
            }
        });
        update(label, (ToggleButton)sel.selected.get());
        return new Group(AxisLayout.horizontal()).add(new Label(name), label);
    }
View Full Code Here

        Styles bigLabel = Styles.make(
            Style.FONT.is(PlayN.graphics().createFont("Times New Roman", Font.Style.PLAIN, 32)),
            Style.HALIGN.center);
        return new Group(AxisLayout.vertical()).add(
            new Shim(15, 15),
            new Label("Wrapped text").addStyles(Style.HALIGN.center),
            new Group(AxisLayout.horizontal(), greenBg.add(Style.VALIGN.top)).add(
                AxisLayout.stretch(new Label(TEXT1, smiley).addStyles(
                                       Style.TEXT_WRAP.is(true), Style.HALIGN.left,
                                       Style.ICON_GAP.is(5))),
                AxisLayout.stretch(new Label(TEXT2).addStyles(
                                       Style.TEXT_WRAP.is(true), Style.HALIGN.center)),
                AxisLayout.stretch(new Label(TEXT3).addStyles(
                                       Style.TEXT_WRAP.is(true), Style.HALIGN.right))),
            new Shim(15, 15),
            new Label("Styled text").addStyles(Style.HALIGN.center),
            new Group(AxisLayout.horizontal().gap(10)).add(
                new Label("Plain").addStyles(bigLabel),
                new Label("Pixel Outline").addStyles(
                                       bigLabel.add(Style.TEXT_EFFECT.pixelOutline).
                                       add(Style.COLOR.is(Colors.WHITE)).
                                       add(Style.HIGHLIGHT.is(Colors.GRAY))),
                new Label("Vector Outline").addStyles(
                                       bigLabel.add(Style.TEXT_EFFECT.vectorOutline,
                                                    Style.OUTLINE_WIDTH.is(2f))),
                new Label("Shadow").addStyles(
                                       bigLabel.add(Style.TEXT_EFFECT.shadow))),
            new Label("Underlining").addStyles(Style.HALIGN.center),
            new Group(AxisLayout.horizontal().gap(10)).add(
                new Label("Plain").addStyles(smallUnderlined),
                new Label("gjpqy").addStyles(smallUnderlined),
                new Label("Pixel Outline").addStyles(
                                       smallUnderlined.add(Style.TEXT_EFFECT.pixelOutline)),
                new Label("gjpqy").addStyles(
                                       smallUnderlined.add(Style.TEXT_EFFECT.pixelOutline))),
            new Group(AxisLayout.horizontal().gap(10)).add(
                new Label("Vector Outline").addStyles(
                                       smallUnderlined.add(Style.TEXT_EFFECT.vectorOutline,
                                                           Style.OUTLINE_WIDTH.is(2f))),
                new Label("gjpqy").addStyles(
                                       smallUnderlined.add(Style.TEXT_EFFECT.vectorOutline,
                                                           Style.OUTLINE_WIDTH.is(2f))),
                new Label("Shadow").addStyles(
                                       smallUnderlined.add(Style.TEXT_EFFECT.shadow)),
                new Label("gjpqy").addStyles(
                                       smallUnderlined.add(Style.TEXT_EFFECT.shadow))));
    }
View Full Code Here

        return Color.rgb(128 + _rnd.nextInt(127), 128 + _rnd.nextInt(127), 128 + _rnd.nextInt(127));
    }

    protected Group tabContent (String label) {
        return new Group(AxisLayout.vertical().offStretch().stretchByDefault()).add(
            new Label(label).addStyles(Style.BACKGROUND.is(Background.solid(randColor()))));
    }
View Full Code Here

        Styles greyBg = Styles.make(Style.BACKGROUND.is(Background.solid(0xFFCCCCCC).inset(5)));
        Styles greenBg = Styles.make(Style.BACKGROUND.is(Background.solid(0xFFCCFF99).inset(5)));

        Group iface = new Group(AxisLayout.vertical().offStretch()).add(
            new Shim(15, 15),
            new Label("Table Layout"),
            new Group(main, greyBg).add(
                new Label("This column is stretched"),
                new Label("This column is not"),

                new Group(new TableLayout(COL, COL).gaps(5, 5), greenBg).add(
                    new Label("Upper left"), new Label("Upper right"),
                    new Label("Lower left"), new Label("Lower right")),

                new Group(alignDemo, greenBg).add(
                    new Button("Foo"),
                    new Button("Bar"),
                    new Button("Baz"),
                    new Button("Foozle"),
                    new Button("Barzle"),
                    new Button("Bazzle")),

                new Group(fixedDemo, greenBg).add(
                    new Button("Fixed"),
                    new Button("Free"),
                    new Button("Stretch+free"),
                    new Button("Fixed"),
                    new Button("Free"),
                    new Button("Stretch+free")),

                new Group(minWidthDemo, greenBg).add(
                    new Button("Min"),
                    new Button("M+stretch"),
                    new Button("Free"),
                    new Button("Min"),
                    new Button("M+stretch"),
                    new Button("Free"))),

            new Shim(15, 15),
            new Label("Absolute Layout"),
            new Group(new AbsoluteLayout(), greyBg).add(
                AbsoluteLayout.at(new Label("+50+20"), 50, 20),
                AbsoluteLayout.at(new Button("150x35+150+50"), 150, 50, 150, 35)));

        return iface;
    }
View Full Code Here

        _root.addStyles(Style.BACKGROUND.is(background()), Style.VALIGN.top);
        _root.setSize(width(), height());
        Background bg = Background.solid(0xFFCC99FF).inset(0, 0, 5, 0);
        _root.add(new Group(AxisLayout.horizontal(), Style.HALIGN.left, Style.BACKGROUND.is(bg)).add(
                      this.back = new Button("Back"),
                      new Label(title()).addStyles(Style.FONT.is(TITLE_FONT), Style.HALIGN.center).
                      setConstraint(AxisLayout.stretched())));
        if (subtitle() != null) _root.add(new Label(subtitle()));
        Group iface = createIface();
        if (iface != null) _root.add(iface.setConstraint(AxisLayout.stretched()));
    }
View Full Code Here

        final Slider height = new Slider(100, 100, 5000);
        final Slider xpos = new Slider(0, 0, 1);
        final Slider ypos = new Slider(0, 0, 1);
        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),
            new Group(AxisLayout.horizontal()).add(
                new Label("Pos:"), new Shim(15, 1), xpos, ypos),
            new Group(AxisLayout.horizontal()).add(
                new Label("Click:"), new Shim(15, 1), click),
            new Group(AxisLayout.horizontal().offStretch()).setConstraint(AxisLayout.stretched()).
                add(scroll.setConstraint(AxisLayout.stretched())));
    }
View Full Code Here

TOP

Related Classes of tripleplay.ui.Label

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.