mirror of https://github.com/anoshenko/rui.git
				
				
				
			Optimisation
This commit is contained in:
		
							parent
							
								
									ed639c94c6
								
							
						
					
					
						commit
						6b2a5b4aee
					
				|  | @ -7,7 +7,7 @@ | |||
| * Changed Push and Pop method of StackLayout interface. | ||||
| * Removed DefaultAnimation, StartToEndAnimation, EndToStartAnimation, TopDownAnimation, and BottomUpAnimation constants. | ||||
| * 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 LineCap type. Type of constants ButtCap, RoundCap, and SquareCap changed to LineCap. Type of Canvas.SetLineCap function argument changed to LineCap. | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										12
									
								
								animation.go
								
								
								
								
							
							
						
						
									
										12
									
								
								animation.go
								
								
								
								
							|  | @ -981,11 +981,7 @@ func IsAnimationPaused(view View, subviewID ...string) bool { | |||
| // 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
 | ||||
| func GetTransitions(view View, subviewID ...string) map[PropertyName]Animation { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		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.
 | ||||
| // 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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if value := view.getRaw(AnimationTag); value != nil { | ||||
| 			if animations, ok := value.([]Animation); ok && animations != nil { | ||||
| 				return animations | ||||
|  |  | |||
|  | @ -174,10 +174,7 @@ func (picker *colorPickerData) handleCommand(self View, command PropertyName, da | |||
| // 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.
 | ||||
| func GetColorPickerValue(view View, subviewID ...string) Color { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if value, ok := colorProperty(view, ColorPickerValue, view.Session()); ok { | ||||
| 			return value | ||||
| 		} | ||||
|  |  | |||
|  | @ -199,11 +199,7 @@ func GetColumnGap(view View, subviewID ...string) SizeUnit { | |||
| } | ||||
| 
 | ||||
| func getColumnSeparator(view View, subviewID []string) ViewBorder { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		value := view.Get(ColumnSeparator) | ||||
| 		if value == nil { | ||||
| 			value = valueFromStyle(view, ColumnSeparator) | ||||
|  |  | |||
							
								
								
									
										75
									
								
								dataList.go
								
								
								
								
							
							
						
						
									
										75
									
								
								dataList.go
								
								
								
								
							|  | @ -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, `"`, `"`) | ||||
| 		} | ||||
| 		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.
 | ||||
| // 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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		return getDataListProperty(view) | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
|  | @ -402,10 +402,7 @@ func getDateProperty(view View, mainTag, shortTag PropertyName) (time.Time, bool | |||
| // "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.
 | ||||
| func GetDatePickerMin(view View, subviewID ...string) (time.Time, bool) { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		return getDateProperty(view, DatePickerMin, Min) | ||||
| 	} | ||||
| 	return time.Now(), false | ||||
|  | @ -415,10 +412,7 @@ func GetDatePickerMin(view View, subviewID ...string) (time.Time, bool) { | |||
| // "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.
 | ||||
| func GetDatePickerMax(view View, subviewID ...string) (time.Time, bool) { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		return getDateProperty(view, DatePickerMax, Max) | ||||
| 	} | ||||
| 	return time.Now(), false | ||||
|  | @ -433,10 +427,7 @@ func GetDatePickerStep(view View, subviewID ...string) int { | |||
| // 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.
 | ||||
| func GetDatePickerValue(view View, subviewID ...string) time.Time { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view == nil { | ||||
| 	if view = getSubview(view, subviewID); view == nil { | ||||
| 		return time.Now() | ||||
| 	} | ||||
| 	date, _ := getDateProperty(view, DatePickerValue, Value) | ||||
|  |  | |||
|  | @ -171,10 +171,7 @@ func (detailsView *detailsViewData) handleCommand(self View, command PropertyNam | |||
| // 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.
 | ||||
| func GetDetailsSummary(view View, subviewID ...string) View { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if value := view.Get(Summary); value != nil { | ||||
| 			switch value := value.(type) { | ||||
| 			case string: | ||||
|  |  | |||
|  | @ -267,10 +267,7 @@ func GetDropDownListeners(view View, subviewID ...string) []func(DropDownList, i | |||
| // 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.
 | ||||
| func GetDropDownItems(view View, subviewID ...string) []string { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if value := view.Get(Items); value != nil { | ||||
| 			if items, ok := value.([]string); ok { | ||||
| 				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.
 | ||||
| // 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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	view = getSubview(view, subviewID) | ||||
| 	return getIndicesArray(view, DisabledItems) | ||||
| } | ||||
| 
 | ||||
| // 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.
 | ||||
| func GetDropDownItemSeparators(view View, subviewID ...string) []int { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	view = getSubview(view, subviewID) | ||||
| 	return getIndicesArray(view, ItemSeparators) | ||||
| } | ||||
|  |  | |||
							
								
								
									
										14
									
								
								editView.go
								
								
								
								
							
							
						
						
									
										14
									
								
								editView.go
								
								
								
								
							|  | @ -398,10 +398,7 @@ func (edit *editViewData) handleCommand(self View, command PropertyName, data Da | |||
| // 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.
 | ||||
| func GetText(view View, subviewID ...string) string { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if value := view.getRaw(Text); value != nil { | ||||
| 			if text, ok := value.(string); ok { | ||||
| 				return text | ||||
|  | @ -414,9 +411,7 @@ func GetText(view View, subviewID ...string) string { | |||
| // 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.
 | ||||
| func GetHint(view View, subviewID ...string) string { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	view = getSubview(view, subviewID) | ||||
| 
 | ||||
| 	session := view.Session() | ||||
| 	text := "" | ||||
|  | @ -477,10 +472,7 @@ func GetEditViewType(view View, subviewID ...string) int { | |||
| // 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.
 | ||||
| func GetEditViewPattern(view View, subviewID ...string) string { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if pattern, ok := stringProperty(view, EditViewPattern, view.Session()); ok { | ||||
| 			return pattern | ||||
| 		} | ||||
|  |  | |||
							
								
								
									
										15
									
								
								events.go
								
								
								
								
							
							
						
						
									
										15
									
								
								events.go
								
								
								
								
							|  | @ -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) { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if value := view.Get(tag); value != nil { | ||||
| 			if result, ok := value.([]func(V)); ok { | ||||
| 				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) { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if value := view.Get(tag); value != nil { | ||||
| 			if result, ok := value.([]func(V, E)); ok { | ||||
| 				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) { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if value := view.Get(tag); value != nil { | ||||
| 			if result, ok := value.([]func(V, E, E)); ok { | ||||
| 				return result | ||||
|  |  | |||
|  | @ -345,10 +345,7 @@ func IsMultipleFilePicker(view View, subviewID ...string) bool { | |||
| // 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.
 | ||||
| func GetFilePickerAccept(view View, subviewID ...string) []string { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		accept, ok := stringProperty(view, Accept, view.Session()) | ||||
| 		if !ok { | ||||
| 			if value := valueFromStyle(view, Accept); value != nil { | ||||
|  |  | |||
|  | @ -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 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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		return gridCellSizes(view, CellWidth, view.Session()) | ||||
| 	} | ||||
| 	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 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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		return gridCellSizes(view, CellHeight, view.Session()) | ||||
| 	} | ||||
| 	return []SizeUnit{} | ||||
|  |  | |||
							
								
								
									
										12
									
								
								imageView.go
								
								
								
								
							
							
						
						
									
										12
									
								
								imageView.go
								
								
								
								
							|  | @ -329,11 +329,7 @@ func (imageView *imageViewData) CurrentSource() string { | |||
| // 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
 | ||||
| func GetImageViewSource(view View, subviewID ...string) string { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if image, ok := imageProperty(view, Source, view.Session()); ok { | ||||
| 			return image | ||||
| 		} | ||||
|  | @ -345,11 +341,7 @@ func GetImageViewSource(view View, subviewID ...string) string { | |||
| // 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
 | ||||
| func GetImageViewAltText(view View, subviewID ...string) string { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if value := view.getRaw(AltText); value != nil { | ||||
| 			if text, ok := value.(string); ok { | ||||
| 				text, _ = view.Session().GetString(text) | ||||
|  |  | |||
|  | @ -222,11 +222,7 @@ func GetListHorizontalAlign(view View, subviewID ...string) int { | |||
| // 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.
 | ||||
| func GetListOrientation(view View, subviewID ...string) int { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if orientation, ok := valueToOrientation(view.Get(Orientation), view.Session()); ok { | ||||
| 			return orientation | ||||
| 		} | ||||
|  | @ -264,11 +260,7 @@ func GetListColumnGap(view View, subviewID ...string) SizeUnit { | |||
| // otherwise does nothing.
 | ||||
| // If the second argument (subviewID) is not specified or it is "" then the first argument (view) updates.
 | ||||
| func UpdateContent(view View, subviewID ...string) { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		switch view := view.(type) { | ||||
| 		case GridLayout: | ||||
| 			view.UpdateGridContent() | ||||
|  | @ -278,6 +270,9 @@ func UpdateContent(view View, subviewID ...string) { | |||
| 
 | ||||
| 		case ListView: | ||||
| 			view.ReloadListViewData() | ||||
| 
 | ||||
| 		case TableView: | ||||
| 			view.ReloadTableData() | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  |  | |||
							
								
								
									
										17
									
								
								listView.go
								
								
								
								
							
							
						
						
									
										17
									
								
								listView.go
								
								
								
								
							|  | @ -1098,11 +1098,7 @@ func GetListViewCheckbox(view View, subviewID ...string) int { | |||
| // 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.
 | ||||
| func GetListViewCheckedItems(view View, subviewID ...string) []int { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if value := view.getRaw(Checked); value != nil { | ||||
| 			if checkedItems, ok := value.([]int); ok { | ||||
| 				switch GetListViewCheckbox(view) { | ||||
|  | @ -1179,10 +1175,7 @@ func GetListItemFrame(view View, subviewID string, index int) Frame { | |||
| // 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.
 | ||||
| func GetListViewAdapter(view View, subviewID ...string) ListAdapter { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if value := view.Get(Items); value != nil { | ||||
| 			if adapter, ok := value.(ListAdapter); ok { | ||||
| 				return adapter | ||||
|  | @ -1195,11 +1188,7 @@ func GetListViewAdapter(view View, subviewID ...string) ListAdapter { | |||
| // ReloadListViewData updates ListView content
 | ||||
| // 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) { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if listView, ok := view.(ListView); ok { | ||||
| 			listView.ReloadListViewData() | ||||
| 		} | ||||
|  |  | |||
|  | @ -304,12 +304,8 @@ func GetNumberPickerType(view View, subviewID ...string) int { | |||
| // 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.
 | ||||
| func GetNumberPickerMinMax(view View, subviewID ...string) (float64, float64) { | ||||
| 	var pickerType int | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		pickerType = GetNumberPickerType(view, subviewID[0]) | ||||
| 	} else { | ||||
| 		pickerType = GetNumberPickerType(view) | ||||
| 	} | ||||
| 	view = getSubview(view, subviewID) | ||||
| 	pickerType := GetNumberPickerType(view) | ||||
| 
 | ||||
| 	var defMin, defMax float64 | ||||
| 	if pickerType == NumberSlider { | ||||
|  | @ -320,8 +316,8 @@ func GetNumberPickerMinMax(view View, subviewID ...string) (float64, float64) { | |||
| 		defMax = math.Inf(1) | ||||
| 	} | ||||
| 
 | ||||
| 	min := floatStyledProperty(view, subviewID, NumberPickerMin, defMin) | ||||
| 	max := floatStyledProperty(view, subviewID, NumberPickerMax, defMax) | ||||
| 	min := floatStyledProperty(view, nil, NumberPickerMin, defMin) | ||||
| 	max := floatStyledProperty(view, nil, NumberPickerMax, defMax) | ||||
| 
 | ||||
| 	if min > max { | ||||
| 		return max, min | ||||
|  | @ -332,14 +328,10 @@ func GetNumberPickerMinMax(view View, subviewID ...string) (float64, float64) { | |||
| // 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.
 | ||||
| func GetNumberPickerStep(view View, subviewID ...string) float64 { | ||||
| 	var max float64 | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		_, max = GetNumberPickerMinMax(view, subviewID[0]) | ||||
| 	} else { | ||||
| 		_, max = GetNumberPickerMinMax(view) | ||||
| 	} | ||||
| 	view = getSubview(view, subviewID) | ||||
| 	_, max := GetNumberPickerMinMax(view) | ||||
| 
 | ||||
| 	result := floatStyledProperty(view, subviewID, NumberPickerStep, 0) | ||||
| 	result := floatStyledProperty(view, nil, NumberPickerStep, 0) | ||||
| 	if result > max { | ||||
| 		return max | ||||
| 	} | ||||
|  | @ -349,15 +341,9 @@ func GetNumberPickerStep(view View, subviewID ...string) float64 { | |||
| // 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.
 | ||||
| func GetNumberPickerValue(view View, subviewID ...string) float64 { | ||||
| 	var min float64 | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		min, _ = GetNumberPickerMinMax(view, subviewID[0]) | ||||
| 	} else { | ||||
| 		min, _ = GetNumberPickerMinMax(view) | ||||
| 	} | ||||
| 
 | ||||
| 	result := floatStyledProperty(view, subviewID, NumberPickerValue, min) | ||||
| 	return result | ||||
| 	view = getSubview(view, subviewID) | ||||
| 	min, _ := GetNumberPickerMinMax(view) | ||||
| 	return floatStyledProperty(view, nil, NumberPickerValue, min) | ||||
| } | ||||
| 
 | ||||
| // GetNumberChangedListeners returns the NumberChangedListener list of an NumberPicker subview.
 | ||||
|  |  | |||
|  | @ -73,9 +73,7 @@ func (view *viewData) Frame() Frame { | |||
| // 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
 | ||||
| func GetViewFrame(view View, subviewID ...string) Frame { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	view = getSubview(view, subviewID) | ||||
| 	if view == nil { | ||||
| 		return Frame{} | ||||
| 	} | ||||
|  |  | |||
|  | @ -42,9 +42,7 @@ func (view *viewData) setScroll(x, y, width, height float64) { | |||
| // GetViewScroll returns ...
 | ||||
| // 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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	view = getSubview(view, subviewID) | ||||
| 	if view == nil { | ||||
| 		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.
 | ||||
| // If the second argument (subviewID) is not specified or it is "" then the first argument (view) is used
 | ||||
| func ScrollViewToStart(view View, subviewID ...string) { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		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.
 | ||||
| // If the second argument (subviewID) is not specified or it is "" then the first argument (view) is used
 | ||||
| func ScrollViewToEnd(view View, subviewID ...string) { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		view.Session().callFunc("scrollToEnd", view.htmlID()) | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -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.
 | ||||
| // 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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if value, ok := boolProperty(view, MoveToFrontAnimation, view.Session()); ok { | ||||
| 			return value | ||||
| 		} | ||||
|  |  | |||
|  | @ -28,11 +28,7 @@ func (cell *tableCellView) cssStyle(self View, builder cssBuilder) { | |||
| // 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.
 | ||||
| func GetTableContent(view View, subviewID ...string) TableAdapter { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if content := view.getRaw(Content); content != nil { | ||||
| 			if adapter, ok := content.(TableAdapter); ok { | ||||
| 				return adapter | ||||
|  | @ -46,11 +42,7 @@ func GetTableContent(view View, subviewID ...string) TableAdapter { | |||
| // 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.
 | ||||
| func GetTableRowStyle(view View, subviewID ...string) TableRowStyle { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		for _, tag := range []PropertyName{RowStyle, Content} { | ||||
| 			if value := view.getRaw(tag); value != nil { | ||||
| 				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.
 | ||||
| // 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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		for _, tag := range []PropertyName{ColumnStyle, Content} { | ||||
| 			if value := view.getRaw(tag); value != nil { | ||||
| 				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.
 | ||||
| // 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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		for _, tag := range []PropertyName{CellStyle, Content} { | ||||
| 			if value := view.getRaw(tag); value != nil { | ||||
| 				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 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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if selectionMode := GetTableSelectionMode(view); selectionMode != NoneSelection { | ||||
| 			return tableViewCurrent(view) | ||||
| 		} | ||||
|  | @ -179,37 +159,23 @@ func GetTableRowSelectedListeners(view View, subviewID ...string) []func(TableVi | |||
| // ReloadTableViewData updates 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 { | ||||
| 	var tableView TableView | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		if tableView = TableViewByID(view, subviewID[0]); tableView == nil { | ||||
| 			return false | ||||
| 		} | ||||
| 	} else { | ||||
| 		var ok bool | ||||
| 		if tableView, ok = view.(TableView); !ok { | ||||
| 			return false | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if tableView, ok := view.(TableView); ok { | ||||
| 			tableView.ReloadTableData() | ||||
| 			return true | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	tableView.ReloadTableData() | ||||
| 	return true | ||||
| 	return false | ||||
| } | ||||
| 
 | ||||
| // 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).
 | ||||
| func ReloadTableViewCell(row, column int, view View, subviewID ...string) bool { | ||||
| 	var tableView TableView | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		if tableView = TableViewByID(view, subviewID[0]); tableView == nil { | ||||
| 			return false | ||||
| 		} | ||||
| 	} else { | ||||
| 		var ok bool | ||||
| 		if tableView, ok = view.(TableView); !ok { | ||||
| 			return false | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if tableView, ok := view.(TableView); ok { | ||||
| 			tableView.ReloadCell(row, column) | ||||
| 			return true | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	tableView.ReloadCell(row, column) | ||||
| 	return true | ||||
| 	return false | ||||
| } | ||||
|  |  | |||
|  | @ -375,10 +375,7 @@ func getTimeProperty(view View, mainTag, shortTag PropertyName) (time.Time, bool | |||
| // "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.
 | ||||
| func GetTimePickerMin(view View, subviewID ...string) (time.Time, bool) { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		return getTimeProperty(view, TimePickerMin, Min) | ||||
| 	} | ||||
| 	return time.Now(), false | ||||
|  | @ -388,10 +385,7 @@ func GetTimePickerMin(view View, subviewID ...string) (time.Time, bool) { | |||
| // "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.
 | ||||
| func GetTimePickerMax(view View, subviewID ...string) (time.Time, bool) { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		return getTimeProperty(view, TimePickerMax, Max) | ||||
| 	} | ||||
| 	return time.Now(), false | ||||
|  | @ -406,10 +400,7 @@ func GetTimePickerStep(view View, subviewID ...string) int { | |||
| // 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.
 | ||||
| func GetTimePickerValue(view View, subviewID ...string) time.Time { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view == nil { | ||||
| 	if view = getSubview(view, subviewID); view == nil { | ||||
| 		return time.Now() | ||||
| 	} | ||||
| 	time, _ := getTimeProperty(view, TimePickerValue, Value) | ||||
|  |  | |||
							
								
								
									
										10
									
								
								viewClip.go
								
								
								
								
							
							
						
						
									
										10
									
								
								viewClip.go
								
								
								
								
							|  | @ -565,10 +565,7 @@ func getClipShape(prop Properties, tag PropertyName, session Session) ClipShape | |||
| // 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
 | ||||
| func GetClip(view View, subviewID ...string) ClipShape { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		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.
 | ||||
| // 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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		return getClipShape(view, ShapeOutside, view.Session()) | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
|  | @ -321,11 +321,7 @@ func setFilterProperty(properties Properties, tag PropertyName, value any) []Pro | |||
| // 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
 | ||||
| func GetFilter(view View, subviewID ...string) ViewFilter { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if value := view.getRaw(Filter); value != nil { | ||||
| 			if filter, ok := value.(ViewFilter); ok { | ||||
| 				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.
 | ||||
| // 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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if value := view.getRaw(BackdropFilter); value != nil { | ||||
| 			if filter, ok := value.(ViewFilter); ok { | ||||
| 				return filter | ||||
|  |  | |||
							
								
								
									
										191
									
								
								viewUtils.go
								
								
								
								
							
							
						
						
									
										191
									
								
								viewUtils.go
								
								
								
								
							|  | @ -70,13 +70,37 @@ func SetParams(rootView View, viewID string, params Params) bool { | |||
| 	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
 | ||||
| // 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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if disabled, _ := boolProperty(view, Disabled, view.Session()); disabled { | ||||
| 			return true | ||||
| 		} | ||||
|  | @ -106,10 +130,7 @@ func GetOpacity(view View, subviewID ...string) float64 { | |||
| // 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
 | ||||
| func GetStyle(view View, subviewID ...string) string { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if style, ok := stringProperty(view, Style, view.Session()); ok { | ||||
| 			return style | ||||
| 		} | ||||
|  | @ -120,10 +141,7 @@ func GetStyle(view View, subviewID ...string) string { | |||
| // 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
 | ||||
| func GetDisabledStyle(view View, subviewID ...string) string { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if style, ok := stringProperty(view, StyleDisabled, view.Session()); ok { | ||||
| 			return style | ||||
| 		} | ||||
|  | @ -142,12 +160,8 @@ func GetVisibility(view View, subviewID ...string) int { | |||
| // 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
 | ||||
| func GetOverflow(view View, subviewID ...string) int { | ||||
| 	defaultOverflow := OverflowHidden | ||||
| 	view2 := view | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view2 = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view2 != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		defaultOverflow := OverflowHidden | ||||
| 		switch view.(type) { | ||||
| 		case EditView: | ||||
| 			defaultOverflow = OverflowAuto | ||||
|  | @ -155,16 +169,16 @@ func GetOverflow(view View, subviewID ...string) int { | |||
| 		case ListView: | ||||
| 			defaultOverflow = OverflowAuto | ||||
| 		} | ||||
| 		return enumStyledProperty(view, nil, Overflow, defaultOverflow, false) | ||||
| 	} | ||||
| 	return enumStyledProperty(view, subviewID, Overflow, defaultOverflow, false) | ||||
| 
 | ||||
| 	return OverflowHidden | ||||
| } | ||||
| 
 | ||||
| // 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
 | ||||
| func GetTabIndex(view View, subviewID ...string) int { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	view = getSubview(view, subviewID) | ||||
| 
 | ||||
| 	defaultValue := -1 | ||||
| 	if view != nil { | ||||
|  | @ -264,11 +278,8 @@ func GetBottom(view View, subviewID ...string) SizeUnit { | |||
| // 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
 | ||||
| func GetMargin(view View, subviewID ...string) Bounds { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	var bounds Bounds | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		bounds.setFromProperties(Margin, MarginTop, MarginRight, MarginBottom, MarginLeft, view, view.Session()) | ||||
| 	} | ||||
| 	return bounds | ||||
|  | @ -277,11 +288,8 @@ func GetMargin(view View, subviewID ...string) Bounds { | |||
| // 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
 | ||||
| func GetPadding(view View, subviewID ...string) Bounds { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	var bounds Bounds | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		bounds.setFromProperties(Padding, PaddingTop, PaddingRight, PaddingBottom, PaddingLeft, view, view.Session()) | ||||
| 	} | ||||
| 	return bounds | ||||
|  | @ -290,10 +298,7 @@ func GetPadding(view View, subviewID ...string) Bounds { | |||
| // 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.
 | ||||
| func GetBorder(view View, subviewID ...string) ViewBorders { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if border := getBorderProperty(view, Border); border != nil { | ||||
| 			return border.ViewBorders(view.Session()) | ||||
| 		} | ||||
|  | @ -304,9 +309,7 @@ func GetBorder(view View, subviewID ...string) ViewBorders { | |||
| // 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.
 | ||||
| func GetRadius(view View, subviewID ...string) BoxRadius { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	view = getSubview(view, subviewID) | ||||
| 	if view == nil { | ||||
| 		return BoxRadius{} | ||||
| 	} | ||||
|  | @ -316,10 +319,7 @@ func GetRadius(view View, subviewID ...string) BoxRadius { | |||
| // 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.
 | ||||
| func GetOutline(view View, subviewID ...string) ViewOutline { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if outline := getOutlineProperty(view); outline != nil { | ||||
| 			return outline.ViewOutline(view.Session()) | ||||
| 		} | ||||
|  | @ -336,9 +336,7 @@ func GetOutlineOffset(view View, subviewID ...string) SizeUnit { | |||
| // 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.
 | ||||
| func GetViewShadows(view View, subviewID ...string) []ViewShadow { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	view = getSubview(view, subviewID) | ||||
| 	if view == nil { | ||||
| 		return []ViewShadow{} | ||||
| 	} | ||||
|  | @ -348,9 +346,7 @@ func GetViewShadows(view View, subviewID ...string) []ViewShadow { | |||
| // 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.
 | ||||
| func GetTextShadows(view View, subviewID ...string) []ViewShadow { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	view = getSubview(view, subviewID) | ||||
| 	if view == nil { | ||||
| 		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.
 | ||||
| // 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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		session := view.Session() | ||||
| 		if result, ok := rangeProperty(view, Row, session); ok { | ||||
| 			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.
 | ||||
| // 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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		session := view.Session() | ||||
| 		if result, ok := rangeProperty(view, Column, session); ok { | ||||
| 			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%).
 | ||||
| // 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) { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	view = getSubview(view, subviewID) | ||||
| 	if view == nil { | ||||
| 		return AutoSize(), AutoSize() | ||||
| 	} | ||||
|  | @ -608,9 +596,7 @@ func GetBackfaceVisible(view View, subviewID ...string) bool { | |||
| // 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.
 | ||||
| func GetTransformOrigin(view View, subviewID ...string) (SizeUnit, SizeUnit, SizeUnit) { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	view = getSubview(view, subviewID) | ||||
| 	if view == nil { | ||||
| 		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
 | ||||
| // 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) { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	view = getSubview(view, subviewID) | ||||
| 	if view == nil { | ||||
| 		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.
 | ||||
| // 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) { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	view = getSubview(view, subviewID) | ||||
| 	if view == nil { | ||||
| 		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.
 | ||||
| // 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) { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	view = getSubview(view, subviewID) | ||||
| 	if view == nil { | ||||
| 		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
 | ||||
| // 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) { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	view = getSubview(view, subviewID) | ||||
| 	if view == nil { | ||||
| 		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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if text, ok := stringProperty(view, tag, view.Session()); ok { | ||||
| 			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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if value, ok := sizeProperty(view, tag, view.Session()); ok { | ||||
| 			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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if value, ok := enumProperty(view, tag, view.Session(), defaultValue); ok { | ||||
| 			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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if value, ok := boolProperty(view, tag, view.Session()); ok { | ||||
| 			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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if value, ok := intProperty(view, tag, view.Session(), defaultValue); ok { | ||||
| 			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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if value, ok := floatProperty(view, tag, view.Session(), defaultValue); ok { | ||||
| 			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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if value, ok := colorProperty(view, tag, view.Session()); ok { | ||||
| 			return value | ||||
| 		} | ||||
|  | @ -868,10 +821,7 @@ func colorStyledProperty(view View, subviewID []string, tag PropertyName, inheri | |||
| } | ||||
| 
 | ||||
| func transformStyledProperty(view View, subviewID []string, tag PropertyName) TransformProperty { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if transform := getTransformProperty(view, tag); transform != nil { | ||||
| 			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.
 | ||||
| // 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) { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		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).
 | ||||
| // 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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	defaultValue := -1 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if result, ok := intProperty(view, Current, view.Session(), defaultValue); ok { | ||||
| 			return result | ||||
| 		} 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.
 | ||||
| // 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 { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		value, _ := isUserSelect(view) | ||||
| 		return value | ||||
| 	} | ||||
|  | @ -1006,11 +945,7 @@ func GetBackgroundBlendMode(view View, subviewID ...string) int { | |||
| // 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.
 | ||||
| func GetTooltip(view View, subviewID ...string) string { | ||||
| 	if len(subviewID) > 0 && subviewID[0] != "" { | ||||
| 		view = ViewByID(view, subviewID[0]) | ||||
| 	} | ||||
| 
 | ||||
| 	if view != nil { | ||||
| 	if view = getSubview(view, subviewID); view != nil { | ||||
| 		if value := view.Get(Tooltip); value != nil { | ||||
| 			if text, ok := value.(string); ok { | ||||
| 				return text | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue