Package org.terasology.rendering.nui

Examples of org.terasology.rendering.nui.UIWidget


    private void expand(PropertyProvider<?> propertyProvider, MigLayout layout) {
        List<Property<?, ?>> props = Lists.newArrayList(propertyProvider.getProperties());
        Collections.sort(props, propertyComparator);
        for (Property<?, ?> property : props) {
            UILabel label = property.getLabel();
            UIWidget editor = property.getEditor();
            editor.setTooltip(property.getDescription());

            layout.addWidget(label, new CCHint("newline"));
            layout.addWidget(editor, new CCHint());
        }
        invalidate();
View Full Code Here


            for (int rowIndex = 0; rowIndex < rows.size(); ++rowIndex) {
                List<UIWidget> row = rows.get(rowIndex);
                RowInfo rowInfo = rowInfos.get(rowIndex);
                int cellOffsetX = rowOffsetX;
                for (int i = 0; i < row.size(); ++i) {
                    UIWidget widget = row.get(i);
                    int rowHeight = rowInfo.height;
                    if (widget != null) {
                        Rect2i drawRegion = Rect2i.createFromMinAndSize(cellOffsetX, rowOffsetY, minWidths[i], rowHeight);
                        canvas.drawWidget(widget, drawRegion);
                    }
View Full Code Here

        int availableWidth = areaHint.x - horizontalSpacing * (columns - 1);

        RowInfo rowInfo = new RowInfo();

        for (int i = 0; i < columns && i < row.size(); ++i) {
            UIWidget widget = row.get(i);
            Vector2i cellSize = new Vector2i(availableWidth, areaHint.y);
            if (!autoSizeColumns) {
                cellSize.x *= columnWidths[i];
            }
            if (widget != null) {
View Full Code Here

        addInteractionRegion(listener, tooltip, getCurrentStyle().getMargin().grow(applyStyleToSize(getRegion())));
    }

    @Override
    public void addInteractionRegion(InteractionListener listener, String tooltip, Rect2i region) {
        UIWidget tooltipLabelWidget = (tooltip == null || tooltip.isEmpty()) ? null : new UILabel(tooltip);
        addInteractionRegion(listener, tooltipLabelWidget, region);
    }
View Full Code Here

            for (int columnIndex = 0; columnIndex < columns.size(); ++columnIndex) {
                List<UIWidget> column = columns.get(columnIndex);
                ColumnInfo columnInfo = columnInfos.get(columnIndex);
                int cellOffsetY = columnOffsetY;
                for (int i = 0; i < column.size(); ++i) {
                    UIWidget widget = column.get(i);
                    int columnWidth = columnInfo.width;
                    if (widget != null) {
                        Rect2i drawRegion = Rect2i.createFromMinAndSize(columnOffsetX, cellOffsetY, columnWidth, minHeights[i]);
                        canvas.drawWidget(widget, drawRegion);
                    }
View Full Code Here

        int availableHeight = areaHint.y - verticalSpacing * (rows - 1);

        ColumnInfo columnInfo = new ColumnInfo();

        for (int i = 0; i < rows && i < column.size(); ++i) {
            UIWidget widget = column.get(i);
            Vector2i cellSize = new Vector2i(areaHint.x, availableHeight);
            if (!autoSizeRows) {
                cellSize.y *= rowHeights[i];
            }
            if (widget != null) {
View Full Code Here

        int[] bounds = {0, 0, canvas.size().x, canvas.size().y};

        layoutContainer(canvas, bounds);

        for (ComponentWrapper wrapper : wrappers.values()) {
            UIWidget component = (UIWidget) wrapper.getComponent();
            Rect2i region = Rect2i.createFromMinAndSize(wrapper.getX(), wrapper.getY(), wrapper.getWidth(), wrapper.getHeight());
            canvas.drawWidget(component, region);
        }

        if (debug) {
View Full Code Here

            String id = null;
            if (jsonObject.has("id")) {
                id = jsonObject.get("id").getAsString();
            }

            UIWidget element = elementMetadata.newInstance();
            if (id != null) {
                FieldMetadata fieldMetadata = elementMetadata.getField("id");
                if (fieldMetadata == null) {
                    logger.warn("UIWidget type {} lacks id field", elementMetadata.getUri());
                } else {
                    fieldMetadata.setValue(element, id);
                }
            }

            // Deserialize normal fields.
            for (FieldMetadata<? extends UIWidget, ?> field : elementMetadata.getFields()) {
                if (jsonObject.has(field.getSerializationName())) {
                    if (field.getName().equals(CONTENTS_FIELD) && UILayout.class.isAssignableFrom(elementMetadata.getType())) {
                        continue;
                    }
                    try {
                        if (List.class.isAssignableFrom(field.getType())) {
                            Type contentType = ReflectionUtil.getTypeParameter(field.getField().getGenericType(), 0);
                            if (contentType != null) {
                                List result = Lists.newArrayList();
                                JsonArray list = jsonObject.getAsJsonArray(field.getSerializationName());
                                for (JsonElement item : list) {
                                    result.add(context.deserialize(item, contentType));
                                }
                                field.setValue(element, result);
                            }
                        } else {
                            field.setValue(element, context.deserialize(jsonObject.get(field.getSerializationName()), field.getType()));
                        }
                    } catch (Throwable e) {
                        logger.error("Failed to deserialize field {} of {}", field.getName(), type, e);
                    }
                }
            }

            // Deserialize contents and layout hints
            if (UILayout.class.isAssignableFrom(elementMetadata.getType())) {
                UILayout layout = (UILayout) element;

                Class<? extends LayoutHint> layoutHintType = (Class<? extends LayoutHint>)
                        ReflectionUtil.getTypeParameter(elementMetadata.getType().getGenericSuperclass(), 0);
                if (jsonObject.has(CONTENTS_FIELD)) {
                    for (JsonElement child : jsonObject.getAsJsonArray(CONTENTS_FIELD)) {
                        UIWidget childElement = context.deserialize(child, UIWidget.class);
                        if (childElement != null) {
                            LayoutHint hint = null;
                            if (child.isJsonObject()) {
                                JsonObject childObject = child.getAsJsonObject();
                                if (layoutHintType != null && !layoutHintType.isInterface() && !Modifier.isAbstract(layoutHintType.getModifiers())
View Full Code Here

TOP

Related Classes of org.terasology.rendering.nui.UIWidget

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.