Search in sources :

Example 6 with IWidget

use of binnie.core.api.gui.IWidget in project Binnie by ForestryMC.

the class Widget method render.

/* RENDERING*/
@Override
@SideOnly(Side.CLIENT)
public final void render(int guiWidth, int guiHeight) {
    if (!isVisible()) {
        return;
    }
    CraftGUI.RENDER.preRender(this, guiWidth, guiHeight);
    this.onRender(RenderStage.PRE_CHILDREN, guiWidth, guiHeight);
    for (final IWidget widget : this.getChildren()) {
        widget.render(guiWidth, guiHeight);
    }
    for (final IWidget widget : this.getChildren()) {
        CraftGUI.RENDER.preRender(widget, guiWidth, guiHeight);
        widget.onRender(RenderStage.POST_SIBLINGS, guiWidth, guiHeight);
        CraftGUI.RENDER.postRender(widget);
    }
    this.onRender(RenderStage.POST_CHILDREN, guiWidth, guiHeight);
    CraftGUI.RENDER.postRender(this);
}
Also used : IWidget(binnie.core.api.gui.IWidget) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 7 with IWidget

use of binnie.core.api.gui.IWidget in project Binnie by ForestryMC.

the class TopLevelWidget method setFocusedWidget.

public void setFocusedWidget(@Nullable final IWidget widget) {
    IWidget newWidget = widget;
    if (this.focusedWidget == newWidget) {
        return;
    }
    if (newWidget != null && !newWidget.canFocus()) {
        newWidget = null;
    }
    if (this.focusedWidget != null) {
        this.callEvent(new EventWidget.LoseFocus(this.focusedWidget));
    }
    this.focusedWidget = newWidget;
    if (this.focusedWidget != null) {
        this.callEvent(new EventWidget.GainFocus(this.focusedWidget));
    }
}
Also used : EventWidget(binnie.core.gui.events.EventWidget) IWidget(binnie.core.api.gui.IWidget)

Example 8 with IWidget

use of binnie.core.api.gui.IWidget in project Binnie by ForestryMC.

the class CraftGUIUtil method verticalGrid.

public static void verticalGrid(final int px, final int py, final TextJustification just, final int spacing, final IWidget... widgets) {
    int y = 0;
    int w = 0;
    for (final IWidget widget : widgets) {
        w = Math.max(w, widget.getSize().xPos());
    }
    for (final IWidget widget : widgets) {
        widget.setPosition(new Point(px + Math.round((w - widget.getSize().xPos()) * just.getXOffset()), py + y));
        y += widget.getSize().yPos() + spacing;
    }
}
Also used : IPoint(binnie.core.api.gui.IPoint) IPoint(binnie.core.api.gui.IPoint) IWidget(binnie.core.api.gui.IWidget)

Example 9 with IWidget

use of binnie.core.api.gui.IWidget in project Binnie by ForestryMC.

the class CraftGUIUtil method horizontalGrid.

public static void horizontalGrid(final int px, final int py, final TextJustification just, final int spacing, final IWidget... widgets) {
    int x = 0;
    int h = 0;
    for (final IWidget widget : widgets) {
        h = Math.max(h, widget.getSize().yPos());
    }
    for (final IWidget widget : widgets) {
        widget.setPosition(new Point(px + x, py + Math.round((h - widget.getSize().yPos()) * just.getYOffset())));
        x += widget.getSize().xPos() + spacing;
    }
}
Also used : IPoint(binnie.core.api.gui.IPoint) IPoint(binnie.core.api.gui.IPoint) IWidget(binnie.core.api.gui.IWidget)

Example 10 with IWidget

use of binnie.core.api.gui.IWidget in project Binnie by ForestryMC.

the class Widget method calculateIsMouseOver.

@Override
public final boolean calculateIsMouseOver() {
    final IPoint mouse = this.getRelativeMousePosition();
    if (!this.cropped || this.cropArea == null) {
        return this.isMouseOverWidget(mouse);
    }
    final IWidget cropRelative = (this.cropWidget != null) ? this.cropWidget : this;
    final IPoint pos = Point.sub(cropRelative.getAbsolutePosition(), this.getAbsolutePosition());
    final IPoint size = new Point(this.cropArea.size().xPos(), this.cropArea.size().yPos());
    final boolean inCrop = mouse.xPos() > pos.xPos() && mouse.yPos() > pos.yPos() && mouse.xPos() < pos.xPos() + size.xPos() && mouse.yPos() < pos.yPos() + size.yPos();
    return inCrop && this.isMouseOverWidget(mouse);
}
Also used : IPoint(binnie.core.api.gui.IPoint) IPoint(binnie.core.api.gui.IPoint) Point(binnie.core.gui.geometry.Point) IWidget(binnie.core.api.gui.IWidget)

Aggregations

IWidget (binnie.core.api.gui.IWidget)14 IPoint (binnie.core.api.gui.IPoint)4 Point (binnie.core.gui.geometry.Point)3 IArea (binnie.core.api.gui.IArea)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)1 Alignment (binnie.core.api.gui.Alignment)1 EventHandlerOrigin (binnie.core.api.gui.events.EventHandlerOrigin)1 ControlTextCentered (binnie.core.gui.controls.ControlTextCentered)1 ControlTextEdit (binnie.core.gui.controls.ControlTextEdit)1 ControlListBox (binnie.core.gui.controls.listbox.ControlListBox)1 ControlTextOption (binnie.core.gui.controls.listbox.ControlTextOption)1 ControlPage (binnie.core.gui.controls.page.ControlPage)1 ControlPages (binnie.core.gui.controls.page.ControlPages)1 ControlTab (binnie.core.gui.controls.tab.ControlTab)1 ControlTabBar (binnie.core.gui.controls.tab.ControlTabBar)1 EventKey (binnie.core.gui.events.EventKey)1 EventMouse (binnie.core.gui.events.EventMouse)1