use of net.drewke.tdme.gui.nodes.GUIParentNode 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);
}
}
});
}
use of net.drewke.tdme.gui.nodes.GUIParentNode 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);
}
}
});
}
use of net.drewke.tdme.gui.nodes.GUIParentNode in project tdme by andreasdr.
the class GUIDropDownController method unselect.
/**
* Unselect all nodes
*/
protected void unselect() {
((GUIParentNode) node).getChildControllerNodes(childControllerNodes);
for (int i = 0; i < childControllerNodes.size(); i++) {
GUINode childControllerNode = childControllerNodes.get(i);
GUINodeController childController = childControllerNode.getController();
if (childController instanceof GUIDropDownOptionController) {
((GUIDropDownOptionController) childController).unselect();
}
}
}
use of net.drewke.tdme.gui.nodes.GUIParentNode in project tdme by andreasdr.
the class GUIDropDownController method determineDropDownOptionControllers.
/**
* Determine drop down option controllers
*/
private void determineDropDownOptionControllers() {
dropDownOptionControllers.clear();
((GUIParentNode) node).getChildControllerNodes(childControllerNodes);
for (int i = 0; i < childControllerNodes.size(); i++) {
GUINode childControllerNode = childControllerNodes.get(i);
GUINodeController childController = childControllerNode.getController();
if (childController instanceof GUIDropDownOptionController) {
dropDownOptionControllers.add((GUIDropDownOptionController) childController);
}
}
}
use of net.drewke.tdme.gui.nodes.GUIParentNode in project tdme by andreasdr.
the class GUISelectBoxMultipleController method unselect.
/**
* Unselect all nodes
*/
protected void unselect() {
((GUIParentNode) node).getChildControllerNodes(childControllerNodes);
for (int i = 0; i < childControllerNodes.size(); i++) {
GUINode childControllerNode = childControllerNodes.get(i);
GUINodeController childController = childControllerNode.getController();
if (childController instanceof GUISelectBoxMultipleOptionController) {
((GUISelectBoxMultipleOptionController) childController).unselect();
}
}
}
Aggregations