forked from mbk-lab/rui_orig
Optimisation
This commit is contained in:
parent
e23ad83b6c
commit
c5ca92de60
10
animation.go
10
animation.go
|
@ -694,15 +694,7 @@ func SetAnimated(rootView View, viewID, tag string, value any, animation Animati
|
||||||
// IsAnimationPaused returns "true" if an animation of the subview is paused, "false" otherwise.
|
// IsAnimationPaused returns "true" if an animation of the subview is paused, "false" otherwise.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
func IsAnimationPaused(view View, subviewID string) bool {
|
func IsAnimationPaused(view View, subviewID string) bool {
|
||||||
if subviewID != "" {
|
return boolStyledProperty(view, subviewID, AnimationPaused, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, ok := boolStyledProperty(view, AnimationPaused); ok {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTransition returns the subview transitions. The result is always non-nil.
|
// GetTransition returns the subview transitions. The result is always non-nil.
|
||||||
|
|
|
@ -188,10 +188,10 @@ func GetColorPickerValue(view View, subviewID string) Color {
|
||||||
view = ViewByID(view, subviewID)
|
view = ViewByID(view, subviewID)
|
||||||
}
|
}
|
||||||
if view != nil {
|
if view != nil {
|
||||||
if result, ok := colorStyledProperty(view, ColorPickerValue); ok {
|
if value, ok := colorProperty(view, ColorPickerValue, view.Session()); ok {
|
||||||
return result
|
return value
|
||||||
}
|
}
|
||||||
for _, tag := range []string{Value, ColorTag} {
|
for _, tag := range []string{ColorPickerValue, Value, ColorTag} {
|
||||||
if value := valueFromStyle(view, tag); value != nil {
|
if value := valueFromStyle(view, tag); value != nil {
|
||||||
if result, ok := valueToColor(value, view.Session()); ok {
|
if result, ok := valueToColor(value, view.Session()); ok {
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -139,14 +139,7 @@ func (columnLayout *columnLayoutData) set(tag string, value any) bool {
|
||||||
// based on the "column-width" property.
|
// based on the "column-width" property.
|
||||||
// If the second argument (subviewID) is "" then a top position of the first argument (view) is returned
|
// If the second argument (subviewID) is "" then a top position of the first argument (view) is returned
|
||||||
func GetColumnCount(view View, subviewID string) int {
|
func GetColumnCount(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return intStyledProperty(view, subviewID, ColumnCount, 0)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
result, _ := intStyledProperty(view, ColumnCount, 0)
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetColumnWidth returns SizeUnit value which specifies the width of each column of ColumnLayout.
|
// GetColumnWidth returns SizeUnit value which specifies the width of each column of ColumnLayout.
|
||||||
|
|
|
@ -392,15 +392,7 @@ func GetDatePickerMax(view View, subviewID string) (time.Time, bool) {
|
||||||
// GetDatePickerStep returns the date changing step in days of DatePicker subview.
|
// GetDatePickerStep returns the date changing step in days of DatePicker subview.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
func GetDatePickerStep(view View, subviewID string) int {
|
func GetDatePickerStep(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return intStyledProperty(view, subviewID, DatePickerStep, 0)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, _ := intStyledProperty(view, DatePickerStep, 0); result >= 0 {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDatePickerValue returns the date of DatePicker subview.
|
// GetDatePickerValue returns the date of DatePicker subview.
|
||||||
|
|
|
@ -208,13 +208,5 @@ func GetDetailsSummary(view View, subviewID string) View {
|
||||||
// IsDetailsExpanded returns a value of the Expanded property of DetailsView.
|
// IsDetailsExpanded returns a value of the Expanded property of DetailsView.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
func IsDetailsExpanded(view View, subviewID string) bool {
|
func IsDetailsExpanded(view View, subviewID string) bool {
|
||||||
if subviewID != "" {
|
return boolStyledProperty(view, subviewID, Expanded, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, ok := boolStyledProperty(view, Expanded); ok {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
50
editView.go
50
editView.go
|
@ -546,43 +546,19 @@ func GetHint(view View, subviewID string) string {
|
||||||
// GetMaxLength returns a maximal lenght of EditView. If a maximal lenght is not limited then 0 is returned
|
// GetMaxLength returns a maximal lenght of EditView. If a maximal lenght is not limited then 0 is returned
|
||||||
// If the second argument (subviewID) is "" then a value of the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value of the first argument (view) is returned.
|
||||||
func GetMaxLength(view View, subviewID string) int {
|
func GetMaxLength(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return intStyledProperty(view, subviewID, MaxLength, 0)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, ok := intStyledProperty(view, MaxLength, 0); ok {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsReadOnly returns the true if a EditView works in read only mode.
|
// IsReadOnly returns the true if a EditView works in read only mode.
|
||||||
// If the second argument (subviewID) is "" then a value of the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value of the first argument (view) is returned.
|
||||||
func IsReadOnly(view View, subviewID string) bool {
|
func IsReadOnly(view View, subviewID string) bool {
|
||||||
if subviewID != "" {
|
return boolStyledProperty(view, subviewID, ReadOnly, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, ok := boolStyledProperty(view, ReadOnly); ok {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsSpellcheck returns a value of the Spellcheck property of EditView.
|
// IsSpellcheck returns a value of the Spellcheck property of EditView.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
func IsSpellcheck(view View, subviewID string) bool {
|
func IsSpellcheck(view View, subviewID string) bool {
|
||||||
if subviewID != "" {
|
return boolStyledProperty(view, subviewID, Spellcheck, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if spellcheck, ok := boolStyledProperty(view, Spellcheck); ok {
|
|
||||||
return spellcheck
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTextChangedListeners returns the TextChangedListener list of an EditView or MultiLineEditView subview.
|
// GetTextChangedListeners returns the TextChangedListener list of an EditView or MultiLineEditView subview.
|
||||||
|
@ -629,16 +605,7 @@ func GetEditViewPattern(view View, subviewID string) string {
|
||||||
// IsEditViewWrap returns a value of the EditWrap property of MultiLineEditView.
|
// IsEditViewWrap returns a value of the EditWrap property of MultiLineEditView.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
func IsEditViewWrap(view View, subviewID string) bool {
|
func IsEditViewWrap(view View, subviewID string) bool {
|
||||||
if subviewID != "" {
|
return boolStyledProperty(view, subviewID, EditWrap, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if wrap, ok := boolStyledProperty(view, EditWrap); ok {
|
|
||||||
return wrap
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppendEditText appends the text to the EditView content.
|
// AppendEditText appends the text to the EditView content.
|
||||||
|
@ -659,12 +626,5 @@ func AppendEditText(view View, subviewID string, text string) {
|
||||||
// GetCaretColor returns the color of the text input carret.
|
// GetCaretColor returns the color of the text input carret.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
func GetCaretColor(view View, subviewID string) Color {
|
func GetCaretColor(view View, subviewID string) Color {
|
||||||
if subviewID != "" {
|
return colorStyledProperty(view, subviewID, CaretColor, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
t, _ := colorStyledProperty(view, CaretColor)
|
|
||||||
return t
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,7 +251,7 @@ func (picker *filePickerData) htmlProperties(self View, buffer *strings.Builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.WriteString(` type="file"`)
|
buffer.WriteString(` type="file"`)
|
||||||
if multiple, ok := boolStyledProperty(picker, Multiple); ok && multiple {
|
if IsMultipleFilePicker(picker, "") {
|
||||||
buffer.WriteString(` multiple`)
|
buffer.WriteString(` multiple`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,15 +354,7 @@ func LoadFilePickerFile(view View, subviewID string, file FileInfo, result func(
|
||||||
// IsMultipleFilePicker returns "true" if multiple files can be selected in the FilePicker, "false" otherwise.
|
// IsMultipleFilePicker returns "true" if multiple files can be selected in the FilePicker, "false" otherwise.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
func IsMultipleFilePicker(view View, subviewID string) bool {
|
func IsMultipleFilePicker(view View, subviewID string) bool {
|
||||||
if subviewID != "" {
|
return boolStyledProperty(view, subviewID, Multiple, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, ok := boolStyledProperty(view, Multiple); ok {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFilePickerAccept returns sets the list of allowed file extensions or MIME types.
|
// GetFilePickerAccept returns sets the list of allowed file extensions or MIME types.
|
||||||
|
|
|
@ -272,54 +272,29 @@ 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 "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) 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) {
|
||||||
if subviewID != "" {
|
var defMin, defMax float64
|
||||||
view = ViewByID(view, subviewID)
|
if GetNumberPickerType(view, subviewID) == NumberSlider {
|
||||||
|
defMin = 0
|
||||||
|
defMax = 1
|
||||||
|
} else {
|
||||||
|
defMin = math.Inf(-1)
|
||||||
|
defMax = math.Inf(1)
|
||||||
}
|
}
|
||||||
if view != nil {
|
|
||||||
t, _ := enumStyledProperty(view, NumberPickerType, NumberEditor)
|
|
||||||
var defMin, defMax float64
|
|
||||||
|
|
||||||
if t == NumberSlider {
|
min := floatStyledProperty(view, subviewID, NumberPickerMin, defMin)
|
||||||
defMin = 0
|
max := floatStyledProperty(view, subviewID, NumberPickerMax, defMax)
|
||||||
defMax = 1
|
|
||||||
} else {
|
|
||||||
defMin = math.Inf(-1)
|
|
||||||
defMax = math.Inf(1)
|
|
||||||
}
|
|
||||||
min, ok := floatStyledProperty(view, NumberPickerMin, defMin)
|
|
||||||
if !ok {
|
|
||||||
min, _ = floatStyledProperty(view, Min, defMin)
|
|
||||||
}
|
|
||||||
|
|
||||||
max, ok := floatStyledProperty(view, NumberPickerMax, defMax)
|
if min > max {
|
||||||
if !ok {
|
return max, min
|
||||||
max, _ = floatStyledProperty(view, Max, defMax)
|
|
||||||
}
|
|
||||||
|
|
||||||
if min > max {
|
|
||||||
return max, min
|
|
||||||
}
|
|
||||||
return min, max
|
|
||||||
}
|
}
|
||||||
return 0, 1
|
return min, max
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNumberPickerStep returns the value changing step of NumberPicker subview.
|
// GetNumberPickerStep returns the value changing step of NumberPicker subview.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) 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 {
|
||||||
if subviewID != "" {
|
_, max := GetNumberPickerMinMax(view, subviewID)
|
||||||
view = ViewByID(view, subviewID)
|
result := floatStyledProperty(view, subviewID, NumberPickerStep, 0)
|
||||||
}
|
|
||||||
if view == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
result, ok := floatStyledProperty(view, NumberPickerStep, 0)
|
|
||||||
if !ok {
|
|
||||||
result, _ = floatStyledProperty(view, Step, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
_, max := GetNumberPickerMinMax(view, "")
|
|
||||||
if result > max {
|
if result > max {
|
||||||
return max
|
return max
|
||||||
}
|
}
|
||||||
|
@ -329,18 +304,8 @@ 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 "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) 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 {
|
||||||
if subviewID != "" {
|
min, _ := GetNumberPickerMinMax(view, subviewID)
|
||||||
view = ViewByID(view, subviewID)
|
result := floatStyledProperty(view, subviewID, NumberPickerValue, min)
|
||||||
}
|
|
||||||
if view == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
min, _ := GetNumberPickerMinMax(view, "")
|
|
||||||
result, ok := floatStyledProperty(view, NumberPickerValue, min)
|
|
||||||
if !ok {
|
|
||||||
result, _ = floatStyledProperty(view, Value, min)
|
|
||||||
}
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,33 +108,11 @@ func (progress *progressBarData) htmlProperties(self View, buffer *strings.Build
|
||||||
// GetProgressBarMax returns the max value of ProgressBar subview.
|
// GetProgressBarMax returns the max value of ProgressBar subview.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
func GetProgressBarMax(view View, subviewID string) float64 {
|
func GetProgressBarMax(view View, subviewID string) float64 {
|
||||||
if subviewID != "" {
|
return floatStyledProperty(view, subviewID, ProgressBarMax, 1)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
result, ok := floatStyledProperty(view, ProgressBarMax, 1)
|
|
||||||
if !ok {
|
|
||||||
result, _ = floatStyledProperty(view, Max, 1)
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetProgressBarValue returns the value of ProgressBar subview.
|
// GetProgressBarValue returns the value of ProgressBar subview.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
func GetProgressBarValue(view View, subviewID string) float64 {
|
func GetProgressBarValue(view View, subviewID string) float64 {
|
||||||
if subviewID != "" {
|
return floatStyledProperty(view, subviewID, ProgressBarValue, 0)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
result, ok := floatStyledProperty(view, ProgressBarValue, 0)
|
|
||||||
if !ok {
|
|
||||||
result, _ = floatStyledProperty(view, Value, 0)
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,27 +120,13 @@ func GetTableVerticalAlign(view View, subviewID string) int {
|
||||||
// GetTableHeadHeight returns the number of rows in the table header.
|
// GetTableHeadHeight returns the number of rows in the table header.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
func GetTableHeadHeight(view View, subviewID string) int {
|
func GetTableHeadHeight(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return intStyledProperty(view, subviewID, HeadHeight, 0)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
headHeight, _ := intStyledProperty(view, HeadHeight, 0)
|
|
||||||
return headHeight
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTableFootHeight returns the number of rows in the table footer.
|
// GetTableFootHeight returns the number of rows in the table footer.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
func GetTableFootHeight(view View, subviewID string) int {
|
func GetTableFootHeight(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return intStyledProperty(view, subviewID, FootHeight, 0)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
headHeight, _ := intStyledProperty(view, FootHeight, 0)
|
|
||||||
return headHeight
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTableCurrent returns the row and column index of the TableView selected cell/row.
|
// GetTableCurrent returns the row and column index of the TableView selected cell/row.
|
||||||
|
|
|
@ -380,22 +380,7 @@ func GetTimePickerMax(view View, subviewID string) (time.Time, bool) {
|
||||||
// GetTimePickerStep returns the time changing step in seconds of TimePicker subview.
|
// GetTimePickerStep returns the time changing step in seconds of TimePicker subview.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
func GetTimePickerStep(view View, subviewID string) int {
|
func GetTimePickerStep(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return intStyledProperty(view, subviewID, TimePickerStep, 60)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view == nil {
|
|
||||||
return 60
|
|
||||||
}
|
|
||||||
|
|
||||||
result, ok := intStyledProperty(view, TimePickerStep, 60)
|
|
||||||
if !ok {
|
|
||||||
result, _ = intStyledProperty(view, Step, 60)
|
|
||||||
}
|
|
||||||
|
|
||||||
if result < 0 {
|
|
||||||
return 60
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTimePickerValue returns the time of TimePicker subview.
|
// GetTimePickerValue returns the time of TimePicker subview.
|
||||||
|
|
272
viewUtils.go
272
viewUtils.go
|
@ -103,15 +103,7 @@ func GetSemantics(view View, subviewID string) int {
|
||||||
// GetOpacity returns the subview opacity.
|
// GetOpacity returns the subview opacity.
|
||||||
// If the second argument (subviewID) is "" then an opacity of the first argument (view) is returned
|
// If the second argument (subviewID) is "" then an opacity of the first argument (view) is returned
|
||||||
func GetOpacity(view View, subviewID string) float64 {
|
func GetOpacity(view View, subviewID string) float64 {
|
||||||
if subviewID != "" {
|
return floatStyledProperty(view, subviewID, Opacity, 1)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if style, ok := floatStyledProperty(view, Opacity, 1); ok {
|
|
||||||
return style
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStyle returns the subview style id.
|
// GetStyle returns the subview style id.
|
||||||
|
@ -183,14 +175,7 @@ func GetOverflow(view View, subviewID string) int {
|
||||||
// GetZIndex returns the subview z-order.
|
// GetZIndex returns the subview z-order.
|
||||||
// If the second argument (subviewID) is "" then a z-order of the first argument (view) is returned
|
// If the second argument (subviewID) is "" then a z-order of the first argument (view) is returned
|
||||||
func GetZIndex(view View, subviewID string) int {
|
func GetZIndex(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return intStyledProperty(view, subviewID, Visibility, 0)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
result, _ := intStyledProperty(view, Visibility, 0)
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetWidth returns the subview width.
|
// GetWidth returns the subview width.
|
||||||
|
@ -434,14 +419,7 @@ func GetTextShadows(view View, subviewID string) []ViewShadow {
|
||||||
// GetBackgroundColor returns a background color of the subview.
|
// GetBackgroundColor returns a background color of the subview.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
func GetBackgroundColor(view View, subviewID string) Color {
|
func GetBackgroundColor(view View, subviewID string) Color {
|
||||||
if subviewID != "" {
|
return colorStyledProperty(view, subviewID, BackgroundColor, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
color, _ := colorStyledProperty(view, BackgroundColor)
|
|
||||||
return color
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFontName returns the subview font.
|
// GetFontName returns the subview font.
|
||||||
|
@ -469,18 +447,7 @@ func GetFontName(view View, subviewID string) string {
|
||||||
// GetTextColor returns a text color of the subview.
|
// GetTextColor returns a text color of the subview.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
func GetTextColor(view View, subviewID string) Color {
|
func GetTextColor(view View, subviewID string) Color {
|
||||||
if subviewID != "" {
|
return colorStyledProperty(view, subviewID, TextColor, true)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if color, ok := colorStyledProperty(view, TextColor); ok {
|
|
||||||
return color
|
|
||||||
}
|
|
||||||
if parent := view.Parent(); parent != nil {
|
|
||||||
return GetTextColor(parent, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTextSize returns a text size of the subview.
|
// GetTextSize returns a text size of the subview.
|
||||||
|
@ -607,86 +574,31 @@ func GetLineHeight(view View, subviewID string) SizeUnit {
|
||||||
// IsItalic returns "true" if a text font of the subview is displayed in italics, "false" otherwise.
|
// IsItalic returns "true" if a text font of the subview is displayed in italics, "false" otherwise.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
func IsItalic(view View, subviewID string) bool {
|
func IsItalic(view View, subviewID string) bool {
|
||||||
if subviewID != "" {
|
return boolStyledProperty(view, subviewID, Italic, true)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, ok := boolStyledProperty(view, Italic); ok {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
if parent := view.Parent(); parent != nil {
|
|
||||||
return IsItalic(parent, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsSmallCaps returns "true" if a text font of the subview is displayed in small caps, "false" otherwise.
|
// IsSmallCaps returns "true" if a text font of the subview is displayed in small caps, "false" otherwise.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
func IsSmallCaps(view View, subviewID string) bool {
|
func IsSmallCaps(view View, subviewID string) bool {
|
||||||
if subviewID != "" {
|
return boolStyledProperty(view, subviewID, SmallCaps, true)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, ok := boolStyledProperty(view, SmallCaps); ok {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
if parent := view.Parent(); parent != nil {
|
|
||||||
return IsSmallCaps(parent, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsStrikethrough returns "true" if a text font of the subview is displayed strikethrough, "false" otherwise.
|
// IsStrikethrough returns "true" if a text font of the subview is displayed strikethrough, "false" otherwise.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
func IsStrikethrough(view View, subviewID string) bool {
|
func IsStrikethrough(view View, subviewID string) bool {
|
||||||
if subviewID != "" {
|
return boolStyledProperty(view, subviewID, Strikethrough, true)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, ok := boolStyledProperty(view, Strikethrough); ok {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
if parent := view.Parent(); parent != nil {
|
|
||||||
return IsStrikethrough(parent, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsOverline returns "true" if a text font of the subview is displayed overlined, "false" otherwise.
|
// IsOverline returns "true" if a text font of the subview is displayed overlined, "false" otherwise.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
func IsOverline(view View, subviewID string) bool {
|
func IsOverline(view View, subviewID string) bool {
|
||||||
if subviewID != "" {
|
return boolStyledProperty(view, subviewID, Overline, true)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, ok := boolStyledProperty(view, Overline); ok {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
if parent := view.Parent(); parent != nil {
|
|
||||||
return IsOverline(parent, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsUnderline returns "true" if a text font of the subview is displayed underlined, "false" otherwise.
|
// IsUnderline returns "true" if a text font of the subview is displayed underlined, "false" otherwise.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
func IsUnderline(view View, subviewID string) bool {
|
func IsUnderline(view View, subviewID string) bool {
|
||||||
if subviewID != "" {
|
return boolStyledProperty(view, subviewID, Underline, true)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, ok := boolStyledProperty(view, Underline); ok {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
if parent := view.Parent(); parent != nil {
|
|
||||||
return IsUnderline(parent, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTextLineThickness returns the stroke thickness of the decoration line that
|
// GetTextLineThickness returns the stroke thickness of the decoration line that
|
||||||
|
@ -729,18 +641,7 @@ func GetTextLineStyle(view View, subviewID string) int {
|
||||||
// is used on text in an element, such as a line-through, underline, or overline.
|
// is used on text in an element, such as a line-through, underline, or overline.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
func GetTextLineColor(view View, subviewID string) Color {
|
func GetTextLineColor(view View, subviewID string) Color {
|
||||||
if subviewID != "" {
|
return colorStyledProperty(view, subviewID, TextLineColor, true)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if color, ok := colorStyledProperty(view, TextLineColor); ok {
|
|
||||||
return color
|
|
||||||
}
|
|
||||||
if parent := view.Parent(); parent != nil {
|
|
||||||
return GetTextLineColor(parent, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTextTransform returns a text transform of the subview. Return one of next values:
|
// GetTextTransform returns a text transform of the subview. Return one of next values:
|
||||||
|
@ -892,15 +793,7 @@ func GetPerspectiveOrigin(view View, subviewID string) (SizeUnit, SizeUnit) {
|
||||||
// false - the back face is hidden, effectively making the element invisible when turned away from the user.
|
// false - the back face is hidden, effectively making the element invisible when turned away from the user.
|
||||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
func GetBackfaceVisible(view View, subviewID string) bool {
|
func GetBackfaceVisible(view View, subviewID string) bool {
|
||||||
if subviewID != "" {
|
return boolStyledProperty(view, subviewID, BackfaceVisible, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, ok := boolStyledProperty(view, BackfaceVisible); ok {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOrigin returns a x-, y-, and z-coordinate of the point around which a view transformation is applied.
|
// GetOrigin returns a x-, y-, and z-coordinate of the point around which a view transformation is applied.
|
||||||
|
@ -974,29 +867,11 @@ func GetRotate(view View, subviewID string) (float64, float64, float64, AngleUni
|
||||||
// and "false" if allows, but does not force, any break to be inserted within the principal box.
|
// and "false" if allows, but does not force, any break to be inserted within the principal box.
|
||||||
// If the second argument (subviewID) is "" then a top position of the first argument (view) is returned
|
// If the second argument (subviewID) is "" then a top position of the first argument (view) is returned
|
||||||
func GetAvoidBreak(view View, subviewID string) bool {
|
func GetAvoidBreak(view View, subviewID string) bool {
|
||||||
if subviewID != "" {
|
return boolStyledProperty(view, subviewID, AvoidBreak, true)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view == nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
result, _ := boolStyledProperty(view, AvoidBreak)
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetNotTranslate(view View, subviewID string) bool {
|
func GetNotTranslate(view View, subviewID string) bool {
|
||||||
if subviewID != "" {
|
return boolStyledProperty(view, subviewID, NotTranslate, true)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, ok := boolStyledProperty(view, NotTranslate); ok {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
if parent := view.Parent(); parent != nil {
|
|
||||||
return GetNotTranslate(parent, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func valueFromStyle(view View, tag string) any {
|
func valueFromStyle(view View, tag string) any {
|
||||||
|
@ -1038,45 +913,83 @@ func enumStyledProperty(view View, tag string, defaultValue int) (int, bool) {
|
||||||
return defaultValue, false
|
return defaultValue, false
|
||||||
}
|
}
|
||||||
|
|
||||||
func boolStyledProperty(view View, tag string) (bool, bool) {
|
func boolStyledProperty(view View, subviewID string, tag string, inherit bool) bool {
|
||||||
if value, ok := boolProperty(view, tag, view.Session()); ok {
|
if subviewID != "" {
|
||||||
return value, true
|
view = ViewByID(view, subviewID)
|
||||||
}
|
}
|
||||||
if value := valueFromStyle(view, tag); value != nil {
|
|
||||||
return valueToBool(value, view.Session())
|
if view != nil {
|
||||||
|
if value, ok := boolProperty(view, tag, view.Session()); ok {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
if value := valueFromStyle(view, tag); value != nil {
|
||||||
|
if b, ok := valueToBool(value, view.Session()); ok {
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if inherit {
|
||||||
|
if parent := view.Parent(); parent != nil {
|
||||||
|
return boolStyledProperty(parent, "", tag, inherit)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false, false
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func intStyledProperty(view View, tag string, defaultValue int) (int, bool) {
|
func intStyledProperty(view View, subviewID string, tag string, defaultValue int) int {
|
||||||
if value, ok := intProperty(view, tag, view.Session(), defaultValue); ok {
|
if subviewID != "" {
|
||||||
return value, true
|
view = ViewByID(view, subviewID)
|
||||||
}
|
}
|
||||||
if value := valueFromStyle(view, tag); value != nil {
|
if view != nil {
|
||||||
return valueToInt(value, view.Session(), defaultValue)
|
if value, ok := intProperty(view, tag, view.Session(), defaultValue); ok {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
if value := valueFromStyle(view, tag); value != nil {
|
||||||
|
n, _ := valueToInt(value, view.Session(), defaultValue)
|
||||||
|
return n
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return defaultValue, false
|
return defaultValue
|
||||||
}
|
}
|
||||||
|
|
||||||
func floatStyledProperty(view View, tag string, defaultValue float64) (float64, bool) {
|
func floatStyledProperty(view View, subviewID string, tag string, defaultValue float64) float64 {
|
||||||
if value, ok := floatProperty(view, tag, view.Session(), defaultValue); ok {
|
if subviewID != "" {
|
||||||
return value, true
|
view = ViewByID(view, subviewID)
|
||||||
}
|
}
|
||||||
if value := valueFromStyle(view, tag); value != nil {
|
if view != nil {
|
||||||
return valueToFloat(value, view.Session(), defaultValue)
|
if value, ok := floatProperty(view, tag, view.Session(), defaultValue); ok {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
if value := valueFromStyle(view, tag); value != nil {
|
||||||
|
f, _ := valueToFloat(value, view.Session(), defaultValue)
|
||||||
|
return f
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return defaultValue
|
||||||
return defaultValue, false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func colorStyledProperty(view View, tag string) (Color, bool) {
|
func colorStyledProperty(view View, subviewID, tag string, inherit bool) Color {
|
||||||
if value, ok := colorProperty(view, tag, view.Session()); ok {
|
if subviewID != "" {
|
||||||
return value, true
|
view = ViewByID(view, subviewID)
|
||||||
}
|
}
|
||||||
if value := valueFromStyle(view, tag); value != nil {
|
if view != nil {
|
||||||
return valueToColor(value, view.Session())
|
if value, ok := colorProperty(view, tag, view.Session()); ok {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
if value := valueFromStyle(view, tag); value != nil {
|
||||||
|
if color, ok := valueToColor(value, view.Session()); ok {
|
||||||
|
return color
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if inherit {
|
||||||
|
if parent := view.Parent(); parent != nil {
|
||||||
|
return colorStyledProperty(parent, "", tag, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Color(0), false
|
return Color(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FocusView sets focus on the specified View, if it can be focused.
|
// FocusView sets focus on the specified View, if it can be focused.
|
||||||
|
@ -1143,29 +1056,30 @@ func IsUserSelect(view View, subviewID string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func isUserSelect(view View) (bool, bool) {
|
func isUserSelect(view View) (bool, bool) {
|
||||||
result, ok := boolStyledProperty(view, UserSelect)
|
if value, ok := boolProperty(view, UserSelect, view.Session()); ok {
|
||||||
if ok {
|
return value, true
|
||||||
return result, true
|
}
|
||||||
|
if value := valueFromStyle(view, UserSelect); value != nil {
|
||||||
|
if b, ok := valueToBool(value, view.Session()); ok {
|
||||||
|
return b, true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if parent := view.Parent(); parent != nil {
|
if parent := view.Parent(); parent != nil {
|
||||||
result, ok = isUserSelect(parent)
|
if result, ok := isUserSelect(parent); ok {
|
||||||
if ok {
|
|
||||||
return result, true
|
return result, true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !result {
|
switch GetSemantics(view, "") {
|
||||||
switch GetSemantics(view, "") {
|
case ParagraphSemantics, H1Semantics, H2Semantics, H3Semantics, H4Semantics, H5Semantics,
|
||||||
case ParagraphSemantics, H1Semantics, H2Semantics, H3Semantics, H4Semantics, H5Semantics,
|
H6Semantics, BlockquoteSemantics, CodeSemantics:
|
||||||
H6Semantics, BlockquoteSemantics, CodeSemantics:
|
return true, false
|
||||||
return true, false
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, ok := view.(TableView); ok {
|
|
||||||
return true, false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, false
|
if _, ok := view.(TableView); ok {
|
||||||
|
return true, false
|
||||||
|
}
|
||||||
|
|
||||||
|
return false, false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue