rui_orig/sessionUtils.go

59 lines
1.4 KiB
Go
Raw Normal View History

2021-09-07 17:36:50 +03:00
package rui
func sizeConstant(session Session, tag string) (SizeUnit, bool) {
if text, ok := session.Constant(tag); ok {
return StringToSizeUnit(text)
}
return AutoSize(), false
}
func updateCSSStyle(htmlID string, session Session) {
if !session.ignoreViewUpdates() {
if view := session.viewByHTMLID(htmlID); view != nil {
2022-10-29 20:16:40 +03:00
builder := viewCSSBuilder{buffer: allocStringBuilder()}
2021-09-07 17:36:50 +03:00
view.cssStyle(view, &builder)
2022-11-02 20:10:19 +03:00
//session.callFunc("updateCSSStyle", view.htmlID(), builder.finish())
2022-10-31 16:07:59 +03:00
session.updateProperty(view.htmlID(), "style", builder.finish())
2021-09-07 17:36:50 +03:00
}
}
}
func updateInnerHTML(htmlID string, session Session) {
if !session.ignoreViewUpdates() {
2022-05-17 10:46:00 +03:00
var view View
if htmlID == "ruiRootView" {
view = session.RootView()
} else {
view = session.viewByHTMLID(htmlID)
}
if view != nil {
2023-05-07 20:58:51 +03:00
session.callFunc("hideTooltip")
2021-09-07 17:36:50 +03:00
script := allocStringBuilder()
defer freeStringBuilder(script)
script.Grow(32 * 1024)
view.htmlSubviews(view, script)
2022-10-30 17:22:33 +03:00
session.updateInnerHTML(view.htmlID(), script.String())
2021-09-07 17:36:50 +03:00
}
}
}
func viewByHTMLID(id string, startView View) View {
if startView != nil {
if startView.htmlID() == id {
return startView
}
2022-11-23 15:10:29 +03:00
if container, ok := startView.(ParentView); ok {
2021-09-07 17:36:50 +03:00
for _, view := range container.Views() {
if view != nil {
if v := viewByHTMLID(id, view); v != nil {
return v
}
}
}
}
}
return nil
}