Search in sources :

Example 16 with GUIElementNode

use of net.drewke.tdme.gui.nodes.GUIElementNode in project tdme by andreasdr.

the class GUIRadioButtonController method init.

/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.gui.GUINodeController#init()
	 */
public void init() {
    GUINodeConditions nodeConditions = ((GUIElementNode) node).getActiveConditions();
    nodeConditions.add(this.selected == true ? CONDITION_SELECTED : CONDITION_UNSELECTED);
    setDisabled(disabled);
}
Also used : GUINodeConditions(net.drewke.tdme.gui.nodes.GUINodeConditions) GUIElementNode(net.drewke.tdme.gui.nodes.GUIElementNode)

Example 17 with GUIElementNode

use of net.drewke.tdme.gui.nodes.GUIElementNode in project tdme by andreasdr.

the class GUIScrollAreaController method init.

/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.gui.nodes.GUINodeController#init()
	 */
public void init() {
    final GUIParentNode contentNode = (GUIParentNode) node.getScreenNode().getNodeById(node.getId() + "_inner");
    final GUIElementNode upArrowNode = (GUIElementNode) node.getScreenNode().getNodeById(node.getId() + "_scrollbar_vertical_layout_up");
    final GUIElementNode downArrowNode = (GUIElementNode) node.getScreenNode().getNodeById(node.getId() + "_scrollbar_vertical_layout_down");
    final GUIElementNode leftArrowNode = (GUIElementNode) node.getScreenNode().getNodeById(node.getId() + "_scrollbar_horizontal_layout_left");
    final GUIElementNode rightArrowNode = (GUIElementNode) node.getScreenNode().getNodeById(node.getId() + "_scrollbar_horizontal_layout_right");
    node.getScreenNode().addActionListener(new GUIActionListener() {

        public void onActionPerformed(Type type, GUIElementNode node) {
            if (node == upArrowNode) {
                // determine scrollable height
                float elementHeight = contentNode.getComputedConstraints().height;
                float contentHeight = contentNode.getContentHeight();
                float scrollableHeight = contentHeight - elementHeight;
                // skip if no scrollable height
                if (scrollableHeight <= 0f)
                    return;
                // set up children render offset y and clip it
                float childrenRenderOffsetY = contentNode.getChildrenRenderOffsetY() - 1f;
                if (childrenRenderOffsetY < 0f)
                    childrenRenderOffsetY = 0f;
                contentNode.setChildrenRenderOffsetY(childrenRenderOffsetY);
            } else if (node == downArrowNode) {
                // determine scrollable height
                float elementHeight = contentNode.getComputedConstraints().height;
                float contentHeight = contentNode.getContentHeight();
                float scrollableHeight = contentHeight - elementHeight;
                // skip if no scrollable height
                if (scrollableHeight <= 0f)
                    return;
                // set up children render offset y and clip it
                float childrenRenderOffsetY = contentNode.getChildrenRenderOffsetY() + 1f;
                if (childrenRenderOffsetY > contentHeight - contentNode.getComputedConstraints().height) {
                    childrenRenderOffsetY = contentHeight - contentNode.getComputedConstraints().height;
                }
                contentNode.setChildrenRenderOffsetY(childrenRenderOffsetY);
            } else if (node == leftArrowNode) {
                // determine scrollable width
                float elementWidth = contentNode.getComputedConstraints().width;
                float contentWidth = contentNode.getContentWidth();
                float scrollableWidth = contentWidth - elementWidth;
                // skip if no scrollable width
                if (scrollableWidth <= 0f)
                    return;
                // set up children render offset X and clip it
                float childrenRenderOffsetX = contentNode.getChildrenRenderOffsetX() - 1f;
                if (childrenRenderOffsetX < 0f)
                    childrenRenderOffsetX = 0f;
                contentNode.setChildrenRenderOffsetX(childrenRenderOffsetX);
            } else if (node == rightArrowNode) {
                // determine scrollable width
                float elementWidth = contentNode.getComputedConstraints().width;
                float contentWidth = contentNode.getContentWidth();
                float scrollableWidth = contentWidth - elementWidth;
                // skip if no scrollable width
                if (scrollableWidth <= 0f)
                    return;
                // set up children render offset x and clip it
                float childrenRenderOffsetX = contentNode.getChildrenRenderOffsetX() + 1f;
                if (childrenRenderOffsetX > contentWidth - contentNode.getComputedConstraints().width) {
                    childrenRenderOffsetX = contentWidth - contentNode.getComputedConstraints().width;
                }
                contentNode.setChildrenRenderOffsetX(childrenRenderOffsetX);
            }
        }
    });
}
Also used : GUIParentNode(net.drewke.tdme.gui.nodes.GUIParentNode) GUIElementNode(net.drewke.tdme.gui.nodes.GUIElementNode) GUIActionListener(net.drewke.tdme.gui.events.GUIActionListener)

Example 18 with GUIElementNode

use of net.drewke.tdme.gui.nodes.GUIElementNode in project tdme by andreasdr.

the class GUIScrollAreaHorizontalController method init.

/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.gui.nodes.GUINodeController#init()
	 */
public void init() {
    final GUIParentNode contentNode = (GUIParentNode) node.getScreenNode().getNodeById(node.getId() + "_inner");
    final GUIElementNode leftArrowNode = (GUIElementNode) node.getScreenNode().getNodeById(node.getId() + "_scrollbar_horizontal_layout_left");
    final GUIElementNode rightArrowNode = (GUIElementNode) node.getScreenNode().getNodeById(node.getId() + "_scrollbar_horizontal_layout_right");
    node.getScreenNode().addActionListener(new GUIActionListener() {

        public void onActionPerformed(Type type, GUIElementNode node) {
            if (node == leftArrowNode) {
                // determine scrollable width
                float elementWidth = contentNode.getComputedConstraints().width;
                float contentWidth = contentNode.getContentWidth();
                float scrollableWidth = contentWidth - elementWidth;
                // skip if no scrollable width
                if (scrollableWidth <= 0f)
                    return;
                // set up children render offset X and clip it
                float childrenRenderOffsetX = contentNode.getChildrenRenderOffsetX() - 1f;
                if (childrenRenderOffsetX < 0f)
                    childrenRenderOffsetX = 0f;
                contentNode.setChildrenRenderOffsetX(childrenRenderOffsetX);
            } else if (node == rightArrowNode) {
                // determine scrollable width
                float elementWidth = contentNode.getComputedConstraints().width;
                float contentWidth = contentNode.getContentWidth();
                float scrollableWidth = contentWidth - elementWidth;
                // skip if no scrollable width
                if (scrollableWidth <= 0f)
                    return;
                // set up children render offset x and clip it
                float childrenRenderOffsetX = contentNode.getChildrenRenderOffsetX() + 1f;
                if (childrenRenderOffsetX > contentWidth - contentNode.getComputedConstraints().width) {
                    childrenRenderOffsetX = contentWidth - contentNode.getComputedConstraints().width;
                }
                contentNode.setChildrenRenderOffsetX(childrenRenderOffsetX);
            }
        }
    });
}
Also used : GUIParentNode(net.drewke.tdme.gui.nodes.GUIParentNode) GUIElementNode(net.drewke.tdme.gui.nodes.GUIElementNode) GUIActionListener(net.drewke.tdme.gui.events.GUIActionListener)

Example 19 with GUIElementNode

use of net.drewke.tdme.gui.nodes.GUIElementNode in project tdme by andreasdr.

the class GUIScrollAreaVerticalController method init.

/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.gui.nodes.GUINodeController#init()
	 */
public void init() {
    final GUIParentNode contentNode = (GUIParentNode) node.getScreenNode().getNodeById(node.getId() + "_inner");
    final GUIElementNode upArrowNode = (GUIElementNode) node.getScreenNode().getNodeById(node.getId() + "_scrollbar_vertical_layout_up");
    final GUIElementNode downArrowNode = (GUIElementNode) node.getScreenNode().getNodeById(node.getId() + "_scrollbar_vertical_layout_down");
    node.getScreenNode().addActionListener(new GUIActionListener() {

        public void onActionPerformed(Type type, GUIElementNode node) {
            if (node == upArrowNode) {
                // determine scrollable height
                float elementHeight = contentNode.getComputedConstraints().height;
                float contentHeight = contentNode.getContentHeight();
                float scrollableHeight = contentHeight - elementHeight;
                // skip if no scrollable height
                if (scrollableHeight <= 0f)
                    return;
                // set up children render offset y and clip it
                float childrenRenderOffsetY = contentNode.getChildrenRenderOffsetY() - 1f;
                if (childrenRenderOffsetY < 0f)
                    childrenRenderOffsetY = 0f;
                contentNode.setChildrenRenderOffsetY(childrenRenderOffsetY);
            } else if (node == downArrowNode) {
                // determine scrollable height
                float elementHeight = contentNode.getComputedConstraints().height;
                float contentHeight = contentNode.getContentHeight();
                float scrollableHeight = contentHeight - elementHeight;
                // skip if no scrollable height
                if (scrollableHeight <= 0f)
                    return;
                // set up children render offset y and clip it
                float childrenRenderOffsetY = contentNode.getChildrenRenderOffsetY() + 1f;
                if (childrenRenderOffsetY > contentHeight - contentNode.getComputedConstraints().height) {
                    childrenRenderOffsetY = contentHeight - contentNode.getComputedConstraints().height;
                }
                contentNode.setChildrenRenderOffsetY(childrenRenderOffsetY);
            }
        }
    });
}
Also used : GUIParentNode(net.drewke.tdme.gui.nodes.GUIParentNode) GUIElementNode(net.drewke.tdme.gui.nodes.GUIElementNode) GUIActionListener(net.drewke.tdme.gui.events.GUIActionListener)

Example 20 with GUIElementNode

use of net.drewke.tdme.gui.nodes.GUIElementNode in project tdme by andreasdr.

the class GUIDropDownController method setDisabled.

/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.gui.nodes.GUINodeController#setDisabled(boolean)
	 */
public void setDisabled(boolean disabled) {
    GUINodeConditions nodeConditions = ((GUIElementNode) node).getActiveConditions();
    GUINodeConditions nodeConditionsTextElement = textElementNode.getActiveConditions();
    nodeConditions.remove(this.disabled == true ? CONDITION_DISABLED : CONDITION_ENABLED);
    nodeConditionsTextElement.remove(this.disabled == true ? CONDITION_DISABLED : CONDITION_ENABLED);
    this.disabled = disabled;
    nodeConditions.add(this.disabled == true ? CONDITION_DISABLED : CONDITION_ENABLED);
    nodeConditionsTextElement.add(this.disabled == true ? CONDITION_DISABLED : CONDITION_ENABLED);
    // close if open
    if (disabled == true && isOpen() == true) {
        toggleOpenState();
    }
}
Also used : GUINodeConditions(net.drewke.tdme.gui.nodes.GUINodeConditions) GUIElementNode(net.drewke.tdme.gui.nodes.GUIElementNode)

Aggregations

GUIElementNode (net.drewke.tdme.gui.nodes.GUIElementNode)28 GUINodeConditions (net.drewke.tdme.gui.nodes.GUINodeConditions)20 GUIParentNode (net.drewke.tdme.gui.nodes.GUIParentNode)5 GUIActionListener (net.drewke.tdme.gui.events.GUIActionListener)4 GUIColor (net.drewke.tdme.gui.nodes.GUIColor)2 GUINode (net.drewke.tdme.gui.nodes.GUINode)2 GUITextNode (net.drewke.tdme.gui.nodes.GUITextNode)2 MutableString (net.drewke.tdme.utils.MutableString)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 GUIColorEffect (net.drewke.tdme.gui.effects.GUIColorEffect)1 GUIPositionEffect (net.drewke.tdme.gui.effects.GUIPositionEffect)1 GUIElement (net.drewke.tdme.gui.elements.GUIElement)1 GUITabController (net.drewke.tdme.gui.elements.GUITabController)1 GUIChangeListener (net.drewke.tdme.gui.events.GUIChangeListener)1 GUIHorizontalScrollbarInternalNode (net.drewke.tdme.gui.nodes.GUIHorizontalScrollbarInternalNode)1 GUIImageNode (net.drewke.tdme.gui.nodes.GUIImageNode)1 GUIInputInternalNode (net.drewke.tdme.gui.nodes.GUIInputInternalNode)1 GUILayoutNode (net.drewke.tdme.gui.nodes.GUILayoutNode)1 GUINodeController (net.drewke.tdme.gui.nodes.GUINodeController)1