Optimisation

This commit is contained in:
Alexei Anoshenko 2024-11-24 15:43:31 +02:00
parent ed639c94c6
commit 6b2a5b4aee
24 changed files with 132 additions and 441 deletions

View File

@ -7,7 +7,7 @@
* Changed Push and Pop method of StackLayout interface. * Changed Push and Pop method of StackLayout interface.
* Removed DefaultAnimation, StartToEndAnimation, EndToStartAnimation, TopDownAnimation, and BottomUpAnimation constants. * Removed DefaultAnimation, StartToEndAnimation, EndToStartAnimation, TopDownAnimation, and BottomUpAnimation constants.
* Added "push-transform", "push-duration", "push-timing", and "move-to-front-animation" properties. * Added "push-transform", "push-duration", "push-timing", and "move-to-front-animation" properties.
* Added GetPushDuration, GetPushTiming, and IsMoveToFrontAnimation functions. * Added GetPushTransform, GetPushDuration, GetPushTiming, and IsMoveToFrontAnimation functions.
* Added LineJoin type. Type of constants MiterJoin, RoundJoin, and BevelJoin changed to LineJoin. Type of Canvas.SetLineJoin function argument changed to LineJoin. * Added LineJoin type. Type of constants MiterJoin, RoundJoin, and BevelJoin changed to LineJoin. Type of Canvas.SetLineJoin function argument changed to LineJoin.
* Added LineCap type. Type of constants ButtCap, RoundCap, and SquareCap changed to LineCap. Type of Canvas.SetLineCap function argument changed to LineCap. * Added LineCap type. Type of constants ButtCap, RoundCap, and SquareCap changed to LineCap. Type of Canvas.SetLineCap function argument changed to LineCap.

View File

@ -981,11 +981,7 @@ func IsAnimationPaused(view View, subviewID ...string) bool {
// GetTransitions returns the subview transitions. The result is always non-nil. // GetTransitions returns the subview transitions. The result is always non-nil.
// If the second argument (subviewID) is not specified or it is "" then transitions of the first argument (view) is returned // If the second argument (subviewID) is not specified or it is "" then transitions of the first argument (view) is returned
func GetTransitions(view View, subviewID ...string) map[PropertyName]Animation { func GetTransitions(view View, subviewID ...string) map[PropertyName]Animation {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
return view.Transitions() return view.Transitions()
} }
@ -1025,11 +1021,7 @@ func AddTransition(view View, subviewID string, tag PropertyName, animation Anim
// GetAnimation returns the subview animations. The result is always non-nil. // GetAnimation returns the subview animations. The result is always non-nil.
// If the second argument (subviewID) is not specified or it is "" then transitions of the first argument (view) is returned // If the second argument (subviewID) is not specified or it is "" then transitions of the first argument (view) is returned
func GetAnimation(view View, subviewID ...string) []Animation { func GetAnimation(view View, subviewID ...string) []Animation {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if value := view.getRaw(AnimationTag); value != nil { if value := view.getRaw(AnimationTag); value != nil {
if animations, ok := value.([]Animation); ok && animations != nil { if animations, ok := value.([]Animation); ok && animations != nil {
return animations return animations

View File

@ -174,10 +174,7 @@ func (picker *colorPickerData) handleCommand(self View, command PropertyName, da
// GetColorPickerValue returns the value of ColorPicker subview. // GetColorPickerValue returns the value of ColorPicker subview.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetColorPickerValue(view View, subviewID ...string) Color { func GetColorPickerValue(view View, subviewID ...string) Color {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if value, ok := colorProperty(view, ColorPickerValue, view.Session()); ok { if value, ok := colorProperty(view, ColorPickerValue, view.Session()); ok {
return value return value
} }

View File

@ -199,11 +199,7 @@ func GetColumnGap(view View, subviewID ...string) SizeUnit {
} }
func getColumnSeparator(view View, subviewID []string) ViewBorder { func getColumnSeparator(view View, subviewID []string) ViewBorder {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
value := view.Get(ColumnSeparator) value := view.Get(ColumnSeparator)
if value == nil { if value == nil {
value = valueFromStyle(view, ColumnSeparator) value = valueFromStyle(view, ColumnSeparator)

View File

@ -322,83 +322,10 @@ func dataListHtmlProperties(view View, buffer *strings.Builder) {
} }
} }
/*
func (list *dataList) setDataList(view View, value any, created bool) bool {
items, ok := anyToStringArray(value)
if !ok {
notCompatibleType(DataList, value)
return false
}
list.dataList = items
if created {
session := view.Session()
dataListID := dataListID(view)
buffer := allocStringBuilder()
defer freeStringBuilder(buffer)
if list.dataListHtml {
list.dataListItemsHtml(buffer)
session.updateInnerHTML(dataListID, buffer.String())
} else {
list.dataListHtmlCode(view, buffer)
session.appendToInnerHTML(view.parentHTMLID(), buffer.String())
list.dataListHtml = true
session.updateProperty(view.htmlID(), "list", dataListID)
}
}
return true
}
func (list *dataList) dataListHtmlSubviews(view View, buffer *strings.Builder) {
if len(list.dataList) > 0 {
list.dataListHtmlCode(view, buffer)
list.dataListHtml = true
} else {
list.dataListHtml = false
}
}
func (list *dataList) dataListHtmlCode(view View, buffer *strings.Builder) {
buffer.WriteString(`<datalist id="`)
buffer.WriteString(dataListID(view))
buffer.WriteString(`">`)
list.dataListItemsHtml(buffer)
buffer.WriteString(`</datalist>`)
}
func (list *dataList) dataListItemsHtml(buffer *strings.Builder) {
for _, text := range list.dataList {
if strings.ContainsRune(text, '"') {
text = strings.ReplaceAll(text, `"`, `&#34;`)
}
if strings.ContainsRune(text, '\n') {
text = strings.ReplaceAll(text, "\n", `\n`)
}
buffer.WriteString(`<option value="`)
buffer.WriteString(text)
buffer.WriteString(`"></option>`)
}
}
func (list *dataList) dataListHtmlProperties(view View, buffer *strings.Builder) {
if len(list.dataList) > 0 {
buffer.WriteString(` list="`)
buffer.WriteString(dataListID(view))
buffer.WriteString(`"`)
}
}
*/
// GetDataList returns the data list of an editor. // GetDataList returns the data list of an editor.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetDataList(view View, subviewID ...string) []string { func GetDataList(view View, subviewID ...string) []string {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
return getDataListProperty(view) return getDataListProperty(view)
} }

View File

@ -402,10 +402,7 @@ func getDateProperty(view View, mainTag, shortTag PropertyName) (time.Time, bool
// "false" as the second value otherwise. // "false" as the second value otherwise.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetDatePickerMin(view View, subviewID ...string) (time.Time, bool) { func GetDatePickerMin(view View, subviewID ...string) (time.Time, bool) {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
return getDateProperty(view, DatePickerMin, Min) return getDateProperty(view, DatePickerMin, Min)
} }
return time.Now(), false return time.Now(), false
@ -415,10 +412,7 @@ func GetDatePickerMin(view View, subviewID ...string) (time.Time, bool) {
// "false" as the second value otherwise. // "false" as the second value otherwise.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetDatePickerMax(view View, subviewID ...string) (time.Time, bool) { func GetDatePickerMax(view View, subviewID ...string) (time.Time, bool) {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
return getDateProperty(view, DatePickerMax, Max) return getDateProperty(view, DatePickerMax, Max)
} }
return time.Now(), false return time.Now(), false
@ -433,10 +427,7 @@ func GetDatePickerStep(view View, subviewID ...string) int {
// GetDatePickerValue returns the date of DatePicker subview. // GetDatePickerValue returns the date of DatePicker subview.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetDatePickerValue(view View, subviewID ...string) time.Time { func GetDatePickerValue(view View, subviewID ...string) time.Time {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view == nil {
view = ViewByID(view, subviewID[0])
}
if view == nil {
return time.Now() return time.Now()
} }
date, _ := getDateProperty(view, DatePickerValue, Value) date, _ := getDateProperty(view, DatePickerValue, Value)

View File

@ -171,10 +171,7 @@ func (detailsView *detailsViewData) handleCommand(self View, command PropertyNam
// GetDetailsSummary returns a value of the Summary property of DetailsView. // GetDetailsSummary returns a value of the Summary property of DetailsView.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetDetailsSummary(view View, subviewID ...string) View { func GetDetailsSummary(view View, subviewID ...string) View {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if value := view.Get(Summary); value != nil { if value := view.Get(Summary); value != nil {
switch value := value.(type) { switch value := value.(type) {
case string: case string:

View File

@ -267,10 +267,7 @@ func GetDropDownListeners(view View, subviewID ...string) []func(DropDownList, i
// GetDropDownItems return the DropDownList items list. // GetDropDownItems return the DropDownList items list.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetDropDownItems(view View, subviewID ...string) []string { func GetDropDownItems(view View, subviewID ...string) []string {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if value := view.Get(Items); value != nil { if value := view.Get(Items); value != nil {
if items, ok := value.([]string); ok { if items, ok := value.([]string); ok {
return items return items
@ -313,19 +310,13 @@ func getIndicesArray(view View, tag PropertyName) []int {
// GetDropDownDisabledItems return an array of disabled(non selectable) items indices of DropDownList. // GetDropDownDisabledItems return an array of disabled(non selectable) items indices of DropDownList.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetDropDownDisabledItems(view View, subviewID ...string) []int { func GetDropDownDisabledItems(view View, subviewID ...string) []int {
if len(subviewID) > 0 && subviewID[0] != "" { view = getSubview(view, subviewID)
view = ViewByID(view, subviewID[0])
}
return getIndicesArray(view, DisabledItems) return getIndicesArray(view, DisabledItems)
} }
// GetDropDownItemSeparators return an array of indices of DropDownList items after which a separator should be added. // GetDropDownItemSeparators return an array of indices of DropDownList items after which a separator should be added.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetDropDownItemSeparators(view View, subviewID ...string) []int { func GetDropDownItemSeparators(view View, subviewID ...string) []int {
if len(subviewID) > 0 && subviewID[0] != "" { view = getSubview(view, subviewID)
view = ViewByID(view, subviewID[0])
}
return getIndicesArray(view, ItemSeparators) return getIndicesArray(view, ItemSeparators)
} }

View File

@ -398,10 +398,7 @@ func (edit *editViewData) handleCommand(self View, command PropertyName, data Da
// GetText returns a text of the EditView subview. // GetText returns a text of the EditView subview.
// If the second argument (subviewID) is not specified or it is "" then a text of the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a text of the first argument (view) is returned.
func GetText(view View, subviewID ...string) string { func GetText(view View, subviewID ...string) string {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if value := view.getRaw(Text); value != nil { if value := view.getRaw(Text); value != nil {
if text, ok := value.(string); ok { if text, ok := value.(string); ok {
return text return text
@ -414,9 +411,7 @@ func GetText(view View, subviewID ...string) string {
// GetHint returns a hint text of the subview. // GetHint returns a hint text of the subview.
// If the second argument (subviewID) is not specified or it is "" then a text of the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a text of the first argument (view) is returned.
func GetHint(view View, subviewID ...string) string { func GetHint(view View, subviewID ...string) string {
if len(subviewID) > 0 && subviewID[0] != "" { view = getSubview(view, subviewID)
view = ViewByID(view, subviewID[0])
}
session := view.Session() session := view.Session()
text := "" text := ""
@ -477,10 +472,7 @@ func GetEditViewType(view View, subviewID ...string) int {
// GetEditViewPattern returns a value of the Pattern property of EditView. // GetEditViewPattern returns a value of the Pattern property of EditView.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetEditViewPattern(view View, subviewID ...string) string { func GetEditViewPattern(view View, subviewID ...string) string {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if pattern, ok := stringProperty(view, EditViewPattern, view.Session()); ok { if pattern, ok := stringProperty(view, EditViewPattern, view.Session()); ok {
return pattern return pattern
} }

View File

@ -411,10 +411,7 @@ func valueToTwoArgEventListeners[V View, E any](value any) ([]func(V, E, E), boo
} }
func getNoArgEventListeners[V View](view View, subviewID []string, tag PropertyName) []func(V) { func getNoArgEventListeners[V View](view View, subviewID []string, tag PropertyName) []func(V) {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if value := view.Get(tag); value != nil { if value := view.Get(tag); value != nil {
if result, ok := value.([]func(V)); ok { if result, ok := value.([]func(V)); ok {
return result return result
@ -425,10 +422,7 @@ func getNoArgEventListeners[V View](view View, subviewID []string, tag PropertyN
} }
func getOneArgEventListeners[V View, E any](view View, subviewID []string, tag PropertyName) []func(V, E) { func getOneArgEventListeners[V View, E any](view View, subviewID []string, tag PropertyName) []func(V, E) {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if value := view.Get(tag); value != nil { if value := view.Get(tag); value != nil {
if result, ok := value.([]func(V, E)); ok { if result, ok := value.([]func(V, E)); ok {
return result return result
@ -439,10 +433,7 @@ func getOneArgEventListeners[V View, E any](view View, subviewID []string, tag P
} }
func getTwoArgEventListeners[V View, E any](view View, subviewID []string, tag PropertyName) []func(V, E, E) { func getTwoArgEventListeners[V View, E any](view View, subviewID []string, tag PropertyName) []func(V, E, E) {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if value := view.Get(tag); value != nil { if value := view.Get(tag); value != nil {
if result, ok := value.([]func(V, E, E)); ok { if result, ok := value.([]func(V, E, E)); ok {
return result return result

View File

@ -345,10 +345,7 @@ func IsMultipleFilePicker(view View, subviewID ...string) bool {
// GetFilePickerAccept returns sets the list of allowed file extensions or MIME types. // GetFilePickerAccept returns sets the list of allowed file extensions or MIME types.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetFilePickerAccept(view View, subviewID ...string) []string { func GetFilePickerAccept(view View, subviewID ...string) []string {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
accept, ok := stringProperty(view, Accept, view.Session()) accept, ok := stringProperty(view, Accept, view.Session())
if !ok { if !ok {
if value := valueFromStyle(view, Accept); value != nil { if value := valueFromStyle(view, Accept); value != nil {

View File

@ -533,10 +533,7 @@ func GetGridAutoFlow(view View, subviewID ...string) int {
// If the result is a single value array, then the width of all cell is equal. // If the result is a single value array, then the width of all cell is equal.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetCellWidth(view View, subviewID ...string) []SizeUnit { func GetCellWidth(view View, subviewID ...string) []SizeUnit {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
return gridCellSizes(view, CellWidth, view.Session()) return gridCellSizes(view, CellWidth, view.Session())
} }
return []SizeUnit{} return []SizeUnit{}
@ -546,10 +543,7 @@ func GetCellWidth(view View, subviewID ...string) []SizeUnit {
// If the result is a single value array, then the height of all cell is equal. // If the result is a single value array, then the height of all cell is equal.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetCellHeight(view View, subviewID ...string) []SizeUnit { func GetCellHeight(view View, subviewID ...string) []SizeUnit {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
return gridCellSizes(view, CellHeight, view.Session()) return gridCellSizes(view, CellHeight, view.Session())
} }
return []SizeUnit{} return []SizeUnit{}

View File

@ -329,11 +329,7 @@ func (imageView *imageViewData) CurrentSource() string {
// GetImageViewSource returns the image URL of an ImageView subview. // GetImageViewSource returns the image URL of an ImageView subview.
// If the second argument (subviewID) is not specified or it is "" then a left position of the first argument (view) is returned // If the second argument (subviewID) is not specified or it is "" then a left position of the first argument (view) is returned
func GetImageViewSource(view View, subviewID ...string) string { func GetImageViewSource(view View, subviewID ...string) string {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if image, ok := imageProperty(view, Source, view.Session()); ok { if image, ok := imageProperty(view, Source, view.Session()); ok {
return image return image
} }
@ -345,11 +341,7 @@ func GetImageViewSource(view View, subviewID ...string) string {
// GetImageViewAltText returns an alternative text description of an ImageView subview. // GetImageViewAltText returns an alternative text description of an ImageView subview.
// If the second argument (subviewID) is not specified or it is "" then a left position of the first argument (view) is returned // If the second argument (subviewID) is not specified or it is "" then a left position of the first argument (view) is returned
func GetImageViewAltText(view View, subviewID ...string) string { func GetImageViewAltText(view View, subviewID ...string) string {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if value := view.getRaw(AltText); value != nil { if value := view.getRaw(AltText); value != nil {
if text, ok := value.(string); ok { if text, ok := value.(string); ok {
text, _ = view.Session().GetString(text) text, _ = view.Session().GetString(text)

View File

@ -222,11 +222,7 @@ func GetListHorizontalAlign(view View, subviewID ...string) int {
// TopDownOrientation (0), StartToEndOrientation (1), BottomUpOrientation (2), or EndToStartOrientation (3) // TopDownOrientation (0), StartToEndOrientation (1), BottomUpOrientation (2), or EndToStartOrientation (3)
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetListOrientation(view View, subviewID ...string) int { func GetListOrientation(view View, subviewID ...string) int {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if orientation, ok := valueToOrientation(view.Get(Orientation), view.Session()); ok { if orientation, ok := valueToOrientation(view.Get(Orientation), view.Session()); ok {
return orientation return orientation
} }
@ -264,11 +260,7 @@ func GetListColumnGap(view View, subviewID ...string) SizeUnit {
// otherwise does nothing. // otherwise does nothing.
// If the second argument (subviewID) is not specified or it is "" then the first argument (view) updates. // If the second argument (subviewID) is not specified or it is "" then the first argument (view) updates.
func UpdateContent(view View, subviewID ...string) { func UpdateContent(view View, subviewID ...string) {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
switch view := view.(type) { switch view := view.(type) {
case GridLayout: case GridLayout:
view.UpdateGridContent() view.UpdateGridContent()
@ -278,6 +270,9 @@ func UpdateContent(view View, subviewID ...string) {
case ListView: case ListView:
view.ReloadListViewData() view.ReloadListViewData()
case TableView:
view.ReloadTableData()
} }
} }
} }

View File

@ -1098,11 +1098,7 @@ func GetListViewCheckbox(view View, subviewID ...string) int {
// GetListViewCheckedItems returns the array of ListView checked items. // GetListViewCheckedItems returns the array of ListView checked items.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetListViewCheckedItems(view View, subviewID ...string) []int { func GetListViewCheckedItems(view View, subviewID ...string) []int {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if value := view.getRaw(Checked); value != nil { if value := view.getRaw(Checked); value != nil {
if checkedItems, ok := value.([]int); ok { if checkedItems, ok := value.([]int); ok {
switch GetListViewCheckbox(view) { switch GetListViewCheckbox(view) {
@ -1179,10 +1175,7 @@ func GetListItemFrame(view View, subviewID string, index int) Frame {
// GetListViewAdapter - returns the ListView adapter. // GetListViewAdapter - returns the ListView adapter.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetListViewAdapter(view View, subviewID ...string) ListAdapter { func GetListViewAdapter(view View, subviewID ...string) ListAdapter {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if value := view.Get(Items); value != nil { if value := view.Get(Items); value != nil {
if adapter, ok := value.(ListAdapter); ok { if adapter, ok := value.(ListAdapter); ok {
return adapter return adapter
@ -1195,11 +1188,7 @@ func GetListViewAdapter(view View, subviewID ...string) ListAdapter {
// ReloadListViewData updates ListView content // ReloadListViewData updates ListView content
// If the second argument (subviewID) is not specified or it is "" then content the first argument (view) is updated. // If the second argument (subviewID) is not specified or it is "" then content the first argument (view) is updated.
func ReloadListViewData(view View, subviewID ...string) { func ReloadListViewData(view View, subviewID ...string) {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if listView, ok := view.(ListView); ok { if listView, ok := view.(ListView); ok {
listView.ReloadListViewData() listView.ReloadListViewData()
} }

View File

@ -304,12 +304,8 @@ func GetNumberPickerType(view View, subviewID ...string) int {
// GetNumberPickerMinMax returns the min and max value of NumberPicker subview. // GetNumberPickerMinMax returns the min and max value of NumberPicker subview.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetNumberPickerMinMax(view View, subviewID ...string) (float64, float64) { func GetNumberPickerMinMax(view View, subviewID ...string) (float64, float64) {
var pickerType int view = getSubview(view, subviewID)
if len(subviewID) > 0 && subviewID[0] != "" { pickerType := GetNumberPickerType(view)
pickerType = GetNumberPickerType(view, subviewID[0])
} else {
pickerType = GetNumberPickerType(view)
}
var defMin, defMax float64 var defMin, defMax float64
if pickerType == NumberSlider { if pickerType == NumberSlider {
@ -320,8 +316,8 @@ func GetNumberPickerMinMax(view View, subviewID ...string) (float64, float64) {
defMax = math.Inf(1) defMax = math.Inf(1)
} }
min := floatStyledProperty(view, subviewID, NumberPickerMin, defMin) min := floatStyledProperty(view, nil, NumberPickerMin, defMin)
max := floatStyledProperty(view, subviewID, NumberPickerMax, defMax) max := floatStyledProperty(view, nil, NumberPickerMax, defMax)
if min > max { if min > max {
return max, min return max, min
@ -332,14 +328,10 @@ func GetNumberPickerMinMax(view View, subviewID ...string) (float64, float64) {
// GetNumberPickerStep returns the value changing step of NumberPicker subview. // GetNumberPickerStep returns the value changing step of NumberPicker subview.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetNumberPickerStep(view View, subviewID ...string) float64 { func GetNumberPickerStep(view View, subviewID ...string) float64 {
var max float64 view = getSubview(view, subviewID)
if len(subviewID) > 0 && subviewID[0] != "" { _, max := GetNumberPickerMinMax(view)
_, max = GetNumberPickerMinMax(view, subviewID[0])
} else {
_, max = GetNumberPickerMinMax(view)
}
result := floatStyledProperty(view, subviewID, NumberPickerStep, 0) result := floatStyledProperty(view, nil, NumberPickerStep, 0)
if result > max { if result > max {
return max return max
} }
@ -349,15 +341,9 @@ func GetNumberPickerStep(view View, subviewID ...string) float64 {
// GetNumberPickerValue returns the value of NumberPicker subview. // GetNumberPickerValue returns the value of NumberPicker subview.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetNumberPickerValue(view View, subviewID ...string) float64 { func GetNumberPickerValue(view View, subviewID ...string) float64 {
var min float64 view = getSubview(view, subviewID)
if len(subviewID) > 0 && subviewID[0] != "" { min, _ := GetNumberPickerMinMax(view)
min, _ = GetNumberPickerMinMax(view, subviewID[0]) return floatStyledProperty(view, nil, NumberPickerValue, min)
} else {
min, _ = GetNumberPickerMinMax(view)
}
result := floatStyledProperty(view, subviewID, NumberPickerValue, min)
return result
} }
// GetNumberChangedListeners returns the NumberChangedListener list of an NumberPicker subview. // GetNumberChangedListeners returns the NumberChangedListener list of an NumberPicker subview.

View File

@ -73,9 +73,7 @@ func (view *viewData) Frame() Frame {
// GetViewFrame returns the size and location of view's viewport. // GetViewFrame returns the size and location of view's viewport.
// If the second argument (subviewID) is not specified or it is "" then the value of the first argument (view) is returned // If the second argument (subviewID) is not specified or it is "" then the value of the first argument (view) is returned
func GetViewFrame(view View, subviewID ...string) Frame { func GetViewFrame(view View, subviewID ...string) Frame {
if len(subviewID) > 0 && subviewID[0] != "" { view = getSubview(view, subviewID)
view = ViewByID(view, subviewID[0])
}
if view == nil { if view == nil {
return Frame{} return Frame{}
} }

View File

@ -42,9 +42,7 @@ func (view *viewData) setScroll(x, y, width, height float64) {
// GetViewScroll returns ... // GetViewScroll returns ...
// If the second argument (subviewID) is not specified or it is "" then a value of the first argument (view) is returned // If the second argument (subviewID) is not specified or it is "" then a value of the first argument (view) is returned
func GetViewScroll(view View, subviewID ...string) Frame { func GetViewScroll(view View, subviewID ...string) Frame {
if len(subviewID) > 0 && subviewID[0] != "" { view = getSubview(view, subviewID)
view = ViewByID(view, subviewID[0])
}
if view == nil { if view == nil {
return Frame{} return Frame{}
} }
@ -71,10 +69,7 @@ func ScrollViewTo(view View, subviewID string, x, y float64) {
// ScrollViewToEnd scrolls the view's content to the start of view. // ScrollViewToEnd scrolls the view's content to the start of view.
// If the second argument (subviewID) is not specified or it is "" then the first argument (view) is used // If the second argument (subviewID) is not specified or it is "" then the first argument (view) is used
func ScrollViewToStart(view View, subviewID ...string) { func ScrollViewToStart(view View, subviewID ...string) {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
view.Session().callFunc("scrollToStart", view.htmlID()) view.Session().callFunc("scrollToStart", view.htmlID())
} }
} }
@ -82,10 +77,7 @@ func ScrollViewToStart(view View, subviewID ...string) {
// ScrollViewToEnd scrolls the view's content to the end of view. // ScrollViewToEnd scrolls the view's content to the end of view.
// If the second argument (subviewID) is not specified or it is "" then the first argument (view) is used // If the second argument (subviewID) is not specified or it is "" then the first argument (view) is used
func ScrollViewToEnd(view View, subviewID ...string) { func ScrollViewToEnd(view View, subviewID ...string) {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
view.Session().callFunc("scrollToEnd", view.htmlID()) view.Session().callFunc("scrollToEnd", view.htmlID())
} }
} }

View File

@ -560,11 +560,7 @@ func (layout *stackLayoutData) htmlSubviews(self View, buffer *strings.Builder)
// IsMoveToFrontAnimation returns "true" if an animation is used when calling the MoveToFront/MoveToFrontByID method of StackLayout interface. // IsMoveToFrontAnimation returns "true" if an animation is used when calling the MoveToFront/MoveToFrontByID method of StackLayout interface.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func IsMoveToFrontAnimation(view View, subviewID ...string) bool { func IsMoveToFrontAnimation(view View, subviewID ...string) bool {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if value, ok := boolProperty(view, MoveToFrontAnimation, view.Session()); ok { if value, ok := boolProperty(view, MoveToFrontAnimation, view.Session()); ok {
return value return value
} }

View File

@ -28,11 +28,7 @@ func (cell *tableCellView) cssStyle(self View, builder cssBuilder) {
// GetTableContent returns a TableAdapter which defines the TableView content. // GetTableContent returns a TableAdapter which defines the TableView content.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTableContent(view View, subviewID ...string) TableAdapter { func GetTableContent(view View, subviewID ...string) TableAdapter {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if content := view.getRaw(Content); content != nil { if content := view.getRaw(Content); content != nil {
if adapter, ok := content.(TableAdapter); ok { if adapter, ok := content.(TableAdapter); ok {
return adapter return adapter
@ -46,11 +42,7 @@ func GetTableContent(view View, subviewID ...string) TableAdapter {
// GetTableRowStyle returns a TableRowStyle which defines styles of TableView rows. // GetTableRowStyle returns a TableRowStyle which defines styles of TableView rows.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTableRowStyle(view View, subviewID ...string) TableRowStyle { func GetTableRowStyle(view View, subviewID ...string) TableRowStyle {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
for _, tag := range []PropertyName{RowStyle, Content} { for _, tag := range []PropertyName{RowStyle, Content} {
if value := view.getRaw(tag); value != nil { if value := view.getRaw(tag); value != nil {
if style, ok := value.(TableRowStyle); ok { if style, ok := value.(TableRowStyle); ok {
@ -66,11 +58,7 @@ func GetTableRowStyle(view View, subviewID ...string) TableRowStyle {
// GetTableColumnStyle returns a TableColumnStyle which defines styles of TableView columns. // GetTableColumnStyle returns a TableColumnStyle which defines styles of TableView columns.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTableColumnStyle(view View, subviewID ...string) TableColumnStyle { func GetTableColumnStyle(view View, subviewID ...string) TableColumnStyle {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
for _, tag := range []PropertyName{ColumnStyle, Content} { for _, tag := range []PropertyName{ColumnStyle, Content} {
if value := view.getRaw(tag); value != nil { if value := view.getRaw(tag); value != nil {
if style, ok := value.(TableColumnStyle); ok { if style, ok := value.(TableColumnStyle); ok {
@ -86,11 +74,7 @@ func GetTableColumnStyle(view View, subviewID ...string) TableColumnStyle {
// GetTableCellStyle returns a TableCellStyle which defines styles of TableView cells. // GetTableCellStyle returns a TableCellStyle which defines styles of TableView cells.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTableCellStyle(view View, subviewID ...string) TableCellStyle { func GetTableCellStyle(view View, subviewID ...string) TableCellStyle {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
for _, tag := range []PropertyName{CellStyle, Content} { for _, tag := range []PropertyName{CellStyle, Content} {
if value := view.getRaw(tag); value != nil { if value := view.getRaw(tag); value != nil {
if style, ok := value.(TableCellStyle); ok { if style, ok := value.(TableCellStyle); ok {
@ -136,11 +120,7 @@ func GetTableFootHeight(view View, subviewID ...string) int {
// If the selection mode is RowSelection (2) then the returned column index is less than 0. // If the selection mode is RowSelection (2) then the returned column index is less than 0.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTableCurrent(view View, subviewID ...string) CellIndex { func GetTableCurrent(view View, subviewID ...string) CellIndex {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if selectionMode := GetTableSelectionMode(view); selectionMode != NoneSelection { if selectionMode := GetTableSelectionMode(view); selectionMode != NoneSelection {
return tableViewCurrent(view) return tableViewCurrent(view)
} }
@ -179,37 +159,23 @@ func GetTableRowSelectedListeners(view View, subviewID ...string) []func(TableVi
// ReloadTableViewData updates TableView // ReloadTableViewData updates TableView
// If the second argument (subviewID) is not specified or it is "" then updates the first argument (TableView). // If the second argument (subviewID) is not specified or it is "" then updates the first argument (TableView).
func ReloadTableViewData(view View, subviewID ...string) bool { func ReloadTableViewData(view View, subviewID ...string) bool {
var tableView TableView if view = getSubview(view, subviewID); view != nil {
if len(subviewID) > 0 && subviewID[0] != "" { if tableView, ok := view.(TableView); ok {
if tableView = TableViewByID(view, subviewID[0]); tableView == nil {
return false
}
} else {
var ok bool
if tableView, ok = view.(TableView); !ok {
return false
}
}
tableView.ReloadTableData() tableView.ReloadTableData()
return true return true
}
}
return false
} }
// ReloadTableViewCell updates the given table cell. // ReloadTableViewCell updates the given table cell.
// If the last argument (subviewID) is not specified or it is "" then updates the cell of the first argument (TableView). // If the last argument (subviewID) is not specified or it is "" then updates the cell of the first argument (TableView).
func ReloadTableViewCell(row, column int, view View, subviewID ...string) bool { func ReloadTableViewCell(row, column int, view View, subviewID ...string) bool {
var tableView TableView if view = getSubview(view, subviewID); view != nil {
if len(subviewID) > 0 && subviewID[0] != "" { if tableView, ok := view.(TableView); ok {
if tableView = TableViewByID(view, subviewID[0]); tableView == nil {
return false
}
} else {
var ok bool
if tableView, ok = view.(TableView); !ok {
return false
}
}
tableView.ReloadCell(row, column) tableView.ReloadCell(row, column)
return true return true
}
}
return false
} }

View File

@ -375,10 +375,7 @@ func getTimeProperty(view View, mainTag, shortTag PropertyName) (time.Time, bool
// "false" as the second value otherwise. // "false" as the second value otherwise.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTimePickerMin(view View, subviewID ...string) (time.Time, bool) { func GetTimePickerMin(view View, subviewID ...string) (time.Time, bool) {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
return getTimeProperty(view, TimePickerMin, Min) return getTimeProperty(view, TimePickerMin, Min)
} }
return time.Now(), false return time.Now(), false
@ -388,10 +385,7 @@ func GetTimePickerMin(view View, subviewID ...string) (time.Time, bool) {
// "false" as the second value otherwise. // "false" as the second value otherwise.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTimePickerMax(view View, subviewID ...string) (time.Time, bool) { func GetTimePickerMax(view View, subviewID ...string) (time.Time, bool) {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
return getTimeProperty(view, TimePickerMax, Max) return getTimeProperty(view, TimePickerMax, Max)
} }
return time.Now(), false return time.Now(), false
@ -406,10 +400,7 @@ func GetTimePickerStep(view View, subviewID ...string) int {
// GetTimePickerValue returns the time of TimePicker subview. // GetTimePickerValue returns the time of TimePicker subview.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTimePickerValue(view View, subviewID ...string) time.Time { func GetTimePickerValue(view View, subviewID ...string) time.Time {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view == nil {
view = ViewByID(view, subviewID[0])
}
if view == nil {
return time.Now() return time.Now()
} }
time, _ := getTimeProperty(view, TimePickerValue, Value) time, _ := getTimeProperty(view, TimePickerValue, Value)

View File

@ -565,10 +565,7 @@ func getClipShape(prop Properties, tag PropertyName, session Session) ClipShape
// GetClip returns a View clipping area. // GetClip returns a View clipping area.
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned // If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
func GetClip(view View, subviewID ...string) ClipShape { func GetClip(view View, subviewID ...string) ClipShape {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
return getClipShape(view, Clip, view.Session()) return getClipShape(view, Clip, view.Session())
} }
@ -578,10 +575,7 @@ func GetClip(view View, subviewID ...string) ClipShape {
// GetShapeOutside returns a shape around which adjacent inline content. // GetShapeOutside returns a shape around which adjacent inline content.
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned // If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
func GetShapeOutside(view View, subviewID ...string) ClipShape { func GetShapeOutside(view View, subviewID ...string) ClipShape {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
return getClipShape(view, ShapeOutside, view.Session()) return getClipShape(view, ShapeOutside, view.Session())
} }

View File

@ -321,11 +321,7 @@ func setFilterProperty(properties Properties, tag PropertyName, value any) []Pro
// GetFilter returns a View graphical effects like blur or color shift. // GetFilter returns a View graphical effects like blur or color shift.
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned // If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
func GetFilter(view View, subviewID ...string) ViewFilter { func GetFilter(view View, subviewID ...string) ViewFilter {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if value := view.getRaw(Filter); value != nil { if value := view.getRaw(Filter); value != nil {
if filter, ok := value.(ViewFilter); ok { if filter, ok := value.(ViewFilter); ok {
return filter return filter
@ -344,11 +340,7 @@ func GetFilter(view View, subviewID ...string) ViewFilter {
// GetBackdropFilter returns the area behind a View graphical effects like blur or color shift. // GetBackdropFilter returns the area behind a View graphical effects like blur or color shift.
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned // If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
func GetBackdropFilter(view View, subviewID ...string) ViewFilter { func GetBackdropFilter(view View, subviewID ...string) ViewFilter {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if value := view.getRaw(BackdropFilter); value != nil { if value := view.getRaw(BackdropFilter); value != nil {
if filter, ok := value.(ViewFilter); ok { if filter, ok := value.(ViewFilter); ok {
return filter return filter

View File

@ -70,13 +70,37 @@ func SetParams(rootView View, viewID string, params Params) bool {
return result return result
} }
func getSubview(view View, subviewID []string) View {
switch len(subviewID) {
case 0:
// do nothing
case 1:
if subviewID[0] != "" {
view = ViewByID(view, subviewID[0])
}
default:
buffer := allocStringBuilder()
defer freeStringBuilder(buffer)
for _, id := range subviewID {
if id != "" {
if buffer.Len() > 0 {
buffer.WriteRune('/')
}
buffer.WriteString(id)
}
}
view = ViewByID(view, buffer.String())
}
return view
}
// IsDisabled returns "true" if the subview is disabled // IsDisabled returns "true" if the subview is disabled
// If the second argument (subviewID) is not specified or it is "" then a state of the first argument (view) is returned // If the second argument (subviewID) is not specified or it is "" then a state of the first argument (view) is returned
func IsDisabled(view View, subviewID ...string) bool { func IsDisabled(view View, subviewID ...string) bool {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if disabled, _ := boolProperty(view, Disabled, view.Session()); disabled { if disabled, _ := boolProperty(view, Disabled, view.Session()); disabled {
return true return true
} }
@ -106,10 +130,7 @@ func GetOpacity(view View, subviewID ...string) float64 {
// GetStyle returns the subview style id. // GetStyle returns the subview style id.
// If the second argument (subviewID) is not specified or it is "" then a style of the first argument (view) is returned // If the second argument (subviewID) is not specified or it is "" then a style of the first argument (view) is returned
func GetStyle(view View, subviewID ...string) string { func GetStyle(view View, subviewID ...string) string {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if style, ok := stringProperty(view, Style, view.Session()); ok { if style, ok := stringProperty(view, Style, view.Session()); ok {
return style return style
} }
@ -120,10 +141,7 @@ func GetStyle(view View, subviewID ...string) string {
// GetDisabledStyle returns the disabled subview style id. // GetDisabledStyle returns the disabled subview style id.
// If the second argument (subviewID) is not specified or it is "" then a style of the first argument (view) is returned // If the second argument (subviewID) is not specified or it is "" then a style of the first argument (view) is returned
func GetDisabledStyle(view View, subviewID ...string) string { func GetDisabledStyle(view View, subviewID ...string) string {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if style, ok := stringProperty(view, StyleDisabled, view.Session()); ok { if style, ok := stringProperty(view, StyleDisabled, view.Session()); ok {
return style return style
} }
@ -142,12 +160,8 @@ func GetVisibility(view View, subviewID ...string) int {
// OverflowHidden (0), OverflowVisible (1), OverflowScroll (2), OverflowAuto (3) // OverflowHidden (0), OverflowVisible (1), OverflowScroll (2), OverflowAuto (3)
// If the second argument (subviewID) is not specified or it is "" then a value of the first argument (view) is returned // If the second argument (subviewID) is not specified or it is "" then a value of the first argument (view) is returned
func GetOverflow(view View, subviewID ...string) int { func GetOverflow(view View, subviewID ...string) int {
if view = getSubview(view, subviewID); view != nil {
defaultOverflow := OverflowHidden defaultOverflow := OverflowHidden
view2 := view
if len(subviewID) > 0 && subviewID[0] != "" {
view2 = ViewByID(view, subviewID[0])
}
if view2 != nil {
switch view.(type) { switch view.(type) {
case EditView: case EditView:
defaultOverflow = OverflowAuto defaultOverflow = OverflowAuto
@ -155,16 +169,16 @@ func GetOverflow(view View, subviewID ...string) int {
case ListView: case ListView:
defaultOverflow = OverflowAuto defaultOverflow = OverflowAuto
} }
return enumStyledProperty(view, nil, Overflow, defaultOverflow, false)
} }
return enumStyledProperty(view, subviewID, Overflow, defaultOverflow, false)
return OverflowHidden
} }
// GetTabIndex returns the subview tab-index. // GetTabIndex returns the subview tab-index.
// If the second argument (subviewID) is not specified or it is "" then a tab-index of the first argument (view) is returned // If the second argument (subviewID) is not specified or it is "" then a tab-index of the first argument (view) is returned
func GetTabIndex(view View, subviewID ...string) int { func GetTabIndex(view View, subviewID ...string) int {
if len(subviewID) > 0 && subviewID[0] != "" { view = getSubview(view, subviewID)
view = ViewByID(view, subviewID[0])
}
defaultValue := -1 defaultValue := -1
if view != nil { if view != nil {
@ -264,11 +278,8 @@ func GetBottom(view View, subviewID ...string) SizeUnit {
// Margin returns the subview margin. // Margin returns the subview margin.
// If the second argument (subviewID) is not specified or it is "" then a margin of the first argument (view) is returned // If the second argument (subviewID) is not specified or it is "" then a margin of the first argument (view) is returned
func GetMargin(view View, subviewID ...string) Bounds { func GetMargin(view View, subviewID ...string) Bounds {
if len(subviewID) > 0 && subviewID[0] != "" {
view = ViewByID(view, subviewID[0])
}
var bounds Bounds var bounds Bounds
if view != nil { if view = getSubview(view, subviewID); view != nil {
bounds.setFromProperties(Margin, MarginTop, MarginRight, MarginBottom, MarginLeft, view, view.Session()) bounds.setFromProperties(Margin, MarginTop, MarginRight, MarginBottom, MarginLeft, view, view.Session())
} }
return bounds return bounds
@ -277,11 +288,8 @@ func GetMargin(view View, subviewID ...string) Bounds {
// GetPadding returns the subview padding. // GetPadding returns the subview padding.
// If the second argument (subviewID) is not specified or it is "" then a padding of the first argument (view) is returned // If the second argument (subviewID) is not specified or it is "" then a padding of the first argument (view) is returned
func GetPadding(view View, subviewID ...string) Bounds { func GetPadding(view View, subviewID ...string) Bounds {
if len(subviewID) > 0 && subviewID[0] != "" {
view = ViewByID(view, subviewID[0])
}
var bounds Bounds var bounds Bounds
if view != nil { if view = getSubview(view, subviewID); view != nil {
bounds.setFromProperties(Padding, PaddingTop, PaddingRight, PaddingBottom, PaddingLeft, view, view.Session()) bounds.setFromProperties(Padding, PaddingTop, PaddingRight, PaddingBottom, PaddingLeft, view, view.Session())
} }
return bounds return bounds
@ -290,10 +298,7 @@ func GetPadding(view View, subviewID ...string) Bounds {
// GetBorder returns ViewBorders of the subview. // GetBorder returns ViewBorders of the subview.
// If the second argument (subviewID) is not specified or it is "" then a ViewBorders of the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a ViewBorders of the first argument (view) is returned.
func GetBorder(view View, subviewID ...string) ViewBorders { func GetBorder(view View, subviewID ...string) ViewBorders {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if border := getBorderProperty(view, Border); border != nil { if border := getBorderProperty(view, Border); border != nil {
return border.ViewBorders(view.Session()) return border.ViewBorders(view.Session())
} }
@ -304,9 +309,7 @@ func GetBorder(view View, subviewID ...string) ViewBorders {
// Radius returns the BoxRadius structure of the subview. // Radius returns the BoxRadius structure of the subview.
// If the second argument (subviewID) is not specified or it is "" then a BoxRadius of the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a BoxRadius of the first argument (view) is returned.
func GetRadius(view View, subviewID ...string) BoxRadius { func GetRadius(view View, subviewID ...string) BoxRadius {
if len(subviewID) > 0 && subviewID[0] != "" { view = getSubview(view, subviewID)
view = ViewByID(view, subviewID[0])
}
if view == nil { if view == nil {
return BoxRadius{} return BoxRadius{}
} }
@ -316,10 +319,7 @@ func GetRadius(view View, subviewID ...string) BoxRadius {
// GetOutline returns ViewOutline of the subview. // GetOutline returns ViewOutline of the subview.
// If the second argument (subviewID) is not specified or it is "" then a ViewOutline of the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a ViewOutline of the first argument (view) is returned.
func GetOutline(view View, subviewID ...string) ViewOutline { func GetOutline(view View, subviewID ...string) ViewOutline {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if outline := getOutlineProperty(view); outline != nil { if outline := getOutlineProperty(view); outline != nil {
return outline.ViewOutline(view.Session()) return outline.ViewOutline(view.Session())
} }
@ -336,9 +336,7 @@ func GetOutlineOffset(view View, subviewID ...string) SizeUnit {
// GetViewShadows returns shadows of the subview. // GetViewShadows returns shadows of the subview.
// If the second argument (subviewID) is not specified or it is "" then shadows of the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then shadows of the first argument (view) is returned.
func GetViewShadows(view View, subviewID ...string) []ViewShadow { func GetViewShadows(view View, subviewID ...string) []ViewShadow {
if len(subviewID) > 0 && subviewID[0] != "" { view = getSubview(view, subviewID)
view = ViewByID(view, subviewID[0])
}
if view == nil { if view == nil {
return []ViewShadow{} return []ViewShadow{}
} }
@ -348,9 +346,7 @@ func GetViewShadows(view View, subviewID ...string) []ViewShadow {
// GetTextShadows returns text shadows of the subview. // GetTextShadows returns text shadows of the subview.
// If the second argument (subviewID) is not specified or it is "" then shadows of the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then shadows of the first argument (view) is returned.
func GetTextShadows(view View, subviewID ...string) []ViewShadow { func GetTextShadows(view View, subviewID ...string) []ViewShadow {
if len(subviewID) > 0 && subviewID[0] != "" { view = getSubview(view, subviewID)
view = ViewByID(view, subviewID[0])
}
if view == nil { if view == nil {
return []ViewShadow{} return []ViewShadow{}
} }
@ -530,10 +526,7 @@ func GetVerticalTextOrientation(view View, subviewID ...string) int {
// GetRow returns the range of row numbers of a GridLayout in which the subview is placed. // GetRow returns the range of row numbers of a GridLayout in which the subview is placed.
// If the second argument (subviewID) is not specified or it is "" then a values from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a values from the first argument (view) is returned.
func GetRow(view View, subviewID ...string) Range { func GetRow(view View, subviewID ...string) Range {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
session := view.Session() session := view.Session()
if result, ok := rangeProperty(view, Row, session); ok { if result, ok := rangeProperty(view, Row, session); ok {
return result return result
@ -550,10 +543,7 @@ func GetRow(view View, subviewID ...string) Range {
// GetColumn returns the range of column numbers of a GridLayout in which the subview is placed. // GetColumn returns the range of column numbers of a GridLayout in which the subview is placed.
// If the second argument (subviewID) is not specified or it is "" then a values from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a values from the first argument (view) is returned.
func GetColumn(view View, subviewID ...string) Range { func GetColumn(view View, subviewID ...string) Range {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
session := view.Session() session := view.Session()
if result, ok := rangeProperty(view, Column, session); ok { if result, ok := rangeProperty(view, Column, session); ok {
return result return result
@ -586,9 +576,7 @@ func GetPerspective(view View, subviewID ...string) SizeUnit {
// It is used as the vanishing point by the Perspective property. The default value is (50%, 50%). // It is used as the vanishing point by the Perspective property. The default value is (50%, 50%).
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetPerspectiveOrigin(view View, subviewID ...string) (SizeUnit, SizeUnit) { func GetPerspectiveOrigin(view View, subviewID ...string) (SizeUnit, SizeUnit) {
if len(subviewID) > 0 && subviewID[0] != "" { view = getSubview(view, subviewID)
view = ViewByID(view, subviewID[0])
}
if view == nil { if view == nil {
return AutoSize(), AutoSize() return AutoSize(), AutoSize()
} }
@ -608,9 +596,7 @@ func GetBackfaceVisible(view View, subviewID ...string) bool {
// The default value is (50%, 50%, 50%). // The default value is (50%, 50%, 50%).
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTransformOrigin(view View, subviewID ...string) (SizeUnit, SizeUnit, SizeUnit) { func GetTransformOrigin(view View, subviewID ...string) (SizeUnit, SizeUnit, SizeUnit) {
if len(subviewID) > 0 && subviewID[0] != "" { view = getSubview(view, subviewID)
view = ViewByID(view, subviewID[0])
}
if view == nil { if view == nil {
return AutoSize(), AutoSize(), AutoSize() return AutoSize(), AutoSize(), AutoSize()
} }
@ -620,9 +606,7 @@ func GetTransformOrigin(view View, subviewID ...string) (SizeUnit, SizeUnit, Siz
// GetTranslate returns a x-, y-, and z-axis translation value of a 2D/3D translation // GetTranslate returns a x-, y-, and z-axis translation value of a 2D/3D translation
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTranslate(view View, subviewID ...string) (SizeUnit, SizeUnit, SizeUnit) { func GetTranslate(view View, subviewID ...string) (SizeUnit, SizeUnit, SizeUnit) {
if len(subviewID) > 0 && subviewID[0] != "" { view = getSubview(view, subviewID)
view = ViewByID(view, subviewID[0])
}
if view == nil { if view == nil {
return AutoSize(), AutoSize(), AutoSize() return AutoSize(), AutoSize(), AutoSize()
} }
@ -638,9 +622,7 @@ func GetTranslate(view View, subviewID ...string) (SizeUnit, SizeUnit, SizeUnit)
// and the ordinate (y-axis). The default value is 0. // and the ordinate (y-axis). The default value is 0.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetSkew(view View, subviewID ...string) (AngleUnit, AngleUnit) { func GetSkew(view View, subviewID ...string) (AngleUnit, AngleUnit) {
if len(subviewID) > 0 && subviewID[0] != "" { view = getSubview(view, subviewID)
view = ViewByID(view, subviewID[0])
}
if view == nil { if view == nil {
return AngleUnit{Value: 0, Type: Radian}, AngleUnit{Value: 0, Type: Radian} return AngleUnit{Value: 0, Type: Radian}, AngleUnit{Value: 0, Type: Radian}
} }
@ -652,9 +634,7 @@ func GetSkew(view View, subviewID ...string) (AngleUnit, AngleUnit) {
// GetScale returns a x-, y-, and z-axis scaling value of a 2D/3D scale. The default value is 1. // GetScale returns a x-, y-, and z-axis scaling value of a 2D/3D scale. The default value is 1.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetScale(view View, subviewID ...string) (float64, float64, float64) { func GetScale(view View, subviewID ...string) (float64, float64, float64) {
if len(subviewID) > 0 && subviewID[0] != "" { view = getSubview(view, subviewID)
view = ViewByID(view, subviewID[0])
}
if view == nil { if view == nil {
return 1, 1, 1 return 1, 1, 1
} }
@ -669,9 +649,7 @@ func GetScale(view View, subviewID ...string) (float64, float64, float64) {
// GetRotate returns a x-, y, z-coordinate of the vector denoting the axis of rotation, and the angle of the view rotation // GetRotate returns a x-, y, z-coordinate of the vector denoting the axis of rotation, and the angle of the view rotation
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetRotate(view View, subviewID ...string) (float64, float64, float64, AngleUnit) { func GetRotate(view View, subviewID ...string) (float64, float64, float64, AngleUnit) {
if len(subviewID) > 0 && subviewID[0] != "" { view = getSubview(view, subviewID)
view = ViewByID(view, subviewID[0])
}
if view == nil { if view == nil {
return 0, 0, 0, AngleUnit{Value: 0, Type: Radian} return 0, 0, 0, AngleUnit{Value: 0, Type: Radian}
} }
@ -717,10 +695,7 @@ func valueFromStyle(view View, tag PropertyName) any {
} }
func stringStyledProperty(view View, subviewID []string, tag PropertyName, inherit bool) string { func stringStyledProperty(view View, subviewID []string, tag PropertyName, inherit bool) string {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if text, ok := stringProperty(view, tag, view.Session()); ok { if text, ok := stringProperty(view, tag, view.Session()); ok {
return text return text
} }
@ -740,11 +715,7 @@ func stringStyledProperty(view View, subviewID []string, tag PropertyName, inher
} }
func sizeStyledProperty(view View, subviewID []string, tag PropertyName, inherit bool) SizeUnit { func sizeStyledProperty(view View, subviewID []string, tag PropertyName, inherit bool) SizeUnit {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if value, ok := sizeProperty(view, tag, view.Session()); ok { if value, ok := sizeProperty(view, tag, view.Session()); ok {
return value return value
} }
@ -764,11 +735,7 @@ func sizeStyledProperty(view View, subviewID []string, tag PropertyName, inherit
} }
func enumStyledProperty(view View, subviewID []string, tag PropertyName, defaultValue int, inherit bool) int { func enumStyledProperty(view View, subviewID []string, tag PropertyName, defaultValue int, inherit bool) int {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if value, ok := enumProperty(view, tag, view.Session(), defaultValue); ok { if value, ok := enumProperty(view, tag, view.Session(), defaultValue); ok {
return value return value
} }
@ -788,11 +755,7 @@ func enumStyledProperty(view View, subviewID []string, tag PropertyName, default
} }
func boolStyledProperty(view View, subviewID []string, tag PropertyName, inherit bool) bool { func boolStyledProperty(view View, subviewID []string, tag PropertyName, inherit bool) bool {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if value, ok := boolProperty(view, tag, view.Session()); ok { if value, ok := boolProperty(view, tag, view.Session()); ok {
return value return value
} }
@ -813,11 +776,7 @@ func boolStyledProperty(view View, subviewID []string, tag PropertyName, inherit
} }
func intStyledProperty(view View, subviewID []string, tag PropertyName, defaultValue int) int { func intStyledProperty(view View, subviewID []string, tag PropertyName, defaultValue int) int {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if value, ok := intProperty(view, tag, view.Session(), defaultValue); ok { if value, ok := intProperty(view, tag, view.Session(), defaultValue); ok {
return value return value
} }
@ -830,10 +789,7 @@ func intStyledProperty(view View, subviewID []string, tag PropertyName, defaultV
} }
func floatStyledProperty(view View, subviewID []string, tag PropertyName, defaultValue float64) float64 { func floatStyledProperty(view View, subviewID []string, tag PropertyName, defaultValue float64) float64 {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if value, ok := floatProperty(view, tag, view.Session(), defaultValue); ok { if value, ok := floatProperty(view, tag, view.Session(), defaultValue); ok {
return value return value
} }
@ -846,10 +802,7 @@ func floatStyledProperty(view View, subviewID []string, tag PropertyName, defaul
} }
func colorStyledProperty(view View, subviewID []string, tag PropertyName, inherit bool) Color { func colorStyledProperty(view View, subviewID []string, tag PropertyName, inherit bool) Color {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if value, ok := colorProperty(view, tag, view.Session()); ok { if value, ok := colorProperty(view, tag, view.Session()); ok {
return value return value
} }
@ -868,10 +821,7 @@ func colorStyledProperty(view View, subviewID []string, tag PropertyName, inheri
} }
func transformStyledProperty(view View, subviewID []string, tag PropertyName) TransformProperty { func transformStyledProperty(view View, subviewID []string, tag PropertyName) TransformProperty {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if transform := getTransformProperty(view, tag); transform != nil { if transform := getTransformProperty(view, tag); transform != nil {
return transform return transform
} }
@ -887,10 +837,7 @@ func transformStyledProperty(view View, subviewID []string, tag PropertyName) Tr
// The focused View is the View which will receive keyboard events by default. // The focused View is the View which will receive keyboard events by default.
// If the second argument (subviewID) is not specified or it is "" then focus is set on the first argument (view) // If the second argument (subviewID) is not specified or it is "" then focus is set on the first argument (view)
func FocusView(view View, subviewID ...string) { func FocusView(view View, subviewID ...string) {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
view.Session().callFunc("focus", view.htmlID()) view.Session().callFunc("focus", view.htmlID())
} }
} }
@ -920,12 +867,8 @@ func BlurViewByID(viewID string, session Session) {
// GetCurrent returns the index of the selected item (<0 if there is no a selected item) or the current view index (StackLayout, TabsLayout). // GetCurrent returns the index of the selected item (<0 if there is no a selected item) or the current view index (StackLayout, TabsLayout).
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetCurrent(view View, subviewID ...string) int { func GetCurrent(view View, subviewID ...string) int {
if len(subviewID) > 0 && subviewID[0] != "" {
view = ViewByID(view, subviewID[0])
}
defaultValue := -1 defaultValue := -1
if view != nil { if view = getSubview(view, subviewID); view != nil {
if result, ok := intProperty(view, Current, view.Session(), defaultValue); ok { if result, ok := intProperty(view, Current, view.Session(), defaultValue); ok {
return result return result
} else if view.Tag() != "ListView" { } else if view.Tag() != "ListView" {
@ -938,11 +881,7 @@ func GetCurrent(view View, subviewID ...string) int {
// IsUserSelect returns "true" if the user can select text, "false" otherwise. // IsUserSelect returns "true" if the user can select text, "false" otherwise.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func IsUserSelect(view View, subviewID ...string) bool { func IsUserSelect(view View, subviewID ...string) bool {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
value, _ := isUserSelect(view) value, _ := isUserSelect(view)
return value return value
} }
@ -1006,11 +945,7 @@ func GetBackgroundBlendMode(view View, subviewID ...string) int {
// GetTooltip returns a tooltip text of the subview. // GetTooltip returns a tooltip text of the subview.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. // If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTooltip(view View, subviewID ...string) string { func GetTooltip(view View, subviewID ...string) string {
if len(subviewID) > 0 && subviewID[0] != "" { if view = getSubview(view, subviewID); view != nil {
view = ViewByID(view, subviewID[0])
}
if view != nil {
if value := view.Get(Tooltip); value != nil { if value := view.Get(Tooltip); value != nil {
if text, ok := value.(string); ok { if text, ok := value.(string); ok {
return text return text