mirror of https://github.com/anoshenko/rui.git
Merge branch 'main' into feature/fix-animations
This commit is contained in:
commit
f36ee4a4a7
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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))
|
||||
|
|
2
view.go
2
view.go
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue