reworked layout

This commit is contained in:
Grimsace
2026-02-10 08:21:03 -06:00
parent 80b1cbd923
commit 78c58393f2
+87 -94
View File
@@ -25,41 +25,37 @@ 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") }),
}), widget.NewButton("d6", func() {
widget.NewButton("d6", func() { diceInputEntry.SetText(diceInputEntry.Text + "d6")
diceInputEntry.SetText(diceInputEntry.Text + "d6") }),
}), widget.NewButton("d8", func() {
widget.NewButton("d8", func() { diceInputEntry.SetText(diceInputEntry.Text + "d8")
diceInputEntry.SetText(diceInputEntry.Text + "d8") }),
}), widget.NewButton("d10", func() {
widget.NewButton("d10", func() { diceInputEntry.SetText(diceInputEntry.Text + "d10")
diceInputEntry.SetText(diceInputEntry.Text + "d10") }),
}), widget.NewButton("d12", func() {
widget.NewButton("d12", func() { diceInputEntry.SetText(diceInputEntry.Text + "d12")
diceInputEntry.SetText(diceInputEntry.Text + "d12") }),
}), widget.NewButton("d20", func() {
), diceInputEntry.SetText(diceInputEntry.Text + "d20")
container.NewHBox( }),
widget.NewButton("d20", func() { widget.NewButton("d100", func() {
diceInputEntry.SetText(diceInputEntry.Text + "d20") diceInputEntry.SetText(diceInputEntry.Text + "d100")
}), }),
widget.NewButton("d100", func() { widget.NewButton("dx", func() {
diceInputEntry.SetText(diceInputEntry.Text + "d100") diceInputEntry.SetText(diceInputEntry.Text + "dx")
}), }),
widget.NewButton("dx", func() { widget.NewButton("H", func() {
diceInputEntry.SetText(diceInputEntry.Text + "dx") diceInputEntry.SetText(diceInputEntry.Text + "H")
}), }),
widget.NewButton("H", func() { widget.NewButton("L", func() {
diceInputEntry.SetText(diceInputEntry.Text + "H") diceInputEntry.SetText(diceInputEntry.Text + "L")
}), }),
widget.NewButton("L", func() {
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
clearButton := widget.NewButton("CLEAR", func() {
diceInputEntry.SetText("")
outputDisplay.Text = "0"
outputDisplay.Refresh()
})
// Calculator-style number buttons // Calculator-style number buttons
numberButtonsContainer := container.NewVBox( numberButtonsContainer := container.NewGridWithColumns(4,
container.NewHBox( widget.NewButton("AC", func() {
createCalcButton("7", diceInputEntry), diceInputEntry.SetText("")
createCalcButton("8", diceInputEntry), outputDisplay.Text = "0"
createCalcButton("9", diceInputEntry), outputDisplay.Refresh()
widget.NewButton("+", func() { }),
diceInputEntry.SetText(diceInputEntry.Text + "+") widget.NewButton("()", func() {
}), // TODO: Implement parenthesis logic
widget.NewButton("-", func() { }),
diceInputEntry.SetText(diceInputEntry.Text + "-") widget.NewButton("%", func() {
}), diceInputEntry.SetText(diceInputEntry.Text + "%")
), }),
container.NewHBox( widget.NewButton("÷", func() {
createCalcButton("4", diceInputEntry), diceInputEntry.SetText(diceInputEntry.Text + "/")
createCalcButton("5", diceInputEntry), }),
createCalcButton("6", diceInputEntry), createCalcButton("7", diceInputEntry),
widget.NewButton("*", func() { createCalcButton("8", diceInputEntry),
diceInputEntry.SetText(diceInputEntry.Text + "*") createCalcButton("9", diceInputEntry),
}), widget.NewButton("x", func() {
widget.NewButton("/", func() { diceInputEntry.SetText(diceInputEntry.Text + "*")
diceInputEntry.SetText(diceInputEntry.Text + "/") }),
}), createCalcButton("4", diceInputEntry),
), createCalcButton("5", diceInputEntry),
container.NewHBox( createCalcButton("6", diceInputEntry),
createCalcButton("1", diceInputEntry), widget.NewButton("-", func() {
createCalcButton("2", diceInputEntry), diceInputEntry.SetText(diceInputEntry.Text + "-")
createCalcButton("3", diceInputEntry), }),
clearButton, createCalcButton("1", diceInputEntry),
widget.NewButton("Backspace", func() { createCalcButton("2", diceInputEntry),
text := diceInputEntry.Text createCalcButton("3", diceInputEntry),
if len(text) > 0 { widget.NewButton("+", func() {
diceInputEntry.SetText(text[:len(text)-1]) diceInputEntry.SetText(diceInputEntry.Text + "+")
} }),
}), createCalcButton("0", diceInputEntry),
), widget.NewButton(".", func() {
container.NewHBox( diceInputEntry.SetText(diceInputEntry.Text + ".")
createCalcButton("0", diceInputEntry), }),
widget.NewButton(".", func() { widget.NewButton("", func() {
diceInputEntry.SetText(diceInputEntry.Text + ".") text := diceInputEntry.Text
}), if len(text) > 0 {
widget.NewLabel(""), diceInputEntry.SetText(text[:len(text)-1])
widget.NewLabel(""), }
widget.NewLabel(""), }),
), rollButton,
) )
// 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()
} }