Merge branch 'main' into feature/fix-animations

This commit is contained in:
Alexei Anoshenko 2025-07-01 17:38:50 +03:00
commit f36ee4a4a7
7 changed files with 730 additions and 362 deletions

View File

@ -282,6 +282,15 @@ func (customView *CustomViewData) RemoveView(index int) View {
return nil
}
func (customView *CustomViewData) RemoveViewByID(id string) View {
if customView.superView != nil {
if container, ok := customView.superView.(ViewsContainer); ok {
return container.RemoveViewByID(id)
}
}
return nil
}
// Remove removes a view from the list of a view children and return it
func (customView *CustomViewData) ViewIndex(view View) int {
if customView.superView != nil {

View File

@ -1,6 +1,8 @@
package rui
import "sort"
import (
"slices"
)
// Params defines a type of a parameters list
type Params map[PropertyName]any
@ -51,9 +53,7 @@ func (params Params) AllTags() []PropertyName {
for t := range params {
tags = append(tags, t)
}
sort.Slice(tags, func(i, j int) bool {
return tags[i] < tags[j]
})
slices.Sort(tags)
return tags
}

1039
popup.go

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
package rui
import (
"sort"
"slices"
"strings"
)
@ -33,9 +33,6 @@ type Properties interface {
type propertyList struct {
properties map[PropertyName]any
normalize func(PropertyName) PropertyName
//getFunc func(PropertyName) any
//set func(Properties, PropertyName, any) []PropertyName
//remove func(Properties, PropertyName) []PropertyName
}
type dataProperty struct {
@ -91,9 +88,7 @@ func (properties *propertyList) AllTags() []PropertyName {
for tag := range properties.properties {
tags = append(tags, tag)
}
sort.Slice(tags, func(i, j int) bool {
return tags[i] < tags[j]
})
slices.Sort(tags)
return tags
}
@ -157,7 +152,7 @@ func (data *dataProperty) init() {
}
func (data *dataProperty) Get(tag PropertyName) any {
return propertiesGet(data, data.normalize(tag))
return data.get(data, data.normalize(tag))
}
func (data *dataProperty) Remove(tag PropertyName) {

View File

@ -84,6 +84,7 @@ var intProperties = []PropertyName{
var floatProperties = map[PropertyName]struct{ min, max float64 }{
Opacity: {min: 0, max: 1},
ShowOpacity: {min: 0, max: 1},
NumberPickerMax: {min: -math.MaxFloat64, max: math.MaxFloat64},
NumberPickerMin: {min: -math.MaxFloat64, max: math.MaxFloat64},
NumberPickerStep: {min: -math.MaxFloat64, max: math.MaxFloat64},
@ -93,6 +94,7 @@ var floatProperties = map[PropertyName]struct{ min, max float64 }{
VideoWidth: {min: 0, max: 10000},
VideoHeight: {min: 0, max: 10000},
PushDuration: {min: 0, max: math.MaxFloat64},
ShowDuration: {min: 0, max: math.MaxFloat64},
DragImageXOffset: {min: -math.MaxFloat64, max: math.MaxFloat64},
DragImageYOffset: {min: -math.MaxFloat64, max: math.MaxFloat64},
}
@ -167,6 +169,9 @@ var sizeProperties = map[PropertyName]string{
ItemHeight: string(ItemHeight),
CenterX: string(CenterX),
CenterY: string(CenterX),
ArrowSize: "",
ArrowWidth: "",
ArrowOffset: "",
}
type enumPropertyData struct {
@ -885,10 +890,8 @@ func (data *dataProperty) Set(tag PropertyName, value any) bool {
}
tag = data.normalize(tag)
for _, supported := range data.supportedProperties {
if tag == supported {
return data.set(data, tag, value) != nil
}
if slices.Contains(data.supportedProperties, tag) {
return data.set(data, tag, value) != nil
}
ErrorLogF(`"%s" property is not supported`, string(tag))

View File

@ -976,7 +976,7 @@ func (view *viewData) propertyChanged(tag PropertyName) {
}
default:
if cssTag, ok := sizeProperties[tag]; ok {
if cssTag, ok := sizeProperties[tag]; ok && cssTag != "" {
if size, ok := sizeProperty(view, tag, session); ok {
session.updateCSSProperty(htmlID, cssTag, size.cssString("", session))
} else {

View File

@ -22,6 +22,9 @@ type ViewsContainer interface {
// Remove removes a view from the list of a view children and return it
RemoveView(index int) View
// Remove removes a view from the list of a view children and return it
RemoveViewByID(id string) View
// ViewIndex returns the index of view, -1 overwise
ViewIndex(view View) int
@ -155,6 +158,15 @@ func (container *viewsContainerData) RemoveView(index int) View {
return view
}
func (container *viewsContainerData) RemoveViewByID(id string) View {
for index, view := range container.views {
if view.ID() == id {
return container.RemoveView(index)
}
}
return nil
}
func (container *viewsContainerData) ViewIndex(view View) int {
for index, v := range container.views {
if v == view {