reworked layout

This commit is contained in:
Grimsace
2026-02-10 08:21:03 -06:00
parent 80b1cbd923
commit 78c58393f2
+37 -44
View File
@@ -25,8 +25,7 @@ func main() {
diceInputEntry.SetPlaceHolder("e.g., 2d20H, 3d6+5") diceInputEntry.SetPlaceHolder("e.g., 2d20H, 3d6+5")
// Dice buttons for quick input // Dice buttons for quick input
diceButtonsContainer := container.NewVBox( diceButtonsContainer := container.NewGridWithColumns(5,
container.NewHBox(
widget.NewButton("d4", func() { widget.NewButton("d4", func() {
diceInputEntry.SetText(diceInputEntry.Text + "d4") diceInputEntry.SetText(diceInputEntry.Text + "d4")
}), }),
@@ -42,8 +41,6 @@ func main() {
widget.NewButton("d12", func() { widget.NewButton("d12", func() {
diceInputEntry.SetText(diceInputEntry.Text + "d12") diceInputEntry.SetText(diceInputEntry.Text + "d12")
}), }),
),
container.NewHBox(
widget.NewButton("d20", func() { widget.NewButton("d20", func() {
diceInputEntry.SetText(diceInputEntry.Text + "d20") diceInputEntry.SetText(diceInputEntry.Text + "d20")
}), }),
@@ -59,7 +56,6 @@ func main() {
widget.NewButton("L", func() { widget.NewButton("L", func() {
diceInputEntry.SetText(diceInputEntry.Text + "L") diceInputEntry.SetText(diceInputEntry.Text + "L")
}), }),
),
) )
// Roll button // Roll button
@@ -81,58 +77,51 @@ func main() {
}) })
rollButton.Importance = widget.HighImportance rollButton.Importance = widget.HighImportance
// Clear button // Calculator-style number buttons
clearButton := widget.NewButton("CLEAR", func() { numberButtonsContainer := container.NewGridWithColumns(4,
widget.NewButton("AC", func() {
diceInputEntry.SetText("") diceInputEntry.SetText("")
outputDisplay.Text = "0" outputDisplay.Text = "0"
outputDisplay.Refresh() outputDisplay.Refresh()
}) }),
widget.NewButton("()", func() {
// Calculator-style number buttons // TODO: Implement parenthesis logic
numberButtonsContainer := container.NewVBox( }),
container.NewHBox( widget.NewButton("%", func() {
diceInputEntry.SetText(diceInputEntry.Text + "%")
}),
widget.NewButton("÷", func() {
diceInputEntry.SetText(diceInputEntry.Text + "/")
}),
createCalcButton("7", diceInputEntry), createCalcButton("7", diceInputEntry),
createCalcButton("8", diceInputEntry), createCalcButton("8", diceInputEntry),
createCalcButton("9", diceInputEntry), createCalcButton("9", diceInputEntry),
widget.NewButton("+", func() { widget.NewButton("x", func() {
diceInputEntry.SetText(diceInputEntry.Text + "+") diceInputEntry.SetText(diceInputEntry.Text + "*")
}), }),
widget.NewButton("-", func() {
diceInputEntry.SetText(diceInputEntry.Text + "-")
}),
),
container.NewHBox(
createCalcButton("4", diceInputEntry), createCalcButton("4", diceInputEntry),
createCalcButton("5", diceInputEntry), createCalcButton("5", diceInputEntry),
createCalcButton("6", diceInputEntry), createCalcButton("6", diceInputEntry),
widget.NewButton("*", func() { widget.NewButton("-", func() {
diceInputEntry.SetText(diceInputEntry.Text + "*") diceInputEntry.SetText(diceInputEntry.Text + "-")
}), }),
widget.NewButton("/", func() {
diceInputEntry.SetText(diceInputEntry.Text + "/")
}),
),
container.NewHBox(
createCalcButton("1", diceInputEntry), createCalcButton("1", diceInputEntry),
createCalcButton("2", diceInputEntry), createCalcButton("2", diceInputEntry),
createCalcButton("3", diceInputEntry), createCalcButton("3", diceInputEntry),
clearButton, widget.NewButton("+", func() {
widget.NewButton("Backspace", func() { diceInputEntry.SetText(diceInputEntry.Text + "+")
}),
createCalcButton("0", diceInputEntry),
widget.NewButton(".", func() {
diceInputEntry.SetText(diceInputEntry.Text + ".")
}),
widget.NewButton("⌫", func() {
text := diceInputEntry.Text text := diceInputEntry.Text
if len(text) > 0 { if len(text) > 0 {
diceInputEntry.SetText(text[:len(text)-1]) diceInputEntry.SetText(text[:len(text)-1])
} }
}), }),
), rollButton,
container.NewHBox(
createCalcButton("0", diceInputEntry),
widget.NewButton(".", func() {
diceInputEntry.SetText(diceInputEntry.Text + ".")
}),
widget.NewLabel(""),
widget.NewLabel(""),
widget.NewLabel(""),
),
) )
// Output section // Output section
@@ -142,17 +131,21 @@ func main() {
) )
// Main layout: output at top, dice bar below, calculator buttons below that // Main layout: output at top, dice bar below, calculator buttons below that
mainContent := container.NewVBox( mainContent := container.NewBorder(
outputSection, outputSection,
widget.NewCard("Dice Options", "", diceButtonsContainer), container.NewVBox(
widget.NewCard("Calculator", "", numberButtonsContainer),
widget.NewLabel("Dice Expression:"), widget.NewLabel("Dice Expression:"),
diceInputEntry, diceInputEntry,
rollButton, ),
nil,
nil,
container.NewVBox(
widget.NewCard("Dice Options", "", diceButtonsContainer),
widget.NewCard("Calculator", "", numberButtonsContainer),
),
) )
scrollContainer := container.NewScroll(mainContent) myWindow.SetContent(mainContent)
myWindow.SetContent(scrollContainer)
myWindow.Resize(fyne.NewSize(400, 600)) myWindow.Resize(fyne.NewSize(400, 600))
myWindow.ShowAndRun() myWindow.ShowAndRun()
} }