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);
}
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));
}
}
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;
}
}
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;
}
}
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);
}
Aggregations