Added AllImageResources() & bug fixing

This commit is contained in:
Alexei Anoshenko 2022-04-21 18:22:17 +03:00
parent 47ca08717d
commit 50cbb10bf6
7 changed files with 26 additions and 14 deletions

View File

@ -2,7 +2,7 @@
* Added "user-data" property * Added "user-data" property
* Added "focusable" property * Added "focusable" property
* Added ReloadTableViewData function * Added ReloadTableViewData, AllImageResources functions
# v0.5.0 # v0.5.0

View File

@ -15,11 +15,11 @@ div {
-ms-user-select: none; -ms-user-select: none;
user-select: none; user-select: none;
} }
/*
div:focus { div:focus {
outline: none; outline: none;
} }
*/
input { input {
margin: 2px; margin: 2px;
padding: 1px; padding: 1px;

View File

@ -1,13 +1,13 @@
theme { theme {
colors = _{ colors = _{
ruiTextColor = #FF000000, ruiTextColor = #FF000000,
ruiDisabledTextColor = #FF202020, ruiDisabledTextColor = #FF808080,
ruiBackgroundColor = #FFFFFFFF, ruiBackgroundColor = #FFFFFFFF,
ruiButtonColor = #FFE0E0E0, ruiButtonColor = #FFE0E0E0,
ruiButtonActiveColor = #FFC0C0C0, ruiButtonActiveColor = #FFC0C0C0,
ruiButtonTextColor = #FF000000, ruiButtonTextColor = #FF000000,
ruiButtonDisabledColor = #FFE0E0E0, ruiButtonDisabledColor = #FFE0E0E0,
ruiButtonDisabledTextColor = #FF202020, ruiButtonDisabledTextColor = #FF808080,
ruiHighlightColor = #FF1A74E8, ruiHighlightColor = #FF1A74E8,
ruiHighlightTextColor = #FFFFFFFF, ruiHighlightTextColor = #FFFFFFFF,
ruiSelectedColor = #FFE0E0E0, ruiSelectedColor = #FFE0E0E0,
@ -19,7 +19,7 @@ theme {
ruiTabBarBackgroundColor = #FFEEEEEE, ruiTabBarBackgroundColor = #FFEEEEEE,
ruiTabColor = #FFD0D0D0, ruiTabColor = #FFD0D0D0,
ruiTabTextColor = #FF202020, ruiTabTextColor = #FF808080,
ruiCurrentTabColor = #FFFFFFFF, ruiCurrentTabColor = #FFFFFFFF,
ruiCurrentTabTextColor = #FF000000, ruiCurrentTabTextColor = #FF000000,
}, },

View File

@ -489,21 +489,21 @@ func (edit *editViewData) htmlProperties(self View, buffer *strings.Builder) {
if hint := GetHint(edit, ""); hint != "" { if hint := GetHint(edit, ""); hint != "" {
buffer.WriteString(` placeholder="`) buffer.WriteString(` placeholder="`)
buffer.WriteString(hint) buffer.WriteString(textToJS(hint))
buffer.WriteByte('"') buffer.WriteByte('"')
} }
buffer.WriteString(` oninput="editViewInputEvent(this)"`) buffer.WriteString(` oninput="editViewInputEvent(this)"`)
if pattern := GetEditViewPattern(edit, ""); pattern != "" { if pattern := GetEditViewPattern(edit, ""); pattern != "" {
buffer.WriteString(` pattern="`) buffer.WriteString(` pattern="`)
buffer.WriteString(pattern) buffer.WriteString(textToJS(pattern))
buffer.WriteByte('"') buffer.WriteByte('"')
} }
if editType != MultiLineText { if editType != MultiLineText {
if text := GetText(edit, ""); text != "" { if text := GetText(edit, ""); text != "" {
buffer.WriteString(` value="`) buffer.WriteString(` value="`)
buffer.WriteString(text) buffer.WriteString(textToJS(text))
buffer.WriteByte('"') buffer.WriteByte('"')
} }
} }
@ -518,10 +518,7 @@ func (edit *editViewData) htmlDisabledProperties(self View, buffer *strings.Buil
func (edit *editViewData) htmlSubviews(self View, buffer *strings.Builder) { func (edit *editViewData) htmlSubviews(self View, buffer *strings.Builder) {
if GetEditViewType(edit, "") == MultiLineText { if GetEditViewType(edit, "") == MultiLineText {
text := strings.ReplaceAll(GetText(edit, ""), `"`, `\"`) buffer.WriteString(textToJS(GetText(edit, "")))
text = strings.ReplaceAll(text, "\n", `\n`)
text = strings.ReplaceAll(text, "\r", `\r`)
buffer.WriteString(strings.ReplaceAll(text, `'`, `\'`))
} }
} }

View File

@ -70,6 +70,7 @@ var intProperties = []string{
} }
var floatProperties = map[string]struct{ min, max float64 }{ var floatProperties = map[string]struct{ min, max float64 }{
Opacity: {min: 0, max: 1},
ScaleX: {min: -math.MaxFloat64, max: math.MaxFloat64}, ScaleX: {min: -math.MaxFloat64, max: math.MaxFloat64},
ScaleY: {min: -math.MaxFloat64, max: math.MaxFloat64}, ScaleY: {min: -math.MaxFloat64, max: math.MaxFloat64},
ScaleZ: {min: -math.MaxFloat64, max: math.MaxFloat64}, ScaleZ: {min: -math.MaxFloat64, max: math.MaxFloat64},

View File

@ -416,3 +416,11 @@ func AllRawResources() []string {
return result return result
} }
func AllImageResources() []string {
result := make([]string, 0, len(resources.images))
for image := range resources.images {
result = append(result, image)
}
return result
}

View File

@ -561,6 +561,12 @@ func viewPropertyChanged(view *viewData, tag string) {
updateCSSProperty(htmlID, `animation-play-state`, `running`, session) updateCSSProperty(htmlID, `animation-play-state`, `running`, session)
} }
return return
case ZIndex:
if i, ok := intProperty(view, ZIndex, session, 0); ok {
updateCSSProperty(htmlID, ZIndex, strconv.Itoa(i), session)
}
return
} }
if cssTag, ok := sizeProperties[tag]; ok { if cssTag, ok := sizeProperties[tag]; ok {
@ -589,7 +595,7 @@ func viewPropertyChanged(view *viewData, tag string) {
return return
} }
for _, floatTag := range []string{ScaleX, ScaleY, ScaleZ, RotateX, RotateY, RotateZ} { for _, floatTag := range []string{Opacity, ScaleX, ScaleY, ScaleZ, RotateX, RotateY, RotateZ} {
if tag == floatTag { if tag == floatTag {
if f, ok := floatProperty(view, floatTag, session, 0); ok { if f, ok := floatProperty(view, floatTag, session, 0); ok {
updateCSSProperty(htmlID, floatTag, strconv.FormatFloat(f, 'g', -1, 64), session) updateCSSProperty(htmlID, floatTag, strconv.FormatFloat(f, 'g', -1, 64), session)