Search in sources :

Example 11 with GUIElementNode

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

the class GUITest method init.

/*
	 * (non-Javadoc)
	 * @see com.jogamp.opengl.GLEventListener#init(com.jogamp.opengl.GLAutoDrawable)
	 */
public void init(GLAutoDrawable drawable) {
    // init engine
    engine.init(drawable);
    // register gui to mouse, keyboard events
    glWindow.addMouseListener(engine.getGUI());
    glWindow.addKeyListener(engine.getGUI());
    //
    try {
        engine.getGUI().addScreen("test", GUIParser.parse("resources/tests/gui", "test.xml"));
        engine.getGUI().getScreen("test").setScreenSize(640, 480);
        engine.getGUI().getScreen("test").addActionListener(new GUIActionListener() {

            public void onActionPerformed(GUIActionListener.Type type, GUIElementNode node) {
                // check if button 1 is pressed
                if (type == Type.PERFORMED && node.getName().equals("button")) {
                    // action performed
                    System.out.println(node.getId() + ".actionPerformed()");
                    // test get values
                    HashMap<String, MutableString> values = new HashMap<String, MutableString>();
                    node.getScreenNode().getValues(values);
                    System.out.println(values);
                    // test set values
                    values.clear();
                    values.put("select", new MutableString("8"));
                    values.put("input", new MutableString("Enter some more text here!"));
                    values.put("checkbox1", new MutableString("1"));
                    values.put("checkbox2", new MutableString("1"));
                    values.put("checkbox3", new MutableString("1"));
                    values.put("dropdown", new MutableString("11"));
                    values.put("radio", new MutableString("3"));
                    values.put("selectmultiple", new MutableString("|1|2|3|15|16|17|"));
                    node.getScreenNode().setValues(values);
                    // test GUI tab controller select tab method
                    ((GUITabController) node.getScreenNode().getNodeById("tab1").getController()).selectTab();
                } else // check if button 2 is pressed
                if (type == Type.PERFORMED && node.getName().equals("button2")) {
                    try {
                        {
                            GUIParentNode parentNode = (GUIParentNode) (node.getScreenNode().getNodeById("sadd_inner"));
                            parentNode.replaceSubNodes("<dropdown-option text=\"Option 1\" value=\"1\" />" + "<dropdown-option text=\"Option 2\" value=\"2\" />" + "<dropdown-option text=\"Option 3\" value=\"3\" />" + "<dropdown-option text=\"Option 4\" value=\"4\" />" + "<dropdown-option text=\"Option 5\" value=\"5\" />" + "<dropdown-option text=\"Option 6\" value=\"6\" />" + "<dropdown-option text=\"Option 7\" value=\"7\" />" + "<dropdown-option text=\"Option 8\" value=\"8\" selected=\"true\" />" + "<dropdown-option text=\"Option 9\" value=\"9\" />" + "<dropdown-option text=\"Option 10\" value=\"10\" />", true);
                        }
                        {
                            //
                            GUIParentNode parentNode = (GUIParentNode) (node.getScreenNode().getNodeById("sasb_inner"));
                            parentNode.replaceSubNodes("<selectbox-option text=\"Option 1\" value=\"1\" />" + "<selectbox-option text=\"Option 2\" value=\"2\" />" + "<selectbox-option text=\"Option 3\" value=\"3\" />" + "<selectbox-option text=\"Option 4\" value=\"4\" selected=\"true\" />" + "<selectbox-option text=\"Option 5\" value=\"5\" />" + "<selectbox-option text=\"Option 6\" value=\"6\" />" + "<selectbox-option text=\"Option 7\" value=\"7\" />" + "<selectbox-option text=\"Option 8\" value=\"8\" />" + "<selectbox-option text=\"Option 9\" value=\"9\" />" + "<selectbox-option text=\"Option 10\" value=\"10\" />", true);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    // test GUI tab controller select tab method
                    ((GUITabController) node.getScreenNode().getNodeById("tab2").getController()).selectTab();
                }
            }
        });
        engine.getGUI().getScreen("test").addChangeListener(new GUIChangeListener() {

            public void onValueChanged(GUIElementNode node) {
                System.out.println(node.getName() + ":onValueChanged: " + node.getController().getValue());
            }
        });
        // layout
        engine.getGUI().getScreen("test").layout();
        // add fade in effect
        GUIColorEffect effectFadeIn = new GUIColorEffect();
        effectFadeIn.getColorMulStart().set(0f, 0f, 0f, 1f);
        effectFadeIn.getColorMulEnd().set(1f, 1f, 1f, 1f);
        effectFadeIn.setTimeTotal(1f);
        effectFadeIn.start();
        engine.getGUI().getScreen("test").addEffect("fadein", effectFadeIn);
        // add scroll in effect
        GUIPositionEffect effectScrollIn = new GUIPositionEffect();
        effectScrollIn.setPositionXStart(-800f);
        effectScrollIn.setPositionXEnd(0f);
        effectScrollIn.setTimeTotal(1f);
        effectScrollIn.start();
        engine.getGUI().getScreen("test").addEffect("scrollin", effectScrollIn);
        // add to render queue
        engine.getGUI().addRenderScreen("test");
    } catch (Exception exception) {
        exception.printStackTrace();
    }
}
Also used : GUITabController(net.drewke.tdme.gui.elements.GUITabController) GUIParentNode(net.drewke.tdme.gui.nodes.GUIParentNode) HashMap(net.drewke.tdme.utils.HashMap) GUIChangeListener(net.drewke.tdme.gui.events.GUIChangeListener) MutableString(net.drewke.tdme.utils.MutableString) GUIColorEffect(net.drewke.tdme.gui.effects.GUIColorEffect) MutableString(net.drewke.tdme.utils.MutableString) GUIElementNode(net.drewke.tdme.gui.nodes.GUIElementNode) GUIActionListener(net.drewke.tdme.gui.events.GUIActionListener) GUIPositionEffect(net.drewke.tdme.gui.effects.GUIPositionEffect)

Example 12 with GUIElementNode

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

the class GUISelectBoxOptionController method select.

/**
	 * Select
	 */
protected void select() {
    // select current
    GUINodeConditions nodeConditions = ((GUIElementNode) node).getActiveConditions();
    nodeConditions.remove(this.selected == true ? CONDITION_SELECTED : CONDITION_UNSELECTED);
    this.selected = true;
    nodeConditions.add(this.selected == true ? CONDITION_SELECTED : CONDITION_UNSELECTED);
    // disabled
    boolean disabled = ((GUISelectBoxController) selectBoxNode.getController()).isDisabled();
    nodeConditions.remove(CONDITION_DISABLED);
    nodeConditions.remove(CONDITION_ENABLED);
    nodeConditions.add(disabled == true ? CONDITION_DISABLED : CONDITION_ENABLED);
}
Also used : GUINodeConditions(net.drewke.tdme.gui.nodes.GUINodeConditions) GUIElementNode(net.drewke.tdme.gui.nodes.GUIElementNode)

Example 13 with GUIElementNode

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

the class GUITabContentController method setSelected.

/**
	 * Set checked
	 * @param selected
	 */
protected void setSelected(boolean selected) {
    // remove old selection condition, add new selection condition
    GUINodeConditions nodeConditions = ((GUIElementNode) this.node.getParentNode()).getActiveConditions();
    nodeConditions.remove(this.selected == true ? CONDITION_SELECTED : CONDITION_UNSELECTED);
    this.selected = selected;
    nodeConditions.add(this.selected == true ? CONDITION_SELECTED : CONDITION_UNSELECTED);
}
Also used : GUINodeConditions(net.drewke.tdme.gui.nodes.GUINodeConditions) GUIElementNode(net.drewke.tdme.gui.nodes.GUIElementNode)

Example 14 with GUIElementNode

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

the class GUITabController method setDisabled.

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

Example 15 with GUIElementNode

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

the class GUITabController method setSelected.

/**
	 * Set checked
	 * @param selected
	 */
protected void setSelected(boolean selected) {
    // remove old selection condition, add new selection condition
    GUINodeConditions nodeConditions = ((GUIElementNode) this.node).getActiveConditions();
    nodeConditions.remove(this.selected == true ? CONDITION_SELECTED : CONDITION_UNSELECTED);
    this.selected = selected;
    nodeConditions.add(this.selected == true ? CONDITION_SELECTED : CONDITION_UNSELECTED);
    // handle focus, alter border depending on tabs header node focus and selection state
    if (((GUITabsHeaderController) tabsHeaderNode.getController()).hasFocus() == true) {
        if (selected == true) {
            GUIColor focussedBorderColor = node.getScreenNode().getGUI().getFoccussedBorderColor();
            GUINode.Border border = node.getBorder();
            border.topColor = focussedBorderColor;
            border.leftColor = focussedBorderColor;
            border.bottomColor = focussedBorderColor;
            border.rightColor = focussedBorderColor;
        } else {
            GUINode.Border border = node.getBorder();
            border.topColor = unfocussedNodeBorderTopColor;
            border.leftColor = unfocussedNodeBorderLeftColor;
            border.bottomColor = unfocussedNodeBorderBottomColor;
            border.rightColor = unfocussedNodeBorderRightColor;
        }
    } else {
        GUINode.Border border = node.getBorder();
        border.topColor = unfocussedNodeBorderTopColor;
        border.leftColor = unfocussedNodeBorderLeftColor;
        border.bottomColor = unfocussedNodeBorderBottomColor;
        border.rightColor = unfocussedNodeBorderRightColor;
    }
}
Also used : GUINodeConditions(net.drewke.tdme.gui.nodes.GUINodeConditions) GUIColor(net.drewke.tdme.gui.nodes.GUIColor) GUIElementNode(net.drewke.tdme.gui.nodes.GUIElementNode) GUINode(net.drewke.tdme.gui.nodes.GUINode)

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