LinearLayout.java
net.minecraft.client.gui.layouts.LinearLayout
信息
- 全限定名:net.minecraft.client.gui.layouts.LinearLayout
- 类型:public class
- 包:net.minecraft.client.gui.layouts
- 源码路径:src/main/java/net/minecraft/client/gui/layouts/LinearLayout.java
- 起始行号:L9
- 实现:Layout
- 职责:
TODO
字段/常量
-
wrapped- 类型:
GridLayout - 修饰符:
private final - 源码定位:
L10 - 说明:
TODO
- 类型:
-
orientation- 类型:
LinearLayout.Orientation - 修饰符:
private final - 源码定位:
L11 - 说明:
TODO
- 类型:
-
nextChildIndex- 类型:
int - 修饰符:
private - 源码定位:
L12 - 说明:
TODO
- 类型:
内部类/嵌套类型
net.minecraft.client.gui.layouts.LinearLayout.Orientation- 类型:
enum - 修饰符:
public static - 源码定位:
L97 - 说明:
TODO
- 类型:
构造器
private LinearLayout(LinearLayout.Orientation orientation) @ L14
- 构造器名:LinearLayout
- 源码定位:L14
- 修饰符:private
参数:
- orientation: LinearLayout.Orientation
说明:
TODO
public LinearLayout(int x, int y, LinearLayout.Orientation orientation) @ L18
- 构造器名:LinearLayout
- 源码定位:L18
- 修饰符:public
参数:
- x: int
- y: int
- orientation: LinearLayout.Orientation
说明:
TODO
方法
下面的方法块按源码顺序生成。
public LinearLayout spacing(int spacing) @ L23
- 方法名:spacing
- 源码定位:L23
- 返回类型:LinearLayout
- 修饰符:public
参数:
- spacing: int
说明:
TODO
public LayoutSettings newCellSettings() @ L28
- 方法名:newCellSettings
- 源码定位:L28
- 返回类型:LayoutSettings
- 修饰符:public
参数:
- 无
说明:
TODO
public LayoutSettings defaultCellSetting() @ L32
- 方法名:defaultCellSetting
- 源码定位:L32
- 返回类型:LayoutSettings
- 修饰符:public
参数:
- 无
说明:
TODO
public <T extends LayoutElement> T addChild(T child, LayoutSettings cellSettings) @ L36
- 方法名:addChild
- 源码定位:L36
- 返回类型:
T - 修饰符:public
参数:
- child: T
- cellSettings: LayoutSettings
说明:
TODO
public <T extends LayoutElement> T addChild(T child) @ L40
- 方法名:addChild
- 源码定位:L40
- 返回类型:
T - 修饰符:public
参数:
- child: T
说明:
TODO
public <T extends LayoutElement> T addChild(T child, Consumer<LayoutSettings> layoutSettingsAdjustments) @ L44
- 方法名:addChild
- 源码定位:L44
- 返回类型:
T - 修饰符:public
参数:
- child: T
- layoutSettingsAdjustments: Consumer
说明:
TODO
public void visitChildren(Consumer<LayoutElement> layoutElementVisitor) @ L48
- 方法名:visitChildren
- 源码定位:L48
- 返回类型:void
- 修饰符:public
参数:
- layoutElementVisitor: Consumer
说明:
TODO
public void arrangeElements() @ L53
- 方法名:arrangeElements
- 源码定位:L53
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public int getWidth() @ L58
- 方法名:getWidth
- 源码定位:L58
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public int getHeight() @ L63
- 方法名:getHeight
- 源码定位:L63
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public void setX(int x) @ L68
- 方法名:setX
- 源码定位:L68
- 返回类型:void
- 修饰符:public
参数:
- x: int
说明:
TODO
public void setY(int y) @ L73
- 方法名:setY
- 源码定位:L73
- 返回类型:void
- 修饰符:public
参数:
- y: int
说明:
TODO
public int getX() @ L78
- 方法名:getX
- 源码定位:L78
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public int getY() @ L83
- 方法名:getY
- 源码定位:L83
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public static LinearLayout vertical() @ L88
- 方法名:vertical
- 源码定位:L88
- 返回类型:LinearLayout
- 修饰符:public static
参数:
- 无
说明:
TODO
public static LinearLayout horizontal() @ L92
- 方法名:horizontal
- 源码定位:L92
- 返回类型:LinearLayout
- 修饰符:public static
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class LinearLayout implements Layout {
private final GridLayout wrapped;
private final LinearLayout.Orientation orientation;
private int nextChildIndex = 0;
private LinearLayout(LinearLayout.Orientation orientation) {
this(0, 0, orientation);
}
public LinearLayout(int x, int y, LinearLayout.Orientation orientation) {
this.wrapped = new GridLayout(x, y);
this.orientation = orientation;
}
public LinearLayout spacing(int spacing) {
this.orientation.setSpacing(this.wrapped, spacing);
return this;
}
public LayoutSettings newCellSettings() {
return this.wrapped.newCellSettings();
}
public LayoutSettings defaultCellSetting() {
return this.wrapped.defaultCellSetting();
}
public <T extends LayoutElement> T addChild(T child, LayoutSettings cellSettings) {
return this.orientation.addChild(this.wrapped, child, this.nextChildIndex++, cellSettings);
}
public <T extends LayoutElement> T addChild(T child) {
return this.addChild(child, this.newCellSettings());
}
public <T extends LayoutElement> T addChild(T child, Consumer<LayoutSettings> layoutSettingsAdjustments) {
return this.orientation.addChild(this.wrapped, child, this.nextChildIndex++, Util.make(this.newCellSettings(), layoutSettingsAdjustments));
}
@Override
public void visitChildren(Consumer<LayoutElement> layoutElementVisitor) {
this.wrapped.visitChildren(layoutElementVisitor);
}
@Override
public void arrangeElements() {
this.wrapped.arrangeElements();
}
@Override
public int getWidth() {
return this.wrapped.getWidth();
}
@Override
public int getHeight() {
return this.wrapped.getHeight();
}
@Override
public void setX(int x) {
this.wrapped.setX(x);
}
@Override
public void setY(int y) {
this.wrapped.setY(y);
}
@Override
public int getX() {
return this.wrapped.getX();
}
@Override
public int getY() {
return this.wrapped.getY();
}
public static LinearLayout vertical() {
return new LinearLayout(LinearLayout.Orientation.VERTICAL);
}
public static LinearLayout horizontal() {
return new LinearLayout(LinearLayout.Orientation.HORIZONTAL);
}
@OnlyIn(Dist.CLIENT)
public static enum Orientation {
HORIZONTAL,
VERTICAL;
private void setSpacing(GridLayout gridLayout, int spacing) {
switch (this) {
case HORIZONTAL:
gridLayout.columnSpacing(spacing);
break;
case VERTICAL:
gridLayout.rowSpacing(spacing);
}
}
public <T extends LayoutElement> T addChild(GridLayout gridLayout, T child, int index, LayoutSettings cellSettings) {
return (T)(switch (this) {
case HORIZONTAL -> gridLayout.addChild(child, 0, index, cellSettings);
case VERTICAL -> gridLayout.addChild(child, index, 0, cellSettings);
});
}
}
}引用的其他类
-
- 引用位置:
字段/构造调用 - 关联成员:
GridLayout()
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
参数/返回值
- 引用位置:
-
- 引用位置:
参数/返回值
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Util.make()
- 引用位置: