Skip to content

Commit

Permalink
feat: OverflowBox widget model (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
lesleysin authored May 2, 2024
1 parent da7f8ff commit f2af92b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/duit_attributes/duit_flex/overflow_box_fit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package duit_flex

type OverflowBoxFit string

const (
Max OverflowBoxFit = "max"
DeferToChild OverflowBoxFit = "deferToChild"
)
15 changes: 15 additions & 0 deletions pkg/duit_attributes/overflow_box_attributes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package duit_attributes

import (
"github.com/lesleysin/duit_go/pkg/duit_attributes/duit_alignment"
"github.com/lesleysin/duit_go/pkg/duit_attributes/duit_flex"
)

type OverflowBoxAttributes struct {
MinWidth float32 `json:"minWidth,omitempty"`
MaxWidth float32 `json:"maxWidth,omitempty"`
MinHeight float32 `json:"minHeight,omitempty"`
MaxHeight float32 `json:"maxHeight,omitempty"`
Alignment duit_alignment.Alignment `json:"alignment,omitempty"`
Fit duit_flex.OverflowBoxFit `json:"fit,omitempty"`
}
1 change: 1 addition & 0 deletions pkg/duit_core/element_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ const (
Meta DuitElementType = "Meta"
ListView DuitElementType = "ListView"
RepaintBoundary DuitElementType = "RepaintBoundary"
OverflowBox DuitElementType = "OverflowBox"
)
10 changes: 10 additions & 0 deletions pkg/duit_widget/overflow_box.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package duit_widget

import (
"github.com/lesleysin/duit_go/pkg/duit_attributes"
"github.com/lesleysin/duit_go/pkg/duit_core"
)

func OverflowBoxUiElement(attributes *duit_attributes.OverflowBoxAttributes, id string, controlled bool) *duit_core.DuitElementModel {
return new(duit_core.DuitElementModel).CreateElement(duit_core.OverflowBox, id, "", attributes, nil, controlled, 1, nil)
}

0 comments on commit f2af92b

Please sign in to comment.