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:
parent
25625e9a99
commit
34794f4c77
16
dialog.go
16
dialog.go
@ -24,8 +24,8 @@ type clickable interface {
|
|||||||
OnClick (func ()) event.Cookie
|
OnClick (func ()) event.Cookie
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new dialog window given a dialog kind.
|
// NewDialog creates a new dialog window given a dialog kind.
|
||||||
func (kind DialogKind) New (parent tomo.Window, title, message string, options ...tomo.Object) (*Dialog, error) {
|
func NewDialog (kind DialogKind, parent tomo.Window, title, message string, options ...tomo.Object) (*Dialog, error) {
|
||||||
if title == "" {
|
if title == "" {
|
||||||
switch kind {
|
switch kind {
|
||||||
case DialogInformation: title = "Information"
|
case DialogInformation: title = "Information"
|
||||||
@ -73,8 +73,8 @@ func (kind DialogKind) New (parent tomo.Window, title, message string, options .
|
|||||||
return dialog, nil
|
return dialog, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewOk creates a new dialog window with an OK option.
|
// NewDialogOk creates a new dialog window with an OK option.
|
||||||
func (kind DialogKind) NewOk (parent tomo.Window, title, message string, onOk func ()) (*Dialog, error) {
|
func NewDialogOk (kind DialogKind, parent tomo.Window, title, message string, onOk func ()) (*Dialog, error) {
|
||||||
okButton := NewButton("OK")
|
okButton := NewButton("OK")
|
||||||
okButton.SetIcon(theme.IconStatusOkay)
|
okButton.SetIcon(theme.IconStatusOkay)
|
||||||
okButton.OnClick(func () {
|
okButton.OnClick(func () {
|
||||||
@ -82,11 +82,11 @@ func (kind DialogKind) NewOk (parent tomo.Window, title, message string, onOk fu
|
|||||||
})
|
})
|
||||||
okButton.SetFocused(true)
|
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.
|
// NewDialogOkCancel creates a new dialog window with OK and Cancel options.
|
||||||
func (kind DialogKind) NewOkCancel (parent tomo.Window, title, message string, onOk func ()) (*Dialog, error) {
|
func NewDialogOkCancel (kind DialogKind, parent tomo.Window, title, message string, onOk func ()) (*Dialog, error) {
|
||||||
cancelButton := NewButton("Cancel")
|
cancelButton := NewButton("Cancel")
|
||||||
cancelButton.SetIcon(theme.IconStatusCancel)
|
cancelButton.SetIcon(theme.IconStatusCancel)
|
||||||
|
|
||||||
@ -97,5 +97,5 @@ func (kind DialogKind) NewOkCancel (parent tomo.Window, title, message string, o
|
|||||||
})
|
})
|
||||||
okButton.SetFocused(true)
|
okButton.SetFocused(true)
|
||||||
|
|
||||||
return kind.New(parent, title, message, cancelButton, okButton)
|
return NewDialog(kind, parent, title, message, cancelButton, okButton)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user