2021-09-07 17:36:50 +03:00
|
|
|
package rui
|
|
|
|
|
|
|
|
// Get returns a value of the property with name "tag" of the "rootView" subview with "viewID" id value.
|
|
|
|
// The type of return value depends on the property.
|
|
|
|
// If the subview don't exists or the property is not set then nil is returned.
|
2022-07-26 18:36:00 +03:00
|
|
|
func Get(rootView View, viewID, tag string) any {
|
2021-11-20 11:15:28 +03:00
|
|
|
var view View
|
|
|
|
if viewID != "" {
|
|
|
|
view = ViewByID(rootView, viewID)
|
|
|
|
} else {
|
|
|
|
view = rootView
|
|
|
|
}
|
|
|
|
if view != nil {
|
2021-09-07 17:36:50 +03:00
|
|
|
return view.Get(tag)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set sets the property with name "tag" of the "rootView" subview with "viewID" id by value. Result:
|
2021-11-04 14:59:25 +03:00
|
|
|
// true - success,
|
|
|
|
// false - error (incompatible type or invalid format of a string value, see AppLog).
|
2022-07-26 18:36:00 +03:00
|
|
|
func Set(rootView View, viewID, tag string, value any) bool {
|
2021-11-20 11:15:28 +03:00
|
|
|
var view View
|
|
|
|
if viewID != "" {
|
|
|
|
view = ViewByID(rootView, viewID)
|
|
|
|
} else {
|
|
|
|
view = rootView
|
|
|
|
}
|
|
|
|
if view != nil {
|
2021-09-07 17:36:50 +03:00
|
|
|
return view.Set(tag, value)
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2021-11-20 11:15:28 +03:00
|
|
|
// SetChangeListener sets a listener for changing a subview property value.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a listener for the first argument (view) is set
|
2021-11-20 11:15:28 +03:00
|
|
|
func SetChangeListener(view View, viewID, tag string, listener func(View, string)) {
|
|
|
|
if viewID != "" {
|
|
|
|
view = ViewByID(view, viewID)
|
|
|
|
}
|
|
|
|
if view != nil {
|
|
|
|
view.SetChangeListener(tag, listener)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-07 17:36:50 +03:00
|
|
|
// SetParams sets properties with name "tag" of the "rootView" subview. Result:
|
2021-11-04 14:59:25 +03:00
|
|
|
// true - all properties were set successful,
|
|
|
|
// false - error (incompatible type or invalid format of a string value, see AppLog).
|
2021-09-07 17:36:50 +03:00
|
|
|
func SetParams(rootView View, viewID string, params Params) bool {
|
2022-06-17 19:26:24 +03:00
|
|
|
if viewID != "" {
|
2022-07-22 13:10:55 +03:00
|
|
|
rootView = ViewByID(rootView, viewID)
|
2022-06-17 19:26:24 +03:00
|
|
|
}
|
2022-07-22 13:10:55 +03:00
|
|
|
if rootView == nil {
|
2021-09-07 17:36:50 +03:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-07-22 13:10:55 +03:00
|
|
|
session := rootView.Session()
|
|
|
|
session.startUpdateScript(rootView.htmlID())
|
2021-09-07 17:36:50 +03:00
|
|
|
result := true
|
|
|
|
for tag, value := range params {
|
2022-07-22 13:10:55 +03:00
|
|
|
result = rootView.Set(tag, value) && result
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
2022-07-22 13:10:55 +03:00
|
|
|
session.finishUpdateScript(rootView.htmlID())
|
2021-09-07 17:36:50 +03:00
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2021-11-20 11:15:28 +03:00
|
|
|
// IsDisabled returns "true" if the subview is disabled
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a state of the first argument (view) is returned
|
|
|
|
func IsDisabled(view View, subviewID ...string) bool {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-11-20 11:15:28 +03:00
|
|
|
}
|
2022-07-01 18:01:25 +03:00
|
|
|
if view != nil {
|
|
|
|
if disabled, _ := boolProperty(view, Disabled, view.Session()); disabled {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
if parent := view.Parent(); parent != nil {
|
2022-08-31 22:17:46 +03:00
|
|
|
return IsDisabled(parent)
|
2022-07-01 18:01:25 +03:00
|
|
|
}
|
2021-11-20 11:15:28 +03:00
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2021-09-07 17:36:50 +03:00
|
|
|
// GetSemantics returns the subview semantics. Valid semantics values are
|
|
|
|
// DefaultSemantics (0), ArticleSemantics (1), SectionSemantics (2), AsideSemantics (3),
|
|
|
|
// HeaderSemantics (4), MainSemantics (5), FooterSemantics (6), NavigationSemantics (7),
|
|
|
|
// FigureSemantics (8), FigureCaptionSemantics (9), ButtonSemantics (10), ParagraphSemantics (11),
|
|
|
|
// H1Semantics (12) - H6Semantics (17), BlockquoteSemantics (18), and CodeSemantics (19).
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a semantics of the first argument (view) is returned
|
|
|
|
func GetSemantics(view View, subviewID ...string) int {
|
2022-07-28 12:41:50 +03:00
|
|
|
return enumStyledProperty(view, subviewID, Semantics, DefaultSemantics, false)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetOpacity returns the subview opacity.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then an opacity of the first argument (view) is returned
|
|
|
|
func GetOpacity(view View, subviewID ...string) float64 {
|
2022-07-28 12:11:27 +03:00
|
|
|
return floatStyledProperty(view, subviewID, Opacity, 1)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetStyle returns the subview style id.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a style of the first argument (view) is returned
|
|
|
|
func GetStyle(view View, subviewID ...string) string {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
if view != nil {
|
|
|
|
if style, ok := stringProperty(view, Style, view.Session()); ok {
|
|
|
|
return style
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetDisabledStyle returns the disabled subview style id.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a style of the first argument (view) is returned
|
|
|
|
func GetDisabledStyle(view View, subviewID ...string) string {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
if view != nil {
|
|
|
|
if style, ok := stringProperty(view, StyleDisabled, view.Session()); ok {
|
|
|
|
return style
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetVisibility returns the subview visibility. One of the following values is returned:
|
|
|
|
// Visible (0), Invisible (1), or Gone (2)
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a visibility of the first argument (view) is returned
|
|
|
|
func GetVisibility(view View, subviewID ...string) int {
|
2022-07-28 12:41:50 +03:00
|
|
|
return enumStyledProperty(view, subviewID, Visibility, Visible, false)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
2022-07-27 13:26:36 +03:00
|
|
|
// GetOverflow returns a value of the subview "overflow" property. Returns one of next values:
|
|
|
|
// OverflowHidden (0), OverflowVisible (1), OverflowScroll (2), OverflowAuto (3)
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value of the first argument (view) is returned
|
|
|
|
func GetOverflow(view View, subviewID ...string) int {
|
2022-07-28 12:41:50 +03:00
|
|
|
defaultOverflow := OverflowHidden
|
|
|
|
view2 := view
|
2022-08-31 22:17:46 +03:00
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view2 = ViewByID(view, subviewID[0])
|
2022-07-27 13:26:36 +03:00
|
|
|
}
|
2022-07-28 12:41:50 +03:00
|
|
|
if view2 != nil {
|
|
|
|
switch view.(type) {
|
|
|
|
case EditView:
|
|
|
|
defaultOverflow = OverflowAuto
|
2022-07-27 13:26:36 +03:00
|
|
|
|
2022-07-28 12:41:50 +03:00
|
|
|
case ListView:
|
|
|
|
defaultOverflow = OverflowAuto
|
|
|
|
}
|
2022-07-27 13:26:36 +03:00
|
|
|
}
|
2022-07-28 12:41:50 +03:00
|
|
|
return enumStyledProperty(view, subviewID, Overflow, defaultOverflow, false)
|
2022-07-27 13:26:36 +03:00
|
|
|
}
|
|
|
|
|
2021-09-07 17:36:50 +03:00
|
|
|
// GetZIndex returns the subview z-order.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a z-order of the first argument (view) is returned
|
|
|
|
func GetZIndex(view View, subviewID ...string) int {
|
2022-08-20 20:05:56 +03:00
|
|
|
return intStyledProperty(view, subviewID, ZIndex, 0)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
2022-12-18 18:37:36 +03:00
|
|
|
// GetOrder returns the subview order to layout an item in a ListLayout or GridLayout container.
|
|
|
|
// If the second argument (subviewID) is not specified or it is "" then an order of the first argument (view) is returned
|
|
|
|
func GetOrder(view View, subviewID ...string) int {
|
|
|
|
return intStyledProperty(view, subviewID, Order, 0)
|
|
|
|
}
|
|
|
|
|
2021-09-07 17:36:50 +03:00
|
|
|
// GetWidth returns the subview width.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a width of the first argument (view) is returned
|
|
|
|
func GetWidth(view View, subviewID ...string) SizeUnit {
|
2022-07-28 12:53:50 +03:00
|
|
|
return sizeStyledProperty(view, subviewID, Width, false)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetHeight returns the subview height.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a height of the first argument (view) is returned
|
|
|
|
func GetHeight(view View, subviewID ...string) SizeUnit {
|
2022-07-28 12:53:50 +03:00
|
|
|
return sizeStyledProperty(view, subviewID, Height, false)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetMinWidth returns a minimal subview width.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a minimal width of the first argument (view) is returned
|
|
|
|
func GetMinWidth(view View, subviewID ...string) SizeUnit {
|
2022-07-28 12:53:50 +03:00
|
|
|
return sizeStyledProperty(view, subviewID, MinWidth, false)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetMinHeight returns a minimal subview height.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a minimal height of the first argument (view) is returned
|
|
|
|
func GetMinHeight(view View, subviewID ...string) SizeUnit {
|
2022-07-28 12:53:50 +03:00
|
|
|
return sizeStyledProperty(view, subviewID, MinHeight, false)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetMaxWidth returns a maximal subview width.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a maximal width of the first argument (view) is returned
|
|
|
|
func GetMaxWidth(view View, subviewID ...string) SizeUnit {
|
2022-07-28 12:53:50 +03:00
|
|
|
return sizeStyledProperty(view, subviewID, MaxWidth, false)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetMaxHeight returns a maximal subview height.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a maximal height of the first argument (view) is returned
|
|
|
|
func GetMaxHeight(view View, subviewID ...string) SizeUnit {
|
2022-07-28 12:53:50 +03:00
|
|
|
return sizeStyledProperty(view, subviewID, MaxHeight, false)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
Added some properties and functions
* Added "resize", "grid-auto-flow", "caret-color", and "backdrop-filter" properties
* Added BlurView, BlurViewByID, GetResize, GetGridAutoFlow, GetCaretColor, GetBackdropFilter functions
* The "warp" property for ListView and ListLayout renamed to "list-warp"
* The "warp" property for EditView renamed to "edit-warp"
* Added CertFile and KeyFile optional fields to the AppParams struct.If they are set, then an https connection is created, otherwise http.
2022-06-07 13:07:10 +03:00
|
|
|
// GetResize returns the "resize" property value if the subview. One of the following values is returned:
|
|
|
|
// NoneResize (0), BothResize (1), HorizontalResize (2), or VerticalResize (3)
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value of the first argument (view) is returned
|
|
|
|
func GetResize(view View, subviewID ...string) int {
|
2022-07-28 12:41:50 +03:00
|
|
|
return enumStyledProperty(view, subviewID, Resize, NoneResize, false)
|
Added some properties and functions
* Added "resize", "grid-auto-flow", "caret-color", and "backdrop-filter" properties
* Added BlurView, BlurViewByID, GetResize, GetGridAutoFlow, GetCaretColor, GetBackdropFilter functions
* The "warp" property for ListView and ListLayout renamed to "list-warp"
* The "warp" property for EditView renamed to "edit-warp"
* Added CertFile and KeyFile optional fields to the AppParams struct.If they are set, then an https connection is created, otherwise http.
2022-06-07 13:07:10 +03:00
|
|
|
}
|
|
|
|
|
2021-09-07 17:36:50 +03:00
|
|
|
// GetLeft returns a left position of the subview in an AbsoluteLayout container.
|
|
|
|
// If a parent view is not an AbsoluteLayout container then this value is ignored.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a left position of the first argument (view) is returned
|
|
|
|
func GetLeft(view View, subviewID ...string) SizeUnit {
|
2022-07-28 12:53:50 +03:00
|
|
|
return sizeStyledProperty(view, subviewID, Left, false)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetRight returns a right position of the subview in an AbsoluteLayout container.
|
|
|
|
// If a parent view is not an AbsoluteLayout container then this value is ignored.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a right position of the first argument (view) is returned
|
|
|
|
func GetRight(view View, subviewID ...string) SizeUnit {
|
2022-07-28 12:53:50 +03:00
|
|
|
return sizeStyledProperty(view, subviewID, Right, false)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetTop returns a top position of the subview in an AbsoluteLayout container.
|
|
|
|
// If a parent view is not an AbsoluteLayout container then this value is ignored.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
|
|
|
|
func GetTop(view View, subviewID ...string) SizeUnit {
|
2022-07-28 12:53:50 +03:00
|
|
|
return sizeStyledProperty(view, subviewID, Top, false)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetBottom returns a top position of the subview in an AbsoluteLayout container.
|
|
|
|
// If a parent view is not an AbsoluteLayout container then this value is ignored.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a bottom position of the first argument (view) is returned
|
|
|
|
func GetBottom(view View, subviewID ...string) SizeUnit {
|
2022-07-28 12:53:50 +03:00
|
|
|
return sizeStyledProperty(view, subviewID, Bottom, false)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Margin returns the subview margin.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a margin of the first argument (view) is returned
|
|
|
|
func GetMargin(view View, subviewID ...string) Bounds {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
var bounds Bounds
|
|
|
|
if view != nil {
|
|
|
|
bounds.setFromProperties(Margin, MarginTop, MarginRight, MarginBottom, MarginLeft, view, view.Session())
|
|
|
|
}
|
|
|
|
return bounds
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetPadding returns the subview padding.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a padding of the first argument (view) is returned
|
|
|
|
func GetPadding(view View, subviewID ...string) Bounds {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
var bounds Bounds
|
|
|
|
if view != nil {
|
|
|
|
bounds.setFromProperties(Padding, PaddingTop, PaddingRight, PaddingBottom, PaddingLeft, view, view.Session())
|
|
|
|
}
|
|
|
|
return bounds
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetBorder returns ViewBorders of the subview.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a ViewBorders of the first argument (view) is returned.
|
|
|
|
func GetBorder(view View, subviewID ...string) ViewBorders {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
if view != nil {
|
|
|
|
if border := getBorder(view, Border); border != nil {
|
|
|
|
return border.ViewBorders(view.Session())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ViewBorders{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Radius returns the BoxRadius structure of the subview.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a BoxRadius of the first argument (view) is returned.
|
|
|
|
func GetRadius(view View, subviewID ...string) BoxRadius {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
if view == nil {
|
|
|
|
return BoxRadius{}
|
|
|
|
}
|
|
|
|
return getRadius(view, view.Session())
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetOutline returns ViewOutline of the subview.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a ViewOutline of the first argument (view) is returned.
|
|
|
|
func GetOutline(view View, subviewID ...string) ViewOutline {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
if view != nil {
|
|
|
|
if outline := getOutline(view); outline != nil {
|
|
|
|
return outline.ViewOutline(view.Session())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ViewOutline{Style: NoneLine, Width: AutoSize(), Color: 0}
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetViewShadows returns shadows of the subview.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then shadows of the first argument (view) is returned.
|
|
|
|
func GetViewShadows(view View, subviewID ...string) []ViewShadow {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
if view == nil {
|
|
|
|
return []ViewShadow{}
|
|
|
|
}
|
|
|
|
return getShadows(view, Shadow)
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetTextShadows returns text shadows of the subview.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then shadows of the first argument (view) is returned.
|
|
|
|
func GetTextShadows(view View, subviewID ...string) []ViewShadow {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
if view == nil {
|
|
|
|
return []ViewShadow{}
|
|
|
|
}
|
|
|
|
return getShadows(view, TextShadow)
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetBackgroundColor returns a background color of the subview.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetBackgroundColor(view View, subviewID ...string) Color {
|
2022-07-28 12:11:27 +03:00
|
|
|
return colorStyledProperty(view, subviewID, BackgroundColor, false)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
2022-08-20 19:13:51 +03:00
|
|
|
// GetAccentColor returns the accent color for UI controls generated by some elements.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetAccentColor(view View, subviewID ...string) Color {
|
2022-08-20 19:13:51 +03:00
|
|
|
return colorStyledProperty(view, subviewID, AccentColor, false)
|
|
|
|
}
|
|
|
|
|
2021-09-07 17:36:50 +03:00
|
|
|
// GetFontName returns the subview font.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetFontName(view View, subviewID ...string) string {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
if view != nil {
|
|
|
|
if font, ok := stringProperty(view, FontName, view.Session()); ok {
|
|
|
|
return font
|
|
|
|
}
|
2022-05-23 15:22:14 +03:00
|
|
|
if value := valueFromStyle(view, FontName); value != nil {
|
|
|
|
if font, ok := value.(string); ok {
|
|
|
|
return font
|
|
|
|
}
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
if parent := view.Parent(); parent != nil {
|
2022-08-31 22:17:46 +03:00
|
|
|
return GetFontName(parent)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetTextColor returns a text color of the subview.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetTextColor(view View, subviewID ...string) Color {
|
2022-07-28 12:11:27 +03:00
|
|
|
return colorStyledProperty(view, subviewID, TextColor, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetTextSize returns a text size of the subview.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetTextSize(view View, subviewID ...string) SizeUnit {
|
2022-07-28 12:53:50 +03:00
|
|
|
return sizeStyledProperty(view, subviewID, TextSize, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
2022-08-20 20:05:56 +03:00
|
|
|
// GetTabSize returns the subview width of tab characters (U+0009) in spaces.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a width of the first argument (view) is returned
|
|
|
|
func GetTabSize(view View, subviewID ...string) int {
|
2022-08-20 20:05:56 +03:00
|
|
|
return intStyledProperty(view, subviewID, TabSize, 8)
|
|
|
|
}
|
|
|
|
|
2021-09-07 17:36:50 +03:00
|
|
|
// GetTextWeight returns a text weight of the subview. Returns one of next values:
|
|
|
|
// 1, 2, 3, 4 (normal text), 5, 6, 7 (bold text), 8 and 9
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetTextWeight(view View, subviewID ...string) int {
|
2022-07-28 12:41:50 +03:00
|
|
|
return enumStyledProperty(view, subviewID, TextWeight, NormalFont, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetTextAlign returns a text align of the subview. Returns one of next values:
|
2022-08-18 18:18:36 +03:00
|
|
|
//
|
|
|
|
// LeftAlign = 0, RightAlign = 1, CenterAlign = 2, JustifyAlign = 3
|
|
|
|
//
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetTextAlign(view View, subviewID ...string) int {
|
2022-07-28 12:41:50 +03:00
|
|
|
return enumStyledProperty(view, subviewID, TextAlign, LeftAlign, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetTextIndent returns a text indent of the subview.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetTextIndent(view View, subviewID ...string) SizeUnit {
|
2022-07-28 12:53:50 +03:00
|
|
|
return sizeStyledProperty(view, subviewID, TextIndent, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetLetterSpacing returns a letter spacing of the subview.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetLetterSpacing(view View, subviewID ...string) SizeUnit {
|
2022-07-28 12:53:50 +03:00
|
|
|
return sizeStyledProperty(view, subviewID, LetterSpacing, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetWordSpacing returns a word spacing of the subview.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetWordSpacing(view View, subviewID ...string) SizeUnit {
|
2022-07-28 12:53:50 +03:00
|
|
|
return sizeStyledProperty(view, subviewID, WordSpacing, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetLineHeight returns a height of a text line of the subview.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetLineHeight(view View, subviewID ...string) SizeUnit {
|
2022-07-28 12:53:50 +03:00
|
|
|
return sizeStyledProperty(view, subviewID, LineHeight, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// IsItalic returns "true" if a text font of the subview is displayed in italics, "false" otherwise.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func IsItalic(view View, subviewID ...string) bool {
|
2022-07-28 12:11:27 +03:00
|
|
|
return boolStyledProperty(view, subviewID, Italic, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// IsSmallCaps returns "true" if a text font of the subview is displayed in small caps, "false" otherwise.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func IsSmallCaps(view View, subviewID ...string) bool {
|
2022-07-28 12:11:27 +03:00
|
|
|
return boolStyledProperty(view, subviewID, SmallCaps, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// IsStrikethrough returns "true" if a text font of the subview is displayed strikethrough, "false" otherwise.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func IsStrikethrough(view View, subviewID ...string) bool {
|
2022-07-28 12:11:27 +03:00
|
|
|
return boolStyledProperty(view, subviewID, Strikethrough, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// IsOverline returns "true" if a text font of the subview is displayed overlined, "false" otherwise.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func IsOverline(view View, subviewID ...string) bool {
|
2022-07-28 12:11:27 +03:00
|
|
|
return boolStyledProperty(view, subviewID, Overline, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// IsUnderline returns "true" if a text font of the subview is displayed underlined, "false" otherwise.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func IsUnderline(view View, subviewID ...string) bool {
|
2022-07-28 12:11:27 +03:00
|
|
|
return boolStyledProperty(view, subviewID, Underline, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetTextLineThickness returns the stroke thickness of the decoration line that
|
|
|
|
// is used on text in an element, such as a line-through, underline, or overline.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetTextLineThickness(view View, subviewID ...string) SizeUnit {
|
2022-07-28 12:53:50 +03:00
|
|
|
return sizeStyledProperty(view, subviewID, TextLineThickness, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetTextLineStyle returns the stroke style of the decoration line that
|
|
|
|
// is used on text in an element, such as a line-through, underline, or overline.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetTextLineStyle(view View, subviewID ...string) int {
|
2022-07-28 12:41:50 +03:00
|
|
|
return enumStyledProperty(view, subviewID, TextLineStyle, SolidLine, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetTextLineColor returns the stroke color of the decoration line that
|
|
|
|
// is used on text in an element, such as a line-through, underline, or overline.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetTextLineColor(view View, subviewID ...string) Color {
|
2022-07-28 12:11:27 +03:00
|
|
|
return colorStyledProperty(view, subviewID, TextLineColor, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetTextTransform returns a text transform of the subview. Return one of next values:
|
|
|
|
// NoneTextTransform (0), CapitalizeTextTransform (1), LowerCaseTextTransform (2) or UpperCaseTextTransform (3)
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetTextTransform(view View, subviewID ...string) int {
|
2022-07-28 12:41:50 +03:00
|
|
|
return enumStyledProperty(view, subviewID, TextTransform, NoneTextTransform, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetWritingMode returns whether lines of text are laid out horizontally or vertically, as well as
|
2021-11-04 14:59:25 +03:00
|
|
|
// the direction in which blocks progress. Valid values are HorizontalTopToBottom (0),
|
|
|
|
// HorizontalBottomToTop (1), VerticalRightToLeft (2) and VerticalLeftToRight (3)
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetWritingMode(view View, subviewID ...string) int {
|
2022-07-28 12:41:50 +03:00
|
|
|
return enumStyledProperty(view, subviewID, WritingMode, HorizontalTopToBottom, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetTextDirection - returns a direction of text, table columns, and horizontal overflow.
|
2022-07-28 12:41:50 +03:00
|
|
|
// Valid values are SystemTextDirection (0), LeftToRightDirection (1), and RightToLeftDirection (2).
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetTextDirection(view View, subviewID ...string) int {
|
2022-07-28 12:41:50 +03:00
|
|
|
if view == nil {
|
|
|
|
return SystemTextDirection
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
2022-07-28 12:41:50 +03:00
|
|
|
defaultDirection := view.Session().TextDirection()
|
|
|
|
return enumStyledProperty(view, subviewID, TextDirection, defaultDirection, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetVerticalTextOrientation returns a orientation of the text characters in a line. It only affects text
|
2021-11-04 14:59:25 +03:00
|
|
|
// in vertical mode (when "writing-mode" is "vertical-right-to-left" or "vertical-left-to-right").
|
|
|
|
// Valid values are MixedTextOrientation (0), UprightTextOrientation (1), and SidewaysTextOrientation (2).
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetVerticalTextOrientation(view View, subviewID ...string) int {
|
2022-07-28 12:41:50 +03:00
|
|
|
return enumStyledProperty(view, subviewID, VerticalTextOrientation, MixedTextOrientation, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetRow returns the range of row numbers of a GridLayout in which the subview is placed.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a values from the first argument (view) is returned.
|
|
|
|
func GetRow(view View, subviewID ...string) Range {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
if view != nil {
|
|
|
|
session := view.Session()
|
|
|
|
if result, ok := rangeProperty(view, Row, session); ok {
|
|
|
|
return result
|
|
|
|
}
|
2022-05-23 15:22:14 +03:00
|
|
|
if value := valueFromStyle(view, Row); value != nil {
|
2021-09-07 17:36:50 +03:00
|
|
|
if result, ok := valueToRange(value, session); ok {
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Range{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetColumn returns the range of column numbers of a GridLayout in which the subview is placed.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a values from the first argument (view) is returned.
|
|
|
|
func GetColumn(view View, subviewID ...string) Range {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
if view != nil {
|
|
|
|
session := view.Session()
|
|
|
|
if result, ok := rangeProperty(view, Column, session); ok {
|
|
|
|
return result
|
|
|
|
}
|
2022-05-23 15:22:14 +03:00
|
|
|
if value := valueFromStyle(view, Column); value != nil {
|
2021-09-07 17:36:50 +03:00
|
|
|
if result, ok := valueToRange(value, session); ok {
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Range{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetPerspective returns a distance between the z = 0 plane and the user in order to give a 3D-positioned
|
|
|
|
// element some perspective. Each 3D element with z > 0 becomes larger; each 3D-element with z < 0 becomes smaller.
|
|
|
|
// The default value is 0 (no 3D effects).
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetPerspective(view View, subviewID ...string) SizeUnit {
|
2022-07-28 12:53:50 +03:00
|
|
|
return sizeStyledProperty(view, subviewID, Perspective, false)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetPerspectiveOrigin returns a x- and y-coordinate of the position at which the viewer is looking.
|
|
|
|
// It is used as the vanishing point by the Perspective property. The default value is (50%, 50%).
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetPerspectiveOrigin(view View, subviewID ...string) (SizeUnit, SizeUnit) {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
if view == nil {
|
|
|
|
return AutoSize(), AutoSize()
|
|
|
|
}
|
|
|
|
return getPerspectiveOrigin(view, view.Session())
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetBackfaceVisible returns a bool property that sets whether the back face of an element is
|
|
|
|
// visible when turned towards the user. Values:
|
2021-11-04 14:59:25 +03:00
|
|
|
// true - the back face is visible when turned towards the user (default value).
|
|
|
|
// false - the back face is hidden, effectively making the element invisible when turned away from the user.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetBackfaceVisible(view View, subviewID ...string) bool {
|
2022-07-28 12:11:27 +03:00
|
|
|
return boolStyledProperty(view, subviewID, BackfaceVisible, false)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetOrigin returns a x-, y-, and z-coordinate of the point around which a view transformation is applied.
|
|
|
|
// The default value is (50%, 50%, 50%).
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetOrigin(view View, subviewID ...string) (SizeUnit, SizeUnit, SizeUnit) {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
if view == nil {
|
|
|
|
return AutoSize(), AutoSize(), AutoSize()
|
|
|
|
}
|
|
|
|
return getOrigin(view, view.Session())
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetTranslate returns a x-, y-, and z-axis translation value of a 2D/3D translation
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetTranslate(view View, subviewID ...string) (SizeUnit, SizeUnit, SizeUnit) {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
if view == nil {
|
|
|
|
return AutoSize(), AutoSize(), AutoSize()
|
|
|
|
}
|
|
|
|
return getTranslate(view, view.Session())
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetSkew returns a angles to use to distort the element along the abscissa (x-axis)
|
|
|
|
// and the ordinate (y-axis). The default value is 0.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetSkew(view View, subviewID ...string) (AngleUnit, AngleUnit) {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
if view == nil {
|
|
|
|
return AngleUnit{Value: 0, Type: Radian}, AngleUnit{Value: 0, Type: Radian}
|
|
|
|
}
|
2021-10-04 17:58:17 +03:00
|
|
|
x, y, _ := getSkew(view, view.Session())
|
|
|
|
return x, y
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetScale returns a x-, y-, and z-axis scaling value of a 2D/3D scale. The default value is 1.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetScale(view View, subviewID ...string) (float64, float64, float64) {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
if view == nil {
|
|
|
|
return 1, 1, 1
|
|
|
|
}
|
2022-08-18 18:18:36 +03:00
|
|
|
|
|
|
|
session := view.Session()
|
|
|
|
x, _ := floatProperty(view, ScaleX, session, 1)
|
|
|
|
y, _ := floatProperty(view, ScaleY, session, 1)
|
|
|
|
z, _ := floatProperty(view, ScaleZ, session, 1)
|
2021-10-04 17:58:17 +03:00
|
|
|
return x, y, z
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetRotate returns a x-, y, z-coordinate of the vector denoting the axis of rotation, and the angle of the view rotation
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetRotate(view View, subviewID ...string) (float64, float64, float64, AngleUnit) {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
if view == nil {
|
|
|
|
return 0, 0, 0, AngleUnit{Value: 0, Type: Radian}
|
|
|
|
}
|
2021-10-04 17:58:17 +03:00
|
|
|
|
2022-08-18 18:18:36 +03:00
|
|
|
session := view.Session()
|
2021-10-04 17:58:17 +03:00
|
|
|
angle, _ := angleProperty(view, Rotate, view.Session())
|
2022-08-18 18:18:36 +03:00
|
|
|
rotateX, _ := floatProperty(view, RotateX, session, 1)
|
|
|
|
rotateY, _ := floatProperty(view, RotateY, session, 1)
|
|
|
|
rotateZ, _ := floatProperty(view, RotateZ, session, 1)
|
2021-10-04 17:58:17 +03:00
|
|
|
return rotateX, rotateY, rotateZ, angle
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetAvoidBreak returns "true" if avoids any break from being inserted within the principal box,
|
|
|
|
// and "false" if allows, but does not force, any break to be inserted within the principal box.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
|
|
|
|
func GetAvoidBreak(view View, subviewID ...string) bool {
|
2022-07-28 12:11:27 +03:00
|
|
|
return boolStyledProperty(view, subviewID, AvoidBreak, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
2022-08-31 22:17:46 +03:00
|
|
|
func GetNotTranslate(view View, subviewID ...string) bool {
|
2022-07-28 12:11:27 +03:00
|
|
|
return boolStyledProperty(view, subviewID, NotTranslate, true)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
2022-07-26 18:36:00 +03:00
|
|
|
func valueFromStyle(view View, tag string) any {
|
2021-09-07 17:36:50 +03:00
|
|
|
session := view.Session()
|
2022-07-26 18:36:00 +03:00
|
|
|
getValue := func(styleTag string) any {
|
2021-09-07 17:36:50 +03:00
|
|
|
if style, ok := stringProperty(view, styleTag, session); ok {
|
|
|
|
if style, ok := session.resolveConstants(style); ok {
|
|
|
|
return session.styleProperty(style, tag)
|
|
|
|
}
|
|
|
|
}
|
2022-05-23 15:22:14 +03:00
|
|
|
return nil
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
2022-08-31 22:17:46 +03:00
|
|
|
if IsDisabled(view) {
|
2022-05-23 15:22:14 +03:00
|
|
|
if value := getValue(StyleDisabled); value != nil {
|
|
|
|
return value
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return getValue(Style)
|
|
|
|
}
|
|
|
|
|
2022-08-31 22:17:46 +03:00
|
|
|
func sizeStyledProperty(view View, subviewID []string, tag string, inherit bool) SizeUnit {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
2022-08-31 22:17:46 +03:00
|
|
|
|
2022-07-28 12:53:50 +03:00
|
|
|
if view != nil {
|
|
|
|
if value, ok := sizeProperty(view, tag, view.Session()); ok {
|
|
|
|
return value
|
|
|
|
}
|
|
|
|
if value := valueFromStyle(view, tag); value != nil {
|
|
|
|
if result, ok := valueToSizeUnit(value, view.Session()); ok {
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if inherit {
|
|
|
|
if parent := view.Parent(); parent != nil {
|
2022-08-31 22:17:46 +03:00
|
|
|
return sizeStyledProperty(parent, []string{}, tag, true)
|
2022-07-28 12:53:50 +03:00
|
|
|
}
|
|
|
|
}
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
2022-07-28 12:53:50 +03:00
|
|
|
return AutoSize()
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
2022-08-31 22:17:46 +03:00
|
|
|
func enumStyledProperty(view View, subviewID []string, tag string, defaultValue int, inherit bool) int {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
2022-08-31 22:17:46 +03:00
|
|
|
|
2022-07-28 12:41:50 +03:00
|
|
|
if view != nil {
|
|
|
|
if value, ok := enumProperty(view, tag, view.Session(), defaultValue); ok {
|
|
|
|
return value
|
|
|
|
}
|
|
|
|
if value := valueFromStyle(view, tag); value != nil {
|
|
|
|
if result, ok := valueToEnum(value, tag, view.Session(), defaultValue); ok {
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if inherit {
|
|
|
|
if parent := view.Parent(); parent != nil {
|
2022-08-31 22:17:46 +03:00
|
|
|
return enumStyledProperty(parent, []string{}, tag, defaultValue, true)
|
2022-07-28 12:41:50 +03:00
|
|
|
}
|
|
|
|
}
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
2022-07-28 12:41:50 +03:00
|
|
|
return defaultValue
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
2022-08-31 22:17:46 +03:00
|
|
|
func boolStyledProperty(view View, subviewID []string, tag string, inherit bool) bool {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
2022-07-28 12:11:27 +03:00
|
|
|
|
|
|
|
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 {
|
2022-08-31 22:17:46 +03:00
|
|
|
return boolStyledProperty(parent, []string{}, tag, inherit)
|
2022-07-28 12:11:27 +03:00
|
|
|
}
|
|
|
|
}
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
2022-07-28 12:11:27 +03:00
|
|
|
|
|
|
|
return false
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
2022-08-31 22:17:46 +03:00
|
|
|
func intStyledProperty(view View, subviewID []string, tag string, defaultValue int) int {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
2022-08-31 22:17:46 +03:00
|
|
|
|
2022-07-28 12:11:27 +03:00
|
|
|
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
|
|
|
|
}
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
2022-07-28 12:11:27 +03:00
|
|
|
return defaultValue
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
2022-08-31 22:17:46 +03:00
|
|
|
func floatStyledProperty(view View, subviewID []string, tag string, defaultValue float64) float64 {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
2022-07-28 12:11:27 +03:00
|
|
|
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
|
|
|
|
}
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
2022-07-28 12:11:27 +03:00
|
|
|
return defaultValue
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
2022-08-31 22:17:46 +03:00
|
|
|
func colorStyledProperty(view View, subviewID []string, tag string, inherit bool) Color {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
2022-07-28 12:11:27 +03:00
|
|
|
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 {
|
2022-08-31 22:17:46 +03:00
|
|
|
return colorStyledProperty(parent, []string{}, tag, true)
|
2022-07-28 12:11:27 +03:00
|
|
|
}
|
|
|
|
}
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
2022-07-28 12:11:27 +03:00
|
|
|
return Color(0)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
|
Added some properties and functions
* Added "resize", "grid-auto-flow", "caret-color", and "backdrop-filter" properties
* Added BlurView, BlurViewByID, GetResize, GetGridAutoFlow, GetCaretColor, GetBackdropFilter functions
* The "warp" property for ListView and ListLayout renamed to "list-warp"
* The "warp" property for EditView renamed to "edit-warp"
* Added CertFile and KeyFile optional fields to the AppParams struct.If they are set, then an https connection is created, otherwise http.
2022-06-07 13:07:10 +03:00
|
|
|
// FocusView sets focus on the specified View, if it can be focused.
|
|
|
|
// The focused View is the View which will receive keyboard events by default.
|
2021-09-07 17:36:50 +03:00
|
|
|
func FocusView(view View) {
|
|
|
|
if view != nil {
|
2022-11-02 20:10:19 +03:00
|
|
|
view.Session().callFunc("focus", view.htmlID())
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Added some properties and functions
* Added "resize", "grid-auto-flow", "caret-color", and "backdrop-filter" properties
* Added BlurView, BlurViewByID, GetResize, GetGridAutoFlow, GetCaretColor, GetBackdropFilter functions
* The "warp" property for ListView and ListLayout renamed to "list-warp"
* The "warp" property for EditView renamed to "edit-warp"
* Added CertFile and KeyFile optional fields to the AppParams struct.If they are set, then an https connection is created, otherwise http.
2022-06-07 13:07:10 +03:00
|
|
|
// FocusView sets focus on the View with the specified viewID, if it can be focused.
|
|
|
|
// The focused View is the View which will receive keyboard events by default.
|
2021-09-07 17:36:50 +03:00
|
|
|
func FocusViewByID(viewID string, session Session) {
|
|
|
|
if viewID != "" {
|
2022-11-02 20:10:19 +03:00
|
|
|
session.callFunc("focus", viewID)
|
2021-09-07 17:36:50 +03:00
|
|
|
}
|
|
|
|
}
|
2021-11-20 19:51:51 +03:00
|
|
|
|
Added some properties and functions
* Added "resize", "grid-auto-flow", "caret-color", and "backdrop-filter" properties
* Added BlurView, BlurViewByID, GetResize, GetGridAutoFlow, GetCaretColor, GetBackdropFilter functions
* The "warp" property for ListView and ListLayout renamed to "list-warp"
* The "warp" property for EditView renamed to "edit-warp"
* Added CertFile and KeyFile optional fields to the AppParams struct.If they are set, then an https connection is created, otherwise http.
2022-06-07 13:07:10 +03:00
|
|
|
// BlurView removes keyboard focus from the specified View.
|
|
|
|
func BlurView(view View) {
|
|
|
|
if view != nil {
|
2022-11-02 20:10:19 +03:00
|
|
|
view.Session().callFunc("blur", view.htmlID())
|
Added some properties and functions
* Added "resize", "grid-auto-flow", "caret-color", and "backdrop-filter" properties
* Added BlurView, BlurViewByID, GetResize, GetGridAutoFlow, GetCaretColor, GetBackdropFilter functions
* The "warp" property for ListView and ListLayout renamed to "list-warp"
* The "warp" property for EditView renamed to "edit-warp"
* Added CertFile and KeyFile optional fields to the AppParams struct.If they are set, then an https connection is created, otherwise http.
2022-06-07 13:07:10 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// BlurViewByID removes keyboard focus from the View with the specified viewID.
|
|
|
|
func BlurViewByID(viewID string, session Session) {
|
|
|
|
if viewID != "" {
|
2022-11-02 20:10:19 +03:00
|
|
|
session.callFunc("blur", viewID)
|
Added some properties and functions
* Added "resize", "grid-auto-flow", "caret-color", and "backdrop-filter" properties
* Added BlurView, BlurViewByID, GetResize, GetGridAutoFlow, GetCaretColor, GetBackdropFilter functions
* The "warp" property for ListView and ListLayout renamed to "list-warp"
* The "warp" property for EditView renamed to "edit-warp"
* Added CertFile and KeyFile optional fields to the AppParams struct.If they are set, then an https connection is created, otherwise http.
2022-06-07 13:07:10 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-20 19:51:51 +03:00
|
|
|
// GetCurrent returns the index of the selected item (<0 if there is no a selected item) or the current view index (StackLayout, TabsLayout).
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetCurrent(view View, subviewID ...string) int {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2021-11-20 19:51:51 +03:00
|
|
|
}
|
|
|
|
|
2022-04-14 12:05:45 +03:00
|
|
|
defaultValue := -1
|
2021-11-20 19:51:51 +03:00
|
|
|
if view != nil {
|
|
|
|
if result, ok := intProperty(view, Current, view.Session(), defaultValue); ok {
|
|
|
|
return result
|
2022-04-14 12:05:45 +03:00
|
|
|
} else if view.Tag() != "ListView" {
|
|
|
|
defaultValue = 0
|
2021-11-20 19:51:51 +03:00
|
|
|
}
|
|
|
|
}
|
2022-04-14 12:05:45 +03:00
|
|
|
return defaultValue
|
2021-11-20 19:51:51 +03:00
|
|
|
}
|
2022-07-08 13:16:42 +03:00
|
|
|
|
|
|
|
// IsUserSelect returns "true" if the user can select text, "false" otherwise.
|
2022-08-31 22:17:46 +03:00
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func IsUserSelect(view View, subviewID ...string) bool {
|
|
|
|
if len(subviewID) > 0 && subviewID[0] != "" {
|
|
|
|
view = ViewByID(view, subviewID[0])
|
2022-07-08 13:16:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if view != nil {
|
|
|
|
value, _ := isUserSelect(view)
|
|
|
|
return value
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func isUserSelect(view View) (bool, bool) {
|
2022-07-28 12:11:27 +03:00
|
|
|
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
|
|
|
|
}
|
2022-07-08 13:16:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if parent := view.Parent(); parent != nil {
|
2022-07-28 12:11:27 +03:00
|
|
|
if result, ok := isUserSelect(parent); ok {
|
2022-07-08 13:16:42 +03:00
|
|
|
return result, true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-31 22:17:46 +03:00
|
|
|
switch GetSemantics(view) {
|
2022-07-28 12:11:27 +03:00
|
|
|
case ParagraphSemantics, H1Semantics, H2Semantics, H3Semantics, H4Semantics, H5Semantics,
|
|
|
|
H6Semantics, BlockquoteSemantics, CodeSemantics:
|
|
|
|
return true, false
|
|
|
|
}
|
2022-07-08 13:16:42 +03:00
|
|
|
|
2022-07-28 12:11:27 +03:00
|
|
|
if _, ok := view.(TableView); ok {
|
|
|
|
return true, false
|
2022-07-08 13:16:42 +03:00
|
|
|
}
|
|
|
|
|
2022-07-28 12:11:27 +03:00
|
|
|
return false, false
|
2022-07-08 13:16:42 +03:00
|
|
|
}
|
2022-12-19 18:31:35 +03:00
|
|
|
|
|
|
|
// GetMixBlendMode returns a "mix-blend-mode" of the subview. Returns one of next values:
|
|
|
|
//
|
|
|
|
// BlendNormal (0), BlendMultiply (1), BlendScreen (2), BlendOverlay (3), BlendDarken (4),
|
|
|
|
// BlendLighten (5), BlendColorDodge (6), BlendColorBurn (7), BlendHardLight (8),
|
|
|
|
// BlendSoftLight (9), BlendDifference (10), BlendExclusion (11), BlendHue (12),
|
|
|
|
// BlendSaturation (13), BlendColor (14), BlendLuminosity (15)
|
|
|
|
//
|
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetMixBlendMode(view View, subviewID ...string) int {
|
|
|
|
return enumStyledProperty(view, subviewID, MixBlendMode, BlendNormal, true)
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetBackgroundBlendMode returns a "background-blend-mode" of the subview. Returns one of next values:
|
|
|
|
//
|
|
|
|
// BlendNormal (0), BlendMultiply (1), BlendScreen (2), BlendOverlay (3), BlendDarken (4),
|
|
|
|
// BlendLighten (5), BlendColorDodge (6), BlendColorBurn (7), BlendHardLight (8),
|
|
|
|
// BlendSoftLight (9), BlendDifference (10), BlendExclusion (11), BlendHue (12),
|
|
|
|
// BlendSaturation (13), BlendColor (14), BlendLuminosity (15)
|
|
|
|
//
|
|
|
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
|
|
|
func GetBackgroundBlendMode(view View, subviewID ...string) int {
|
|
|
|
return enumStyledProperty(view, subviewID, BackgroundBlendMode, BlendNormal, true)
|
|
|
|
}
|