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.
|
||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||
func IsAnimationPaused(view View, subviewID string) bool {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if view != nil {
|
||||
if result, ok := boolStyledProperty(view, AnimationPaused); ok {
|
||||
return result
|
||||
}
|
||||
}
|
||||
return false
|
||||
return boolStyledProperty(view, subviewID, AnimationPaused, false)
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
if view != nil {
|
||||
if result, ok := colorStyledProperty(view, ColorPickerValue); ok {
|
||||
return result
|
||||
if value, ok := colorProperty(view, ColorPickerValue, view.Session()); ok {
|
||||
return value
|
||||
}
|
||||
for _, tag := range []string{Value, ColorTag} {
|
||||
for _, tag := range []string{ColorPickerValue, Value, ColorTag} {
|
||||
if value := valueFromStyle(view, tag); value != nil {
|
||||
if result, ok := valueToColor(value, view.Session()); ok {
|
||||
return result
|
||||
|
|
|
@ -139,14 +139,7 @@ func (columnLayout *columnLayoutData) set(tag string, value any) bool {
|
|||
// based on the "column-width" property.
|
||||
// If the second argument (subviewID) is "" then a top position of the first argument (view) is returned
|
||||
func GetColumnCount(view View, subviewID string) int {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if view == nil {
|
||||
return 0
|
||||
}
|
||||
result, _ := intStyledProperty(view, ColumnCount, 0)
|
||||
return result
|
||||
return intStyledProperty(view, subviewID, ColumnCount, 0)
|
||||
}
|
||||
|
||||
// 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.
|
||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||
func GetDatePickerStep(view View, subviewID string) int {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if view != nil {
|
||||
if result, _ := intStyledProperty(view, DatePickerStep, 0); result >= 0 {
|
||||
return result
|
||||
}
|
||||
}
|
||||
return 0
|
||||
return intStyledProperty(view, subviewID, DatePickerStep, 0)
|
||||
}
|
||||
|
||||
// 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.
|
||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||
func IsDetailsExpanded(view View, subviewID string) bool {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if view != nil {
|
||||
if result, ok := boolStyledProperty(view, Expanded); ok {
|
||||
return result
|
||||
}
|
||||
}
|
||||
return false
|
||||
return boolStyledProperty(view, subviewID, Expanded, 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
|
||||
// If the second argument (subviewID) is "" then a value of the first argument (view) is returned.
|
||||
func GetMaxLength(view View, subviewID string) int {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if view != nil {
|
||||
if result, ok := intStyledProperty(view, MaxLength, 0); ok {
|
||||
return result
|
||||
}
|
||||
}
|
||||
return 0
|
||||
return intStyledProperty(view, subviewID, MaxLength, 0)
|
||||
}
|
||||
|
||||
// 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.
|
||||
func IsReadOnly(view View, subviewID string) bool {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if view != nil {
|
||||
if result, ok := boolStyledProperty(view, ReadOnly); ok {
|
||||
return result
|
||||
}
|
||||
}
|
||||
return false
|
||||
return boolStyledProperty(view, subviewID, ReadOnly, false)
|
||||
}
|
||||
|
||||
// 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.
|
||||
func IsSpellcheck(view View, subviewID string) bool {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if view != nil {
|
||||
if spellcheck, ok := boolStyledProperty(view, Spellcheck); ok {
|
||||
return spellcheck
|
||||
}
|
||||
}
|
||||
return false
|
||||
return boolStyledProperty(view, subviewID, Spellcheck, false)
|
||||
}
|
||||
|
||||
// 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.
|
||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||
func IsEditViewWrap(view View, subviewID string) bool {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if view != nil {
|
||||
if wrap, ok := boolStyledProperty(view, EditWrap); ok {
|
||||
return wrap
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
||||
return boolStyledProperty(view, subviewID, EditWrap, false)
|
||||
}
|
||||
|
||||
// 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.
|
||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||
func GetCaretColor(view View, subviewID string) Color {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if view == nil {
|
||||
return 0
|
||||
}
|
||||
t, _ := colorStyledProperty(view, CaretColor)
|
||||
return t
|
||||
return colorStyledProperty(view, subviewID, CaretColor, false)
|
||||
}
|
||||
|
|
|
@ -251,7 +251,7 @@ func (picker *filePickerData) htmlProperties(self View, buffer *strings.Builder)
|
|||
}
|
||||
|
||||
buffer.WriteString(` type="file"`)
|
||||
if multiple, ok := boolStyledProperty(picker, Multiple); ok && multiple {
|
||||
if IsMultipleFilePicker(picker, "") {
|
||||
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.
|
||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||
func IsMultipleFilePicker(view View, subviewID string) bool {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if view != nil {
|
||||
if result, ok := boolStyledProperty(view, Multiple); ok {
|
||||
return result
|
||||
}
|
||||
}
|
||||
return false
|
||||
return boolStyledProperty(view, subviewID, Multiple, false)
|
||||
}
|
||||
|
||||
// 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.
|
||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||
func GetNumberPickerMinMax(view View, subviewID string) (float64, float64) {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
var defMin, defMax float64
|
||||
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 {
|
||||
defMin = 0
|
||||
defMax = 1
|
||||
} else {
|
||||
defMin = math.Inf(-1)
|
||||
defMax = math.Inf(1)
|
||||
}
|
||||
min, ok := floatStyledProperty(view, NumberPickerMin, defMin)
|
||||
if !ok {
|
||||
min, _ = floatStyledProperty(view, Min, defMin)
|
||||
}
|
||||
min := floatStyledProperty(view, subviewID, NumberPickerMin, defMin)
|
||||
max := floatStyledProperty(view, subviewID, NumberPickerMax, defMax)
|
||||
|
||||
max, ok := floatStyledProperty(view, NumberPickerMax, defMax)
|
||||
if !ok {
|
||||
max, _ = floatStyledProperty(view, Max, defMax)
|
||||
}
|
||||
|
||||
if min > max {
|
||||
return max, min
|
||||
}
|
||||
return min, max
|
||||
if min > max {
|
||||
return max, min
|
||||
}
|
||||
return 0, 1
|
||||
return min, max
|
||||
}
|
||||
|
||||
// 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.
|
||||
func GetNumberPickerStep(view View, subviewID string) float64 {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if view == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
result, ok := floatStyledProperty(view, NumberPickerStep, 0)
|
||||
if !ok {
|
||||
result, _ = floatStyledProperty(view, Step, 0)
|
||||
}
|
||||
|
||||
_, max := GetNumberPickerMinMax(view, "")
|
||||
_, max := GetNumberPickerMinMax(view, subviewID)
|
||||
result := floatStyledProperty(view, subviewID, NumberPickerStep, 0)
|
||||
if result > max {
|
||||
return max
|
||||
}
|
||||
|
@ -329,18 +304,8 @@ func GetNumberPickerStep(view View, subviewID string) float64 {
|
|||
// GetNumberPickerValue returns the value of NumberPicker subview.
|
||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||
func GetNumberPickerValue(view View, subviewID string) float64 {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if view == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
min, _ := GetNumberPickerMinMax(view, "")
|
||||
result, ok := floatStyledProperty(view, NumberPickerValue, min)
|
||||
if !ok {
|
||||
result, _ = floatStyledProperty(view, Value, min)
|
||||
}
|
||||
min, _ := GetNumberPickerMinMax(view, subviewID)
|
||||
result := floatStyledProperty(view, subviewID, NumberPickerValue, min)
|
||||
return result
|
||||
}
|
||||
|
||||
|
|
|
@ -108,33 +108,11 @@ func (progress *progressBarData) htmlProperties(self View, buffer *strings.Build
|
|||
// GetProgressBarMax returns the max value of ProgressBar subview.
|
||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||
func GetProgressBarMax(view View, subviewID string) float64 {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if view == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
result, ok := floatStyledProperty(view, ProgressBarMax, 1)
|
||||
if !ok {
|
||||
result, _ = floatStyledProperty(view, Max, 1)
|
||||
}
|
||||
return result
|
||||
return floatStyledProperty(view, subviewID, ProgressBarMax, 1)
|
||||
}
|
||||
|
||||
// GetProgressBarValue returns the value of ProgressBar subview.
|
||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||
func GetProgressBarValue(view View, subviewID string) float64 {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if view == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
result, ok := floatStyledProperty(view, ProgressBarValue, 0)
|
||||
if !ok {
|
||||
result, _ = floatStyledProperty(view, Value, 0)
|
||||
}
|
||||
return result
|
||||
return floatStyledProperty(view, subviewID, ProgressBarValue, 0)
|
||||
}
|
||||
|
|
|
@ -120,27 +120,13 @@ func GetTableVerticalAlign(view View, subviewID string) int {
|
|||
// 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.
|
||||
func GetTableHeadHeight(view View, subviewID string) int {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if view != nil {
|
||||
headHeight, _ := intStyledProperty(view, HeadHeight, 0)
|
||||
return headHeight
|
||||
}
|
||||
return 0
|
||||
return intStyledProperty(view, subviewID, HeadHeight, 0)
|
||||
}
|
||||
|
||||
// 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.
|
||||
func GetTableFootHeight(view View, subviewID string) int {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if view != nil {
|
||||
headHeight, _ := intStyledProperty(view, FootHeight, 0)
|
||||
return headHeight
|
||||
}
|
||||
return 0
|
||||
return intStyledProperty(view, subviewID, FootHeight, 0)
|
||||
}
|
||||
|
||||
// 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.
|
||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||
func GetTimePickerStep(view View, subviewID string) int {
|
||||
if subviewID != "" {
|
||||
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
|
||||
return intStyledProperty(view, subviewID, TimePickerStep, 60)
|
||||
}
|
||||
|
||||
// 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.
|
||||
// If the second argument (subviewID) is "" then an opacity of the first argument (view) is returned
|
||||
func GetOpacity(view View, subviewID string) float64 {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if view != nil {
|
||||
if style, ok := floatStyledProperty(view, Opacity, 1); ok {
|
||||
return style
|
||||
}
|
||||
}
|
||||
return 1
|
||||
return floatStyledProperty(view, subviewID, Opacity, 1)
|
||||
}
|
||||
|
||||
// GetStyle returns the subview style id.
|
||||
|
@ -183,14 +175,7 @@ func GetOverflow(view View, subviewID string) int {
|
|||
// GetZIndex returns the subview z-order.
|
||||
// If the second argument (subviewID) is "" then a z-order of the first argument (view) is returned
|
||||
func GetZIndex(view View, subviewID string) int {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if view == nil {
|
||||
return 0
|
||||
}
|
||||
result, _ := intStyledProperty(view, Visibility, 0)
|
||||
return result
|
||||
return intStyledProperty(view, subviewID, Visibility, 0)
|
||||
}
|
||||
|
||||
// GetWidth returns the subview width.
|
||||
|
@ -434,14 +419,7 @@ func GetTextShadows(view View, subviewID string) []ViewShadow {
|
|||
// GetBackgroundColor returns a background color of the subview.
|
||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||
func GetBackgroundColor(view View, subviewID string) Color {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if view == nil {
|
||||
return 0
|
||||
}
|
||||
color, _ := colorStyledProperty(view, BackgroundColor)
|
||||
return color
|
||||
return colorStyledProperty(view, subviewID, BackgroundColor, false)
|
||||
}
|
||||
|
||||
// GetFontName returns the subview font.
|
||||
|
@ -469,18 +447,7 @@ func GetFontName(view View, subviewID string) string {
|
|||
// GetTextColor returns a text color of the subview.
|
||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||
func GetTextColor(view View, subviewID string) Color {
|
||||
if subviewID != "" {
|
||||
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
|
||||
return colorStyledProperty(view, subviewID, TextColor, true)
|
||||
}
|
||||
|
||||
// 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.
|
||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||
func IsItalic(view View, subviewID string) bool {
|
||||
if subviewID != "" {
|
||||
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
|
||||
return boolStyledProperty(view, subviewID, Italic, true)
|
||||
}
|
||||
|
||||
// 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.
|
||||
func IsSmallCaps(view View, subviewID string) bool {
|
||||
if subviewID != "" {
|
||||
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
|
||||
return boolStyledProperty(view, subviewID, SmallCaps, true)
|
||||
}
|
||||
|
||||
// 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.
|
||||
func IsStrikethrough(view View, subviewID string) bool {
|
||||
if subviewID != "" {
|
||||
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
|
||||
return boolStyledProperty(view, subviewID, Strikethrough, true)
|
||||
}
|
||||
|
||||
// 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.
|
||||
func IsOverline(view View, subviewID string) bool {
|
||||
if subviewID != "" {
|
||||
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
|
||||
return boolStyledProperty(view, subviewID, Overline, true)
|
||||
}
|
||||
|
||||
// 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.
|
||||
func IsUnderline(view View, subviewID string) bool {
|
||||
if subviewID != "" {
|
||||
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
|
||||
return boolStyledProperty(view, subviewID, Underline, true)
|
||||
}
|
||||
|
||||
// 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.
|
||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||
func GetTextLineColor(view View, subviewID string) Color {
|
||||
if subviewID != "" {
|
||||
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
|
||||
return colorStyledProperty(view, subviewID, TextLineColor, true)
|
||||
}
|
||||
|
||||
// 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.
|
||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||
func GetBackfaceVisible(view View, subviewID string) bool {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if view != nil {
|
||||
if result, ok := boolStyledProperty(view, BackfaceVisible); ok {
|
||||
return result
|
||||
}
|
||||
}
|
||||
return true
|
||||
return boolStyledProperty(view, subviewID, BackfaceVisible, false)
|
||||
}
|
||||
|
||||
// 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.
|
||||
// If the second argument (subviewID) is "" then a top position of the first argument (view) is returned
|
||||
func GetAvoidBreak(view View, subviewID string) bool {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if view == nil {
|
||||
return false
|
||||
}
|
||||
result, _ := boolStyledProperty(view, AvoidBreak)
|
||||
return result
|
||||
return boolStyledProperty(view, subviewID, AvoidBreak, true)
|
||||
}
|
||||
|
||||
func GetNotTranslate(view View, subviewID string) bool {
|
||||
if subviewID != "" {
|
||||
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
|
||||
return boolStyledProperty(view, subviewID, NotTranslate, true)
|
||||
}
|
||||
|
||||
func valueFromStyle(view View, tag string) any {
|
||||
|
@ -1038,45 +913,83 @@ func enumStyledProperty(view View, tag string, defaultValue int) (int, bool) {
|
|||
return defaultValue, false
|
||||
}
|
||||
|
||||
func boolStyledProperty(view View, tag string) (bool, bool) {
|
||||
if value, ok := boolProperty(view, tag, view.Session()); ok {
|
||||
return value, true
|
||||
func boolStyledProperty(view View, subviewID string, tag string, inherit bool) bool {
|
||||
if subviewID != "" {
|
||||
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) {
|
||||
if value, ok := intProperty(view, tag, view.Session(), defaultValue); ok {
|
||||
return value, true
|
||||
func intStyledProperty(view View, subviewID string, tag string, defaultValue int) int {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if value := valueFromStyle(view, tag); value != nil {
|
||||
return valueToInt(value, view.Session(), defaultValue)
|
||||
if view != nil {
|
||||
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) {
|
||||
if value, ok := floatProperty(view, tag, view.Session(), defaultValue); ok {
|
||||
return value, true
|
||||
func floatStyledProperty(view View, subviewID string, tag string, defaultValue float64) float64 {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if value := valueFromStyle(view, tag); value != nil {
|
||||
return valueToFloat(value, view.Session(), defaultValue)
|
||||
if view != nil {
|
||||
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, false
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
func colorStyledProperty(view View, tag string) (Color, bool) {
|
||||
if value, ok := colorProperty(view, tag, view.Session()); ok {
|
||||
return value, true
|
||||
func colorStyledProperty(view View, subviewID, tag string, inherit bool) Color {
|
||||
if subviewID != "" {
|
||||
view = ViewByID(view, subviewID)
|
||||
}
|
||||
if value := valueFromStyle(view, tag); value != nil {
|
||||
return valueToColor(value, view.Session())
|
||||
if view != nil {
|
||||
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.
|
||||
|
@ -1143,29 +1056,30 @@ func IsUserSelect(view View, subviewID string) bool {
|
|||
}
|
||||
|
||||
func isUserSelect(view View) (bool, bool) {
|
||||
result, ok := boolStyledProperty(view, UserSelect)
|
||||
if ok {
|
||||
return result, true
|
||||
if value, ok := boolProperty(view, UserSelect, view.Session()); ok {
|
||||
return value, 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 {
|
||||
result, ok = isUserSelect(parent)
|
||||
if ok {
|
||||
if result, ok := isUserSelect(parent); ok {
|
||||
return result, true
|
||||
}
|
||||
}
|
||||
|
||||
if !result {
|
||||
switch GetSemantics(view, "") {
|
||||
case ParagraphSemantics, H1Semantics, H2Semantics, H3Semantics, H4Semantics, H5Semantics,
|
||||
H6Semantics, BlockquoteSemantics, CodeSemantics:
|
||||
return true, false
|
||||
}
|
||||
|
||||
if _, ok := view.(TableView); ok {
|
||||
return true, false
|
||||
}
|
||||
switch GetSemantics(view, "") {
|
||||
case ParagraphSemantics, H1Semantics, H2Semantics, H3Semantics, H4Semantics, H5Semantics,
|
||||
H6Semantics, BlockquoteSemantics, CodeSemantics:
|
||||
return true, false
|
||||
}
|
||||
|
||||
return result, false
|
||||
if _, ok := view.(TableView); ok {
|
||||
return true, false
|
||||
}
|
||||
|
||||
return false, false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue