bug fixes and clean code

This commit is contained in:
2024-09-29 21:22:25 +02:00
parent e873c01e50
commit dd8f1fbc1f
14 changed files with 89 additions and 90 deletions
+10 -7
View File
@@ -8,6 +8,12 @@ import (
"github.com/orus-dev/osui/isKey"
)
type DivParams struct {
Style DivStyle
Width int
Height int
}
type DivStyle struct {
Background string `default:"" type:"bg"`
Foreground string `default:"" type:"fg"`
@@ -82,8 +88,10 @@ func (d *DivComponent) Update(key string) bool {
return false
}
func (d *DivComponent) SetStyle(c interface{}) {
d.Style = osui.SetDefaults(c.(*DivStyle)).(*DivStyle)
func (b *DivComponent) Params(param DivParams) *DivComponent {
b.Style = osui.SetDefaults(&param.Style).(*DivStyle)
b.Data.Width = osui.LogicValueInt(param.Width == 0, 20, param.Width)
return b
}
func (d *DivComponent) updateActive(newIndex int) {
@@ -92,11 +100,6 @@ func (d *DivComponent) updateActive(newIndex int) {
}
}
func (d *DivComponent) AddTo(c *DivComponent) *DivComponent {
*c = *d
return d
}
func Div(components ...osui.Component) *DivComponent {
return &DivComponent{
Components: components,