Make the dialog API more normal

It was very nice but inconsistent with literally everything else,
and never in my life have I seen someone else make a constructor
that way.
This commit is contained in:
Sasha Koshka 2024-05-18 14:16:57 -04:00
parent 25625e9a99
commit 34794f4c77

View File

@ -24,8 +24,8 @@ type clickable interface {
OnClick (func ()) event.Cookie
}
// New creates a new dialog window given a dialog kind.
func (kind DialogKind) New (parent tomo.Window, title, message string, options ...tomo.Object) (*Dialog, error) {
// NewDialog creates a new dialog window given a dialog kind.
func NewDialog (kind DialogKind, parent tomo.Window, title, message string, options ...tomo.Object) (*Dialog, error) {
if title == "" {
switch kind {
case DialogInformation: title = "Information"
@ -73,8 +73,8 @@ func (kind DialogKind) New (parent tomo.Window, title, message string, options .
return dialog, nil
}
// NewOk creates a new dialog window with an OK option.
func (kind DialogKind) NewOk (parent tomo.Window, title, message string, onOk func ()) (*Dialog, error) {
// NewDialogOk creates a new dialog window with an OK option.
func NewDialogOk (kind DialogKind, parent tomo.Window, title, message string, onOk func ()) (*Dialog, error) {
okButton := NewButton("OK")
okButton.SetIcon(theme.IconStatusOkay)
okButton.OnClick(func () {
@ -82,11 +82,11 @@ func (kind DialogKind) NewOk (parent tomo.Window, title, message string, onOk fu
})
okButton.SetFocused(true)
return kind.New(parent, title, message, okButton)
return NewDialog(kind, parent, title, message, okButton)
}
// NewOkCancel creates a new dialog window with OK and Cancel options.
func (kind DialogKind) NewOkCancel (parent tomo.Window, title, message string, onOk func ()) (*Dialog, error) {
// NewDialogOkCancel creates a new dialog window with OK and Cancel options.
func NewDialogOkCancel (kind DialogKind, parent tomo.Window, title, message string, onOk func ()) (*Dialog, error) {
cancelButton := NewButton("Cancel")
cancelButton.SetIcon(theme.IconStatusCancel)
@ -97,5 +97,5 @@ func (kind DialogKind) NewOkCancel (parent tomo.Window, title, message string, o
})
okButton.SetFocused(true)
return kind.New(parent, title, message, cancelButton, okButton)
return NewDialog(kind, parent, title, message, cancelButton, okButton)
}