use of gregtech.common.terminal.app.guide.widget.IGuideWidget in project GregTech by GregTechCEu.
the class GuidePageEditorWidget method addGuideWidget.
public JsonObject addGuideWidget(IGuideWidget widget, boolean isFixed) {
int pageWidth = getPageWidth();
int margin = getMargin();
JsonObject widgetConfig = widget.getTemplate(isFixed);
Widget guideWidget;
if (isFixed) {
int width = widgetConfig.get("width").getAsInt();
int height = widgetConfig.get("height").getAsInt();
guideWidget = widget.updateOrCreateFixedWidget((pageWidth - width) / 2 + 5, this.scrollYOffset + (this.getSize().height - height) / 2, width, height, widgetConfig);
fixed.add(guideWidget);
this.addWidget(guideWidget);
} else {
int index = stream.indexOf(selected);
if (index >= 0) {
guideWidget = widget.updateOrCreateStreamWidget(margin, selected.getSize().height + selected.getSelfPosition().y + scrollYOffset + 5, pageWidth - 2 * margin, widgetConfig);
for (int i = index + 1; i < stream.size(); i++) {
stream.get(i).addSelfPosition(0, guideWidget.getSize().height + 5);
}
stream.add(index + 1, guideWidget);
} else {
guideWidget = widget.updateOrCreateStreamWidget(margin, getStreamBottom() + 5, pageWidth - 2 * margin, widgetConfig);
stream.add(guideWidget);
}
this.addWidget(guideWidget);
computeMax();
}
return widgetConfig;
}
use of gregtech.common.terminal.app.guide.widget.IGuideWidget in project GregTech by GregTechCEu.
the class GuidePageEditorWidget method setToolButton.
private void setToolButton(Widget widget) {
customPositionSizeWidget.setControlled(widget);
customPositionSizeWidget.setVisible(true);
customPositionSizeWidget.setActive(!(widget instanceof IGuideWidget) || ((IGuideWidget) widget).isFixed());
toolButtons.setVisible(true);
toolButtons.setSelfPosition(new Position(widget.getSelfPosition().x + widget.getSize().width / 2, widget.getSelfPosition().y));
}
Aggregations