mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-22 13:10:10 +00:00
ViewportScrollable is now its own class.
This commit is contained in:
1 parent
a6890c5824
commit
a92a5dde3c
2 files changed
+59
-45
No files matched your search
@@ -12,6 +12,7 @@ import mcp.mobius.waila.gui.widgets.LabelFixedFont;
|
||||
import mcp.mobius.waila.gui.widgets.LayoutCropping;
|
||||
import mcp.mobius.waila.gui.widgets.PictureDisplay;
|
||||
import mcp.mobius.waila.gui.widgets.PictureSwitch;
|
||||
import mcp.mobius.waila.gui.widgets.ViewportScrollable;
|
||||
import mcp.mobius.waila.gui.widgets.WidgetBase;
|
||||
import mcp.mobius.waila.gui.widgets.WidgetGeometry;
|
||||
import mcp.mobius.waila.gui.widgets.buttons.ButtonBoolean;
|
||||
@@ -26,53 +27,10 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ScreenTest extends ScreenBase {
|
||||
|
||||
public class SubLayout extends WidgetBase{
|
||||
|
||||
IWidget attachedWidget = null;
|
||||
int yOffset = 0;
|
||||
int step = 5;
|
||||
|
||||
public SubLayout( IWidget parent){
|
||||
super(parent);
|
||||
this.addWidget("Cropping", new LayoutCropping(null)).setGeometry(new WidgetGeometry(50.0,50.0,100.0,100.0,CType.RELXY, CType.RELXY, WAlign.CENTER, WAlign.CENTER));
|
||||
}
|
||||
|
||||
public IWidget attachWidget(IWidget widget){
|
||||
this.attachedWidget = this.getWidget("Cropping").addWidget("Cropped", widget);
|
||||
return this.attachedWidget;
|
||||
}
|
||||
|
||||
public IWidget getAttachedWidget(){
|
||||
return this.attachedWidget;
|
||||
}
|
||||
|
||||
public IWidget setStep(int step){
|
||||
this.step = step;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Point pos) {}
|
||||
|
||||
@Override
|
||||
public void onMouseWheel(MouseEvent event){
|
||||
this.yOffset += event.z / 120.0 * this.step;
|
||||
|
||||
this.yOffset = Math.max(this.yOffset, this.getSize().getY() - this.attachedWidget.getSize().getY());
|
||||
this.yOffset = Math.min(this.yOffset, 0);
|
||||
|
||||
((LayoutCropping)this.getWidget("Cropping")).setOffsets(0, this.yOffset);
|
||||
}
|
||||
}
|
||||
|
||||
public ScreenTest(GuiScreen parent) {
|
||||
super(parent);
|
||||
|
||||
this.getRoot().addWidget("Layout", new SubLayout(null)).setGeometry(new WidgetGeometry(50.0,50.0,50.0,50.0,CType.ABSXY, CType.RELXY, WAlign.TOP, WAlign.LEFT));
|
||||
((SubLayout)this.getRoot().getWidget("Layout")).attachWidget(new PictureSwitch(this.getRoot(), "waila:textures/test.png", "waila:textures/test_solar.png")).getGeometry().setSize(300, 300);
|
||||
|
||||
//this.getRoot().addWidget("Layout", new LayoutCropping(null)).setGeometry(new WidgetGeometry(50.0,50.0,50.0,50.0,CType.ABSXY, CType.RELXY, WAlign.TOP, WAlign.LEFT));
|
||||
//this.getRoot().getWidget("Layout").addWidget("Picture", new PictureSwitch(this.getRoot(), "waila:textures/test.png", "waila:textures/test_solar.png")).getGeometry().setSize(300, 300);
|
||||
//this.getRoot().addWidget("Picture", new ItemStackDisplay(null, new ItemStack(Block.dirt, 8))).setGeometry(new WidgetGeometry(50.0,50.0,75.0,75.0,CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
|
||||
this.getRoot().addWidget("Layout", new ViewportScrollable(null)).setGeometry(new WidgetGeometry(50.0,50.0,50.0,50.0,CType.ABSXY, CType.RELXY, WAlign.TOP, WAlign.LEFT));
|
||||
((ViewportScrollable)this.getRoot().getWidget("Layout")).attachWidget(new PictureSwitch(this.getRoot(), "waila:textures/test.png", "waila:textures/test_solar.png")).getGeometry().setSize(300, 300);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package mcp.mobius.waila.gui.widgets;
|
||||
|
||||
import mcp.mobius.waila.gui.events.MouseEvent;
|
||||
import mcp.mobius.waila.gui.interfaces.CType;
|
||||
import mcp.mobius.waila.gui.interfaces.IWidget;
|
||||
import mcp.mobius.waila.gui.interfaces.WAlign;
|
||||
|
||||
import org.lwjgl.util.Point;
|
||||
|
||||
public class ViewportScrollable extends WidgetBase {
|
||||
|
||||
public class Escalator extends WidgetBase{
|
||||
public Escalator(IWidget parent){
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Point pos) {}
|
||||
}
|
||||
|
||||
IWidget attachedWidget = null;
|
||||
int yOffset = 0;
|
||||
int step = 5;
|
||||
|
||||
public ViewportScrollable( IWidget parent){
|
||||
super(parent);
|
||||
this.addWidget("Cropping", new LayoutCropping(null)).setGeometry(new WidgetGeometry(50.0,50.0,100.0,100.0,CType.RELXY, CType.RELXY, WAlign.CENTER, WAlign.CENTER));
|
||||
}
|
||||
|
||||
public IWidget attachWidget(IWidget widget){
|
||||
this.attachedWidget = this.getWidget("Cropping").addWidget("Cropped", widget);
|
||||
return this.attachedWidget;
|
||||
}
|
||||
|
||||
public IWidget getAttachedWidget(){
|
||||
return this.attachedWidget;
|
||||
}
|
||||
|
||||
public IWidget setStep(int step){
|
||||
this.step = step;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Point pos) {}
|
||||
|
||||
@Override
|
||||
public void onMouseWheel(MouseEvent event){
|
||||
this.yOffset += event.z / 120.0 * this.step;
|
||||
|
||||
this.yOffset = Math.max(this.yOffset, this.getSize().getY() - this.attachedWidget.getSize().getY());
|
||||
this.yOffset = Math.min(this.yOffset, 0);
|
||||
|
||||
((LayoutCropping)this.getWidget("Cropping")).setOffsets(0, this.yOffset);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user