mirror of https://github.com/anoshenko/rui.git
Optimisation
This commit is contained in:
parent
049a2b365f
commit
942d7c45d3
|
@ -926,7 +926,7 @@ func (session *sessionData) registerAnimation(props []AnimatedProperty) string {
|
|||
}
|
||||
|
||||
cssBuilder.startAnimationFrame("from")
|
||||
NewViewStyle(fromParams).cssViewStyle(&cssBuilder, session)
|
||||
writeViewStyleCSS(NewViewStyle(fromParams), &cssBuilder, session)
|
||||
cssBuilder.endAnimationFrame()
|
||||
|
||||
if len(frames) > 0 {
|
||||
|
@ -942,14 +942,14 @@ func (session *sessionData) registerAnimation(props []AnimatedProperty) string {
|
|||
|
||||
if len(params) > 0 {
|
||||
cssBuilder.startAnimationFrame(strconv.Itoa(frame) + "%")
|
||||
NewViewStyle(params).cssViewStyle(&cssBuilder, session)
|
||||
writeViewStyleCSS(NewViewStyle(params), &cssBuilder, session)
|
||||
cssBuilder.endAnimationFrame()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cssBuilder.startAnimationFrame("to")
|
||||
NewViewStyle(toParams).cssViewStyle(&cssBuilder, session)
|
||||
writeViewStyleCSS(NewViewStyle(toParams), &cssBuilder, session)
|
||||
cssBuilder.endAnimationFrame()
|
||||
|
||||
cssBuilder.endAnimation()
|
||||
|
|
11
button.go
11
button.go
|
@ -1,5 +1,7 @@
|
|||
package rui
|
||||
|
||||
import "strings"
|
||||
|
||||
// Button represent a Button view
|
||||
type Button interface {
|
||||
ListLayout
|
||||
|
@ -35,6 +37,15 @@ func (button *buttonData) Focusable() bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func (button *buttonData) htmlSubviews(self View, buffer *strings.Builder) {
|
||||
if button.views != nil {
|
||||
for _, view := range button.views {
|
||||
view.addToCSSStyle(map[string]string{`flex`: `0 0 auto`})
|
||||
viewHTML(view, buffer, "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GetButtonVerticalAlign returns the vertical align of a Button subview:
|
||||
// TopAlign (0), BottomAlign (1), CenterAlign (2), or StretchAlign (3)
|
||||
//
|
||||
|
|
|
@ -128,10 +128,6 @@ func (customView *CustomViewData) Clear() {
|
|||
customView.superView.Clear()
|
||||
}
|
||||
|
||||
func (customView *CustomViewData) cssViewStyle(buffer cssBuilder, session Session) {
|
||||
customView.superView.cssViewStyle(buffer, session)
|
||||
}
|
||||
|
||||
// Session returns a current Session interface
|
||||
func (customView *CustomViewData) Session() Session {
|
||||
return customView.superView.Session()
|
||||
|
|
34
listView.go
34
listView.go
|
@ -802,21 +802,7 @@ func (listView *listViewData) cssStyle(self View, builder cssBuilder) {
|
|||
}
|
||||
*/
|
||||
|
||||
func (listView *listViewData) htmlSubviews(self View, buffer *strings.Builder) {
|
||||
adapter := listView.getAdapter()
|
||||
if adapter == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if listSize := adapter.ListSize(); listSize == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if !listView.session.ignoreViewUpdates() {
|
||||
listView.session.setIgnoreViewUpdates(true)
|
||||
defer listView.session.setIgnoreViewUpdates(false)
|
||||
}
|
||||
|
||||
func listDiv(listView View, buffer *strings.Builder) {
|
||||
buffer.WriteString(`<div style="display: flex; align-content: stretch;`)
|
||||
|
||||
if gap := GetListRowGap(listView); gap.Type != Auto {
|
||||
|
@ -939,6 +925,24 @@ func (listView *listViewData) htmlSubviews(self View, buffer *strings.Builder) {
|
|||
}
|
||||
|
||||
buffer.WriteString(`">`)
|
||||
}
|
||||
|
||||
func (listView *listViewData) htmlSubviews(self View, buffer *strings.Builder) {
|
||||
adapter := listView.getAdapter()
|
||||
if adapter == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if listSize := adapter.ListSize(); listSize == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if !listView.session.ignoreViewUpdates() {
|
||||
listView.session.setIgnoreViewUpdates(true)
|
||||
defer listView.session.setIgnoreViewUpdates(false)
|
||||
}
|
||||
|
||||
listDiv(listView, buffer)
|
||||
|
||||
checkbox := GetListViewCheckbox(listView)
|
||||
if checkbox == NoneCheckbox {
|
||||
|
|
|
@ -1616,7 +1616,7 @@ func tableViewCurrent(view View) CellIndex {
|
|||
|
||||
func (table *tableViewData) cssStyle(self View, builder cssBuilder) {
|
||||
session := table.Session()
|
||||
table.viewData.cssViewStyle(builder, session)
|
||||
writeViewStyleCSS(table, builder, session)
|
||||
|
||||
gap, ok := sizeProperty(table, Gap, session)
|
||||
if !ok || gap.Type == Auto || gap.Value <= 0 {
|
||||
|
|
|
@ -18,7 +18,7 @@ func (cell *tableCellView) init(session Session) {
|
|||
|
||||
func (cell *tableCellView) cssStyle(self View, builder cssBuilder) {
|
||||
session := cell.Session()
|
||||
cell.viewData.cssViewStyle(builder, session)
|
||||
writeViewStyleCSS(cell, builder, session)
|
||||
|
||||
if value, ok := enumProperty(cell, TableVerticalAlign, session, 0); ok {
|
||||
builder.add("vertical-align", enumProperties[TableVerticalAlign].values[value])
|
||||
|
|
4
theme.go
4
theme.go
|
@ -661,7 +661,7 @@ func (theme *theme) cssText(session Session) string {
|
|||
for _, tag := range styleList(theme.styles) {
|
||||
if style := theme.styles[tag]; style != nil {
|
||||
builder.startStyle(tag)
|
||||
style.cssViewStyle(&builder, session)
|
||||
writeViewStyleCSS(style, &builder, session)
|
||||
builder.endStyle()
|
||||
}
|
||||
}
|
||||
|
@ -671,7 +671,7 @@ func (theme *theme) cssText(session Session) string {
|
|||
for _, tag := range styleList(media.styles) {
|
||||
if style := media.styles[tag]; style != nil {
|
||||
builder.startStyle(tag)
|
||||
style.cssViewStyle(&builder, session)
|
||||
writeViewStyleCSS(style, &builder, session)
|
||||
builder.endStyle()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -556,7 +556,7 @@ func (transform *transformPropertyData) transformCSS(session Session) string {
|
|||
return result[:length-1]
|
||||
}
|
||||
|
||||
func (style *viewStyle) writeViewTransformCSS(builder cssBuilder, session Session) {
|
||||
func writeViewTransformCSS(style Properties, builder cssBuilder, session Session) {
|
||||
x, y := getPerspectiveOrigin(style, session)
|
||||
z := AutoSize()
|
||||
if css := transformOriginCSS(x, y, z, session); css != "" {
|
||||
|
|
2
view.go
2
view.go
|
@ -1094,7 +1094,7 @@ func (view *viewData) addToCSSStyle(addCSS map[string]string) {
|
|||
}
|
||||
|
||||
func (view *viewData) cssStyle(self View, builder cssBuilder) {
|
||||
view.viewStyle.cssViewStyle(builder, view.session)
|
||||
writeViewStyleCSS(view, builder, view.session)
|
||||
if view.addCSS != nil {
|
||||
for tag, value := range view.addCSS {
|
||||
builder.add(tag, value)
|
||||
|
|
12
viewStyle.go
12
viewStyle.go
|
@ -22,8 +22,6 @@ type ViewStyle interface {
|
|||
// removes the transition animation of the property if "animation" argument is nil.
|
||||
// The "tag" argument is the property name.
|
||||
SetTransition(tag PropertyName, animation AnimationProperty)
|
||||
|
||||
cssViewStyle(buffer cssBuilder, session Session)
|
||||
}
|
||||
|
||||
type viewStyle struct {
|
||||
|
@ -109,7 +107,7 @@ func split4Values(text string) []string {
|
|||
return []string{}
|
||||
}
|
||||
|
||||
func (style *viewStyle) cssListStyle(builder cssBuilder, session Session) {
|
||||
func writeListStyleCSS(style Properties, builder cssBuilder, session Session) {
|
||||
wrap, _ := enumProperty(style, ListWrap, session, 0)
|
||||
orientation, ok := valueToOrientation(style.Get(Orientation), session)
|
||||
if ok || wrap > 0 {
|
||||
|
@ -189,7 +187,7 @@ func (style *viewStyle) cssListStyle(builder cssBuilder, session Session) {
|
|||
|
||||
}
|
||||
|
||||
func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) {
|
||||
func writeViewStyleCSS(style Properties, builder cssBuilder, session Session) {
|
||||
|
||||
if visibility, ok := enumProperty(style, Visibility, session, Visible); ok {
|
||||
switch visibility {
|
||||
|
@ -355,7 +353,7 @@ func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) {
|
|||
builder.add("text-shadow", css)
|
||||
}
|
||||
|
||||
if value, ok := style.properties[ColumnSeparator]; ok {
|
||||
if value := style.getRaw(ColumnSeparator); value != nil {
|
||||
if separator, ok := value.(ColumnSeparatorProperty); ok {
|
||||
if css := separator.cssValue(session); css != "" {
|
||||
builder.add("column-rule", css)
|
||||
|
@ -371,7 +369,7 @@ func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) {
|
|||
}
|
||||
}
|
||||
|
||||
style.cssListStyle(builder, session)
|
||||
writeListStyleCSS(style, builder, session)
|
||||
|
||||
if r, ok := rangeProperty(style, Row, session); ok {
|
||||
builder.add("grid-row", fmt.Sprintf("%d / %d", r.First+1, r.Last+2))
|
||||
|
@ -386,7 +384,7 @@ func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) {
|
|||
builder.add(`grid-template-rows`, text)
|
||||
}
|
||||
|
||||
style.writeViewTransformCSS(builder, session)
|
||||
writeViewTransformCSS(style, builder, session)
|
||||
|
||||
if clip := getClipShapeProperty(style, Clip, session); clip != nil && clip.valid(session) {
|
||||
builder.add(`clip-path`, clip.cssStyle(session))
|
||||
|
|
Loading…
Reference in New Issue