forked from mbk-lab/rui_orig
Optimisation
This commit is contained in:
parent
c5ca92de60
commit
3da4d660d5
24
checkbox.go
24
checkbox.go
|
@ -266,8 +266,8 @@ func (button *checkboxData) setChangedListener(value any) bool {
|
||||||
|
|
||||||
func (button *checkboxData) cssStyle(self View, builder cssBuilder) {
|
func (button *checkboxData) cssStyle(self View, builder cssBuilder) {
|
||||||
session := button.Session()
|
session := button.Session()
|
||||||
vAlign, _ := enumStyledProperty(button, CheckboxVerticalAlign, LeftAlign)
|
vAlign := GetCheckboxVerticalAlign(button, "")
|
||||||
hAlign, _ := enumStyledProperty(button, CheckboxHorizontalAlign, TopAlign)
|
hAlign := GetCheckboxHorizontalAlign(button, "")
|
||||||
switch hAlign {
|
switch hAlign {
|
||||||
case CenterAlign:
|
case CenterAlign:
|
||||||
if vAlign == BottomAlign {
|
if vAlign == BottomAlign {
|
||||||
|
@ -294,8 +294,8 @@ func (button *checkboxData) cssStyle(self View, builder cssBuilder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (button *checkboxData) htmlCheckbox(buffer *strings.Builder, checked bool) (int, int) {
|
func (button *checkboxData) htmlCheckbox(buffer *strings.Builder, checked bool) (int, int) {
|
||||||
vAlign, _ := enumStyledProperty(button, CheckboxVerticalAlign, LeftAlign)
|
vAlign := GetCheckboxVerticalAlign(button, "")
|
||||||
hAlign, _ := enumStyledProperty(button, CheckboxHorizontalAlign, TopAlign)
|
hAlign := GetCheckboxHorizontalAlign(button, "")
|
||||||
|
|
||||||
buffer.WriteString(`<div id="`)
|
buffer.WriteString(`<div id="`)
|
||||||
buffer.WriteString(button.htmlID())
|
buffer.WriteString(button.htmlID())
|
||||||
|
@ -370,7 +370,7 @@ func (button *checkboxData) htmlSubviews(self View, buffer *strings.Builder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (button *checkboxData) cssHorizontalAlign() string {
|
func (button *checkboxData) cssHorizontalAlign() string {
|
||||||
align, _ := enumStyledProperty(button, HorizontalAlign, TopAlign)
|
align := GetCheckboxHorizontalAlign(button, "")
|
||||||
values := enumProperties[CellHorizontalAlign].cssValues
|
values := enumProperties[CellHorizontalAlign].cssValues
|
||||||
if align >= 0 && align < len(values) {
|
if align >= 0 && align < len(values) {
|
||||||
return values[align]
|
return values[align]
|
||||||
|
@ -379,7 +379,7 @@ func (button *checkboxData) cssHorizontalAlign() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (button *checkboxData) cssVerticalAlign() string {
|
func (button *checkboxData) cssVerticalAlign() string {
|
||||||
align, _ := enumStyledProperty(button, VerticalAlign, TopAlign)
|
align := GetCheckboxVerticalAlign(button, "")
|
||||||
values := enumProperties[CellVerticalAlign].cssValues
|
values := enumProperties[CellVerticalAlign].cssValues
|
||||||
if align >= 0 && align < len(values) {
|
if align >= 0 && align < len(values) {
|
||||||
return values[align]
|
return values[align]
|
||||||
|
@ -402,3 +402,15 @@ func IsCheckboxChecked(view View, subviewID string) bool {
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetCheckboxVerticalAlign return the vertical align of a Checkbox subview: TopAlign (0), BottomAlign (1), CenterAlign (2)
|
||||||
|
// If the second argument (subviewID) is "" then a left position of the first argument (view) is returned
|
||||||
|
func GetCheckboxVerticalAlign(view View, subviewID string) int {
|
||||||
|
return enumStyledProperty(view, subviewID, VerticalAlign, LeftAlign, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCheckboxHorizontalAlign return the vertical align of a Checkbox subview: LeftAlign (0), RightAlign (1), CenterAlign (2)
|
||||||
|
// If the second argument (subviewID) is "" then a left position of the first argument (view) is returned
|
||||||
|
func GetCheckboxHorizontalAlign(view View, subviewID string) int {
|
||||||
|
return enumStyledProperty(view, subviewID, VerticalAlign, TopAlign, false)
|
||||||
|
}
|
||||||
|
|
|
@ -571,14 +571,7 @@ func GetTextChangedListeners(view View, subviewID string) []func(EditView, strin
|
||||||
// GetEditViewType returns a value of the Type property of EditView.
|
// GetEditViewType returns a value of the Type 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 GetEditViewType(view View, subviewID string) int {
|
func GetEditViewType(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return enumStyledProperty(view, subviewID, EditViewType, SingleLineText, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view == nil {
|
|
||||||
return SingleLineText
|
|
||||||
}
|
|
||||||
t, _ := enumStyledProperty(view, EditViewType, SingleLineText)
|
|
||||||
return t
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetEditViewPattern returns a value of the Pattern property of EditView.
|
// GetEditViewPattern returns a value of the Pattern property of EditView.
|
||||||
|
|
|
@ -325,43 +325,19 @@ func (gridLayout *gridLayoutData) cssStyle(self View, builder cssBuilder) {
|
||||||
// GetCellVerticalAlign returns the vertical align of a GridLayout cell content: TopAlign (0), BottomAlign (1), CenterAlign (2), StretchAlign (3)
|
// GetCellVerticalAlign returns the vertical align of a GridLayout cell content: TopAlign (0), BottomAlign (1), CenterAlign (2), StretchAlign (3)
|
||||||
// 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 GetCellVerticalAlign(view View, subviewID string) int {
|
func GetCellVerticalAlign(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return enumStyledProperty(view, subviewID, CellVerticalAlign, StretchAlign, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if align, ok := enumStyledProperty(view, CellVerticalAlign, StretchAlign); ok {
|
|
||||||
return align
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return StretchAlign
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCellHorizontalAlign returns the vertical align of a GridLayout cell content: LeftAlign (0), RightAlign (1), CenterAlign (2), StretchAlign (3)
|
// GetCellHorizontalAlign returns the vertical align of a GridLayout cell content: LeftAlign (0), RightAlign (1), CenterAlign (2), StretchAlign (3)
|
||||||
// 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 GetCellHorizontalAlign(view View, subviewID string) int {
|
func GetCellHorizontalAlign(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return enumStyledProperty(view, subviewID, CellHorizontalAlign, StretchAlign, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if align, ok := enumStyledProperty(view, CellHorizontalAlign, StretchAlign); ok {
|
|
||||||
return align
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return StretchAlign
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetGridAutoFlow returns the value of the "grid-auto-flow" property
|
// GetGridAutoFlow returns the value of the "grid-auto-flow" property
|
||||||
// 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 GetGridAutoFlow(view View, subviewID string) int {
|
func GetGridAutoFlow(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return enumStyledProperty(view, subviewID, GridAutoFlow, 0, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if align, ok := enumStyledProperty(view, GridAutoFlow, 0); ok {
|
|
||||||
return align
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCellWidth returns the width of a GridLayout cell. If the result is an empty array, then the width is not set.
|
// GetCellWidth returns the width of a GridLayout cell. If the result is an empty array, then the width is not set.
|
||||||
|
|
27
imageView.go
27
imageView.go
|
@ -360,38 +360,17 @@ func GetImageViewAltText(view View, subviewID string) string {
|
||||||
// NoneFit (0), ContainFit (1), CoverFit (2), FillFit (3), or ScaleDownFit (4).
|
// NoneFit (0), ContainFit (1), CoverFit (2), FillFit (3), or ScaleDownFit (4).
|
||||||
// If the second argument (subviewID) is "" then a left position of the first argument (view) is returned
|
// If the second argument (subviewID) is "" then a left position of the first argument (view) is returned
|
||||||
func GetImageViewFit(view View, subviewID string) int {
|
func GetImageViewFit(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return enumStyledProperty(view, subviewID, Fit, NoneFit, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
|
|
||||||
if value, ok := enumStyledProperty(view, Fit, NoneFit); ok {
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetImageViewVerticalAlign return the vertical align of an ImageView subview: TopAlign (0), BottomAlign (1), CenterAlign (2)
|
// GetImageViewVerticalAlign return the vertical align of an ImageView subview: TopAlign (0), BottomAlign (1), CenterAlign (2)
|
||||||
// If the second argument (subviewID) is "" then a left position of the first argument (view) is returned
|
// If the second argument (subviewID) is "" then a left position of the first argument (view) is returned
|
||||||
func GetImageViewVerticalAlign(view View, subviewID string) int {
|
func GetImageViewVerticalAlign(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return enumStyledProperty(view, subviewID, ImageVerticalAlign, LeftAlign, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
|
|
||||||
if align, ok := enumStyledProperty(view, ImageVerticalAlign, LeftAlign); ok {
|
|
||||||
return align
|
|
||||||
}
|
|
||||||
return CenterAlign
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetImageViewHorizontalAlign return the vertical align of an ImageView subview: LeftAlign (0), RightAlign (1), CenterAlign (2)
|
// GetImageViewHorizontalAlign return the vertical align of an ImageView subview: LeftAlign (0), RightAlign (1), CenterAlign (2)
|
||||||
// If the second argument (subviewID) is "" then a left position of the first argument (view) is returned
|
// If the second argument (subviewID) is "" then a left position of the first argument (view) is returned
|
||||||
func GetImageViewHorizontalAlign(view View, subviewID string) int {
|
func GetImageViewHorizontalAlign(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return enumStyledProperty(view, subviewID, ImageHorizontalAlign, LeftAlign, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
|
|
||||||
if align, ok := enumStyledProperty(view, ImageHorizontalAlign, LeftAlign); ok {
|
|
||||||
return align
|
|
||||||
}
|
|
||||||
return CenterAlign
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,16 +163,8 @@ func GetListOrientation(view View, subviewID string) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetListWrap returns the wrap type of a ListLayout or ListView subview:
|
// GetListWrap returns the wrap type of a ListLayout or ListView subview:
|
||||||
// WrapOff (0), WrapOn (1), or WrapReverse (2)
|
// ListWrapOff (0), ListWrapOn (1), or ListWrapReverse (2)
|
||||||
// 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 GetListWrap(view View, subviewID string) int {
|
func GetListWrap(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return enumStyledProperty(view, subviewID, ListWrap, ListWrapOff, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, ok := enumStyledProperty(view, ListWrap, 0); ok {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ListWrapOff
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -917,8 +917,7 @@ func (listView *listViewData) htmlSubviews(self View, buffer *strings.Builder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
value := ""
|
value := ""
|
||||||
if align, ok := enumStyledProperty(listView, HorizontalAlign, LeftAlign); ok {
|
switch enumStyledProperty(listView, "", HorizontalAlign, LeftAlign, false) {
|
||||||
switch align {
|
|
||||||
case LeftAlign:
|
case LeftAlign:
|
||||||
if (!rows && wrap == ListWrapReverse) || orientation == EndToStartOrientation {
|
if (!rows && wrap == ListWrapReverse) || orientation == EndToStartOrientation {
|
||||||
value = `flex-end`
|
value = `flex-end`
|
||||||
|
@ -941,7 +940,6 @@ func (listView *listViewData) htmlSubviews(self View, buffer *strings.Builder) {
|
||||||
value = `stretch`
|
value = `stretch`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if value != "" {
|
if value != "" {
|
||||||
buffer.WriteRune(' ')
|
buffer.WriteRune(' ')
|
||||||
|
@ -952,8 +950,7 @@ func (listView *listViewData) htmlSubviews(self View, buffer *strings.Builder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
value = ""
|
value = ""
|
||||||
if align, ok := enumStyledProperty(listView, VerticalAlign, TopAlign); ok {
|
switch enumStyledProperty(listView, "", VerticalAlign, TopAlign, false) {
|
||||||
switch align {
|
|
||||||
case TopAlign:
|
case TopAlign:
|
||||||
if (rows && wrap == ListWrapReverse) || orientation == BottomUpOrientation {
|
if (rows && wrap == ListWrapReverse) || orientation == BottomUpOrientation {
|
||||||
value = `flex-end`
|
value = `flex-end`
|
||||||
|
@ -976,7 +973,6 @@ func (listView *listViewData) htmlSubviews(self View, buffer *strings.Builder) {
|
||||||
value = `space-between`
|
value = `space-between`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if value != "" {
|
if value != "" {
|
||||||
buffer.WriteRune(' ')
|
buffer.WriteRune(' ')
|
||||||
|
|
|
@ -258,15 +258,7 @@ func (picker *numberPickerData) handleCommand(self View, command string, data Da
|
||||||
// NumberSlider (1) - NumberPicker is presented by slider.
|
// NumberSlider (1) - NumberPicker is presented by slider.
|
||||||
// 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 GetNumberPickerType(view View, subviewID string) int {
|
func GetNumberPickerType(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return enumStyledProperty(view, subviewID, NumberPickerType, NumberEditor, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
t, _ := enumStyledProperty(view, NumberPickerType, NumberEditor)
|
|
||||||
return t
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNumberPickerMinMax returns the min and max value of NumberPicker subview.
|
// GetNumberPickerMinMax returns the min and max value of NumberPicker subview.
|
||||||
|
|
|
@ -91,30 +91,14 @@ func GetTableCellStyle(view View, subviewID string) TableCellStyle {
|
||||||
// Valid values are NoneSelection (0), CellSelection (1), and RowSelection (2).
|
// Valid values are NoneSelection (0), CellSelection (1), and RowSelection (2).
|
||||||
// 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 GetTableSelectionMode(view View, subviewID string) int {
|
func GetTableSelectionMode(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return enumStyledProperty(view, subviewID, SelectionMode, NoneSelection, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, ok := enumStyledProperty(view, SelectionMode, NoneSelection); ok {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NoneSelection
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTableVerticalAlign returns a vertical align in a TavleView cell. Returns one of next values:
|
// GetTableVerticalAlign returns a vertical align in a TavleView cell. Returns one of next values:
|
||||||
// TopAlign (0), BottomAlign (1), CenterAlign (2), and BaselineAlign (3)
|
// TopAlign (0), BottomAlign (1), CenterAlign (2), and BaselineAlign (3)
|
||||||
// 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 GetTableVerticalAlign(view View, subviewID string) int {
|
func GetTableVerticalAlign(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return enumStyledProperty(view, subviewID, TableVerticalAlign, TopAlign, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, ok := enumStyledProperty(view, TableVerticalAlign, TopAlign); ok {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return TopAlign
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTableHeadHeight returns the number of rows in the table header.
|
// GetTableHeadHeight returns the number of rows in the table header.
|
||||||
|
|
|
@ -167,12 +167,5 @@ func (textView *textViewData) htmlSubviews(self View, buffer *strings.Builder) {
|
||||||
// TextOverflowClip (0) or TextOverflowEllipsis (1).
|
// TextOverflowClip (0) or TextOverflowEllipsis (1).
|
||||||
// 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 GetTextOverflow(view View, subviewID string) int {
|
func GetTextOverflow(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return enumStyledProperty(view, subviewID, TextOverflow, SingleLineText, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view == nil {
|
|
||||||
return SingleLineText
|
|
||||||
}
|
|
||||||
t, _ := enumStyledProperty(view, TextOverflow, SingleLineText)
|
|
||||||
return t
|
|
||||||
}
|
}
|
||||||
|
|
163
viewUtils.go
163
viewUtils.go
|
@ -88,16 +88,7 @@ func IsDisabled(view View, subviewID string) bool {
|
||||||
// H1Semantics (12) - H6Semantics (17), BlockquoteSemantics (18), and CodeSemantics (19).
|
// H1Semantics (12) - H6Semantics (17), BlockquoteSemantics (18), and CodeSemantics (19).
|
||||||
// If the second argument (subviewID) is "" then a semantics of the first argument (view) is returned
|
// If the second argument (subviewID) is "" then a semantics of the first argument (view) is returned
|
||||||
func GetSemantics(view View, subviewID string) int {
|
func GetSemantics(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return enumStyledProperty(view, subviewID, Semantics, DefaultSemantics, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if semantics, ok := enumStyledProperty(view, Semantics, DefaultSemantics); ok {
|
|
||||||
return semantics
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return DefaultSemantics
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOpacity returns the subview opacity.
|
// GetOpacity returns the subview opacity.
|
||||||
|
@ -138,28 +129,19 @@ func GetDisabledStyle(view View, subviewID string) string {
|
||||||
// Visible (0), Invisible (1), or Gone (2)
|
// Visible (0), Invisible (1), or Gone (2)
|
||||||
// If the second argument (subviewID) is "" then a visibility of the first argument (view) is returned
|
// If the second argument (subviewID) is "" then a visibility of the first argument (view) is returned
|
||||||
func GetVisibility(view View, subviewID string) int {
|
func GetVisibility(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return enumStyledProperty(view, subviewID, Visibility, Visible, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view == nil {
|
|
||||||
return Visible
|
|
||||||
}
|
|
||||||
result, _ := enumStyledProperty(view, Visibility, Visible)
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOverflow returns a value of the subview "overflow" property. Returns one of next values:
|
// GetOverflow returns a value of the subview "overflow" property. Returns one of next values:
|
||||||
// OverflowHidden (0), OverflowVisible (1), OverflowScroll (2), OverflowAuto (3)
|
// OverflowHidden (0), OverflowVisible (1), OverflowScroll (2), OverflowAuto (3)
|
||||||
// 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 GetOverflow(view View, subviewID string) int {
|
func GetOverflow(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view == nil {
|
|
||||||
return OverflowHidden
|
|
||||||
}
|
|
||||||
|
|
||||||
defaultOverflow := OverflowHidden
|
defaultOverflow := OverflowHidden
|
||||||
|
view2 := view
|
||||||
|
if subviewID != "" {
|
||||||
|
view2 = ViewByID(view, subviewID)
|
||||||
|
}
|
||||||
|
if view2 != nil {
|
||||||
switch view.(type) {
|
switch view.(type) {
|
||||||
case EditView:
|
case EditView:
|
||||||
defaultOverflow = OverflowAuto
|
defaultOverflow = OverflowAuto
|
||||||
|
@ -167,9 +149,8 @@ func GetOverflow(view View, subviewID string) int {
|
||||||
case ListView:
|
case ListView:
|
||||||
defaultOverflow = OverflowAuto
|
defaultOverflow = OverflowAuto
|
||||||
}
|
}
|
||||||
|
}
|
||||||
result, _ := enumStyledProperty(view, Overflow, defaultOverflow)
|
return enumStyledProperty(view, subviewID, Overflow, defaultOverflow, false)
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetZIndex returns the subview z-order.
|
// GetZIndex returns the subview z-order.
|
||||||
|
@ -260,14 +241,7 @@ func GetMaxHeight(view View, subviewID string) SizeUnit {
|
||||||
// NoneResize (0), BothResize (1), HorizontalResize (2), or VerticalResize (3)
|
// NoneResize (0), BothResize (1), HorizontalResize (2), or VerticalResize (3)
|
||||||
// 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 GetResize(view View, subviewID string) int {
|
func GetResize(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return enumStyledProperty(view, subviewID, Resize, NoneResize, false)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
result, _ := enumStyledProperty(view, Resize, 0)
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetLeft returns a left position of the subview in an AbsoluteLayout container.
|
// GetLeft returns a left position of the subview in an AbsoluteLayout container.
|
||||||
|
@ -471,36 +445,14 @@ func GetTextSize(view View, subviewID string) SizeUnit {
|
||||||
// 1, 2, 3, 4 (normal text), 5, 6, 7 (bold text), 8 and 9
|
// 1, 2, 3, 4 (normal text), 5, 6, 7 (bold text), 8 and 9
|
||||||
// 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 GetTextWeight(view View, subviewID string) int {
|
func GetTextWeight(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return enumStyledProperty(view, subviewID, TextWeight, NormalFont, true)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if weight, ok := enumStyledProperty(view, TextWeight, NormalFont); ok {
|
|
||||||
return weight
|
|
||||||
}
|
|
||||||
if parent := view.Parent(); parent != nil {
|
|
||||||
return GetTextWeight(parent, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NormalFont
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTextAlign returns a text align of the subview. Returns one of next values:
|
// GetTextAlign returns a text align of the subview. Returns one of next values:
|
||||||
// LeftAlign = 0, RightAlign = 1, CenterAlign = 2, JustifyAlign = 3
|
// LeftAlign = 0, RightAlign = 1, CenterAlign = 2, JustifyAlign = 3
|
||||||
// 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 GetTextAlign(view View, subviewID string) int {
|
func GetTextAlign(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return enumStyledProperty(view, subviewID, TextAlign, LeftAlign, true)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, ok := enumStyledProperty(view, TextAlign, LeftAlign); ok {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
if parent := view.Parent(); parent != nil {
|
|
||||||
return GetTextAlign(parent, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return LeftAlign
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTextIndent returns a text indent of the subview.
|
// GetTextIndent returns a text indent of the subview.
|
||||||
|
@ -623,18 +575,7 @@ func GetTextLineThickness(view View, subviewID string) SizeUnit {
|
||||||
// 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 GetTextLineStyle(view View, subviewID string) int {
|
func GetTextLineStyle(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return enumStyledProperty(view, subviewID, TextLineStyle, SolidLine, true)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, ok := enumStyledProperty(view, TextLineStyle, SolidLine); ok {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
if parent := view.Parent(); parent != nil {
|
|
||||||
return GetTextLineStyle(parent, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return SolidLine
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTextLineColor returns the stroke color of the decoration line that
|
// GetTextLineColor returns the stroke color of the decoration line that
|
||||||
|
@ -648,18 +589,7 @@ func GetTextLineColor(view View, subviewID string) Color {
|
||||||
// NoneTextTransform (0), CapitalizeTextTransform (1), LowerCaseTextTransform (2) or UpperCaseTextTransform (3)
|
// NoneTextTransform (0), CapitalizeTextTransform (1), LowerCaseTextTransform (2) or UpperCaseTextTransform (3)
|
||||||
// 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 GetTextTransform(view View, subviewID string) int {
|
func GetTextTransform(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return enumStyledProperty(view, subviewID, TextTransform, NoneTextTransform, true)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, ok := enumStyledProperty(view, TextTransform, NoneTextTransform); ok {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
if parent := view.Parent(); parent != nil {
|
|
||||||
return GetTextTransform(parent, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NoneTextTransform
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetWritingMode returns whether lines of text are laid out horizontally or vertically, as well as
|
// GetWritingMode returns whether lines of text are laid out horizontally or vertically, as well as
|
||||||
|
@ -667,37 +597,18 @@ func GetTextTransform(view View, subviewID string) int {
|
||||||
// HorizontalBottomToTop (1), VerticalRightToLeft (2) and VerticalLeftToRight (3)
|
// HorizontalBottomToTop (1), VerticalRightToLeft (2) and VerticalLeftToRight (3)
|
||||||
// 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 GetWritingMode(view View, subviewID string) int {
|
func GetWritingMode(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return enumStyledProperty(view, subviewID, WritingMode, HorizontalTopToBottom, true)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, ok := enumStyledProperty(view, WritingMode, HorizontalTopToBottom); ok {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
if parent := view.Parent(); parent != nil {
|
|
||||||
return GetWritingMode(parent, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return HorizontalTopToBottom
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTextDirection - returns a direction of text, table columns, and horizontal overflow.
|
// GetTextDirection - returns a direction of text, table columns, and horizontal overflow.
|
||||||
// Valid values are Inherit (0), LeftToRightDirection (1), and RightToLeftDirection (2).
|
// Valid values are SystemTextDirection (0), LeftToRightDirection (1), and RightToLeftDirection (2).
|
||||||
// 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 GetTextDirection(view View, subviewID string) int {
|
func GetTextDirection(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
if view == nil {
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, ok := enumStyledProperty(view, TextDirection, SystemTextDirection); ok {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
if parent := view.Parent(); parent != nil {
|
|
||||||
return GetTextDirection(parent, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return SystemTextDirection
|
return SystemTextDirection
|
||||||
// TODO return system text direction
|
}
|
||||||
|
defaultDirection := view.Session().TextDirection()
|
||||||
|
return enumStyledProperty(view, subviewID, TextDirection, defaultDirection, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetVerticalTextOrientation returns a orientation of the text characters in a line. It only affects text
|
// GetVerticalTextOrientation returns a orientation of the text characters in a line. It only affects text
|
||||||
|
@ -705,18 +616,7 @@ func GetTextDirection(view View, subviewID string) int {
|
||||||
// Valid values are MixedTextOrientation (0), UprightTextOrientation (1), and SidewaysTextOrientation (2).
|
// Valid values are MixedTextOrientation (0), UprightTextOrientation (1), and SidewaysTextOrientation (2).
|
||||||
// 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 GetVerticalTextOrientation(view View, subviewID string) int {
|
func GetVerticalTextOrientation(view View, subviewID string) int {
|
||||||
if subviewID != "" {
|
return enumStyledProperty(view, subviewID, VerticalTextOrientation, MixedTextOrientation, true)
|
||||||
view = ViewByID(view, subviewID)
|
|
||||||
}
|
|
||||||
if view != nil {
|
|
||||||
if result, ok := enumStyledProperty(view, VerticalTextOrientation, MixedTextOrientation); ok {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
if parent := view.Parent(); parent != nil {
|
|
||||||
return GetVerticalTextOrientation(parent, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return MixedTextOrientation
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRow returns the range of row numbers of a GridLayout in which the subview is placed.
|
// GetRow returns the range of row numbers of a GridLayout in which the subview is placed.
|
||||||
|
@ -903,14 +803,27 @@ func sizeStyledProperty(view View, tag string) (SizeUnit, bool) {
|
||||||
return AutoSize(), false
|
return AutoSize(), false
|
||||||
}
|
}
|
||||||
|
|
||||||
func enumStyledProperty(view View, tag string, defaultValue int) (int, bool) {
|
func enumStyledProperty(view View, subviewID string, tag string, defaultValue int, inherit bool) int {
|
||||||
|
if subviewID != "" {
|
||||||
|
view = ViewByID(view, subviewID)
|
||||||
|
}
|
||||||
|
if view != nil {
|
||||||
if value, ok := enumProperty(view, tag, view.Session(), defaultValue); ok {
|
if value, ok := enumProperty(view, tag, view.Session(), defaultValue); ok {
|
||||||
return value, true
|
return value
|
||||||
}
|
}
|
||||||
if value := valueFromStyle(view, tag); value != nil {
|
if value := valueFromStyle(view, tag); value != nil {
|
||||||
return valueToEnum(value, tag, view.Session(), defaultValue)
|
if result, ok := valueToEnum(value, tag, view.Session(), defaultValue); ok {
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
return defaultValue, false
|
}
|
||||||
|
|
||||||
|
if inherit {
|
||||||
|
if parent := view.Parent(); parent != nil {
|
||||||
|
return enumStyledProperty(parent, "", tag, defaultValue, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultValue
|
||||||
}
|
}
|
||||||
|
|
||||||
func boolStyledProperty(view View, subviewID string, tag string, inherit bool) bool {
|
func boolStyledProperty(view View, subviewID string, tag string, inherit bool) bool {
|
||||||
|
|
Loading…
Reference in New Issue