forked from mbk-lab/rui_orig
Added "order" property
This commit is contained in:
parent
c31b2f9d8c
commit
9fe570ec22
|
@ -669,4 +669,9 @@ const (
|
||||||
// The "user-select" bool property controls whether the user can select text.
|
// 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.
|
// This is an inherited property, i.e. if it is not defined, then the value of the parent view is used.
|
||||||
UserSelect = "user-select"
|
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"
|
||||||
)
|
)
|
||||||
|
|
|
@ -73,6 +73,7 @@ var intProperties = []string{
|
||||||
RowSpan,
|
RowSpan,
|
||||||
ColumnSpan,
|
ColumnSpan,
|
||||||
ColumnCount,
|
ColumnCount,
|
||||||
|
Order,
|
||||||
}
|
}
|
||||||
|
|
||||||
var floatProperties = map[string]struct{ min, max float64 }{
|
var floatProperties = map[string]struct{ min, max float64 }{
|
||||||
|
|
2
view.go
2
view.go
|
@ -577,7 +577,7 @@ func viewPropertyChanged(view *viewData, tag string) {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
||||||
case ZIndex, TabSize:
|
case ZIndex, Order, TabSize:
|
||||||
if i, ok := intProperty(view, tag, session, 0); ok {
|
if i, ok := intProperty(view, tag, session, 0); ok {
|
||||||
session.updateCSSProperty(htmlID, tag, strconv.Itoa(i))
|
session.updateCSSProperty(htmlID, tag, strconv.Itoa(i))
|
||||||
}
|
}
|
||||||
|
|
16
viewStyle.go
16
viewStyle.go
|
@ -193,16 +193,20 @@ func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) {
|
||||||
outline.ViewOutline(session).cssValue(builder, session)
|
outline.ViewOutline(session).cssValue(builder, session)
|
||||||
}
|
}
|
||||||
|
|
||||||
if z, ok := intProperty(style, ZIndex, session, 0); ok {
|
for _, tag := range []string{ZIndex, Order} {
|
||||||
builder.add(ZIndex, strconv.Itoa(z))
|
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 {
|
if opacity, ok := floatProperty(style, Opacity, session, 1.0); ok && opacity >= 0 && opacity <= 1 {
|
||||||
builder.add(Opacity, strconv.FormatFloat(opacity, 'f', 3, 32))
|
builder.add(Opacity, strconv.FormatFloat(opacity, 'f', 3, 32))
|
||||||
}
|
}
|
||||||
|
|
||||||
if n, ok := intProperty(style, ColumnCount, session, 0); ok && n > 0 {
|
for _, tag := range []string{ColumnCount, TabSize} {
|
||||||
builder.add(ColumnCount, strconv.Itoa(n))
|
if value, ok := intProperty(style, tag, session, 0); ok && value > 0 {
|
||||||
|
builder.add(tag, strconv.Itoa(value))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tag := range []string{
|
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 != "" {
|
if text := style.cssTextDecoration(session); text != "" {
|
||||||
builder.add("text-decoration", text)
|
builder.add("text-decoration", text)
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,6 +159,12 @@ func GetZIndex(view View, subviewID ...string) int {
|
||||||
return intStyledProperty(view, subviewID, ZIndex, 0)
|
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.
|
// 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
|
// 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 {
|
func GetWidth(view View, subviewID ...string) SizeUnit {
|
||||||
|
|
Loading…
Reference in New Issue