Package tripleplay.ui.layout

Examples of tripleplay.ui.layout.TableLayout$Column


            }

            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),
View Full Code Here


    @Override protected String title () {
        return "UI: Various Layouts";
    }

    @Override protected Group createIface () {
        TableLayout main = new TableLayout(COL.stretch(), COL).gaps(15, 15);
        TableLayout alignDemo = new TableLayout(
            COL.alignLeft(), COL.alignRight(), COL.stretch()).gaps(5, 5);
        TableLayout fixedDemo = new TableLayout(COL.fixed(), COL, COL.stretch()).gaps(5, 5);
        TableLayout minWidthDemo = new TableLayout(
            COL.minWidth(100), COL.minWidth(100).stretch(), COL).gaps(5, 5);

        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"),
View Full Code Here

        return "Util: Colors";
    }

    @Override protected Group createIface () {
        return new Group(AxisLayout.vertical(), Style.HALIGN.center).add(
            new Group(new TableLayout(TableLayout.COL.fixed().alignRight(),
                                      TableLayout.COL.fixed().alignLeft()).gaps(1, 5)).add(
                new Label("White"), createLabel(Colors.WHITE),
                new Label("Light Gray"), createLabel(Colors.LIGHT_GRAY),
                new Label("Gray"), createLabel(Colors.GRAY),
                new Label("Dark Gray"), createLabel(Colors.DARK_GRAY),
View Full Code Here

                if (menu != null) {
                    return menu;
                }
                String letters = "ABCDEFGHIJ";
                menu = new Menu(AxisLayout.horizontal().offStretch(), Style.VALIGN.top);
                Group g = new Group(new TableLayout(10));
                g.setStylesheet(Stylesheet.builder().add(MenuItem.class, Styles.none().
                    add(Style.BACKGROUND.is(Background.blank().inset(5, 1))).
                    addSelected(Style.BACKGROUND.is(Background.solid(Colors.BLACK).inset(5, 1)))).
                    create());
                for (int col = 0; col < 10; col++) {
                    for (int row = 0; row < 10; row++) {
                       g.add(new MenuItem(letters.substring(col, col+1) + (row + 1)));
                    }
                }
                return menu.add(g);
            }

            @Override public MenuHost.Pop makePop (Pointer.Event ev) {
                return super.makePop(ev).retainMenu();
            }

            @Override protected void wasRemoved () {
                super.wasRemoved();
                if (menu != null) {
                    menu.layer.destroy();
                }
            }
        };

        TrackingLabel scrolled = new TrackingLabel(menuHost, "Bits \u25BC") {
            @Override public Menu createMenu () {
                final Menu menu = new Menu(AxisLayout.vertical().offStretch());
                menu.add(new Label("Select a byte").addStyles(Style.COLOR.is(0xFFFFFFFF),
                    Style.BACKGROUND.is(Background.beveled(0xFF8F8F8F, 0xFF4F4F4F, 0xFFCFCFCF).
                        inset(4))));
                Group items = new Group(AxisLayout.vertical());
                Scroller scroller = new Scroller(items);
                menu.add(new SizableGroup(AxisLayout.vertical().offStretch(), 0, 200).add(
                    scroller.setBehavior(Scroller.Behavior.VERTICAL).
                        setConstraint(AxisLayout.stretched())));

                StringBuilder bits = new StringBuilder();
                for (int ii = 0; ii < 256; ii++) {
                    bits.setLength(0);
                    for (int mask = 128; mask > 0; mask >>= 1) {
                        bits.append((ii & mask) != 0 ? 1 : 0);
                    }
                    items.add(new MenuItem(bits.toString()));
                }
                return menu;
            }
        };

        TrackingLabel bytes = new TrackingLabel(menuHost, "Bytes \u25BC") {
            final String HEX = "0123456789ABCDEF";
            @Override public Menu createMenu () {
                final PagedMenu menu = new PagedMenu(new TableLayout(2), 16);
                menu.add(new Label("Select a byte").addStyles(Style.COLOR.is(0xFFFFFFFF),
                    Style.BACKGROUND.is(Background.beveled(0xFF8F8F8F, 0xFF4F4F4F, 0xFFCFCFCF).
                        inset(4))).setConstraint(new TableLayout.Colspan(2)));
                final Button prev = new Button("<< Previous").onClick(menu.incrementPage(-1));
                final Button next = new Button("Next >>").onClick(menu.incrementPage(1));
                menu.add(prev, next);
                UnitSlot updateEnabling = new UnitSlot() {
                    @Override public void onEmit () {
                        prev.setEnabled(menu.page().get() > 0);
                        next.setEnabled(menu.page().get() < menu.numPages().get() - 1);
                    }
                };

                menu.page().connect(updateEnabling);
                menu.numPages().connect(updateEnabling);

                int sel = -1;
                for (int ii = 0; ii < 256; ii++) {
                    String hex = new StringBuilder("0x").
                        append(HEX.charAt((ii>>4)&0xf)).
                        append(HEX.charAt(ii&0xf)).toString();
                    if (text.get().startsWith(hex)) sel = ii;
                    menu.add(new MenuItem(hex));
                }
                if (sel != -1) menu.setPage(sel / menu.itemsPerPage);
                updateEnabling.onEmit();
                return menu;
            }
        };

        TrackingLabel colors = new TrackingLabel(menuHost, "Colors \u25BC") {
            @Override public Menu createMenu () {
                final PagedMenu menu = new PagedMenu(AxisLayout.vertical(), 32);
                final Slider slider = new Slider().setIncrement(1);
                slider.value.connect(new Slot<Float>() {
                    @Override public void onEmit (Float val) {
                        menu.setPage(FloatMath.round(val));
                    }
                });
                menu.page().connect(new Slot<Integer>() {
                    @Override public void onEmit (Integer page) {
                        slider.value.update(page.floatValue());
                    }
                });
                menu.numPages().connect(new Slot<Integer>() {
                    @Override public void onEmit (Integer numPages) {
                        slider.range.update(new Slider.Range(0, numPages.intValue() - 1));
                        slider.setEnabled(numPages > 0);
                    }
                });

                Styles itemStyles = Styles.none().add(Style.Mode.SELECTED,
                        Style.BACKGROUND.is(Background.solid(Colors.BLUE).inset(2))).
                    add(Style.BACKGROUND.is(Background.blank().inset(2)));
                Group colorTable = new Group(new TableLayout(4));
                for (int ii = 0; ii < 256; ii++) {
                    CanvasImage colorImg = PlayN.graphics().createImage(16, 16);
                    colorImg.canvas().setFillColor(0xFF000000 | (ii << 16));
                    colorImg.canvas().fillRect(0, 0, 16, 16);
                    colorTable.add(new MenuItem("", Icons.image(colorImg)).addStyles(itemStyles));
View Full Code Here

        void refresh () {
            Group oldTable = table;
            if (table != null) tableHolder.remove(table);
            tableHolder.add(table = new Group(
                new TableLayout(columns.toArray(new TableLayout.Column[0])), tableStyles));
            if (oldTable!= null) {
                while (oldTable.childCount() > 0) table.add(oldTable.childAt(0));
            }
        }
View Full Code Here

                                            inset(5, 10)));
        _root.setSize(width(), height());

        _root.add(new Label("Triple Play Demos").addStyles(Style.FONT.is(DemoScreen.TITLE_FONT)));

        Group grid = new Group(new TableLayout(
                                   TableLayout.COL.alignRight(),
                                   TableLayout.COL.stretch(),
                                   TableLayout.COL.stretch(),
                                   TableLayout.COL.stretch()).gaps(10, 10));
        _root.add(grid);
View Full Code Here

TOP

Related Classes of tripleplay.ui.layout.TableLayout$Column

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.