fixed ui problems and added statistical functionality

This commit is contained in:
Grimsace
2026-02-12 09:00:14 -06:00
parent 6dcdac4016
commit e818131376
5 changed files with 538 additions and 39 deletions
+27 -3
View File
@@ -19,15 +19,21 @@ type historyItemRenderer struct {
equationLabel *customLabel
diceRollsLabel *customLabel
resultLabel *customLabel
container fyne.CanvasObject
objects []fyne.CanvasObject
}
func (r *historyItemRenderer) MinSize() fyne.Size {
return r.objects[0].MinSize()
minSize := r.container.MinSize()
// Ensure a minimum height so items don't overlap
if minSize.Height < 90 {
minSize = fyne.NewSize(minSize.Width, 90)
}
return minSize
}
func (r *historyItemRenderer) Layout(size fyne.Size) {
r.objects[0].Resize(size)
r.container.Resize(size)
}
func (r *historyItemRenderer) ApplyTheme() {
@@ -40,6 +46,7 @@ func (r *historyItemRenderer) Refresh() {
r.equationLabel.Refresh()
r.diceRollsLabel.Refresh()
r.resultLabel.Refresh()
r.container.Refresh()
}
func (r *historyItemRenderer) Objects() []fyne.CanvasObject {
@@ -51,7 +58,17 @@ func (r *historyItemRenderer) Destroy() {
type historyItem struct {
widget.BaseWidget
calc *calculation
calc *calculation
onTapped func(equation string)
}
func (h *historyItem) Tapped(*fyne.PointEvent) {
if h.onTapped != nil && h.calc != nil {
h.onTapped(h.calc.equation)
}
}
func (h *historyItem) TappedSecondary(*fyne.PointEvent) {
}
func (h *historyItem) CreateRenderer() fyne.WidgetRenderer {
@@ -75,6 +92,7 @@ func (h *historyItem) CreateRenderer() fyne.WidgetRenderer {
equationLabel: equationLabel,
diceRollsLabel: diceRollsLabel,
resultLabel: resultLabel,
container: layout,
objects: []fyne.CanvasObject{layout},
}
}
@@ -89,3 +107,9 @@ func newHistoryItem(c *calculation) *historyItem {
item.ExtendBaseWidget(item)
return item
}
func newHistoryItemWithCallback(c *calculation, onTapped func(equation string)) *historyItem {
item := &historyItem{calc: c, onTapped: onTapped}
item.ExtendBaseWidget(item)
return item
}