forked from mbk-lab/rui_orig
2
0
Fork 0

Added "order" property

This commit is contained in:
anoshenko 2022-12-18 18:37:36 +03:00
parent c31b2f9d8c
commit 9fe570ec22
5 changed files with 21 additions and 9 deletions

View File

@ -669,4 +669,9 @@ const (
// The "user-select" bool property controls whether the user can select text.
// This is an inherited property, i.e. if it is not defined, then the value of the parent view is used.
UserSelect = "user-select"
// Order is the constant for the "Order" property tag.
// The "Order" int property sets the order to layout an item in a ListLayout or GridLayout container.
// Items in a container are sorted by ascending order value and then by their source code order.
Order = "Order"
)

View File

@ -73,6 +73,7 @@ var intProperties = []string{
RowSpan,
ColumnSpan,
ColumnCount,
Order,
}
var floatProperties = map[string]struct{ min, max float64 }{

View File

@ -577,7 +577,7 @@ func viewPropertyChanged(view *viewData, tag string) {
}
return
case ZIndex, TabSize:
case ZIndex, Order, TabSize:
if i, ok := intProperty(view, tag, session, 0); ok {
session.updateCSSProperty(htmlID, tag, strconv.Itoa(i))
}

View File

@ -193,16 +193,20 @@ func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) {
outline.ViewOutline(session).cssValue(builder, session)
}
if z, ok := intProperty(style, ZIndex, session, 0); ok {
builder.add(ZIndex, strconv.Itoa(z))
for _, tag := range []string{ZIndex, Order} {
if value, ok := intProperty(style, tag, session, 0); ok {
builder.add(tag, strconv.Itoa(value))
}
}
if opacity, ok := floatProperty(style, Opacity, session, 1.0); ok && opacity >= 0 && opacity <= 1 {
builder.add(Opacity, strconv.FormatFloat(opacity, 'f', 3, 32))
}
if n, ok := intProperty(style, ColumnCount, session, 0); ok && n > 0 {
builder.add(ColumnCount, strconv.Itoa(n))
for _, tag := range []string{ColumnCount, TabSize} {
if value, ok := intProperty(style, tag, session, 0); ok && value > 0 {
builder.add(tag, strconv.Itoa(value))
}
}
for _, tag := range []string{
@ -279,10 +283,6 @@ func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) {
}
}
if tabSize, ok := intProperty(style, TabSize, session, 8); ok && tabSize > 0 {
builder.add(TabSize, strconv.Itoa(tabSize))
}
if text := style.cssTextDecoration(session); text != "" {
builder.add("text-decoration", text)
}

View File

@ -159,6 +159,12 @@ func GetZIndex(view View, subviewID ...string) int {
return intStyledProperty(view, subviewID, ZIndex, 0)
}
// GetOrder returns the subview order to layout an item in a ListLayout or GridLayout container.
// If the second argument (subviewID) is not specified or it is "" then an order of the first argument (view) is returned
func GetOrder(view View, subviewID ...string) int {
return intStyledProperty(view, subviewID, Order, 0)
}
// GetWidth returns the subview width.
// If the second argument (subviewID) is not specified or it is "" then a width of the first argument (view) is returned
func GetWidth(view View, subviewID ...string) SizeUnit {