Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package xenustreet.gui.control;
- import com.jme3.math.Vector2f;
- import com.jme3.math.Vector4f;
- import tonegod.gui.controls.scrolling.ScrollArea;
- import tonegod.gui.controls.scrolling.VScrollBar;
- import tonegod.gui.core.Element;
- import tonegod.gui.core.ElementManager;
- import tonegod.gui.core.utils.UIDUtil;
- /**
- *
- * @author root
- */
- public abstract class ScrollableRepeator extends ScrollArea {
- private float scrollBottom = 0;
- public ScrollableRepeator(ElementManager screen, Vector2f position) {
- super(screen, position, false);
- }
- public ScrollableRepeator(ElementManager screen, Vector2f position, Vector2f dimensions) {
- super(screen, position, dimensions, false);
- }
- public ScrollableRepeator(ElementManager screen, Vector2f position, Vector2f dimensions, Vector4f resizeBorders, String defaultImg) {
- super(screen, position, dimensions, resizeBorders, defaultImg, false);
- }
- public ScrollableRepeator(ElementManager screen, String UID, Vector2f position) {
- super(screen, UID, position, false);
- }
- public ScrollableRepeator(ElementManager screen, String UID, Vector2f position, Vector2f dimensions) {
- super(screen, UID, position, dimensions, false);
- }
- public ScrollableRepeator(ElementManager screen, String UID, Vector2f position, Vector2f dimensions, Vector4f resizeBorders, String defaultImg) {
- super(screen, UID, position, dimensions, resizeBorders, defaultImg, false);
- }
- /**
- * adds a child to the scrollable repeator, modifying it to fit.
- * @param child
- */
- @Override
- public void addScrollableChild(Element child) {
- VScrollBar vSC = getVScrollBar();
- Vector2f childDimensions = child.getDimensions();
- float ratio = this.getScrollableArea().getWidth() / childDimensions.x;
- float height = childDimensions.y * ratio;
- child.setDimensions(childDimensions.x * ratio, height);
- child.setPosition(new Vector2f(0f, scrollBottom));
- scrollBottom += child.getHeight();
- super.addScrollableChild(child);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement