generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow WGridPanel to have gaps between widgets. (#170)
* Allow WGridPanel to have gaps between widgets. * Various formatting changes
- Loading branch information
Showing
4 changed files
with
92 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
GuiTest/src/main/java/io/github/cottonmc/test/client/PaddingTestGui.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.github.cottonmc.test.client; | ||
|
||
import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription; | ||
import io.github.cottonmc.cotton.gui.widget.WGridPanel; | ||
import io.github.cottonmc.cotton.gui.widget.WLabel; | ||
import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment; | ||
import io.github.cottonmc.cotton.gui.widget.data.Insets; | ||
import io.github.cottonmc.cotton.gui.widget.data.VerticalAlignment; | ||
|
||
import net.minecraft.text.Text; | ||
|
||
public class PaddingTestGui extends LightweightGuiDescription { | ||
public PaddingTestGui(int hori, int vert) { | ||
var root = new WGridPanel(); | ||
root.setGaps(hori, vert); | ||
setRootPanel(root); | ||
root.setInsets(Insets.ROOT_PANEL); | ||
|
||
addBox(root, 0, 0, 2, 1); | ||
addBox(root, 0, 1, 1, 2); | ||
addBox(root, 1, 1, 1, 1); | ||
addBox(root, 1, 2, 1, 1); | ||
|
||
root.validate(this); | ||
} | ||
|
||
void addBox(WGridPanel root, int x, int y, int w, int h) { | ||
root.add(new TestClientGui.WColorBox(0xffff0000), x, y, w, h); | ||
var l = new WLabel(Text.literal(w + "x" + h), 0xff00ffff); | ||
l.setVerticalAlignment(VerticalAlignment.CENTER); | ||
l.setHorizontalAlignment(HorizontalAlignment.CENTER); | ||
root.add(l, x, y, w, h); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters