Search in sources :

Example 1 with ZoomableLayout

use of org.terasology.nui.layouts.ZoomableLayout in project Terasology by MovingBlocks.

the class ZoomableLayoutTest method setup.

@BeforeEach
public void setup() {
    zoomableLayout = new ZoomableLayout();
    item1 = mock(ZoomableLayout.PositionalWidget.class);
    item2 = mock(ZoomableLayout.PositionalWidget.class);
    item3 = mock(ZoomableLayout.PositionalWidget.class);
    canvas = mock(Canvas.class);
    // 
    // +------+
    // |  1   |
    // +------+
    // +-+
    // |2|
    // +-+
    // 
    // +---+
    // | 3 |
    // |   |
    // +---+
    // positions of the widgets in the world
    pos1 = new Vector2f(10, 10);
    pos2 = new Vector2f(40, 40);
    pos3 = new Vector2f(80, 70);
    when(item1.getPosition()).thenReturn(pos1);
    when(item2.getPosition()).thenReturn(pos2);
    when(item3.getPosition()).thenReturn(pos3);
    // size of widgets
    size1 = new Vector2f(20, 10);
    size2 = new Vector2f(5, 10);
    size3 = new Vector2f(10, 20);
    when(item1.getSize()).thenReturn(size1);
    when(item2.getSize()).thenReturn(size2);
    when(item3.getSize()).thenReturn(size3);
    when(item1.isVisible()).thenReturn(true);
    when(item2.isVisible()).thenReturn(true);
    when(item3.isVisible()).thenReturn(true);
    Vector2i availableSize = new Vector2i(CANVAS_WIDTH, CANVAS_HEIGHT);
    when(canvas.size()).thenReturn(availableSize);
    zoomableLayout.setWindowSize(new Vector2f(WORLD_WIDTH, WORLD_HEIGHT));
    zoomableLayout.addWidget(item1);
    zoomableLayout.addWidget(item2);
    zoomableLayout.addWidget(item3);
}
Also used : Vector2f(org.joml.Vector2f) Canvas(org.terasology.nui.Canvas) Vector2i(org.joml.Vector2i) ZoomableLayout(org.terasology.nui.layouts.ZoomableLayout) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Vector2f (org.joml.Vector2f)1 Vector2i (org.joml.Vector2i)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Canvas (org.terasology.nui.Canvas)1 ZoomableLayout (org.terasology.nui.layouts.ZoomableLayout)1