0 && subviewID[0] != "" {
+ view = ViewByID(view, subviewID[0])
+ }
+
+ if view != nil {
+ if value, ok := boolProperty(view, MoveToFrontAnimation, view.Session()); ok {
+ return value
+ }
+ if value := valueFromStyle(view, MoveToFrontAnimation); value != nil {
+ if b, ok := valueToBool(value, view.Session()); ok {
+ return b
+ }
+ }
+ }
+
+ return true
+}
+
+// GetPushDuration returns the length of time in seconds that an push/pop StackLayout animation takes to complete.
+// If the second argument (subviewID) is not specified or it is "" then a width of the first argument (view) is returned
+func GetPushDuration(view View, subviewID ...string) float64 {
+ return floatStyledProperty(view, subviewID, PushDuration, 1)
+}
+
+// GetPushTiming returns the function which sets how an push/pop animation progresses.
+// If the second argument (subviewID) is not specified or it is "" then a width of the first argument (view) is returned
+func GetPushTiming(view View, subviewID ...string) string {
+ result := stringStyledProperty(view, subviewID, PushTiming, false)
+ if isTimingFunctionValid(result) {
+ return result
+ }
+
+ return "easy"
+}
+
+// GetTransform returns the start transform (translation, scale and rotation over x, y and z axes as well as a distortion)
+// for an animated pushing of a child view.
+// The default value is nil (no transform).
+// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
+func GetPushTransform(view View, subviewID ...string) TransformProperty {
+ return transformStyledProperty(view, subviewID, PushTransform)
+}
diff --git a/transform.go b/transform.go
index 1949efe..fefe2fd 100644
--- a/transform.go
+++ b/transform.go
@@ -11,14 +11,14 @@ const (
// Transform is the constant for "transform" property tag.
//
// Used by `View`.
- // Specify translation, scale and rotation over x, y and z axes as well as a distorsion of a view along x and y axes.
+ // Specify translation, scale and rotation over x, y and z axes as well as a distortion of a view along x and y axes.
//
// Supported types: `TransformProperty`, `string`.
//
- // See `Transform` description for more details.
+ // See `TransformProperty` description for more details.
//
// Conversion rules:
- // `Transform` - stored as is, no conversion performed.
+ // `TransformProperty` - stored as is, no conversion performed.
// `string` - string representation of `Transform` interface. Example: "_{translate-x = 10px, scale-y = 1.1}".
Transform PropertyName = "transform"
@@ -466,9 +466,9 @@ func transformSet(properties Properties, tag PropertyName, value any) []Property
return nil
}
-func setTransformProperty(properties Properties, value any) bool {
+func valueToTransformProperty(value any) TransformProperty {
- setObject := func(obj DataObject) bool {
+ parseObject := func(obj DataObject) TransformProperty {
transform := NewTransformProperty(nil)
ok := true
for i := 0; i < obj.PropertyCount(); i++ {
@@ -482,41 +482,44 @@ func setTransformProperty(properties Properties, value any) bool {
}
if !ok && transform.empty() {
- return false
+ return nil
}
-
- properties.setRaw(Transform, transform)
- return true
+ return transform
}
switch value := value.(type) {
case TransformProperty:
- properties.setRaw(Transform, value)
- return true
+ return value
case DataObject:
- return setObject(value)
+ return parseObject(value)
case DataNode:
if obj := value.Object(); obj != nil {
- return setObject(obj)
+ return parseObject(obj)
}
- notCompatibleType(Transform, value)
- return false
case string:
if obj := ParseDataText(value); obj != nil {
- return setObject(obj)
+ return parseObject(obj)
}
- notCompatibleType(Transform, value)
- return false
}
+ return nil
+}
+
+func setTransformProperty(properties Properties, tag PropertyName, value any) bool {
+ if transform := valueToTransformProperty(value); transform != nil {
+ properties.setRaw(tag, transform)
+ return true
+ }
+
+ notCompatibleType(tag, value)
return false
}
-func getTransformProperty(properties Properties) TransformProperty {
- if val := properties.getRaw(Transform); val != nil {
+func getTransformProperty(properties Properties, tag PropertyName) TransformProperty {
+ if val := properties.getRaw(tag); val != nil {
if transform, ok := val.(TransformProperty); ok {
return transform
}
@@ -528,7 +531,7 @@ func setTransformPropertyElement(properties Properties, tag PropertyName, value
switch tag {
case Perspective, RotateX, RotateY, RotateZ, Rotate, SkewX, SkewY, ScaleX, ScaleY, ScaleZ, TranslateX, TranslateY, TranslateZ:
var result []PropertyName = nil
- if transform := getTransformProperty(properties); transform != nil {
+ if transform := getTransformProperty(properties, Transform); transform != nil {
if result = transformSet(transform, tag, value); result != nil {
result = append(result, Transform)
}
@@ -694,7 +697,7 @@ func (style *viewStyle) writeViewTransformCSS(builder cssBuilder, session Sessio
builder.add(`transform-origin`, css)
}
- if transform := getTransformProperty(style); transform != nil {
+ if transform := getTransformProperty(style, Transform); transform != nil {
builder.add(`transform`, transform.transformCSS(session))
}
}
diff --git a/view.go b/view.go
index b6664a5..e1923b0 100644
--- a/view.go
+++ b/view.go
@@ -708,7 +708,7 @@ func (view *viewData) propertyChanged(tag PropertyName) {
case Transform, Perspective, SkewX, SkewY, TranslateX, TranslateY, TranslateZ,
ScaleX, ScaleY, ScaleZ, Rotate, RotateX, RotateY, RotateZ:
css := ""
- if transform := getTransformProperty(view); transform != nil {
+ if transform := getTransformProperty(view, Transform); transform != nil {
css = transform.transformCSS(session)
}
session.updateCSSProperty(htmlID, "transform", css)
diff --git a/viewStyle.go b/viewStyle.go
index 0671a4f..0976958 100644
--- a/viewStyle.go
+++ b/viewStyle.go
@@ -562,7 +562,7 @@ func viewStyleGet(style Properties, tag PropertyName) any {
case RotateX, RotateY, RotateZ, Rotate, SkewX, SkewY, ScaleX, ScaleY, ScaleZ,
TranslateX, TranslateY, TranslateZ:
- if transform := getTransformProperty(style); transform != nil {
+ if transform := getTransformProperty(style, Transform); transform != nil {
return transform.Get(tag)
}
return nil
diff --git a/viewStyleSet.go b/viewStyleSet.go
index 49e58f7..1aac7ed 100644
--- a/viewStyleSet.go
+++ b/viewStyleSet.go
@@ -345,8 +345,8 @@ func viewStyleSet(style Properties, tag PropertyName, value any) []PropertyName
}
return nil
- case Transform:
- if setTransformProperty(style, value) {
+ case Transform, PushTransform:
+ if setTransformProperty(style, tag, value) {
return []PropertyName{Transform}
} else {
return nil
diff --git a/viewUtils.go b/viewUtils.go
index 3946d40..a8f28ce 100644
--- a/viewUtils.go
+++ b/viewUtils.go
@@ -567,6 +567,13 @@ func GetColumn(view View, subviewID ...string) Range {
return Range{}
}
+// GetTransform returns a view transform: translation, scale and rotation over x, y and z axes as well as a distortion of a view along x and y axes.
+// The default value is nil (no transform)
+// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
+func GetTransform(view View, subviewID ...string) TransformProperty {
+ return transformStyledProperty(view, subviewID, Transform)
+}
+
// 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).
@@ -860,6 +867,22 @@ func colorStyledProperty(view View, subviewID []string, tag PropertyName, inheri
return Color(0)
}
+func transformStyledProperty(view View, subviewID []string, tag PropertyName) TransformProperty {
+ if len(subviewID) > 0 && subviewID[0] != "" {
+ view = ViewByID(view, subviewID[0])
+ }
+ if view != nil {
+ if transform := getTransformProperty(view, tag); transform != nil {
+ return transform
+ }
+
+ if value := valueFromStyle(view, tag); value != nil {
+ return valueToTransformProperty(value)
+ }
+ }
+ return nil
+}
+
// FocusView sets focus on the specified subview, if it can be focused.
// The focused View is the View which will receive keyboard events by default.
// If the second argument (subviewID) is not specified or it is "" then focus is set on the first argument (view)
From 6b2a5b4aeef8ff313557cdf9c2a23c25b08916d2 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Sun, 24 Nov 2024 15:43:31 +0200
Subject: [PATCH 10/43] Optimisation
---
CHANGELOG.md | 2 +-
animation.go | 12 +--
colorPicker.go | 5 +-
columnLayout.go | 6 +-
dataList.go | 75 +-----------------
datePicker.go | 15 +---
detailsView.go | 5 +-
dropDownList.go | 15 +---
editView.go | 14 +---
events.go | 15 +---
filePicker.go | 5 +-
gridLayout.go | 10 +--
imageView.go | 12 +--
listLayout.go | 15 ++--
listView.go | 17 +----
numberPicker.go | 34 +++------
resizeEvent.go | 4 +-
scrollEvent.go | 14 +---
stackLayout.go | 6 +-
tableViewUtils.go | 64 ++++------------
timePicker.go | 15 +---
viewClip.go | 10 +--
viewFilter.go | 12 +--
viewUtils.go | 191 +++++++++++++++-------------------------------
24 files changed, 132 insertions(+), 441 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4345e6f..38b90f2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,7 +7,7 @@
* Changed Push and Pop method of StackLayout interface.
* Removed DefaultAnimation, StartToEndAnimation, EndToStartAnimation, TopDownAnimation, and BottomUpAnimation constants.
* Added "push-transform", "push-duration", "push-timing", and "move-to-front-animation" properties.
-* Added GetPushDuration, GetPushTiming, and IsMoveToFrontAnimation functions.
+* Added GetPushTransform, GetPushDuration, GetPushTiming, and IsMoveToFrontAnimation functions.
* Added LineJoin type. Type of constants MiterJoin, RoundJoin, and BevelJoin changed to LineJoin. Type of Canvas.SetLineJoin function argument changed to LineJoin.
* Added LineCap type. Type of constants ButtCap, RoundCap, and SquareCap changed to LineCap. Type of Canvas.SetLineCap function argument changed to LineCap.
diff --git a/animation.go b/animation.go
index e1012b2..6d5afb7 100644
--- a/animation.go
+++ b/animation.go
@@ -981,11 +981,7 @@ func IsAnimationPaused(view View, subviewID ...string) bool {
// GetTransitions returns the subview transitions. The result is always non-nil.
// If the second argument (subviewID) is not specified or it is "" then transitions of the first argument (view) is returned
func GetTransitions(view View, subviewID ...string) map[PropertyName]Animation {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
return view.Transitions()
}
@@ -1025,11 +1021,7 @@ func AddTransition(view View, subviewID string, tag PropertyName, animation Anim
// GetAnimation returns the subview animations. The result is always non-nil.
// If the second argument (subviewID) is not specified or it is "" then transitions of the first argument (view) is returned
func GetAnimation(view View, subviewID ...string) []Animation {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if value := view.getRaw(AnimationTag); value != nil {
if animations, ok := value.([]Animation); ok && animations != nil {
return animations
diff --git a/colorPicker.go b/colorPicker.go
index 3561547..3a2e07f 100644
--- a/colorPicker.go
+++ b/colorPicker.go
@@ -174,10 +174,7 @@ func (picker *colorPickerData) handleCommand(self View, command PropertyName, da
// GetColorPickerValue returns the value of ColorPicker subview.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetColorPickerValue(view View, subviewID ...string) Color {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if value, ok := colorProperty(view, ColorPickerValue, view.Session()); ok {
return value
}
diff --git a/columnLayout.go b/columnLayout.go
index 9468167..c5bb3e3 100644
--- a/columnLayout.go
+++ b/columnLayout.go
@@ -199,11 +199,7 @@ func GetColumnGap(view View, subviewID ...string) SizeUnit {
}
func getColumnSeparator(view View, subviewID []string) ViewBorder {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
value := view.Get(ColumnSeparator)
if value == nil {
value = valueFromStyle(view, ColumnSeparator)
diff --git a/dataList.go b/dataList.go
index a4fa535..1e62674 100644
--- a/dataList.go
+++ b/dataList.go
@@ -322,83 +322,10 @@ func dataListHtmlProperties(view View, buffer *strings.Builder) {
}
}
-/*
-func (list *dataList) setDataList(view View, value any, created bool) bool {
- items, ok := anyToStringArray(value)
- if !ok {
- notCompatibleType(DataList, value)
- return false
- }
-
- list.dataList = items
- if created {
- session := view.Session()
- dataListID := dataListID(view)
- buffer := allocStringBuilder()
- defer freeStringBuilder(buffer)
-
- if list.dataListHtml {
- list.dataListItemsHtml(buffer)
- session.updateInnerHTML(dataListID, buffer.String())
- } else {
- list.dataListHtmlCode(view, buffer)
- session.appendToInnerHTML(view.parentHTMLID(), buffer.String())
- list.dataListHtml = true
- session.updateProperty(view.htmlID(), "list", dataListID)
- }
- }
-
- return true
-}
-
-func (list *dataList) dataListHtmlSubviews(view View, buffer *strings.Builder) {
- if len(list.dataList) > 0 {
- list.dataListHtmlCode(view, buffer)
- list.dataListHtml = true
- } else {
- list.dataListHtml = false
- }
-}
-
-func (list *dataList) dataListHtmlCode(view View, buffer *strings.Builder) {
- buffer.WriteString(``)
-}
-
-func (list *dataList) dataListItemsHtml(buffer *strings.Builder) {
- for _, text := range list.dataList {
- if strings.ContainsRune(text, '"') {
- text = strings.ReplaceAll(text, `"`, `"`)
- }
- if strings.ContainsRune(text, '\n') {
- text = strings.ReplaceAll(text, "\n", `\n`)
- }
- buffer.WriteString(``)
- }
-}
-
-func (list *dataList) dataListHtmlProperties(view View, buffer *strings.Builder) {
- if len(list.dataList) > 0 {
- buffer.WriteString(` list="`)
- buffer.WriteString(dataListID(view))
- buffer.WriteString(`"`)
- }
-}
-*/
-
// GetDataList returns the data list of an editor.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetDataList(view View, subviewID ...string) []string {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
return getDataListProperty(view)
}
diff --git a/datePicker.go b/datePicker.go
index dded25f..d36b4e1 100644
--- a/datePicker.go
+++ b/datePicker.go
@@ -402,10 +402,7 @@ func getDateProperty(view View, mainTag, shortTag PropertyName) (time.Time, bool
// "false" as the second value otherwise.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetDatePickerMin(view View, subviewID ...string) (time.Time, bool) {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
return getDateProperty(view, DatePickerMin, Min)
}
return time.Now(), false
@@ -415,10 +412,7 @@ func GetDatePickerMin(view View, subviewID ...string) (time.Time, bool) {
// "false" as the second value otherwise.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetDatePickerMax(view View, subviewID ...string) (time.Time, bool) {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
return getDateProperty(view, DatePickerMax, Max)
}
return time.Now(), false
@@ -433,10 +427,7 @@ func GetDatePickerStep(view View, subviewID ...string) int {
// GetDatePickerValue returns the date of DatePicker subview.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetDatePickerValue(view View, subviewID ...string) time.Time {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view == nil {
+ if view = getSubview(view, subviewID); view == nil {
return time.Now()
}
date, _ := getDateProperty(view, DatePickerValue, Value)
diff --git a/detailsView.go b/detailsView.go
index 5e30696..646043e 100644
--- a/detailsView.go
+++ b/detailsView.go
@@ -171,10 +171,7 @@ func (detailsView *detailsViewData) handleCommand(self View, command PropertyNam
// GetDetailsSummary returns a value of the Summary property of DetailsView.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetDetailsSummary(view View, subviewID ...string) View {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if value := view.Get(Summary); value != nil {
switch value := value.(type) {
case string:
diff --git a/dropDownList.go b/dropDownList.go
index 1b9f739..558fecb 100644
--- a/dropDownList.go
+++ b/dropDownList.go
@@ -267,10 +267,7 @@ func GetDropDownListeners(view View, subviewID ...string) []func(DropDownList, i
// GetDropDownItems return the DropDownList items list.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetDropDownItems(view View, subviewID ...string) []string {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if value := view.Get(Items); value != nil {
if items, ok := value.([]string); ok {
return items
@@ -313,19 +310,13 @@ func getIndicesArray(view View, tag PropertyName) []int {
// GetDropDownDisabledItems return an array of disabled(non selectable) items indices of DropDownList.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetDropDownDisabledItems(view View, subviewID ...string) []int {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
+ view = getSubview(view, subviewID)
return getIndicesArray(view, DisabledItems)
}
// GetDropDownItemSeparators return an array of indices of DropDownList items after which a separator should be added.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetDropDownItemSeparators(view View, subviewID ...string) []int {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
+ view = getSubview(view, subviewID)
return getIndicesArray(view, ItemSeparators)
}
diff --git a/editView.go b/editView.go
index 4056ddf..d45f559 100644
--- a/editView.go
+++ b/editView.go
@@ -398,10 +398,7 @@ func (edit *editViewData) handleCommand(self View, command PropertyName, data Da
// GetText returns a text of the EditView subview.
// If the second argument (subviewID) is not specified or it is "" then a text of the first argument (view) is returned.
func GetText(view View, subviewID ...string) string {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if value := view.getRaw(Text); value != nil {
if text, ok := value.(string); ok {
return text
@@ -414,9 +411,7 @@ func GetText(view View, subviewID ...string) string {
// GetHint returns a hint text of the subview.
// If the second argument (subviewID) is not specified or it is "" then a text of the first argument (view) is returned.
func GetHint(view View, subviewID ...string) string {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
+ view = getSubview(view, subviewID)
session := view.Session()
text := ""
@@ -477,10 +472,7 @@ func GetEditViewType(view View, subviewID ...string) int {
// GetEditViewPattern returns a value of the Pattern property of EditView.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetEditViewPattern(view View, subviewID ...string) string {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if pattern, ok := stringProperty(view, EditViewPattern, view.Session()); ok {
return pattern
}
diff --git a/events.go b/events.go
index 55d8772..8bf6a9d 100644
--- a/events.go
+++ b/events.go
@@ -411,10 +411,7 @@ func valueToTwoArgEventListeners[V View, E any](value any) ([]func(V, E, E), boo
}
func getNoArgEventListeners[V View](view View, subviewID []string, tag PropertyName) []func(V) {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if value := view.Get(tag); value != nil {
if result, ok := value.([]func(V)); ok {
return result
@@ -425,10 +422,7 @@ func getNoArgEventListeners[V View](view View, subviewID []string, tag PropertyN
}
func getOneArgEventListeners[V View, E any](view View, subviewID []string, tag PropertyName) []func(V, E) {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if value := view.Get(tag); value != nil {
if result, ok := value.([]func(V, E)); ok {
return result
@@ -439,10 +433,7 @@ func getOneArgEventListeners[V View, E any](view View, subviewID []string, tag P
}
func getTwoArgEventListeners[V View, E any](view View, subviewID []string, tag PropertyName) []func(V, E, E) {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if value := view.Get(tag); value != nil {
if result, ok := value.([]func(V, E, E)); ok {
return result
diff --git a/filePicker.go b/filePicker.go
index 72e86ab..80553bf 100644
--- a/filePicker.go
+++ b/filePicker.go
@@ -345,10 +345,7 @@ func IsMultipleFilePicker(view View, subviewID ...string) bool {
// GetFilePickerAccept returns sets the list of allowed file extensions or MIME types.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetFilePickerAccept(view View, subviewID ...string) []string {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
accept, ok := stringProperty(view, Accept, view.Session())
if !ok {
if value := valueFromStyle(view, Accept); value != nil {
diff --git a/gridLayout.go b/gridLayout.go
index 39d8a7f..fa5299c 100644
--- a/gridLayout.go
+++ b/gridLayout.go
@@ -533,10 +533,7 @@ func GetGridAutoFlow(view View, subviewID ...string) int {
// If the result is a single value array, then the width of all cell is equal.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetCellWidth(view View, subviewID ...string) []SizeUnit {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
return gridCellSizes(view, CellWidth, view.Session())
}
return []SizeUnit{}
@@ -546,10 +543,7 @@ func GetCellWidth(view View, subviewID ...string) []SizeUnit {
// If the result is a single value array, then the height of all cell is equal.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetCellHeight(view View, subviewID ...string) []SizeUnit {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
return gridCellSizes(view, CellHeight, view.Session())
}
return []SizeUnit{}
diff --git a/imageView.go b/imageView.go
index b837456..5eeaaac 100644
--- a/imageView.go
+++ b/imageView.go
@@ -329,11 +329,7 @@ func (imageView *imageViewData) CurrentSource() string {
// GetImageViewSource returns the image URL of an ImageView subview.
// If the second argument (subviewID) is not specified or it is "" then a left position of the first argument (view) is returned
func GetImageViewSource(view View, subviewID ...string) string {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if image, ok := imageProperty(view, Source, view.Session()); ok {
return image
}
@@ -345,11 +341,7 @@ func GetImageViewSource(view View, subviewID ...string) string {
// GetImageViewAltText returns an alternative text description of an ImageView subview.
// If the second argument (subviewID) is not specified or it is "" then a left position of the first argument (view) is returned
func GetImageViewAltText(view View, subviewID ...string) string {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if value := view.getRaw(AltText); value != nil {
if text, ok := value.(string); ok {
text, _ = view.Session().GetString(text)
diff --git a/listLayout.go b/listLayout.go
index a3426b6..0709416 100644
--- a/listLayout.go
+++ b/listLayout.go
@@ -222,11 +222,7 @@ func GetListHorizontalAlign(view View, subviewID ...string) int {
// TopDownOrientation (0), StartToEndOrientation (1), BottomUpOrientation (2), or EndToStartOrientation (3)
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetListOrientation(view View, subviewID ...string) int {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if orientation, ok := valueToOrientation(view.Get(Orientation), view.Session()); ok {
return orientation
}
@@ -264,11 +260,7 @@ func GetListColumnGap(view View, subviewID ...string) SizeUnit {
// otherwise does nothing.
// If the second argument (subviewID) is not specified or it is "" then the first argument (view) updates.
func UpdateContent(view View, subviewID ...string) {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
switch view := view.(type) {
case GridLayout:
view.UpdateGridContent()
@@ -278,6 +270,9 @@ func UpdateContent(view View, subviewID ...string) {
case ListView:
view.ReloadListViewData()
+
+ case TableView:
+ view.ReloadTableData()
}
}
}
diff --git a/listView.go b/listView.go
index 7338add..98f8393 100644
--- a/listView.go
+++ b/listView.go
@@ -1098,11 +1098,7 @@ func GetListViewCheckbox(view View, subviewID ...string) int {
// GetListViewCheckedItems returns the array of ListView checked items.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetListViewCheckedItems(view View, subviewID ...string) []int {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if value := view.getRaw(Checked); value != nil {
if checkedItems, ok := value.([]int); ok {
switch GetListViewCheckbox(view) {
@@ -1179,10 +1175,7 @@ func GetListItemFrame(view View, subviewID string, index int) Frame {
// GetListViewAdapter - returns the ListView adapter.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetListViewAdapter(view View, subviewID ...string) ListAdapter {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if value := view.Get(Items); value != nil {
if adapter, ok := value.(ListAdapter); ok {
return adapter
@@ -1195,11 +1188,7 @@ func GetListViewAdapter(view View, subviewID ...string) ListAdapter {
// ReloadListViewData updates ListView content
// If the second argument (subviewID) is not specified or it is "" then content the first argument (view) is updated.
func ReloadListViewData(view View, subviewID ...string) {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if listView, ok := view.(ListView); ok {
listView.ReloadListViewData()
}
diff --git a/numberPicker.go b/numberPicker.go
index 501a207..5f6fac0 100644
--- a/numberPicker.go
+++ b/numberPicker.go
@@ -304,12 +304,8 @@ func GetNumberPickerType(view View, subviewID ...string) int {
// GetNumberPickerMinMax returns the min and max value of NumberPicker subview.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetNumberPickerMinMax(view View, subviewID ...string) (float64, float64) {
- var pickerType int
- if len(subviewID) > 0 && subviewID[0] != "" {
- pickerType = GetNumberPickerType(view, subviewID[0])
- } else {
- pickerType = GetNumberPickerType(view)
- }
+ view = getSubview(view, subviewID)
+ pickerType := GetNumberPickerType(view)
var defMin, defMax float64
if pickerType == NumberSlider {
@@ -320,8 +316,8 @@ func GetNumberPickerMinMax(view View, subviewID ...string) (float64, float64) {
defMax = math.Inf(1)
}
- min := floatStyledProperty(view, subviewID, NumberPickerMin, defMin)
- max := floatStyledProperty(view, subviewID, NumberPickerMax, defMax)
+ min := floatStyledProperty(view, nil, NumberPickerMin, defMin)
+ max := floatStyledProperty(view, nil, NumberPickerMax, defMax)
if min > max {
return max, min
@@ -332,14 +328,10 @@ func GetNumberPickerMinMax(view View, subviewID ...string) (float64, float64) {
// GetNumberPickerStep returns the value changing step of NumberPicker subview.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetNumberPickerStep(view View, subviewID ...string) float64 {
- var max float64
- if len(subviewID) > 0 && subviewID[0] != "" {
- _, max = GetNumberPickerMinMax(view, subviewID[0])
- } else {
- _, max = GetNumberPickerMinMax(view)
- }
+ view = getSubview(view, subviewID)
+ _, max := GetNumberPickerMinMax(view)
- result := floatStyledProperty(view, subviewID, NumberPickerStep, 0)
+ result := floatStyledProperty(view, nil, NumberPickerStep, 0)
if result > max {
return max
}
@@ -349,15 +341,9 @@ func GetNumberPickerStep(view View, subviewID ...string) float64 {
// GetNumberPickerValue returns the value of NumberPicker subview.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetNumberPickerValue(view View, subviewID ...string) float64 {
- var min float64
- if len(subviewID) > 0 && subviewID[0] != "" {
- min, _ = GetNumberPickerMinMax(view, subviewID[0])
- } else {
- min, _ = GetNumberPickerMinMax(view)
- }
-
- result := floatStyledProperty(view, subviewID, NumberPickerValue, min)
- return result
+ view = getSubview(view, subviewID)
+ min, _ := GetNumberPickerMinMax(view)
+ return floatStyledProperty(view, nil, NumberPickerValue, min)
}
// GetNumberChangedListeners returns the NumberChangedListener list of an NumberPicker subview.
diff --git a/resizeEvent.go b/resizeEvent.go
index 3096105..16dfd6b 100644
--- a/resizeEvent.go
+++ b/resizeEvent.go
@@ -73,9 +73,7 @@ func (view *viewData) Frame() Frame {
// GetViewFrame returns the size and location of view's viewport.
// If the second argument (subviewID) is not specified or it is "" then the value of the first argument (view) is returned
func GetViewFrame(view View, subviewID ...string) Frame {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
+ view = getSubview(view, subviewID)
if view == nil {
return Frame{}
}
diff --git a/scrollEvent.go b/scrollEvent.go
index f6c276d..5b44845 100644
--- a/scrollEvent.go
+++ b/scrollEvent.go
@@ -42,9 +42,7 @@ func (view *viewData) setScroll(x, y, width, height float64) {
// GetViewScroll returns ...
// If the second argument (subviewID) is not specified or it is "" then a value of the first argument (view) is returned
func GetViewScroll(view View, subviewID ...string) Frame {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
+ view = getSubview(view, subviewID)
if view == nil {
return Frame{}
}
@@ -71,10 +69,7 @@ func ScrollViewTo(view View, subviewID string, x, y float64) {
// ScrollViewToEnd scrolls the view's content to the start of view.
// If the second argument (subviewID) is not specified or it is "" then the first argument (view) is used
func ScrollViewToStart(view View, subviewID ...string) {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
view.Session().callFunc("scrollToStart", view.htmlID())
}
}
@@ -82,10 +77,7 @@ func ScrollViewToStart(view View, subviewID ...string) {
// ScrollViewToEnd scrolls the view's content to the end of view.
// If the second argument (subviewID) is not specified or it is "" then the first argument (view) is used
func ScrollViewToEnd(view View, subviewID ...string) {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
view.Session().callFunc("scrollToEnd", view.htmlID())
}
}
diff --git a/stackLayout.go b/stackLayout.go
index b834002..a2cc899 100644
--- a/stackLayout.go
+++ b/stackLayout.go
@@ -560,11 +560,7 @@ func (layout *stackLayoutData) htmlSubviews(self View, buffer *strings.Builder)
// IsMoveToFrontAnimation returns "true" if an animation is used when calling the MoveToFront/MoveToFrontByID method of StackLayout interface.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func IsMoveToFrontAnimation(view View, subviewID ...string) bool {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if value, ok := boolProperty(view, MoveToFrontAnimation, view.Session()); ok {
return value
}
diff --git a/tableViewUtils.go b/tableViewUtils.go
index 9e707d1..152a8e6 100644
--- a/tableViewUtils.go
+++ b/tableViewUtils.go
@@ -28,11 +28,7 @@ func (cell *tableCellView) cssStyle(self View, builder cssBuilder) {
// GetTableContent returns a TableAdapter which defines the TableView content.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTableContent(view View, subviewID ...string) TableAdapter {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if content := view.getRaw(Content); content != nil {
if adapter, ok := content.(TableAdapter); ok {
return adapter
@@ -46,11 +42,7 @@ func GetTableContent(view View, subviewID ...string) TableAdapter {
// GetTableRowStyle returns a TableRowStyle which defines styles of TableView rows.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTableRowStyle(view View, subviewID ...string) TableRowStyle {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
for _, tag := range []PropertyName{RowStyle, Content} {
if value := view.getRaw(tag); value != nil {
if style, ok := value.(TableRowStyle); ok {
@@ -66,11 +58,7 @@ func GetTableRowStyle(view View, subviewID ...string) TableRowStyle {
// GetTableColumnStyle returns a TableColumnStyle which defines styles of TableView columns.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTableColumnStyle(view View, subviewID ...string) TableColumnStyle {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
for _, tag := range []PropertyName{ColumnStyle, Content} {
if value := view.getRaw(tag); value != nil {
if style, ok := value.(TableColumnStyle); ok {
@@ -86,11 +74,7 @@ func GetTableColumnStyle(view View, subviewID ...string) TableColumnStyle {
// GetTableCellStyle returns a TableCellStyle which defines styles of TableView cells.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTableCellStyle(view View, subviewID ...string) TableCellStyle {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
for _, tag := range []PropertyName{CellStyle, Content} {
if value := view.getRaw(tag); value != nil {
if style, ok := value.(TableCellStyle); ok {
@@ -136,11 +120,7 @@ func GetTableFootHeight(view View, subviewID ...string) int {
// If the selection mode is RowSelection (2) then the returned column index is less than 0.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTableCurrent(view View, subviewID ...string) CellIndex {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if selectionMode := GetTableSelectionMode(view); selectionMode != NoneSelection {
return tableViewCurrent(view)
}
@@ -179,37 +159,23 @@ func GetTableRowSelectedListeners(view View, subviewID ...string) []func(TableVi
// ReloadTableViewData updates TableView
// If the second argument (subviewID) is not specified or it is "" then updates the first argument (TableView).
func ReloadTableViewData(view View, subviewID ...string) bool {
- var tableView TableView
- if len(subviewID) > 0 && subviewID[0] != "" {
- if tableView = TableViewByID(view, subviewID[0]); tableView == nil {
- return false
- }
- } else {
- var ok bool
- if tableView, ok = view.(TableView); !ok {
- return false
+ if view = getSubview(view, subviewID); view != nil {
+ if tableView, ok := view.(TableView); ok {
+ tableView.ReloadTableData()
+ return true
}
}
-
- tableView.ReloadTableData()
- return true
+ return false
}
// ReloadTableViewCell updates the given table cell.
// If the last argument (subviewID) is not specified or it is "" then updates the cell of the first argument (TableView).
func ReloadTableViewCell(row, column int, view View, subviewID ...string) bool {
- var tableView TableView
- if len(subviewID) > 0 && subviewID[0] != "" {
- if tableView = TableViewByID(view, subviewID[0]); tableView == nil {
- return false
- }
- } else {
- var ok bool
- if tableView, ok = view.(TableView); !ok {
- return false
+ if view = getSubview(view, subviewID); view != nil {
+ if tableView, ok := view.(TableView); ok {
+ tableView.ReloadCell(row, column)
+ return true
}
}
-
- tableView.ReloadCell(row, column)
- return true
+ return false
}
diff --git a/timePicker.go b/timePicker.go
index 1e2956a..3652dd5 100644
--- a/timePicker.go
+++ b/timePicker.go
@@ -375,10 +375,7 @@ func getTimeProperty(view View, mainTag, shortTag PropertyName) (time.Time, bool
// "false" as the second value otherwise.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTimePickerMin(view View, subviewID ...string) (time.Time, bool) {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
return getTimeProperty(view, TimePickerMin, Min)
}
return time.Now(), false
@@ -388,10 +385,7 @@ func GetTimePickerMin(view View, subviewID ...string) (time.Time, bool) {
// "false" as the second value otherwise.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTimePickerMax(view View, subviewID ...string) (time.Time, bool) {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
return getTimeProperty(view, TimePickerMax, Max)
}
return time.Now(), false
@@ -406,10 +400,7 @@ func GetTimePickerStep(view View, subviewID ...string) int {
// GetTimePickerValue returns the time of TimePicker subview.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTimePickerValue(view View, subviewID ...string) time.Time {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view == nil {
+ if view = getSubview(view, subviewID); view == nil {
return time.Now()
}
time, _ := getTimeProperty(view, TimePickerValue, Value)
diff --git a/viewClip.go b/viewClip.go
index 77d7dae..ca918e8 100644
--- a/viewClip.go
+++ b/viewClip.go
@@ -565,10 +565,7 @@ func getClipShape(prop Properties, tag PropertyName, session Session) ClipShape
// GetClip returns a View clipping area.
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
func GetClip(view View, subviewID ...string) ClipShape {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
return getClipShape(view, Clip, view.Session())
}
@@ -578,10 +575,7 @@ func GetClip(view View, subviewID ...string) ClipShape {
// GetShapeOutside returns a shape around which adjacent inline content.
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
func GetShapeOutside(view View, subviewID ...string) ClipShape {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
return getClipShape(view, ShapeOutside, view.Session())
}
diff --git a/viewFilter.go b/viewFilter.go
index 7222017..4773d4d 100644
--- a/viewFilter.go
+++ b/viewFilter.go
@@ -321,11 +321,7 @@ func setFilterProperty(properties Properties, tag PropertyName, value any) []Pro
// GetFilter returns a View graphical effects like blur or color shift.
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
func GetFilter(view View, subviewID ...string) ViewFilter {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if value := view.getRaw(Filter); value != nil {
if filter, ok := value.(ViewFilter); ok {
return filter
@@ -344,11 +340,7 @@ func GetFilter(view View, subviewID ...string) ViewFilter {
// GetBackdropFilter returns the area behind a View graphical effects like blur or color shift.
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
func GetBackdropFilter(view View, subviewID ...string) ViewFilter {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if value := view.getRaw(BackdropFilter); value != nil {
if filter, ok := value.(ViewFilter); ok {
return filter
diff --git a/viewUtils.go b/viewUtils.go
index a8f28ce..f1ea069 100644
--- a/viewUtils.go
+++ b/viewUtils.go
@@ -70,13 +70,37 @@ func SetParams(rootView View, viewID string, params Params) bool {
return result
}
+func getSubview(view View, subviewID []string) View {
+ switch len(subviewID) {
+ case 0:
+ // do nothing
+
+ case 1:
+ if subviewID[0] != "" {
+ view = ViewByID(view, subviewID[0])
+ }
+
+ default:
+ buffer := allocStringBuilder()
+ defer freeStringBuilder(buffer)
+ for _, id := range subviewID {
+ if id != "" {
+ if buffer.Len() > 0 {
+ buffer.WriteRune('/')
+ }
+ buffer.WriteString(id)
+ }
+ }
+ view = ViewByID(view, buffer.String())
+ }
+
+ return view
+}
+
// IsDisabled returns "true" if the subview is disabled
// If the second argument (subviewID) is not specified or it is "" then a state of the first argument (view) is returned
func IsDisabled(view View, subviewID ...string) bool {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if disabled, _ := boolProperty(view, Disabled, view.Session()); disabled {
return true
}
@@ -106,10 +130,7 @@ func GetOpacity(view View, subviewID ...string) float64 {
// GetStyle returns the subview style id.
// If the second argument (subviewID) is not specified or it is "" then a style of the first argument (view) is returned
func GetStyle(view View, subviewID ...string) string {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if style, ok := stringProperty(view, Style, view.Session()); ok {
return style
}
@@ -120,10 +141,7 @@ func GetStyle(view View, subviewID ...string) string {
// GetDisabledStyle returns the disabled subview style id.
// If the second argument (subviewID) is not specified or it is "" then a style of the first argument (view) is returned
func GetDisabledStyle(view View, subviewID ...string) string {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if style, ok := stringProperty(view, StyleDisabled, view.Session()); ok {
return style
}
@@ -142,12 +160,8 @@ func GetVisibility(view View, subviewID ...string) int {
// OverflowHidden (0), OverflowVisible (1), OverflowScroll (2), OverflowAuto (3)
// If the second argument (subviewID) is not specified or it is "" then a value of the first argument (view) is returned
func GetOverflow(view View, subviewID ...string) int {
- defaultOverflow := OverflowHidden
- view2 := view
- if len(subviewID) > 0 && subviewID[0] != "" {
- view2 = ViewByID(view, subviewID[0])
- }
- if view2 != nil {
+ if view = getSubview(view, subviewID); view != nil {
+ defaultOverflow := OverflowHidden
switch view.(type) {
case EditView:
defaultOverflow = OverflowAuto
@@ -155,16 +169,16 @@ func GetOverflow(view View, subviewID ...string) int {
case ListView:
defaultOverflow = OverflowAuto
}
+ return enumStyledProperty(view, nil, Overflow, defaultOverflow, false)
}
- return enumStyledProperty(view, subviewID, Overflow, defaultOverflow, false)
+
+ return OverflowHidden
}
// GetTabIndex returns the subview tab-index.
// If the second argument (subviewID) is not specified or it is "" then a tab-index of the first argument (view) is returned
func GetTabIndex(view View, subviewID ...string) int {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
+ view = getSubview(view, subviewID)
defaultValue := -1
if view != nil {
@@ -264,11 +278,8 @@ func GetBottom(view View, subviewID ...string) SizeUnit {
// Margin returns the subview margin.
// If the second argument (subviewID) is not specified or it is "" then a margin of the first argument (view) is returned
func GetMargin(view View, subviewID ...string) Bounds {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
var bounds Bounds
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
bounds.setFromProperties(Margin, MarginTop, MarginRight, MarginBottom, MarginLeft, view, view.Session())
}
return bounds
@@ -277,11 +288,8 @@ func GetMargin(view View, subviewID ...string) Bounds {
// GetPadding returns the subview padding.
// If the second argument (subviewID) is not specified or it is "" then a padding of the first argument (view) is returned
func GetPadding(view View, subviewID ...string) Bounds {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
var bounds Bounds
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
bounds.setFromProperties(Padding, PaddingTop, PaddingRight, PaddingBottom, PaddingLeft, view, view.Session())
}
return bounds
@@ -290,10 +298,7 @@ func GetPadding(view View, subviewID ...string) Bounds {
// GetBorder returns ViewBorders of the subview.
// If the second argument (subviewID) is not specified or it is "" then a ViewBorders of the first argument (view) is returned.
func GetBorder(view View, subviewID ...string) ViewBorders {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if border := getBorderProperty(view, Border); border != nil {
return border.ViewBorders(view.Session())
}
@@ -304,9 +309,7 @@ func GetBorder(view View, subviewID ...string) ViewBorders {
// Radius returns the BoxRadius structure of the subview.
// If the second argument (subviewID) is not specified or it is "" then a BoxRadius of the first argument (view) is returned.
func GetRadius(view View, subviewID ...string) BoxRadius {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
+ view = getSubview(view, subviewID)
if view == nil {
return BoxRadius{}
}
@@ -316,10 +319,7 @@ func GetRadius(view View, subviewID ...string) BoxRadius {
// GetOutline returns ViewOutline of the subview.
// If the second argument (subviewID) is not specified or it is "" then a ViewOutline of the first argument (view) is returned.
func GetOutline(view View, subviewID ...string) ViewOutline {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if outline := getOutlineProperty(view); outline != nil {
return outline.ViewOutline(view.Session())
}
@@ -336,9 +336,7 @@ func GetOutlineOffset(view View, subviewID ...string) SizeUnit {
// GetViewShadows returns shadows of the subview.
// If the second argument (subviewID) is not specified or it is "" then shadows of the first argument (view) is returned.
func GetViewShadows(view View, subviewID ...string) []ViewShadow {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
+ view = getSubview(view, subviewID)
if view == nil {
return []ViewShadow{}
}
@@ -348,9 +346,7 @@ func GetViewShadows(view View, subviewID ...string) []ViewShadow {
// GetTextShadows returns text shadows of the subview.
// If the second argument (subviewID) is not specified or it is "" then shadows of the first argument (view) is returned.
func GetTextShadows(view View, subviewID ...string) []ViewShadow {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
+ view = getSubview(view, subviewID)
if view == nil {
return []ViewShadow{}
}
@@ -530,10 +526,7 @@ func GetVerticalTextOrientation(view View, subviewID ...string) int {
// GetRow returns the range of row numbers of a GridLayout in which the subview is placed.
// If the second argument (subviewID) is not specified or it is "" then a values from the first argument (view) is returned.
func GetRow(view View, subviewID ...string) Range {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
session := view.Session()
if result, ok := rangeProperty(view, Row, session); ok {
return result
@@ -550,10 +543,7 @@ func GetRow(view View, subviewID ...string) Range {
// GetColumn returns the range of column numbers of a GridLayout in which the subview is placed.
// If the second argument (subviewID) is not specified or it is "" then a values from the first argument (view) is returned.
func GetColumn(view View, subviewID ...string) Range {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
session := view.Session()
if result, ok := rangeProperty(view, Column, session); ok {
return result
@@ -586,9 +576,7 @@ func GetPerspective(view View, subviewID ...string) SizeUnit {
// It is used as the vanishing point by the Perspective property. The default value is (50%, 50%).
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetPerspectiveOrigin(view View, subviewID ...string) (SizeUnit, SizeUnit) {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
+ view = getSubview(view, subviewID)
if view == nil {
return AutoSize(), AutoSize()
}
@@ -608,9 +596,7 @@ func GetBackfaceVisible(view View, subviewID ...string) bool {
// The default value is (50%, 50%, 50%).
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTransformOrigin(view View, subviewID ...string) (SizeUnit, SizeUnit, SizeUnit) {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
+ view = getSubview(view, subviewID)
if view == nil {
return AutoSize(), AutoSize(), AutoSize()
}
@@ -620,9 +606,7 @@ func GetTransformOrigin(view View, subviewID ...string) (SizeUnit, SizeUnit, Siz
// GetTranslate returns a x-, y-, and z-axis translation value of a 2D/3D translation
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTranslate(view View, subviewID ...string) (SizeUnit, SizeUnit, SizeUnit) {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
+ view = getSubview(view, subviewID)
if view == nil {
return AutoSize(), AutoSize(), AutoSize()
}
@@ -638,9 +622,7 @@ func GetTranslate(view View, subviewID ...string) (SizeUnit, SizeUnit, SizeUnit)
// and the ordinate (y-axis). The default value is 0.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetSkew(view View, subviewID ...string) (AngleUnit, AngleUnit) {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
+ view = getSubview(view, subviewID)
if view == nil {
return AngleUnit{Value: 0, Type: Radian}, AngleUnit{Value: 0, Type: Radian}
}
@@ -652,9 +634,7 @@ func GetSkew(view View, subviewID ...string) (AngleUnit, AngleUnit) {
// GetScale returns a x-, y-, and z-axis scaling value of a 2D/3D scale. The default value is 1.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetScale(view View, subviewID ...string) (float64, float64, float64) {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
+ view = getSubview(view, subviewID)
if view == nil {
return 1, 1, 1
}
@@ -669,9 +649,7 @@ func GetScale(view View, subviewID ...string) (float64, float64, float64) {
// GetRotate returns a x-, y, z-coordinate of the vector denoting the axis of rotation, and the angle of the view rotation
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetRotate(view View, subviewID ...string) (float64, float64, float64, AngleUnit) {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
+ view = getSubview(view, subviewID)
if view == nil {
return 0, 0, 0, AngleUnit{Value: 0, Type: Radian}
}
@@ -717,10 +695,7 @@ func valueFromStyle(view View, tag PropertyName) any {
}
func stringStyledProperty(view View, subviewID []string, tag PropertyName, inherit bool) string {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if text, ok := stringProperty(view, tag, view.Session()); ok {
return text
}
@@ -740,11 +715,7 @@ func stringStyledProperty(view View, subviewID []string, tag PropertyName, inher
}
func sizeStyledProperty(view View, subviewID []string, tag PropertyName, inherit bool) SizeUnit {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if value, ok := sizeProperty(view, tag, view.Session()); ok {
return value
}
@@ -764,11 +735,7 @@ func sizeStyledProperty(view View, subviewID []string, tag PropertyName, inherit
}
func enumStyledProperty(view View, subviewID []string, tag PropertyName, defaultValue int, inherit bool) int {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if value, ok := enumProperty(view, tag, view.Session(), defaultValue); ok {
return value
}
@@ -788,11 +755,7 @@ func enumStyledProperty(view View, subviewID []string, tag PropertyName, default
}
func boolStyledProperty(view View, subviewID []string, tag PropertyName, inherit bool) bool {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if value, ok := boolProperty(view, tag, view.Session()); ok {
return value
}
@@ -813,11 +776,7 @@ func boolStyledProperty(view View, subviewID []string, tag PropertyName, inherit
}
func intStyledProperty(view View, subviewID []string, tag PropertyName, defaultValue int) int {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if value, ok := intProperty(view, tag, view.Session(), defaultValue); ok {
return value
}
@@ -830,10 +789,7 @@ func intStyledProperty(view View, subviewID []string, tag PropertyName, defaultV
}
func floatStyledProperty(view View, subviewID []string, tag PropertyName, defaultValue float64) float64 {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if value, ok := floatProperty(view, tag, view.Session(), defaultValue); ok {
return value
}
@@ -846,10 +802,7 @@ func floatStyledProperty(view View, subviewID []string, tag PropertyName, defaul
}
func colorStyledProperty(view View, subviewID []string, tag PropertyName, inherit bool) Color {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if value, ok := colorProperty(view, tag, view.Session()); ok {
return value
}
@@ -868,10 +821,7 @@ func colorStyledProperty(view View, subviewID []string, tag PropertyName, inheri
}
func transformStyledProperty(view View, subviewID []string, tag PropertyName) TransformProperty {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if transform := getTransformProperty(view, tag); transform != nil {
return transform
}
@@ -887,10 +837,7 @@ func transformStyledProperty(view View, subviewID []string, tag PropertyName) Tr
// The focused View is the View which will receive keyboard events by default.
// If the second argument (subviewID) is not specified or it is "" then focus is set on the first argument (view)
func FocusView(view View, subviewID ...string) {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
view.Session().callFunc("focus", view.htmlID())
}
}
@@ -920,12 +867,8 @@ func BlurViewByID(viewID string, session Session) {
// GetCurrent returns the index of the selected item (<0 if there is no a selected item) or the current view index (StackLayout, TabsLayout).
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetCurrent(view View, subviewID ...string) int {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
defaultValue := -1
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if result, ok := intProperty(view, Current, view.Session(), defaultValue); ok {
return result
} else if view.Tag() != "ListView" {
@@ -938,11 +881,7 @@ func GetCurrent(view View, subviewID ...string) int {
// IsUserSelect returns "true" if the user can select text, "false" otherwise.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func IsUserSelect(view View, subviewID ...string) bool {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
value, _ := isUserSelect(view)
return value
}
@@ -1006,11 +945,7 @@ func GetBackgroundBlendMode(view View, subviewID ...string) int {
// GetTooltip returns a tooltip text of the subview.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTooltip(view View, subviewID ...string) string {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- if view != nil {
+ if view = getSubview(view, subviewID); view != nil {
if value := view.Get(Tooltip); value != nil {
if text, ok := value.(string); ok {
return text
From 488368de8cfc440075e6ca8b1891218b4ea9bc54 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Sun, 24 Nov 2024 17:23:24 +0200
Subject: [PATCH 11/43] Optimisation
---
app_scripts.js | 7 +++
stackLayout.go | 111 +++++++++++++++++++++++++++++++++++++++++++++-
viewsContainer.go | 35 +++++++++++----
3 files changed, 143 insertions(+), 10 deletions(-)
diff --git a/app_scripts.js b/app_scripts.js
index 8c40e74..e187c4a 100644
--- a/app_scripts.js
+++ b/app_scripts.js
@@ -223,6 +223,13 @@ function appendToInputValue(elementId, content) {
}
}
+function removeView(elementId) {
+ const element = document.getElementById(elementId);
+ if (element) {
+ element.remove()
+ }
+}
+
function setDisabled(elementId, disabled) {
const element = document.getElementById(elementId);
if (element) {
diff --git a/stackLayout.go b/stackLayout.go
index a2cc899..05c7f49 100644
--- a/stackLayout.go
+++ b/stackLayout.go
@@ -176,7 +176,7 @@ func (layout *stackLayoutData) transitionFinished(view View, tag PropertyName) {
case "pop":
if finished, ok := layout.onPopFinished[viewID]; ok {
- session.updateCSSProperty(viewID+"page", "display", "none")
+ session.callFunc("removeView", viewID+"page")
if finished.listener != nil {
finished.listener(finished.view)
}
@@ -405,6 +405,115 @@ func transformMirror(transform TransformProperty, session Session) TransformProp
return result
}
+// Append appends a view to the end of the list of a view children
+func (layout *stackLayoutData) Append(view View) {
+ if view == nil {
+ ErrorLog("StackLayout.Append(nil) is forbidden")
+ return
+ }
+
+ stackID := layout.htmlID()
+ view.setParentID(stackID)
+
+ count := len(layout.views)
+ if count == 0 {
+ layout.views = []View{view}
+ } else {
+ layout.views = append(layout.views, view)
+ }
+
+ buffer := allocStringBuilder()
+ defer freeStringBuilder(buffer)
+
+ buffer.WriteString(`
`)
+
+ session := layout.Session()
+ session.appendToInnerHTML(stackID, buffer.String())
+
+ if listener, ok := layout.changeListener[Content]; ok {
+ listener(layout, Content)
+ }
+}
+
+// Remove removes view from list and return it
+func (layout *stackLayoutData) RemoveView(index int) View {
+ if layout.views == nil {
+ layout.views = []View{}
+ return nil
+ }
+
+ count := len(layout.views)
+ if index < 0 || index >= count {
+ return nil
+ }
+
+ session := layout.Session()
+ view := layout.views[index]
+ view.setParentID("")
+
+ if count == 1 {
+ layout.views = []View{}
+ } else if index == 0 {
+ layout.views = layout.views[1:]
+ } else if index == count-1 {
+ layout.views = layout.views[:index]
+ session.updateCSSProperty(layout.views[count-2].htmlID()+"page", "visibility", "visible")
+ } else {
+ layout.views = append(layout.views[:index], layout.views[index+1:]...)
+ }
+
+ layout.Session().callFunc("removeView", view.htmlID()+"page")
+
+ if listener, ok := layout.changeListener[Content]; ok {
+ listener(layout, Content)
+ }
+ return view
+}
+
func (layout *stackLayoutData) Push(view View, onPushFinished func()) {
if view == nil {
ErrorLog("StackLayout.Push(nil, ....) is forbidden")
diff --git a/viewsContainer.go b/viewsContainer.go
index 7a9bca1..678719c 100644
--- a/viewsContainer.go
+++ b/viewsContainer.go
@@ -64,7 +64,7 @@ func (container *viewsContainerData) Views() []View {
return []View{}
}
-func viewsContainerContentChanged(container *viewsContainerData) {
+func viewsContainerContentChanged1(container *viewsContainerData) {
updateInnerHTML(container.htmlID(), container.Session())
if listener, ok := container.changeListener[Content]; ok {
listener(container, Content)
@@ -81,24 +81,37 @@ func (container *viewsContainerData) Append(view View) {
} else {
container.views = append(container.views, view)
}
- viewsContainerContentChanged(container)
+
+ buffer := allocStringBuilder()
+ defer freeStringBuilder(buffer)
+
+ viewHTML(view, buffer, "")
+ container.Session().appendToInnerHTML(htmlID, buffer.String())
+
+ if listener, ok := container.changeListener[Content]; ok {
+ listener(container, Content)
+ }
}
}
// Insert inserts a view to the "index" position in the list of a view children
func (container *viewsContainerData) Insert(view View, index int) {
if view != nil {
- htmlID := container.htmlID()
if container.views == nil || index < 0 || index >= len(container.views) {
container.Append(view)
- } else if index > 0 {
- view.setParentID(htmlID)
+ return
+ }
+
+ htmlID := container.htmlID()
+ view.setParentID(htmlID)
+ if index > 0 {
container.views = append(container.views[:index], append([]View{view}, container.views[index:]...)...)
- viewsContainerContentChanged(container)
} else {
- view.setParentID(htmlID)
container.views = append([]View{view}, container.views...)
- viewsContainerContentChanged(container)
+ }
+ updateInnerHTML(htmlID, container.Session())
+ if listener, ok := container.changeListener[Content]; ok {
+ listener(container, Content)
}
}
}
@@ -125,7 +138,11 @@ func (container *viewsContainerData) RemoveView(index int) View {
}
view.setParentID("")
- viewsContainerContentChanged(container)
+
+ container.Session().callFunc("removeView", view.htmlID())
+ if listener, ok := container.changeListener[Content]; ok {
+ listener(container, Content)
+ }
return view
}
From 91093637c7c0bf0bede105cc63fbe469cce0c885 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Sun, 24 Nov 2024 21:14:35 +0200
Subject: [PATCH 12/43] Update stackLayout.go
---
stackLayout.go | 83 +++++++++++++++++++++++++++++++++++---------------
1 file changed, 58 insertions(+), 25 deletions(-)
diff --git a/stackLayout.go b/stackLayout.go
index 05c7f49..1ea0eea 100644
--- a/stackLayout.go
+++ b/stackLayout.go
@@ -70,11 +70,15 @@ type StackLayout interface {
// RemovePeek removes the current View and returns it. If StackLayout is empty then it doesn't do anything and returns nil.
RemovePeek() View
- // MoveToFront makes the given View current. Returns true if successful, false otherwise.
- MoveToFront(view View) bool
+ // MoveToFront makes the given View current.
+ // The second argument is a function called after the move to front animation ends.
+ // Returns true if successful, false otherwise.
+ MoveToFront(view View, onShown ...func(View)) bool
- // MoveToFrontByID makes the View current by viewID. Returns true if successful, false otherwise.
- MoveToFrontByID(viewID string) bool
+ // MoveToFrontByID makes the View current by viewID.
+ // The second argument is a function called after the move to front animation ends.
+ // Returns true if successful, false otherwise.
+ MoveToFrontByID(viewID string, onShown ...func(View)) bool
// Push adds a new View to the container and makes it current.
// It is similar to Append, but the addition is done using an animation effect.
@@ -84,29 +88,30 @@ type StackLayout interface {
// * EndToStartAnimation (2) - End-to-Beginning animation;
// * TopDownAnimation (3) - Top-down animation;
// * BottomUpAnimation (4) - Bottom up animation.
- // The third argument `onPushFinished` is the function to be called when the animation ends. It may be nil.
- Push(view View, onPushFinished func())
+ // The second argument `onPushFinished` is the function to be called when the animation ends.
+ Push(view View, onPushFinished ...func())
// Pop removes the current View from the container using animation.
- // The second argument `onPopFinished`` is the function to be called when the animation ends. It may be nil.
+ // The argument `onPopFinished` is the function to be called when the animation ends.
// The function will return false if the StackLayout is empty and true if the current item has been removed.
- Pop(onPopFinished func(View)) bool
+ Pop(onPopFinished ...func(View)) bool
}
type pushFinished struct {
peekID string
- listener func()
+ listener []func()
}
type popFinished struct {
view View
- listener func(View)
+ listener []func(View)
}
type stackLayoutData struct {
viewsContainerData
onPushFinished map[string]pushFinished
onPopFinished map[string]popFinished
+ onMoveFinished map[string]popFinished
}
// NewStackLayout create new StackLayout object and return it
@@ -129,6 +134,7 @@ func (layout *stackLayoutData) init(session Session) {
layout.systemClass = "ruiStackLayout"
layout.onPushFinished = map[string]pushFinished{}
layout.onPopFinished = map[string]popFinished{}
+ layout.onMoveFinished = map[string]popFinished{}
layout.set = layout.setFunc
layout.remove = layout.removeFunc
@@ -167,8 +173,10 @@ func (layout *stackLayoutData) transitionFinished(view View, tag PropertyName) {
session.removeProperty(pageID, "ontransitioncancel")
session.finishUpdateScript(pageID)
- if finished.listener != nil {
- finished.listener()
+ for _, listener := range finished.listener {
+ if listener != nil {
+ listener()
+ }
}
delete(layout.onPushFinished, viewID)
layout.contentChanged()
@@ -177,8 +185,10 @@ func (layout *stackLayoutData) transitionFinished(view View, tag PropertyName) {
case "pop":
if finished, ok := layout.onPopFinished[viewID]; ok {
session.callFunc("removeView", viewID+"page")
- if finished.listener != nil {
- finished.listener(finished.view)
+ for _, listener := range finished.listener {
+ if listener != nil {
+ listener(finished.view)
+ }
}
delete(layout.onPopFinished, viewID)
@@ -209,6 +219,15 @@ func (layout *stackLayoutData) transitionFinished(view View, tag PropertyName) {
session.removeProperty(pageID, "ontransitioncancel")
session.finishUpdateScript(pageID)
layout.contentChanged()
+
+ if finished, ok := layout.onMoveFinished[viewID]; ok {
+ for _, listener := range finished.listener {
+ if listener != nil {
+ listener(finished.view)
+ }
+ }
+ delete(layout.onMoveFinished, viewID)
+ }
}
}
}
@@ -250,7 +269,7 @@ func (layout *stackLayoutData) Peek() View {
return nil
}
-func (layout *stackLayoutData) MoveToFront(view View) bool {
+func (layout *stackLayoutData) MoveToFront(view View, onShown ...func(View)) bool {
if view == nil {
ErrorLog(`MoveToFront(nil) forbidden`)
return false
@@ -269,7 +288,7 @@ func (layout *stackLayoutData) MoveToFront(view View) bool {
default:
for i, view := range layout.views {
if view.htmlID() == htmlID {
- layout.moveToFrontByIndex(i)
+ layout.moveToFrontByIndex(i, onShown)
return true
}
}
@@ -279,7 +298,7 @@ func (layout *stackLayoutData) MoveToFront(view View) bool {
return false
}
-func (layout *stackLayoutData) MoveToFrontByID(viewID string) bool {
+func (layout *stackLayoutData) MoveToFrontByID(viewID string, onShown ...func(View)) bool {
switch count := len(layout.views); count {
case 0:
// do nothing
@@ -292,7 +311,7 @@ func (layout *stackLayoutData) MoveToFrontByID(viewID string) bool {
default:
for i, view := range layout.views {
if view.ID() == viewID {
- layout.moveToFrontByIndex(i)
+ layout.moveToFrontByIndex(i, onShown)
return true
}
}
@@ -302,7 +321,7 @@ func (layout *stackLayoutData) MoveToFrontByID(viewID string) bool {
return false
}
-func (layout *stackLayoutData) moveToFrontByIndex(index int) {
+func (layout *stackLayoutData) moveToFrontByIndex(index int, onShow []func(View)) {
count := len(layout.views)
if index == count-1 {
@@ -332,9 +351,19 @@ func (layout *stackLayoutData) moveToFrontByIndex(index int) {
session.updateCSSProperty(peekPageID, "visibility", "hidden")
session.updateCSSProperty(pageID, "visibility", "visible")
layout.contentChanged()
+ for _, listener := range onShow {
+ if listener != nil {
+ listener(view)
+ }
+ }
return
}
+ layout.onMoveFinished[view.htmlID()] = popFinished{
+ view: view,
+ listener: onShow,
+ }
+
buffer := allocStringBuilder()
defer freeStringBuilder(buffer)
@@ -514,7 +543,7 @@ func (layout *stackLayoutData) RemoveView(index int) View {
return view
}
-func (layout *stackLayoutData) Push(view View, onPushFinished func()) {
+func (layout *stackLayoutData) Push(view View, onPushFinished ...func()) {
if view == nil {
ErrorLog("StackLayout.Push(nil, ....) is forbidden")
return
@@ -523,8 +552,10 @@ func (layout *stackLayoutData) Push(view View, onPushFinished func()) {
transform := GetPushTransform(layout)
if transform == nil {
layout.Append(view)
- if onPushFinished != nil {
- onPushFinished()
+ for _, listener := range onPushFinished {
+ if listener != nil {
+ listener()
+ }
}
return
}
@@ -578,7 +609,7 @@ func (layout *stackLayoutData) Push(view View, onPushFinished func()) {
layout.session.updateCSSProperty(htmlID+"page", "transform", "")
}
-func (layout *stackLayoutData) Pop(onPopFinished func(View)) bool {
+func (layout *stackLayoutData) Pop(onPopFinished ...func(View)) bool {
count := len(layout.views)
if count == 0 {
ErrorLog("StackLayout is empty")
@@ -588,8 +619,10 @@ func (layout *stackLayoutData) Pop(onPopFinished func(View)) bool {
transform := GetPushTransform(layout)
if transform == nil {
if view := layout.RemovePeek(); view != nil {
- if onPopFinished != nil {
- onPopFinished(view)
+ for _, listener := range onPopFinished {
+ if listener != nil {
+ listener(view)
+ }
}
return true
}
From bdc8472600952787fb8ab8794408dc2c035a4e77 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Sun, 24 Nov 2024 21:15:05 +0200
Subject: [PATCH 13/43] Cleanup
---
viewsContainer.go | 7 -------
1 file changed, 7 deletions(-)
diff --git a/viewsContainer.go b/viewsContainer.go
index 678719c..372c13c 100644
--- a/viewsContainer.go
+++ b/viewsContainer.go
@@ -64,13 +64,6 @@ func (container *viewsContainerData) Views() []View {
return []View{}
}
-func viewsContainerContentChanged1(container *viewsContainerData) {
- updateInnerHTML(container.htmlID(), container.Session())
- if listener, ok := container.changeListener[Content]; ok {
- listener(container, Content)
- }
-}
-
// Append appends a view to the end of the list of a view children
func (container *viewsContainerData) Append(view View) {
if view != nil {
From 5cc4475370002bdd8d68c3bd22b257958fa8728d Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Mon, 25 Nov 2024 12:03:08 +0200
Subject: [PATCH 14/43] * Added "push-perspective", "push-rotate-x",
"push-rotate-y", "push-rotate-z", "push-rotate", "push-skew-x",
"push-skew-y", "push-scale-x", "push-scale-y", "push-scale-z",
"push-translate-x", "push-translate-y", "push-translate-z" properties.
---
CHANGELOG.md | 2 +
stackLayout.go | 198 ++++++++++++++++++++++++++++++++++++++++++++++++
transform.go | 86 ++++++++++++---------
view.go | 7 +-
viewStyleSet.go | 6 +-
5 files changed, 260 insertions(+), 39 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 38b90f2..979568a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,8 @@
* Changed Push and Pop method of StackLayout interface.
* Removed DefaultAnimation, StartToEndAnimation, EndToStartAnimation, TopDownAnimation, and BottomUpAnimation constants.
* Added "push-transform", "push-duration", "push-timing", and "move-to-front-animation" properties.
+* Added "push-perspective", "push-rotate-x", "push-rotate-y", "push-rotate-z", "push-rotate", "push-skew-x", "push-skew-y",
+"push-scale-x", "push-scale-y", "push-scale-z", "push-translate-x", "push-translate-y", "push-translate-z" properties.
* Added GetPushTransform, GetPushDuration, GetPushTiming, and IsMoveToFrontAnimation functions.
* Added LineJoin type. Type of constants MiterJoin, RoundJoin, and BevelJoin changed to LineJoin. Type of Canvas.SetLineJoin function argument changed to LineJoin.
* Added LineCap type. Type of constants ButtCap, RoundCap, and SquareCap changed to LineCap. Type of Canvas.SetLineCap function argument changed to LineCap.
diff --git a/stackLayout.go b/stackLayout.go
index 1ea0eea..1d77b6e 100644
--- a/stackLayout.go
+++ b/stackLayout.go
@@ -58,6 +58,191 @@ const (
// `true` or `1` or "true", "yes", "on", "1" - animation is used (default value).
// `false` or `0` or "false", "no", "off", "0" - animation is not used.
MoveToFrontAnimation = "move-to-front-animation"
+
+ // PushPerspective is the constant for "push-perspective" property tag.
+ //
+ // Used by `StackLayout`.
+ //
+ // Used to access the "perspective" property of StackLayout "push-transform" property:
+ // Distance between the z-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).
+ //
+ // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ //
+ // Internal type is `SizeUnit`, other types converted to it during assignment.
+ // See `SizeUnit` description for more details.
+ PushPerspective PropertyName = "push-perspective"
+
+ // PushTranslateX is the constant for "push-translate-x" property tag.
+ //
+ // Used by `StackLayout`.
+ //
+ // Used to access the "translate-x" property of StackLayout "push-transform" property:
+ // x-axis translation value of a 2D/3D translation.
+ //
+ // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ //
+ // Internal type is `SizeUnit`, other types converted to it during assignment.
+ // See `SizeUnit` description for more details.
+ PushTranslateX PropertyName = "push-translate-x"
+
+ // PushTranslateY is the constant for "push-translate-y" property tag.
+ //
+ // Used by `StackLayout`.
+ //
+ // Used to access the "translate-y" property of StackLayout "push-transform" property:
+ // y-axis translation value of a 2D/3D translation.
+ //
+ // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ //
+ // Internal type is `SizeUnit`, other types converted to it during assignment.
+ // See `SizeUnit` description for more details.
+ PushTranslateY PropertyName = "push-translate-y"
+
+ // PushTranslateZ is the constant for "push-translate-z" property tag.
+ //
+ // Used by `StackLayout`.
+ //
+ // Used to access the "translate-z" property of StackLayout "push-transform" property:
+ // z-axis translation value of a 3D translation.
+ //
+ // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ //
+ // Internal type is `SizeUnit`, other types converted to it during assignment.
+ // See `SizeUnit` description for more details.
+ PushTranslateZ PropertyName = "push-translate-z"
+
+ // PushScaleX is the constant for "push-scale-x" property tag.
+ //
+ // Used by `StackLayout`.
+ //
+ // Used to access the "scale-x" property of StackLayout "push-transform" property:
+ // x-axis scaling value of a 2D/3D scale. The original scale is 1. Values between 0 and 1 are used to decrease original
+ // scale, more than 1 - to increase. The default value is 1.
+ //
+ // Supported types: `float`, `int`, `string`.
+ //
+ // Internal type is `float`, other types converted to it during assignment.
+ PushScaleX PropertyName = "push-scale-x"
+
+ // PushScaleY is the constant for "push-scale-y" property tag.
+ //
+ // Used by `StackLayout`.
+ //
+ // Used to access the "scale-y" property of StackLayout "push-transform" property:
+ // y-axis scaling value of a 2D/3D scale. The original scale is 1. Values between 0 and 1 are used to decrease original
+ // scale, more than 1 - to increase. The default value is 1.
+ //
+ // Supported types: `float`, `int`, `string`.
+ //
+ // Internal type is `float`, other types converted to it during assignment.
+ PushScaleY PropertyName = "push-scale-y"
+
+ // PushScaleZ is the constant for "push-scale-z" property tag.
+ //
+ // Used by `StackLayout`.
+ //
+ // Used to access the "scale-z" property of StackLayout "push-transform" property:
+ // z-axis scaling value of a 3D scale. The original scale is 1. Values between 0 and 1 are used to decrease original
+ // scale, more than 1 - to increase. The default value is 1.
+ //
+ // Supported types: `float`, `int`, `string`.
+ //
+ // Internal type is `float`, other types converted to it during assignment.
+ PushScaleZ PropertyName = "push-scale-z"
+
+ // PushRotate is the constant for "push-rotate" property tag.
+ //
+ // Used by `StackLayout`.
+ //
+ // Used to access the "rotate" property of StackLayout "push-transform" property:
+ // Angle of the view rotation. A positive angle denotes a clockwise rotation, a negative angle a counter-clockwise.
+ //
+ // Supported types: `AngleUnit`, `string`, `float`, `int`.
+ //
+ // Internal type is `AngleUnit`, other types will be converted to it during assignment.
+ // See `AngleUnit` description for more details.
+ //
+ // Conversion rules:
+ // `AngleUnit` - stored as is, no conversion performed.
+ // `string` - must contain string representation of `AngleUnit`. If numeric value will be provided without any suffix then `AngleUnit` with value and `Radian` value type will be created.
+ // `float` - a new `AngleUnit` value will be created with `Radian` as a type.
+ // `int` - a new `AngleUnit` value will be created with `Radian` as a type.
+ PushRotate PropertyName = "push-rotate"
+
+ // PushRotateX is the constant for "push-rotate-x" property tag.
+ //
+ // Used by `StackLayout`.
+ //
+ // Used to access the "rotate-x" property of StackLayout "push-transform" property:
+ // x-coordinate of the vector denoting the axis of rotation in range 0 to 1.
+ //
+ // Supported types: `float`, `int`, `string`.
+ //
+ // Internal type is `float`, other types converted to it during assignment.
+ PushRotateX PropertyName = "push-rotate-x"
+
+ // PushRotateY is the constant for "push-rotate-y" property tag.
+ //
+ // Used by `StackLayout`.
+ //
+ // Used to access the "rotate-y" property of StackLayout "push-transform" property:
+ // y-coordinate of the vector denoting the axis of rotation in range 0 to 1.
+ //
+ // Supported types: `float`, `int`, `string`.
+ //
+ // Internal type is `float`, other types converted to it during assignment.
+ PushRotateY PropertyName = "push-rotate-y"
+
+ // PushRotateZ is the constant for "push-rotate-z" property tag.
+ //
+ // Used by `StackLayout`.
+ //
+ // Used to access the "rotate-z" property of StackLayout "push-transform" property:
+ // z-coordinate of the vector denoting the axis of rotation in range 0 to 1.
+ //
+ // Supported types: `float`, `int`, `string`.
+ //
+ // Internal type is `float`, other types converted to it during assignment.
+ PushRotateZ PropertyName = "push-rotate-z"
+
+ // PushSkewX is the constant for "push-skew-x" property tag.
+ //
+ // Used by `StackLayout`.
+ //
+ // Used to access the "skew-x" property of StackLayout "push-transform" property:
+ // Angle to use to distort the element along the abscissa. The default value is 0.
+ //
+ // Supported types: `AngleUnit`, `string`, `float`, `int`.
+ //
+ // Internal type is `AngleUnit`, other types will be converted to it during assignment.
+ // See `AngleUnit` description for more details.
+ //
+ // Conversion rules:
+ // `AngleUnit` - stored as is, no conversion performed.
+ // `string` - must contain string representation of `AngleUnit`. If numeric value will be provided without any suffix then `AngleUnit` with value and `Radian` value type will be created.
+ // `float` - a new `AngleUnit` value will be created with `Radian` as a type.
+ // `int` - a new `AngleUnit` value will be created with `Radian` as a type.
+ PushSkewX PropertyName = "push-skew-x"
+
+ // PushSkewY is the constant for "push-skew-y" property tag.
+ //
+ // Used by `StackLayout`.
+ //
+ // Used to access the "skew-y" property of StackLayout "push-transform" property:
+ // Angle to use to distort the element along the ordinate. The default value is 0.
+ //
+ // Supported types: `AngleUnit`, `string`, `float`, `int`.
+ //
+ // Internal type is `AngleUnit`, other types will be converted to it during assignment.
+ // See `AngleUnit` description for more details.
+ //
+ // Conversion rules:
+ // `AngleUnit` - stored as is, no conversion performed.
+ // `string` - must contain string representation of `AngleUnit`. If numeric value will be provided without any suffix then `AngleUnit` with value and `Radian` value type will be created.
+ // `float` - a new `AngleUnit` value will be created with `Radian` as a type.
+ // `int` - a new `AngleUnit` value will be created with `Radian` as a type.
+ PushSkewY PropertyName = "push-skew-y"
)
// StackLayout represents a StackLayout view
@@ -137,6 +322,7 @@ func (layout *stackLayoutData) init(session Session) {
layout.onMoveFinished = map[string]popFinished{}
layout.set = layout.setFunc
layout.remove = layout.removeFunc
+ layout.changed = layout.propertyChanged
layout.setRaw(TransitionEndEvent, []func(View, PropertyName){layout.transitionFinished})
if session.TextDirection() == RightToLeftDirection {
@@ -253,6 +439,18 @@ func (layout *stackLayoutData) setFunc(tag PropertyName, value any) []PropertyNa
return layout.viewsContainerData.setFunc(tag, value)
}
+func (layout *stackLayoutData) propertyChanged(tag PropertyName) {
+ switch tag {
+ case PushTransform, PushTiming, PushDuration, MoveToFrontAnimation,
+ PushPerspective, PushRotateX, PushRotateY, PushRotateZ, PushRotate, PushSkewX, PushSkewY,
+ PushScaleX, PushScaleY, PushScaleZ, PushTranslateX, PushTranslateY, PushTranslateZ:
+ // do nothing
+
+ default:
+ layout.viewsContainerData.propertyChanged(tag)
+ }
+}
+
func (layout *stackLayoutData) removeFunc(tag PropertyName) []PropertyName {
switch tag {
case TransitionEndEvent:
diff --git a/transform.go b/transform.go
index fefe2fd..c9a9756 100644
--- a/transform.go
+++ b/transform.go
@@ -19,12 +19,12 @@ const (
//
// Conversion rules:
// `TransformProperty` - stored as is, no conversion performed.
- // `string` - string representation of `Transform` interface. Example: "_{translate-x = 10px, scale-y = 1.1}".
+ // `string` - string representation of `TransformProperty` interface. Example: "_{translate-x = 10px, scale-y = 1.1}".
Transform PropertyName = "transform"
// Perspective is the constant for "perspective" property tag.
//
- // Used by `View`.
+ // Used by `View`, `TransformProperty`.
// Distance between the z-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).
//
@@ -70,7 +70,7 @@ const (
// `false` or `0` or "false", "no", "off", "0" - Back face is hidden, effectively making the view invisible when turned away from the user.
BackfaceVisible PropertyName = "backface-visibility"
- // OriginX is the constant for "origin-x" property tag.
+ // TransformOriginX is the constant for "transform-origin-x" property tag.
//
// Used by `View`.
// x-coordinate of the point around which a view transformation is applied. The default value is 50%.
@@ -81,7 +81,7 @@ const (
// See `SizeUnit` description for more details.
TransformOriginX PropertyName = "transform-origin-x"
- // OriginY is the constant for "origin-y" property tag.
+ // TransformOriginY is the constant for "transform-origin-y" property tag.
//
// Used by `View`.
// y-coordinate of the point around which a view transformation is applied. The default value is 50%.
@@ -92,7 +92,7 @@ const (
// See `SizeUnit` description for more details.
TransformOriginY PropertyName = "transform-origin-y"
- // OriginZ is the constant for "origin-z" property tag.
+ // TransformOriginZ is the constant for "transform-origin-z" property tag.
//
// Used by `View`.
// z-coordinate of the point around which a view transformation is applied. The default value is 50%.
@@ -105,7 +105,7 @@ const (
// TranslateX is the constant for "translate-x" property tag.
//
- // Used by `View`, `Transform`.
+ // Used by `View`, `TransformProperty`.
//
// Usage in `View`:
// x-axis translation value of a 2D/3D translation.
@@ -115,7 +115,7 @@ const (
// Internal type is `SizeUnit`, other types converted to it during assignment.
// See `SizeUnit` description for more details.
//
- // Usage in `Transform`:
+ // Usage in `TransformProperty`:
// x-axis translation value of a 2D/3D translation.
//
// Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
@@ -126,7 +126,7 @@ const (
// TranslateY is the constant for "translate-y" property tag.
//
- // Used by `View`, `Transform`.
+ // Used by `View`, `TransformProperty`.
//
// Usage in `View`:
// y-axis translation value of a 2D/3D translation.
@@ -136,7 +136,7 @@ const (
// Internal type is `SizeUnit`, other types converted to it during assignment.
// See `SizeUnit` description for more details.
//
- // Usage in `Transform`:
+ // Usage in `TransformProperty`:
// x-axis translation value of a 2D/3D translation.
//
// Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
@@ -147,7 +147,7 @@ const (
// TranslateZ is the constant for "translate-z" property tag.
//
- // Used by `View`, `Transform`.
+ // Used by `View`, `TransformProperty`.
//
// Usage in `View`:
// z-axis translation value of a 3D translation.
@@ -157,7 +157,7 @@ const (
// Internal type is `SizeUnit`, other types converted to it during assignment.
// See `SizeUnit` description for more details.
//
- // Usage in `Transform`:
+ // Usage in `TransformProperty`:
// z-axis translation value of a 3D translation.
//
// Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
@@ -168,7 +168,7 @@ const (
// ScaleX is the constant for "scale-x" property tag.
//
- // Used by `View`, `Transform`.
+ // Used by `View`, `TransformProperty`.
//
// Usage in `View`:
// x-axis scaling value of a 2D/3D scale. The original scale is 1. Values between 0 and 1 are used to decrease original
@@ -178,7 +178,7 @@ const (
//
// Internal type is `float`, other types converted to it during assignment.
//
- // Usage in `Transform`:
+ // Usage in `TransformProperty`:
// x-axis scaling value of a 2D/3D scale. The original scale is 1. Values between 0 and 1 are used to decrease original
// scale, more than 1 - to increase. The default value is 1.
//
@@ -189,7 +189,7 @@ const (
// ScaleY is the constant for "scale-y" property tag.
//
- // Used by `View`, `Transform`.
+ // Used by `View`, `TransformProperty`.
//
// Usage in `View`:
// y-axis scaling value of a 2D/3D scale. The original scale is 1. Values between 0 and 1 are used to decrease original
@@ -199,7 +199,7 @@ const (
//
// Internal type is `float`, other types converted to it during assignment.
//
- // Usage in `Transform`:
+ // Usage in `TransformProperty`:
// y-axis scaling value of a 2D/3D scale. The original scale is 1. Values between 0 and 1 are used to decrease original
// scale, more than 1 - to increase. The default value is 1.
//
@@ -210,7 +210,7 @@ const (
// ScaleZ is the constant for "scale-z" property tag.
//
- // Used by `View`, `Transform`.
+ // Used by `View`, `TransformProperty`.
//
// Usage in `View`:
// z-axis scaling value of a 3D scale. The original scale is 1. Values between 0 and 1 are used to decrease original
@@ -220,7 +220,7 @@ const (
//
// Internal type is `float`, other types converted to it during assignment.
//
- // Usage in `Transform`:
+ // Usage in `TransformProperty`:
// z-axis scaling value of a 3D scale. The original scale is 1. Values between 0 and 1 are used to decrease original
// scale, more than 1 - to increase. The default value is 1.
//
@@ -231,7 +231,7 @@ const (
// Rotate is the constant for "rotate" property tag.
//
- // Used by `View`, `Transform`.
+ // Used by `View`, `TransformProperty`.
//
// Usage in `View`:
// Angle of the view rotation. A positive angle denotes a clockwise rotation, a negative angle a counter-clockwise.
@@ -247,7 +247,7 @@ const (
// `float` - a new `AngleUnit` value will be created with `Radian` as a type.
// `int` - a new `AngleUnit` value will be created with `Radian` as a type.
//
- // Usage in `Transform`:
+ // Usage in `TransformProperty`:
// Angle of the view rotation. A positive angle denotes a clockwise rotation, a negative angle a counter-clockwise.
//
// Supported types: `AngleUnit`, `string`, `float`, `int`.
@@ -264,7 +264,7 @@ const (
// RotateX is the constant for "rotate-x" property tag.
//
- // Used by `View`, `Transform`.
+ // Used by `View`, `TransformProperty`.
//
// Usage in `View`:
// x-coordinate of the vector denoting the axis of rotation in range 0 to 1.
@@ -273,7 +273,7 @@ const (
//
// Internal type is `float`, other types converted to it during assignment.
//
- // Usage in `Transform`:
+ // Usage in `TransformProperty`:
// x-coordinate of the vector denoting the axis of rotation in range 0 to 1.
//
// Supported types: `float`, `int`, `string`.
@@ -283,7 +283,7 @@ const (
// RotateY is the constant for "rotate-y" property tag.
//
- // Used by `View`, `Transform`.
+ // Used by `View`, `TransformProperty`.
//
// Usage in `View`:
// y-coordinate of the vector denoting the axis of rotation in range 0 to 1.
@@ -292,7 +292,7 @@ const (
//
// Internal type is `float`, other types converted to it during assignment.
//
- // Usage in `Transform`:
+ // Usage in `TransformProperty`:
// y-coordinate of the vector denoting the axis of rotation in range 0 to 1.
//
// Supported types: `float`, `int`, `string`.
@@ -302,7 +302,7 @@ const (
// RotateZ is the constant for "rotate-z" property tag.
//
- // Used by `View`, `Transform`.
+ // Used by `View`, `TransformProperty`.
//
// Usage in `View`:
// z-coordinate of the vector denoting the axis of rotation in range 0 to 1.
@@ -311,7 +311,7 @@ const (
//
// Internal type is `float`, other types converted to it during assignment.
//
- // Usage in `Transform`:
+ // Usage in `TransformProperty`:
// z-coordinate of the vector denoting the axis of rotation in range 0 to 1.
//
// Supported types: `float`, `int`, `string`.
@@ -321,7 +321,7 @@ const (
// SkewX is the constant for "skew-x" property tag.
//
- // Used by `View`, `Transform`.
+ // Used by `View`, `TransformProperty`.
//
// Usage in `View`:
// Angle to use to distort the element along the abscissa. The default value is 0.
@@ -337,7 +337,7 @@ const (
// `float` - a new `AngleUnit` value will be created with `Radian` as a type.
// `int` - a new `AngleUnit` value will be created with `Radian` as a type.
//
- // Usage in `Transform`:
+ // Usage in `TransformProperty`:
// Angle to use to distort the element along the abscissa. The default value is 0.
//
// Supported types: `AngleUnit`, `string`, `float`, `int`.
@@ -354,7 +354,7 @@ const (
// SkewY is the constant for "skew-y" property tag.
//
- // Used by `View`, `Transform`.
+ // Used by `View`, `TransformProperty`.
//
// Usage in `View`:
// Angle to use to distort the element along the ordinate. The default value is 0.
@@ -370,7 +370,7 @@ const (
// `float` - a new `AngleUnit` value will be created with `Radian` as a type.
// `int` - a new `AngleUnit` value will be created with `Radian` as a type.
//
- // Usage in `Transform`:
+ // Usage in `TransformProperty`:
// Angle to use to distort the element along the ordinate. The default value is 0.
//
// Supported types: `AngleUnit`, `string`, `float`, `int`.
@@ -416,6 +416,7 @@ func NewTransformProperty(params Params) TransformProperty {
func (transform *transformPropertyData) init() {
transform.dataProperty.init()
+ transform.normalize = normalizeTransformTag
transform.set = transformSet
transform.supportedProperties = []PropertyName{
RotateX, RotateY, RotateZ, Rotate, SkewX, SkewY, ScaleX, ScaleY, ScaleZ,
@@ -423,6 +424,17 @@ func (transform *transformPropertyData) init() {
}
}
+func normalizeTransformTag(tag PropertyName) PropertyName {
+ tag = defaultNormalize(tag)
+
+ name := string(tag)
+ if strings.HasPrefix(name, "push-") {
+ tag = PropertyName(name[5:])
+ }
+
+ return tag
+}
+
func (transform *transformPropertyData) String() string {
buffer := allocStringBuilder()
defer freeStringBuilder(buffer)
@@ -527,25 +539,27 @@ func getTransformProperty(properties Properties, tag PropertyName) TransformProp
return nil
}
-func setTransformPropertyElement(properties Properties, tag PropertyName, value any) []PropertyName {
+func setTransformPropertyElement(properties Properties, tag, transformTag PropertyName, value any) []PropertyName {
+ srcTag := tag
+ tag = normalizeTransformTag(tag)
switch tag {
case Perspective, RotateX, RotateY, RotateZ, Rotate, SkewX, SkewY, ScaleX, ScaleY, ScaleZ, TranslateX, TranslateY, TranslateZ:
var result []PropertyName = nil
- if transform := getTransformProperty(properties, Transform); transform != nil {
+ if transform := getTransformProperty(properties, transformTag); transform != nil {
if result = transformSet(transform, tag, value); result != nil {
- result = append(result, Transform)
+ result = []PropertyName{srcTag, transformTag}
}
} else {
transform := NewTransformProperty(nil)
if result = transformSet(transform, tag, value); result != nil {
- properties.setRaw(Transform, transform)
- result = append(result, Transform)
+ properties.setRaw(transformTag, transform)
+ result = []PropertyName{srcTag, transformTag}
}
}
return result
}
- ErrorLogF(`"Transform" interface does not support the "%s" property`, tag)
+ ErrorLogF(`"TransformProperty" interface does not support the "%s" property`, tag)
return nil
}
@@ -698,7 +712,7 @@ func (style *viewStyle) writeViewTransformCSS(builder cssBuilder, session Sessio
}
if transform := getTransformProperty(style, Transform); transform != nil {
- builder.add(`transform`, transform.transformCSS(session))
+ builder.add(`TransformProperty`, transform.transformCSS(session))
}
}
diff --git a/view.go b/view.go
index e1923b0..c999658 100644
--- a/view.go
+++ b/view.go
@@ -705,14 +705,17 @@ func (view *viewData) propertyChanged(tag PropertyName) {
x, y, z := getTransformOrigin(view, session)
session.updateCSSProperty(htmlID, "transform-origin", transformOriginCSS(x, y, z, view.Session()))
- case Transform, Perspective, SkewX, SkewY, TranslateX, TranslateY, TranslateZ,
- ScaleX, ScaleY, ScaleZ, Rotate, RotateX, RotateY, RotateZ:
+ case Transform:
css := ""
if transform := getTransformProperty(view, Transform); transform != nil {
css = transform.transformCSS(session)
}
session.updateCSSProperty(htmlID, "transform", css)
+ case Perspective, SkewX, SkewY, TranslateX, TranslateY, TranslateZ,
+ ScaleX, ScaleY, ScaleZ, Rotate, RotateX, RotateY, RotateZ:
+ // do nothing
+
case FocusEvent, LostFocusEvent, ResizeEvent, ScrollEvent, KeyDownEvent, KeyUpEvent,
ClickEvent, DoubleClickEvent, MouseDown, MouseUp, MouseMove, MouseOut, MouseOver, ContextMenuEvent,
PointerDown, PointerUp, PointerMove, PointerOut, PointerOver, PointerCancel,
diff --git a/viewStyleSet.go b/viewStyleSet.go
index 1aac7ed..942951d 100644
--- a/viewStyleSet.go
+++ b/viewStyleSet.go
@@ -354,7 +354,11 @@ func viewStyleSet(style Properties, tag PropertyName, value any) []PropertyName
case Perspective, RotateX, RotateY, RotateZ, Rotate, SkewX, SkewY, ScaleX, ScaleY, ScaleZ,
TranslateX, TranslateY, TranslateZ:
- return setTransformPropertyElement(style, tag, value)
+ return setTransformPropertyElement(style, tag, Transform, value)
+
+ case PushPerspective, PushRotateX, PushRotateY, PushRotateZ, PushRotate, PushSkewX, PushSkewY,
+ PushScaleX, PushScaleY, PushScaleZ, PushTranslateX, PushTranslateY, PushTranslateZ:
+ return setTransformPropertyElement(style, tag, PushTransform, value)
case Orientation:
if text, ok := value.(string); ok {
From bc6e0c4db97f5e93effcefc33f127702e1886fbb Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Mon, 25 Nov 2024 22:13:29 +0200
Subject: [PATCH 15/43] Added Popup show/hide animation
---
app_styles.css | 2 +-
color.go | 8 ++
popup.go | 298 ++++++++++++++++++++++++++++++++++------------
stackLayout.go | 34 +++---
transform.go | 2 +-
viewsContainer.go | 31 +++--
6 files changed, 273 insertions(+), 102 deletions(-)
diff --git a/app_styles.css b/app_styles.css
index 19cda67..ba496a7 100644
--- a/app_styles.css
+++ b/app_styles.css
@@ -79,7 +79,7 @@ ul:focus {
}
.ruiPopupLayer {
- background-color: rgba(128,128,128,0.1);
+ /*background-color: rgba(128,128,128,0.1);*/
position: absolute;
top: 0px;
bottom: 0px;
diff --git a/color.go b/color.go
index ba29f12..cdfdb5f 100644
--- a/color.go
+++ b/color.go
@@ -11,6 +11,14 @@ import (
// Color - represent color in argb format
type Color uint32
+// ARGB creates Color using alpha, red, green and blue components
+func ARGB[T int | uint | int8 | uint8](alpha, red, green, blue T) Color {
+ return ((Color(alpha) & 0xFF) << 24) +
+ ((Color(red) & 0xFF) << 16) +
+ ((Color(green) & 0xFF) << 8) +
+ (Color(blue) & 0xFF)
+}
+
// ARGB - return alpha, red, green and blue components of the color
func (color Color) ARGB() (uint8, uint8, uint8, uint8) {
return uint8(color >> 24),
diff --git a/popup.go b/popup.go
index ca963e9..8cc0148 100644
--- a/popup.go
+++ b/popup.go
@@ -1,6 +1,7 @@
package rui
import (
+ "fmt"
"strings"
)
@@ -143,6 +144,48 @@ const (
// See `SizeUnit` description for more details.
ArrowWidth PropertyName = "arrow-width"
+ // ShowTransform is the constant for "show-transform" property tag.
+ //
+ // Used by `Popup`.
+ // Specify start translation, scale and rotation over x, y and z axes as well as a distortion
+ // for an animated Popup showing/hidding.
+ //
+ // Supported types: `TransformProperty`, `string`.
+ //
+ // See `TransformProperty` description for more details.
+ //
+ // Conversion rules:
+ // `TransformProperty` - stored as is, no conversion performed.
+ // `string` - string representation of `Transform` interface. Example: "_{translate-x = 10px, scale-y = 1.1}".
+ ShowTransform = "show-transform"
+
+ // ShowDuration is the constant for "show-duration" property tag.
+ //
+ // Used by `Popup`.
+ // Sets the length of time in seconds that a Popup show/hide animation takes to complete.
+ //
+ // Supported types: `float`, `int`, `string`.
+ //
+ // Internal type is `float`, other types converted to it during assignment.
+ ShowDuration = "show-duration"
+
+ // ShowTiming is the constant for "show-timing" property tag.
+ //
+ // Used by `StackLayout`.
+ // Set how a Popup show/hide animation progresses through the duration of each cycle.
+ //
+ // Supported types: `string`.
+ //
+ // Values:
+ // "ease"(`EaseTiming`) - Speed increases towards the middle and slows down at the end.
+ // "ease-in"(`EaseInTiming`) - Speed is slow at first, but increases in the end.
+ // "ease-out"(`EaseOutTiming`) - Speed is fast at first, but decreases in the end.
+ // "ease-in-out"(`EaseInOutTiming`) - Speed is slow at first, but quickly increases and at the end it decreases again.
+ // "linear"(`LinearTiming`) - Constant speed.
+ ShowTiming = "show-timing"
+
+ ShowOpacity = "show-opacity"
+
// ArrowOffset is the constant for "arrow-offset" property tag.
//
// Used by `Popup`.
@@ -219,14 +262,21 @@ type Popup interface {
html(buffer *strings.Builder)
viewByHTMLID(id string) View
keyEvent(event KeyEvent) bool
+ showAnimation()
+ dissmissAnimation(listener func(PropertyName)) bool
}
type popupData struct {
- layerView View
- view View
+ layerView GridLayout
+ popupView GridLayout
+ contentView View
buttons []PopupButton
cancelable bool
dismissListener []func(Popup)
+ showTransform TransformProperty
+ showOpacity float64
+ showDuration float64
+ showTiming string
}
type popupManager struct {
@@ -397,39 +447,15 @@ func (arrow *popupArrow) createView(popupView View) View {
return NewGridLayout(session, params)
}
-func (popup *popupData) init(view View, popupParams Params) {
- popup.view = view
- popup.cancelable = false
- session := view.Session()
+func (popup *popupData) layerCellWidth(arrowLocation int, popupParams Params, session Session) []SizeUnit {
- columnCount := 3
- rowCount := 3
- popupRow := 1
- popupColumn := 1
- arrow := popupArrow{
- row: 1,
- column: 1,
- align: CenterAlign,
- }
-
- switch arrow.location, _ = enumProperty(popupParams, Arrow, session, NoneArrow); arrow.location {
- case TopArrow:
- rowCount = 4
- popupRow = 2
-
- case BottomArrow:
- rowCount = 4
- arrow.row = 2
-
- case LeftArrow:
+ var columnCount int
+ switch arrowLocation {
+ case LeftArrow, RightArrow:
columnCount = 4
- popupColumn = 2
-
- case RightArrow:
- columnCount = 4
- arrow.column = 2
default:
+ columnCount = 3
}
cellWidth := make([]SizeUnit, columnCount)
@@ -444,6 +470,19 @@ func (popup *popupData) init(view View, popupParams Params) {
cellWidth[0] = Fr(1)
cellWidth[columnCount-1] = Fr(1)
}
+ return cellWidth
+}
+
+func (popup *popupData) layerCellHeight(arrowLocation int, popupParams Params, session Session) []SizeUnit {
+
+ var rowCount int
+ switch arrowLocation {
+ case TopArrow, BottomArrow:
+ rowCount = 4
+
+ default:
+ rowCount = 3
+ }
cellHeight := make([]SizeUnit, rowCount)
switch vAlign, _ := enumProperty(popupParams, VerticalAlign, session, CenterAlign); vAlign {
@@ -458,16 +497,47 @@ func (popup *popupData) init(view View, popupParams Params) {
cellHeight[rowCount-1] = Fr(1)
}
+ return cellHeight
+}
+
+func (popup *popupData) init(view View, popupParams Params) {
+ popup.contentView = view
+ popup.cancelable = false
+ session := view.Session()
+
+ popupRow := 1
+ popupColumn := 1
+ arrow := popupArrow{
+ row: 1,
+ column: 1,
+ align: CenterAlign,
+ }
+
+ switch arrow.location, _ = enumProperty(popupParams, Arrow, session, NoneArrow); arrow.location {
+ case TopArrow:
+ popupRow = 2
+
+ case BottomArrow:
+ arrow.row = 2
+
+ case LeftArrow:
+ popupColumn = 2
+
+ case RightArrow:
+ arrow.column = 2
+ }
+
layerParams := Params{
Style: "ruiPopupLayer",
MaxWidth: Percent(100),
MaxHeight: Percent(100),
- CellWidth: cellWidth,
- CellHeight: cellHeight,
+ CellWidth: popup.layerCellWidth(arrow.location, popupParams, session),
+ CellHeight: popup.layerCellHeight(arrow.location, popupParams, session),
}
params := Params{
Style: "ruiPopup",
+ ID: "ruiPopup",
Row: popupRow,
Column: popupColumn,
MaxWidth: Percent(100),
@@ -483,10 +553,14 @@ func (popup *popupData) init(view View, popupParams Params) {
}
var closeButton View = nil
- outsideClose := false
- buttons := []PopupButton{}
- titleStyle := "ruiPopupTitle"
var title View = nil
+ outsideClose := false
+ popup.buttons = []PopupButton{}
+ titleStyle := "ruiPopupTitle"
+
+ popup.showOpacity = 1.0
+ popup.showDuration = 1.0
+ popup.showTiming = "easy"
for tag, value := range popupParams {
if value != nil {
@@ -532,10 +606,10 @@ func (popup *popupData) init(view View, popupParams Params) {
case Buttons:
switch value := value.(type) {
case PopupButton:
- buttons = []PopupButton{value}
+ popup.buttons = []PopupButton{value}
case []PopupButton:
- buttons = value
+ popup.buttons = value
}
case Title:
@@ -587,13 +661,36 @@ func (popup *popupData) init(view View, popupParams Params) {
case ArrowOffset:
arrow.off, _ = sizeProperty(popupParams, ArrowOffset, session)
+ case ShowOpacity:
+ if opacity, _ := floatProperty(popupParams, ShowOpacity, session, 1); opacity >= 0 && opacity < 1 {
+ popup.showOpacity = opacity
+ }
+
+ case ShowTransform:
+ if transform := valueToTransformProperty(value); transform != nil && !transform.empty() {
+ popup.showTransform = transform
+ }
+
+ case ShowDuration:
+ if duration, _ := floatProperty(popupParams, ShowDuration, session, 1); duration > 0 {
+ popup.showDuration = duration
+ }
+
+ case ShowTiming:
+ if text, ok := value.(string); ok {
+ text, _ = session.resolveConstants(text)
+ if isTimingFunctionValid(text) {
+ popup.showTiming = text
+ }
+ }
+
default:
params[tag] = value
}
}
}
- popupView := NewGridLayout(view.Session(), params)
+ popup.popupView = NewGridLayout(view.Session(), params)
var popupCellHeight []SizeUnit
viewRow := 0
@@ -605,7 +702,7 @@ func (popup *popupData) init(view View, popupParams Params) {
if closeButton != nil {
titleContent = append(titleContent, closeButton)
}
- popupView.Append(NewGridLayout(session, Params{
+ popup.popupView.Append(NewGridLayout(session, Params{
Row: 0,
Style: titleStyle,
CellWidth: []any{Fr(1), AutoSize()},
@@ -621,10 +718,9 @@ func (popup *popupData) init(view View, popupParams Params) {
}
view.Set(Row, viewRow)
- popupView.Append(view)
+ popup.popupView.Append(view)
- popup.buttons = buttons
- if buttonCount := len(buttons); buttonCount > 0 {
+ if buttonCount := len(popup.buttons); buttonCount > 0 {
buttonsAlign, _ := enumProperty(params, ButtonsAlign, session, RightAlign)
popupCellHeight = append(popupCellHeight, AutoSize())
gap, _ := sizeConstant(session, "ruiPopupButtonGap")
@@ -641,7 +737,7 @@ func (popup *popupData) init(view View, popupParams Params) {
buttonsPanel.Set(Margin, gap)
}
- for i, button := range buttons {
+ for i, button := range popup.buttons {
title := button.Title
if title == "" && button.Type == CancelButton {
title = "Cancel"
@@ -668,33 +764,82 @@ func (popup *popupData) init(view View, popupParams Params) {
buttonsPanel.Append(buttonView)
}
- popupView.Append(NewGridLayout(session, Params{
+ popup.popupView.Append(NewGridLayout(session, Params{
Row: viewRow + 1,
CellHorizontalAlign: buttonsAlign,
Content: buttonsPanel,
}))
}
- popupView.Set(CellHeight, popupCellHeight)
+ popup.popupView.Set(CellHeight, popupCellHeight)
if arrow.location != NoneArrow {
- layerParams[Content] = []View{popupView, arrow.createView(popupView)}
+ layerParams[Content] = []View{popup.popupView, arrow.createView(popup.popupView)}
} else {
- layerParams[Content] = []View{popupView}
+ layerParams[Content] = []View{popup.popupView}
}
popup.layerView = NewGridLayout(session, layerParams)
+
+ if popup.showOpacity != 1 || popup.showTransform != nil {
+ animation := NewAnimation(Params{
+ Duration: popup.showDuration,
+ TimingFunction: popup.showTiming,
+ })
+ if popup.showOpacity != 1 {
+ popup.popupView.Set(Opacity, popup.showOpacity)
+ popup.popupView.SetTransition(Opacity, animation)
+ }
+ if popup.showTransform != nil {
+ popup.popupView.Set(Transform, popup.showTransform)
+ popup.popupView.SetTransition(Transform, animation)
+ }
+ } else {
+ session.updateCSSProperty("ruiPopupLayer", "transition", "")
+ }
+
if outsideClose {
popup.layerView.Set(ClickEvent, popup.cancel)
}
}
-func (popup popupData) View() View {
- return popup.view
+func (popup *popupData) showAnimation() {
+ if popup.showOpacity != 1 || popup.showTransform != nil {
+ htmlID := popup.popupView.htmlID()
+ session := popup.Session()
+ if popup.showOpacity != 1 {
+ session.updateCSSProperty(htmlID, string(Opacity), "1")
+ }
+ if popup.showTransform != nil {
+ session.updateCSSProperty(htmlID, string(Transform), "")
+ }
+ }
+}
+
+func (popup *popupData) dissmissAnimation(listener func(PropertyName)) bool {
+ if popup.showOpacity != 1 || popup.showTransform != nil {
+ session := popup.Session()
+ popup.popupView.Set(TransitionEndEvent, listener)
+ popup.popupView.Set(TransitionCancelEvent, listener)
+
+ htmlID := popup.popupView.htmlID()
+ if popup.showOpacity != 1 {
+ session.updateCSSProperty(htmlID, string(Opacity), fmt.Sprintf("%.2f", popup.showOpacity))
+ }
+ if popup.showTransform != nil {
+ session.updateCSSProperty(htmlID, string(Transform), popup.showTransform.transformCSS(session))
+ }
+ return true
+ }
+ return false
+}
+
+func (popup *popupData) View() View {
+ return popup.contentView
}
func (popup *popupData) Session() Session {
- return popup.view.Session()
+ return popup.contentView.Session()
}
func (popup *popupData) cancel() {
@@ -709,9 +854,6 @@ func (popup *popupData) cancel() {
func (popup *popupData) Dismiss() {
popup.Session().popupManager().dismissPopup(popup)
- for _, listener := range popup.dismissListener {
- listener(popup)
- }
}
func (popup *popupData) Show() {
@@ -719,7 +861,6 @@ func (popup *popupData) Show() {
}
func (popup *popupData) html(buffer *strings.Builder) {
-
viewHTML(popup.layerView, buffer, "")
}
@@ -728,6 +869,8 @@ func (popup *popupData) viewByHTMLID(id string) View {
}
func (popup *popupData) onDismiss() {
+ popup.Session().callFunc("removeView", popup.layerView.htmlID())
+
for _, listener := range popup.dismissListener {
listener(popup)
}
@@ -808,6 +951,7 @@ func (manager *popupManager) showPopup(popup Popup) {
session.updateCSSProperty("ruiTooltipLayer", "opacity", "0")
session.updateCSSProperty("ruiPopupLayer", "visibility", "visible")
session.updateCSSProperty("ruiRoot", "pointer-events", "none")
+ popup.showAnimation()
}
func (manager *popupManager) dismissPopup(popup Popup) {
@@ -821,31 +965,37 @@ func (manager *popupManager) dismissPopup(popup Popup) {
return
}
- session := popup.Session()
- if manager.popups[count-1] == popup {
- if count == 1 {
- manager.popups = []Popup{}
- session.updateCSSProperty("ruiRoot", "pointer-events", "auto")
- session.updateCSSProperty("ruiPopupLayer", "visibility", "hidden")
- session.updateInnerHTML("ruiPopupLayer", "")
- } else {
- manager.popups = manager.popups[:count-1]
- manager.updatePopupLayerInnerHTML(session)
+ index := -1
+ for n, p := range manager.popups {
+ if p == popup {
+ index = n
+ break
}
- popup.onDismiss()
+ }
+
+ if index < 0 {
return
}
- for n, p := range manager.popups {
- if p == popup {
- if n == 0 {
- manager.popups = manager.popups[1:]
+ session := popup.Session()
+ listener := func(PropertyName) {
+ if index == count-1 {
+ if count == 1 {
+ manager.popups = []Popup{}
+ session.updateCSSProperty("ruiRoot", "pointer-events", "auto")
+ session.updateCSSProperty("ruiPopupLayer", "visibility", "hidden")
} else {
- manager.popups = append(manager.popups[:n], manager.popups[n+1:]...)
+ manager.popups = manager.popups[:count-1]
}
- manager.updatePopupLayerInnerHTML(session)
- popup.onDismiss()
- return
+ } else if index == 0 {
+ manager.popups = manager.popups[1:]
+ } else {
+ manager.popups = append(manager.popups[:index], manager.popups[index+1:]...)
}
+ popup.onDismiss()
+ }
+
+ if !popup.dissmissAnimation(listener) {
+ listener("")
}
}
diff --git a/stackLayout.go b/stackLayout.go
index 1d77b6e..efb49e6 100644
--- a/stackLayout.go
+++ b/stackLayout.go
@@ -534,6 +534,10 @@ func (layout *stackLayoutData) moveToFrontByIndex(index int, onShow []func(View)
layout.views = append(append(layout.views[:index], layout.views[index+1:]...), view)
}
+ if !layout.created {
+ return
+ }
+
session := layout.Session()
pageID := view.htmlID() + "page"
peekPageID := peekID + "page"
@@ -649,23 +653,25 @@ func (layout *stackLayoutData) Append(view View) {
layout.views = append(layout.views, view)
}
- buffer := allocStringBuilder()
- defer freeStringBuilder(buffer)
+ if layout.created {
+ buffer := allocStringBuilder()
+ defer freeStringBuilder(buffer)
- buffer.WriteString(`
`)
- session := layout.Session()
- if count > 0 {
- session.updateCSSProperty(layout.views[count-1].htmlID()+"page", "visibility", "hidden")
- }
- session.appendToInnerHTML(stackID, buffer.String())
+ session := layout.Session()
+ if count > 0 {
+ session.updateCSSProperty(layout.views[count-1].htmlID()+"page", "visibility", "hidden")
+ }
+ session.appendToInnerHTML(stackID, buffer.String())
- if listener, ok := layout.changeListener[Content]; ok {
- listener(layout, Content)
+ if listener, ok := layout.changeListener[Content]; ok {
+ listener(layout, Content)
+ }
}
}
diff --git a/transform.go b/transform.go
index c9a9756..a1c10da 100644
--- a/transform.go
+++ b/transform.go
@@ -712,7 +712,7 @@ func (style *viewStyle) writeViewTransformCSS(builder cssBuilder, session Sessio
}
if transform := getTransformProperty(style, Transform); transform != nil {
- builder.add(`TransformProperty`, transform.transformCSS(session))
+ builder.add(`transform`, transform.transformCSS(session))
}
}
diff --git a/viewsContainer.go b/viewsContainer.go
index 372c13c..0add036 100644
--- a/viewsContainer.go
+++ b/viewsContainer.go
@@ -75,14 +75,16 @@ func (container *viewsContainerData) Append(view View) {
container.views = append(container.views, view)
}
- buffer := allocStringBuilder()
- defer freeStringBuilder(buffer)
+ if container.created {
+ buffer := allocStringBuilder()
+ defer freeStringBuilder(buffer)
- viewHTML(view, buffer, "")
- container.Session().appendToInnerHTML(htmlID, buffer.String())
+ viewHTML(view, buffer, "")
+ container.Session().appendToInnerHTML(htmlID, buffer.String())
- if listener, ok := container.changeListener[Content]; ok {
- listener(container, Content)
+ if listener, ok := container.changeListener[Content]; ok {
+ listener(container, Content)
+ }
}
}
}
@@ -102,9 +104,12 @@ func (container *viewsContainerData) Insert(view View, index int) {
} else {
container.views = append([]View{view}, container.views...)
}
- updateInnerHTML(htmlID, container.Session())
- if listener, ok := container.changeListener[Content]; ok {
- listener(container, Content)
+
+ if container.created {
+ updateInnerHTML(htmlID, container.Session())
+ if listener, ok := container.changeListener[Content]; ok {
+ listener(container, Content)
+ }
}
}
}
@@ -132,9 +137,11 @@ func (container *viewsContainerData) RemoveView(index int) View {
view.setParentID("")
- container.Session().callFunc("removeView", view.htmlID())
- if listener, ok := container.changeListener[Content]; ok {
- listener(container, Content)
+ if container.created {
+ container.Session().callFunc("removeView", view.htmlID())
+ if listener, ok := container.changeListener[Content]; ok {
+ listener(container, Content)
+ }
}
return view
}
From e9937a8f3a52d977aa49be5b25419c7e774d3671 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Tue, 26 Nov 2024 11:56:52 +0200
Subject: [PATCH 16/43] Update popup.go
---
popup.go | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/popup.go b/popup.go
index 8cc0148..2536370 100644
--- a/popup.go
+++ b/popup.go
@@ -171,7 +171,7 @@ const (
// ShowTiming is the constant for "show-timing" property tag.
//
- // Used by `StackLayout`.
+ // Used by `Popup`.
// Set how a Popup show/hide animation progresses through the duration of each cycle.
//
// Supported types: `string`.
@@ -184,6 +184,15 @@ const (
// "linear"(`LinearTiming`) - Constant speed.
ShowTiming = "show-timing"
+ // ShowOpacity is the constant for "show-opacity" property tag.
+ //
+ // Used by `Popup`.
+ // In [1..0] range sets the start opacity of Popup show animation (the finish animation opacity is 1).
+ // Opacity is the degree to which content behind the view is hidden, and is the opposite of transparency.
+ //
+ // Supported types: `float`, `int`, `string`.
+ //
+ // Internal type is `float`, other types converted to it during assignment.
ShowOpacity = "show-opacity"
// ArrowOffset is the constant for "arrow-offset" property tag.
From 87735b3a4d4efaf243002e206fb2f707e38bbecf Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Tue, 26 Nov 2024 12:11:39 +0200
Subject: [PATCH 17/43] Update CHANGELOG.md
---
CHANGELOG.md | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 979568a..3294818 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,9 +6,10 @@
* GetOrigin function renamed to GetTransformOrigin.
* Changed Push and Pop method of StackLayout interface.
* Removed DefaultAnimation, StartToEndAnimation, EndToStartAnimation, TopDownAnimation, and BottomUpAnimation constants.
-* Added "push-transform", "push-duration", "push-timing", and "move-to-front-animation" properties.
+* Added "push-transform", "push-duration", "push-timing", and "move-to-front-animation" StackLayout properties.
* Added "push-perspective", "push-rotate-x", "push-rotate-y", "push-rotate-z", "push-rotate", "push-skew-x", "push-skew-y",
-"push-scale-x", "push-scale-y", "push-scale-z", "push-translate-x", "push-translate-y", "push-translate-z" properties.
+"push-scale-x", "push-scale-y", "push-scale-z", "push-translate-x", "push-translate-y", "push-translate-z" StackLayout properties.
+* Added "show-opacity", "show-transform", "show-duration", and "show-timing" Popup properties.
* Added GetPushTransform, GetPushDuration, GetPushTiming, and IsMoveToFrontAnimation functions.
* Added LineJoin type. Type of constants MiterJoin, RoundJoin, and BevelJoin changed to LineJoin. Type of Canvas.SetLineJoin function argument changed to LineJoin.
* Added LineCap type. Type of constants ButtCap, RoundCap, and SquareCap changed to LineCap. Type of Canvas.SetLineCap function argument changed to LineCap.
From a5577273e6a2bb7420ae04ee86f091efc19a9fa2 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Tue, 26 Nov 2024 12:15:06 +0200
Subject: [PATCH 18/43] Update CHANGELOG.md
---
CHANGELOG.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3294818..99328b8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,9 +2,9 @@
* Property name type changed from string to PropertyName.
* Transform interface renamed to TransformProperty. NewTransform function renamed to NewTransformProperty. TransformTag constant renamed to Transform.
-* OriginX, OriginY, and OriginZ properties renamed to TransformOriginX, TransformOriginY, and TransformOriginZ
+* "origin-x", "origin-y", and "origin-z" properties renamed to "transform-origin-x", "transform-origin-y", and "transform-origin-z".
* GetOrigin function renamed to GetTransformOrigin.
-* Changed Push and Pop method of StackLayout interface.
+* Changed Push, Pop, MoveToFront, and MoveToFrontByID methods of StackLayout interface.
* Removed DefaultAnimation, StartToEndAnimation, EndToStartAnimation, TopDownAnimation, and BottomUpAnimation constants.
* Added "push-transform", "push-duration", "push-timing", and "move-to-front-animation" StackLayout properties.
* Added "push-perspective", "push-rotate-x", "push-rotate-y", "push-rotate-z", "push-rotate", "push-skew-x", "push-skew-y",
From 27beb1e679b8b8bd76b46b1247367494cd63db44 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Wed, 27 Nov 2024 10:32:13 +0200
Subject: [PATCH 19/43] Added "mask" property
---
CHANGELOG.md | 3 +
background.go | 221 +++++++++++++++++++++++++++++++++++-------
backgroundGradient.go | 13 ++-
propertyNames.go | 54 +++++++++++
propertySet.go | 21 +++-
view.go | 3 +
viewStyle.go | 44 +++------
viewStyleSet.go | 4 +-
8 files changed, 289 insertions(+), 74 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 99328b8..b8c6d5a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,9 @@
"push-scale-x", "push-scale-y", "push-scale-z", "push-translate-x", "push-translate-y", "push-translate-z" StackLayout properties.
* Added "show-opacity", "show-transform", "show-duration", and "show-timing" Popup properties.
* Added GetPushTransform, GetPushDuration, GetPushTiming, and IsMoveToFrontAnimation functions.
+* Added "mask", "mask-clip", "mask-origin", and "background-origin" properties.
+* Added GetBackground, GetMask, GetBackgroundClip,GetBackgroundOrigin, GetMaskClip, and GetMaskOrigin functions.
+* Renamed BorderBoxClip, PaddingBoxClip, and ContentBoxClip constants to BorderBox, PaddingBox, and ContentBox.
* Added LineJoin type. Type of constants MiterJoin, RoundJoin, and BevelJoin changed to LineJoin. Type of Canvas.SetLineJoin function argument changed to LineJoin.
* Added LineCap type. Type of constants ButtCap, RoundCap, and SquareCap changed to LineCap. Type of Canvas.SetLineCap function argument changed to LineCap.
diff --git a/background.go b/background.go
index db18cfb..44a99da 100644
--- a/background.go
+++ b/background.go
@@ -12,25 +12,30 @@ const (
// will not necessarily be entirely covered). The position of the non-repeated
// background image is defined by the background-position CSS property.
NoRepeat = 0
+
// RepeatXY is value of the Repeat property of an background image:
// The image is repeated as much as needed to cover the whole background
// image painting area. The last image will be clipped if it doesn't fit.
RepeatXY = 1
+
// RepeatX is value of the Repeat property of an background image:
// The image is repeated horizontally as much as needed to cover
// the whole width background image painting area. The image is not repeated vertically.
// The last image will be clipped if it doesn't fit.
RepeatX = 2
+
// RepeatY is value of the Repeat property of an background image:
// The image is repeated vertically as much as needed to cover
// the whole height background image painting area. The image is not repeated horizontally.
// The last image will be clipped if it doesn't fit.
RepeatY = 3
+
// RepeatRound is value of the Repeat property of an background image:
// As the allowed space increases in size, the repeated images will stretch (leaving no gaps)
// until there is room (space left >= half of the image width) for another one to be added.
// When the next image is added, all of the current ones compress to allow room.
RepeatRound = 4
+
// RepeatSpace is value of the Repeat property of an background image:
// The image is repeated as much as possible without clipping. The first and last images
// are pinned to either side of the element, and whitespace is distributed evenly between the images.
@@ -40,10 +45,12 @@ const (
// The background is fixed relative to the element itself and does not scroll with its contents.
// (It is effectively attached to the element's border.)
ScrollAttachment = 0
+
// FixedAttachment is value of the Attachment property of an background image:
// The background is fixed relative to the viewport. Even if an element has
// a scrolling mechanism, the background doesn't move with the element.
FixedAttachment = 1
+
// LocalAttachment is value of the Attachment property of an background image:
// The background is fixed relative to the element's contents. If the element has a scrolling mechanism,
// the background scrolls with the element's contents, and the background painting area
@@ -51,15 +58,38 @@ const (
// rather than to the border framing them.
LocalAttachment = 2
- // BorderBoxClip is value of the BackgroundClip property:
- // The background extends to the outside edge of the border (but underneath the border in z-ordering).
- BorderBoxClip = 0
- // PaddingBoxClip is value of the BackgroundClip property:
- // The background extends to the outside edge of the padding. No background is drawn beneath the border.
- PaddingBoxClip = 1
- // ContentBoxClip is value of the BackgroundClip property:
- // The background is painted within (clipped to) the content box.
- ContentBoxClip = 2
+ // BorderBox is the value of the following properties:
+ //
+ // * BackgroundClip - The background extends to the outside edge of the border (but underneath the border in z-ordering).
+ //
+ // * BackgroundOrigin - The background is positioned relative to the border box.
+ //
+ // * MaskClip - The painted content is clipped to the border box.
+ //
+ // * MaskOrigin - The mask is positioned relative to the border box.
+ BorderBox = 0
+
+ // PaddingBox is value of the BackgroundClip and MaskClip property:
+ //
+ // * BackgroundClip - The background extends to the outside edge of the padding. No background is drawn beneath the border.
+ //
+ // * BackgroundOrigin - The background is positioned relative to the padding box.
+ //
+ // * MaskClip - The painted content is clipped to the padding box.
+ //
+ // * MaskOrigin - The mask is positioned relative to the padding box.
+ PaddingBox = 1
+
+ // ContentBox is value of the BackgroundClip and MaskClip property:
+ //
+ // * BackgroundClip - The background is painted within (clipped to) the content box.
+ //
+ // * BackgroundOrigin - The background is positioned relative to the content box.
+ //
+ // * MaskClip - The painted content is clipped to the content box.
+ //
+ // * MaskOrigin - The mask is positioned relative to the content box.
+ ContentBox = 2
)
// BackgroundElement describes the background element
@@ -253,75 +283,198 @@ func (image *backgroundImage) String() string {
return runStringWriter(image)
}
-func setBackgroundProperty(properties Properties, value any) []PropertyName {
- background := []BackgroundElement{}
-
- error := func() []PropertyName {
- notCompatibleType(Background, value)
- return nil
- }
+func parseBackgroundValue(value any) []BackgroundElement {
switch value := value.(type) {
case BackgroundElement:
- background = []BackgroundElement{value}
+ return []BackgroundElement{value}
case []BackgroundElement:
- background = value
+ return value
case []DataValue:
+ background := []BackgroundElement{}
for _, el := range value {
if el.IsObject() {
if element := createBackground(el.Object()); element != nil {
background = append(background, element)
} else {
- return error()
+ return nil
}
} else if obj := ParseDataText(el.Value()); obj != nil {
if element := createBackground(obj); element != nil {
background = append(background, element)
} else {
- return error()
+ return nil
}
} else {
- return error()
+ return nil
}
}
+ return background
case DataObject:
if element := createBackground(value); element != nil {
- background = []BackgroundElement{element}
- } else {
- return error()
+ return []BackgroundElement{element}
}
case []DataObject:
+ background := []BackgroundElement{}
for _, obj := range value {
if element := createBackground(obj); element != nil {
background = append(background, element)
} else {
- return error()
+ return nil
}
}
+ return background
case string:
if obj := ParseDataText(value); obj != nil {
if element := createBackground(obj); element != nil {
- background = []BackgroundElement{element}
- } else {
- return error()
+ return []BackgroundElement{element}
}
- } else {
- return error()
}
}
+ return nil
+}
+
+func setBackgroundProperty(properties Properties, tag PropertyName, value any) []PropertyName {
+
+ background := parseBackgroundValue(value)
+ if background == nil {
+ notCompatibleType(tag, value)
+ return nil
+ }
+
if len(background) > 0 {
- properties.setRaw(Background, background)
- } else if properties.getRaw(Background) != nil {
- properties.setRaw(Background, nil)
+ properties.setRaw(tag, background)
+ } else if properties.getRaw(tag) != nil {
+ properties.setRaw(tag, nil)
} else {
return []PropertyName{}
}
- return []PropertyName{Background}
+ return []PropertyName{tag}
+}
+
+func backgroundCSS(properties Properties, session Session) string {
+
+ if value := properties.getRaw(Background); value != nil {
+ if backgrounds, ok := value.([]BackgroundElement); ok && len(backgrounds) > 0 {
+ buffer := allocStringBuilder()
+ defer freeStringBuilder(buffer)
+
+ for _, background := range backgrounds {
+ if value := background.cssStyle(session); value != "" {
+ if buffer.Len() > 0 {
+ buffer.WriteString(", ")
+ }
+ buffer.WriteString(value)
+ }
+ }
+
+ if buffer.Len() > 0 {
+ backgroundColor, _ := colorProperty(properties, BackgroundColor, session)
+ if backgroundColor != 0 {
+ buffer.WriteRune(' ')
+ buffer.WriteString(backgroundColor.cssString())
+ }
+ return buffer.String()
+ }
+ }
+ }
+ return ""
+}
+
+func maskCSS(properties Properties, session Session) string {
+
+ if value := properties.getRaw(Mask); value != nil {
+ if backgrounds, ok := value.([]BackgroundElement); ok && len(backgrounds) > 0 {
+ buffer := allocStringBuilder()
+ defer freeStringBuilder(buffer)
+
+ for _, background := range backgrounds {
+ if value := background.cssStyle(session); value != "" {
+ if buffer.Len() > 0 {
+ buffer.WriteString(", ")
+ }
+ buffer.WriteString(value)
+ }
+ }
+ return buffer.String()
+ }
+ }
+ return ""
+}
+
+func backgroundStyledPropery(view View, subviewID []string, tag PropertyName) []BackgroundElement {
+ var background []BackgroundElement = nil
+
+ if view = getSubview(view, subviewID); view != nil {
+ if value := view.getRaw(tag); value != nil {
+ if backgrounds, ok := value.([]BackgroundElement); ok {
+ background = backgrounds
+ }
+ } else if value := valueFromStyle(view, tag); value != nil {
+ background = parseBackgroundValue(value)
+ }
+ }
+
+ if count := len(background); count > 0 {
+ result := make([]BackgroundElement, count)
+ copy(result, background)
+ return result
+ }
+
+ return []BackgroundElement{}
+}
+
+// GetBackground returns the view background.
+// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
+func GetBackground(view View, subviewID ...string) []BackgroundElement {
+ return backgroundStyledPropery(view, subviewID, Background)
+}
+
+// GetMask returns the view mask.
+// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
+func GetMask(view View, subviewID ...string) []BackgroundElement {
+ return backgroundStyledPropery(view, subviewID, Mask)
+}
+
+// GetBackgroundClip returns a "background-clip" of the subview. Returns one of next values:
+//
+// BorderBox (0), PaddingBox (1), ContentBox (2)
+//
+// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
+func GetBackgroundClip(view View, subviewID ...string) int {
+ return enumStyledProperty(view, subviewID, BackgroundClip, 0, false)
+}
+
+// GetBackgroundOrigin returns a "background-origin" of the subview. Returns one of next values:
+//
+// BorderBox (0), PaddingBox (1), ContentBox (2)
+//
+// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
+func GetBackgroundOrigin(view View, subviewID ...string) int {
+ return enumStyledProperty(view, subviewID, BackgroundOrigin, 0, false)
+}
+
+// GetMaskClip returns a "mask-clip" of the subview. Returns one of next values:
+//
+// BorderBox (0), PaddingBox (1), ContentBox (2)
+//
+// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
+func GetMaskClip(view View, subviewID ...string) int {
+ return enumStyledProperty(view, subviewID, MaskClip, 0, false)
+}
+
+// GetMaskOrigin returns a "mask-origin" of the subview. Returns one of next values:
+//
+// BorderBox (0), PaddingBox (1), ContentBox (2)
+//
+// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
+func GetMaskOrigin(view View, subviewID ...string) int {
+ return enumStyledProperty(view, subviewID, MaskOrigin, 0, false)
}
diff --git a/backgroundGradient.go b/backgroundGradient.go
index e672271..0089020 100644
--- a/backgroundGradient.go
+++ b/backgroundGradient.go
@@ -220,6 +220,11 @@ func (point *BackgroundGradientPoint) color(session Session) (Color, bool) {
case Color:
return color, true
+
+ default:
+ if n, ok := isInt(point.Color); ok {
+ return Color(n), true
+ }
}
}
return 0, false
@@ -315,7 +320,7 @@ func (gradient *backgroundGradient) writeGradient(session Session, buffer *strin
func (gradient *backgroundLinearGradient) init() {
gradient.backgroundElement.init()
gradient.set = backgroundLinearGradientSet
- gradient.supportedProperties = append(gradient.supportedProperties, Direction)
+ gradient.supportedProperties = []PropertyName{Direction, Repeating, Gradient}
}
@@ -422,9 +427,9 @@ func (gradient *backgroundRadialGradient) init() {
gradient.backgroundElement.init()
gradient.normalize = normalizeRadialGradientTag
gradient.set = backgroundRadialGradientSet
- gradient.supportedProperties = append(gradient.supportedProperties, []PropertyName{
- RadialGradientRadius, RadialGradientShape, CenterX, CenterY,
- }...)
+ gradient.supportedProperties = []PropertyName{
+ RadialGradientRadius, RadialGradientShape, CenterX, CenterY, Gradient, Repeating,
+ }
}
func (gradient *backgroundRadialGradient) Tag() string {
diff --git a/propertyNames.go b/propertyNames.go
index e825ebf..18dd429 100644
--- a/propertyNames.go
+++ b/propertyNames.go
@@ -594,6 +594,21 @@ const (
// `string` - must contain text representation of background element(s) like in resource files.
Background PropertyName = "background"
+ // Mask is the constant for "mask" property tag.
+ //
+ // Used by `View`.
+ // Set one or more images and/or gradients as the view mask.
+ // As mask is used only alpha channel of images and/or gradients.
+ //
+ // Supported types: `BackgroundElement`, `[]BackgroundElement`, `string`.
+ //
+ // Internal type is `[]BackgroundElement`, other types converted to it during assignment.
+ // See `BackgroundElement` description for more details.
+ //
+ // Conversion rules:
+ // `string` - must contain text representation of background element(s) like in resource files.
+ Mask PropertyName = "mask"
+
// Cursor is the constant for "cursor" property tag.
//
// Used by `View`.
@@ -1825,6 +1840,45 @@ const (
// `2`(`ContentBoxClip`) or "content-box" - The background is painted inside(clipped) of the content box.
BackgroundClip PropertyName = "background-clip"
+ // BackgroundOrigin is the constant for "background-origin" property tag.
+ //
+ // Used by `View`.
+ // Determines the background's origin: from the border start, inside the border, or inside the padding.
+ //
+ // Supported types: `int`, `string`.
+ //
+ // Values:
+ // `0`(`BorderBox`) or "border-box" - The background is positioned relative to the border box.
+ // `1`(`PaddingBox`) or "padding-box" - The background is positioned relative to the padding box.
+ // `2`(`ContentBox`) or "content-box" - The background is positioned relative to the content box.
+ BackgroundOrigin PropertyName = "background-origin"
+
+ // MaskClip is the constant for "mask-clip" property tag.
+ //
+ // Used by `View`.
+ // Determines how image/gradient masks will be used below the box borders.
+ //
+ // Supported types: `int`, `string`.
+ //
+ // Values:
+ // `0`(`BorderBox`) or "border-box" - The mask extends to the outer edge of the border.
+ // `1`(`PaddingBox`) or "padding-box" - The mask extends to the outer edge of the padding.
+ // `2`(`ContentBox`) or "content-box" - The mask is used inside(clipped) of the content box.
+ MaskClip PropertyName = "mask-clip"
+
+ // MaskOrigin is the constant for "mask-origin" property tag.
+ //
+ // Used by `View`.
+ // Determines the mask's origin: from the border start, inside the border, or inside the padding.
+ //
+ // Supported types: `int`, `string`.
+ //
+ // Values:
+ // `0`(`BorderBox`) or "border-box" - The mask is positioned relative to the border box.
+ // `1`(`PaddingBox`) or "padding-box" - The mask is positioned relative to the padding box.
+ // `2`(`ContentBox`) or "content-box" - The mask is positioned relative to the content box.
+ MaskOrigin PropertyName = "mask-origin"
+
// Gradient is the constant for "gradient" property tag.
//
// Used by `BackgroundElement`.
diff --git a/propertySet.go b/propertySet.go
index 028de6f..41d43b3 100644
--- a/propertySet.go
+++ b/propertySet.go
@@ -164,11 +164,13 @@ var sizeProperties = map[PropertyName]string{
CenterY: string(CenterX),
}
-var enumProperties = map[PropertyName]struct {
+type enumPropertyData struct {
values []string
cssTag string
cssValues []string
-}{
+}
+
+var enumProperties = map[PropertyName]enumPropertyData{
Semantics: {
[]string{"default", "article", "section", "aside", "header", "main", "footer", "navigation", "figure", "figure-caption", "button", "p", "h1", "h2", "h3", "h4", "h5", "h6", "blockquote", "code"},
"",
@@ -409,6 +411,21 @@ var enumProperties = map[PropertyName]struct {
"background-clip",
[]string{"border-box", "padding-box", "content-box"}, // "text"},
},
+ BackgroundOrigin: {
+ []string{"border-box", "padding-box", "content-box"},
+ "background-origin",
+ []string{"border-box", "padding-box", "content-box"},
+ },
+ MaskClip: {
+ []string{"border-box", "padding-box", "content-box"},
+ "mask-clip",
+ []string{"border-box", "padding-box", "content-box"},
+ },
+ MaskOrigin: {
+ []string{"border-box", "padding-box", "content-box"},
+ "background-origin",
+ []string{"border-box", "padding-box", "content-box"},
+ },
Direction: {
[]string{"to-top", "to-right-top", "to-right", "to-right-bottom", "to-bottom", "to-left-bottom", "to-left", "to-left-top"},
"",
diff --git a/view.go b/view.go
index c999658..1131d7b 100644
--- a/view.go
+++ b/view.go
@@ -491,6 +491,9 @@ func (view *viewData) propertyChanged(tag PropertyName) {
case Background:
session.updateCSSProperty(htmlID, string(Background), backgroundCSS(view, session))
+ case Mask:
+ session.updateCSSProperty(htmlID, "mask", maskCSS(view, session))
+
case Border, BorderLeft, BorderRight, BorderTop, BorderBottom:
cssWidth := ""
cssColor := ""
diff --git a/viewStyle.go b/viewStyle.go
index 0976958..5462d2c 100644
--- a/viewStyle.go
+++ b/viewStyle.go
@@ -108,35 +108,6 @@ func split4Values(text string) []string {
return []string{}
}
-func backgroundCSS(properties Properties, session Session) string {
-
- if value := properties.getRaw(Background); value != nil {
- if backgrounds, ok := value.([]BackgroundElement); ok && len(backgrounds) > 0 {
- buffer := allocStringBuilder()
- defer freeStringBuilder(buffer)
-
- for _, background := range backgrounds {
- if value := background.cssStyle(session); value != "" {
- if buffer.Len() > 0 {
- buffer.WriteString(", ")
- }
- buffer.WriteString(value)
- }
- }
-
- if buffer.Len() > 0 {
- backgroundColor, _ := colorProperty(properties, BackgroundColor, session)
- if backgroundColor != 0 {
- buffer.WriteRune(' ')
- buffer.WriteString(backgroundColor.cssString())
- }
- return buffer.String()
- }
- }
- }
- return ""
-}
-
func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) {
if visibility, ok := enumProperty(style, Visibility, session, Visible); ok {
@@ -217,8 +188,12 @@ func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) {
}
}
- if value, ok := enumProperty(style, BackgroundClip, session, 0); ok {
- builder.add(string(BackgroundClip), enumProperties[BackgroundClip].values[value])
+ for _, tag := range []PropertyName{BackgroundClip, BackgroundOrigin, MaskClip, MaskOrigin} {
+ if value, ok := enumProperty(style, tag, session, 0); ok {
+ if data, ok := enumProperties[tag]; ok {
+ builder.add(data.cssTag, data.values[value])
+ }
+ }
}
if background := backgroundCSS(style, session); background != "" {
@@ -230,6 +205,10 @@ func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) {
}
}
+ if mask := maskCSS(style, session); mask != "" {
+ builder.add("mask", mask)
+ }
+
if font, ok := stringProperty(style, FontName, session); ok && font != "" {
builder.add(`font-family`, font)
}
@@ -870,7 +849,8 @@ func writeViewStyle(name string, view Properties, buffer *strings.Builder, inden
tagOrder := []PropertyName{
ID, Row, Column, Top, Right, Bottom, Left, Semantics, Cursor, Visibility,
Opacity, ZIndex, Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight,
- Margin, Padding, BackgroundClip, BackgroundColor, Background, Border, Radius, Outline, Shadow,
+ Margin, Padding, BackgroundColor, Background, BackgroundClip, BackgroundOrigin,
+ Mask, MaskClip, MaskOrigin, Border, Radius, Outline, Shadow,
Orientation, ListWrap, VerticalAlign, HorizontalAlign, CellWidth, CellHeight,
CellVerticalAlign, CellHorizontalAlign, ListRowGap, ListColumnGap, GridRowGap, GridColumnGap,
ColumnCount, ColumnWidth, ColumnSeparator, ColumnGap, AvoidBreak,
diff --git a/viewStyleSet.go b/viewStyleSet.go
index 942951d..0139e87 100644
--- a/viewStyleSet.go
+++ b/viewStyleSet.go
@@ -210,8 +210,8 @@ func viewStyleSet(style Properties, tag PropertyName, value any) []PropertyName
return []PropertyName{tag}
}
- case Background:
- return setBackgroundProperty(style, value)
+ case Background, Mask:
+ return setBackgroundProperty(style, tag, value)
case Border, CellBorder:
if border := newBorderProperty(value); border != nil {
From 7ce631b6ce45146dff18766e337bf2819c372de9 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Wed, 27 Nov 2024 16:06:12 +0200
Subject: [PATCH 20/43] Bug fixing
---
backgroundGradient.go | 2 ++
1 file changed, 2 insertions(+)
diff --git a/backgroundGradient.go b/backgroundGradient.go
index 0089020..1a5355f 100644
--- a/backgroundGradient.go
+++ b/backgroundGradient.go
@@ -653,6 +653,8 @@ func (gradient *backgroundRadialGradient) cssStyle(session Session) string {
buffer.WriteString(x.cssString("50%", session))
buffer.WriteString(" ")
buffer.WriteString(y.cssString("50%", session))
+ } else if shapeText != "" {
+ buffer.WriteString(shapeText)
}
buffer.WriteString(", ")
From f632104d49f512da72275e514197faa21c850360 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Wed, 27 Nov 2024 16:28:11 +0200
Subject: [PATCH 21/43] Update backgroundConicGradient.go
---
backgroundConicGradient.go | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/backgroundConicGradient.go b/backgroundConicGradient.go
index 05444a4..c441fe9 100644
--- a/backgroundConicGradient.go
+++ b/backgroundConicGradient.go
@@ -72,6 +72,11 @@ func (point *BackgroundGradientAngle) color(session Session) (Color, bool) {
case Color:
return color, true
+
+ default:
+ if n, ok := isInt(color); ok {
+ return Color(n), true
+ }
}
}
return 0, false
From bed6c1bf41021af9274341137126173c8f7ee4dd Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Sun, 1 Dec 2024 12:30:33 +0300
Subject: [PATCH 22/43] Optimisation
---
viewUtils.go | 19 +++----------------
1 file changed, 3 insertions(+), 16 deletions(-)
diff --git a/viewUtils.go b/viewUtils.go
index f1ea069..4bf5242 100644
--- a/viewUtils.go
+++ b/viewUtils.go
@@ -71,27 +71,14 @@ func SetParams(rootView View, viewID string, params Params) bool {
}
func getSubview(view View, subviewID []string) View {
- switch len(subviewID) {
- case 0:
- // do nothing
-
- case 1:
- if subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
-
- default:
- buffer := allocStringBuilder()
- defer freeStringBuilder(buffer)
+ if view != nil {
for _, id := range subviewID {
if id != "" {
- if buffer.Len() > 0 {
- buffer.WriteRune('/')
+ if view = ViewByID(view, id); view == nil {
+ return nil
}
- buffer.WriteString(id)
}
}
- view = ViewByID(view, buffer.String())
}
return view
From f81ffe6bed2379125403554d321078a803521ed4 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Sun, 1 Dec 2024 12:42:38 +0300
Subject: [PATCH 23/43] Refactoring
---
background.go | 192 -----------
backgroundImage.go | 198 +++++++++++
...Gradient.go => backgroundLinearGradient.go | 304 +----------------
backgroundRadialGradient.go | 307 ++++++++++++++++++
4 files changed, 512 insertions(+), 489 deletions(-)
create mode 100644 backgroundImage.go
rename backgroundGradient.go => backgroundLinearGradient.go (53%)
create mode 100644 backgroundRadialGradient.go
diff --git a/background.go b/background.go
index 44a99da..68e6b8f 100644
--- a/background.go
+++ b/background.go
@@ -2,62 +2,9 @@ package rui
import (
"fmt"
- "strings"
)
-// Constants related to view's background description
const (
- // NoRepeat is value of the Repeat property of an background image:
- // The image is not repeated (and hence the background image painting area
- // will not necessarily be entirely covered). The position of the non-repeated
- // background image is defined by the background-position CSS property.
- NoRepeat = 0
-
- // RepeatXY is value of the Repeat property of an background image:
- // The image is repeated as much as needed to cover the whole background
- // image painting area. The last image will be clipped if it doesn't fit.
- RepeatXY = 1
-
- // RepeatX is value of the Repeat property of an background image:
- // The image is repeated horizontally as much as needed to cover
- // the whole width background image painting area. The image is not repeated vertically.
- // The last image will be clipped if it doesn't fit.
- RepeatX = 2
-
- // RepeatY is value of the Repeat property of an background image:
- // The image is repeated vertically as much as needed to cover
- // the whole height background image painting area. The image is not repeated horizontally.
- // The last image will be clipped if it doesn't fit.
- RepeatY = 3
-
- // RepeatRound is value of the Repeat property of an background image:
- // As the allowed space increases in size, the repeated images will stretch (leaving no gaps)
- // until there is room (space left >= half of the image width) for another one to be added.
- // When the next image is added, all of the current ones compress to allow room.
- RepeatRound = 4
-
- // RepeatSpace is value of the Repeat property of an background image:
- // The image is repeated as much as possible without clipping. The first and last images
- // are pinned to either side of the element, and whitespace is distributed evenly between the images.
- RepeatSpace = 5
-
- // ScrollAttachment is value of the Attachment property of an background image:
- // The background is fixed relative to the element itself and does not scroll with its contents.
- // (It is effectively attached to the element's border.)
- ScrollAttachment = 0
-
- // FixedAttachment is value of the Attachment property of an background image:
- // The background is fixed relative to the viewport. Even if an element has
- // a scrolling mechanism, the background doesn't move with the element.
- FixedAttachment = 1
-
- // LocalAttachment is value of the Attachment property of an background image:
- // The background is fixed relative to the element's contents. If the element has a scrolling mechanism,
- // the background scrolls with the element's contents, and the background painting area
- // and background positioning area are relative to the scrollable area of the element
- // rather than to the border framing them.
- LocalAttachment = 2
-
// BorderBox is the value of the following properties:
//
// * BackgroundClip - The background extends to the outside edge of the border (but underneath the border in z-ordering).
@@ -111,10 +58,6 @@ type backgroundElement struct {
dataProperty
}
-type backgroundImage struct {
- backgroundElement
-}
-
// NewBackgroundImage creates the new background image
func createBackground(obj DataObject) BackgroundElement {
var result BackgroundElement = nil
@@ -148,141 +91,6 @@ func createBackground(obj DataObject) BackgroundElement {
return result
}
-// NewBackgroundImage creates the new background image
-func NewBackgroundImage(params Params) BackgroundElement {
- result := new(backgroundImage)
- result.init()
- for tag, value := range params {
- result.Set(tag, value)
- }
- return result
-}
-
-func (image *backgroundImage) init() {
- image.backgroundElement.init()
- image.normalize = normalizeBackgroundImageTag
- image.supportedProperties = []PropertyName{
- Attachment, Width, Height, Repeat, ImageHorizontalAlign, ImageVerticalAlign, backgroundFit, Source,
- }
-}
-
-func (image *backgroundImage) Tag() string {
- return "image"
-}
-
-func (image *backgroundImage) Clone() BackgroundElement {
- result := NewBackgroundImage(nil)
- for tag, value := range image.properties {
- result.setRaw(tag, value)
- }
- return result
-}
-
-func normalizeBackgroundImageTag(tag PropertyName) PropertyName {
- tag = defaultNormalize(tag)
- switch tag {
- case "source":
- tag = Source
-
- case Fit:
- tag = backgroundFit
-
- case HorizontalAlign:
- tag = ImageHorizontalAlign
-
- case VerticalAlign:
- tag = ImageVerticalAlign
- }
-
- return tag
-}
-
-func (image *backgroundImage) cssStyle(session Session) string {
- if src, ok := imageProperty(image, Source, session); ok && src != "" {
- buffer := allocStringBuilder()
- defer freeStringBuilder(buffer)
-
- buffer.WriteString(`url(`)
- buffer.WriteString(src)
- buffer.WriteRune(')')
-
- attachment, _ := enumProperty(image, Attachment, session, NoRepeat)
- values := enumProperties[Attachment].values
- if attachment > 0 && attachment < len(values) {
- buffer.WriteRune(' ')
- buffer.WriteString(values[attachment])
- }
-
- align, _ := enumProperty(image, ImageHorizontalAlign, session, LeftAlign)
- values = enumProperties[ImageHorizontalAlign].values
- if align >= 0 && align < len(values) {
- buffer.WriteRune(' ')
- buffer.WriteString(values[align])
- } else {
- buffer.WriteString(` left`)
- }
-
- align, _ = enumProperty(image, ImageVerticalAlign, session, TopAlign)
- values = enumProperties[ImageVerticalAlign].values
- if align >= 0 && align < len(values) {
- buffer.WriteRune(' ')
- buffer.WriteString(values[align])
- } else {
- buffer.WriteString(` top`)
- }
-
- fit, _ := enumProperty(image, backgroundFit, session, NoneFit)
- values = enumProperties[backgroundFit].values
- if fit > 0 && fit < len(values) {
-
- buffer.WriteString(` / `)
- buffer.WriteString(values[fit])
-
- } else {
-
- width, _ := sizeProperty(image, Width, session)
- height, _ := sizeProperty(image, Height, session)
-
- if width.Type != Auto || height.Type != Auto {
- buffer.WriteString(` / `)
- buffer.WriteString(width.cssString("auto", session))
- buffer.WriteRune(' ')
- buffer.WriteString(height.cssString("auto", session))
- }
- }
-
- repeat, _ := enumProperty(image, Repeat, session, NoRepeat)
- values = enumProperties[Repeat].values
- if repeat >= 0 && repeat < len(values) {
- buffer.WriteRune(' ')
- buffer.WriteString(values[repeat])
- } else {
- buffer.WriteString(` no-repeat`)
- }
-
- return buffer.String()
- }
-
- return ""
-}
-
-func (image *backgroundImage) writeString(buffer *strings.Builder, indent string) {
- image.writeToBuffer(buffer, indent, image.Tag(), []PropertyName{
- Source,
- Width,
- Height,
- ImageHorizontalAlign,
- ImageVerticalAlign,
- backgroundFit,
- Repeat,
- Attachment,
- })
-}
-
-func (image *backgroundImage) String() string {
- return runStringWriter(image)
-}
-
func parseBackgroundValue(value any) []BackgroundElement {
switch value := value.(type) {
diff --git a/backgroundImage.go b/backgroundImage.go
new file mode 100644
index 0000000..aac13fb
--- /dev/null
+++ b/backgroundImage.go
@@ -0,0 +1,198 @@
+package rui
+
+import (
+ "strings"
+)
+
+// Constants related to view's background description
+const (
+ // NoRepeat is value of the Repeat property of an background image:
+ // The image is not repeated (and hence the background image painting area
+ // will not necessarily be entirely covered). The position of the non-repeated
+ // background image is defined by the background-position CSS property.
+ NoRepeat = 0
+
+ // RepeatXY is value of the Repeat property of an background image:
+ // The image is repeated as much as needed to cover the whole background
+ // image painting area. The last image will be clipped if it doesn't fit.
+ RepeatXY = 1
+
+ // RepeatX is value of the Repeat property of an background image:
+ // The image is repeated horizontally as much as needed to cover
+ // the whole width background image painting area. The image is not repeated vertically.
+ // The last image will be clipped if it doesn't fit.
+ RepeatX = 2
+
+ // RepeatY is value of the Repeat property of an background image:
+ // The image is repeated vertically as much as needed to cover
+ // the whole height background image painting area. The image is not repeated horizontally.
+ // The last image will be clipped if it doesn't fit.
+ RepeatY = 3
+
+ // RepeatRound is value of the Repeat property of an background image:
+ // As the allowed space increases in size, the repeated images will stretch (leaving no gaps)
+ // until there is room (space left >= half of the image width) for another one to be added.
+ // When the next image is added, all of the current ones compress to allow room.
+ RepeatRound = 4
+
+ // RepeatSpace is value of the Repeat property of an background image:
+ // The image is repeated as much as possible without clipping. The first and last images
+ // are pinned to either side of the element, and whitespace is distributed evenly between the images.
+ RepeatSpace = 5
+
+ // ScrollAttachment is value of the Attachment property of an background image:
+ // The background is fixed relative to the element itself and does not scroll with its contents.
+ // (It is effectively attached to the element's border.)
+ ScrollAttachment = 0
+
+ // FixedAttachment is value of the Attachment property of an background image:
+ // The background is fixed relative to the viewport. Even if an element has
+ // a scrolling mechanism, the background doesn't move with the element.
+ FixedAttachment = 1
+
+ // LocalAttachment is value of the Attachment property of an background image:
+ // The background is fixed relative to the element's contents. If the element has a scrolling mechanism,
+ // the background scrolls with the element's contents, and the background painting area
+ // and background positioning area are relative to the scrollable area of the element
+ // rather than to the border framing them.
+ LocalAttachment = 2
+)
+
+type backgroundImage struct {
+ backgroundElement
+}
+
+// NewBackgroundImage creates the new background image
+func NewBackgroundImage(params Params) BackgroundElement {
+ result := new(backgroundImage)
+ result.init()
+ for tag, value := range params {
+ result.Set(tag, value)
+ }
+ return result
+}
+
+func (image *backgroundImage) init() {
+ image.backgroundElement.init()
+ image.normalize = normalizeBackgroundImageTag
+ image.supportedProperties = []PropertyName{
+ Attachment, Width, Height, Repeat, ImageHorizontalAlign, ImageVerticalAlign, backgroundFit, Source,
+ }
+}
+
+func (image *backgroundImage) Tag() string {
+ return "image"
+}
+
+func (image *backgroundImage) Clone() BackgroundElement {
+ result := NewBackgroundImage(nil)
+ for tag, value := range image.properties {
+ result.setRaw(tag, value)
+ }
+ return result
+}
+
+func normalizeBackgroundImageTag(tag PropertyName) PropertyName {
+ tag = defaultNormalize(tag)
+ switch tag {
+ case "source":
+ tag = Source
+
+ case Fit:
+ tag = backgroundFit
+
+ case HorizontalAlign:
+ tag = ImageHorizontalAlign
+
+ case VerticalAlign:
+ tag = ImageVerticalAlign
+ }
+
+ return tag
+}
+
+func (image *backgroundImage) cssStyle(session Session) string {
+ if src, ok := imageProperty(image, Source, session); ok && src != "" {
+ buffer := allocStringBuilder()
+ defer freeStringBuilder(buffer)
+
+ buffer.WriteString(`url(`)
+ buffer.WriteString(src)
+ buffer.WriteRune(')')
+
+ attachment, _ := enumProperty(image, Attachment, session, NoRepeat)
+ values := enumProperties[Attachment].values
+ if attachment > 0 && attachment < len(values) {
+ buffer.WriteRune(' ')
+ buffer.WriteString(values[attachment])
+ }
+
+ align, _ := enumProperty(image, ImageHorizontalAlign, session, LeftAlign)
+ values = enumProperties[ImageHorizontalAlign].values
+ if align >= 0 && align < len(values) {
+ buffer.WriteRune(' ')
+ buffer.WriteString(values[align])
+ } else {
+ buffer.WriteString(` left`)
+ }
+
+ align, _ = enumProperty(image, ImageVerticalAlign, session, TopAlign)
+ values = enumProperties[ImageVerticalAlign].values
+ if align >= 0 && align < len(values) {
+ buffer.WriteRune(' ')
+ buffer.WriteString(values[align])
+ } else {
+ buffer.WriteString(` top`)
+ }
+
+ fit, _ := enumProperty(image, backgroundFit, session, NoneFit)
+ values = enumProperties[backgroundFit].values
+ if fit > 0 && fit < len(values) {
+
+ buffer.WriteString(` / `)
+ buffer.WriteString(values[fit])
+
+ } else {
+
+ width, _ := sizeProperty(image, Width, session)
+ height, _ := sizeProperty(image, Height, session)
+
+ if width.Type != Auto || height.Type != Auto {
+ buffer.WriteString(` / `)
+ buffer.WriteString(width.cssString("auto", session))
+ buffer.WriteRune(' ')
+ buffer.WriteString(height.cssString("auto", session))
+ }
+ }
+
+ repeat, _ := enumProperty(image, Repeat, session, NoRepeat)
+ values = enumProperties[Repeat].values
+ if repeat >= 0 && repeat < len(values) {
+ buffer.WriteRune(' ')
+ buffer.WriteString(values[repeat])
+ } else {
+ buffer.WriteString(` no-repeat`)
+ }
+
+ return buffer.String()
+ }
+
+ return ""
+}
+
+func (image *backgroundImage) writeString(buffer *strings.Builder, indent string) {
+ image.writeToBuffer(buffer, indent, image.Tag(), []PropertyName{
+ Source,
+ Width,
+ Height,
+ ImageHorizontalAlign,
+ ImageVerticalAlign,
+ backgroundFit,
+ Repeat,
+ Attachment,
+ })
+}
+
+func (image *backgroundImage) String() string {
+ return runStringWriter(image)
+}
diff --git a/backgroundGradient.go b/backgroundLinearGradient.go
similarity index 53%
rename from backgroundGradient.go
rename to backgroundLinearGradient.go
index 1a5355f..1760b9c 100644
--- a/backgroundGradient.go
+++ b/backgroundLinearGradient.go
@@ -4,47 +4,29 @@ import "strings"
// Constants related to view's background gradient description
const (
-
// ToTopGradient is value of the Direction property of a linear gradient. The value is equivalent to the 0deg angle
ToTopGradient = 0
+
// ToRightTopGradient is value of the Direction property of a linear gradient.
ToRightTopGradient = 1
+
// ToRightGradient is value of the Direction property of a linear gradient. The value is equivalent to the 90deg angle
ToRightGradient = 2
+
// ToRightBottomGradient is value of the Direction property of a linear gradient.
ToRightBottomGradient = 3
+
// ToBottomGradient is value of the Direction property of a linear gradient. The value is equivalent to the 180deg angle
ToBottomGradient = 4
+
// ToLeftBottomGradient is value of the Direction property of a linear gradient.
ToLeftBottomGradient = 5
+
// ToLeftGradient is value of the Direction property of a linear gradient. The value is equivalent to the 270deg angle
ToLeftGradient = 6
+
// ToLeftTopGradient is value of the Direction property of a linear gradient.
ToLeftTopGradient = 7
-
- // EllipseGradient is value of the Shape property of a radial gradient background:
- // the shape is an axis-aligned ellipse
- EllipseGradient = 0
- // CircleGradient is value of the Shape property of a radial gradient background:
- // the gradient's shape is a circle with constant radius
- CircleGradient = 1
-
- // ClosestSideGradient is value of the Radius property of a radial gradient background:
- // The gradient's ending shape meets the side of the box closest to its center (for circles)
- // or meets both the vertical and horizontal sides closest to the center (for ellipses).
- ClosestSideGradient = 0
- // ClosestCornerGradient is value of the Radius property of a radial gradient background:
- // The gradient's ending shape is sized so that it exactly meets the closest corner
- // of the box from its center.
- ClosestCornerGradient = 1
- // FarthestSideGradient is value of the Radius property of a radial gradient background:
- // Similar to closest-side, except the ending shape is sized to meet the side of the box
- // farthest from its center (or vertical and horizontal sides).
- FarthestSideGradient = 2
- // FarthestCornerGradient is value of the Radius property of a radial gradient background:
- // The default value, the gradient's ending shape is sized so that it exactly meets
- // the farthest corner of the box from its center.
- FarthestCornerGradient = 3
)
// BackgroundGradientPoint define point on gradient straight line
@@ -65,10 +47,6 @@ type backgroundLinearGradient struct {
backgroundGradient
}
-type backgroundRadialGradient struct {
- backgroundGradient
-}
-
// NewBackgroundLinearGradient creates the new background linear gradient
func NewBackgroundLinearGradient(params Params) BackgroundElement {
result := new(backgroundLinearGradient)
@@ -79,16 +57,6 @@ func NewBackgroundLinearGradient(params Params) BackgroundElement {
return result
}
-// NewBackgroundRadialGradient creates the new background radial gradient
-func NewBackgroundRadialGradient(params Params) BackgroundElement {
- result := new(backgroundRadialGradient)
- result.init()
- for tag, value := range params {
- result.Set(tag, value)
- }
- return result
-}
-
func parseGradientText(value string) []BackgroundGradientPoint {
elements := strings.Split(value, ",")
count := len(elements)
@@ -422,261 +390,3 @@ func (gradient *backgroundLinearGradient) writeString(buffer *strings.Builder, i
func (gradient *backgroundLinearGradient) String() string {
return runStringWriter(gradient)
}
-
-func (gradient *backgroundRadialGradient) init() {
- gradient.backgroundElement.init()
- gradient.normalize = normalizeRadialGradientTag
- gradient.set = backgroundRadialGradientSet
- gradient.supportedProperties = []PropertyName{
- RadialGradientRadius, RadialGradientShape, CenterX, CenterY, Gradient, Repeating,
- }
-}
-
-func (gradient *backgroundRadialGradient) Tag() string {
- return "radial-gradient"
-}
-
-func (image *backgroundRadialGradient) Clone() BackgroundElement {
- result := NewBackgroundRadialGradient(nil)
- for tag, value := range image.properties {
- result.setRaw(tag, value)
- }
- return result
-}
-
-func normalizeRadialGradientTag(tag PropertyName) PropertyName {
- tag = defaultNormalize(tag)
- switch tag {
- case Radius:
- tag = RadialGradientRadius
-
- case Shape:
- tag = RadialGradientShape
-
- case "x-center":
- tag = CenterX
-
- case "y-center":
- tag = CenterY
- }
-
- return tag
-}
-
-func backgroundRadialGradientSet(properties Properties, tag PropertyName, value any) []PropertyName {
- switch tag {
- case RadialGradientRadius:
- switch value := value.(type) {
- case []SizeUnit:
- switch len(value) {
- case 0:
- properties.setRaw(RadialGradientRadius, nil)
-
- case 1:
- if value[0].Type == Auto {
- properties.setRaw(RadialGradientRadius, nil)
- } else {
- properties.setRaw(RadialGradientRadius, value[0])
- }
-
- default:
- properties.setRaw(RadialGradientRadius, value)
- }
- return []PropertyName{tag}
-
- case []any:
- switch len(value) {
- case 0:
- properties.setRaw(RadialGradientRadius, nil)
- return []PropertyName{tag}
-
- case 1:
- return backgroundRadialGradientSet(properties, RadialGradientRadius, value[0])
-
- default:
- properties.setRaw(RadialGradientRadius, value)
- return []PropertyName{tag}
- }
-
- case string:
- if setSimpleProperty(properties, RadialGradientRadius, value) {
- return []PropertyName{tag}
- }
- if size, err := stringToSizeUnit(value); err == nil {
- if size.Type == Auto {
- properties.setRaw(RadialGradientRadius, nil)
- } else {
- properties.setRaw(RadialGradientRadius, size)
- }
- return []PropertyName{tag}
- }
- return setEnumProperty(properties, RadialGradientRadius, value, enumProperties[RadialGradientRadius].values)
-
- case SizeUnit:
- if value.Type == Auto {
- properties.setRaw(RadialGradientRadius, nil)
- } else {
- properties.setRaw(RadialGradientRadius, value)
- }
- return []PropertyName{tag}
-
- case int:
- return setEnumProperty(properties, RadialGradientRadius, value, enumProperties[RadialGradientRadius].values)
- }
-
- ErrorLogF(`Invalid value of "%s" property: %v`, tag, value)
- return nil
-
- case RadialGradientShape, CenterX, CenterY:
- return propertiesSet(properties, tag, value)
- }
-
- return backgroundGradientSet(properties, tag, value)
-}
-
-func (gradient *backgroundRadialGradient) cssStyle(session Session) string {
- buffer := allocStringBuilder()
- defer freeStringBuilder(buffer)
-
- if repeating, _ := boolProperty(gradient, Repeating, session); repeating {
- buffer.WriteString(`repeating-radial-gradient(`)
- } else {
- buffer.WriteString(`radial-gradient(`)
- }
-
- var shapeText string
- if shape, ok := enumProperty(gradient, RadialGradientShape, session, EllipseGradient); ok && shape == CircleGradient {
- shapeText = `circle `
- } else {
- shapeText = `ellipse `
- }
-
- if value, ok := gradient.properties[RadialGradientRadius]; ok {
- switch value := value.(type) {
- case string:
- if text, ok := session.resolveConstants(value); ok {
- values := enumProperties[RadialGradientRadius]
- if n, ok := enumStringToInt(text, values.values, false); ok {
- buffer.WriteString(shapeText)
- shapeText = ""
- buffer.WriteString(values.cssValues[n])
- buffer.WriteString(" ")
- } else {
- if r, ok := StringToSizeUnit(text); ok && r.Type != Auto {
- buffer.WriteString("ellipse ")
- shapeText = ""
- buffer.WriteString(r.cssString("", session))
- buffer.WriteString(" ")
- buffer.WriteString(r.cssString("", session))
- buffer.WriteString(" ")
- } else {
- ErrorLog(`Invalid radial gradient radius: ` + text)
- }
- }
- } else {
- ErrorLog(`Invalid radial gradient radius: ` + value)
- }
-
- case int:
- values := enumProperties[RadialGradientRadius].cssValues
- if value >= 0 && value < len(values) {
- buffer.WriteString(shapeText)
- shapeText = ""
- buffer.WriteString(values[value])
- buffer.WriteString(" ")
- } else {
- ErrorLogF(`Invalid radial gradient radius: %d`, value)
- }
-
- case SizeUnit:
- if value.Type != Auto {
- buffer.WriteString("ellipse ")
- shapeText = ""
- buffer.WriteString(value.cssString("", session))
- buffer.WriteString(" ")
- buffer.WriteString(value.cssString("", session))
- buffer.WriteString(" ")
- }
-
- case []SizeUnit:
- count := len(value)
- if count > 2 {
- count = 2
- }
- buffer.WriteString("ellipse ")
- shapeText = ""
- for i := 0; i < count; i++ {
- buffer.WriteString(value[i].cssString("50%", session))
- buffer.WriteString(" ")
- }
-
- case []any:
- count := len(value)
- if count > 2 {
- count = 2
- }
- buffer.WriteString("ellipse ")
- shapeText = ""
- for i := 0; i < count; i++ {
- if value[i] != nil {
- switch value := value[i].(type) {
- case SizeUnit:
- buffer.WriteString(value.cssString("50%", session))
- buffer.WriteString(" ")
-
- case string:
- if text, ok := session.resolveConstants(value); ok {
- if size, err := stringToSizeUnit(text); err == nil {
- buffer.WriteString(size.cssString("50%", session))
- buffer.WriteString(" ")
- } else {
- buffer.WriteString("50% ")
- }
- } else {
- buffer.WriteString("50% ")
- }
- }
- } else {
- buffer.WriteString("50% ")
- }
- }
- }
- }
-
- x, _ := sizeProperty(gradient, CenterX, session)
- y, _ := sizeProperty(gradient, CenterX, session)
- if x.Type != Auto || y.Type != Auto {
- if shapeText != "" {
- buffer.WriteString(shapeText)
- }
- buffer.WriteString("at ")
- buffer.WriteString(x.cssString("50%", session))
- buffer.WriteString(" ")
- buffer.WriteString(y.cssString("50%", session))
- } else if shapeText != "" {
- buffer.WriteString(shapeText)
- }
-
- buffer.WriteString(", ")
- if !gradient.writeGradient(session, buffer) {
- return ""
- }
-
- buffer.WriteString(") ")
-
- return buffer.String()
-}
-func (gradient *backgroundRadialGradient) writeString(buffer *strings.Builder, indent string) {
- gradient.writeToBuffer(buffer, indent, gradient.Tag(), []PropertyName{
- Gradient,
- CenterX,
- CenterY,
- Repeating,
- RadialGradientShape,
- RadialGradientRadius,
- })
-}
-
-func (gradient *backgroundRadialGradient) String() string {
- return runStringWriter(gradient)
-}
diff --git a/backgroundRadialGradient.go b/backgroundRadialGradient.go
new file mode 100644
index 0000000..85956c6
--- /dev/null
+++ b/backgroundRadialGradient.go
@@ -0,0 +1,307 @@
+package rui
+
+import "strings"
+
+// Constants related to view's background gradient description
+const (
+ // EllipseGradient is value of the Shape property of a radial gradient background:
+ // the shape is an axis-aligned ellipse
+ EllipseGradient = 0
+
+ // CircleGradient is value of the Shape property of a radial gradient background:
+ // the gradient's shape is a circle with constant radius
+ CircleGradient = 1
+
+ // ClosestSideGradient is value of the Radius property of a radial gradient background:
+ // The gradient's ending shape meets the side of the box closest to its center (for circles)
+ // or meets both the vertical and horizontal sides closest to the center (for ellipses).
+ ClosestSideGradient = 0
+
+ // ClosestCornerGradient is value of the Radius property of a radial gradient background:
+ // The gradient's ending shape is sized so that it exactly meets the closest corner
+ // of the box from its center.
+ ClosestCornerGradient = 1
+
+ // FarthestSideGradient is value of the Radius property of a radial gradient background:
+ // Similar to closest-side, except the ending shape is sized to meet the side of the box
+ // farthest from its center (or vertical and horizontal sides).
+ FarthestSideGradient = 2
+
+ // FarthestCornerGradient is value of the Radius property of a radial gradient background:
+ // The default value, the gradient's ending shape is sized so that it exactly meets
+ // the farthest corner of the box from its center.
+ FarthestCornerGradient = 3
+)
+
+type backgroundRadialGradient struct {
+ backgroundGradient
+}
+
+// NewBackgroundRadialGradient creates the new background radial gradient
+func NewBackgroundRadialGradient(params Params) BackgroundElement {
+ result := new(backgroundRadialGradient)
+ result.init()
+ for tag, value := range params {
+ result.Set(tag, value)
+ }
+ return result
+}
+
+func (gradient *backgroundRadialGradient) init() {
+ gradient.backgroundElement.init()
+ gradient.normalize = normalizeRadialGradientTag
+ gradient.set = backgroundRadialGradientSet
+ gradient.supportedProperties = []PropertyName{
+ RadialGradientRadius, RadialGradientShape, CenterX, CenterY, Gradient, Repeating,
+ }
+}
+
+func (gradient *backgroundRadialGradient) Tag() string {
+ return "radial-gradient"
+}
+
+func (image *backgroundRadialGradient) Clone() BackgroundElement {
+ result := NewBackgroundRadialGradient(nil)
+ for tag, value := range image.properties {
+ result.setRaw(tag, value)
+ }
+ return result
+}
+
+func normalizeRadialGradientTag(tag PropertyName) PropertyName {
+ tag = defaultNormalize(tag)
+ switch tag {
+ case Radius:
+ tag = RadialGradientRadius
+
+ case Shape:
+ tag = RadialGradientShape
+
+ case "x-center":
+ tag = CenterX
+
+ case "y-center":
+ tag = CenterY
+ }
+
+ return tag
+}
+
+func backgroundRadialGradientSet(properties Properties, tag PropertyName, value any) []PropertyName {
+ switch tag {
+ case RadialGradientRadius:
+ switch value := value.(type) {
+ case []SizeUnit:
+ switch len(value) {
+ case 0:
+ properties.setRaw(RadialGradientRadius, nil)
+
+ case 1:
+ if value[0].Type == Auto {
+ properties.setRaw(RadialGradientRadius, nil)
+ } else {
+ properties.setRaw(RadialGradientRadius, value[0])
+ }
+
+ default:
+ properties.setRaw(RadialGradientRadius, value)
+ }
+ return []PropertyName{tag}
+
+ case []any:
+ switch len(value) {
+ case 0:
+ properties.setRaw(RadialGradientRadius, nil)
+ return []PropertyName{tag}
+
+ case 1:
+ return backgroundRadialGradientSet(properties, RadialGradientRadius, value[0])
+
+ default:
+ properties.setRaw(RadialGradientRadius, value)
+ return []PropertyName{tag}
+ }
+
+ case string:
+ if setSimpleProperty(properties, RadialGradientRadius, value) {
+ return []PropertyName{tag}
+ }
+ if size, err := stringToSizeUnit(value); err == nil {
+ if size.Type == Auto {
+ properties.setRaw(RadialGradientRadius, nil)
+ } else {
+ properties.setRaw(RadialGradientRadius, size)
+ }
+ return []PropertyName{tag}
+ }
+ return setEnumProperty(properties, RadialGradientRadius, value, enumProperties[RadialGradientRadius].values)
+
+ case SizeUnit:
+ if value.Type == Auto {
+ properties.setRaw(RadialGradientRadius, nil)
+ } else {
+ properties.setRaw(RadialGradientRadius, value)
+ }
+ return []PropertyName{tag}
+
+ case int:
+ return setEnumProperty(properties, RadialGradientRadius, value, enumProperties[RadialGradientRadius].values)
+ }
+
+ ErrorLogF(`Invalid value of "%s" property: %v`, tag, value)
+ return nil
+
+ case RadialGradientShape, CenterX, CenterY:
+ return propertiesSet(properties, tag, value)
+ }
+
+ return backgroundGradientSet(properties, tag, value)
+}
+
+func (gradient *backgroundRadialGradient) cssStyle(session Session) string {
+ buffer := allocStringBuilder()
+ defer freeStringBuilder(buffer)
+
+ if repeating, _ := boolProperty(gradient, Repeating, session); repeating {
+ buffer.WriteString(`repeating-radial-gradient(`)
+ } else {
+ buffer.WriteString(`radial-gradient(`)
+ }
+
+ var shapeText string
+ if shape, ok := enumProperty(gradient, RadialGradientShape, session, EllipseGradient); ok && shape == CircleGradient {
+ shapeText = `circle `
+ } else {
+ shapeText = `ellipse `
+ }
+
+ if value, ok := gradient.properties[RadialGradientRadius]; ok {
+ switch value := value.(type) {
+ case string:
+ if text, ok := session.resolveConstants(value); ok {
+ values := enumProperties[RadialGradientRadius]
+ if n, ok := enumStringToInt(text, values.values, false); ok {
+ buffer.WriteString(shapeText)
+ shapeText = ""
+ buffer.WriteString(values.cssValues[n])
+ buffer.WriteString(" ")
+ } else {
+ if r, ok := StringToSizeUnit(text); ok && r.Type != Auto {
+ buffer.WriteString("ellipse ")
+ shapeText = ""
+ buffer.WriteString(r.cssString("", session))
+ buffer.WriteString(" ")
+ buffer.WriteString(r.cssString("", session))
+ buffer.WriteString(" ")
+ } else {
+ ErrorLog(`Invalid radial gradient radius: ` + text)
+ }
+ }
+ } else {
+ ErrorLog(`Invalid radial gradient radius: ` + value)
+ }
+
+ case int:
+ values := enumProperties[RadialGradientRadius].cssValues
+ if value >= 0 && value < len(values) {
+ buffer.WriteString(shapeText)
+ shapeText = ""
+ buffer.WriteString(values[value])
+ buffer.WriteString(" ")
+ } else {
+ ErrorLogF(`Invalid radial gradient radius: %d`, value)
+ }
+
+ case SizeUnit:
+ if value.Type != Auto {
+ buffer.WriteString("ellipse ")
+ shapeText = ""
+ buffer.WriteString(value.cssString("", session))
+ buffer.WriteString(" ")
+ buffer.WriteString(value.cssString("", session))
+ buffer.WriteString(" ")
+ }
+
+ case []SizeUnit:
+ count := len(value)
+ if count > 2 {
+ count = 2
+ }
+ buffer.WriteString("ellipse ")
+ shapeText = ""
+ for i := 0; i < count; i++ {
+ buffer.WriteString(value[i].cssString("50%", session))
+ buffer.WriteString(" ")
+ }
+
+ case []any:
+ count := len(value)
+ if count > 2 {
+ count = 2
+ }
+ buffer.WriteString("ellipse ")
+ shapeText = ""
+ for i := 0; i < count; i++ {
+ if value[i] != nil {
+ switch value := value[i].(type) {
+ case SizeUnit:
+ buffer.WriteString(value.cssString("50%", session))
+ buffer.WriteString(" ")
+
+ case string:
+ if text, ok := session.resolveConstants(value); ok {
+ if size, err := stringToSizeUnit(text); err == nil {
+ buffer.WriteString(size.cssString("50%", session))
+ buffer.WriteString(" ")
+ } else {
+ buffer.WriteString("50% ")
+ }
+ } else {
+ buffer.WriteString("50% ")
+ }
+ }
+ } else {
+ buffer.WriteString("50% ")
+ }
+ }
+ }
+ }
+
+ x, _ := sizeProperty(gradient, CenterX, session)
+ y, _ := sizeProperty(gradient, CenterX, session)
+ if x.Type != Auto || y.Type != Auto {
+ if shapeText != "" {
+ buffer.WriteString(shapeText)
+ }
+ buffer.WriteString("at ")
+ buffer.WriteString(x.cssString("50%", session))
+ buffer.WriteString(" ")
+ buffer.WriteString(y.cssString("50%", session))
+ } else if shapeText != "" {
+ buffer.WriteString(shapeText)
+ }
+
+ buffer.WriteString(", ")
+ if !gradient.writeGradient(session, buffer) {
+ return ""
+ }
+
+ buffer.WriteString(") ")
+
+ return buffer.String()
+}
+
+func (gradient *backgroundRadialGradient) writeString(buffer *strings.Builder, indent string) {
+ gradient.writeToBuffer(buffer, indent, gradient.Tag(), []PropertyName{
+ Gradient,
+ CenterX,
+ CenterY,
+ Repeating,
+ RadialGradientShape,
+ RadialGradientRadius,
+ })
+}
+
+func (gradient *backgroundRadialGradient) String() string {
+ return runStringWriter(gradient)
+}
From 8a353f765e457dfa209af4c21b3bea72d3f42b91 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Mon, 2 Dec 2024 15:05:49 +0300
Subject: [PATCH 24/43] Improved SizeUnit and AngleUnit functions
---
angleUnit.go | 16 ++++++++--------
sizeUnit.go | 40 ++++++++++++++++++++--------------------
2 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/angleUnit.go b/angleUnit.go
index 4f35342..dae0d5a 100644
--- a/angleUnit.go
+++ b/angleUnit.go
@@ -35,23 +35,23 @@ type AngleUnit struct {
}
// Deg creates AngleUnit with Degree type
-func Deg(value float64) AngleUnit {
- return AngleUnit{Type: Degree, Value: value}
+func Deg[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) AngleUnit {
+ return AngleUnit{Type: Degree, Value: float64(value)}
}
// Rad create AngleUnit with Radian type
-func Rad(value float64) AngleUnit {
- return AngleUnit{Type: Radian, Value: value}
+func Rad[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) AngleUnit {
+ return AngleUnit{Type: Radian, Value: float64(value)}
}
// PiRad create AngleUnit with PiRadian type
-func PiRad(value float64) AngleUnit {
- return AngleUnit{Type: PiRadian, Value: value}
+func PiRad[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) AngleUnit {
+ return AngleUnit{Type: PiRadian, Value: float64(value)}
}
// Grad create AngleUnit with Gradian type
-func Grad(value float64) AngleUnit {
- return AngleUnit{Type: Gradian, Value: value}
+func Grad[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) AngleUnit {
+ return AngleUnit{Type: Gradian, Value: float64(value)}
}
// Equal compare two AngleUnit. Return true if AngleUnit are equal
diff --git a/sizeUnit.go b/sizeUnit.go
index 579c507..2ea8f8c 100644
--- a/sizeUnit.go
+++ b/sizeUnit.go
@@ -62,53 +62,53 @@ func AutoSize() SizeUnit {
}
// Px creates SizeUnit with SizeInPixel type
-func Px(value float64) SizeUnit {
- return SizeUnit{SizeInPixel, value, nil}
+func Px[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
+ return SizeUnit{Type: SizeInPixel, Value: float64(value), Function: nil}
}
// Em creates SizeUnit with SizeInEM type
-func Em(value float64) SizeUnit {
- return SizeUnit{SizeInEM, value, nil}
+func Em[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
+ return SizeUnit{Type: SizeInEM, Value: float64(value), Function: nil}
}
// Ex creates SizeUnit with SizeInEX type
-func Ex(value float64) SizeUnit {
- return SizeUnit{SizeInEX, value, nil}
+func Ex[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
+ return SizeUnit{Type: SizeInEX, Value: float64(value), Function: nil}
}
// Percent creates SizeUnit with SizeInDIP type
-func Percent(value float64) SizeUnit {
- return SizeUnit{SizeInPercent, value, nil}
+func Percent[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
+ return SizeUnit{Type: SizeInPercent, Value: float64(value), Function: nil}
}
// Pt creates SizeUnit with SizeInPt type
-func Pt(value float64) SizeUnit {
- return SizeUnit{SizeInPt, value, nil}
+func Pt[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
+ return SizeUnit{Type: SizeInPt, Value: float64(value), Function: nil}
}
// Pc creates SizeUnit with SizeInPc type
-func Pc(value float64) SizeUnit {
- return SizeUnit{SizeInPc, value, nil}
+func Pc[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
+ return SizeUnit{Type: SizeInPc, Value: float64(value), Function: nil}
}
// Mm creates SizeUnit with SizeInMM type
-func Mm(value float64) SizeUnit {
- return SizeUnit{SizeInMM, value, nil}
+func Mm[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
+ return SizeUnit{Type: SizeInMM, Value: float64(value), Function: nil}
}
// Cm creates SizeUnit with SizeInCM type
-func Cm(value float64) SizeUnit {
- return SizeUnit{SizeInCM, value, nil}
+func Cm[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
+ return SizeUnit{Type: SizeInCM, Value: float64(value), Function: nil}
}
// Inch creates SizeUnit with SizeInInch type
-func Inch(value float64) SizeUnit {
- return SizeUnit{SizeInInch, value, nil}
+func Inch[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
+ return SizeUnit{Type: SizeInInch, Value: float64(value), Function: nil}
}
// Fr creates SizeUnit with SizeInFraction type
-func Fr(value float64) SizeUnit {
- return SizeUnit{SizeInFraction, value, nil}
+func Fr[T float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](value T) SizeUnit {
+ return SizeUnit{SizeInFraction, float64(value), nil}
}
// Equal compare two SizeUnit. Return true if SizeUnit are equal
From 5efa2f5ae8620e24ad7ba3bf564d61bdfbead150 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Mon, 2 Dec 2024 15:47:06 +0300
Subject: [PATCH 25/43] Bug fixing
---
stackLayout.go | 2 +-
transform.go | 150 ++++++++++++++++++++++++++++++-------------------
viewUtils.go | 113 +++----------------------------------
3 files changed, 101 insertions(+), 164 deletions(-)
diff --git a/stackLayout.go b/stackLayout.go
index efb49e6..9972bb3 100644
--- a/stackLayout.go
+++ b/stackLayout.go
@@ -937,7 +937,7 @@ func GetPushTiming(view View, subviewID ...string) string {
return "easy"
}
-// GetTransform returns the start transform (translation, scale and rotation over x, y and z axes as well as a distortion)
+// GetPushTransform returns the start transform (translation, scale and rotation over x, y and z axes as well as a distortion)
// for an animated pushing of a child view.
// The default value is nil (no transform).
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
diff --git a/transform.go b/transform.go
index a1c10da..5ecfa32 100644
--- a/transform.go
+++ b/transform.go
@@ -397,6 +397,8 @@ type TransformProperty interface {
fmt.Stringer
stringWriter
transformCSS(session Session) string
+ getSkew(session Session) (AngleUnit, AngleUnit, bool)
+ getTranslate(session Session) (SizeUnit, SizeUnit, SizeUnit)
}
type transformPropertyData struct {
@@ -563,13 +565,6 @@ func setTransformPropertyElement(properties Properties, tag, transformTag Proper
return nil
}
-/*
-func getTransform3D(style Properties, session Session) bool {
- perspective, ok := sizeProperty(style, Perspective, session)
- return ok && perspective.Type != Auto && perspective.Value != 0
-}
-*/
-
func getPerspectiveOrigin(style Properties, session Session) (SizeUnit, SizeUnit) {
x, _ := sizeProperty(style, PerspectiveOriginX, session)
y, _ := sizeProperty(style, PerspectiveOriginY, session)
@@ -766,54 +761,95 @@ func transformOriginCSS(x, y, z SizeUnit, session Session) string {
return buffer.String()
}
-/*
-func (view *viewData) updateTransformProperty(tag PropertyName) bool {
- htmlID := view.htmlID()
- session := view.session
-
- switch tag {
- case PerspectiveOriginX, PerspectiveOriginY:
- if getTransform3D(view, session) {
- x, y := GetPerspectiveOrigin(view)
- value := ""
- if x.Type != Auto || y.Type != Auto {
- value = x.cssString("50%", session) + " " + y.cssString("50%", session)
- }
- session.updateCSSProperty(htmlID, "perspective-origin", value)
- }
-
- case BackfaceVisible:
- if getTransform3D(view, session) {
- if GetBackfaceVisible(view) {
- session.updateCSSProperty(htmlID, string(BackfaceVisible), "visible")
- } else {
- session.updateCSSProperty(htmlID, string(BackfaceVisible), "hidden")
- }
- }
-
- case OriginX, OriginY, OriginZ:
- x, y, z := getOrigin(view, session)
- value := ""
-
- if z.Type != Auto {
- value = x.cssString("50%", session) + " " + y.cssString("50%", session) + " " + z.cssString("50%", session)
- } else if x.Type != Auto || y.Type != Auto {
- value = x.cssString("50%", session) + " " + y.cssString("50%", session)
- }
- session.updateCSSProperty(htmlID, "transform-origin", value)
-
- case TransformTag, SkewX, SkewY, TranslateX, TranslateY, TranslateZ,
- ScaleX, ScaleY, ScaleZ, Rotate, RotateX, RotateY, RotateZ:
- if transform := getTransformProperty(view); transform != nil {
- session.updateCSSProperty(htmlID, "transform", transform.transformCSS(session))
- } else {
- session.updateCSSProperty(htmlID, "transform", "")
- }
-
- default:
- return false
- }
-
- return true
+// GetTransform returns a view transform: translation, scale and rotation over x, y and z axes as well as a distortion of a view along x and y axes.
+// The default value is nil (no transform)
+// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
+func GetTransform(view View, subviewID ...string) TransformProperty {
+ return transformStyledProperty(view, subviewID, Transform)
+}
+
+// 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).
+// 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 {
+ return sizeStyledProperty(view, subviewID, Perspective, false)
+}
+
+// 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%).
+// 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) {
+ view = getSubview(view, subviewID)
+ 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:
+// 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.
+// 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 {
+ return boolStyledProperty(view, subviewID, BackfaceVisible, false)
+}
+
+// GetTransformOrigin returns a x-, y-, and z-coordinate of the point around which a view transformation is applied.
+// The default value is (50%, 50%, 50%).
+// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
+func GetTransformOrigin(view View, subviewID ...string) (SizeUnit, SizeUnit, SizeUnit) {
+ view = getSubview(view, subviewID)
+ if view == nil {
+ return AutoSize(), AutoSize(), AutoSize()
+ }
+ return getTransformOrigin(view, view.Session())
+}
+
+// GetTranslate returns a x-, y-, and z-axis translation value of a 2D/3D translation
+// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
+func GetTranslate(view View, subviewID ...string) (SizeUnit, SizeUnit, SizeUnit) {
+ if transform := GetTransform(view, subviewID...); transform != nil {
+ return transform.getTranslate(view.Session())
+ }
+ return AutoSize(), AutoSize(), AutoSize()
+}
+
+// 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.
+// 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 transform := GetTransform(view, subviewID...); transform != nil {
+ x, y, _ := transform.getSkew(view.Session())
+ return x, y
+ }
+ return AngleUnit{Value: 0, Type: Radian}, AngleUnit{Value: 0, Type: Radian}
+}
+
+// GetScale returns a x-, y-, and z-axis scaling value of a 2D/3D scale. The default value is 1.
+// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
+func GetScale(view View, subviewID ...string) (float64, float64, float64) {
+ if transform := GetTransform(view, subviewID...); transform != nil {
+ session := view.Session()
+ x, _ := floatProperty(transform, ScaleX, session, 1)
+ y, _ := floatProperty(transform, ScaleY, session, 1)
+ z, _ := floatProperty(transform, ScaleZ, session, 1)
+ return x, y, z
+ }
+ return 1, 1, 1
+}
+
+// GetRotate returns a x-, y, z-coordinate of the vector denoting the axis of rotation, and the angle of the view rotation
+// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
+func GetRotate(view View, subviewID ...string) (float64, float64, float64, AngleUnit) {
+ if transform := GetTransform(view, subviewID...); transform != nil {
+ session := view.Session()
+ angle, _ := angleProperty(transform, Rotate, view.Session())
+ rotateX, _ := floatProperty(transform, RotateX, session, 1)
+ rotateY, _ := floatProperty(transform, RotateY, session, 1)
+ rotateZ, _ := floatProperty(transform, RotateZ, session, 1)
+ return rotateX, rotateY, rotateZ, angle
+ }
+ return 0, 0, 0, AngleUnit{Value: 0, Type: Radian}
}
-*/
diff --git a/viewUtils.go b/viewUtils.go
index 4bf5242..2d69438 100644
--- a/viewUtils.go
+++ b/viewUtils.go
@@ -3,6 +3,8 @@ 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.
+//
+// If the second argument (subviewID) is "" then a listener for the first argument (view) is get
func Get(rootView View, viewID string, tag PropertyName) any {
var view View
if viewID != "" {
@@ -17,8 +19,12 @@ func Get(rootView View, viewID string, tag PropertyName) any {
}
// Set sets the property with name "tag" of the "rootView" subview with "viewID" id by value. Result:
+//
// true - success,
+//
// false - error (incompatible type or invalid format of a string value, see AppLog).
+//
+// If the second argument (subviewID) is "" then a listener for the first argument (view) is set
func Set(rootView View, viewID string, tag PropertyName, value any) bool {
var view View
if viewID != "" {
@@ -33,7 +39,7 @@ func Set(rootView View, viewID string, tag PropertyName, value any) bool {
}
// SetChangeListener sets a listener for changing a subview property value.
-// If the second argument (subviewID) is not specified or it is "" then a listener for the first argument (view) is set
+// If the second argument (subviewID) is "" then a listener for the first argument (view) is set
func SetChangeListener(view View, viewID string, tag PropertyName, listener func(View, PropertyName)) {
if viewID != "" {
view = ViewByID(view, viewID)
@@ -544,111 +550,6 @@ func GetColumn(view View, subviewID ...string) Range {
return Range{}
}
-// GetTransform returns a view transform: translation, scale and rotation over x, y and z axes as well as a distortion of a view along x and y axes.
-// The default value is nil (no transform)
-// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
-func GetTransform(view View, subviewID ...string) TransformProperty {
- return transformStyledProperty(view, subviewID, Transform)
-}
-
-// 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).
-// 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 {
- return sizeStyledProperty(view, subviewID, Perspective, false)
-}
-
-// 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%).
-// 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) {
- view = getSubview(view, subviewID)
- 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:
-// 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.
-// 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 {
- return boolStyledProperty(view, subviewID, BackfaceVisible, false)
-}
-
-// GetTransformOrigin returns a x-, y-, and z-coordinate of the point around which a view transformation is applied.
-// The default value is (50%, 50%, 50%).
-// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
-func GetTransformOrigin(view View, subviewID ...string) (SizeUnit, SizeUnit, SizeUnit) {
- view = getSubview(view, subviewID)
- if view == nil {
- return AutoSize(), AutoSize(), AutoSize()
- }
- return getTransformOrigin(view, view.Session())
-}
-
-// GetTranslate returns a x-, y-, and z-axis translation value of a 2D/3D translation
-// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
-func GetTranslate(view View, subviewID ...string) (SizeUnit, SizeUnit, SizeUnit) {
- view = getSubview(view, subviewID)
- if view == nil {
- return AutoSize(), AutoSize(), AutoSize()
- }
-
- session := view.Session()
- x, _ := sizeProperty(view, TranslateX, session)
- y, _ := sizeProperty(view, TranslateY, session)
- z, _ := sizeProperty(view, TranslateZ, session)
- return x, y, z
-}
-
-// 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.
-// 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) {
- view = getSubview(view, subviewID)
- if view == nil {
- return AngleUnit{Value: 0, Type: Radian}, AngleUnit{Value: 0, Type: Radian}
- }
- x, _ := angleProperty(view, SkewX, view.Session())
- y, _ := angleProperty(view, SkewY, view.Session())
- return x, y
-}
-
-// GetScale returns a x-, y-, and z-axis scaling value of a 2D/3D scale. The default value is 1.
-// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
-func GetScale(view View, subviewID ...string) (float64, float64, float64) {
- view = getSubview(view, subviewID)
- if view == nil {
- return 1, 1, 1
- }
-
- session := view.Session()
- x, _ := floatProperty(view, ScaleX, session, 1)
- y, _ := floatProperty(view, ScaleY, session, 1)
- z, _ := floatProperty(view, ScaleZ, session, 1)
- return x, y, z
-}
-
-// GetRotate returns a x-, y, z-coordinate of the vector denoting the axis of rotation, and the angle of the view rotation
-// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
-func GetRotate(view View, subviewID ...string) (float64, float64, float64, AngleUnit) {
- view = getSubview(view, subviewID)
- if view == nil {
- return 0, 0, 0, AngleUnit{Value: 0, Type: Radian}
- }
-
- session := view.Session()
- angle, _ := angleProperty(view, Rotate, view.Session())
- rotateX, _ := floatProperty(view, RotateX, session, 1)
- rotateY, _ := floatProperty(view, RotateY, session, 1)
- rotateZ, _ := floatProperty(view, RotateZ, session, 1)
- return rotateX, rotateY, rotateZ, angle
-}
-
// 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.
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
From 32141b996a38c5b30a2c44c8be4c254baa917739 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Tue, 3 Dec 2024 10:25:55 +0300
Subject: [PATCH 26/43] Rename ViewShadow interface
---
CHANGELOG.md | 20 +++++++--
README-ru.md | 36 ++++++++---------
README.md | 34 ++++++++--------
popup.go | 4 +-
propertyNames.go | 24 +++++------
shadow.go | 103 ++++++++++++++++++++++++-----------------------
viewFilter.go | 14 +++----
viewStyle.go | 4 +-
viewUtils.go | 17 +++++---
9 files changed, 139 insertions(+), 117 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b8c6d5a..6b89090 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,9 +1,22 @@
# v0.18.0
+* Renamed:
+ Transform interface -> TransformProperty
+ NewTransform function -> NewTransformProperty
+ TransformTag constant -> Transform.
+ "origin-x" property -> "transform-origin-x"
+ "origin-y" property -> "transform-origin-y"
+ "origin-z" property -> "transform-origin-z"
+ GetOrigin function -> GetTransformOrigin.
+ BorderBoxClip constant -> BorderBox
+ PaddingBoxClip constant -> PaddingBox
+ ContentBoxClip constant -> ContentBox.
+ ViewShadow interface -> ShadowProperty
+ NewViewShadow function -> NewShadow
+ NewInsetViewShadow function -> NewInsetShadow
+ NewShadowWithParams function -> NewShadowProperty
+
* Property name type changed from string to PropertyName.
-* Transform interface renamed to TransformProperty. NewTransform function renamed to NewTransformProperty. TransformTag constant renamed to Transform.
-* "origin-x", "origin-y", and "origin-z" properties renamed to "transform-origin-x", "transform-origin-y", and "transform-origin-z".
-* GetOrigin function renamed to GetTransformOrigin.
* Changed Push, Pop, MoveToFront, and MoveToFrontByID methods of StackLayout interface.
* Removed DefaultAnimation, StartToEndAnimation, EndToStartAnimation, TopDownAnimation, and BottomUpAnimation constants.
* Added "push-transform", "push-duration", "push-timing", and "move-to-front-animation" StackLayout properties.
@@ -13,7 +26,6 @@
* Added GetPushTransform, GetPushDuration, GetPushTiming, and IsMoveToFrontAnimation functions.
* Added "mask", "mask-clip", "mask-origin", and "background-origin" properties.
* Added GetBackground, GetMask, GetBackgroundClip,GetBackgroundOrigin, GetMaskClip, and GetMaskOrigin functions.
-* Renamed BorderBoxClip, PaddingBoxClip, and ContentBoxClip constants to BorderBox, PaddingBox, and ContentBox.
* Added LineJoin type. Type of constants MiterJoin, RoundJoin, and BevelJoin changed to LineJoin. Type of Canvas.SetLineJoin function argument changed to LineJoin.
* Added LineCap type. Type of constants ButtCap, RoundCap, and SquareCap changed to LineCap. Type of Canvas.SetLineCap function argument changed to LineCap.
diff --git a/README-ru.md b/README-ru.md
index a1080f6..6cb42d9 100644
--- a/README-ru.md
+++ b/README-ru.md
@@ -1047,7 +1047,7 @@ RadiusProperty, а не структура BoxRadius. Получить стру
### Свойство "shadow"
Свойство "shadow" позволяет задать тени для View. Теней может быть несколько. Тень описывается
-с помощью интерфейса ViewShadow расширяющего интерфейс Properties (см. выше). У тени имеются следующие свойства:
+с помощью интерфейса ShadowProperty расширяющего интерфейс Properties (см. выше). У тени имеются следующие свойства:
| Свойство | Константа | Тип | Описание |
|-----------------|---------------|----------|---------------------------------------------------------------|
@@ -1058,13 +1058,13 @@ RadiusProperty, а не структура BoxRadius. Получить стру
| "blur" | BlurRadius | float | Радиус размытия тени. Значение должно быть >= 0 |
| "spread-radius" | SpreadRadius | float | Увеличение тени. Значение > 0 увеличивает тень, < 0 уменьшает |
-Для создания ViewShadow используются три функции:
+Для создания ShadowProperty используются три функции:
- func NewViewShadow(offsetX, offsetY, blurRadius, spread-radius SizeUnit, color Color) ViewShadow
- func NewInsetViewShadow(offsetX, offsetY, blurRadius, spread-radius SizeUnit, color Color) ViewShadow
- func NewShadowWithParams(params Params) ViewShadow
+ func NewShadowProperty(offsetX, offsetY, blurRadius, spread-radius SizeUnit, color Color) ShadowProperty
+ func NewInsetShadowProperty(offsetX, offsetY, blurRadius, spread-radius SizeUnit, color Color) ShadowProperty
+ func NewShadowWithParams(params Params) ShadowProperty
-Функция NewViewShadow создает внешнюю тень (Inset == false), NewInsetViewShadow - внутреннюю
+Функция NewShadowProperty создает внешнюю тень (Inset == false), NewInsetShadowProperty - внутреннюю
(Inset == true).
Функция NewShadowWithParams используется когда в качестве параметров необходимо использовать
константы. Например:
@@ -1075,10 +1075,10 @@ RadiusProperty, а не структура BoxRadius. Получить стру
rui.Dilation : 16.0,
})
-В качестве значения свойству "shadow" может быть присвоено ViewShadow, массив ViewShadow,
-текстовое представление ViewShadow.
+В качестве значения свойству "shadow" может быть присвоено ShadowProperty, массив ShadowProperty,
+текстовое представление ShadowProperty.
-Текстовое представление ViewShadow имеет следующий формат:
+Текстовое представление ShadowProperty имеет следующий формат:
_{ color = <цвет> [, x-offset = <смещение>] [, y-offset = <смещение>] [, blur = <радиус>]
[, spread-radius = <увеличение>] [, inset = <тип>] }
@@ -1086,7 +1086,7 @@ RadiusProperty, а не структура BoxRadius. Получить стру
Получить значение данного свойства можно с помощью функции
- func GetViewShadows(view View, subviewID ...string) []ViewShadow
+ func GetShadowPropertys(view View, subviewID ...string) []ShadowProperty
Если тень не задана, то данная функция вернет пустой массив
@@ -1447,7 +1447,7 @@ radius необходимо передать nil
| "blur" | Blur | float64 0…10000px | Размытие по Гауссу |
| "brightness" | Brightness | float64 0…10000% | Изменение яркости |
| "contrast" | Contrast | float64 0…10000% | Изменение контрастности |
-| "drop-shadow" | DropShadow | []ViewShadow | Добавление тени |
+| "drop-shadow" | DropShadow | []ShadowProperty | Добавление тени |
| "grayscale" | Grayscale | float64 0…100% | Преобразование к оттенкам серого |
| "hue-rotate" | HueRotate | AngleUnit | Вращение оттенка |
| "invert" | Invert | float64 0…100% | Инвертирование цветов |
@@ -1704,14 +1704,14 @@ radius необходимо передать nil
#### Свойство "text-shadow"
Свойство "text-shadow" позволяет задать тени для текста. Теней может быть несколько. Тень описывается
-с помощью интерфейса ViewShadow (см. выше, раздел "Свойство 'shadow'"). Для тени текста используются только
+с помощью интерфейса ShadowProperty (см. выше, раздел "Свойство 'shadow'"). Для тени текста используются только
Свойства "color", "x-offset", "y-offset" и "blur". Свойства "inset" и "spread-radius" игнорируются (т.е. их
задание не является ошибкой, просто никакого влияния на тень текста они не имеют).
-Для создания ViewShadow для тени текста используются функции:
+Для создания ShadowProperty для тени текста используются функции:
- func NewTextShadow(offsetX, offsetY, blurRadius SizeUnit, color Color) ViewShadow
- func NewShadowWithParams(params Params) ViewShadow
+ func NewTextShadow(offsetX, offsetY, blurRadius SizeUnit, color Color) ShadowProperty
+ func NewShadowWithParams(params Params) ShadowProperty
Функция NewShadowWithParams используется когда в качестве параметров необходимо использовать
константы. Например:
@@ -1721,12 +1721,12 @@ radius необходимо передать nil
rui.BlurRadius : 8.0,
})
-В качестве значения свойству "text-shadow" может быть присвоено ViewShadow, массив ViewShadow,
-текстовое представление ViewShadow (см. выше, раздел "Свойство 'shadow'").
+В качестве значения свойству "text-shadow" может быть присвоено ShadowProperty, массив ShadowProperty,
+текстовое представление ShadowProperty (см. выше, раздел "Свойство 'shadow'").
Получить значение данного свойства можно с помощью функции
- func GetTextShadows(view View, subviewID ...string) []ViewShadow
+ func GetTextShadows(view View, subviewID ...string) []ShadowProperty
Если тень не задана, то данная функция вернет пустой массив
diff --git a/README.md b/README.md
index d05c1da..12c66d5 100644
--- a/README.md
+++ b/README.md
@@ -1024,7 +1024,7 @@ equivalent to
### "shadow" property
The "shadow" property allows you to set shadows for the View. There may be several shadows.
-The shadow is described using the ViewShadow interface extending the Properties interface (see above).
+The shadow is described using the ShadowProperty interface extending the Properties interface (see above).
The shadow has the following properties:
| Property | Constant | Type | Description |
@@ -1036,14 +1036,14 @@ The shadow has the following properties:
| "blur" | BlurRadius | float | Shadow blur radius. The value must be >= 0 |
| "spread-radius" | SpreadRadius | float | Increase the shadow. Value > 0 increases shadow, < 0 decreases shadow |
-Three functions are used to create a ViewShadow:
+Three functions are used to create a ShadowProperty:
- func NewViewShadow(offsetX, offsetY, blurRadius, spread-radius SizeUnit, color Color) ViewShadow
- func NewInsetViewShadow(offsetX, offsetY, blurRadius, spread-radius SizeUnit, color Color) ViewShadow
- func NewShadowWithParams(params Params) ViewShadow
+ func NewShadowProperty(offsetX, offsetY, blurRadius, spread-radius SizeUnit, color Color) ShadowProperty
+ func NewInsetShadowProperty(offsetX, offsetY, blurRadius, spread-radius SizeUnit, color Color) ShadowProperty
+ func NewShadowWithParams(params Params) ShadowProperty
-The NewViewShadow function creates an outer shadow (Inset == false),
-NewInsetViewShadow - an inner one (Inset == true).
+The NewShadowProperty function creates an outer shadow (Inset == false),
+NewInsetShadowProperty - an inner one (Inset == true).
The NewShadowWithParams function is used when constants must be used as parameters.
For example:
@@ -1053,16 +1053,16 @@ For example:
rui.Dilation : 16.0,
})
-ViewShadow, ViewShadow array, and ViewShadow textual representation can be assigned as a value to the "shadow" property.
+ShadowProperty, ShadowProperty array, and ShadowProperty textual representation can be assigned as a value to the "shadow" property.
-The ViewShadow text representation has the following format:
+The ShadowProperty text representation has the following format:
_{ color = [, x-offset = ] [, y-offset = ] [, blur = ]
[, spread-radius = ] [, inset = ] }
You can get the value of "shadow" property using the function
- func GetViewShadows(view View, subviewID ...string) []ViewShadow
+ func GetShadowPropertys(view View, subviewID ...string) []ShadowProperty
If no shadow is specified, then this function will return an empty array
@@ -1425,7 +1425,7 @@ The argument lists the effects to apply. The following effects are possible:
| "blur" | Blur | float64 0…10000px | Gaussian blur |
| "brightness" | Brightness | float64 0…10000% | Brightness change |
| "contrast" | Contrast | float64 0…10000% | Contrast change |
-| "drop-shadow" | DropShadow | []ViewShadow | Adding shadow |
+| "drop-shadow" | DropShadow | []ShadowProperty | Adding shadow |
| "grayscale" | Grayscale | float64 0…100% | Converting to grayscale |
| "hue-rotate" | HueRotate | AngleUnit | Hue rotation |
| "invert" | Invert | float64 0…100% | Invert colors |
@@ -1686,14 +1686,14 @@ You can get the value of this property using the function
#### "text-shadow" property
The "text-shadow" property allows you to set shadows for the text. There may be several shadows.
-The shadow is described using the ViewShadow interface (see above, section "The 'shadow' property").
+The shadow is described using the ShadowProperty interface (see above, section "The 'shadow' property").
For text shadow, only the "color", "x-offset", "y-offset" and "blur" properties are used.
The "inset" and "spread-radius" properties are ignored (i.e. setting them is not an error, they just have no effect on the text shadow).
-To create a ViewShadow for the text shadow, the following functions are used:
+To create a ShadowProperty for the text shadow, the following functions are used:
- func NewTextShadow(offsetX, offsetY, blurRadius SizeUnit, color Color) ViewShadow
- func NewShadowWithParams(params Params) ViewShadow
+ func NewTextShadow(offsetX, offsetY, blurRadius SizeUnit, color Color) ShadowProperty
+ func NewShadowWithParams(params Params) ShadowProperty
The NewShadowWithParams function is used when constants must be used as parameters. For example:
@@ -1702,11 +1702,11 @@ The NewShadowWithParams function is used when constants must be used as paramete
rui.BlurRadius: 8.0,
})
-ViewShadow, ViewShadow array, ViewShadow textual representation can be assigned as a value to the "text-shadow" property (see above, section "The 'shadow' property").
+ShadowProperty, ShadowProperty array, ShadowProperty textual representation can be assigned as a value to the "text-shadow" property (see above, section "The 'shadow' property").
You can get the value of this property using the function
- func GetTextShadows(view View, subviewID ...string) []ViewShadow
+ func GetTextShadows(view View, subviewID ...string) []ShadowProperty
If no shadow is specified, then this function will return an empty array
diff --git a/popup.go b/popup.go
index 2536370..3947d29 100644
--- a/popup.go
+++ b/popup.go
@@ -363,7 +363,7 @@ func (arrow *popupArrow) createView(popupView View) View {
params := Params{BackgroundColor: GetBackgroundColor(popupView)}
- if shadow := GetViewShadows(popupView); shadow != nil {
+ if shadow := GetShadowPropertys(popupView); shadow != nil {
params[Shadow] = shadow
}
@@ -554,7 +554,7 @@ func (popup *popupData) init(view View, popupParams Params) {
CellVerticalAlign: StretchAlign,
CellHorizontalAlign: StretchAlign,
ClickEvent: func(View) {},
- Shadow: NewShadowWithParams(Params{
+ Shadow: NewShadowProperty(Params{
SpreadRadius: Px(4),
Blur: Px(16),
ColorTag: "@ruiPopupShadow",
diff --git a/propertyNames.go b/propertyNames.go
index 18dd429..8780e18 100644
--- a/propertyNames.go
+++ b/propertyNames.go
@@ -964,15 +964,15 @@ const (
// Adds shadow effects around a view's frame. A shadow is described by X and Y offsets relative to the element, blur,
// spread radius and color.
//
- // Supported types: `ViewShadow`, `[]ViewShadow`, `string`.
+ // Supported types: `ShadowProperty`, `[]ShadowProperty`, `string`.
//
- // Internal type is `[]ViewShadow`, other types converted to it during assignment.
- // See `ViewShadow` description for more details.
+ // Internal type is `[]ShadowProperty`, other types converted to it during assignment.
+ // See `ShadowProperty` description for more details.
//
// Conversion rules:
- // `[]ViewShadow` - stored as is. no conversion performed.
- // `ViewShadow` - converted to `[]ViewShadow` during assignment.
- // `string` - must contain a string representation of `ViewShadow`
+ // `[]ShadowProperty` - stored as is. no conversion performed.
+ // `ShadowProperty` - converted to `[]ShadowProperty` during assignment.
+ // `string` - must contain a string representation of `ShadowProperty`
Shadow PropertyName = "shadow"
// FontName is the constant for "font-name" property tag.
@@ -1178,15 +1178,15 @@ const (
// Used by `View`.
// Specify shadow for the text.
//
- // Supported types: `ViewShadow`, `[]ViewShadow`, `string`.
+ // Supported types: `ShadowProperty`, `[]ShadowProperty`, `string`.
//
- // Internal type is `[]ViewShadow`, other types converted to it during assignment.
- // See `ViewShadow` description for more details.
+ // Internal type is `[]ShadowProperty`, other types converted to it during assignment.
+ // See `ShadowProperty` description for more details.
//
// Conversion rules:
- // `[]ViewShadow` - stored as is. no conversion performed.
- // `ViewShadow` - converted to `[]ViewShadow` during assignment.
- // `string` - must contain a string representation of `ViewShadow`
+ // `[]ShadowProperty` - stored as is. no conversion performed.
+ // `ShadowProperty` - converted to `[]ShadowProperty` during assignment.
+ // `string` - must contain a string representation of `ShadowProperty`
TextShadow PropertyName = "text-shadow"
// TextWrap is the constant for "text-wrap" property tag.
diff --git a/shadow.go b/shadow.go
index 08b29ce..dd09ea3 100644
--- a/shadow.go
+++ b/shadow.go
@@ -5,11 +5,11 @@ import (
"strings"
)
-// Constants for [ViewShadow] specific properties
+// Constants for [ShadowProperty] specific properties
const (
// ColorTag is the constant for "color" property tag.
//
- // Used by `ColumnSeparatorProperty`, `BorderProperty`, `OutlineProperty`, `ViewShadow`.
+ // Used by `ColumnSeparatorProperty`, `BorderProperty`, `OutlineProperty`, `ShadowProperty`.
//
// Usage in `ColumnSeparatorProperty`:
// Line color.
@@ -35,7 +35,7 @@ const (
// Internal type is `Color`, other types converted to it during assignment.
// See `Color` description for more details.
//
- // Usage in `ViewShadow`:
+ // Usage in `ShadowProperty`:
// Color property of the shadow.
//
// Supported types: `Color`, `string`.
@@ -46,7 +46,7 @@ const (
// Inset is the constant for "inset" property tag.
//
- // Used by `ViewShadow`.
+ // Used by `ShadowProperty`.
// Controls whether to draw shadow inside the frame or outside. Inset shadows are drawn inside the border(even transparent
// ones), above the background, but below content.
//
@@ -59,7 +59,7 @@ const (
// XOffset is the constant for "x-offset" property tag.
//
- // Used by `ViewShadow`.
+ // Used by `ShadowProperty`.
// Determines the shadow horizontal offset. Negative values place the shadow to the left of the element.
//
// Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
@@ -70,7 +70,7 @@ const (
// YOffset is the constant for "y-offset" property tag.
//
- // Used by `ViewShadow`.
+ // Used by `ShadowProperty`.
// Determines the shadow vertical offset. Negative values place the shadow above the element.
//
// Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
@@ -81,7 +81,7 @@ const (
// BlurRadius is the constant for "blur" property tag.
//
- // Used by `ViewShadow`.
+ // Used by `ShadowProperty`.
// Determines the radius of the blur effect. The larger this value, the bigger the blur, so the shadow becomes bigger and
// lighter. Negative values are not allowed.
//
@@ -93,7 +93,7 @@ const (
// SpreadRadius is the constant for "spread-radius" property tag.
//
- // Used by `ViewShadow`.
+ // Used by `ShadowProperty`.
// Positive values will cause the shadow to expand and grow bigger, negative values will cause the shadow to shrink.
//
// Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
@@ -103,8 +103,8 @@ const (
SpreadRadius PropertyName = "spread-radius"
)
-// ViewShadow contains attributes of the view shadow
-type ViewShadow interface {
+// ShadowProperty contains attributes of the view shadow
+type ShadowProperty interface {
Properties
fmt.Stringer
stringWriter
@@ -113,11 +113,11 @@ type ViewShadow interface {
visible(session Session) bool
}
-type viewShadowData struct {
+type shadowPropertyData struct {
dataProperty
}
-// NewViewShadow create the new shadow for a view. Arguments:
+// NewShadow create the new shadow property for a view. Arguments:
//
// offsetX, offsetY is x and y offset of the shadow;
//
@@ -126,17 +126,18 @@ type viewShadowData struct {
// spreadRadius is the spread radius of the shadow;
//
// color is the color of the shadow.
-func NewViewShadow(offsetX, offsetY, blurRadius, spreadRadius SizeUnit, color Color) ViewShadow {
- return NewShadowWithParams(Params{
- XOffset: offsetX,
- YOffset: offsetY,
+func NewShadow[xOffsetType SizeUnit | int | float64, yOffsetType SizeUnit | int | float64, blurType SizeUnit | int | float64, spreadType SizeUnit | int | float64](
+ xOffset xOffsetType, yOffset yOffsetType, blurRadius blurType, spreadRadius spreadType, color Color) ShadowProperty {
+ return NewShadowProperty(Params{
+ XOffset: xOffset,
+ YOffset: yOffset,
BlurRadius: blurRadius,
SpreadRadius: spreadRadius,
ColorTag: color,
})
}
-// NewInsetViewShadow create the new inset shadow for a view. Arguments:
+// NewInsetShadow create the new inset shadow property for a view. Arguments:
//
// offsetX, offsetY is x and y offset of the shadow;
//
@@ -145,10 +146,11 @@ func NewViewShadow(offsetX, offsetY, blurRadius, spreadRadius SizeUnit, color Co
// spreadRadius is the spread radius of the shadow;
//
// color is the color of the shadow.
-func NewInsetViewShadow(offsetX, offsetY, blurRadius, spreadRadius SizeUnit, color Color) ViewShadow {
- return NewShadowWithParams(Params{
- XOffset: offsetX,
- YOffset: offsetY,
+func NewInsetShadow[xOffsetType SizeUnit | int | float64, yOffsetType SizeUnit | int | float64, blurType SizeUnit | int | float64, spreadType SizeUnit | int | float64](
+ xOffset xOffsetType, yOffset yOffsetType, blurRadius blurType, spreadRadius spreadType, color Color) ShadowProperty {
+ return NewShadowProperty(Params{
+ XOffset: xOffset,
+ YOffset: yOffset,
BlurRadius: blurRadius,
SpreadRadius: spreadRadius,
ColorTag: color,
@@ -156,23 +158,24 @@ func NewInsetViewShadow(offsetX, offsetY, blurRadius, spreadRadius SizeUnit, col
})
}
-// NewTextShadow create the new text shadow. Arguments:
+// NewTextShadow create the new text shadow property. Arguments:
//
// offsetX, offsetY is the x- and y-offset of the shadow;
//
// blurRadius is the blur radius of the shadow;
//
// color is the color of the shadow.
-func NewTextShadow(offsetX, offsetY, blurRadius SizeUnit, color Color) ViewShadow {
- return NewShadowWithParams(Params{
- XOffset: offsetX,
- YOffset: offsetY,
+func NewTextShadow[xOffsetType SizeUnit | int | float64, yOffsetType SizeUnit | int | float64, blurType SizeUnit | int | float64](
+ xOffset xOffsetType, yOffset yOffsetType, blurRadius blurType, color Color) ShadowProperty {
+ return NewShadowProperty(Params{
+ XOffset: xOffset,
+ YOffset: yOffset,
BlurRadius: blurRadius,
ColorTag: color,
})
}
-// NewShadowWithParams create the new shadow for a view.
+// NewShadowProperty create the new shadow property for a view.
// The following properties can be used:
//
// "color" (ColorTag). Determines the color of the shadow (Color);
@@ -186,8 +189,8 @@ func NewTextShadow(offsetX, offsetY, blurRadius SizeUnit, color Color) ViewShado
// "spread-radius" (SpreadRadius). Positive values (SizeUnit) will cause the shadow to expand and grow bigger, negative values will cause the shadow to shrink;
//
// "inset" (Inset). Controls (bool) whether to draw shadow inside the frame or outside.
-func NewShadowWithParams(params Params) ViewShadow {
- shadow := new(viewShadowData)
+func NewShadowProperty(params Params) ShadowProperty {
+ shadow := new(shadowPropertyData)
shadow.init()
if params != nil {
@@ -200,20 +203,20 @@ func NewShadowWithParams(params Params) ViewShadow {
return shadow
}
-// parseViewShadow parse DataObject and create ViewShadow object
-func parseViewShadow(object DataObject) ViewShadow {
- shadow := new(viewShadowData)
+// parseShadowProperty parse DataObject and create ShadowProperty object
+func parseShadowProperty(object DataObject) ShadowProperty {
+ shadow := new(shadowPropertyData)
shadow.init()
parseProperties(shadow, object)
return shadow
}
-func (shadow *viewShadowData) init() {
+func (shadow *shadowPropertyData) init() {
shadow.dataProperty.init()
shadow.supportedProperties = []PropertyName{ColorTag, Inset, XOffset, YOffset, BlurRadius, SpreadRadius}
}
-func (shadow *viewShadowData) cssStyle(buffer *strings.Builder, session Session, lead string) bool {
+func (shadow *shadowPropertyData) cssStyle(buffer *strings.Builder, session Session, lead string) bool {
color, _ := colorProperty(shadow, ColorTag, session)
offsetX, _ := sizeProperty(shadow, XOffset, session)
offsetY, _ := sizeProperty(shadow, YOffset, session)
@@ -245,7 +248,7 @@ func (shadow *viewShadowData) cssStyle(buffer *strings.Builder, session Session,
return true
}
-func (shadow *viewShadowData) cssTextStyle(buffer *strings.Builder, session Session, lead string) bool {
+func (shadow *shadowPropertyData) cssTextStyle(buffer *strings.Builder, session Session, lead string) bool {
color, _ := colorProperty(shadow, ColorTag, session)
offsetX, _ := sizeProperty(shadow, XOffset, session)
offsetY, _ := sizeProperty(shadow, YOffset, session)
@@ -269,7 +272,7 @@ func (shadow *viewShadowData) cssTextStyle(buffer *strings.Builder, session Sess
return true
}
-func (shadow *viewShadowData) visible(session Session) bool {
+func (shadow *shadowPropertyData) visible(session Session) bool {
color, _ := colorProperty(shadow, ColorTag, session)
offsetX, _ := sizeProperty(shadow, XOffset, session)
offsetY, _ := sizeProperty(shadow, YOffset, session)
@@ -286,11 +289,11 @@ func (shadow *viewShadowData) visible(session Session) bool {
return true
}
-func (shadow *viewShadowData) String() string {
+func (shadow *shadowPropertyData) String() string {
return runStringWriter(shadow)
}
-func (shadow *viewShadowData) writeString(buffer *strings.Builder, indent string) {
+func (shadow *shadowPropertyData) writeString(buffer *strings.Builder, indent string) {
buffer.WriteString("_{ ")
comma := false
for _, tag := range shadow.AllTags() {
@@ -315,10 +318,10 @@ func setShadowProperty(properties Properties, tag PropertyName, value any) bool
}
switch value := value.(type) {
- case ViewShadow:
- properties.setRaw(tag, []ViewShadow{value})
+ case ShadowProperty:
+ properties.setRaw(tag, []ShadowProperty{value})
- case []ViewShadow:
+ case []ShadowProperty:
if len(value) == 0 {
properties.setRaw(tag, nil)
} else {
@@ -329,13 +332,13 @@ func setShadowProperty(properties Properties, tag PropertyName, value any) bool
if !value.IsObject() {
return false
}
- properties.setRaw(tag, []ViewShadow{parseViewShadow(value.Object())})
+ properties.setRaw(tag, []ShadowProperty{parseShadowProperty(value.Object())})
case []DataValue:
- shadows := []ViewShadow{}
+ shadows := []ShadowProperty{}
for _, data := range value {
if data.IsObject() {
- shadows = append(shadows, parseViewShadow(data.Object()))
+ shadows = append(shadows, parseShadowProperty(data.Object()))
}
}
if len(shadows) == 0 {
@@ -349,7 +352,7 @@ func setShadowProperty(properties Properties, tag PropertyName, value any) bool
notCompatibleType(tag, value)
return false
}
- properties.setRaw(tag, []ViewShadow{parseViewShadow(obj)})
+ properties.setRaw(tag, []ShadowProperty{parseShadowProperty(obj)})
default:
notCompatibleType(tag, value)
@@ -359,17 +362,17 @@ func setShadowProperty(properties Properties, tag PropertyName, value any) bool
return true
}
-func getShadows(properties Properties, tag PropertyName) []ViewShadow {
+func getShadows(properties Properties, tag PropertyName) []ShadowProperty {
if value := properties.Get(tag); value != nil {
switch value := value.(type) {
- case []ViewShadow:
+ case []ShadowProperty:
return value
- case ViewShadow:
- return []ViewShadow{value}
+ case ShadowProperty:
+ return []ShadowProperty{value}
}
}
- return []ViewShadow{}
+ return []ShadowProperty{}
}
func shadowCSS(properties Properties, tag PropertyName, session Session) string {
diff --git a/viewFilter.go b/viewFilter.go
index 4773d4d..96c7bb0 100644
--- a/viewFilter.go
+++ b/viewFilter.go
@@ -47,17 +47,17 @@ const (
// Used by `ViewFilter`.
// Applies a drop shadow effect to the input image. A drop shadow is effectively a blurred, offset version of the input
// image's alpha mask drawn in a particular color, composited below the image. Shadow parameters are set using the
- // `ViewShadow` interface.
+ // `ShadowProperty` interface.
//
- // Supported types: `[]ViewShadow`, `ViewShadow`, `string`.
+ // Supported types: `[]ShadowProperty`, `ShadowProperty`, `string`.
//
- // Internal type is `[]ViewShadow`, other types converted to it during assignment.
- // See `ViewShadow` description for more details.
+ // Internal type is `[]ShadowProperty`, other types converted to it during assignment.
+ // See `ShadowProperty` description for more details.
//
// Conversion rules:
- // `[]ViewShadow` - stored as is, no conversion performed.
- // `ViewShadow` - converted to `[]ViewShadow`.
- // `string` - string representation of `ViewShadow`. Example: "_{blur = 1em, color = black, spread-radius = 0.5em}".
+ // `[]ShadowProperty` - stored as is, no conversion performed.
+ // `ShadowProperty` - converted to `[]ShadowProperty`.
+ // `string` - string representation of `ShadowProperty`. Example: "_{blur = 1em, color = black, spread-radius = 0.5em}".
DropShadow PropertyName = "drop-shadow"
// Grayscale is the constant for "grayscale" property tag.
diff --git a/viewStyle.go b/viewStyle.go
index 5462d2c..1352ce3 100644
--- a/viewStyle.go
+++ b/viewStyle.go
@@ -560,7 +560,7 @@ func supportedPropertyValue(value any) bool {
case int:
case stringWriter:
case fmt.Stringer:
- case []ViewShadow:
+ case []ShadowProperty:
case []View:
case []any:
case []BackgroundElement:
@@ -671,7 +671,7 @@ func writePropertyValue(buffer *strings.Builder, tag PropertyName, value any, in
case fmt.Stringer:
writeString(value.String())
- case []ViewShadow:
+ case []ShadowProperty:
switch len(value) {
case 0:
// do nothing
diff --git a/viewUtils.go b/viewUtils.go
index 2d69438..1a278ba 100644
--- a/viewUtils.go
+++ b/viewUtils.go
@@ -203,6 +203,13 @@ func GetWidth(view View, subviewID ...string) SizeUnit {
return sizeStyledProperty(view, subviewID, Width, false)
}
+func SetWidth[T SizeUnit | float64 | float32 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](size T, view View, subviewID ...string) bool {
+ if view = getSubview(view, subviewID); view != nil {
+ return view.Set(Width, size)
+ }
+ return false
+}
+
// GetHeight returns the subview height.
// 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 {
@@ -326,22 +333,22 @@ func GetOutlineOffset(view View, subviewID ...string) SizeUnit {
return sizeStyledProperty(view, subviewID, OutlineOffset, false)
}
-// GetViewShadows returns shadows of the subview.
+// GetShadowPropertys returns shadows of the subview.
// If the second argument (subviewID) is not specified or it is "" then shadows of the first argument (view) is returned.
-func GetViewShadows(view View, subviewID ...string) []ViewShadow {
+func GetShadowPropertys(view View, subviewID ...string) []ShadowProperty {
view = getSubview(view, subviewID)
if view == nil {
- return []ViewShadow{}
+ return []ShadowProperty{}
}
return getShadows(view, Shadow)
}
// GetTextShadows returns text shadows of the subview.
// If the second argument (subviewID) is not specified or it is "" then shadows of the first argument (view) is returned.
-func GetTextShadows(view View, subviewID ...string) []ViewShadow {
+func GetTextShadows(view View, subviewID ...string) []ShadowProperty {
view = getSubview(view, subviewID)
if view == nil {
- return []ViewShadow{}
+ return []ShadowProperty{}
}
return getShadows(view, TextShadow)
}
From 8e20e80899e0f85f3262f8939fb8400c6634e133 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Tue, 3 Dec 2024 10:45:55 +0300
Subject: [PATCH 27/43] Added NewBounds function
---
CHANGELOG.md | 19 +++++++++++++------
bounds.go | 13 +++++++++++++
shadow.go | 16 ++++++++--------
3 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6b89090..23e0f28 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,6 @@
# v0.18.0
+* Property name type changed from string to PropertyName.
* Renamed:
Transform interface -> TransformProperty
NewTransform function -> NewTransformProperty
@@ -16,17 +17,23 @@
NewInsetViewShadow function -> NewInsetShadow
NewShadowWithParams function -> NewShadowProperty
-* Property name type changed from string to PropertyName.
+* Added functions: NewBounds, GetPushTransform, GetPushDuration, GetPushTiming, IsMoveToFrontAnimation,
+GetBackground, GetMask, GetBackgroundClip,GetBackgroundOrigin, GetMaskClip, GetMaskOrigin.
+
* Changed Push, Pop, MoveToFront, and MoveToFrontByID methods of StackLayout interface.
+
* Removed DefaultAnimation, StartToEndAnimation, EndToStartAnimation, TopDownAnimation, and BottomUpAnimation constants.
-* Added "push-transform", "push-duration", "push-timing", and "move-to-front-animation" StackLayout properties.
-* Added "push-perspective", "push-rotate-x", "push-rotate-y", "push-rotate-z", "push-rotate", "push-skew-x", "push-skew-y",
-"push-scale-x", "push-scale-y", "push-scale-z", "push-translate-x", "push-translate-y", "push-translate-z" StackLayout properties.
+
+* Added StackLayout properties: "push-transform", "push-duration", "push-timing", "move-to-front-animation", "push-perspective",
+"push-rotate-x", "push-rotate-y", "push-rotate-z", "push-rotate", "push-skew-x", "push-skew-y",
+"push-scale-x", "push-scale-y", "push-scale-z", "push-translate-x", "push-translate-y", "push-translate-z".
+
* Added "show-opacity", "show-transform", "show-duration", and "show-timing" Popup properties.
-* Added GetPushTransform, GetPushDuration, GetPushTiming, and IsMoveToFrontAnimation functions.
+
* Added "mask", "mask-clip", "mask-origin", and "background-origin" properties.
-* Added GetBackground, GetMask, GetBackgroundClip,GetBackgroundOrigin, GetMaskClip, and GetMaskOrigin functions.
+
* Added LineJoin type. Type of constants MiterJoin, RoundJoin, and BevelJoin changed to LineJoin. Type of Canvas.SetLineJoin function argument changed to LineJoin.
+
* Added LineCap type. Type of constants ButtCap, RoundCap, and SquareCap changed to LineCap. Type of Canvas.SetLineCap function argument changed to LineCap.
# v0.17.3
diff --git a/bounds.go b/bounds.go
index dc66f14..5d931d2 100644
--- a/bounds.go
+++ b/bounds.go
@@ -35,6 +35,19 @@ func NewBoundsProperty(params Params) BoundsProperty {
return bounds
}
+// NewBounds creates the new BoundsProperty object.
+// The arguments specify the boundaries in a clockwise direction: "top", "right", "bottom", and "left".
+// If the argument is specified as int or float64, the value is considered to be in pixels.
+func NewBounds[topType SizeUnit | int | float64, rightType SizeUnit | int | float64, bottomType SizeUnit | int | float64, leftType SizeUnit | int | float64](
+ top topType, right rightType, bottom bottomType, left leftType) BoundsProperty {
+ return NewBoundsProperty(Params{
+ Top: top,
+ Right: right,
+ Bottom: bottom,
+ Left: left,
+ })
+}
+
func (bounds *boundsPropertyData) init() {
bounds.dataProperty.init()
bounds.normalize = normalizeBoundsTag
diff --git a/shadow.go b/shadow.go
index dd09ea3..937d45f 100644
--- a/shadow.go
+++ b/shadow.go
@@ -119,11 +119,11 @@ type shadowPropertyData struct {
// NewShadow create the new shadow property for a view. Arguments:
//
-// offsetX, offsetY is x and y offset of the shadow;
+// offsetX, offsetY is x and y offset of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
//
-// blurRadius is the blur radius of the shadow;
+// blurRadius is the blur radius of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
//
-// spreadRadius is the spread radius of the shadow;
+// spreadRadius is the spread radius of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
//
// color is the color of the shadow.
func NewShadow[xOffsetType SizeUnit | int | float64, yOffsetType SizeUnit | int | float64, blurType SizeUnit | int | float64, spreadType SizeUnit | int | float64](
@@ -139,11 +139,11 @@ func NewShadow[xOffsetType SizeUnit | int | float64, yOffsetType SizeUnit | int
// NewInsetShadow create the new inset shadow property for a view. Arguments:
//
-// offsetX, offsetY is x and y offset of the shadow;
+// offsetX, offsetY is x and y offset of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
//
-// blurRadius is the blur radius of the shadow;
+// blurRadius is the blur radius of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
//
-// spreadRadius is the spread radius of the shadow;
+// spreadRadius is the spread radius of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
//
// color is the color of the shadow.
func NewInsetShadow[xOffsetType SizeUnit | int | float64, yOffsetType SizeUnit | int | float64, blurType SizeUnit | int | float64, spreadType SizeUnit | int | float64](
@@ -160,9 +160,9 @@ func NewInsetShadow[xOffsetType SizeUnit | int | float64, yOffsetType SizeUnit |
// NewTextShadow create the new text shadow property. Arguments:
//
-// offsetX, offsetY is the x- and y-offset of the shadow;
+// offsetX, offsetY is the x- and y-offset of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
//
-// blurRadius is the blur radius of the shadow;
+// blurRadius is the blur radius of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
//
// color is the color of the shadow.
func NewTextShadow[xOffsetType SizeUnit | int | float64, yOffsetType SizeUnit | int | float64, blurType SizeUnit | int | float64](
From 5f55d3044340b8a1aaba98d6052f24cecb0ee6ea Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Tue, 3 Dec 2024 11:20:32 +0300
Subject: [PATCH 28/43] Added NewRadius functions
---
CHANGELOG.md | 4 ++-
bounds.go | 30 --------------------
radius.go | 77 ++++++++++++++++++++++++++++++++++++++++++++--------
3 files changed, 69 insertions(+), 42 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 23e0f28..6e3c8a0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
# v0.18.0
* Property name type changed from string to PropertyName.
+
* Renamed:
Transform interface -> TransformProperty
NewTransform function -> NewTransformProperty
@@ -17,7 +18,8 @@
NewInsetViewShadow function -> NewInsetShadow
NewShadowWithParams function -> NewShadowProperty
-* Added functions: NewBounds, GetPushTransform, GetPushDuration, GetPushTiming, IsMoveToFrontAnimation,
+* Added functions: NewBounds, NewEllipticRadius, NewRadii,
+GetPushTransform, GetPushDuration, GetPushTiming, IsMoveToFrontAnimation,
GetBackground, GetMask, GetBackgroundClip,GetBackgroundOrigin, GetMaskClip, GetMaskOrigin.
* Changed Push, Pop, MoveToFront, and MoveToFrontByID methods of StackLayout interface.
diff --git a/bounds.go b/bounds.go
index 5d931d2..1384318 100644
--- a/bounds.go
+++ b/bounds.go
@@ -152,22 +152,6 @@ func (bounds *Bounds) setFromProperties(tag, topTag, rightTag, bottomTag, leftTa
}
}
-/*
-func (bounds *Bounds) allFieldsAuto() bool {
- return bounds.Left.Type == Auto &&
- bounds.Top.Type == Auto &&
- bounds.Right.Type == Auto &&
- bounds.Bottom.Type == Auto
-}
-
-func (bounds *Bounds) allFieldsZero() bool {
- return (bounds.Left.Type == Auto || bounds.Left.Value == 0) &&
- (bounds.Top.Type == Auto || bounds.Top.Value == 0) &&
- (bounds.Right.Type == Auto || bounds.Right.Value == 0) &&
- (bounds.Bottom.Type == Auto || bounds.Bottom.Value == 0)
-}
-*/
-
func (bounds *Bounds) allFieldsEqual() bool {
if bounds.Left.Type == bounds.Top.Type &&
bounds.Left.Type == bounds.Right.Type &&
@@ -181,20 +165,6 @@ func (bounds *Bounds) allFieldsEqual() bool {
return false
}
-/*
-func (bounds Bounds) writeCSSString(buffer *strings.Builder, textForAuto string) {
- buffer.WriteString(bounds.Top.cssString(textForAuto))
- if !bounds.allFieldsEqual() {
- buffer.WriteRune(' ')
- buffer.WriteString(bounds.Right.cssString(textForAuto))
- buffer.WriteRune(' ')
- buffer.WriteString(bounds.Bottom.cssString(textForAuto))
- buffer.WriteRune(' ')
- buffer.WriteString(bounds.Left.cssString(textForAuto))
- }
-}
-*/
-
// String convert Bounds to string
func (bounds *Bounds) String() string {
if bounds.allFieldsEqual() {
diff --git a/radius.go b/radius.go
index 7352632..7241a53 100644
--- a/radius.go
+++ b/radius.go
@@ -226,7 +226,7 @@ const (
// See `SizeUnit` description for more details.
//
// Usage in `RadiusProperty`:
- // Determines the x-axis top-right corner elliptic rounding radius of an element's outer border edge.
+ // Determines the x-axis elliptic rounding radius of an element's outer border edge.
//
// Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
//
@@ -247,7 +247,7 @@ const (
// See `SizeUnit` description for more details.
//
// Usage in `RadiusProperty`:
- // Determines the y-axis top-right corner elliptic rounding radius of an element's outer border edge.
+ // Determines the y-axis elliptic rounding radius of an element's outer border edge.
//
// Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
//
@@ -403,17 +403,38 @@ type radiusPropertyData struct {
}
// NewRadiusProperty creates the new RadiusProperty
+// The following properties can be used:
+//
+// "x" (X) - Determines the x-axis elliptic rounding radius of an element's outer border edge.
+//
+// "y" (Y) - Determines the y-axis corner elliptic rounding radius of an element's outer border edge.
+//
+// "top-left" (TopLeft) - Determines the top-left corner rounding radius of an element's outer border edge.
+//
+// "top-left-x" (TopLeftX) - Determines the x-axis top-left corner elliptic rounding radius of an element's outer border edge.
+//
+// "top-left-y" (TopLeftY) - Determines the y-axis top-left corner elliptic rounding radius of an element's outer border edge.
+//
+// "top-right" (TopRight) - Determines the top-right corner rounding radius of an element's outer border edge.
+//
+// "top-right-x" (TopRightX) - Determines the x-axis top-right corner elliptic rounding radius of an element's outer border edge.
+//
+// "top-right-y" (TopRightY) - Determines the y-axis top-right corner elliptic rounding radius of an element's outer border edge.
+//
+// "bottom-left" (BottomLeft) - Determines the bottom-left corner rounding radius of an element's outer border edge.
+//
+// "bottom-left-x" (BottomLeftX) - Determines the x-axis bottom-left corner elliptic rounding radius of an element's outer border edge.
+//
+// "bottom-left-y" (BottomLeftY) - Determines the y-axis bottom-left corner elliptic rounding radius of an element's outer border edge.
+//
+// "bottom-right" (BottomRight) - Determines the bottom-right corner rounding radius of an element's outer border edge.
+//
+// "bottom-right-x" (BottomRightX) - Determines the x-axis bottom-right corner elliptic rounding radius of an element's outer border edge.
+//
+// "bottom-right-y" (BottomRightY) - Determines the y-axis bottom-right corner elliptic rounding radius of an element's outer border edge.
func NewRadiusProperty(params Params) RadiusProperty {
result := new(radiusPropertyData)
- result.dataProperty.init()
- result.normalize = radiusPropertyNormalize
- result.get = radiusPropertyGet
- result.remove = radiusPropertyRemove
- result.set = radiusPropertySet
- result.supportedProperties = []PropertyName{
- X, Y, TopLeft, TopRight, BottomLeft, BottomRight, TopLeftX, TopLeftY,
- TopRightX, TopRightY, BottomLeftX, BottomLeftY, BottomRightX, BottomRightY,
- }
+ result.init()
if params != nil {
for _, tag := range result.supportedProperties {
@@ -425,11 +446,45 @@ func NewRadiusProperty(params Params) RadiusProperty {
return result
}
+// NewRadiusProperty creates the new RadiusProperty which having the same elliptical radii for all angles.
+// Arguments determines the x- and y-axis elliptic rounding radius. if an argument is specified as int or float64, the value is considered to be in pixels
+func NewEllipticRadius[xType SizeUnit | int | float64, yType SizeUnit | int | float64](x xType, y yType) RadiusProperty {
+ return NewRadiusProperty(Params{
+ X: x,
+ Y: y,
+ })
+}
+
+// NewRadius creates the new RadiusProperty.
+// The arguments specify the radii in a clockwise direction: "top-right", "bottom-right", "bottom-left", and "top-left".
+// if an argument is specified as int or float64, the value is considered to be in pixels
+func NewRadii[topRightType SizeUnit | int | float64, bottomRightType SizeUnit | int | float64, bottomLeftType SizeUnit | int | float64, topLeftType SizeUnit | int | float64](
+ topRight topRightType, bottomRight bottomRightType, bottomLeft bottomLeftType, topLeft topLeftType) RadiusProperty {
+ return NewRadiusProperty(Params{
+ TopRight: topRight,
+ BottomRight: bottomRight,
+ BottomLeft: bottomLeft,
+ TopLeft: topLeft,
+ })
+}
+
func radiusPropertyNormalize(tag PropertyName) PropertyName {
name := strings.TrimPrefix(strings.ToLower(string(tag)), "radius-")
return PropertyName(name)
}
+func (radius *radiusPropertyData) init() {
+ radius.dataProperty.init()
+ radius.normalize = radiusPropertyNormalize
+ radius.get = radiusPropertyGet
+ radius.remove = radiusPropertyRemove
+ radius.set = radiusPropertySet
+ radius.supportedProperties = []PropertyName{
+ X, Y, TopLeft, TopRight, BottomLeft, BottomRight, TopLeftX, TopLeftY,
+ TopRightX, TopRightY, BottomLeftX, BottomLeftY, BottomRightX, BottomRightY,
+ }
+}
+
func (radius *radiusPropertyData) writeString(buffer *strings.Builder, indent string) {
buffer.WriteString("_{ ")
comma := false
From 7bb90e5b2a19e8a678401c683c38f1c1c74b54f3 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Wed, 4 Dec 2024 18:45:08 +0300
Subject: [PATCH 29/43] Added New...Gradient functions
---
background.go | 40 +++++++++++++++++++++++
backgroundLinearGradient.go | 43 +++++++++++++++++++------
backgroundRadialGradient.go | 64 ++++++++++++++++++++++++++++++++++---
3 files changed, 132 insertions(+), 15 deletions(-)
diff --git a/background.go b/background.go
index 68e6b8f..235cb4e 100644
--- a/background.go
+++ b/background.go
@@ -143,6 +143,46 @@ func parseBackgroundValue(value any) []BackgroundElement {
return []BackgroundElement{element}
}
}
+
+ case []string:
+ elements := make([]BackgroundElement, 0, len(value))
+ for _, element := range value {
+ if obj := ParseDataText(element); obj != nil {
+ if element := createBackground(obj); element != nil {
+ elements = append(elements, element)
+ } else {
+ return nil
+ }
+ } else {
+ return nil
+ }
+ }
+ return elements
+
+ case []any:
+ elements := make([]BackgroundElement, 0, len(value))
+ for _, element := range value {
+ switch element := element.(type) {
+ case BackgroundElement:
+ elements = append(elements, element)
+
+ case string:
+ if obj := ParseDataText(element); obj != nil {
+ if element := createBackground(obj); element != nil {
+ elements = append(elements, element)
+ } else {
+ return nil
+ }
+ } else {
+ return nil
+ }
+
+ default:
+ return nil
+ }
+ }
+ return elements
+
}
return nil
diff --git a/backgroundLinearGradient.go b/backgroundLinearGradient.go
index 1760b9c..e93b00b 100644
--- a/backgroundLinearGradient.go
+++ b/backgroundLinearGradient.go
@@ -2,31 +2,33 @@ package rui
import "strings"
+type LinearGradientDirectionType int
+
// Constants related to view's background gradient description
const (
// ToTopGradient is value of the Direction property of a linear gradient. The value is equivalent to the 0deg angle
- ToTopGradient = 0
+ ToTopGradient LinearGradientDirectionType = 0
// ToRightTopGradient is value of the Direction property of a linear gradient.
- ToRightTopGradient = 1
+ ToRightTopGradient LinearGradientDirectionType = 1
// ToRightGradient is value of the Direction property of a linear gradient. The value is equivalent to the 90deg angle
- ToRightGradient = 2
+ ToRightGradient LinearGradientDirectionType = 2
// ToRightBottomGradient is value of the Direction property of a linear gradient.
- ToRightBottomGradient = 3
+ ToRightBottomGradient LinearGradientDirectionType = 3
// ToBottomGradient is value of the Direction property of a linear gradient. The value is equivalent to the 180deg angle
- ToBottomGradient = 4
+ ToBottomGradient LinearGradientDirectionType = 4
// ToLeftBottomGradient is value of the Direction property of a linear gradient.
- ToLeftBottomGradient = 5
+ ToLeftBottomGradient LinearGradientDirectionType = 5
// ToLeftGradient is value of the Direction property of a linear gradient. The value is equivalent to the 270deg angle
- ToLeftGradient = 6
+ ToLeftGradient LinearGradientDirectionType = 6
// ToLeftTopGradient is value of the Direction property of a linear gradient.
- ToLeftTopGradient = 7
+ ToLeftTopGradient LinearGradientDirectionType = 7
)
// BackgroundGradientPoint define point on gradient straight line
@@ -47,7 +49,14 @@ type backgroundLinearGradient struct {
backgroundGradient
}
-// NewBackgroundLinearGradient creates the new background linear gradient
+// NewBackgroundLinearGradient creates the new background linear gradient.
+// The following properties can be used:
+//
+// "gradient" (Gradient) - Describes gradient stop points. This is a mandatory property while describing background gradients.
+//
+// "direction" (Direction) - Defines the direction of the gradient line.
+//
+// "repeating" (Repeating) - Defines whether stop points needs to be repeated after the last one.
func NewBackgroundLinearGradient(params Params) BackgroundElement {
result := new(backgroundLinearGradient)
result.init()
@@ -57,6 +66,18 @@ func NewBackgroundLinearGradient(params Params) BackgroundElement {
return result
}
+// NewLinearGradient creates the new background linear gradient.
+func NewLinearGradient[DirectionType LinearGradientDirectionType | AngleUnit](direction DirectionType, repeating bool, point1 GradientPoint, point2 GradientPoint, points ...GradientPoint) BackgroundElement {
+ params := Params{
+ Direction: direction,
+ Gradient: append([]GradientPoint{point1, point2}, points...),
+ }
+ if repeating {
+ params[Repeating] = true
+ }
+ return NewBackgroundLinearGradient(params)
+}
+
func parseGradientText(value string) []BackgroundGradientPoint {
elements := strings.Split(value, ",")
count := len(elements)
@@ -289,7 +310,6 @@ func (gradient *backgroundLinearGradient) init() {
gradient.backgroundElement.init()
gradient.set = backgroundLinearGradientSet
gradient.supportedProperties = []PropertyName{Direction, Repeating, Gradient}
-
}
func (gradient *backgroundLinearGradient) Tag() string {
@@ -319,6 +339,9 @@ func backgroundLinearGradientSet(properties Properties, tag PropertyName, value
properties.setRaw(Direction, angle)
return []PropertyName{tag}
}
+
+ case LinearGradientDirectionType:
+ return setEnumProperty(properties, tag, int(value), enumProperties[Direction].values)
}
return setEnumProperty(properties, tag, value, enumProperties[Direction].values)
}
diff --git a/backgroundRadialGradient.go b/backgroundRadialGradient.go
index 85956c6..acad729 100644
--- a/backgroundRadialGradient.go
+++ b/backgroundRadialGradient.go
@@ -2,6 +2,8 @@ package rui
import "strings"
+type RadialGradientRadiusType int
+
// Constants related to view's background gradient description
const (
// EllipseGradient is value of the Shape property of a radial gradient background:
@@ -15,29 +17,40 @@ const (
// ClosestSideGradient is value of the Radius property of a radial gradient background:
// The gradient's ending shape meets the side of the box closest to its center (for circles)
// or meets both the vertical and horizontal sides closest to the center (for ellipses).
- ClosestSideGradient = 0
+ ClosestSideGradient RadialGradientRadiusType = 0
// ClosestCornerGradient is value of the Radius property of a radial gradient background:
// The gradient's ending shape is sized so that it exactly meets the closest corner
// of the box from its center.
- ClosestCornerGradient = 1
+ ClosestCornerGradient RadialGradientRadiusType = 1
// FarthestSideGradient is value of the Radius property of a radial gradient background:
// Similar to closest-side, except the ending shape is sized to meet the side of the box
// farthest from its center (or vertical and horizontal sides).
- FarthestSideGradient = 2
+ FarthestSideGradient RadialGradientRadiusType = 2
// FarthestCornerGradient is value of the Radius property of a radial gradient background:
// The default value, the gradient's ending shape is sized so that it exactly meets
// the farthest corner of the box from its center.
- FarthestCornerGradient = 3
+ FarthestCornerGradient RadialGradientRadiusType = 3
)
type backgroundRadialGradient struct {
backgroundGradient
}
-// NewBackgroundRadialGradient creates the new background radial gradient
+// NewBackgroundRadialGradient creates the new background radial gradient.
+// The following properties can be used:
+//
+// "gradient" (Gradient) - Describes gradient stop points. This is a mandatory property while describing background gradients.
+//
+// "center-x" (CenterX), "center-y" (CenterY) - Defines the gradient center point cooordinates.
+//
+// "radial-gradient-radius" (RadialGradientRadius) - Defines radius of the radial gradient.
+//
+// "radial-gradient-shape" (RadialGradientShape) - Defines shape of the radial gradient.
+//
+// "repeating" (Repeating) - Defines whether stop points needs to be repeated after the last one.
func NewBackgroundRadialGradient(params Params) BackgroundElement {
result := new(backgroundRadialGradient)
result.init()
@@ -47,6 +60,44 @@ func NewBackgroundRadialGradient(params Params) BackgroundElement {
return result
}
+// NewCircleRadialGradient creates the new background circle radial gradient.
+func NewCircleRadialGradient[radiusType SizeUnit | RadialGradientRadiusType](xCenter, yCenter SizeUnit, radius radiusType, repeating bool, point1 GradientPoint, point2 GradientPoint, points ...GradientPoint) BackgroundElement {
+ params := Params{
+ RadialGradientShape: CircleGradient,
+ Gradient: append([]GradientPoint{point1, point2}, points...),
+ RadialGradientRadius: radius,
+ }
+ if xCenter.Type != Auto {
+ params[CenterX] = xCenter
+ }
+ if yCenter.Type != Auto {
+ params[CenterY] = yCenter
+ }
+ if repeating {
+ params[Repeating] = true
+ }
+ return NewBackgroundRadialGradient(params)
+}
+
+// NewCircleRadialGradient creates the new background ellipse radial gradient.
+func NewEllipseRadialGradient[radiusType []SizeUnit | RadialGradientRadiusType](xCenter, yCenter SizeUnit, radius radiusType, repeating bool, point1 GradientPoint, point2 GradientPoint, points ...GradientPoint) BackgroundElement {
+ params := Params{
+ RadialGradientShape: EllipseGradient,
+ Gradient: append([]GradientPoint{point1, point2}, points...),
+ RadialGradientRadius: radius,
+ }
+ if xCenter.Type != Auto {
+ params[CenterX] = xCenter
+ }
+ if yCenter.Type != Auto {
+ params[CenterY] = yCenter
+ }
+ if repeating {
+ params[Repeating] = true
+ }
+ return NewBackgroundRadialGradient(params)
+}
+
func (gradient *backgroundRadialGradient) init() {
gradient.backgroundElement.init()
gradient.normalize = normalizeRadialGradientTag
@@ -144,6 +195,9 @@ func backgroundRadialGradientSet(properties Properties, tag PropertyName, value
}
return []PropertyName{tag}
+ case RadialGradientRadiusType:
+ return setEnumProperty(properties, RadialGradientRadius, int(value), enumProperties[RadialGradientRadius].values)
+
case int:
return setEnumProperty(properties, RadialGradientRadius, value, enumProperties[RadialGradientRadius].values)
}
From cccf1e6ee17124cf3678e77ce07d1c95660b247e Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Wed, 4 Dec 2024 19:27:33 +0300
Subject: [PATCH 30/43] Added conic gradient to canvas
---
canvas.go | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/canvas.go b/canvas.go
index 804264f..6fb405b 100644
--- a/canvas.go
+++ b/canvas.go
@@ -198,6 +198,24 @@ type Canvas interface {
// stopPoints - the array of stop points
SetRadialGradientStrokeStyle(x0, y0, r0 float64, color0 Color, x1, y1, r1 float64, color1 Color, stopPoints []GradientPoint)
+ // SetConicGradientFillStyle sets a conic gradient around a point
+ // to use inside shapes
+ // x, y - coordinates of the center of the conic gradient in pilels;
+ // startAngle - the angle at which to begin the gradient, in radians. The angle starts from a line going horizontally right from the center, and proceeds clockwise.
+ // startColor - the start color;
+ // endColor - the end color;
+ // stopPoints - the array of stop points. The Pos field of GradientPoint, in the range from 0 to 1, specifies the angle in turns.
+ SetConicGradientFillStyle(x, y, startAngle float64, startColor, endColor Color, stopPoints []GradientPoint)
+
+ // SetConicGradientFillStyle sets a conic gradient around a point
+ // to use inside shapes
+ // x, y - coordinates of the center of the conic gradient in pilels;
+ // startAngle - the angle at which to begin the gradient, in radians. The angle starts from a line going horizontally right from the center, and proceeds clockwise.
+ // startColor - the start color;
+ // endColor - the end color;
+ // stopPoints - the array of stop points. The Pos field of GradientPoint, in the range from 0 to 1, specifies the angle in turns.
+ SetConicGradientStrokeStyle(x, y, startAngle float64, startColor, endColor Color, stopPoints []GradientPoint)
+
// SetImageFillStyle set the image as the filling pattern.
// repeat - indicating how to repeat the pattern's image. Possible values are:
// NoRepeat (0) - neither direction,
@@ -465,6 +483,30 @@ func (canvas *canvasData) SetRadialGradientStrokeStyle(x0, y0, r0 float64, color
canvas.session.updateCanvasProperty("strokeStyle", gradient)
}
+func (canvas *canvasData) createConicGradient(x, y, startAngle float64, startColor, endColor Color, stopPoints []GradientPoint) any {
+ gradient := canvas.session.createCanvasVar("createConicGradient", startAngle, x, y)
+ canvas.session.callCanvasVarFunc(gradient, "addColorStop", 0, startColor.cssString())
+
+ for _, point := range stopPoints {
+ if point.Offset >= 0 && point.Offset <= 1 {
+ canvas.session.callCanvasVarFunc(gradient, "addColorStop", point.Offset, point.Color.cssString())
+ }
+ }
+
+ canvas.session.callCanvasVarFunc(gradient, "addColorStop", 1, endColor.cssString())
+ return gradient
+}
+
+func (canvas *canvasData) SetConicGradientFillStyle(x, y, startAngle float64, startColor, endColor Color, stopPoints []GradientPoint) {
+ gradient := canvas.createConicGradient(x, y, startAngle, startColor, endColor, stopPoints)
+ canvas.session.updateCanvasProperty("fillStyle", gradient)
+}
+
+func (canvas *canvasData) SetConicGradientStrokeStyle(x, y, startAngle float64, startColor, endColor Color, stopPoints []GradientPoint) {
+ gradient := canvas.createConicGradient(x, y, startAngle, startColor, endColor, stopPoints)
+ canvas.session.updateCanvasProperty("strokeStyle", gradient)
+}
+
func (canvas *canvasData) SetImageFillStyle(image Image, repeat int) {
if image == nil || image.LoadingStatus() != ImageReady {
return
From 0919376f096abfaaf3cd7a232be513d6593b6145 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Wed, 4 Dec 2024 19:35:28 +0300
Subject: [PATCH 31/43] Updated CHANGELOG.md
---
CHANGELOG.md | 6 ++++--
backgroundRadialGradient.go | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6e3c8a0..1a81998 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,10 +18,12 @@
NewInsetViewShadow function -> NewInsetShadow
NewShadowWithParams function -> NewShadowProperty
-* Added functions: NewBounds, NewEllipticRadius, NewRadii,
-GetPushTransform, GetPushDuration, GetPushTiming, IsMoveToFrontAnimation,
+* Added functions: NewBounds, NewEllipticRadius, NewRadii, NewLinearGradient, NewCircleRadialGradient,
+NewEllipseRadialGradient, GetPushTransform, GetPushDuration, GetPushTiming, IsMoveToFrontAnimation,
GetBackground, GetMask, GetBackgroundClip,GetBackgroundOrigin, GetMaskClip, GetMaskOrigin.
+* Added SetConicGradientFillStyle and SetConicGradientStrokeStyle methods to Canvas interface.
+
* Changed Push, Pop, MoveToFront, and MoveToFrontByID methods of StackLayout interface.
* Removed DefaultAnimation, StartToEndAnimation, EndToStartAnimation, TopDownAnimation, and BottomUpAnimation constants.
diff --git a/backgroundRadialGradient.go b/backgroundRadialGradient.go
index acad729..e39a3d7 100644
--- a/backgroundRadialGradient.go
+++ b/backgroundRadialGradient.go
@@ -79,7 +79,7 @@ func NewCircleRadialGradient[radiusType SizeUnit | RadialGradientRadiusType](xCe
return NewBackgroundRadialGradient(params)
}
-// NewCircleRadialGradient creates the new background ellipse radial gradient.
+// NewEllipseRadialGradient creates the new background ellipse radial gradient.
func NewEllipseRadialGradient[radiusType []SizeUnit | RadialGradientRadiusType](xCenter, yCenter SizeUnit, radius radiusType, repeating bool, point1 GradientPoint, point2 GradientPoint, points ...GradientPoint) BackgroundElement {
params := Params{
RadialGradientShape: EllipseGradient,
From a8242c99fe19e5d9bc40ed236439cccff818930a Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Thu, 5 Dec 2024 20:15:39 +0300
Subject: [PATCH 32/43] Updated doc comments
---
CHANGELOG.md | 3 +-
angleUnit.go | 4 +
animation.go | 99 +-
animationEvents.go | 119 +-
appWasm.go | 2 +-
background.go | 47 +-
backgroundConicGradient.go | 7 +
backgroundImage.go | 19 +
backgroundLinearGradient.go | 12 +-
backgroundRadialGradient.go | 16 +-
border.go | 120 +-
bounds.go | 3 +
canvas.go | 106 +-
checkbox.go | 14 +-
color.go | 8 +
colorPicker.go | 18 +-
columnLayout.go | 82 +-
columnSeparator.go | 28 +-
dataList.go | 109 +-
datePicker.go | 110 +-
detailsView.go | 19 +-
dropDownList.go | 13 +-
editView.go | 54 +-
filePicker.go | 28 +-
focusEvents.go | 12 +-
gridLayout.go | 68 +-
imageView.go | 12 +-
keyEvents.go | 32 +-
listView.go | 61 +-
mediaPlayer.go | 597 ++-------
mouseEvents.go | 128 +-
numberPicker.go | 58 +-
outline.go | 7 +-
path.go | 40 +-
pointerEvents.go | 96 +-
popup.go | 154 ++-
popupUtils.go | 3 +
progressBar.go | 12 +-
propertyNames.go | 2535 +++++++++++++++++------------------
propertyValues.go | 6 +-
radius.go | 342 +++--
resizable.go | 22 +-
resizeEvent.go | 16 +-
scrollEvent.go | 16 +-
shadow.go | 130 +-
sizeFunc.go | 2 +
stackLayout.go | 174 +--
tableAdapter.go | 26 +-
tableView.go | 402 +++---
tabsLayout.go | 82 +-
timePicker.go | 74 +-
touchEvents.go | 64 +-
transform.go | 306 ++---
videoPlayer.go | 16 +-
view.go | 4 +-
viewClip.go | 11 +-
viewFilter.go | 74 +-
viewUtils.go | 13 +-
58 files changed, 3121 insertions(+), 3514 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1a81998..6936f2d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,10 +17,11 @@
NewViewShadow function -> NewShadow
NewInsetViewShadow function -> NewInsetShadow
NewShadowWithParams function -> NewShadowProperty
+ NewColumnSeparator function -> NewColumnSeparatorProperty
* Added functions: NewBounds, NewEllipticRadius, NewRadii, NewLinearGradient, NewCircleRadialGradient,
NewEllipseRadialGradient, GetPushTransform, GetPushDuration, GetPushTiming, IsMoveToFrontAnimation,
-GetBackground, GetMask, GetBackgroundClip,GetBackgroundOrigin, GetMaskClip, GetMaskOrigin.
+GetBackground, GetMask, GetBackgroundClip,GetBackgroundOrigin, GetMaskClip, GetMaskOrigin, NewColumnSeparator.
* Added SetConicGradientFillStyle and SetConicGradientStrokeStyle methods to Canvas interface.
diff --git a/angleUnit.go b/angleUnit.go
index dae0d5a..422aa0f 100644
--- a/angleUnit.go
+++ b/angleUnit.go
@@ -15,12 +15,16 @@ type AngleUnitType uint8
const (
// Radian - angle in radians
Radian AngleUnitType = 0
+
// Radian - angle in radians * π
PiRadian AngleUnitType = 1
+
// Degree - angle in degrees
Degree AngleUnitType = 2
+
// Gradian - angle in gradian (1⁄400 of a full circle)
Gradian AngleUnitType = 3
+
// Turn - angle in turns (1 turn = 360 degree)
Turn AngleUnitType = 4
)
diff --git a/animation.go b/animation.go
index 6d5afb7..b187f20 100644
--- a/animation.go
+++ b/animation.go
@@ -11,132 +11,146 @@ import (
const (
// AnimationTag is the constant for "animation" property tag.
//
- // Used by `View`.
+ // Used by View.
// Sets and starts animations.
//
- // Supported types: `Animation`, `[]Animation`.
+ // Supported types: Animation, []Animation.
//
- // Internal type is `[]Animation`, other types converted to it during assignment.
- // See `Animation` description for more details.
+ // Internal type is []Animation, other types converted to it during assignment.
+ // See Animation description for more details.
AnimationTag PropertyName = "animation"
// AnimationPaused is the constant for "animation-paused" property tag.
//
- // Used by `Animation`.
+ // Used by Animation.
// Controls whether the animation is running or paused.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - Animation is paused.
- // `false` or `0` or "false", "no", "off", "0" - Animation is playing.
+ // - true, 1, "true", "yes", "on", or "1" - Animation is paused.
+ // - false, 0, "false", "no", "off", or "0" - Animation is playing.
AnimationPaused PropertyName = "animation-paused"
// Transition is the constant for "transition" property tag.
//
- // Used by `View`.
- // Sets transition animation of view properties. Each provided property must contain `Animation` which describe how
+ // Used by View.
+ //
+ // Sets transition animation of view properties. Each provided property must contain Animation which describe how
// particular property will be animated on property value change. Transition animation can be applied to properties of the
- // type `SizeUnit`, `Color`, `AngleUnit`, `float64` and composite properties that contain elements of the listed types(for
- // example, "shadow", "border", etc.). If we'll try to animate other properties with internal type like `bool` or
- // `string` no error will occur, simply there will be no animation.
+ // type SizeUnit, Color, AngleUnit, float64 and composite properties that contain elements of the listed types(for
+ // example, "shadow", "border", etc.). If we'll try to animate other properties with internal type like bool or
+ // string no error will occur, simply there will be no animation.
//
- // Supported types: `Params`.
+ // Supported types: Params.
//
- // See `Params` description for more details.
+ // See Params description for more details.
Transition PropertyName = "transition"
// PropertyTag is the constant for "property" property tag.
//
- // Used by `Animation`.
- // Describes a scenario for changing a `View`'s property. Used only for animation script.
+ // Used by Animation.
//
- // Supported types: `[]AnimatedProperty`, `AnimatedProperty`.
+ // Describes a scenario for changing a View's property. Used only for animation script.
//
- // Internal type is `[]AnimatedProperty`, other types converted to it during assignment.
- // See `AnimatedProperty` description for more details.
+ // Supported types: []AnimatedProperty, AnimatedProperty.
+ //
+ // Internal type is []AnimatedProperty, other types converted to it during assignment.
+ // See AnimatedProperty description for more details.
PropertyTag PropertyName = "property"
// Duration is the constant for "duration" property tag.
//
- // Used by `Animation`.
+ // Used by Animation.
+ //
// Sets the length of time in seconds that an animation takes to complete one cycle.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
Duration PropertyName = "duration"
// Delay is the constant for "delay" property tag.
//
- // Used by `Animation`.
+ // Used by Animation.
+ //
// Specifies the amount of time in seconds to wait from applying the animation to an element before beginning to perform
// the animation. The animation can start later, immediately from its beginning or immediately and partway through the
// animation.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
Delay PropertyName = "delay"
// TimingFunction is the constant for "timing-function" property tag.
//
- // Used by `Animation`.
+ // Used by Animation.
+ //
// Set how an animation progresses through the duration of each cycle.
//
- // Supported types: `string`.
+ // Supported types: string.
//
// Values:
- // "ease"(`EaseTiming`) - Speed increases towards the middle and slows down at the end.
- // "ease-in"(`EaseInTiming`) - Speed is slow at first, but increases in the end.
- // "ease-out"(`EaseOutTiming`) - Speed is fast at first, but decreases in the end.
- // "ease-in-out"(`EaseInOutTiming`) - Speed is slow at first, but quickly increases and at the end it decreases again.
- // "linear"(`LinearTiming`) - Constant speed.
+ // - "ease" (EaseTiming) - Speed increases towards the middle and slows down at the end.
+ // - "ease-in" (EaseInTiming) - Speed is slow at first, but increases in the end.
+ // - "ease-out" (EaseOutTiming) - Speed is fast at first, but decreases in the end.
+ // - "ease-in-out" (EaseInOutTiming) - Speed is slow at first, but quickly increases and at the end it decreases again.
+ // - "linear" (LinearTiming) - Constant speed.
+ // - "step(n)" (StepTiming(n int) function) - Timing function along stepCount stops along the transition, displaying each stop for equal lengths of time.
+ // - "cubic-bezier(x1, y1, x2, y2)" (CubicBezierTiming(x1, y1, x2, y2 float64) function) - Cubic-Bezier curve timing function. x1 and x2 must be in the range [0, 1].
TimingFunction PropertyName = "timing-function"
// IterationCount is the constant for "iteration-count" property tag.
//
- // Used by `Animation`.
+ // Used by Animation.
+ //
// Sets the number of times an animation sequence should be played before stopping. Used only for animation script.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
- // Internal type is `int`, other types converted to it during assignment.
+ // Internal type is int, other types converted to it during assignment.
IterationCount PropertyName = "iteration-count"
// AnimationDirection is the constant for "animation-direction" property tag.
//
- // Used by `Animation`.
+ // Used by Animation.
+ //
// Whether an animation should play forward, backward, or alternate back and forth between playing the sequence forward
// and backward. Used only for animation script.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NormalAnimation`) or "normal" - The animation plays forward every iteration, that is, when the animation ends, it is immediately reset to its starting position and played again.
- // `1`(`ReverseAnimation`) or "reverse" - The animation plays backwards, from the last position to the first, and then resets to the final position and plays again.
- // `2`(`AlternateAnimation`) or "alternate" - The animation changes direction in each cycle, that is, in the first cycle, it starts from the start position, reaches the end position, and in the second cycle, it continues from the end position and reaches the start position, and so on.
- // `3`(`AlternateReverseAnimation`) or "alternate-reverse" - The animation starts playing from the end position and reaches the start position, and in the next cycle, continuing from the start position, it goes to the end position.
+ // - 0 (NormalAnimation) or "normal" - The animation plays forward every iteration, that is, when the animation ends, it is immediately reset to its starting position and played again.
+ // - 1 (ReverseAnimation) or "reverse" - The animation plays backwards, from the last position to the first, and then resets to the final position and plays again.
+ // - 2 (AlternateAnimation) or "alternate" - The animation changes direction in each cycle, that is, in the first cycle, it starts from the start position, reaches the end position, and in the second cycle, it continues from the end position and reaches the start position, and so on.
+ // - 3 (AlternateReverseAnimation) or "alternate-reverse" - The animation starts playing from the end position and reaches the start position, and in the next cycle, continuing from the start position, it goes to the end position.
AnimationDirection PropertyName = "animation-direction"
// NormalAnimation is value of the "animation-direction" property.
+ //
// The animation plays forwards each cycle. In other words, each time the animation cycles,
// the animation will reset to the beginning state and start over again. This is the default value.
NormalAnimation = 0
// ReverseAnimation is value of the "animation-direction" property.
+ //
// The animation plays backwards each cycle. In other words, each time the animation cycles,
// the animation will reset to the end state and start over again. Animation steps are performed
// backwards, and timing functions are also reversed.
+ //
// For example, an "ease-in" timing function becomes "ease-out".
ReverseAnimation = 1
// AlternateAnimation is value of the "animation-direction" property.
+ //
// The animation reverses direction each cycle, with the first iteration being played forwards.
// The count to determine if a cycle is even or odd starts at one.
AlternateAnimation = 2
// AlternateReverseAnimation is value of the "animation-direction" property.
+ //
// The animation reverses direction each cycle, with the first iteration being played backwards.
// The count to determine if a cycle is even or odd starts at one.
AlternateReverseAnimation = 3
@@ -200,6 +214,7 @@ type animationData struct {
}
// Animation interface is used to set animation parameters. Used properties:
+//
// "property", "id", "duration", "delay", "timing-function", "iteration-count", and "animation-direction"
type Animation interface {
Properties
diff --git a/animationEvents.go b/animationEvents.go
index f666de6..2fd7028 100644
--- a/animationEvents.go
+++ b/animationEvents.go
@@ -4,154 +4,155 @@ package rui
const (
// TransitionRunEvent is the constant for "transition-run-event" property tag.
//
- // Used by `View`.
+ // Used by View:
// Is fired when a transition is first created, i.e. before any transition delay has begun.
//
// General listener format:
- // `func(view rui.View, propertyName string)`.
+ // func(view rui.View, propertyName rui.PropertyName).
//
// where:
- // view - Interface of a view which generated this event,
- // propertyName - Name of the property.
+ // - view - Interface of a view which generated this event,
+ // - propertyName - Name of the property.
//
// Allowed listener formats:
- // `func(view rui.View)`,
- // `func(propertyName string)`,
- // `func()`.
+ // func(view rui.View),
+ // func(propertyName rui.PropertyName)
+ // func().
TransitionRunEvent PropertyName = "transition-run-event"
// TransitionStartEvent is the constant for "transition-start-event" property tag.
//
- // Used by `View`.
+ // Used by View:
// Is fired when a transition has actually started, i.e., after "delay" has ended.
//
// General listener format:
- // `func(view rui.View, propertyName string)`.
+ // func(view rui.View, propertyName rui.PropertyName).
//
// where:
- // view - Interface of a view which generated this event,
- // propertyName - Name of the property.
+ // - view - Interface of a view which generated this event,
+ // - propertyName - Name of the property.
//
// Allowed listener formats:
- // `func(view rui.View)`,
- // `func(propertyName string)`,
- // `func()`.
+ // func(view rui.View)
+ // func(propertyName rui.PropertyName)
+ // func()
TransitionStartEvent PropertyName = "transition-start-event"
// TransitionEndEvent is the constant for "transition-end-event" property tag.
//
- // Used by `View`.
+ // Used by View:
// Is fired when a transition has completed.
//
// General listener format:
- // `func(view rui.View, propertyName string)`.
+ // func(view rui.View, propertyName rui.PropertyName).
//
// where:
- // view - Interface of a view which generated this event,
- // propertyName - Name of the property.
+ // - view - Interface of a view which generated this event,
+ // - propertyName - Name of the property.
//
// Allowed listener formats:
- // `func(view rui.View)`,
- // `func(propertyName string)`,
- // `func()`.
+ // func(view rui.View)
+ // func(propertyName rui.PropertyName)
+ // func()
TransitionEndEvent PropertyName = "transition-end-event"
// TransitionCancelEvent is the constant for "transition-cancel-event" property tag.
//
- // Used by `View`.
- // Is fired when a transition is cancelled. The transition is cancelled when: * A new property transition has begun. * The
- // "visibility" property is set to "gone". * The transition is stopped before it has run to completion, e.g. by moving the
- // mouse off a hover-transitioning view.
+ // Used by View:
+ // Is fired when a transition is cancelled. The transition is cancelled when:
+ // - A new property transition has begun.
+ // - The "visibility" property is set to "gone".
+ // - The transition is stopped before it has run to completion, e.g. by moving the mouse off a hover-transitioning view.
//
// General listener format:
- // `func(view rui.View, propertyName string)`.
+ // func(view rui.View, propertyName rui.PropertyName).
//
// where:
- // view - Interface of a view which generated this event,
- // propertyName - Name of the property.
+ // - view - Interface of a view which generated this event,
+ // - propertyName - Name of the property.
//
// Allowed listener formats:
- // `func(view rui.View)`,
- // `func(propertyName string)`,
- // `func()`.
+ // func(view rui.View)
+ // func(propertyName rui.PropertyName)
+ // func()
TransitionCancelEvent PropertyName = "transition-cancel-event"
// AnimationStartEvent is the constant for "animation-start-event" property tag.
//
- // Used by `View`.
+ // Used by View:
// Fired when an animation has started. If there is an "animation-delay", this event will fire once the delay period has
// expired.
//
// General listener format:
- // `func(view rui.View, animationId string)`.
+ // func(view rui.View, animationId string).
//
// where:
- // view - Interface of a view which generated this event,
- // animationId - Id of the animation.
+ // - view - Interface of a view which generated this event,
+ // - animationId - Id of the animation.
//
// Allowed listener formats:
- // `func(view rui.View)`,
- // `func(animationId string)`,
- // `func()`.
+ // func(view rui.View)
+ // func(animationId string)
+ // func()
AnimationStartEvent PropertyName = "animation-start-event"
// AnimationEndEvent is the constant for "animation-end-event" property tag.
//
- // Used by `View`.
+ // Used by View:
// Fired when an animation has completed. If the animation aborts before reaching completion, such as if the element is
// removed or the animation is removed from the element, the "animation-end-event" is not fired.
//
// General listener format:
- // `func(view rui.View, animationId string)`.
+ // func(view rui.View, animationId string).
//
// where:
- // view - Interface of a view which generated this event,
- // animationId - Id of the animation.
+ // - view - Interface of a view which generated this event,
+ // - animationId - Id of the animation.
//
// Allowed listener formats:
- // `func(view rui.View)`,
- // `func(animationId string)`,
- // `func()`.
+ // func(view rui.View)
+ // func(animationId string)
+ // func()
AnimationEndEvent PropertyName = "animation-end-event"
// AnimationCancelEvent is the constant for "animation-cancel-event" property tag.
//
- // Used by `View`.
+ // Used by View:
// Fired when an animation unexpectedly aborts. In other words, any time it stops running without sending the
// "animation-end-event". This might happen when the animation-name is changed such that the animation is removed, or when
// the animating view is hidden. Therefore, either directly or because any of its containing views are hidden. The event
// is not supported by all browsers.
//
// General listener format:
- // `func(view rui.View, animationId string)`.
+ // func(view rui.View, animationId string).
//
// where:
- // view - Interface of a view which generated this event,
- // animationId - Id of the animation.
+ // - view - Interface of a view which generated this event,
+ // - animationId - Id of the animation.
//
// Allowed listener formats:
- // `func(view rui.View)`,
- // `func(animationId string)`,
- // `func()`.
+ // func(view rui.View)
+ // func(animationId string)
+ // func()
AnimationCancelEvent PropertyName = "animation-cancel-event"
// AnimationIterationEvent is the constant for "animation-iteration-event" property tag.
//
- // Used by `View`.
+ // Used by View:
// Fired when an iteration of an animation ends, and another one begins. This event does not occur at the same time as the
// animation end event, and therefore does not occur for animations with an "iteration-count" of one.
//
// General listener format:
- // `func(view rui.View, animationId string)`.
+ // func(view rui.View, animationId string).
//
// where:
- // view - Interface of a view which generated this event,
- // animationId - Id of the animation.
+ // - view - Interface of a view which generated this event,
+ // - animationId - Id of the animation.
//
// Allowed listener formats:
- // `func(view rui.View)`,
- // `func(animationId string)`,
- // `func()`.
+ // func(view rui.View)
+ // func(animationId string)
+ // func()
AnimationIterationEvent PropertyName = "animation-iteration-event"
)
diff --git a/appWasm.go b/appWasm.go
index 1a07c36..045e787 100644
--- a/appWasm.go
+++ b/appWasm.go
@@ -141,7 +141,7 @@ func (app *wasmApp) init(params AppParams) {
div := document.Call("createElement", "div")
div.Set("className", "ruiRoot")
div.Set("id", "ruiRootView")
- viewHTML(app.session.RootView(), buffer)
+ viewHTML(app.session.RootView(), buffer, "")
div.Set("innerHTML", buffer.String())
body.Call("appendChild", div)
diff --git a/background.go b/background.go
index 235cb4e..592cb68 100644
--- a/background.go
+++ b/background.go
@@ -6,36 +6,24 @@ import (
const (
// BorderBox is the value of the following properties:
- //
- // * BackgroundClip - The background extends to the outside edge of the border (but underneath the border in z-ordering).
- //
- // * BackgroundOrigin - The background is positioned relative to the border box.
- //
- // * MaskClip - The painted content is clipped to the border box.
- //
- // * MaskOrigin - The mask is positioned relative to the border box.
+ // - BackgroundClip - The background extends to the outside edge of the border (but underneath the border in z-ordering).
+ // - BackgroundOrigin - The background is positioned relative to the border box.
+ // - MaskClip - The painted content is clipped to the border box.
+ // - MaskOrigin - The mask is positioned relative to the border box.
BorderBox = 0
// PaddingBox is value of the BackgroundClip and MaskClip property:
- //
- // * BackgroundClip - The background extends to the outside edge of the padding. No background is drawn beneath the border.
- //
- // * BackgroundOrigin - The background is positioned relative to the padding box.
- //
- // * MaskClip - The painted content is clipped to the padding box.
- //
- // * MaskOrigin - The mask is positioned relative to the padding box.
+ // - BackgroundClip - The background extends to the outside edge of the padding. No background is drawn beneath the border.
+ // - BackgroundOrigin - The background is positioned relative to the padding box.
+ // - MaskClip - The painted content is clipped to the padding box.
+ // - MaskOrigin - The mask is positioned relative to the padding box.
PaddingBox = 1
// ContentBox is value of the BackgroundClip and MaskClip property:
- //
- // * BackgroundClip - The background is painted within (clipped to) the content box.
- //
- // * BackgroundOrigin - The background is positioned relative to the content box.
- //
- // * MaskClip - The painted content is clipped to the content box.
- //
- // * MaskOrigin - The mask is positioned relative to the content box.
+ // - BackgroundClip - The background is painted within (clipped to) the content box.
+ // - BackgroundOrigin - The background is positioned relative to the content box.
+ // - MaskClip - The painted content is clipped to the content box.
+ // - MaskOrigin - The mask is positioned relative to the content box.
ContentBox = 2
)
@@ -58,7 +46,6 @@ type backgroundElement struct {
dataProperty
}
-// NewBackgroundImage creates the new background image
func createBackground(obj DataObject) BackgroundElement {
var result BackgroundElement = nil
@@ -280,12 +267,14 @@ func backgroundStyledPropery(view View, subviewID []string, tag PropertyName) []
}
// GetBackground returns the view background.
+//
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetBackground(view View, subviewID ...string) []BackgroundElement {
return backgroundStyledPropery(view, subviewID, Background)
}
// GetMask returns the view mask.
+//
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetMask(view View, subviewID ...string) []BackgroundElement {
return backgroundStyledPropery(view, subviewID, Mask)
@@ -293,7 +282,7 @@ func GetMask(view View, subviewID ...string) []BackgroundElement {
// GetBackgroundClip returns a "background-clip" of the subview. Returns one of next values:
//
-// BorderBox (0), PaddingBox (1), ContentBox (2)
+// BorderBox (0), PaddingBox (1), ContentBox (2)
//
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetBackgroundClip(view View, subviewID ...string) int {
@@ -302,7 +291,7 @@ func GetBackgroundClip(view View, subviewID ...string) int {
// GetBackgroundOrigin returns a "background-origin" of the subview. Returns one of next values:
//
-// BorderBox (0), PaddingBox (1), ContentBox (2)
+// BorderBox (0), PaddingBox (1), ContentBox (2)
//
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetBackgroundOrigin(view View, subviewID ...string) int {
@@ -311,7 +300,7 @@ func GetBackgroundOrigin(view View, subviewID ...string) int {
// GetMaskClip returns a "mask-clip" of the subview. Returns one of next values:
//
-// BorderBox (0), PaddingBox (1), ContentBox (2)
+// BorderBox (0), PaddingBox (1), ContentBox (2)
//
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetMaskClip(view View, subviewID ...string) int {
@@ -320,7 +309,7 @@ func GetMaskClip(view View, subviewID ...string) int {
// GetMaskOrigin returns a "mask-origin" of the subview. Returns one of next values:
//
-// BorderBox (0), PaddingBox (1), ContentBox (2)
+// BorderBox (0), PaddingBox (1), ContentBox (2)
//
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetMaskOrigin(view View, subviewID ...string) int {
diff --git a/backgroundConicGradient.go b/backgroundConicGradient.go
index c441fe9..f44524f 100644
--- a/backgroundConicGradient.go
+++ b/backgroundConicGradient.go
@@ -19,6 +19,13 @@ type BackgroundGradientAngle struct {
}
// NewBackgroundConicGradient creates the new background conic gradient
+//
+// The following properties can be used:
+// - "gradient" [Gradient] - Describes gradient stop points. This is a mandatory property while describing background gradients.
+// - "center-x" [CenterX] - center X point of the gradient.
+// - "center-y" [CenterY] - center Y point of the gradient.
+// - "from" [From] - start angle position of the gradient.
+// - "repeating" [Repeating] - Defines whether stop points needs to be repeated after the last one.
func NewBackgroundConicGradient(params Params) BackgroundElement {
result := new(backgroundConicGradient)
result.init()
diff --git a/backgroundImage.go b/backgroundImage.go
index aac13fb..37dcd95 100644
--- a/backgroundImage.go
+++ b/backgroundImage.go
@@ -7,50 +7,59 @@ import (
// Constants related to view's background description
const (
// NoRepeat is value of the Repeat property of an background image:
+ //
// The image is not repeated (and hence the background image painting area
// will not necessarily be entirely covered). The position of the non-repeated
// background image is defined by the background-position CSS property.
NoRepeat = 0
// RepeatXY is value of the Repeat property of an background image:
+ //
// The image is repeated as much as needed to cover the whole background
// image painting area. The last image will be clipped if it doesn't fit.
RepeatXY = 1
// RepeatX is value of the Repeat property of an background image:
+ //
// The image is repeated horizontally as much as needed to cover
// the whole width background image painting area. The image is not repeated vertically.
// The last image will be clipped if it doesn't fit.
RepeatX = 2
// RepeatY is value of the Repeat property of an background image:
+ //
// The image is repeated vertically as much as needed to cover
// the whole height background image painting area. The image is not repeated horizontally.
// The last image will be clipped if it doesn't fit.
RepeatY = 3
// RepeatRound is value of the Repeat property of an background image:
+ //
// As the allowed space increases in size, the repeated images will stretch (leaving no gaps)
// until there is room (space left >= half of the image width) for another one to be added.
// When the next image is added, all of the current ones compress to allow room.
RepeatRound = 4
// RepeatSpace is value of the Repeat property of an background image:
+ //
// The image is repeated as much as possible without clipping. The first and last images
// are pinned to either side of the element, and whitespace is distributed evenly between the images.
RepeatSpace = 5
// ScrollAttachment is value of the Attachment property of an background image:
+ //
// The background is fixed relative to the element itself and does not scroll with its contents.
// (It is effectively attached to the element's border.)
ScrollAttachment = 0
// FixedAttachment is value of the Attachment property of an background image:
+ //
// The background is fixed relative to the viewport. Even if an element has
// a scrolling mechanism, the background doesn't move with the element.
FixedAttachment = 1
// LocalAttachment is value of the Attachment property of an background image:
+ //
// The background is fixed relative to the element's contents. If the element has a scrolling mechanism,
// the background scrolls with the element's contents, and the background painting area
// and background positioning area are relative to the scrollable area of the element
@@ -63,6 +72,16 @@ type backgroundImage struct {
}
// NewBackgroundImage creates the new background image
+//
+// The following properties can be used:
+// - "src" [Source] - the name of the image in the "images" folder of the resources, or the URL of the image or inline-image.
+// - "width" [Width] - the width of the image.
+// - "height" [Height] - the height of the image.
+// - "image-horizontal-align" [ImageHorizontalAlign] - the horizontal alignment of the image relative to view's bounds.
+// - "image-vertical-align" [ImageVerticalAlign] - the vertical alignment of the image relative to view's bounds.
+// - "repeat" [Repeat] - the repetition of the image.
+// - "fit" [Fit] - the image scaling parameters.
+// - "attachment" [Attachment] - defines whether a background image's position is fixed within the viewport or scrolls with its containing block.
func NewBackgroundImage(params Params) BackgroundElement {
result := new(backgroundImage)
result.init()
diff --git a/backgroundLinearGradient.go b/backgroundLinearGradient.go
index e93b00b..4eb7ec7 100644
--- a/backgroundLinearGradient.go
+++ b/backgroundLinearGradient.go
@@ -37,7 +37,7 @@ type BackgroundGradientPoint struct {
// Can take a value of Color type or string (color constant or textual description of the color)
Color any
// Pos - the distance from the start of the gradient straight line. Optional (may be nil).
- // Can take a value of SizeUnit type or string (angle constant or textual description of the SizeUnit)
+ // Can take a value of SizeUnit type or string (size constant or textual description of the SizeUnit)
Pos any
}
@@ -50,13 +50,11 @@ type backgroundLinearGradient struct {
}
// NewBackgroundLinearGradient creates the new background linear gradient.
+//
// The following properties can be used:
-//
-// "gradient" (Gradient) - Describes gradient stop points. This is a mandatory property while describing background gradients.
-//
-// "direction" (Direction) - Defines the direction of the gradient line.
-//
-// "repeating" (Repeating) - Defines whether stop points needs to be repeated after the last one.
+// - "gradient" [Gradient] - Describes gradient stop points. This is a mandatory property while describing background gradients.
+// - "direction" [Direction] - Defines the direction of the gradient line.
+// - "repeating" [Repeating] - Defines whether stop points needs to be repeated after the last one.
func NewBackgroundLinearGradient(params Params) BackgroundElement {
result := new(backgroundLinearGradient)
result.init()
diff --git a/backgroundRadialGradient.go b/backgroundRadialGradient.go
index e39a3d7..d126899 100644
--- a/backgroundRadialGradient.go
+++ b/backgroundRadialGradient.go
@@ -40,17 +40,13 @@ type backgroundRadialGradient struct {
}
// NewBackgroundRadialGradient creates the new background radial gradient.
+//
// The following properties can be used:
-//
-// "gradient" (Gradient) - Describes gradient stop points. This is a mandatory property while describing background gradients.
-//
-// "center-x" (CenterX), "center-y" (CenterY) - Defines the gradient center point cooordinates.
-//
-// "radial-gradient-radius" (RadialGradientRadius) - Defines radius of the radial gradient.
-//
-// "radial-gradient-shape" (RadialGradientShape) - Defines shape of the radial gradient.
-//
-// "repeating" (Repeating) - Defines whether stop points needs to be repeated after the last one.
+// - "gradient" (Gradient) - Describes gradient stop points. This is a mandatory property while describing background gradients.
+// - "center-x" (CenterX), "center-y" (CenterY) - Defines the gradient center point cooordinates.
+// - "radial-gradient-radius" (RadialGradientRadius) - Defines radius of the radial gradient.
+// - "radial-gradient-shape" (RadialGradientShape) - Defines shape of the radial gradient.
+// - "repeating" (Repeating) - Defines whether stop points needs to be repeated after the last one.
func NewBackgroundRadialGradient(params Params) BackgroundElement {
result := new(backgroundRadialGradient)
result.init()
diff --git a/border.go b/border.go
index 209ea80..a4cfef7 100644
--- a/border.go
+++ b/border.go
@@ -27,150 +27,150 @@ const (
// LeftStyle is the constant for "left-style" property tag.
//
- // Used by `BorderProperty`.
+ // Used by BorderProperty.
// Left border line style.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneLine`) or "none" - The border will not be drawn.
- // `1`(`SolidLine`) or "solid" - Solid line as a border.
- // `2`(`DashedLine`) or "dashed" - Dashed line as a border.
- // `3`(`DottedLine`) or "dotted" - Dotted line as a border.
- // `4`(`DoubleLine`) or "double" - Double line as a border.
+ // - 0 (NoneLine) or "none" - The border will not be drawn.
+ // - 1 (SolidLine) or "solid" - Solid line as a border.
+ // - 2 (DashedLine) or "dashed" - Dashed line as a border.
+ // - 3 (DottedLine) or "dotted" - Dotted line as a border.
+ // - 4 (DoubleLine) or "double" - Double line as a border.
LeftStyle PropertyName = "left-style"
// RightStyle is the constant for "right-style" property tag.
//
- // Used by `BorderProperty`.
+ // Used by BorderProperty.
// Right border line style.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneLine`) or "none" - The border will not be drawn.
- // `1`(`SolidLine`) or "solid" - Solid line as a border.
- // `2`(`DashedLine`) or "dashed" - Dashed line as a border.
- // `3`(`DottedLine`) or "dotted" - Dotted line as a border.
- // `4`(`DoubleLine`) or "double" - Double line as a border.
+ // - 0 (NoneLine) or "none" - The border will not be drawn.
+ // - 1 (SolidLine) or "solid" - Solid line as a border.
+ // - 2 (DashedLine) or "dashed" - Dashed line as a border.
+ // - 3 (DottedLine) or "dotted" - Dotted line as a border.
+ // - 4 (DoubleLine) or "double" - Double line as a border.
RightStyle PropertyName = "right-style"
// TopStyle is the constant for "top-style" property tag.
//
- // Used by `BorderProperty`.
+ // Used by BorderProperty.
// Top border line style.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneLine`) or "none" - The border will not be drawn.
- // `1`(`SolidLine`) or "solid" - Solid line as a border.
- // `2`(`DashedLine`) or "dashed" - Dashed line as a border.
- // `3`(`DottedLine`) or "dotted" - Dotted line as a border.
- // `4`(`DoubleLine`) or "double" - Double line as a border.
+ // - 0 (NoneLine) or "none" - The border will not be drawn.
+ // - 1 (SolidLine) or "solid" - Solid line as a border.
+ // - 2 (DashedLine) or "dashed" - Dashed line as a border.
+ // - 3 (DottedLine) or "dotted" - Dotted line as a border.
+ // - 4 (DoubleLine) or "double" - Double line as a border.
TopStyle PropertyName = "top-style"
// BottomStyle is the constant for "bottom-style" property tag.
//
- // Used by `BorderProperty`.
+ // Used by BorderProperty.
// Bottom border line style.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneLine`) or "none" - The border will not be drawn.
- // `1`(`SolidLine`) or "solid" - Solid line as a border.
- // `2`(`DashedLine`) or "dashed" - Dashed line as a border.
- // `3`(`DottedLine`) or "dotted" - Dotted line as a border.
- // `4`(`DoubleLine`) or "double" - Double line as a border.
+ // - 0 (NoneLine) or "none" - The border will not be drawn.
+ // - 1 (SolidLine) or "solid" - Solid line as a border.
+ // - 2 (DashedLine) or "dashed" - Dashed line as a border.
+ // - 3 (DottedLine) or "dotted" - Dotted line as a border.
+ // - 4 (DoubleLine) or "double" - Double line as a border.
BottomStyle PropertyName = "bottom-style"
// LeftWidth is the constant for "left-width" property tag.
//
- // Used by `BorderProperty`.
+ // Used by BorderProperty.
// Left border line width.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
LeftWidth PropertyName = "left-width"
// RightWidth is the constant for "right-width" property tag.
//
- // Used by `BorderProperty`.
+ // Used by BorderProperty.
// Right border line width.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
RightWidth PropertyName = "right-width"
// TopWidth is the constant for "top-width" property tag.
//
- // Used by `BorderProperty`.
+ // Used by BorderProperty.
// Top border line width.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
TopWidth PropertyName = "top-width"
// BottomWidth is the constant for "bottom-width" property tag.
//
- // Used by `BorderProperty`.
+ // Used by BorderProperty.
// Bottom border line width.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
BottomWidth PropertyName = "bottom-width"
// LeftColor is the constant for "left-color" property tag.
//
- // Used by `BorderProperty`.
+ // Used by BorderProperty.
// Left border line color.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See [Color] description for more details.
LeftColor PropertyName = "left-color"
// RightColor is the constant for "right-color" property tag.
//
- // Used by `BorderProperty`.
+ // Used by BorderProperty.
// Right border line color.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See [Color] description for more details.
RightColor PropertyName = "right-color"
// TopColor is the constant for "top-color" property tag.
//
- // Used by `BorderProperty`.
+ // Used by BorderProperty.
// Top border line color.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See [Color] description for more details.
TopColor PropertyName = "top-color"
// BottomColor is the constant for "bottom-color" property tag.
//
- // Used by `BorderProperty`.
+ // Used by BorderProperty.
// Bottom border line color.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See [Color] description for more details.
BottomColor PropertyName = "bottom-color"
)
diff --git a/bounds.go b/bounds.go
index 1384318..3a6931d 100644
--- a/bounds.go
+++ b/bounds.go
@@ -20,6 +20,7 @@ type boundsPropertyData struct {
}
// NewBoundsProperty creates the new BoundsProperty object.
+//
// The following SizeUnit properties can be used: "left" (Left), "right" (Right), "top" (Top), and "bottom" (Bottom).
func NewBoundsProperty(params Params) BoundsProperty {
bounds := new(boundsPropertyData)
@@ -36,7 +37,9 @@ func NewBoundsProperty(params Params) BoundsProperty {
}
// NewBounds creates the new BoundsProperty object.
+//
// The arguments specify the boundaries in a clockwise direction: "top", "right", "bottom", and "left".
+//
// If the argument is specified as int or float64, the value is considered to be in pixels.
func NewBounds[topType SizeUnit | int | float64, rightType SizeUnit | int | float64, bottomType SizeUnit | int | float64, leftType SizeUnit | int | float64](
top topType, right rightType, bottom bottomType, left leftType) BoundsProperty {
diff --git a/canvas.go b/canvas.go
index 6fb405b..f537997 100644
--- a/canvas.go
+++ b/canvas.go
@@ -129,15 +129,15 @@ type Canvas interface {
ClipPath(path Path)
// SetScale adds a scaling transformation to the canvas units horizontally and/or vertically.
- // x - scaling factor in the horizontal direction. A negative value flips pixels across
+ // * x - scaling factor in the horizontal direction. A negative value flips pixels across
// the vertical axis. A value of 1 results in no horizontal scaling;
- // y - scaling factor in the vertical direction. A negative value flips pixels across
+ // * y - scaling factor in the vertical direction. A negative value flips pixels across
// the horizontal axis. A value of 1 results in no vertical scaling.
SetScale(x, y float64)
// SetTranslation adds a translation transformation to the current matrix.
- // x - distance to move in the horizontal direction. Positive values are to the right, and negative to the left;
- // y - distance to move in the vertical direction. Positive values are down, and negative are up.
+ // * x - distance to move in the horizontal direction. Positive values are to the right, and negative to the left;
+ // * y - distance to move in the vertical direction. Positive values are down, and negative are up.
SetTranslation(x, y float64)
// SetRotation adds a rotation to the transformation matrix.
@@ -147,12 +147,13 @@ type Canvas interface {
// SetTransformation multiplies the current transformation with the matrix described by the arguments
// of this method. This lets you scale, rotate, translate (move), and skew the context.
// The transformation matrix is described by:
- // ⎡ xScale xSkew dx ⎤
- // ⎢ ySkew yScale dy ⎥
- // ⎣ 0 0 1 ⎦
- // xScale, yScale - horizontal and vertical scaling. A value of 1 results in no scaling;
- // xSkew, ySkew - horizontal and vertical skewing;
- // dx, dy - horizontal and vertical translation (moving).
+ // ⎡ xScale xSkew dx ⎤
+ // ⎢ ySkew yScale dy ⎥
+ // ⎣ 0 0 1 ⎦
+ // where
+ // * xScale, yScale - horizontal and vertical scaling. A value of 1 results in no scaling;
+ // * xSkew, ySkew - horizontal and vertical skewing;
+ // * dx, dy - horizontal and vertical translation (moving).
SetTransformation(xScale, yScale, xSkew, ySkew, dx, dy float64)
// ResetTransformation resets the current transform to the identity matrix
@@ -165,63 +166,64 @@ type Canvas interface {
SetSolidColorStrokeStyle(color Color)
// SetLinearGradientFillStyle sets a gradient along the line connecting two given coordinates to use inside shapes
- // x0, y0 - coordinates of the start point;
- // x1, y1 - coordinates of the end point;
- // startColor, endColor - the start and end color
- // stopPoints - the array of stop points
+ // * x0, y0 - coordinates of the start point;
+ // * x1, y1 - coordinates of the end point;
+ // * startColor, endColor - the start and end color
+ // * stopPoints - the array of stop points
SetLinearGradientFillStyle(x0, y0 float64, color0 Color, x1, y1 float64, color1 Color, stopPoints []GradientPoint)
// SetLinearGradientStrokeStyle sets a gradient along the line connecting two given coordinates to use for the strokes (outlines) around shapes
- // x0, y0 - coordinates of the start point;
- // x1, y1 - coordinates of the end point;
- // color0, color1 - the start and end color
- // stopPoints - the array of stop points
+ // * x0, y0 - coordinates of the start point;
+ // * x1, y1 - coordinates of the end point;
+ // * color0, color1 - the start and end color
+ // * stopPoints - the array of stop points
SetLinearGradientStrokeStyle(x0, y0 float64, color0 Color, x1, y1 float64, color1 Color, stopPoints []GradientPoint)
// SetRadialGradientFillStyle sets a radial gradient using the size and coordinates of two circles
// to use inside shapes
- // x0, y0 - coordinates of the center of the start circle;
- // r0 - the radius of the start circle;
- // x1, y1 - coordinates the center of the end circle;
- // r1 - the radius of the end circle;
- // color0, color1 - the start and end color
- // stopPoints - the array of stop points
+ // * x0, y0 - coordinates of the center of the start circle;
+ // * r0 - the radius of the start circle;
+ // * x1, y1 - coordinates the center of the end circle;
+ // * r1 - the radius of the end circle;
+ // * color0, color1 - the start and end color
+ // * stopPoints - the array of stop points
SetRadialGradientFillStyle(x0, y0, r0 float64, color0 Color, x1, y1, r1 float64, color1 Color, stopPoints []GradientPoint)
// SetRadialGradientStrokeStyle sets a radial gradient using the size and coordinates of two circles
// to use for the strokes (outlines) around shapes
- // x0, y0 - coordinates of the center of the start circle;
- // r0 - the radius of the start circle;
- // x1, y1 - coordinates the center of the end circle;
- // r1 - the radius of the end circle;
- // color0, color1 - the start and end color
- // stopPoints - the array of stop points
+ // * x0, y0 - coordinates of the center of the start circle;
+ // * r0 - the radius of the start circle;
+ // * x1, y1 - coordinates the center of the end circle;
+ // * r1 - the radius of the end circle;
+ // * color0, color1 - the start and end color
+ // * stopPoints - the array of stop points
SetRadialGradientStrokeStyle(x0, y0, r0 float64, color0 Color, x1, y1, r1 float64, color1 Color, stopPoints []GradientPoint)
// SetConicGradientFillStyle sets a conic gradient around a point
// to use inside shapes
- // x, y - coordinates of the center of the conic gradient in pilels;
- // startAngle - the angle at which to begin the gradient, in radians. The angle starts from a line going horizontally right from the center, and proceeds clockwise.
- // startColor - the start color;
- // endColor - the end color;
- // stopPoints - the array of stop points. The Pos field of GradientPoint, in the range from 0 to 1, specifies the angle in turns.
+ // * x, y - coordinates of the center of the conic gradient in pilels;
+ // * startAngle - the angle at which to begin the gradient, in radians. The angle starts from a line going horizontally right from the center, and proceeds clockwise.
+ // * startColor - the start color;
+ // * endColor - the end color;
+ // * stopPoints - the array of stop points. The Pos field of GradientPoint, in the range from 0 to 1, specifies the angle in turns.
SetConicGradientFillStyle(x, y, startAngle float64, startColor, endColor Color, stopPoints []GradientPoint)
// SetConicGradientFillStyle sets a conic gradient around a point
// to use inside shapes
- // x, y - coordinates of the center of the conic gradient in pilels;
- // startAngle - the angle at which to begin the gradient, in radians. The angle starts from a line going horizontally right from the center, and proceeds clockwise.
- // startColor - the start color;
- // endColor - the end color;
- // stopPoints - the array of stop points. The Pos field of GradientPoint, in the range from 0 to 1, specifies the angle in turns.
+ // * x, y - coordinates of the center of the conic gradient in pilels;
+ // * startAngle - the angle at which to begin the gradient, in radians. The angle starts from a line going horizontally right from the center, and proceeds clockwise.
+ // * startColor - the start color;
+ // * endColor - the end color;
+ // * stopPoints - the array of stop points. The Pos field of GradientPoint, in the range from 0 to 1, specifies the angle in turns.
SetConicGradientStrokeStyle(x, y, startAngle float64, startColor, endColor Color, stopPoints []GradientPoint)
// SetImageFillStyle set the image as the filling pattern.
- // repeat - indicating how to repeat the pattern's image. Possible values are:
- // NoRepeat (0) - neither direction,
- // RepeatXY (1) - both directions,
- // RepeatX (2) - horizontal only,
- // RepeatY (3) - vertical only.
+ //
+ // repeat - indicating how to repeat the pattern's image. Possible values are:
+ // * NoRepeat (0) - neither direction,
+ // * RepeatXY (1) - both directions,
+ // * RepeatX (2) - horizontal only,
+ // * RepeatY (3) - vertical only.
SetImageFillStyle(image Image, repeat int)
// SetLineWidth the line width, in coordinate space units. Zero, negative, Infinity, and NaN values are ignored.
@@ -258,9 +260,9 @@ type Canvas interface {
SetTextAlign(align int)
// SetShadow sets shadow parameters:
- // offsetX, offsetY - the distance that shadows will be offset horizontally and vertically;
- // blur - the amount of blur applied to shadows. Must be non-negative;
- // color - the color of shadows.
+ // * offsetX, offsetY - the distance that shadows will be offset horizontally and vertically;
+ // * blur - the amount of blur applied to shadows. Must be non-negative;
+ // * color - the color of shadows.
SetShadow(offsetX, offsetY, blur float64, color Color)
// ResetShadow sets shadow parameters to default values (invisible shadow)
@@ -292,10 +294,10 @@ type Canvas interface {
FillAndStrokeRoundedRect(x, y, width, height, r float64)
// FillEllipse draws a ellipse that is filled according to the current FillStyle.
- // x, y - coordinates of the ellipse's center;
- // radiusX - the ellipse's major-axis radius. Must be non-negative;
- // radiusY - the ellipse's minor-axis radius. Must be non-negative;
- // rotation - the rotation of the ellipse, expressed in radians.
+ // * x, y - coordinates of the ellipse's center;
+ // * radiusX - the ellipse's major-axis radius. Must be non-negative;
+ // * radiusY - the ellipse's minor-axis radius. Must be non-negative;
+ // * rotation - the rotation of the ellipse, expressed in radians.
FillEllipse(x, y, radiusX, radiusY, rotation float64)
// StrokeRoundedRect draws a ellipse that is stroked (outlined) according
diff --git a/checkbox.go b/checkbox.go
index cdce746..8328d5b 100644
--- a/checkbox.go
+++ b/checkbox.go
@@ -10,16 +10,18 @@ import (
// Event occurs when the checkbox becomes checked/unchecked.
//
// General listener format:
-// `func(checkbox rui.Checkbox, checked bool)`.
+//
+// func(checkbox rui.Checkbox, checked bool)
//
// where:
-// checkbox - Interface of a checkbox which generated this event,
-// checked - Checkbox state.
+// - checkbox - Interface of a checkbox which generated this event,
+// - checked - Checkbox state.
//
// Allowed listener formats:
-// `func(checkbox rui.Checkbox)`,
-// `func(checked bool)`,
-// `func()`.
+//
+// func(checkbox rui.Checkbox)
+// func(checked bool)
+// func()
const CheckboxChangedEvent PropertyName = "checkbox-event"
// Checkbox represent a Checkbox view
diff --git a/color.go b/color.go
index cdfdb5f..fcb9249 100644
--- a/color.go
+++ b/color.go
@@ -19,6 +19,14 @@ func ARGB[T int | uint | int8 | uint8](alpha, red, green, blue T) Color {
(Color(blue) & 0xFF)
}
+// RGB creates Color using red, green and blue components
+func RGB[T int | uint | int8 | uint8](red, green, blue T) Color {
+ return (Color(0xFF) << 24) +
+ ((Color(red) & 0xFF) << 16) +
+ ((Color(green) & 0xFF) << 8) +
+ (Color(blue) & 0xFF)
+}
+
// ARGB - return alpha, red, green and blue components of the color
func (color Color) ARGB() (uint8, uint8, uint8, uint8) {
return uint8(color >> 24),
diff --git a/colorPicker.go b/colorPicker.go
index 3a2e07f..b1016f5 100644
--- a/colorPicker.go
+++ b/colorPicker.go
@@ -12,19 +12,19 @@ const (
// Event generated when color picker value has been changed.
//
// General listener format:
- // `func(picker rui.ColorPicker, newColor, oldColor rui.Color)`.
+ // func(picker rui.ColorPicker, newColor, oldColor rui.Color)
//
// where:
- // picker - Interface of a color picker which generated this event,
- // newColor - New color value,
- // oldColor - Old color value.
+ // - picker - Interface of a color picker which generated this event,
+ // - newColor - New color value,
+ // - oldColor - Old color value.
//
// Allowed listener formats:
- // `func(picker rui.ColorPicker, newColor rui.Color)`,
- // `func(newColor, oldColor rui.Color)`,
- // `func(newColor rui.Color)`,
- // `func(picker rui.ColorPicker)`,
- // `func()`.
+ // func(picker rui.ColorPicker, newColor rui.Color)
+ // func(newColor, oldColor rui.Color)
+ // func(newColor rui.Color)
+ // func(picker rui.ColorPicker)
+ // func()
ColorChangedEvent PropertyName = "color-changed"
// ColorPickerValue is the constant for "color-picker-value" property tag.
diff --git a/columnLayout.go b/columnLayout.go
index c5bb3e3..9f51cec 100644
--- a/columnLayout.go
+++ b/columnLayout.go
@@ -8,110 +8,110 @@ import (
const (
// ColumnCount is the constant for "column-count" property tag.
//
- // Used by `ColumnLayout`.
+ // Used by ColumnLayout.
// Specifies number of columns into which the content is break. Values less than zero are not valid. If this property
// value is 0 then the number of columns is calculated based on the "column-width" property.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0` or "0" - Use "column-width" to control how many columns will be created.
- // >= `0` or >= "0" - Тhe number of columns into which the content is divided.
+ // - 0 or "0" - Use "column-width" to control how many columns will be created.
+ // - positive value - Тhe number of columns into which the content is divided.
ColumnCount PropertyName = "column-count"
// ColumnWidth is the constant for "column-width" property tag.
//
- // Used by `ColumnLayout`.
+ // Used by ColumnLayout.
// Specifies the width of each column.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
ColumnWidth PropertyName = "column-width"
// ColumnGap is the constant for "column-gap" property tag.
//
- // Used by `ColumnLayout`.
+ // Used by ColumnLayout.
// Set the size of the gap (gutter) between columns.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
ColumnGap PropertyName = "column-gap"
// ColumnSeparator is the constant for "column-separator" property tag.
//
- // Used by `ColumnLayout`.
+ // Used by ColumnLayout.
// Specifies the line drawn between columns in a multi-column layout.
//
- // Supported types: `ColumnSeparatorProperty`, `ViewBorder`.
+ // Supported types: ColumnSeparatorProperty, ViewBorder.
//
- // Internal type is `ColumnSeparatorProperty`, other types converted to it during assignment.
- // See `ColumnSeparatorProperty` and `ViewBorder` description for more details.
+ // Internal type is ColumnSeparatorProperty, other types converted to it during assignment.
+ // See [ColumnSeparatorProperty] and [ViewBorder] description for more details.
ColumnSeparator PropertyName = "column-separator"
// ColumnSeparatorStyle is the constant for "column-separator-style" property tag.
//
- // Used by `ColumnLayout`.
+ // Used by ColumnLayout.
// Controls the style of the line drawn between columns in a multi-column layout.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneLine`) or "none" - The separator will not be drawn.
- // `1`(`SolidLine`) or "solid" - Solid line as a separator.
- // `2`(`DashedLine`) or "dashed" - Dashed line as a separator.
- // `3`(`DottedLine`) or "dotted" - Dotted line as a separator.
- // `4`(`DoubleLine`) or "double" - Double line as a separator.
+ // - 0 (NoneLine) or "none" - The separator will not be drawn.
+ // - 1 (SolidLine) or "solid" - Solid line as a separator.
+ // - 2 (DashedLine) or "dashed" - Dashed line as a separator.
+ // - 3 (DottedLine) or "dotted" - Dotted line as a separator.
+ // - 4 (DoubleLine) or "double" - Double line as a separator.
ColumnSeparatorStyle PropertyName = "column-separator-style"
// ColumnSeparatorWidth is the constant for "column-separator-width" property tag.
//
- // Used by `ColumnLayout`.
+ // Used by ColumnLayout.
// Set the width of the line drawn between columns in a multi-column layout.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
ColumnSeparatorWidth PropertyName = "column-separator-width"
// ColumnSeparatorColor is the constant for "column-separator-color" property tag.
//
- // Used by `ColumnLayout`.
+ // Used by ColumnLayout.
// Set the color of the line drawn between columns in a multi-column layout.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See Color description for more details.
ColumnSeparatorColor PropertyName = "column-separator-color"
// ColumnFill is the constant for "column-fill" property tag.
//
- // Used by `ColumnLayout`.
- // Controls how a `ColumnLayout`'s content is balanced when broken into columns. Default value is "balance".
+ // Used by ColumnLayout.
+ // Controls how a ColumnLayout's content is balanced when broken into columns. Default value is "balance".
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`ColumnFillBalance`) or "balance" - Content is equally divided between columns.
- // `1`(`ColumnFillAuto`) or "auto" - Columns are filled sequentially. Content takes up only the room it needs, possibly resulting in some columns remaining empty.
+ // - 0 (ColumnFillBalance) or "balance" - Content is equally divided between columns.
+ // - 1 (ColumnFillAuto) or "auto" - Columns are filled sequentially. Content takes up only the room it needs, possibly resulting in some columns remaining empty.
ColumnFill PropertyName = "column-fill"
// ColumnSpanAll is the constant for "column-span-all" property tag.
//
- // Used by `ColumnLayout`.
+ // Used by ColumnLayout.
// Property used in views placed inside the column layout container. Makes it possible for a view to span across all
- // columns. Default value is `false`.
+ // columns. Default value is false.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - View will span across all columns.
- // `false` or `0` or "false", "no", "off", "0" - View will be a part of a column.
+ // - true, 1, "true", "yes", "on", or "1" - View will span across all columns.
+ // - false, 0, "false", "no", "off", or "0" - View will be a part of a column.
ColumnSpanAll PropertyName = "column-span-all"
)
diff --git a/columnSeparator.go b/columnSeparator.go
index 323f858..5de3574 100644
--- a/columnSeparator.go
+++ b/columnSeparator.go
@@ -58,15 +58,13 @@ func newColumnSeparatorProperty(value any) ColumnSeparatorProperty {
return nil
}
-// NewColumnSeparator creates the new ColumnSeparatorProperty.
+// NewColumnSeparatorProperty creates the new ColumnSeparatorProperty.
+//
// The following properties can be used:
-//
-// "style" (Style). Determines the line style (int). Valid values: 0 (NoneLine), 1 (SolidLine), 2 (DashedLine), 3 (DottedLine), or 4 (DoubleLine);
-//
-// "color" (ColorTag). Determines the line color (Color);
-//
-// "width" (Width). Determines the line thickness (SizeUnit).
-func NewColumnSeparator(params Params) ColumnSeparatorProperty {
+// - "style" (Style) - Determines the line style (type is int). Valid values: 0 (NoneLine), 1 (SolidLine), 2 (DashedLine), 3 (DottedLine), or 4 (DoubleLine);
+// - "color" (ColorTag) - Determines the line color (type is [Color]);
+// - "width" (Width) - Determines the line thickness (type is [SizeUnit]).
+func NewColumnSeparatorProperty(params Params) ColumnSeparatorProperty {
separator := new(columnSeparatorProperty)
separator.init()
if params != nil {
@@ -79,6 +77,20 @@ func NewColumnSeparator(params Params) ColumnSeparatorProperty {
return separator
}
+// NewColumnSeparator creates the new ColumnSeparatorProperty.
+//
+// Arguments:
+// - style - determines the line style. Valid values: 0 [NoneLine], 1 [SolidLine], 2 [DashedLine], 3 [DottedLine], or 4 [DoubleLine];
+// - color - determines the line color;
+// - width - determines the line thickness.
+func NewColumnSeparator(style int, color Color, width SizeUnit) ColumnSeparatorProperty {
+ return NewColumnSeparatorProperty(Params{
+ Width: width,
+ Style: style,
+ ColorTag: color,
+ })
+}
+
func (separator *columnSeparatorProperty) init() {
separator.dataProperty.init()
separator.normalize = normalizeVolumnSeparatorTag
diff --git a/dataList.go b/dataList.go
index 1e62674..2c1bb11 100644
--- a/dataList.go
+++ b/dataList.go
@@ -10,99 +10,88 @@ import (
const (
// DataList is the constant for "data-list" property tag.
//
- // Used by `ColorPicker`, `DatePicker`, `EditView`, `NumberPicker`, `TimePicker`.
+ // Used by ColorPicker, DatePicker, EditView, NumberPicker, TimePicker.
+ //
+ // # Usage in ColorPicker
//
- // Usage in `ColorPicker`:
// List of pre-defined colors.
//
- // Supported types: `[]string`, `string`, `[]fmt.Stringer`, `[]Color`, `[]SizeUnit`, `[]AngleUnit`, `[]any` containing
- // elements of `string`, `fmt.Stringer`, `bool`, `rune`, `float32`, `float64`, `int`, `int8` … `int64`, `uint`, `uint8` …
- // `uint64`.
+ // Supported types: []string, string, []fmt.Stringer, []Color, []any containing
+ // elements of string, fmt.Stringer, int, int8…int64, uint, uint8…uint64.
//
- // Internal type is `[]string`, other types converted to it during assignment.
+ // Internal type is []string, other types converted to it during assignment.
//
// Conversion rules:
- // `string` - contain single item.
- // `[]string` - an array of items.
- // `[]fmt.Stringer` - an array of objects convertible to a string.
- // `[]Color` - An array of color values which will be converted to a string array.
- // `[]SizeUnit` - an array of size unit values which will be converted to a string array.
- // `[]any` - this array must contain only types which were listed in Types section.
+ // - string - contain single item.
+ // - []string - an array of items.
+ // - []fmt.Stringer - an array of objects convertible to a string.
+ // - []Color - An array of color values which will be converted to a string array.
+ // - []any - this array must contain only types which were listed in Types section.
+ //
+ // # Usage in DatePicker
//
- // Usage in `DatePicker`:
// List of predefined dates. If we set this property, date picker may have a drop-down menu with a list of these values.
// Some browsers may ignore this property, such as Safari for macOS. The value of this property must be an array of
// strings in the format "YYYY-MM-DD".
//
- // Supported types: `[]string`, `string`, `[]fmt.Stringer`, `[]Color`, `[]SizeUnit`, `[]AngleUnit`, `[]any` containing
- // elements of `string`, `fmt.Stringer`, `bool`, `rune`, `float32`, `float64`, `int`, `int8` … `int64`, `uint`, `uint8` …
- // `uint64`.
+ // Supported types: []string, string, []fmt.Stringer, []time.Time, []any containing elements of string, fmt.Stringer, time.Time.
//
- // Internal type is `[]string`, other types converted to it during assignment.
+ // Internal type is []string, other types converted to it during assignment.
//
// Conversion rules:
- // `string` - contain single item.
- // `[]string` - an array of items.
- // `[]fmt.Stringer` - an array of objects convertible to a string.
- // `[]Color` - An array of color values which will be converted to a string array.
- // `[]SizeUnit` - an array of size unit values which will be converted to a string array.
- // `[]any` - this array must contain only types which were listed in Types section.
+ // - string - contain single item.
+ // - []string - an array of items.
+ // - []fmt.Stringer - an array of objects convertible to a string.
+ // - []time.Time - an array of Time values which will be converted to a string array.
+ // - []any - this array must contain only types which were listed in Types section.
+ //
+ // # Usage in EditView
//
- // Usage in `EditView`:
// Array of recommended values.
//
- // Supported types: `[]string`, `string`, `[]fmt.Stringer`, `[]Color`, `[]SizeUnit`, `[]AngleUnit`, `[]any` containing
- // elements of `string`, `fmt.Stringer`, `bool`, `rune`, `float32`, `float64`, `int`, `int8` … `int64`, `uint`, `uint8` …
- // `uint64`.
+ // Supported types: []string, string, []fmt.Stringer, and []any containing
+ // elements of string, fmt.Stringer, bool, rune, float32, float64, int, int8…int64, uint, uint8…uint64.
//
- // Internal type is `[]string`, other types converted to it during assignment.
+ // Internal type is []string, other types converted to it during assignment.
//
// Conversion rules:
- // `string` - contain single item.
- // `[]string` - an array of items.
- // `[]fmt.Stringer` - an array of objects convertible to a string.
- // `[]Color` - An array of color values which will be converted to a string array.
- // `[]SizeUnit` - an array of size unit values which will be converted to a string array.
- // `[]any` - this array must contain only types which were listed in Types section.
+ // - string - contain single item.
+ // - []string - an array of items.
+ // - []fmt.Stringer - an array of objects convertible to a string.
+ // - []any - this array must contain only types which were listed in Types section.
+ //
+ // # Usage in NumberPicker
//
- // Usage in `NumberPicker`:
// Specify an array of recommended values.
//
- // Supported types: `[]string`, `string`, `[]fmt.Stringer`, `[]Color`, `[]SizeUnit`, `[]AngleUnit`, `[]float`, `[]int`,
- // `[]bool`, `[]any` containing elements of `string`, `fmt.Stringer`, `bool`, `rune`, `float32`, `float64`, `int`, `int8`
- // … `int64`, `uint`, `uint8` … `uint64`.
+ // Supported types: []string, string, []fmt.Stringer, []float, []int, []bool, []any containing elements
+ // of string, fmt.Stringer, rune, float32, float64, int, int8…int64, uint, uint8…uint64.
//
- // Internal type is `[]string`, other types converted to it during assignment.
+ // Internal type is []string, other types converted to it during assignment.
//
// Conversion rules:
- // `string` - must contain integer or floating point number, converted to `[]string`.
- // `[]string` - an array of strings which must contain integer or floating point numbers, stored as is.
- // `[]fmt.Stringer` - object which implement this interface must contain integer or floating point numbers, converted to a `[]string`.
- // `[]Color` - an array of color values, converted to `[]string`.
- // `[]SizeUnit` - an array of size unit, converted to `[]string`.
- // `[]AngleUnit` - an array of angle unit, converted to `[]string`.
- // `[]float` - converted to `[]string`.
- // `[]int` - converted to `[]string`.
- // `[]bool` - converted to `[]string`.
- // `[]any` - an array which may contain types listed in Types section above, each value will be converted to a `string` and wrapped to array.
+ // - string - must contain integer or floating point number, converted to []string.
+ // - []string - an array of strings which must contain integer or floating point numbers, stored as is.
+ // - []fmt.Stringer - object which implement this interface must contain integer or floating point numbers, converted to a []string.
+ // - []float - converted to []string.
+ // - []int - converted to []string.
+ // - []any - an array which may contain types listed in Types section above, each value will be converted to a string and wrapped to array.
+ //
+ // # Usage in TimePicker
//
- // Usage in `TimePicker`:
// An array of recommended values. The value of this property must be an array of strings in the format "HH:MM:SS" or
// "HH:MM".
//
- // Supported types: `[]string`, `string`, `[]fmt.Stringer`, `[]Color`, `[]SizeUnit`, `[]AngleUnit`, `[]any` containing
- // elements of `string`, `fmt.Stringer`, `bool`, `rune`, `float32`, `float64`, `int`, `int8` … `int64`, `uint`, `uint8` …
- // `uint64`.
+ // Supported types: []string, string, []fmt.Stringer, []time.Time, []any containing elements of string, fmt.Stringer, time.Time.
//
- // Internal type is `[]string`, other types converted to it during assignment.
+ // Internal type is []string, other types converted to it during assignment.
//
// Conversion rules:
- // `string` - contain single item.
- // `[]string` - an array of items.
- // `[]fmt.Stringer` - an array of objects convertible to a string.
- // `[]Color` - An array of color values which will be converted to a string array.
- // `[]SizeUnit` - an array of size unit values which will be converted to a string array.
- // `[]any` - this array must contain only types which were listed in Types section.
+ // - string - contain single item.
+ // - []string - an array of items.
+ // - []fmt.Stringer - an array of objects convertible to a string.
+ // - []time.Time - An array of Time values which will be converted to a string array.
+ // - []any - this array must contain only types which were listed in Types section.
DataList PropertyName = "data-list"
)
diff --git a/datePicker.go b/datePicker.go
index d36b4e1..bff18c6 100644
--- a/datePicker.go
+++ b/datePicker.go
@@ -10,103 +10,103 @@ import (
const (
// DateChangedEvent is the constant for "date-changed" property tag.
//
- // Used by `DatePicker`.
+ // Used by DatePicker.
// Occur when date picker value has been changed.
//
// General listener format:
- // `func(picker rui.DatePicker, newDate, oldDate time.Time)`.
+ // func(picker rui.DatePicker, newDate time.Time, oldDate time.Time)
//
// where:
- // picker - Interface of a date picker which generated this event,
- // newDate - New date value,
- // oldDate - Old date value.
+ // - picker - Interface of a date picker which generated this event,
+ // - newDate - New date value,
+ // - oldDate - Old date value.
//
// Allowed listener formats:
- // `func(picker rui.DatePicker, newDate time.Time)`,
- // `func(newDate, oldDate time.Time)`,
- // `func(newDate time.Time)`,
- // `func(picker rui.DatePicker)`,
- // `func()`.
+ // func(picker rui.DatePicker, newDate time.Time)
+ // func(newDate time.Time, oldDate time.Time)
+ // func(newDate time.Time)
+ // func(picker rui.DatePicker)
+ // func()
DateChangedEvent PropertyName = "date-changed"
// DatePickerMin is the constant for "date-picker-min" property tag.
//
- // Used by `DatePicker`.
+ // Used by DatePicker.
// Minimum date value.
//
- // Supported types: `time.Time`, `string`.
+ // Supported types: time.Time, string.
//
- // Internal type is `time.Time`, other types converted to it during assignment.
+ // Internal type is time.Time, other types converted to it during assignment.
//
// Conversion rules:
- // `string` - values of this type parsed and converted to `time.Time`. The following formats are supported:
- // "YYYYMMDD" - "20240102".
- // "Mon-DD-YYYY" - "Jan-02-24".
- // "Mon-DD-YY" - "Jan-02-2024".
- // "DD-Mon-YYYY" - "02-Jan-2024".
- // "YYYY-MM-DD" - "2024-01-02".
- // "Month DD, YYYY" - "January 02, 2024".
- // "DD Month YYYY" - "02 January 2024".
- // "MM/DD/YYYY" - "01/02/2024".
- // "MM/DD/YY" - "01/02/24".
- // "MMDDYY" - "010224".
+ // string - values of this type parsed and converted to time.Time. The following formats are supported:
+ // - "YYYYMMDD" - "20240102".
+ // - "Mon-DD-YYYY" - "Jan-02-24".
+ // - "Mon-DD-YY" - "Jan-02-2024".
+ // - "DD-Mon-YYYY" - "02-Jan-2024".
+ // - "YYYY-MM-DD" - "2024-01-02".
+ // - "Month DD, YYYY" - "January 02, 2024".
+ // - "DD Month YYYY" - "02 January 2024".
+ // - "MM/DD/YYYY" - "01/02/2024".
+ // - "MM/DD/YY" - "01/02/24".
+ // - "MMDDYY" - "010224".
DatePickerMin PropertyName = "date-picker-min"
// DatePickerMax is the constant for "date-picker-max" property tag.
//
- // Used by `DatePicker`.
+ // Used by DatePicker.
// Maximum date value.
//
- // Supported types: `time.Time`, `string`.
+ // Supported types: time.Time, string.
//
- // Internal type is `time.Time`, other types converted to it during assignment.
+ // Internal type is time.Time, other types converted to it during assignment.
//
// Conversion rules:
- // `string` - values of this type parsed and converted to `time.Time`. The following formats are supported:
- // "YYYYMMDD" - "20240102".
- // "Mon-DD-YYYY" - "Jan-02-24".
- // "Mon-DD-YY" - "Jan-02-2024".
- // "DD-Mon-YYYY" - "02-Jan-2024".
- // "YYYY-MM-DD" - "2024-01-02".
- // "Month DD, YYYY" - "January 02, 2024".
- // "DD Month YYYY" - "02 January 2024".
- // "MM/DD/YYYY" - "01/02/2024".
- // "MM/DD/YY" - "01/02/24".
- // "MMDDYY" - "010224".
+ // string - values of this type parsed and converted to time.Time. The following formats are supported:
+ // - "YYYYMMDD" - "20240102".
+ // - "Mon-DD-YYYY" - "Jan-02-24".
+ // - "Mon-DD-YY" - "Jan-02-2024".
+ // - "DD-Mon-YYYY" - "02-Jan-2024".
+ // - "YYYY-MM-DD" - "2024-01-02".
+ // - "Month DD, YYYY" - "January 02, 2024".
+ // - "DD Month YYYY" - "02 January 2024".
+ // - "MM/DD/YYYY" - "01/02/2024".
+ // - "MM/DD/YY" - "01/02/24".
+ // - "MMDDYY" - "010224".
DatePickerMax PropertyName = "date-picker-max"
// DatePickerStep is the constant for "date-picker-step" property tag.
//
- // Used by `DatePicker`.
+ // Used by DatePicker.
// Date change step in days.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // >= `0` or >= "0" - Step value in days used to increment or decrement date.
+ // positive value - Step value in days used to increment or decrement date.
DatePickerStep PropertyName = "date-picker-step"
// DatePickerValue is the constant for "date-picker-value" property tag.
//
- // Used by `DatePicker`.
+ // Used by DatePicker.
// Current value.
//
- // Supported types: `time.Time`, `string`.
+ // Supported types: time.Time, string.
//
- // Internal type is `time.Time`, other types converted to it during assignment.
+ // Internal type is time.Time, other types converted to it during assignment.
//
// Conversion rules:
- // `string` - values of this type parsed and converted to `time.Time`. The following formats are supported:
- // "YYYYMMDD" - "20240102".
- // "Mon-DD-YYYY" - "Jan-02-24".
- // "Mon-DD-YY" - "Jan-02-2024".
- // "DD-Mon-YYYY" - "02-Jan-2024".
- // "YYYY-MM-DD" - "2024-01-02".
- // "Month DD, YYYY" - "January 02, 2024".
- // "DD Month YYYY" - "02 January 2024".
- // "MM/DD/YYYY" - "01/02/2024".
- // "MM/DD/YY" - "01/02/24".
- // "MMDDYY" - "010224".
+ // string - values of this type parsed and converted to time.Time. The following formats are supported:
+ // - "YYYYMMDD" - "20240102".
+ // - "Mon-DD-YYYY" - "Jan-02-24".
+ // - "Mon-DD-YY" - "Jan-02-2024".
+ // - "DD-Mon-YYYY" - "02-Jan-2024".
+ // - "YYYY-MM-DD" - "2024-01-02".
+ // - "Month DD, YYYY" - "January 02, 2024".
+ // - "DD Month YYYY" - "02 January 2024".
+ // - "MM/DD/YYYY" - "01/02/2024".
+ // - "MM/DD/YY" - "01/02/24".
+ // - "MMDDYY" - "010224".
DatePickerValue PropertyName = "date-picker-value"
dateFormat = "2006-01-02"
diff --git a/detailsView.go b/detailsView.go
index 646043e..90c4ecc 100644
--- a/detailsView.go
+++ b/detailsView.go
@@ -6,25 +6,24 @@ import "strings"
const (
// Summary is the constant for "summary" property tag.
//
- // Used by `DetailsView`.
+ // Used by DetailsView.
// The content of this property is used as the label for the disclosure widget.
//
- // Supported types: `string`, `View`.
- //
- // `string` - Summary as a text.
- // `View` - Summary as a view, in this case it can be quite complex if needed.
+ // Supported types:
+ // - string - Summary as a text.
+ // - View - Summary as a view, in this case it can be quite complex if needed.
Summary PropertyName = "summary"
// Expanded is the constant for "expanded" property tag.
//
- // Used by `DetailsView`.
- // Controls the content expanded state of the details view. Default value is `false`.
+ // Used by DetailsView.
+ // Controls the content expanded state of the details view. Default value is false.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - Content is visible.
- // `false` or `0` or "false", "no", "off", "0" - Content is collapsed(hidden).
+ // - true, 1, "true", "yes", "on", or "1" - Content is visible.
+ // - false, 0, "false", "no", "off", or "0" - Content is collapsed (hidden).
Expanded PropertyName = "expanded"
)
diff --git a/dropDownList.go b/dropDownList.go
index 558fecb..f7fd3e6 100644
--- a/dropDownList.go
+++ b/dropDownList.go
@@ -7,17 +7,22 @@ import (
// DropDownEvent is the constant for "drop-down-event" property tag.
//
-// Used by `DropDownList`.
+// Used by DropDownList.
// Occur when a list item becomes selected.
//
// General listener format:
-// `func(list rui.DropDownList, index int)`.
+//
+// func(list rui.DropDownList, index int)
//
// where:
-// list - Interface of a drop down list which generated this event,
-// index - Index of a newly selected item.
+// - list - Interface of a drop down list which generated this event,
+// - index - Index of a newly selected item.
//
// Allowed listener formats:
+//
+// func(index int)
+// func(list rui.DropDownList)
+// func()
const DropDownEvent PropertyName = "drop-down-event"
// DropDownList represent a DropDownList view
diff --git a/editView.go b/editView.go
index d45f559..0b81faa 100644
--- a/editView.go
+++ b/editView.go
@@ -9,61 +9,61 @@ import (
const (
// EditTextChangedEvent is the constant for "edit-text-changed" property tag.
//
- // Used by `EditView`.
+ // Used by EditView.
// Occur when edit view text has been changed.
//
// General listener format:
- // `func(editView rui.EditView, newText, oldText string)`.
+ // func(editView rui.EditView, newText string, oldText string).
//
// where:
- // editView - Interface of an edit view which generated this event,
- // newText - New edit view text,
- // oldText - Previous edit view text.
+ // - editView - Interface of an edit view which generated this event,
+ // - newText - New edit view text,
+ // - oldText - Previous edit view text.
//
// Allowed listener formats:
- // `func(editView rui.EditView, newText string)`,
- // `func(newText, oldText string)`,
- // `func(newText string)`,
- // `func(editView rui.EditView)`,
- // `func()`.
+ // - func(editView rui.EditView, newText string)
+ // - func(newText string, oldText string)
+ // - func(newText string)
+ // - func(editView rui.EditView)
+ // - func()
EditTextChangedEvent PropertyName = "edit-text-changed"
// EditViewType is the constant for "edit-view-type" property tag.
//
- // Used by `EditView`.
+ // Used by EditView.
// Type of the text input. Default value is "text".
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`SingleLineText`) or "text" - One-line text editor.
- // `1`(`PasswordText`) or "password" - Password editor. The text is hidden by asterisks.
- // `2`(`EmailText`) or "email" - Single e-mail editor.
- // `3`(`EmailsText`) or "emails" - Multiple e-mail editor.
- // `4`(`URLText`) or "url" - Internet address input editor.
- // `5`(`PhoneText`) or "phone" - Phone number editor.
- // `6`(`MultiLineText`) or "multiline" - Multi-line text editor.
+ // - 0 (SingleLineText) or "text" - One-line text editor.
+ // - 1 (PasswordText) or "password" - Password editor. The text is hidden by asterisks.
+ // - 2 (EmailText) or "email" - Single e-mail editor.
+ // - 3 (EmailsText) or "emails" - Multiple e-mail editor.
+ // - 4 (URLText) or "url" - Internet address input editor.
+ // - 5 (PhoneText) or "phone" - Phone number editor.
+ // - 6 (MultiLineText) or "multiline" - Multi-line text editor.
EditViewType PropertyName = "edit-view-type"
// EditViewPattern is the constant for "edit-view-pattern" property tag.
//
- // Used by `EditView`.
+ // Used by EditView.
// Regular expression to limit editing of a text.
//
- // Supported types: `string`.
+ // Supported types: string.
EditViewPattern PropertyName = "edit-view-pattern"
// Spellcheck is the constant for "spellcheck" property tag.
//
- // Used by `EditView`.
- // Enable or disable spell checker. Available in `SingleLineText` and `MultiLineText` types of edit view. Default value is
- // `false`.
+ // Used by EditView.
+ // Enable or disable spell checker. Available in SingleLineText and MultiLineText types of edit view. Default value is
+ // false.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - Enable spell checker for text.
- // `false` or `0` or "false", "no", "off", "0" - Disable spell checker for text.
+ // - true, 1, "true", "yes", "on", "1" - Enable spell checker for text.
+ // - false, 0, "false", "no", "off", "0" - Disable spell checker for text.
Spellcheck PropertyName = "spellcheck"
)
diff --git a/filePicker.go b/filePicker.go
index 80553bf..bc2296e 100644
--- a/filePicker.go
+++ b/filePicker.go
@@ -11,46 +11,46 @@ import (
const (
// FileSelectedEvent is the constant for "file-selected-event" property tag.
//
- // Used by `FilePicker`.
+ // Used by FilePicker.
// Fired when user selects file(s).
//
// General listener format:
- // `func(picker rui.FilePicker, files []rui.FileInfo)`.
+ // func(picker rui.FilePicker, files []rui.FileInfo).
//
// where:
// picker - Interface of a file picker which generated this event,
// files - Array of description of selected files.
//
// Allowed listener formats:
- // `func(picker rui.FilePicker)`,
- // `func(files []rui.FileInfo)`,
- // `func()`.
+ // func(picker rui.FilePicker)
+ // func(files []rui.FileInfo)
+ // func()
FileSelectedEvent PropertyName = "file-selected-event"
// Accept is the constant for "accept" property tag.
//
- // Used by `FilePicker`.
+ // Used by FilePicker.
// Set the list of allowed file extensions or MIME types.
//
- // Supported types: `string`, `[]string`.
+ // Supported types: string, []string.
//
- // Internal type is `string`, other types converted to it during assignment.
+ // Internal type is string, other types converted to it during assignment.
//
// Conversion rules:
- // `string` - may contain single value of multiple separated by comma(`,`).
- // `[]string` - an array of acceptable file extensions or MIME types.
+ // - string - may contain single value of multiple separated by comma(,).
+ // - []string - an array of acceptable file extensions or MIME types.
Accept PropertyName = "accept"
// Multiple is the constant for "multiple" property tag.
//
- // Used by `FilePicker`.
+ // Used by FilePicker.
// Controls whether multiple files can be selected.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - Several files can be selected.
- // `false` or `0` or "false", "no", "off", "0" - Only one file can be selected.
+ // - true, 1, "true", "yes", "on", "1" - Several files can be selected.
+ // - false, 0, "false", "no", "off", "0" - Only one file can be selected.
Multiple PropertyName = "multiple"
)
diff --git a/focusEvents.go b/focusEvents.go
index 425c599..281e128 100644
--- a/focusEvents.go
+++ b/focusEvents.go
@@ -6,32 +6,32 @@ import "strings"
const (
// FocusEvent is the constant for "focus-event" property tag.
//
- // Used by `View`.
+ // Used by View.
// Occur when the view takes input focus.
//
// General listener format:
- // `func(View)`.
+ // func(rui.View).
//
// where:
// view - Interface of a view which generated this event.
//
// Allowed listener formats:
- // `func()`.
+ // func().
FocusEvent PropertyName = "focus-event"
// LostFocusEvent is the constant for "lost-focus-event" property tag.
//
- // Used by `View`.
+ // Used by View.
// Occur when the View lost input focus.
//
// General listener format:
- // `func(view rui.View)`.
+ // func(view rui.View).
//
// where:
// view - Interface of a view which generated this event.
//
// Allowed listener formats:
- // `func()`.
+ // func()
LostFocusEvent PropertyName = "lost-focus-event"
)
diff --git a/gridLayout.go b/gridLayout.go
index fa5299c..bad0a78 100644
--- a/gridLayout.go
+++ b/gridLayout.go
@@ -9,70 +9,70 @@ import (
const (
// CellVerticalAlign is the constant for "cell-vertical-align" property tag.
//
- // Used by `GridLayout`, `SvgImageView`.
+ // Used by GridLayout, SvgImageView.
//
- // Usage in `GridLayout`:
- // Sets the default vertical alignment of `GridLayout` children within the cell they are occupying.
+ // Usage in GridLayout:
+ // Sets the default vertical alignment of GridLayout children within the cell they are occupying.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`TopAlign`) or "top" - Top alignment.
- // `1`(`BottomAlign`) or "bottom" - Bottom alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
- // `3`(`StretchAlign`) or "stretch" - Full height stretch.
+ // - 0 (TopAlign) or "top" - Top alignment.
+ // - 1 (BottomAlign) or "bottom" - Bottom alignment.
+ // - 2 (CenterAlign) or "center" - Center alignment.
+ // - 3 (StretchAlign) or "stretch" - Full height stretch.
//
- // Usage in `SvgImageView`:
+ // Usage in SvgImageView:
// Same as "vertical-align".
CellVerticalAlign PropertyName = "cell-vertical-align"
// CellHorizontalAlign is the constant for "cell-horizontal-align" property tag.
//
- // Used by `GridLayout`, `SvgImageView`.
+ // Used by GridLayout, SvgImageView.
//
- // Usage in `GridLayout`:
- // Sets the default horizontal alignment of `GridLayout` children within the occupied cell.
+ // Usage in GridLayout:
+ // Sets the default horizontal alignment of GridLayout children within the occupied cell.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`LeftAlign`) or "left" - Left alignment.
- // `1`(`RightAlign`) or "right" - Right alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
- // `3`(`StretchAlign`) or "stretch" - Full width stretch.
+ // - 0 (LeftAlign) or "left" - Left alignment.
+ // - 1 (RightAlign) or "right" - Right alignment.
+ // - 2 (CenterAlign) or "center" - Center alignment.
+ // - 3 (StretchAlign) or "stretch" - Full width stretch.
//
- // Usage in `SvgImageView`:
+ // Usage in SvgImageView:
// Same as "horizontal-align".
CellHorizontalAlign PropertyName = "cell-horizontal-align"
// CellVerticalSelfAlign is the constant for "cell-vertical-self-align" property tag.
//
- // Used by `GridLayout`.
- // Sets the vertical alignment of `GridLayout` children within the cell they are occupying. The property is set for the
- // child view of `GridLayout`.
+ // Used by GridLayout.
+ // Sets the vertical alignment of GridLayout children within the cell they are occupying. The property is set for the
+ // child view of GridLayout.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`TopAlign`) or "top" - Top alignment.
- // `1`(`BottomAlign`) or "bottom" - Bottom alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
- // `3`(`StretchAlign`) or "stretch" - Full height stretch.
+ // - 0 (TopAlign) or "top" - Top alignment.
+ // - 1 (BottomAlign) or "bottom" - Bottom alignment.
+ // - 2 (CenterAlign) or "center" - Center alignment.
+ // - 3 (StretchAlign) or "stretch" - Full height stretch.
CellVerticalSelfAlign PropertyName = "cell-vertical-self-align"
// CellHorizontalSelfAlign is the constant for "cell-horizontal-self-align" property tag.
//
- // Used by `GridLayout`.
- // Sets the horizontal alignment of `GridLayout` children within the occupied cell. The property is set for the child view
- // of `GridLayout`.
+ // Used by GridLayout.
+ // Sets the horizontal alignment of GridLayout children within the occupied cell. The property is set for the child view
+ // of GridLayout.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`LeftAlign`) or "left" - Left alignment.
- // `1`(`RightAlign`) or "right" - Right alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
- // `3`(`StretchAlign`) or "stretch" - Full width stretch.
+ // - 0 (LeftAlign) or "left" - Left alignment.
+ // - 1 (RightAlign) or "right" - Right alignment.
+ // - 2 (CenterAlign) or "center" - Center alignment.
+ // - 3 (StretchAlign) or "stretch" - Full width stretch.
CellHorizontalSelfAlign PropertyName = "cell-horizontal-self-align"
)
diff --git a/imageView.go b/imageView.go
index 5eeaaac..9053748 100644
--- a/imageView.go
+++ b/imageView.go
@@ -9,32 +9,32 @@ import (
const (
// LoadedEvent is the constant for "loaded-event" property tag.
//
- // Used by `ImageView`.
+ // Used by ImageView.
// Occur when the image has been loaded.
//
// General listener format:
- // `func(image rui.ImageView)`.
+ // func(image rui.ImageView)
//
// where:
// image - Interface of an image view which generated this event.
//
// Allowed listener formats:
- // `func()`.
+ // func()
LoadedEvent PropertyName = "loaded-event"
// ErrorEvent is the constant for "error-event" property tag.
//
- // Used by `ImageView`.
+ // Used by ImageView.
// Occur when the image loading has been failed.
//
// General listener format:
- // `func(image rui.ImageView)`.
+ // func(image rui.ImageView)
//
// where:
// image - Interface of an image view which generated this event.
//
// Allowed listener formats:
- // `func()`.
+ // func()
ErrorEvent PropertyName = "error-event"
// NoneFit - value of the "object-fit" property of an ImageView. The replaced content is not resized
diff --git a/keyEvents.go b/keyEvents.go
index 97d6b68..a26419f 100644
--- a/keyEvents.go
+++ b/keyEvents.go
@@ -6,38 +6,42 @@ import "strings"
const (
// KeyDownEvent is the constant for "key-down-event" property tag.
//
- // Used by `View`.
+ // Used by View.
// Is fired when a key is pressed.
//
// General listener format:
- // `func(view rui.View, event rui.KeyEvent)`.
+ //
+ // func(view rui.View, event rui.KeyEvent).
//
// where:
- // view - Interface of a view which generated this event,
- // event - Key event.
+ // - view - Interface of a view which generated this event,
+ // - event - Key event.
//
// Allowed listener formats:
- // `func(view rui.View)`,
- // `func(event rui.KeyEvent)`,
- // `func()`.
+ //
+ // func(view rui.View)
+ // func(event rui.KeyEvent)
+ // func()
KeyDownEvent PropertyName = "key-down-event"
// KeyUpEvent is the constant for "key-up-event" property tag.
//
- // Used by `View`.
+ // Used by View.
// Is fired when a key is released.
//
// General listener format:
- // `func(view rui.View, event rui.KeyEvent)`.
+ //
+ // func(view rui.View, event rui.KeyEvent)
//
// where:
- // view - Interface of a view which generated this event,
- // event - Key event.
+ // - view - Interface of a view which generated this event,
+ // - event - Key event.
//
// Allowed listener formats:
- // `func(view rui.View)`,
- // `func(event rui.KeyEvent)`,
- // `func()`.
+ //
+ // func(view rui.View)
+ // func(event rui.KeyEvent)
+ // func()
KeyUpEvent PropertyName = "key-up-event"
)
diff --git a/listView.go b/listView.go
index 98f8393..8ff9d0a 100644
--- a/listView.go
+++ b/listView.go
@@ -10,77 +10,86 @@ import (
const (
// ListItemClickedEvent is the constant for "list-item-clicked" property tag.
//
- // Used by `ListView`.
+ // Used by ListView.
// Occur when the user clicks on an item in the list.
//
// General listener format:
- // `func(list rui.ListView, item int)`.
+ //
+ // func(list rui.ListView, item int)
//
// where:
- // list - Interface of a list which generated this event,
- // item - An index of an item clicked.
+ // - list - Interface of a list which generated this event,
+ // - item - An index of an item clicked.
//
// Allowed listener formats:
- // `func(item int)`,
- // `func(list rui.ListView)`,
- // `func()`.
+ //
+ // func(item int)
+ // func(list rui.ListView)
+ // func()
ListItemClickedEvent PropertyName = "list-item-clicked"
// ListItemSelectedEvent is the constant for "list-item-selected" property tag.
//
- // Used by `ListView`.
+ // Used by ListView.
// Occur when a list item becomes selected.
//
// General listener format:
- // `func(list rui.ListView, item int)`.
+ //
+ // func(list rui.ListView, item int)
//
// where:
- // list - Interface of a list which generated this event,
- // item - An index of an item selected.
+ // - list - Interface of a list which generated this event,
+ // - item - An index of an item selected.
//
// Allowed listener formats:
+ //
+ // func(item int)
+ // func(list rui.ListView)
+ // func()
ListItemSelectedEvent PropertyName = "list-item-selected"
// ListItemCheckedEvent is the constant for "list-item-checked" property tag.
//
- // Used by `ListView`.
+ // Used by ListView.
// Occur when a list item checkbox becomes checked or unchecked.
//
// General listener format:
- // `func(list rui.ListView, checkedItems []int)`.
+ //
+ // func(list rui.ListView, checkedItems []int).
//
// where:
- // list - Interface of a list which generated this event,
- // checkedItems - Array of indices of marked elements.
+ // - list - Interface of a list which generated this event,
+ // - checkedItems - Array of indices of marked elements.
//
// Allowed listener formats:
- // `func(checkedItems []int)`,
- // `func(list rui.ListView)`,
- // `func()`.
+ //
+ // func(checkedItems []int)
+ // func(list rui.ListView)
+ // func()
ListItemCheckedEvent PropertyName = "list-item-checked"
// ListItemStyle is the constant for "list-item-style" property tag.
//
- // Used by `ListView`.
+ // Used by ListView.
// Defines the style of an unselected item.
//
- // Supported types: `string`.
+ // Supported types: string.
ListItemStyle PropertyName = "list-item-style"
// CurrentStyle is the constant for "current-style" property tag.
//
- // Used by `ListView`.
- // Defines the style of the selected item when the `ListView` is focused.
+ // Used by ListView.
+ // Defines the style of the selected item when the ListView is focused.
//
- // Supported types: `string`.
+ // Supported types: string.
CurrentStyle PropertyName = "current-style"
// CurrentInactiveStyle is the constant for "current-inactive-style" property tag.
//
- // Used by `ListView`.
- // Defines the style of the selected item when the `ListView` is unfocused.
+ // Used by ListView.
+ // Defines the style of the selected item when the ListView is unfocused.
//
- // Supported types: `string`.
+ // Supported types: string.
CurrentInactiveStyle PropertyName = "current-inactive-style"
)
diff --git a/mediaPlayer.go b/mediaPlayer.go
index 518b7a5..83a5c9a 100644
--- a/mediaPlayer.go
+++ b/mediaPlayer.go
@@ -11,815 +11,496 @@ import (
const (
// Controls is the constant for "controls" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Controls whether the browser need to provide controls to allow user to control audio playback, volume, seeking and
- // pause/resume playback. Default value is `false`.
+ // pause/resume playback. Default value is false.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - The browser will offer controls to allow the user to control audio playback, volume, seeking and pause/resume playback.
- // `false` or `0` or "false", "no", "off", "0" - No controls will be visible to the end user.
- //
- // Usage in `VideoPlayer`:
- // Whether the browser need to provide controls to allow user to control video playback, volume, seeking and pause/resume
- // playback. Default value is `false`.
- //
- // Supported types: `bool`, `int`, `string`.
- //
- // Values:
- // `true` or `1` or "true", "yes", "on", "1" - The browser will offer controls to allow the user to control video playback, volume, seeking and pause/resume playback.
- // `false` or `0` or "false", "no", "off", "0" - No controls will be visible to the end user.
+ // - true, 1, "true", "yes", "on", "1" - The browser will offer controls to allow the user to control audio playback, volume, seeking and pause/resume playback.
+ // - false, 0, "false", "no", "off", "0" - No controls will be visible to the end user.
Controls PropertyName = "controls"
// Loop is the constant for "loop" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
- // Controls whether the audio player will play media in a loop. Default value is `false`.
+ // Controls whether the audio player will play media in a loop. Default value is false.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - The audio player will automatically seek back to the start upon reaching the end of the audio.
- // `false` or `0` or "false", "no", "off", "0" - Audio player will stop playing when the end of the media file has been reached.
- //
- // Usage in `VideoPlayer`:
- // Controls whether the video player will play media in a loop. Default value is `false`.
- //
- // Supported types: `bool`, `int`, `string`.
- //
- // Values:
- // `true` or `1` or "true", "yes", "on", "1" - The video player will automatically seek back to the start upon reaching the end of the video.
- // `false` or `0` or "false", "no", "off", "0" - Video player will stop playing when the end of the media file has been reached.
+ // - true, 1, "true", "yes", "on", "1" - The audio player will automatically seek back to the start upon reaching the end of the audio.
+ // - false, 0, "false", "no", "off", "0" - Audio player will stop playing when the end of the media file has been reached.
Loop PropertyName = "loop"
// Muted is the constant for "muted" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
- // Controls whether the audio will be initially silenced. Default value is `false`.
+ // Controls whether the audio will be initially silenced. Default value is false.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - Audio will be muted.
- // `false` or `0` or "false", "no", "off", "0" - Audio playing normally.
- //
- // Usage in `VideoPlayer`:
- // Controls whether the video will be initially silenced. Default value is `false`.
- //
- // Supported types: `bool`, `int`, `string`.
- //
- // Values:
- // `true` or `1` or "true", "yes", "on", "1" - Video will be muted.
- // `false` or `0` or "false", "no", "off", "0" - Video playing normally.
+ // - true, 1, "true", "yes", "on", "1" - Audio will be muted.
+ // - false, 0, "false", "no", "off", "0" - Audio playing normally.
Muted PropertyName = "muted"
// Preload is the constant for "preload" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Property is intended to provide a hint to the browser about what the author thinks will lead to the best user
// experience. Default value is different for each browser.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`PreloadNone`) or "none" - Media file must not be pre-loaded.
- // `1`(`PreloadMetadata`) or "metadata" - Only metadata is preloaded.
- // `2`(`PreloadAuto`) or "auto" - The entire media file can be downloaded even if the user doesn't have to use it.
- //
- // Usage in `VideoPlayer`:
- // Property is intended to provide a hint to the browser about what the author thinks will lead to the best user
- // experience. Default value is different for each browser.
- //
- // Supported types: `int`, `string`.
- //
- // Values:
- // `0`(`PreloadNone`) or "none" - Media file must not be pre-loaded.
- // `1`(`PreloadMetadata`) or "metadata" - Only metadata is preloaded.
- // `2`(`PreloadAuto`) or "auto" - The entire media file can be downloaded even if the user doesn't have to use it.
+ // - 0 (PreloadNone) or "none" - Media file must not be pre-loaded.
+ // - 1 (PreloadMetadata) or "metadata" - Only metadata is preloaded.
+ // - 2 (PreloadAuto) or "auto" - The entire media file can be downloaded even if the user doesn't have to use it.
Preload PropertyName = "preload"
// AbortEvent is the constant for "abort-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Fired when the resource was not fully loaded, but not as the result of an error.
//
// General listener format:
- // `func(player rui.MediaPlayer)`.
+ //
+ // func(player rui.MediaPlayer)
//
// where:
// player - Interface of a player which generated this event.
//
// Allowed listener formats:
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Fired when the resource was not fully loaded, but not as the result of an error.
- //
- // General listener format:
- // `func(player rui.MediaPlayer)`.
- //
- // where:
- // player - Interface of a player which generated this event.
- //
- // Allowed listener formats:
- // `func()`.
+ // func()
AbortEvent PropertyName = "abort-event"
// CanPlayEvent is the constant for "can-play-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Occur when the browser can play the media, but estimates that not enough data has been loaded to play the media up to
// its end without having to stop for further buffering of content.
//
// General listener format:
- // `func(player rui.MediaPlayer)`.
+ //
+ // func(player rui.MediaPlayer)
//
// where:
// player - Interface of a player which generated this event.
//
// Allowed listener formats:
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Occur when the browser can play the media, but estimates that not enough data has been loaded to play the media up to
- // its end without having to stop for further buffering of content.
- //
- // General listener format:
- // `func(player rui.MediaPlayer)`.
- //
- // where:
- // player - Interface of a player which generated this event.
- //
- // Allowed listener formats:
- // `func()`.
+ // func()
CanPlayEvent PropertyName = "can-play-event"
// CanPlayThroughEvent is the constant for "can-play-through-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Occur when the browser estimates it can play the media up to its end without stopping for content buffering.
//
// General listener format:
- // `func(player rui.MediaPlayer)`.
+ //
+ // func(player rui.MediaPlayer)
//
// where:
// player - Interface of a player which generated this event.
//
// Allowed listener formats:
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Occur when the browser estimates it can play the media up to its end without stopping for content buffering.
- //
- // General listener format:
- // `func(player rui.MediaPlayer)`.
- //
- // where:
- // player - Interface of a player which generated this event.
- //
- // Allowed listener formats:
- // `func()`.
+ // func()
CanPlayThroughEvent PropertyName = "can-play-through-event"
// CompleteEvent is the constant for "complete-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Occur when the rendering of an OfflineAudioContext has been terminated.
//
// General listener format:
- // `func(player rui.MediaPlayer)`.
+ //
+ // func(player rui.MediaPlayer)
//
// where:
// player - Interface of a player which generated this event.
//
// Allowed listener formats:
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Occur when the rendering of an OfflineAudioContext has been terminated.
- //
- // General listener format:
- // `func(player rui.MediaPlayer)`.
- //
- // where:
- // player - Interface of a player which generated this event.
- //
- // Allowed listener formats:
- // `func()`.
+ // func()
CompleteEvent PropertyName = "complete-event"
// DurationChangedEvent is the constant for "duration-changed-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Occur when the duration attribute has been updated.
//
// General listener format:
- // `func(player rui.MediaPlayer, duration float64)`.
+ //
+ // func(player rui.MediaPlayer, duration float64).
//
// where:
- // player - Interface of a player which generated this event,
- // duration - Current duration.
+ // - player - Interface of a player which generated this event,
+ // - duration - Current duration.
//
// Allowed listener formats:
- // `func(player rui.MediaPlayer)`,
- // `func(duration float64)`,
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Occur when the duration attribute has been updated.
- //
- // General listener format:
- // `func(player rui.MediaPlayer, duration float64)`.
- //
- // where:
- // player - Interface of a player which generated this event,
- // duration - Current duration.
- //
- // Allowed listener formats:
- // `func(player rui.MediaPlayer)`,
- // `func(duration float64)`,
- // `func()`.
+ // func(player rui.MediaPlayer),
+ // func(duration float64),
+ // func()
DurationChangedEvent PropertyName = "duration-changed-event"
// EmptiedEvent is the constant for "emptied-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Occur when the media has become empty; for example, this event is sent if the media has already been loaded(or
// partially loaded), and the HTMLMediaElement.load method is called to reload it.
//
// General listener format:
- // `func(player rui.MediaPlayer)`.
+ //
+ // func(player rui.MediaPlayer)
//
// where:
// player - Interface of a player which generated this event.
//
// Allowed listener formats:
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Occur when the media has become empty; for example, this event is sent if the media has already been loaded(or
- // partially loaded), and the HTMLMediaElement.load method is called to reload it.
- //
- // General listener format:
- // `func(player rui.MediaPlayer)`.
- //
- // where:
- // player - Interface of a player which generated this event.
- //
- // Allowed listener formats:
- // `func()`.
+ // func()
EmptiedEvent PropertyName = "emptied-event"
// EndedEvent is the constant for "ended-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Occur when the playback has stopped because the end of the media was reached.
//
// General listener format:
- // `func(player rui.MediaPlayer)`.
+ //
+ // func(player rui.MediaPlayer)
//
// where:
// player - Interface of a player which generated this event.
//
// Allowed listener formats:
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Occur when the playback has stopped because the end of the media was reached.
- //
- // General listener format:
- // `func(player rui.MediaPlayer)`.
- //
- // where:
- // player - Interface of a player which generated this event.
- //
- // Allowed listener formats:
- // `func()`.
+ // func()
EndedEvent PropertyName = "ended-event"
// LoadedDataEvent is the constant for "loaded-data-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Occur when the first frame of the media has finished loading.
//
// General listener format:
- // `func(player rui.MediaPlayer)`.
+ //
+ // func(player rui.MediaPlayer)
//
// where:
// player - Interface of a player which generated this event.
//
// Allowed listener formats:
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Occur when the first frame of the media has finished loading.
- //
- // General listener format:
- // `func(player rui.MediaPlayer)`.
- //
- // where:
- // player - Interface of a player which generated this event.
- //
- // Allowed listener formats:
- // `func()`.
+ // func()
LoadedDataEvent PropertyName = "loaded-data-event"
// LoadedMetadataEvent is the constant for "loaded-metadata-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Occur when the metadata has been loaded.
//
// General listener format:
- // `func(player rui.MediaPlayer)`.
+ //
+ // func(player rui.MediaPlayer)
//
// where:
// player - Interface of a player which generated this event.
//
// Allowed listener formats:
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Occur when the metadata has been loaded.
- //
- // General listener format:
- // `func(player rui.MediaPlayer)`.
- //
- // where:
- // player - Interface of a player which generated this event.
- //
- // Allowed listener formats:
- // `func()`.
+ // func()
LoadedMetadataEvent PropertyName = "loaded-metadata-event"
// LoadStartEvent is the constant for "load-start-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Fired when the browser has started to load a resource.
//
// General listener format:
- // `func(player rui.MediaPlayer)`.
+ //
+ // func(player rui.MediaPlayer)
//
// where:
// player - Interface of a player which generated this event.
//
// Allowed listener formats:
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Fired when the browser has started to load a resource.
- //
- // General listener format:
- // `func(player rui.MediaPlayer)`.
- //
- // where:
- // player - Interface of a player which generated this event.
- //
- // Allowed listener formats:
- // `func()`.
+ // func()
LoadStartEvent PropertyName = "load-start-event"
// PauseEvent is the constant for "pause-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Occur when the playback has been paused.
//
// General listener format:
- // `func(player rui.MediaPlayer)`.
+ //
+ // func(player rui.MediaPlayer)
//
// where:
// player - Interface of a player which generated this event.
//
// Allowed listener formats:
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Occur when the playback has been paused.
- //
- // General listener format:
- // `func(player rui.MediaPlayer)`.
- //
- // where:
- // player - Interface of a player which generated this event.
- //
- // Allowed listener formats:
- // `func()`.
+ // func()
PauseEvent PropertyName = "pause-event"
// PlayEvent is the constant for "play-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Occur when the playback has begun.
//
// General listener format:
- // `func(player rui.MediaPlayer)`.
+ //
+ // func(player rui.MediaPlayer)
//
// where:
// player - Interface of a player which generated this event.
//
// Allowed listener formats:
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Occur when the playback has begun.
- //
- // General listener format:
- // `func(player rui.MediaPlayer)`.
- //
- // where:
- // player - Interface of a player which generated this event.
- //
- // Allowed listener formats:
- // `func()`.
+ // func()
PlayEvent PropertyName = "play-event"
// PlayingEvent is the constant for "playing-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Occur when the playback is ready to start after having been paused or delayed due to lack of data.
//
// General listener format:
- // `func(player rui.MediaPlayer)`.
+ //
+ // func(player rui.MediaPlayer)
//
// where:
// player - Interface of a player which generated this event.
//
// Allowed listener formats:
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Occur when the playback is ready to start after having been paused or delayed due to lack of data.
- //
- // General listener format:
- // `func(player rui.MediaPlayer)`.
- //
- // where:
- // player - Interface of a player which generated this event.
- //
- // Allowed listener formats:
- // `func()`.
+ // func()
PlayingEvent PropertyName = "playing-event"
// ProgressEvent is the constant for "progress-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Fired periodically as the browser loads a resource.
//
// General listener format:
- // `func(player rui.MediaPlayer)`.
+ //
+ // func(player rui.MediaPlayer)
//
// where:
// player - Interface of a player which generated this event.
//
// Allowed listener formats:
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Fired periodically as the browser loads a resource.
- //
- // General listener format:
- // `func(player rui.MediaPlayer)`.
- //
- // where:
- // player - Interface of a player which generated this event.
- //
- // Allowed listener formats:
- // `func()`.
+ // func()
ProgressEvent PropertyName = "progress-event"
// RateChangedEvent is the constant for "rate-changed-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Occur when the playback rate has changed.
//
// General listener format:
- // `func(player rui.MediaPlayer, rate float64)`.
+ //
+ // func(player rui.MediaPlayer, rate float64).
//
// where:
- // player - Interface of a player which generated this event,
- // rate - Playback rate.
+ // - player - Interface of a player which generated this event,
+ // - rate - Playback rate.
//
// Allowed listener formats:
- // `func(player rui.MediaPlayer)`,
- // `func(rate float64)`,
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Occur when the playback rate has changed.
- //
- // General listener format:
- // `func(player rui.MediaPlayer, rate float64)`.
- //
- // where:
- // player - Interface of a player which generated this event,
- // rate - Playback rate.
- //
- // Allowed listener formats:
- // `func(player rui.MediaPlayer)`,
- // `func(rate float64)`,
- // `func()`.
+ // func(player rui.MediaPlayer),
+ // func(rate float64),
+ // func()
RateChangedEvent PropertyName = "rate-changed-event"
// SeekedEvent is the constant for "seeked-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Occur when a seek operation completed.
//
// General listener format:
- // `func(player rui.MediaPlayer)`.
+ //
+ // func(player rui.MediaPlayer)
//
// where:
// player - Interface of a player which generated this event.
//
// Allowed listener formats:
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Occur when a seek operation completed.
- //
- // General listener format:
- // `func(player rui.MediaPlayer)`.
- //
- // where:
- // player - Interface of a player which generated this event.
- //
- // Allowed listener formats:
- // `func()`.
+ // func()
SeekedEvent PropertyName = "seeked-event"
// SeekingEvent is the constant for "seeking-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Occur when a seek operation has began.
//
// General listener format:
- // `func(player rui.MediaPlayer)`.
+ //
+ // func(player rui.MediaPlayer)
//
// where:
// player - Interface of a player which generated this event.
//
// Allowed listener formats:
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Occur when a seek operation has began.
- //
- // General listener format:
- // `func(player rui.MediaPlayer)`.
- //
- // where:
- // player - Interface of a player which generated this event.
- //
- // Allowed listener formats:
- // `func()`.
+ // func()
SeekingEvent PropertyName = "seeking-event"
// StalledEvent is the constant for "stalled-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Occur when the user agent is trying to fetch media data, but data is unexpectedly not forthcoming.
//
// General listener format:
- // `func(player rui.MediaPlayer)`.
+ //
+ // func(player rui.MediaPlayer)
//
// where:
// player - Interface of a player which generated this event.
//
// Allowed listener formats:
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Occur when the user agent is trying to fetch media data, but data is unexpectedly not forthcoming.
- //
- // General listener format:
- // `func(player rui.MediaPlayer)`.
- //
- // where:
- // player - Interface of a player which generated this event.
- //
- // Allowed listener formats:
- // `func()`.
+ // func()
StalledEvent PropertyName = "stalled-event"
// SuspendEvent is the constant for "suspend-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Occur when the media data loading has been suspended.
//
// General listener format:
- // `func(player rui.MediaPlayer)`.
+ //
+ // func(player rui.MediaPlayer)
//
// where:
// player - Interface of a player which generated this event.
//
// Allowed listener formats:
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Occur when the media data loading has been suspended.
- //
- // General listener format:
- // `func(player rui.MediaPlayer)`.
- //
- // where:
- // player - Interface of a player which generated this event.
- //
- // Allowed listener formats:
- // `func()`.
+ // func()
SuspendEvent PropertyName = "suspend-event"
// TimeUpdateEvent is the constant for "time-update-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Occur when the time indicated by the currentTime attribute has been updated.
//
// General listener format:
- // `func(player rui.MediaPlayer, time float64)`.
+ //
+ // func(player rui.MediaPlayer, time float64).
//
// where:
- // player - Interface of a player which generated this event,
- // time - Current time.
+ // - player - Interface of a player which generated this event,
+ // - time - Current time.
//
// Allowed listener formats:
- // `func(player rui.MediaPlayer)`,
- // `func(time float64)`,
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Occur when the time indicated by the currentTime attribute has been updated.
- //
- // General listener format:
- // `func(player rui.MediaPlayer, time float64)`.
- //
- // where:
- // player - Interface of a player which generated this event,
- // time - Current time.
- //
- // Allowed listener formats:
- // `func(player rui.MediaPlayer)`,
- // `func(time float64)`,
- // `func()`.
+ // func(player rui.MediaPlayer),
+ // func(time float64),
+ // func()
TimeUpdateEvent PropertyName = "time-update-event"
// VolumeChangedEvent is the constant for "volume-changed-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Occur when the volume has changed.
//
// General listener format:
- // `func(player rui.MediaPlayer, volume float64)`.
+ //
+ // func(player rui.MediaPlayer, volume float64).
//
// where:
- // player - Interface of a player which generated this event,
- // volume - New volume level.
+ // - player - Interface of a player which generated this event,
+ // - volume - New volume level.
//
// Allowed listener formats:
- // `func(player rui.MediaPlayer)`,
- // `func(volume float64)`,
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Occur when the volume has changed.
- //
- // General listener format:
- // `func(player rui.MediaPlayer, volume float64)`.
- //
- // where:
- // player - Interface of a player which generated this event,
- // volume - New volume level.
- //
- // Allowed listener formats:
- // `func(player rui.MediaPlayer)`,
- // `func(volume float64)`,
- // `func()`.
+ // func(player rui.MediaPlayer),
+ // func(volume float64),
+ // func()
VolumeChangedEvent PropertyName = "volume-changed-event"
// WaitingEvent is the constant for "waiting-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Occur when the playback has stopped because of a temporary lack of data.
//
// General listener format:
- // `func(player rui.MediaPlayer)`.
+ //
+ // func(player rui.MediaPlayer)
//
// where:
// player - Interface of a player which generated this event.
//
// Allowed listener formats:
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Occur when the playback has stopped because of a temporary lack of data.
- //
- // General listener format:
- // `func(player rui.MediaPlayer)`.
- //
- // where:
- // player - Interface of a player which generated this event.
- //
- // Allowed listener formats:
- // `func()`.
+ // func()
WaitingEvent PropertyName = "waiting-event"
// PlayerErrorEvent is the constant for "player-error-event" property tag.
//
- // Used by `AudioPlayer`, `VideoPlayer`.
+ // Used by AudioPlayer, VideoPlayer.
//
- // Usage in `AudioPlayer`:
// Fired when the resource could not be loaded due to an error(for example, a network connectivity problem).
//
// General listener format:
- // `func(player rui.MediaPlayer, code int, message string)`.
+ //
+ // func(player rui.MediaPlayer, code int, message string).
//
// where:
- // player - Interface of a player which generated this event,
- // code - Error code. See below,
- // message - Error message,
+ // - player - Interface of a player which generated this event,
+ // - code - Error code. See below,
+ // - message - Error message,
+
// Error codes:
- // `0`(`PlayerErrorUnknown`) - Unknown error,
- // `1`(`PlayerErrorAborted`) - Fetching the associated resource was interrupted by a user request,
- // `2`(`PlayerErrorNetwork`) - Some kind of network error has occurred that prevented the media from successfully ejecting, even though it was previously available,
- // `3`(`PlayerErrorDecode`) - Although the resource was previously identified as being used, an error occurred while trying to decode the media resource,
- // `4`(`PlayerErrorSourceNotSupported`) - The associated resource object or media provider was found to be invalid.
+ // - 0 (PlayerErrorUnknown) - Unknown error,
+ // - 1 (PlayerErrorAborted) - Fetching the associated resource was interrupted by a user request,
+ // - 2 (PlayerErrorNetwork) - Some kind of network error has occurred that prevented the media from successfully ejecting, even though it was previously available,
+ // - 3 (PlayerErrorDecode) - Although the resource was previously identified as being used, an error occurred while trying to decode the media resource,
+ // - 4 (PlayerErrorSourceNotSupported) - The associated resource object or media provider was found to be invalid.
//
// Allowed listener formats:
- // `func(code int, message string)`,
- // `func(player rui.MediaPlayer)`,
- // `func()`.
//
- // Usage in `VideoPlayer`:
- // Fired when the resource could not be loaded due to an error(for example, a network connectivity problem).
- //
- // General listener format:
- // `func(player rui.MediaPlayer, code int, message string)`.
- //
- // where:
- // player - Interface of a player which generated this event,
- // code - Error code. See below,
- // message - Error message,
- // Error codes:
- // `0`(`PlayerErrorUnknown`) - Unknown error,
- // `1`(`PlayerErrorAborted`) - Fetching the associated resource was interrupted by a user request,
- // `2`(`PlayerErrorNetwork`) - Some kind of network error has occurred that prevented the media from successfully ejecting, even though it was previously available,
- // `3`(`PlayerErrorDecode`) - Although the resource was previously identified as being used, an error occurred while trying to decode the media resource,
- // `4`(`PlayerErrorSourceNotSupported`) - The associated resource object or media provider was found to be invalid.
- //
- // Allowed listener formats:
- // `func(code int, message string)`,
- // `func(player rui.MediaPlayer)`,
- // `func()`.
+ // func(code int, message string),
+ // func(player rui.MediaPlayer),
+ // func()
PlayerErrorEvent PropertyName = "player-error-event"
// PreloadNone - value of the view "preload" property: indicates that the audio/video should not be preloaded.
diff --git a/mouseEvents.go b/mouseEvents.go
index e338fca..a184483 100644
--- a/mouseEvents.go
+++ b/mouseEvents.go
@@ -9,150 +9,166 @@ import (
const (
// ClickEvent is the constant for "click-event" property tag.
//
- // Used by `View`.
+ // Used by View.
// Occur when the user clicks on the view.
//
// General listener format:
- // `func(view rui.View, event rui.MouseEvent)`.
+ //
+ // func(view rui.View, event rui.MouseEvent)
//
// where:
- // view - Interface of a view which generated this event,
- // event - Mouse event.
+ // - view - Interface of a view which generated this event,
+ // - event - Mouse event.
//
// Allowed listener formats:
- // `func(view rui.View)`,
- // `func(event rui.MouseEvent)`,
- // `func()`.
+ //
+ // func(view rui.View)
+ // func(event rui.MouseEvent)
+ // func()
ClickEvent PropertyName = "click-event"
// DoubleClickEvent is the constant for "double-click-event" property tag.
//
- // Used by `View`.
+ // Used by View.
// Occur when the user double clicks on the view.
//
// General listener format:
- // `func(view rui.View, event rui.MouseEvent)`.
+ //
+ // func(view rui.View, event rui.MouseEvent)
//
// where:
- // view - Interface of a view which generated this event,
- // event - Mouse event.
+ // - view - Interface of a view which generated this event,
+ // - event - Mouse event.
//
// Allowed listener formats:
- // `func(view rui.View)`,
- // `func(event rui.MouseEvent)`,
- // `func()`.
+ //
+ // func(view rui.View)
+ // func(event rui.MouseEvent)
+ // func()
DoubleClickEvent PropertyName = "double-click-event"
// MouseDown is the constant for "mouse-down" property tag.
//
- // Used by `View`.
+ // Used by View.
// Is fired at a View when a pointing device button is pressed while the pointer is inside the view.
//
// General listener format:
- // `func(view rui.View, event rui.MouseEvent)`.
+ //
+ // func(view rui.View, event rui.MouseEvent)
//
// where:
- // view - Interface of a view which generated this event,
- // event - Mouse event.
+ // - view - Interface of a view which generated this event,
+ // - event - Mouse event.
//
// Allowed listener formats:
- // `func(view rui.View)`,
- // `func(event rui.MouseEvent)`,
- // `func()`.
+ //
+ // func(view rui.View)
+ // func(event rui.MouseEvent)
+ // func()
MouseDown PropertyName = "mouse-down"
// MouseUp is the constant for "mouse-up" property tag.
//
- // Used by `View`.
+ // Used by View.
// Is fired at a View when a button on a pointing device (such as a mouse or trackpad) is released while the pointer is
// located inside it. "mouse-up" events are the counterpoint to "mouse-down" events.
//
// General listener format:
- // `func(view rui.View, event rui.MouseEvent)`.
+ //
+ // func(view rui.View, event rui.MouseEvent)
//
// where:
- // view - Interface of a view which generated this event,
- // event - Mouse event.
+ // - view - Interface of a view which generated this event,
+ // - event - Mouse event.
//
// Allowed listener formats:
- // `func(view rui.View)`,
- // `func(event rui.MouseEvent)`,
- // `func()`.
+ //
+ // func(view rui.View)
+ // func(event rui.MouseEvent)
+ // func()
MouseUp PropertyName = "mouse-up"
// MouseMove is the constant for "mouse-move" property tag.
//
- // Used by `View`.
+ // Used by View.
// Is fired at a view when a pointing device(usually a mouse) is moved while the cursor's hotspot is inside it.
//
// General listener format:
- // `func(view rui.View, event rui.MouseEvent)`.
+ //
+ // func(view rui.View, event rui.MouseEvent)
//
// where:
- // view - Interface of a view which generated this event,
- // event - Mouse event.
+ // - view - Interface of a view which generated this event,
+ // - event - Mouse event.
//
// Allowed listener formats:
- // `func(view rui.View)`,
- // `func(event rui.MouseEvent)`,
- // `func()`.
+ //
+ // func(view rui.View)
+ // func(event rui.MouseEvent)
+ // func()
MouseMove PropertyName = "mouse-move"
// MouseOut is the constant for "mouse-out" property tag.
//
- // Used by `View`.
+ // Used by View.
// Is fired at a View when a pointing device (usually a mouse) is used to move the cursor so that it is no longer
// contained within the view or one of its children. "mouse-out" is also delivered to a view if the cursor enters a child
// view, because the child view obscures the visible area of the view.
//
// General listener format:
- // `func(view rui.View, event rui.MouseEvent)`.
+ //
+ // func(view rui.View, event rui.MouseEvent)
//
// where:
- // view - Interface of a view which generated this event,
- // event - Mouse event.
+ // - view - Interface of a view which generated this event,
+ // - event - Mouse event.
//
// Allowed listener formats:
- // `func(view rui.View)`,
- // `func(event rui.MouseEvent)`,
- // `func()`.
+ //
+ // func(view rui.View)
+ // func(event rui.MouseEvent)
+ // func()
MouseOut PropertyName = "mouse-out"
// MouseOver is the constant for "mouse-over" property tag.
//
- // Used by `View`.
+ // Used by View.
// Is fired at a View when a pointing device (such as a mouse or trackpad) is used to move the cursor onto the view or one
// of its child views.
//
// General listener format:
- // `func(view rui.View, event rui.MouseEvent)`.
+ //
+ // func(view rui.View, event rui.MouseEvent)
//
// where:
- // view - Interface of a view which generated this event,
- // event - Mouse event.
+ // - view - Interface of a view which generated this event,
+ // - event - Mouse event.
//
// Allowed listener formats:
- // `func(view rui.View)`,
- // `func(event rui.MouseEvent)`,
- // `func()`.
+ //
+ // func(view rui.View)
+ // func(event rui.MouseEvent)
+ // func()
MouseOver PropertyName = "mouse-over"
// ContextMenuEvent is the constant for "context-menu-event" property tag.
//
- // Used by `View`.
+ // Used by View.
// Occur when the user calls the context menu by the right mouse clicking.
//
// General listener format:
- // `func(view rui.View, event rui.MouseEvent)`.
+ //
+ // func(view rui.View, event rui.MouseEvent)
//
// where:
- // view - Interface of a view which generated this event,
- // event - Mouse event.
+ // - view - Interface of a view which generated this event,
+ // - event - Mouse event.
//
// Allowed listener formats:
- // `func(view rui.View)`,
- // `func(event rui.MouseEvent)`,
- // `func()`.
+ //
+ // func(view rui.View)
+ // func(event rui.MouseEvent)
+ // func()
ContextMenuEvent PropertyName = "context-menu-event"
// PrimaryMouseButton is a number of the main pressed button, usually the left button or the un-initialized state
diff --git a/numberPicker.go b/numberPicker.go
index 5f6fac0..c664bc0 100644
--- a/numberPicker.go
+++ b/numberPicker.go
@@ -11,84 +11,86 @@ import (
const (
// NumberChangedEvent is the constant for "number-changed" property tag.
//
- // Used by `NumberPicker`.
+ // Used by NumberPicker.
// Set listener(s) that track the change in the entered value.
//
// General listener format:
- // `func(picker rui.NumberPicker, newValue, oldValue float64)`.
+ //
+ // func(picker rui.NumberPicker, newValue float64, oldValue float64)
//
// where:
- // picker - Interface of a number picker which generated this event,
- // newValue - New value,
- // oldValue - Old Value.
+ // - picker - Interface of a number picker which generated this event,
+ // - newValue - New value,
+ // - oldValue - Old Value.
//
// Allowed listener formats:
- // `func(picker rui.NumberPicker, newValue float64)`,
- // `func(newValue, oldValue float64)`,
- // `func(newValue float64)`,
- // `func()`.
+ //
+ // func(picker rui.NumberPicker, newValue float64)
+ // func(newValue float64, oldValue float64)
+ // func(newValue float64)
+ // func()
NumberChangedEvent PropertyName = "number-changed"
// NumberPickerType is the constant for "number-picker-type" property tag.
//
- // Used by `NumberPicker`.
+ // Used by NumberPicker.
// Sets the visual representation.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NumberEditor`) or "editor" - Displayed as an editor.
- // `1`(`NumberSlider`) or "slider" - Displayed as a slider.
+ // - 0 (NumberEditor) or "editor" - Displayed as an editor.
+ // - 1 (NumberSlider) or "slider" - Displayed as a slider.
NumberPickerType PropertyName = "number-picker-type"
// NumberPickerMin is the constant for "number-picker-min" property tag.
//
- // Used by `NumberPicker`.
+ // Used by NumberPicker.
// Set the minimum value. The default value is 0.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
NumberPickerMin PropertyName = "number-picker-min"
// NumberPickerMax is the constant for "number-picker-max" property tag.
//
- // Used by `NumberPicker`.
+ // Used by NumberPicker.
// Set the maximum value. The default value is 1.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
NumberPickerMax PropertyName = "number-picker-max"
// NumberPickerStep is the constant for "number-picker-step" property tag.
//
- // Used by `NumberPicker`.
+ // Used by NumberPicker.
// Set the value change step.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
NumberPickerStep PropertyName = "number-picker-step"
// NumberPickerValue is the constant for "number-picker-value" property tag.
//
- // Used by `NumberPicker`.
+ // Used by NumberPicker.
// Current value. The default value is 0.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
NumberPickerValue PropertyName = "number-picker-value"
// NumberPickerValue is the constant for "number-picker-value" property tag.
//
- // Used by `NumberPicker`.
+ // Used by NumberPicker.
// Precision of displaying fractional part in editor. The default value is 0 (not used).
//
- // Supported types: `int`, `int8`...`int64`, `uint`, `uint8`...`uint64`, `string`.
+ // Supported types: int, int8...int64, uint, uint8...uint64, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
NumberPickerPrecision PropertyName = "number-picker-precision"
)
diff --git a/outline.go b/outline.go
index 160cd99..7ca284e 100644
--- a/outline.go
+++ b/outline.go
@@ -20,11 +20,10 @@ type outlinePropertyData struct {
}
// NewOutlineProperty creates the new OutlineProperty.
+//
// The following properties can be used:
-//
-// "color" (ColorTag). Determines the line color (Color);
-//
-// "width" (Width). Determines the line thickness (SizeUnit).
+// - "color" (ColorTag) - Determines the line color (Color);
+// - "width" (Width) - Determines the line thickness (SizeUnit).
func NewOutlineProperty(params Params) OutlineProperty {
outline := new(outlinePropertyData)
outline.init()
diff --git a/path.go b/path.go
index 889c293..5e08d82 100644
--- a/path.go
+++ b/path.go
@@ -11,44 +11,44 @@ type Path interface {
// ArcTo adds a circular arc to the current sub-path, using the given control points and radius.
// The arc is automatically connected to the path's latest point with a straight line, if necessary.
- // x0, y0 - coordinates of the first control point;
- // x1, y1 - coordinates of the second control point;
- // radius - the arc's radius. Must be non-negative.
+ // - x0, y0 - coordinates of the first control point;
+ // - x1, y1 - coordinates of the second control point;
+ // - radius - the arc's radius. Must be non-negative.
ArcTo(x0, y0, x1, y1, radius float64)
// Arc adds a circular arc to the current sub-path.
- // x, y - coordinates of the arc's center;
- // radius - the arc's radius. Must be non-negative;
- // startAngle - the angle at which the arc starts, measured clockwise from the positive
+ // - x, y - coordinates of the arc's center;
+ // - radius - the arc's radius. Must be non-negative;
+ // - startAngle - the angle at which the arc starts, measured clockwise from the positive
// x-axis and expressed in radians.
- // endAngle - the angle at which the arc ends, measured clockwise from the positive
+ // - endAngle - the angle at which the arc ends, measured clockwise from the positive
// x-axis and expressed in radians.
- // clockwise - if true, causes the arc to be drawn clockwise between the start and end angles,
+ // - clockwise - if true, causes the arc to be drawn clockwise between the start and end angles,
// otherwise - counter-clockwise
Arc(x, y, radius, startAngle, endAngle float64, clockwise bool)
// BezierCurveTo adds a cubic Bézier curve to the current sub-path. The starting point is
// the latest point in the current path.
- // cp0x, cp0y - coordinates of the first control point;
- // cp1x, cp1y - coordinates of the second control point;
- // x, y - coordinates of the end point.
+ // - cp0x, cp0y - coordinates of the first control point;
+ // - cp1x, cp1y - coordinates of the second control point;
+ // - x, y - coordinates of the end point.
BezierCurveTo(cp0x, cp0y, cp1x, cp1y, x, y float64)
// QuadraticCurveTo adds a quadratic Bézier curve to the current sub-path.
- // cpx, cpy - coordinates of the control point;
- // x, y - coordinates of the end point.
+ // - cpx, cpy - coordinates of the control point;
+ // - x, y - coordinates of the end point.
QuadraticCurveTo(cpx, cpy, x, y float64)
// Ellipse adds an elliptical arc to the current sub-path
- // x, y - coordinates of the ellipse's center;
- // radiusX - the ellipse's major-axis radius. Must be non-negative;
- // radiusY - the ellipse's minor-axis radius. Must be non-negative;
- // rotation - the rotation of the ellipse, expressed in radians;
- // startAngle - the angle at which the ellipse starts, measured clockwise
+ // - x, y - coordinates of the ellipse's center;
+ // - radiusX - the ellipse's major-axis radius. Must be non-negative;
+ // - radiusY - the ellipse's minor-axis radius. Must be non-negative;
+ // - rotation - the rotation of the ellipse, expressed in radians;
+ // - startAngle - the angle at which the ellipse starts, measured clockwise
// from the positive x-axis and expressed in radians;
- // endAngle - the angle at which the ellipse ends, measured clockwise
+ // - endAngle - the angle at which the ellipse ends, measured clockwise
// from the positive x-axis and expressed in radians.
- // clockwise - if true, draws the ellipse clockwise, otherwise draws counter-clockwise
+ // - clockwise - if true, draws the ellipse clockwise, otherwise draws counter-clockwise
Ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle float64, clockwise bool)
// Close adds a straight line from the current point to the start of the current sub-path.
diff --git a/pointerEvents.go b/pointerEvents.go
index 3d42cb8..57d226b 100644
--- a/pointerEvents.go
+++ b/pointerEvents.go
@@ -4,114 +4,126 @@ package rui
const (
// PointerDown is the constant for "pointer-down" property tag.
//
- // Used by `View`.
+ // Used by View.
// Fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at
// least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is
// fired when the stylus makes physical contact with the digitizer.
//
// General listener format:
- // `func(view rui.View, event rui.PointerEvent)`.
+ //
+ // func(view rui.View, event rui.PointerEvent)
//
// where:
- // view - Interface of a view which generated this event,
- // event - Pointer event.
+ // - view - Interface of a view which generated this event,
+ // - event - Pointer event.
//
// Allowed listener formats:
- // `func(event rui.PointerEvent)`,
- // `func(view rui.View)`,
- // `func()`.
+ //
+ // func(event rui.PointerEvent)
+ // func(view rui.View)
+ // func()
PointerDown PropertyName = "pointer-down"
// PointerUp is the constant for "pointer-up" property tag.
//
- // Used by `View`.
+ // Used by View.
// Is fired when a pointer is no longer active.
//
// General listener format:
- // `func(view rui.View, event rui.PointerEvent)`.
+ //
+ // func(view rui.View, event rui.PointerEvent)
//
// where:
- // view - Interface of a view which generated this event,
- // event - Pointer event.
+ // - view - Interface of a view which generated this event,
+ // - event - Pointer event.
//
// Allowed listener formats:
- // `func(event rui.PointerEvent)`,
- // `func(view rui.View)`,
- // `func()`.
+ //
+ // func(event rui.PointerEvent)
+ // func(view rui.View)
+ // func()
PointerUp PropertyName = "pointer-up"
// PointerMove is the constant for "pointer-move" property tag.
//
- // Used by `View`.
+ // Used by View.
// Is fired when a pointer changes coordinates.
//
// General listener format:
- // `func(view rui.View, event rui.PointerEvent)`.
+ //
+ // func(view rui.View, event rui.PointerEvent)
//
// where:
- // view - Interface of a view which generated this event,
- // event - Pointer event.
+ // - view - Interface of a view which generated this event,
+ // - event - Pointer event.
//
// Allowed listener formats:
- // `func(event rui.PointerEvent)`,
- // `func(view rui.View)`,
- // `func()`.
+ //
+ // func(event rui.PointerEvent)
+ // func(view rui.View)
+ // func()
PointerMove PropertyName = "pointer-move"
// PointerCancel is the constant for "pointer-cancel" property tag.
//
- // Used by `View`.
+ // Used by View.
// Is fired if the pointer will no longer be able to generate events (for example the related device is deactivated).
//
// General listener format:
- // `func(view rui.View, event rui.PointerEvent)`.
+ //
+ // func(view rui.View, event rui.PointerEvent)
//
// where:
- // view - Interface of a view which generated this event,
- // event - Pointer event.
+ // - view - Interface of a view which generated this event,
+ // - event - Pointer event.
//
// Allowed listener formats:
- // `func(event rui.PointerEvent)`,
- // `func(view rui.View)`,
- // `func()`.
+ //
+ // func(event rui.PointerEvent)
+ // func(view rui.View)
+ // func()
PointerCancel PropertyName = "pointer-cancel"
// PointerOut is the constant for "pointer-out" property tag.
//
- // Used by `View`.
+ // Used by View.
// Is fired for several reasons including: pointing device is moved out of the hit test boundaries of an element; firing
// the "pointer-up" event for a device that does not support hover (see "pointer-up"); after firing the "pointer-cancel"
// event (see "pointer-cancel"); when a pen stylus leaves the hover range detectable by the digitizer.
//
// General listener format:
- // `func(view rui.View, event rui.PointerEvent)`.
+ //
+ // func(view rui.View, event rui.PointerEvent)
//
// where:
- // view - Interface of a view which generated this event,
- // event - Pointer event.
+ // - view - Interface of a view which generated this event,
+ // - event - Pointer event.
//
// Allowed listener formats:
- // `func(event rui.PointerEvent)`,
- // `func(view rui.View)`,
- // `func()`.
+ //
+ // func(event rui.PointerEvent)
+ // func(view rui.View)
+ // func()
PointerOut PropertyName = "pointer-out"
// PointerOver is the constant for "pointer-over" property tag.
//
- // Used by `View`.
+ // Used by View.
// Is fired when a pointing device is moved into an view's hit test boundaries.
//
// General listener format:
- // `func(view rui.View, event rui.PointerEvent)`.
+ //
+ // func(view rui.View, event rui.PointerEvent)
//
// where:
- // view - Interface of a view which generated this event,
- // event - Pointer event.
+ // - view - Interface of a view which generated this event,
+ // - event - Pointer event.
//
// Allowed listener formats:
- // `func(event rui.PointerEvent)`,
- // `func(view rui.View)`,
- // `func()`.
+ //
+ // func(event rui.PointerEvent)
+ // func(view rui.View)
+ // func()
PointerOver PropertyName = "pointer-over"
)
diff --git a/popup.go b/popup.go
index 3947d29..be1d6e4 100644
--- a/popup.go
+++ b/popup.go
@@ -9,201 +9,207 @@ import (
const (
// Title is the constant for "title" property tag.
//
- // Used by `Popup`, `TabsLayout`.
+ // Used by Popup, TabsLayout.
//
- // Usage in `Popup`:
+ // Usage in Popup:
// Define the title.
//
- // Supported types: `string`.
+ // Supported types: string.
//
- // Usage in `TabsLayout`:
- // Set the title of the tab. The property is set for the child view of `TabsLayout`.
+ // Usage in TabsLayout:
+ // Set the title of the tab. The property is set for the child view of TabsLayout.
//
- // Supported types: `string`.
+ // Supported types: string.
Title = "title"
// TitleStyle is the constant for "title-style" property tag.
//
- // Used by `Popup`.
+ // Used by Popup.
// Set popup title style. Default title style is "ruiPopupTitle".
//
- // Supported types: `string`.
+ // Supported types: string.
TitleStyle PropertyName = "title-style"
// CloseButton is the constant for "close-button" property tag.
//
- // Used by `Popup`.
- // Controls whether a close button can be added to the popup. Default value is `false`.
+ // Used by Popup.
+ // Controls whether a close button can be added to the popup. Default value is false.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - Close button will be added to a title bar of a window.
- // `false` or `0` or "false", "no", "off", "0" - Popup without a close button.
+ // - true, 1, "true", "yes", "on", "1" - Close button will be added to a title bar of a window.
+ // - false, 0, "false", "no", "off", "0" - Popup without a close button.
CloseButton PropertyName = "close-button"
// OutsideClose is the constant for "outside-close" property tag.
//
- // Used by `Popup`.
- // Controls whether popup can be closed by clicking outside of the window. Default value is `false`.
+ // Used by Popup.
+ // Controls whether popup can be closed by clicking outside of the window. Default value is false.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - Clicking outside the popup window will automatically call the `Dismiss()` method.
- // `false` or `0` or "false", "no", "off", "0" - Clicking outside the popup window has no effect.
+ // - true, 1, "true", "yes", "on", "1" - Clicking outside the popup window will automatically call the Dismiss() method.
+ // - false, 0, "false", "no", "off", "0" - Clicking outside the popup window has no effect.
OutsideClose PropertyName = "outside-close"
// Buttons is the constant for "buttons" property tag.
//
- // Used by `Popup`.
+ // Used by Popup.
// Buttons that will be placed at the bottom of the popup.
//
- // Supported types: `PopupButton`, `[]PopupButton`.
+ // Supported types: PopupButton, []PopupButton.
//
- // Internal type is `[]PopupButton`, other types converted to it during assignment.
- // See `PopupButton` description for more details.
+ // Internal type is []PopupButton, other types converted to it during assignment.
+ // See PopupButton description for more details.
Buttons PropertyName = "buttons"
// ButtonsAlign is the constant for "buttons-align" property tag.
//
- // Used by `Popup`.
+ // Used by Popup.
// Set the horizontal alignment of popup buttons.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`LeftAlign`) or "left" - Left alignment.
- // `1`(`RightAlign`) or "right" - Right alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
- // `3`(`StretchAlign`) or "stretch" - Width alignment.
+ // - 0 (LeftAlign) or "left" - Left alignment.
+ // - 1 (RightAlign) or "right" - Right alignment.
+ // - 2 (CenterAlign) or "center" - Center alignment.
+ // - 3 (StretchAlign) or "stretch" - Width alignment.
ButtonsAlign PropertyName = "buttons-align"
// DismissEvent is the constant for "dismiss-event" property tag.
//
- // Used by `Popup`.
- // Used to track the closing state of the `Popup`. It occurs after the `Popup` disappears from the screen.
+ // Used by Popup.
+ // Used to track the closing state of the Popup. It occurs after the Popup disappears from the screen.
//
// General listener format:
- // `func(popup rui.Popup)`.
+ //
+ // func(popup rui.Popup)
//
// where:
// popup - Interface of a popup which generated this event.
//
// Allowed listener formats:
- // `func()`.
+ //
+ // func()
DismissEvent PropertyName = "dismiss-event"
// Arrow is the constant for "arrow" property tag.
//
- // Used by `Popup`.
+ // Used by Popup.
// Add an arrow to popup. Default value is "none".
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneArrow`) or "none" - No arrow.
- // `1`(`TopArrow`) or "top" - Arrow at the top side of the pop-up window.
- // `2`(`RightArrow`) or "right" - Arrow on the right side of the pop-up window.
- // `3`(`BottomArrow`) or "bottom" - Arrow at the bottom of the pop-up window.
- // `4`(`LeftArrow`) or "left" - Arrow on the left side of the pop-up window.
+ // - 0 (NoneArrow) or "none" - No arrow.
+ // - 1 (TopArrow) or "top" - Arrow at the top side of the pop-up window.
+ // - 2 (RightArrow) or "right" - Arrow on the right side of the pop-up window.
+ // - 3 (BottomArrow) or "bottom" - Arrow at the bottom of the pop-up window.
+ // - 4 (LeftArrow) or "left" - Arrow on the left side of the pop-up window.
Arrow PropertyName = "arrow"
// ArrowAlign is the constant for "arrow-align" property tag.
//
- // Used by `Popup`.
+ // Used by Popup.
// Set the horizontal alignment of the popup arrow. Default value is "center".
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`TopAlign`/`LeftAlign`) or "top" - Top/left alignment.
- // `1`(`BottomAlign`/`RightAlign`) or "bottom" - Bottom/right alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
+ // - 0 (TopAlign/LeftAlign) or "top" - Top/left alignment.
+ // - 1 (BottomAlign/RightAlign) or "bottom" - Bottom/right alignment.
+ // - 2 (CenterAlign) or "center" - Center alignment.
ArrowAlign PropertyName = "arrow-align"
// ArrowSize is the constant for "arrow-size" property tag.
//
- // Used by `Popup`.
+ // Used by Popup.
// Set the size(length) of the popup arrow. Default value is 16px defined by @ruiArrowSize constant.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
ArrowSize PropertyName = "arrow-size"
// ArrowWidth is the constant for "arrow-width" property tag.
//
- // Used by `Popup`.
+ // Used by Popup.
// Set the width of the popup arrow. Default value is 16px defined by @ruiArrowWidth constant.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
ArrowWidth PropertyName = "arrow-width"
// ShowTransform is the constant for "show-transform" property tag.
//
- // Used by `Popup`.
+ // Used by Popup.
// Specify start translation, scale and rotation over x, y and z axes as well as a distortion
// for an animated Popup showing/hidding.
//
- // Supported types: `TransformProperty`, `string`.
+ // Supported types: TransformProperty, string.
//
- // See `TransformProperty` description for more details.
+ // See TransformProperty description for more details.
//
// Conversion rules:
- // `TransformProperty` - stored as is, no conversion performed.
- // `string` - string representation of `Transform` interface. Example: "_{translate-x = 10px, scale-y = 1.1}".
+ // - TransformProperty - stored as is, no conversion performed.
+ // - string - string representation of Transform interface. Example:
+ //
+ // "_{ translate-x = 10px, scale-y = 1.1}"
ShowTransform = "show-transform"
// ShowDuration is the constant for "show-duration" property tag.
//
- // Used by `Popup`.
+ // Used by Popup.
// Sets the length of time in seconds that a Popup show/hide animation takes to complete.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
ShowDuration = "show-duration"
// ShowTiming is the constant for "show-timing" property tag.
//
- // Used by `Popup`.
+ // Used by Popup.
// Set how a Popup show/hide animation progresses through the duration of each cycle.
//
- // Supported types: `string`.
+ // Supported types: string.
//
// Values:
- // "ease"(`EaseTiming`) - Speed increases towards the middle and slows down at the end.
- // "ease-in"(`EaseInTiming`) - Speed is slow at first, but increases in the end.
- // "ease-out"(`EaseOutTiming`) - Speed is fast at first, but decreases in the end.
- // "ease-in-out"(`EaseInOutTiming`) - Speed is slow at first, but quickly increases and at the end it decreases again.
- // "linear"(`LinearTiming`) - Constant speed.
+ // - "ease" (EaseTiming) - Speed increases towards the middle and slows down at the end.
+ // - "ease-in" (EaseInTiming) - Speed is slow at first, but increases in the end.
+ // - "ease-out" (EaseOutTiming) - Speed is fast at first, but decreases in the end.
+ // - "ease-in-out" (EaseInOutTiming) - Speed is slow at first, but quickly increases and at the end it decreases again.
+ // - "linear" (LinearTiming) - Constant speed.
+ // - "step(n)" (StepTiming(n int) function) - Timing function along stepCount stops along the transition, displaying each stop for equal lengths of time.
+ // - "cubic-bezier(x1, y1, x2, y2)" (CubicBezierTiming(x1, y1, x2, y2 float64) function) - Cubic-Bezier curve timing function. x1 and x2 must be in the range [0, 1].
ShowTiming = "show-timing"
// ShowOpacity is the constant for "show-opacity" property tag.
//
- // Used by `Popup`.
+ // Used by Popup.
// In [1..0] range sets the start opacity of Popup show animation (the finish animation opacity is 1).
// Opacity is the degree to which content behind the view is hidden, and is the opposite of transparency.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
ShowOpacity = "show-opacity"
// ArrowOffset is the constant for "arrow-offset" property tag.
//
- // Used by `Popup`.
+ // Used by Popup.
// Set the offset of the popup arrow.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
ArrowOffset PropertyName = "arrow-offset"
// NoneArrow is value of the popup "arrow" property: no arrow
diff --git a/popupUtils.go b/popupUtils.go
index 10ae910..f00ae47 100644
--- a/popupUtils.go
+++ b/popupUtils.go
@@ -17,7 +17,9 @@ func ShowMessage(title, text string, session Session) {
}
// ShowQuestion displays a message with the given title and text and two buttons "Yes" and "No".
+//
// When the "Yes" button is clicked, the message is closed and the onYes function is called (if it is not nil).
+//
// When the "No" button is pressed, the message is closed and the onNo function is called (if it is not nil).
func ShowQuestion(title, text string, session Session, onYes func(), onNo func()) {
textView := NewTextView(session, Params{
@@ -57,6 +59,7 @@ func ShowQuestion(title, text string, session Session, onYes func(), onNo func()
}
// ShowCancellableQuestion displays a message with the given title and text and three buttons "Yes", "No" and "Cancel".
+//
// When the "Yes", "No" or "Cancel" button is pressed, the message is closed and the onYes, onNo or onCancel function
// (if it is not nil) is called, respectively.
func ShowCancellableQuestion(title, text string, session Session, onYes func(), onNo func(), onCancel func()) {
diff --git a/progressBar.go b/progressBar.go
index 04b3027..d37b23c 100644
--- a/progressBar.go
+++ b/progressBar.go
@@ -9,22 +9,22 @@ import (
const (
// ProgressBarMax is the constant for "progress-max" property tag.
//
- // Used by `ProgressBar`.
+ // Used by ProgressBar.
// Maximum value, default is 1.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
ProgressBarMax PropertyName = "progress-max"
// ProgressBarValue is the constant for "progress-value" property tag.
//
- // Used by `ProgressBar`.
+ // Used by ProgressBar.
// Current value, default is 0.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
ProgressBarValue PropertyName = "progress-value"
)
diff --git a/propertyNames.go b/propertyNames.go
index 8780e18..b62e9a3 100644
--- a/propertyNames.go
+++ b/propertyNames.go
@@ -6,2804 +6,2721 @@ type PropertyName string
const (
// ID is the constant for "id" property tag.
//
- // Used by `View`, `Animation`.
+ // # Used by View, Animation.
//
- // Usage in `View`:
+ // Usage in View:
// Optional textual identifier for the view. Used to reference view from source code if needed.
//
- // Supported types: `string`.
+ // Supported types: string.
+ //
+ // # Usage in Animation:
//
- // Usage in `Animation`:
// Specifies the animation identifier. Used only for animation script.
//
- // Supported types: `string`.
+ // Supported types: string.
ID PropertyName = "id"
// Style is the constant for "style" property tag.
//
- // Used by `ColumnSeparatorProperty`, `View`, `BorderProperty`, `OutlineProperty`.
+ // Used by ColumnSeparatorProperty, View, BorderProperty, OutlineProperty.
+ //
+ // # Usage in ColumnSeparatorProperty:
//
- // Usage in `ColumnSeparatorProperty`:
// Line style.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneLine`) or "none" - The separator will not be drawn.
- // `1`(`SolidLine`) or "solid" - Solid line as a separator.
- // `2`(`DashedLine`) or "dashed" - Dashed line as a separator.
- // `3`(`DottedLine`) or "dotted" - Dotted line as a separator.
- // `4`(`DoubleLine`) or "double" - Double line as a separator.
+ // - 0 (NoneLine) or "none" - The separator will not be drawn.
+ // - 1 (SolidLine) or "solid" - Solid line as a separator.
+ // - 2 (DashedLine) or "dashed" - Dashed line as a separator.
+ // - 3 (DottedLine) or "dotted" - Dotted line as a separator.
+ // - 4 (DoubleLine) or "double" - Double line as a separator.
+ //
+ // # Usage in View:
//
- // Usage in `View`:
// Sets the name of the style that is applied to the view when the "disabled" property is set to false or "style-disabled"
// property is not defined.
//
- // Supported types: `string`.
+ // Supported types: string.
+ //
+ // # Usage in BorderProperty:
//
- // Usage in `BorderProperty`:
// Border line style.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneLine`) or "none" - The border will not be drawn.
- // `1`(`SolidLine`) or "solid" - Solid line as a border.
- // `2`(`DashedLine`) or "dashed" - Dashed line as a border.
- // `3`(`DottedLine`) or "dotted" - Dotted line as a border.
- // `4`(`DoubleLine`) or "double" - Double line as a border.
+ // - 0 (NoneLine) or "none" - The border will not be drawn.
+ // - 1 (SolidLine) or "solid" - Solid line as a border.
+ // - 2 (DashedLine) or "dashed" - Dashed line as a border.
+ // - 3 (DottedLine) or "dotted" - Dotted line as a border.
+ // - 4 (DoubleLine) or "double" - Double line as a border.
+ //
+ // # Usage in OutlineProperty:
//
- // Usage in `OutlineProperty`:
// Outline line style.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneLine`) or "none" - The outline will not be drawn.
- // `1`(`SolidLine`) or "solid" - Solid line as an outline.
- // `2`(`DashedLine`) or "dashed" - Dashed line as an outline.
- // `3`(`DottedLine`) or "dotted" - Dotted line as an outline.
- // `4`(`DoubleLine`) or "double" - Double line as an outline.
+ // - 0 (NoneLine) or "none" - The outline will not be drawn.
+ // - 1 (SolidLine) or "solid" - Solid line as an outline.
+ // - 2 (DashedLine) or "dashed" - Dashed line as an outline.
+ // - 3 (DottedLine) or "dotted" - Dotted line as an outline.
+ // - 4 (DoubleLine) or "double" - Double line as an outline.
Style PropertyName = "style"
// StyleDisabled is the constant for "style-disabled" property tag.
//
- // Used by `View`.
+ // Used by View.
// Sets the name of the style that is applied to the view when the "disabled" property is set to true.
//
- // Supported types: `string`.
+ // Supported types: string.
StyleDisabled PropertyName = "style-disabled"
// Disabled is the constant for "disabled" property tag.
//
- // Used by `ViewsContainer`.
- // Controls whether the view can receive focus and which style to use. Default value is `false`.
+ // Used by ViewsContainer.
+ // Controls whether the view can receive focus and which style to use. Default value is false.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - View can't receive focus and "style-disabled" style will be used by the view.
- // `false` or `0` or "false", "no", "off", "0" - View can receive focus and "style" style will be used by the view.
+ // - true, 1, "true", "yes", "on", or "1" - View can't receive focus and "style-disabled" style will be used by the view.
+ // - false, 0, "false", "no", "off", or "0" - View can receive focus and "style" style will be used by the view.
Disabled PropertyName = "disabled"
// Focusable is the constant for "focusable" property tag.
//
- // Used by `View`.
+ // Used by View.
// Controls whether view can receive focus.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - View can have a focus.
- // `false` or `0` or "false", "no", "off", "0" - View can't have a focus.
+ // - true, 1, "true", "yes", "on", or "1" - View can have a focus.
+ // - false, 0, "false", "no", "off", or "0" - View can't have a focus.
Focusable PropertyName = "focusable"
// Semantics is the constant for "semantics" property tag.
//
- // Used by `View`.
+ // Used by View.
// Defines the semantic meaning of the view. This property may have no visible effect, but it allows search engines to
// understand the structure of your application. It also helps to voice the interface to systems for people with
// disabilities.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`DefaultSemantics`) or "default" - Default semantics.
- // `1`(`ArticleSemantics`) or "article" - Article semantics.
- // `2`(`SectionSemantics`) or "section" - Section semantics.
- // `3`(`AsideSemantics`) or "aside" - Aside semantics.
- // `4`(`HeaderSemantics`) or "header" - Header semantics.
- // `5`(`MainSemantics`) or "main" - Main semantics.
- // `6`(`FooterSemantics`) or "footer" - Footer semantics.
- // `7`(`NavigationSemantics`) or "navigation" - Navigation semantics.
- // `8`(`FigureSemantics`) or "figure" - Figure semantics.
- // `9`(`FigureCaptionSemantics`) or "figure-caption" - Figure caption semantics.
- // `10`(`ButtonSemantics`) or "button" - Button semantics.
- // `11`(`ParagraphSemantics`) or "p" - Paragraph semantics.
- // `12`(`H1Semantics`) or "h1" - Heading level 1 semantics.
- // `13`(`H2Semantics`) or "h2" - Heading level 2 semantics.
- // `14`(`H3Semantics`) or "h3" - Heading level 3 semantics.
- // `15`(`H4Semantics`) or "h4" - Heading level 4 semantics.
- // `16`(`H5Semantics`) or "h5" - Heading level 5 semantics.
- // `17`(`H6Semantics`) or "h6" - Heading level 6 semantics.
- // `18`(`BlockquoteSemantics`) or "blockquote" - Blockquote semantics.
- // `19`(`CodeSemantics`) or "code" - Code semantics.
+ // - 0 (DefaultSemantics) or "default" - Default semantics.
+ // - 1 (ArticleSemantics) or "article" - Article semantics.
+ // - 2 (SectionSemantics) or "section" - Section semantics.
+ // - 3 (AsideSemantics) or "aside" - Aside semantics.
+ // - 4 (HeaderSemantics) or "header" - Header semantics.
+ // - 5 (MainSemantics) or "main" - Main semantics.
+ // - 6 (FooterSemantics) or "footer" - Footer semantics.
+ // - 7 (NavigationSemantics) or "navigation" - Navigation semantics.
+ // - 8 (FigureSemantics) or "figure" - Figure semantics.
+ // - 9 (FigureCaptionSemantics) or "figure-caption" - Figure caption semantics.
+ // - 10 (ButtonSemantics) or "button" - Button semantics.
+ // - 11 (ParagraphSemantics) or "p" - Paragraph semantics.
+ // - 12 (H1Semantics) or "h1" - Heading level 1 semantics.
+ // - 13 (H2Semantics) or "h2" - Heading level 2 semantics.
+ // - 14 (H3Semantics) or "h3" - Heading level 3 semantics.
+ // - 15 (H4Semantics) or "h4" - Heading level 4 semantics.
+ // - 16 (H5Semantics) or "h5" - Heading level 5 semantics.
+ // - 17 (H6Semantics) or "h6" - Heading level 6 semantics.
+ // - 18 (BlockquoteSemantics) or "blockquote" - Blockquote semantics.
+ // - 19 (CodeSemantics) or "code" - Code semantics.
Semantics PropertyName = "semantics"
// Visibility is the constant for "visibility" property tag.
//
- // Used by `View`.
+ // Used by View.
// Specifies the visibility of the view.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`Visible`) or "visible" - The view is visible.
- // `1`(`Invisible`) or "invisible" - The view is invisible but takes up space.
- // `2`(`Gone`) or "gone" - The view is invisible and does not take up space.
+ // - 0 (Visible) or "visible" - The view is visible.
+ // - 1 (Invisible) or "invisible" - The view is invisible but takes up space.
+ // - 2 (Gone) or "gone" - The view is invisible and does not take up space.
Visibility PropertyName = "visibility"
// ZIndex is the constant for "z-index" property tag.
//
- // Used by `View`.
+ // Used by View.
// Sets the z-order of a positioned view. Overlapping views with a larger z-index cover those with a smaller one.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // < `0` or < "0" - Views with lower value will be behind views with higher value.
- // >PropertyName = `0` or >PropertyName = "0" - Views with higher value will be on top of views with lower value.
+ // - negative value - Views with lower value will be behind views with higher value.
+ // - not negative value - Views with higher value will be on top of views with lower value.
ZIndex PropertyName = "z-index"
// Opacity is the constant for "opacity" property tag.
//
- // Used by `View`, `ViewFilter`.
+ // Used by View, ViewFilter.
+ //
+ // # Usage in View:
//
- // Usage in `View`:
// In [1..0] range sets the opacity of view. Opacity is the degree to which content behind the view is hidden, and is the
// opposite of transparency.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
+ //
+ // # Usage in ViewFilter:
//
- // Usage in `ViewFilter`:
// Opacity is the degree to which content behind the view is hidden, and is the opposite of transparency. Value is in
// range 0% to 100%, where 0% is fully transparent.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
Opacity PropertyName = "opacity"
// Overflow is the constant for "overflow" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the desired behavior for an element's overflow i.e. when an element's content is too big to fit in its block
// formatting context in both directions.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`OverflowHidden`) or "hidden" - The overflow is clipped, and the rest of the content will be invisible.
- // `1`(`OverflowVisible`) or "visible" - The overflow is not clipped. The content renders outside the element's box.
- // `2`(`OverflowScroll`) or "scroll" - The overflow is clipped, and a scrollbar is added to see the rest of the content.
- // `3`(`OverflowAuto`) or "auto" - Similar to `OverflowScroll`, but it adds scrollbars only when necessary.
+ // - 0 (OverflowHidden) or "hidden" - The overflow is clipped, and the rest of the content will be invisible.
+ // - 1 (OverflowVisible) or "visible" - The overflow is not clipped. The content renders outside the element's box.
+ // - 2 (OverflowScroll) or "scroll" - The overflow is clipped, and a scrollbar is added to see the rest of the content.
+ // - 3 (OverflowAuto) or "auto" - Similar to OverflowScroll, but it adds scrollbars only when necessary.
Overflow PropertyName = "overflow"
// Row is the constant for "row" property tag.
//
- // Used by `View`.
- // Row of the view inside the container like `GridLayout`.
+ // Used by View.
+ // Row of the view inside the container like GridLayout.
//
- // Supported types: `Range`, `int`, `string`.
+ // Supported types: Range, int, string.
//
- // Internal type is `Range`, other types converted to it during assignment.
+ // Internal type is Range, other types converted to it during assignment.
//
// Conversion rules:
- // `int` - set single value(index).
- // `string` - can contain single integer value(index) or a range of integer values(indices), examples: "0", "0:3".
+ // - int - set single value(index).
+ // - string - can contain single integer value(index) or a range of integer values(indices), examples: "0", "0:3".
Row PropertyName = "row"
// Column is the constant for "column" property tag.
//
- // Used by `View`.
- // Column of the view inside the container like `GridLayout`.
+ // Used by View.
+ // Column of the view inside the container like GridLayout.
//
- // Supported types: `Range`, `int`, `string`.
+ // Supported types: Range, int, string.
//
- // Internal type is `Range`, other types converted to it during assignment.
+ // Internal type is Range, other types converted to it during assignment.
//
// Conversion rules:
- // `int` - set single value(index).
- // `string` - can contain single integer value(index) or a range of integer values(indices), examples: "0", "0:3".
+ // - int - set single value(index).
+ // - string - can contain single integer value(index) or a range of integer values(indices), examples: "0", "0:3".
Column PropertyName = "column"
// Left is the constant for "left" property tag.
//
- // Used by `View`, `BoundsProperty`, `ClipShape`.
+ // Used by View, BoundsProperty, ClipShape.
//
- // Usage in `View`:
- // Offset from left border of the container. Used only for views placed in an `AbsoluteLayout`.
+ // # Usage in View:
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Offset from left border of the container. Used only for views placed in an AbsoluteLayout.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
+ //
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
+ //
+ // # Usage in BoundsProperty:
//
- // Usage in `BoundsProperty`:
// Left bound value.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
+ //
+ // # Usage in ClipShape:
//
- // Usage in `ClipShape`:
// Specifies the left border position of inset clip shape.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
Left PropertyName = "left"
// Right is the constant for "right" property tag.
//
- // Used by `View`, `BoundsProperty`, `ClipShape`.
+ // Used by View, BoundsProperty, ClipShape.
//
- // Usage in `View`:
- // Offset from right border of the container. Used only for views placed in an `AbsoluteLayout`.
+ // # Usage in View:
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Offset from right border of the container. Used only for views placed in an AbsoluteLayout.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
+ //
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
+ //
+ // # Usage in BoundsProperty:
//
- // Usage in `BoundsProperty`:
// Right bound value.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
+ //
+ // # Usage in ClipShape:
//
- // Usage in `ClipShape`:
// Specifies the right border position of inset clip shape.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
Right PropertyName = "right"
// Top is the constant for "top" property tag.
//
- // Used by `View`, `BoundsProperty`, `ClipShape`.
+ // Used by View, BoundsProperty, ClipShape.
//
- // Usage in `View`:
- // Offset from top border of the container. Used only for views placed in an `AbsoluteLayout`.
+ // # Usage in View:
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Offset from top border of the container. Used only for views placed in an AbsoluteLayout.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
+ //
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
+ //
+ // # Usage in BoundsProperty:
//
- // Usage in `BoundsProperty`:
// Top bound value.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
+ //
+ // # Usage in ClipShape:
//
- // Usage in `ClipShape`:
// Specifies the top border position of inset clip shape.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
Top PropertyName = "top"
// Bottom is the constant for "bottom" property tag.
//
- // Used by `View`, `BoundsProperty`, `ClipShape`.
+ // Used by View, BoundsProperty, ClipShape.
//
- // Usage in `View`:
- // Offset from bottom border of the container. Used only for views placed in an `AbsoluteLayout`.
+ // # Usage in View:
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Offset from bottom border of the container. Used only for views placed in an AbsoluteLayout.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
+ //
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
+ //
+ // # Usage in BoundsProperty:
//
- // Usage in `BoundsProperty`:
// Bottom bound value.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
+ //
+ // # Usage in ClipShape:
//
- // Usage in `ClipShape`:
// Specifies the bottom border position of inset clip shape.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
Bottom PropertyName = "bottom"
// Width is the constant for "width" property tag.
//
- // Used by `ColumnSeparatorProperty`, `View`, `BorderProperty`, `OutlineProperty`.
+ // Used by ColumnSeparatorProperty, View, BorderProperty, OutlineProperty.
+ //
+ // # Usage in ColumnSeparatorProperty:
//
- // Usage in `ColumnSeparatorProperty`:
// Line width.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
+ //
+ // # Usage in View:
//
- // Usage in `View`:
// Set a view's width.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
+ //
+ // # Usage in BorderProperty:
//
- // Usage in `BorderProperty`:
// Border line width.
//
- // Supported types: `SizeUnit`, `string`.
+ // Supported types: SizeUnit, string.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
+ //
+ // # Usage in OutlineProperty:
//
- // Usage in `OutlineProperty`:
// Outline line width.
//
- // Supported types: `SizeUnit`, `string`.
+ // Supported types: SizeUnit, string.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
Width PropertyName = "width"
// Height is the constant for "height" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set a view's height.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
Height PropertyName = "height"
// MinWidth is the constant for "min-width" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set a view's minimal width.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
MinWidth PropertyName = "min-width"
// MinHeight is the constant for "min-height" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set a view's minimal height.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
MinHeight PropertyName = "min-height"
// MaxWidth is the constant for "max-width" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set a view's maximal width.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
MaxWidth PropertyName = "max-width"
// MaxHeight is the constant for "max-height" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set a view's maximal height.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
MaxHeight PropertyName = "max-height"
// Margin is the constant for "margin" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the margin area on all four sides of an element.
//
- // Supported types: `BoundsProperty`, `Bounds`, `SizeUnit`, `float32`, `float64`, `int`, `string`.
+ // Supported types: BoundsProperty, Bounds, SizeUnit, float32, float64, int, string.
//
- // Internal type could be `BoundsProperty` or `SizeUnit` depending on whether single value or multiple values has been set, other types converted to them during assignment.
- // See `BoundsProperty`, `Bounds`, `SizeUnit` for more information.
+ // Internal type could be BoundsProperty or SizeUnit depending on whether single value or multiple values has been set, other types converted to them during assignment.
+ // See BoundsProperty, Bounds, SizeUnit for more information.
//
// Conversion rules:
- // `BoundsProperty` - stored as is, no conversion performed.
- // `Bounds` - new `BoundsProperty` will be created and corresponding values for top, right, bottom and left border will be set.
- // `SizeUnit` - stored as is and the same value will be used for all borders.
- // `float` - new `SizeUnit` will be created and the same value(in pixels) will be used for all borders.
- // `int` - new `SizeUnit` will be created and the same value(in pixels) will be used for all borders.
- // `string` - can contain one or four `SizeUnit` separated with comma(`,`). In case one value will be provided a new `SizeUnit` will be created and the same value will be used for all borders. If four values will be provided then they will be set respectively for top, right, bottom and left border.
+ // - BoundsProperty - stored as is, no conversion performed.
+ // - Bounds - new BoundsProperty will be created and corresponding values for top, right, bottom and left border will be set.
+ // - SizeUnit - stored as is and the same value will be used for all borders.
+ // - float - new SizeUnit will be created and the same value(in pixels) will be used for all borders.
+ // - int - new SizeUnit will be created and the same value(in pixels) will be used for all borders.
+ // - string - can contain one or four SizeUnit separated with comma(,). In case one value will be provided a new SizeUnit will be created and the same value will be used for all borders. If four values will be provided then they will be set respectively for top, right, bottom and left border.
Margin PropertyName = "margin"
// MarginLeft is the constant for "margin-left" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the margin area on the left of a view. A positive value places it farther from its neighbors, while a negative
// value places it closer.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
MarginLeft PropertyName = "margin-left"
// MarginRight is the constant for "margin-right" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the margin area on the right of a view. A positive value places it farther from its neighbors, while a negative
// value places it closer.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
MarginRight PropertyName = "margin-right"
// MarginTop is the constant for "margin-top" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the margin area on the top of a view. A positive value places it farther from its neighbors, while a negative value
// places it closer.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
MarginTop PropertyName = "margin-top"
// MarginBottom is the constant for "margin-bottom" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the margin area on the bottom of a view. A positive value places it farther from its neighbors, while a negative
// value places it closer.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
MarginBottom PropertyName = "margin-bottom"
// Padding is the constant for "padding" property tag.
//
- // Used by `View`.
+ // Used by View.
// Sets the padding area on all four sides of a view at once. An element's padding area is the space between its content
// and its border.
//
- // Supported types: `BoundsProperty`, `Bounds`, `SizeUnit`, `float32`, `float64`, `int`, `string`.
+ // Supported types: BoundsProperty, Bounds, SizeUnit, float32, float64, int, string.
//
- // Internal type could be `BoundsProperty` or `SizeUnit` depending on whether single value or multiple values has been set, other types converted to them during assignment.
- // See `BoundsProperty`, `Bounds`, `SizeUnit` for more information.
+ // Internal type could be BoundsProperty or SizeUnit depending on whether single value or multiple values has been set, other types converted to them during assignment.
+ // See BoundsProperty, Bounds, SizeUnit for more information.
//
// Conversion rules:
- // `BoundsProperty` - stored as is, no conversion performed.
- // `Bounds` - new `BoundsProperty` will be created and corresponding values for top, right, bottom and left border will be set.
- // `SizeUnit` - stored as is and the same value will be used for all borders.
- // `float` - new `SizeUnit` will be created and the same value(in pixels) will be used for all borders.
- // `int` - new `SizeUnit` will be created and the same value(in pixels) will be used for all borders.
- // `string` - can contain one or four `SizeUnit` separated with comma(`,`). In case one value will be provided a new `SizeUnit` will be created and the same value will be used for all borders. If four values will be provided then they will be set respectively for top, right, bottom and left border.
+ // - BoundsProperty - stored as is, no conversion performed.
+ // - Bounds - new BoundsProperty will be created and corresponding values for top, right, bottom and left border will be set.
+ // - SizeUnit - stored as is and the same value will be used for all borders.
+ // - float - new SizeUnit will be created and the same value(in pixels) will be used for all borders.
+ // - int - new SizeUnit will be created and the same value(in pixels) will be used for all borders.
+ // - string - can contain one or four SizeUnit separated with comma(,). In case one value will be provided a new SizeUnit will be created and the same value will be used for all borders. If four values will be provided then they will be set respectively for top, right, bottom and left border.
Padding PropertyName = "padding"
// PaddingLeft is the constant for "padding-left" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the width of the padding area to the left of a view.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
PaddingLeft PropertyName = "padding-left"
// PaddingRight is the constant for "padding-right" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the width of the padding area to the right of a view.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
PaddingRight PropertyName = "padding-right"
// PaddingTop is the constant for "padding-top" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the height of the padding area to the top of a view.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
PaddingTop PropertyName = "padding-top"
// PaddingBottom is the constant for "padding-bottom" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the height of the padding area to the bottom of a view.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
PaddingBottom PropertyName = "padding-bottom"
// AccentColor is the constant for "accent-color" property tag.
//
- // Used by `View`.
+ // Used by View.
// Sets the accent color for UI controls generated by some elements.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See [Color] description for more details.
AccentColor PropertyName = "accent-color"
// BackgroundColor is the constant for "background-color" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the background color of a view.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See [Color] description for more details.
BackgroundColor PropertyName = "background-color"
// Background is the constant for "background" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set one or more background images and/or gradients for the view.
//
- // Supported types: `BackgroundElement`, `[]BackgroundElement`, `string`.
+ // Supported types: BackgroundElement, []BackgroundElement, string.
//
- // Internal type is `[]BackgroundElement`, other types converted to it during assignment.
- // See `BackgroundElement` description for more details.
+ // Internal type is []BackgroundElement, other types converted to it during assignment.
+ // See BackgroundElement description for more details.
//
// Conversion rules:
- // `string` - must contain text representation of background element(s) like in resource files.
+ // - string - must contain text representation of background element(s) like in resource files.
Background PropertyName = "background"
// Mask is the constant for "mask" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set one or more images and/or gradients as the view mask.
// As mask is used only alpha channel of images and/or gradients.
//
- // Supported types: `BackgroundElement`, `[]BackgroundElement`, `string`.
+ // Supported types: BackgroundElement, []BackgroundElement, string.
//
- // Internal type is `[]BackgroundElement`, other types converted to it during assignment.
- // See `BackgroundElement` description for more details.
+ // Internal type is []BackgroundElement, other types converted to it during assignment.
+ // See BackgroundElement description for more details.
//
// Conversion rules:
- // `string` - must contain text representation of background element(s) like in resource files.
+ // - string - must contain text representation of background element(s) like in resource files.
Mask PropertyName = "mask"
// Cursor is the constant for "cursor" property tag.
//
- // Used by `View`.
+ // Used by View.
// Sets the type of mouse cursor, if any, to show when the mouse pointer is over the view.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0` or "auto" - Auto cursor.
- // `1` or "default" - Default cursor.
- // `2` or "none" - None cursor.
- // `3` or "context-menu" - Context menu cursor.
- // `4` or "help" - Help cursor.
- // `5` or "pointer" - Pointer cursor.
- // `6` or "progress" - Progress cursor.
- // `7` or "wait" - Wait cursor.
- // `8` or "cell" - Cell cursor.
- // `9` or "crosshair" - Crosshair cursor.
- // `10` or "text" - Text cursor.
- // `11` or "vertical-text" - Vertical text cursor.
- // `12` or "alias" - Alias cursor.
- // `13` or "copy" - Copy cursor.
- // `14` or "move" - Move cursor.
- // `15` or "no-drop" - No drop cursor.
- // `16` or "not-allowed" - Not allowed cursor.
- // `17` or "e-resize" - Resize cursor.
- // `18` or "n-resize" - Resize cursor.
- // `19` or "ne-resize" - Resize cursor.
- // `20` or "nw-resize" - Resize cursor.
- // `21` or "s-resize" - Resize cursor.
- // `22` or "se-resize" - Resize cursor.
- // `23` or "sw-resize" - Resize cursor.
- // `24` or "w-resize" - Resize cursor.
- // `25` or "ew-resize" - Resize cursor.
- // `26` or "ns-resize" - Resize cursor.
- // `27` or "nesw-resize" - Resize cursor.
- // `28` or "nwse-resize" - Resize cursor.
- // `29` or "col-resize" - Col resize cursor.
- // `30` or "row-resize" - Row resize cursor.
- // `31` or "all-scroll" - All scroll cursor.
- // `32` or "zoom-in" - Zoom in cursor.
- // `33` or "zoom-out" - Zoom out cursor.
- // `34` or "grab" - Grab cursor.
- // `35` or "grabbing" - Grabbing cursor.
+ // - 0 or "auto" - Auto cursor.
+ // - 1 or "default" - Default cursor.
+ // - 2 or "none" - None cursor.
+ // - 3 or "context-menu" - Context menu cursor.
+ // - 4 or "help" - Help cursor.
+ // - 5 or "pointer" - Pointer cursor.
+ // - 6 or "progress" - Progress cursor.
+ // - 7 or "wait" - Wait cursor.
+ // - 8 or "cell" - Cell cursor.
+ // - 9 or "crosshair" - Crosshair cursor.
+ // - 10 or "text" - Text cursor.
+ // - 11 or "vertical-text" - Vertical text cursor.
+ // - 12 or "alias" - Alias cursor.
+ // - 13 or "copy" - Copy cursor.
+ // - 14 or "move" - Move cursor.
+ // - 15 or "no-drop" - No drop cursor.
+ // - 16 or "not-allowed" - Not allowed cursor.
+ // - 17 or "e-resize" - Resize cursor.
+ // - 18 or "n-resize" - Resize cursor.
+ // - 19 or "ne-resize" - Resize cursor.
+ // - 20 or "nw-resize" - Resize cursor.
+ // - 21 or "s-resize" - Resize cursor.
+ // - 22 or "se-resize" - Resize cursor.
+ // - 23 or "sw-resize" - Resize cursor.
+ // - 24 or "w-resize" - Resize cursor.
+ // - 25 or "ew-resize" - Resize cursor.
+ // - 26 or "ns-resize" - Resize cursor.
+ // - 27 or "nesw-resize" - Resize cursor.
+ // - 28 or "nwse-resize" - Resize cursor.
+ // - 29 or "col-resize" - Col resize cursor.
+ // - 30 or "row-resize" - Row resize cursor.
+ // - 31 or "all-scroll" - All scroll cursor.
+ // - 32 or "zoom-in" - Zoom in cursor.
+ // - 33 or "zoom-out" - Zoom out cursor.
+ // - 34 or "grab" - Grab cursor.
+ // - 35 or "grabbing" - Grabbing cursor.
Cursor PropertyName = "cursor"
// Border is the constant for "border" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set a view's border. It sets the values of a border width, style, and color.
//
- // Supported types: `BorderProperty`, `ViewBorder`, `ViewBorders`.
+ // Supported types: BorderProperty, ViewBorder, ViewBorders.
//
- // Internal type is `BorderProperty`, other types converted to it during assignment.
- // See `BorderProperty`, `ViewBorder`, `ViewBorders` description for more details.
+ // Internal type is BorderProperty, other types converted to it during assignment.
+ // See BorderProperty, ViewBorder, ViewBorders description for more details.
//
// Conversion rules:
- // `ViewBorder` - style, width and color applied to all borders and stored in internal implementation of `BorderProperty`.
- // `ViewBorders` - style, width and color of each border like top, right, bottom and left applied to related borders, stored in internal implementation of `BorderProperty`.
+ // - ViewBorder - style, width and color applied to all borders and stored in internal implementation of BorderProperty.
+ // - ViewBorders - style, width and color of each border like top, right, bottom and left applied to related borders, stored in internal implementation of BorderProperty.
Border PropertyName = "border"
// BorderLeft is the constant for "border-left" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set a view's left border. It sets the values of a border width, style, and color.
//
- // Supported types: `ViewBorder`, `BorderProperty`, `string`.
+ // Supported types: ViewBorder, BorderProperty, string.
//
- // Internal type is `BorderProperty`, other types converted to it during assignment.
- // See `ViewBorder`, `BorderProperty` description for more details.
+ // Internal type is BorderProperty, other types converted to it during assignment.
+ // See ViewBorder, BorderProperty description for more details.
BorderLeft PropertyName = "border-left"
// BorderRight is the constant for "border-right" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set a view's right border. It sets the values of a border width, style, and color.
//
- // Supported types: `ViewBorder`, `BorderProperty`, `string`.
+ // Supported types: ViewBorder, BorderProperty, string.
//
- // Internal type is `BorderProperty`, other types converted to it during assignment.
- // See `ViewBorder`, `BorderProperty` description for more details.
+ // Internal type is BorderProperty, other types converted to it during assignment.
+ // See ViewBorder, BorderProperty description for more details.
BorderRight PropertyName = "border-right"
// BorderTop is the constant for "border-top" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set a view's top border. It sets the values of a border width, style, and color.
//
- // Supported types: `ViewBorder`, `BorderProperty`, `string`.
+ // Supported types: ViewBorder, BorderProperty, string.
//
- // Internal type is `BorderProperty`, other types converted to it during assignment.
- // See `ViewBorder`, `BorderProperty` description for more details.
+ // Internal type is BorderProperty, other types converted to it during assignment.
+ // See ViewBorder, BorderProperty description for more details.
BorderTop PropertyName = "border-top"
// BorderBottom is the constant for "border-bottom" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set a view's bottom border. It sets the values of a border width, style, and color.
//
- // Supported types: `ViewBorder`, `BorderProperty`, `string`.
+ // Supported types: ViewBorder, BorderProperty, string.
//
- // Internal type is `BorderProperty`, other types converted to it during assignment.
- // See `ViewBorder`, `BorderProperty` description for more details.
+ // Internal type is BorderProperty, other types converted to it during assignment.
+ // See ViewBorder, BorderProperty description for more details.
BorderBottom PropertyName = "border-bottom"
// BorderStyle is the constant for "border-style" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the line style for all four sides of a view's border.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneLine`) or "none" - The border will not be drawn.
- // `1`(`SolidLine`) or "solid" - Solid line as a border.
- // `2`(`DashedLine`) or "dashed" - Dashed line as a border.
- // `3`(`DottedLine`) or "dotted" - Dotted line as a border.
- // `4`(`DoubleLine`) or "double" - Double line as a border.
+ // - 0 (NoneLine) or "none" - The border will not be drawn.
+ // - 1 (SolidLine) or "solid" - Solid line as a border.
+ // - 2 (DashedLine) or "dashed" - Dashed line as a border.
+ // - 3 (DottedLine) or "dotted" - Dotted line as a border.
+ // - 4 (DoubleLine) or "double" - Double line as a border.
BorderStyle PropertyName = "border-style"
// BorderLeftStyle is the constant for "border-left-style" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the line style of a view's left border.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneLine`) or "none" - The border will not be drawn.
- // `1`(`SolidLine`) or "solid" - Solid line as a border.
- // `2`(`DashedLine`) or "dashed" - Dashed line as a border.
- // `3`(`DottedLine`) or "dotted" - Dotted line as a border.
- // `4`(`DoubleLine`) or "double" - Double line as a border.
+ // - 0 (NoneLine) or "none" - The border will not be drawn.
+ // - 1 (SolidLine) or "solid" - Solid line as a border.
+ // - 2 (DashedLine) or "dashed" - Dashed line as a border.
+ // - 3 (DottedLine) or "dotted" - Dotted line as a border.
+ // - 4 (DoubleLine) or "double" - Double line as a border.
BorderLeftStyle PropertyName = "border-left-style"
// BorderRightStyle is the constant for "border-right-style" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the line style of a view's right border.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneLine`) or "none" - The border will not be drawn.
- // `1`(`SolidLine`) or "solid" - Solid line as a border.
- // `2`(`DashedLine`) or "dashed" - Dashed line as a border.
- // `3`(`DottedLine`) or "dotted" - Dotted line as a border.
- // `4`(`DoubleLine`) or "double" - Double line as a border.
+ // - 0 (NoneLine) or "none" - The border will not be drawn.
+ // - 1 (SolidLine) or "solid" - Solid line as a border.
+ // - 2 (DashedLine) or "dashed" - Dashed line as a border.
+ // - 3 (DottedLine) or "dotted" - Dotted line as a border.
+ // - 4 (DoubleLine) or "double" - Double line as a border.
BorderRightStyle PropertyName = "border-right-style"
// BorderTopStyle is the constant for "border-top-style" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the line style of a view's top border.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneLine`) or "none" - The border will not be drawn.
- // `1`(`SolidLine`) or "solid" - Solid line as a border.
- // `2`(`DashedLine`) or "dashed" - Dashed line as a border.
- // `3`(`DottedLine`) or "dotted" - Dotted line as a border.
- // `4`(`DoubleLine`) or "double" - Double line as a border.
+ // - 0 (NoneLine) or "none" - The border will not be drawn.
+ // - 1 (SolidLine) or "solid" - Solid line as a border.
+ // - 2 (DashedLine) or "dashed" - Dashed line as a border.
+ // - 3 (DottedLine) or "dotted" - Dotted line as a border.
+ // - 4 (DoubleLine) or "double" - Double line as a border.
BorderTopStyle PropertyName = "border-top-style"
// BorderBottomStyle is the constant for "border-bottom-style" property tag.
//
- // Used by `View`.
+ // Used by View.
// Sets the line style of a view's bottom border.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneLine`) or "none" - The border will not be drawn.
- // `1`(`SolidLine`) or "solid" - Solid line as a border.
- // `2`(`DashedLine`) or "dashed" - Dashed line as a border.
- // `3`(`DottedLine`) or "dotted" - Dotted line as a border.
- // `4`(`DoubleLine`) or "double" - Double line as a border.
+ // - 0 (NoneLine) or "none" - The border will not be drawn.
+ // - 1 (SolidLine) or "solid" - Solid line as a border.
+ // - 2 (DashedLine) or "dashed" - Dashed line as a border.
+ // - 3 (DottedLine) or "dotted" - Dotted line as a border.
+ // - 4 (DoubleLine) or "double" - Double line as a border.
BorderBottomStyle PropertyName = "border-bottom-style"
// BorderWidth is the constant for "border-width" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the line width for all four sides of a view's border.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
BorderWidth PropertyName = "border-width"
// BorderLeftWidth is the constant for "border-left-width" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the line width of a view's left border.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
BorderLeftWidth PropertyName = "border-left-width"
// BorderRightWidth is the constant for "border-right-width" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the line width of a view's right border.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
BorderRightWidth PropertyName = "border-right-width"
// BorderTopWidth is the constant for "border-top-width" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the line width of a view's top border.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
BorderTopWidth PropertyName = "border-top-width"
// BorderBottomWidth is the constant for "border-bottom-width" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the line width of a view's bottom border.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
BorderBottomWidth PropertyName = "border-bottom-width"
// BorderColor is the constant for "border-color" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the line color for all four sides of a view's border.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See [Color] description for more details.
BorderColor PropertyName = "border-color"
// BorderLeftColor is the constant for "border-left-color" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the line color of a view's left border.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See [Color] description for more details.
BorderLeftColor PropertyName = "border-left-color"
// BorderRightColor is the constant for "border-right-color" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the line color of a view's right border.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See [Color] description for more details.
BorderRightColor PropertyName = "border-right-color"
// BorderTopColor is the constant for "border-top-color" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the line color of a view's top border.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See [Color] description for more details.
BorderTopColor PropertyName = "border-top-color"
// BorderBottomColor is the constant for "border-bottom-color" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the line color of a view's bottom border.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See [Color] description for more details.
BorderBottomColor PropertyName = "border-bottom-color"
// Outline is the constant for "outline" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set a view's outline. It sets the values of an outline width, style, and color.
//
- // Supported types: `OutlineProperty`, `ViewOutline`, `ViewBorder`.
+ // Supported types: OutlineProperty, ViewOutline, ViewBorder.
//
- // Internal type is `OutlineProperty`, other types converted to it during assignment.
- // See `OutlineProperty`, `ViewOutline` and `ViewBorder` description for more details.
+ // Internal type is OutlineProperty, other types converted to it during assignment.
+ // See OutlineProperty, ViewOutline and ViewBorder description for more details.
Outline PropertyName = "outline"
// OutlineStyle is the constant for "outline-style" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the style of an view's outline.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneLine`) or "none" - The outline will not be drawn.
- // `1`(`SolidLine`) or "solid" - Solid line as an outline.
- // `2`(`DashedLine`) or "dashed" - Dashed line as an outline.
- // `3`(`DottedLine`) or "dotted" - Dotted line as an outline.
- // `4`(`DoubleLine`) or "double" - Double line as an outline.
+ // - 0 (NoneLine) or "none" - The outline will not be drawn.
+ // - 1 (SolidLine) or "solid" - Solid line as an outline.
+ // - 2 (DashedLine) or "dashed" - Dashed line as an outline.
+ // - 3 (DottedLine) or "dotted" - Dotted line as an outline.
+ // - 4 (DoubleLine) or "double" - Double line as an outline.
OutlineStyle PropertyName = "outline-style"
// OutlineColor is the constant for "outline-color" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the color of an view's outline.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See [Color] description for more details.
OutlineColor PropertyName = "outline-color"
// OutlineWidth is the constant for "outline-width" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the width of an view's outline.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
OutlineWidth PropertyName = "outline-width"
// OutlineOffset is the constant for "outline-offset" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the amount of space between an outline and the edge or border of a view.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
OutlineOffset PropertyName = "outline-offset"
// Shadow is the constant for "shadow" property tag.
//
- // Used by `View`.
+ // Used by View.
// Adds shadow effects around a view's frame. A shadow is described by X and Y offsets relative to the element, blur,
// spread radius and color.
//
- // Supported types: `ShadowProperty`, `[]ShadowProperty`, `string`.
+ // Supported types: ShadowProperty, []ShadowProperty, string.
//
- // Internal type is `[]ShadowProperty`, other types converted to it during assignment.
- // See `ShadowProperty` description for more details.
+ // Internal type is []ShadowProperty, other types converted to it during assignment.
+ // See ShadowProperty description for more details.
//
// Conversion rules:
- // `[]ShadowProperty` - stored as is. no conversion performed.
- // `ShadowProperty` - converted to `[]ShadowProperty` during assignment.
- // `string` - must contain a string representation of `ShadowProperty`
+ // - []ShadowProperty - stored as is. no conversion performed.
+ // - ShadowProperty - converted to []ShadowProperty during assignment.
+ // - string - must contain a string representation of ShadowProperty
Shadow PropertyName = "shadow"
// FontName is the constant for "font-name" property tag.
//
- // Used by `View`.
+ // Used by View.
// Specifies a prioritized list of one or more font family names and/or generic family names for the view. Values are
// separated by commas to indicate that they are alternatives. This is an inherited property, i.e. if it is not defined,
// then the value of the parent view is used.
//
- // Supported types: `string`.
+ // Supported types: string.
FontName PropertyName = "font-name"
// TextColor is the constant for "text-color" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the foreground color value of a view's text and text decorations. This is an inherited property, i.e. if it is not
// defined, then the value of the parent view is used.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See [Color] description for more details.
TextColor PropertyName = "text-color"
// TextSize is the constant for "text-size" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the size of the font. This is an inherited property, i.e. if it is not defined, then the value of the parent view
// is used.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
TextSize PropertyName = "text-size"
// Italic is the constant for "italic" property tag.
//
- // Used by `View`.
+ // Used by View.
// Controls whether the text is displayed in italics. This is an inherited property, i.e. if it is not defined, then the
- // value of the parent view is used. Default value is `false`.
+ // value of the parent view is used. Default value is false.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - Text is displayed in italics.
- // `false` or `0` or "false", "no", "off", "0" - Normal text.
+ // - true, 1, "true", "yes", "on", or "1" - Text is displayed in italics.
+ // - false, 0, "false", "no", "off", or "0" - Normal text.
Italic PropertyName = "italic"
// SmallCaps is the constant for "small-caps" property tag.
//
- // Used by `View`.
+ // Used by View.
// Controls whether to use small caps characters while displaying the text. This is an inherited property, i.e. if it is
- // not defined, then the value of the parent view is used. Default value is `false`.
+ // not defined, then the value of the parent view is used. Default value is false.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - Text displayed using small caps.
- // `false` or `0` or "false", "no", "off", "0" - Normal text display.
+ // - true, 1, "true", "yes", "on", or "1" - Text displayed using small caps.
+ // - false, 0, "false", "no", "off", or "0" - Normal text display.
SmallCaps PropertyName = "small-caps"
// Strikethrough is the constant for "strikethrough" property tag.
//
- // Used by `View`.
+ // Used by View.
// Controls whether to draw line over the text. This is an inherited property, i.e. if it is not defined, then the value
- // of the parent view is used. Default value is `false`.
+ // of the parent view is used. Default value is false.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - Draw line over the text.
- // `false` or `0` or "false", "no", "off", "0" - Normal text display.
+ // - true, 1, "true", "yes", "on", or "1" - Draw line over the text.
+ // - false, 0, "false", "no", "off", or "0" - Normal text display.
Strikethrough PropertyName = "strikethrough"
// Overline is the constant for "overline" property tag.
//
- // Used by `View`.
+ // Used by View.
// Controls whether the line needs to be displayed on top of the text. This is an inherited property, i.e. if it is not
- // defined, then the value of the parent view is used. Default value is `false`.
+ // defined, then the value of the parent view is used. Default value is false.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - Overline text.
- // `false` or `0` or "false", "no", "off", "0" - No overline.
+ // - true, 1, "true", "yes", "on", or "1" - Overline text.
+ // - false, 0, "false", "no", "off", or "0" - No overline.
Overline PropertyName = "overline"
// Underline is the constant for "underline" property tag.
//
- // Used by `View`.
+ // Used by View.
// Controls whether to draw line below the text, This is an inherited property, i.e. if it is not defined, then the value
- // of the parent view is used. Default value is `false`.
+ // of the parent view is used. Default value is false.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - Draw line below the text.
- // `false` or `0` or "false", "no", "off", "0" - Normal text display.
+ // - true, 1, "true", "yes", "on", or "1" - Draw line below the text.
+ // - false, 0, "false", "no", "off", or "0" - Normal text display.
Underline PropertyName = "underline"
// TextLineThickness is the constant for "text-line-thickness" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the stroke thickness of the decoration line that is used on text in an element, such as a strikethrough, underline,
// or overline. This is an inherited property, i.e. if it is not defined, then the value of the parent view is used.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
TextLineThickness PropertyName = "text-line-thickness"
// TextLineStyle is the constant for "text-line-style" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the style of the lines specified by "strikethrough", "overline" and "underline" properties. This is an inherited
// property, i.e. if it is not defined, then the value of the parent view is used.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `1`(`SolidLine`) or "solid" - Solid line as a text line.
- // `2`(`DashedLine`) or "dashed" - Dashed line as a text line.
- // `3`(`DottedLine`) or "dotted" - Dotted line as a text line.
- // `4`(`DoubleLine`) or "double" - Double line as a text line.
- // `5`(`WavyLine`) or "wavy" - Wavy line as a text line.
+ // - 1 (SolidLine) or "solid" - Solid line as a text line.
+ // - 2 (DashedLine) or "dashed" - Dashed line as a text line.
+ // - 3 (DottedLine) or "dotted" - Dotted line as a text line.
+ // - 4 (DoubleLine) or "double" - Double line as a text line.
+ // - 5 (WavyLine) or "wavy" - Wavy line as a text line.
TextLineStyle PropertyName = "text-line-style"
// TextLineColor is the constant for "text-line-color" property tag.
//
- // Used by `View`.
+ // Used by View.
// Sets the color of the lines specified by "strikethrough", "overline" and "underline" properties. This is an inherited
// property, i.e. if it is not defined, then the value of the parent view is used.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See [Color] description for more details.
TextLineColor PropertyName = "text-line-color"
// TextWeight is the constant for "text-weight" property tag.
//
- // Used by `View`.
+ // Used by View.
// Sets weight of the text.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `1`(`ThinFont`) or "thin" - Thin font.
- // `2`(`ExtraLightFont`) or "extra-light" - Extra light font.
- // `3`(`LightFont`) or "light" - Light font.
- // `4`(`NormalFont`) or "normal" - Normal font.
- // `5`(`MediumFont`) or "medium" - Medium font.
- // `6`(`SemiBoldFont`) or "semi-bold" - Semi-bold font.
- // `7`(`BoldFont`) or "bold" - Bold font.
- // `8`(`ExtraBoldFont`) or "extra-bold" - Extra bold font.
- // `9`(`BlackFont`) or "black" - Black font.
+ // - 1 (ThinFont) or "thin" - Thin font.
+ // - 2 (ExtraLightFont) or "extra-light" - Extra light font.
+ // - 3 (LightFont) or "light" - Light font.
+ // - 4 (NormalFont) or "normal" - Normal font.
+ // - 5 (MediumFont) or "medium" - Medium font.
+ // - 6 (SemiBoldFont) or "semi-bold" - Semi-bold font.
+ // - 7 (BoldFont) or "bold" - Bold font.
+ // - 8 (ExtraBoldFont) or "extra-bold" - Extra bold font.
+ // - 9 (BlackFont) or "black" - Black font.
TextWeight PropertyName = "text-weight"
// TextAlign is the constant for "text-align" property tag.
//
- // Used by `TableView`, `View`.
+ // Used by TableView, View.
//
- // Usage in `TableView`:
+ // Usage in TableView:
// Sets the horizontal alignment of the content inside a table cell.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`LeftAlign`) or "left" - Left alignment.
- // `1`(`RightAlign`) or "right" - Right alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
- // `3`(`JustifyAlign`) or "justify" - Justify alignment.
+ // - 0 (LeftAlign) or "left" - Left alignment.
+ // - 1 (RightAlign) or "right" - Right alignment.
+ // - 2 (CenterAlign) or "center" - Center alignment.
+ // - 3 (JustifyAlign) or "justify" - Justify alignment.
//
- // Usage in `View`:
+ // Usage in View:
// Alignment of the text in view. This is an inherited property, i.e. if it is not defined, then the value of the parent
// view is used.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`LeftAlign`) or "left" - Left alignment.
- // `1`(`RightAlign`) or "right" - Right alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
- // `3`(`JustifyAlign`) or "justify" - Justify alignment.
+ // - 0 (LeftAlign) or "left" - Left alignment.
+ // - 1 (RightAlign) or "right" - Right alignment.
+ // - 2 (CenterAlign) or "center" - Center alignment.
+ // - 3 (JustifyAlign) or "justify" - Justify alignment.
TextAlign PropertyName = "text-align"
// TextIndent is the constant for "text-indent" property tag.
//
- // Used by `View`.
+ // Used by View.
// Determines the size of the indent(empty space) before the first line of text. This is an inherited property, i.e. if it
// is not defined, then the value of the parent view is used.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
TextIndent PropertyName = "text-indent"
// TextShadow is the constant for "text-shadow" property tag.
//
- // Used by `View`.
+ // Used by View.
// Specify shadow for the text.
//
- // Supported types: `ShadowProperty`, `[]ShadowProperty`, `string`.
+ // Supported types: ShadowProperty, []ShadowProperty, string.
//
- // Internal type is `[]ShadowProperty`, other types converted to it during assignment.
- // See `ShadowProperty` description for more details.
+ // Internal type is []ShadowProperty, other types converted to it during assignment.
+ // See ShadowProperty description for more details.
//
// Conversion rules:
- // `[]ShadowProperty` - stored as is. no conversion performed.
- // `ShadowProperty` - converted to `[]ShadowProperty` during assignment.
- // `string` - must contain a string representation of `ShadowProperty`
+ // - []ShadowProperty - stored as is. no conversion performed.
+ // - ShadowProperty - converted to []ShadowProperty during assignment.
+ // - string - must contain a string representation of ShadowProperty
TextShadow PropertyName = "text-shadow"
// TextWrap is the constant for "text-wrap" property tag.
//
- // Used by `View`.
+ // Used by View.
// Controls how text inside the view is wrapped. Default value is "wrap".
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`TextWrapOn`) or "wrap" - Text is wrapped across lines at appropriate characters (for example spaces, in languages like English that use space separators) to minimize overflow.
- // `1`(`TextWrapOff`) or "nowrap" - Text does not wrap across lines. It will overflow its containing element rather than breaking onto a new line.
- // `2`(`TextWrapBalance`) or "balance" - Text is wrapped in a way that best balances the number of characters on each line, enhancing layout quality and legibility. Because counting characters and balancing them across multiple lines is computationally expensive, this value is only supported for blocks of text spanning a limited number of lines (six or less for Chromium and ten or less for Firefox).
+ // - 0 (TextWrapOn) or "wrap" - Text is wrapped across lines at appropriate characters (for example spaces, in languages like English that use space separators) to minimize overflow.
+ // - 1 (TextWrapOff) or "nowrap" - Text does not wrap across lines. It will overflow its containing element rather than breaking onto a new line.
+ // - 2 (TextWrapBalance) or "balance" - Text is wrapped in a way that best balances the number of characters on each line, enhancing layout quality and legibility. Because counting characters and balancing them across multiple lines is computationally expensive, this value is only supported for blocks of text spanning a limited number of lines (six or less for Chromium and ten or less for Firefox).
TextWrap PropertyName = "text-wrap"
// TabSize is the constant for "tab-size" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the width of tab characters (U+0009) in spaces. This is an inherited property, i.e. if it is not defined, then the
- // value of the parent view is used. Default value is `8`.
+ // value of the parent view is used. Default value is 8.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // > `0` or > "0" - Number of spaces in tab character.
+ // - greater than 0 - Number of spaces in tab character.
+ // - 0 or negative - ignored.
TabSize PropertyName = "tab-size"
// LetterSpacing is the constant for "letter-spacing" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the horizontal spacing behavior between text characters. This value is added to the natural spacing between
// characters while rendering the text. Positive values of letter-spacing causes characters to spread farther apart, while
// negative values of letter-spacing bring characters closer together. This is an inherited property, i.e. if it is not
// defined, then the value of the parent view is used.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
LetterSpacing PropertyName = "letter-spacing"
// WordSpacing is the constant for "word-spacing" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the length of space between words and between tags. This is an inherited property, i.e. if it is not defined, then
// the value of the parent view is used.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
WordSpacing PropertyName = "word-spacing"
// LineHeight is the constant for "line-height" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the height of a line box. It's commonly used to set the distance between lines of text. This is an inherited
// property, i.e. if it is not defined, then the value of the parent view is used.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
LineHeight PropertyName = "line-height"
// WhiteSpace is the constant for "white-space" property tag.
//
- // Used by `View`.
+ // Used by View.
// Sets how white space inside an element is handled. This is an inherited property, i.e. if it is not defined, then the
// value of the parent view is used.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`WhiteSpaceNormal`) or "normal" - Sequences of spaces are concatenated into one space. Newlines in the source are treated as a single space. Applying this value optionally splits lines to fill inline boxes.
- // `1`(`WhiteSpaceNowrap`) or "nowrap" - Concatenates sequences of spaces into one space, like a normal value, but does not wrap lines(text wrapping) within the text.
- // `2`(`WhiteSpacePre`) or "pre" - Sequences of spaces are saved as they are specified in the source. Lines are wrapped only where newlines are specified in the source and where "br" elements are specified in the source.
- // `3`(`WhiteSpacePreWrap`) or "pre-wrap" - Sequences of spaces are saved as they are indicated in the source. Lines are wrapped only where newlines are specified in the source and there, where "br" elements are specified in the source, and optionally to fill inline boxes.
- // `4`(`WhiteSpacePreLine`) or "pre-line" - Sequences of spaces are concatenated into one space. Lines are split on newlines, on "br" elements, and optionally to fill inline boxes.
- // `5`(`WhiteSpaceBreakSpaces`) or "break-spaces" - The behavior is identical to `WhiteSpacePreWrap` with the following differences: 1. Sequences of spaces are preserved as specified in the source, including spaces at the end of lines. 2. Lines are wrapped on any spaces, including in the middle of a sequence of spaces. 3. Spaces take up space and do not hang at the ends of lines, which means they affect the internal dimensions (min-content and max-content).
+ // - 0 (WhiteSpaceNormal) or "normal" - Sequences of spaces are concatenated into one space.
+ // Newlines in the source are treated as a single space. Applying this value optionally splits lines to fill inline boxes.
+ // - 1 (WhiteSpaceNowrap) or "nowrap" - Concatenates sequences of spaces into one space, like a normal value, but does not wrap lines(text wrapping) within the text.
+ // - 2 (WhiteSpacePre) or "pre" - Sequences of spaces are saved as they are specified in the source.
+ // Lines are wrapped only where newlines are specified in the source and where "br" elements are specified in the source.
+ // - 3 (WhiteSpacePreWrap) or "pre-wrap" - Sequences of spaces are saved as they are indicated in the source.
+ // Lines are wrapped only where newlines are specified in the source and there, where "br" elements are specified in the source, and optionally to fill inline boxes.
+ // - 4 (WhiteSpacePreLine) or "pre-line" - Sequences of spaces are concatenated into one space. Lines are split on newlines, on "br" elements, and optionally to fill inline boxes.
+ // - 5 (WhiteSpaceBreakSpaces) or "break-spaces" - The behavior is identical to WhiteSpacePreWrap with the some differences.
+ //
+ // Differences WhiteSpaceBreakSpaces (5) from WhiteSpacePreWrap(3):
+ // 1. Sequences of spaces are preserved as specified in the source, including spaces at the end of lines.
+ // 2. Lines are wrapped on any spaces, including in the middle of a sequence of spaces.
+ // 3. Spaces take up space and do not hang at the ends of lines, which means they affect the internal dimensions (min-content and max-content).
WhiteSpace PropertyName = "white-space"
// WordBreak is the constant for "word-break" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set whether line breaks appear wherever the text would otherwise overflow its content box. This is an inherited
// property, i.e. if it is not defined, then the value of the parent view is used. Default value is "normal".
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`WordBreakNormal`) or "normal" - Default behavior for linefeed placement.
- // `1`(`WordBreakAll`) or "break-all" - If the block boundaries are exceeded, a line break will be inserted between any two characters(except for Chinese/Japanese/Korean text).
- // `2`(`WordBreakKeepAll`) or "keep-all" - Line break will not be used in Chinese/Japanese/ Korean text. For text in other languages, the default behavior(normal) will be applied.
- // `3`(`WordBreakWord`) or "break-word" - When the block boundaries are exceeded, the remaining whole words can be broken in an arbitrary place, if a more suitable place for line break is not found.
+ // - 0 (WordBreakNormal) or "normal" - Default behavior for linefeed placement.
+ // - 1 (WordBreakAll) or "break-all" - If the block boundaries are exceeded, a line break will be inserted between any two characters(except for Chinese/Japanese/Korean text).
+ // - 2 (WordBreakKeepAll) or "keep-all" - Line break will not be used in Chinese/Japanese/ Korean text. For text in other languages, the default behavior(normal) will be applied.
+ // - 3 (WordBreakWord) or "break-word" - When the block boundaries are exceeded, the remaining whole words can be broken in an arbitrary place, if a more suitable place for line break is not found.
WordBreak PropertyName = "word-break"
// TextTransform is the constant for "text-transform" property tag.
//
- // Used by `View`.
+ // Used by View.
// Specifies how to capitalize an element's text. It can be used to make text appear in all-uppercase or all-lowercase, or
// with each word capitalized. This is an inherited property, i.e. if it is not defined, then the value of the parent view
// is used.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneTextTransform`) or "none" - Original case of characters.
- // `1`(`CapitalizeTextTransform`) or "capitalize" - Every word starts with a capital letter.
- // `2`(`LowerCaseTextTransform`) or "lowercase" - All characters are lowercase.
- // `3`(`UpperCaseTextTransform`) or "uppercase" - All characters are uppercase.
+ // - 0 (NoneTextTransform) or "none" - Original case of characters.
+ // - 1 (CapitalizeTextTransform) or "capitalize" - Every word starts with a capital letter.
+ // - 2 (LowerCaseTextTransform) or "lowercase" - All characters are lowercase.
+ // - 3 (UpperCaseTextTransform) or "uppercase" - All characters are uppercase.
TextTransform PropertyName = "text-transform"
// TextDirection is the constant for "text-direction" property tag.
//
- // Used by `ColumnLayout`, `View`.
- //
- // Usage in `ColumnLayout`:
+ // Used by View.
// Sets the direction of text, table columns, and horizontal overflow. This is an inherited property, i.e. if it is not
// defined, then the value of the parent view is used. Default value is "system".
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`SystemTextDirection`) or "system" - Use the system text direction.
- // `1`(`LeftToRightDirection`) or "left-to-right" - For languages written from left to right (like English and most other languages).
- // `2`(`RightToLeftDirection`) or "right-to-left" - For languages written from right to left (like Hebrew or Arabic).
- //
- // Usage in `View`:
- // Set the direction of text, table columns, and horizontal overflow. This is an inherited property, i.e. if it is not
- // defined, then the value of the parent view is used, Default value is "system".
- //
- // Supported types: `int`, `string`.
- //
- // Values:
- // `0`(`SystemTextDirection`) or "system" - Use the system text direction.
- // `1`(`LeftToRightDirection`) or "left-to-right" - For languages written from left to right (like English and most other languages).
- // `2`(`RightToLeftDirection`) or "right-to-left" - For languages written from right to left (like Hebrew or Arabic).
+ // - 0 (SystemTextDirection) or "system" - Use the system text direction.
+ // - 1 (LeftToRightDirection) or "left-to-right" - For languages written from left to right (like English and most other languages).
+ // - 2 (RightToLeftDirection) or "right-to-left" - For languages written from right to left (like Hebrew or Arabic).
TextDirection PropertyName = "text-direction"
// WritingMode is the constant for "writing-mode" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set whether lines of text are laid out horizontally or vertically, as well as the direction in which blocks progress.
// This is an inherited property, i.e. if it is not defined, then the value of the parent view is used. Default value is
// "horizontal-top-to-bottom".
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`HorizontalTopToBottom`) or "horizontal-top-to-bottom" - Horizontal lines are displayed from top to bottom.
- // `1`(`HorizontalBottomToTop`) or "horizontal-bottom-to-top" - Horizontal lines are displayed from bottom to top.
- // `2`(`VerticalRightToLeft`) or "vertical-right-to-left" - Vertical lines are output from right to left.
- // `3`(`VerticalLeftToRight`) or "vertical-left-to-right" - Vertical lines are output from left to right.
+ // - 0 (HorizontalTopToBottom) or "horizontal-top-to-bottom" - Horizontal lines are displayed from top to bottom.
+ // - 1 (HorizontalBottomToTop) or "horizontal-bottom-to-top" - Horizontal lines are displayed from bottom to top.
+ // - 2 (VerticalRightToLeft) or "vertical-right-to-left" - Vertical lines are output from right to left.
+ // - 3 (VerticalLeftToRight) or "vertical-left-to-right" - Vertical lines are output from left to right.
WritingMode PropertyName = "writing-mode"
// VerticalTextOrientation is the constant for "vertical-text-orientation" property tag.
//
- // Used by `View`.
+ // Used by View.
// Set the orientation of the text characters in a line. It only affects text in vertical mode ("writing-mode" property).
// This is an inherited property, i.e. if it is not defined, then the value of the parent view is used.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`MixedTextOrientation`) or "mixed" - Symbols rotated 90° clockwise.
- // `1`(`UprightTextOrientation`) or "upright" - Symbols are arranged normally(vertically).
+ // - 0 (MixedTextOrientation) or "mixed" - Symbols rotated 90° clockwise.
+ // - 1 (UprightTextOrientation) or "upright" - Symbols are arranged normally(vertically).
VerticalTextOrientation PropertyName = "vertical-text-orientation"
// TextOverflow is the constant for "text-overflow" property tag.
//
- // Used by `TextView`.
+ // Used by TextView.
// Sets how hidden overflow content is signaled to users. Default value is "clip".
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`TextOverflowClip`) or "clip" - Text is clipped at the border.
- // `1`(`TextOverflowEllipsis`) or "ellipsis" - At the end of the visible part of the text "…" is displayed.
+ // - 0 (TextOverflowClip) or "clip" - Text is clipped at the border.
+ // - 1 (TextOverflowEllipsis) or "ellipsis" - At the end of the visible part of the text "…" is displayed.
TextOverflow PropertyName = "text-overflow"
// Hint is the constant for "hint" property tag.
//
- // Used by `EditView`.
+ // Used by EditView.
// Sets a hint to the user of what can be entered in the control.
//
- // Supported types: `string`.
+ // Supported types: string.
Hint PropertyName = "hint"
// MaxLength is the constant for "max-length" property tag.
//
- // Used by `EditView`.
+ // Used by EditView.
// Sets the maximum number of characters that the user can enter.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // >PropertyName = `0` or >PropertyName = "0" - Maximum number of characters.
+ // - positive value - Maximum number of characters.
+ // - 0 or negative value - The maximum number of characters is not limited.
MaxLength PropertyName = "max-length"
// ReadOnly is the constant for "readonly" property tag.
//
- // Used by `EditView`.
- // Controls whether the user can modify value or not. Default value is `false`.
+ // Used by EditView.
+ // Controls whether the user can modify value or not. Default value is false.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - User not able to modify the value.
- // `false` or `0` or "false", "no", "off", "0" - Value can be modified.
+ // - true, 1, "true", "yes", "on", or "1" - User not able to modify the value.
+ // - false, 0, "false", "no", "off", or "0" - Value can be modified.
ReadOnly PropertyName = "readonly"
// Content is the constant for "content" property tag.
//
- // Used by `Checkbox`, `GridLayout`, `ListLayout`, `Resizable`, `StackLayout`, `SvgImageView`, `TableView`, `TabsLayout`, `ViewsContainer`.
+ // Used by ViewsContainer, GridLayout, ListLayout, Resizable, StackLayout, SvgImageView, TableView.
+ //
+ // # Usage in ViewsContainer:
//
- // Usage in `Checkbox`:
// An array of child views.
//
- // Supported types: `View`, `[]View`, `string`, `[]string`, `[]any` containing elements of `View` or `string`.
+ // Supported types: View, []View, string, []string, []any containing elements of View, string.
//
- // Internal type is `[]View`, other types converted to it during assignment.
+ // Internal type is []View, other types converted to it during assignment.
//
// Conversion rules:
- // `View` - converted to `[]View` containing one element.
- // `[]View` - nil-elements are prohibited, if the array contains nil, then the property will not be set, and the `Set` function will return false and an error message will be written to the log.
- // `string` - if the string is a text representation of the `View`, then the corresponding view is created, otherwise a `TextView` is created, to which the given string is passed as a text. Then a `[]View` is created containing the resulting view.
- // `[]string` - each element of an array is converted to `View` as described above.
- // `[]any` - this array must contain only `View` and a `string`. Each `string` element is converted to a view as described above. If array contains invalid values, the "content" property will not be set, and the `Set` function will return `false` and an error message will be written to the log.
+ // - View - converted to []View containing one element.
+ // - []View - nil-elements are prohibited, if the array contains nil, then the property will not be set, and the Set function will return false and an error message will be written to the log.
+ // - string - if the string is a text representation of the View, then the corresponding view is created, otherwise a TextView is created, to which the given string is passed as a text. Then a []View is created containing the resulting view.
+ // - []string - each element of an array is converted to View as described above.
+ // - []any - this array must contain only View and a string. Each string element is converted to a view as described above. If array contains invalid values, the "content" property will not be set, and the Set function will return false and an error message will be written to the log.
//
- // Usage in `GridLayout`:
- // Defines an array of child views or can be an implementation of `GridAdapter` interface.
+ // # Usage in GridLayout:
//
- // Supported types: `[]View`, `GridAdapter`, `View`, `string`, `[]string`.
+ // Defines an array of child views or can be an implementation of GridAdapter interface.
//
- // Internal type is either `[]View` or `GridAdapter`, other types converted to `[]View` during assignment.
+ // Supported types: []View, GridAdapter, View, string, []string.
+ //
+ // Internal type is either []View or GridAdapter, other types converted to []View during assignment.
//
// Conversion rules:
- // `View` - view which describe one cell, converted to `[]View`.
- // `[]View` - describe several cells, stored as is.
- // `string` - text representation of the view which describe one cell, converted to `[]View`.
- // `[]string` - an array of text representation of the views which describe several cells, converted to `[]View`.
- // `GridAdapter` - interface which describe several cells, see `GridAdapter` description for more details.
+ // - View - view which describe one cell, converted to []View.
+ // - []View - describe several cells, stored as is.
+ // - string - text representation of the view which describe one cell, converted to []View.
+ // - []string - an array of text representation of the views which describe several cells, converted to []View.
+ // - GridAdapter - interface which describe several cells, see GridAdapter description for more details.
//
- // Usage in `ListLayout`:
- // Defines an array of child views or can be an implementation of `ListAdapter` interface.
+ // # Usage in ListLayout:
//
- // Supported types: `[]View`, `ListAdapter`, `View`, `string`, `[]string`.
+ // Defines an array of child views or can be an implementation of ListAdapter interface.
//
- // Internal type is either `[]View` or `ListAdapter`, other types converted to `[]View` during assignment.
+ // Supported types: []View, ListAdapter, View, string, []string.
+ //
+ // Internal type is either []View or ListAdapter, other types converted to []View during assignment.
//
// Conversion rules:
- // `View` - view which describe one item, converted to `[]View`.
- // `[]View` - describe several items, stored as is.
- // `string` - text representation of the view which describe one item, converted to `[]View`.
- // `[]string` - an array of text representation of the views which describe several items, converted to `[]View`.
- // `ListAdapter` - interface which describe several items, see `ListAdapter` description for more details.
+ // - View - view which describe one item, converted to []View.
+ // - []View - describe several items, stored as is.
+ // - string - text representation of the view which describe one item, converted to []View.
+ // - []string - an array of text representation of the views which describe several items, converted to []View.
+ // - ListAdapter - interface which describe several items, see ListAdapter description for more details.
//
- // Usage in `Resizable`:
- // Content view to make it resizable or text in this case `TextView` will be created.
+ // # Usage in Resizable:
//
- // Supported types: `View`, `string`.
+ // Content view to make it resizable or text in this case TextView will be created.
//
- // Internal type is `View`, other types converted to it during assignment.
+ // Supported types: View, string.
//
- // Usage in `StackLayout`:
+ // Internal type is View, other types converted to it during assignment.
+ //
+ // Usage in StackLayout:
// An array of child views.
//
- // Supported types: `View`, `[]View`, `string`, `[]string`, `[]any` containing elements of `View`, `string`.
+ // Supported types: View, []View, string, []string, []any containing elements of View, string.
//
- // Internal type is `[]View`, other types converted to it during assignment.
+ // Internal type is []View, other types converted to it during assignment.
//
// Conversion rules:
- // `View` - converted to `[]View` containing one element.
- // `[]View` - nil-elements are prohibited, if the array contains nil, then the property will not be set, and the `Set` function will return false and an error message will be written to the log.
- // `string` - if the string is a text representation of the `View`, then the corresponding view is created, otherwise a `TextView` is created, to which the given string is passed as a text. Then a `[]View` is created containing the resulting view.
- // `[]string` - each element of an array is converted to `View` as described above.
- // `[]any` - this array must contain only `View` and a `string`. Each `string` element is converted to a view as described above. If array contains invalid values, the "content" property will not be set, and the `Set` function will return `false` and an error message will be written to the log.
+ // - View - converted to []View containing one element.
+ // - []View - nil-elements are prohibited, if the array contains nil, then the property will not be set, and the Set function will return false and an error message will be written to the log.
+ // - string - if the string is a text representation of the View, then the corresponding view is created, otherwise a TextView is created, to which the given string is passed as a text. Then a []View is created containing the resulting view.
+ // - []string - each element of an array is converted to View as described above.
+ // - []any - this array must contain only View and a string. Each string element is converted to a view as described above. If array contains invalid values, the "content" property will not be set, and the Set function will return false and an error message will be written to the log.
//
- // Usage in `SvgImageView`:
- // Image to display. Could be the image file name in the images folder of the resources, image URL or content of the svg
- // image.
+ // # Usage in SvgImageView:
//
- // Supported types: `string`.
+ // Image to display. Could be the image file name in the images folder of the resources, image URL or content of the svg image.
+ //
+ // Supported types: string.
+ //
+ // # Usage in TableView:
//
- // Usage in `TableView`:
// Defines the content of the table.
//
- // Supported types: `TableAdapter`, `[][]string`, `[][]any`.
+ // Supported types: TableAdapter, [][]string, [][]any.
//
- // Internal type is `TableAdapter`, other types converted to it during assignment.
- // See `TableAdapter` description for more details.
- //
- // Usage in `TabsLayout`:
- // An array of child views.
- //
- // Supported types: `View`, `[]View`, `string`, `[]string`, `[]any` containing elements of `View` or `string`.
- //
- // Internal type is `[]View`, other types converted to it during assignment.
- //
- // Conversion rules:
- // `View` - converted to `[]View` containing one element.
- // `[]View` - nil-elements are prohibited, if the array contains nil, then the property will not be set, and the `Set` function will return false and an error message will be written to the log.
- // `string` - if the string is a text representation of the `View`, then the corresponding view is created, otherwise a `TextView` is created, to which the given string is passed as a text. Then a `[]View` is created containing the resulting view.
- // `[]string` - each element of an array is converted to `View` as described above.
- // `[]any` - this array must contain only `View` and a `string`. Each `string` element is converted to a view as described above. If array contains invalid values, the "content" property will not be set, and the `Set` function will return `false` and an error message will be written to the log.
- //
- // Usage in `ViewsContainer`:
- // An array of child views.
- //
- // Supported types: `View`, `[]View`, `string`, `[]string`, `[]any` containing elements of `View`, `string`.
- //
- // Internal type is `[]View`, other types converted to it during assignment.
- //
- // Conversion rules:
- // `View` - converted to `[]View` containing one element.
- // `[]View` - nil-elements are prohibited, if the array contains nil, then the property will not be set, and the `Set` function will return false and an error message will be written to the log.
- // `string` - if the string is a text representation of the `View`, then the corresponding view is created, otherwise a `TextView` is created, to which the given string is passed as a text. Then a `[]View` is created containing the resulting view.
- // `[]string` - each element of an array is converted to `View` as described above.
- // `[]any` - this array must contain only `View` and a `string`. Each `string` element is converted to a view as described above. If array contains invalid values, the "content" property will not be set, and the `Set` function will return `false` and an error message will be written to the log.
+ // Internal type is TableAdapter, other types converted to it during assignment.
+ // See TableAdapter description for more details.
Content PropertyName = "content"
// Items is the constant for "items" property tag.
//
- // Used by `DropDownList`, `ListView`, `Popup`.
+ // Used by DropDownList, ListView, Popup.
+ //
+ // # Usage in DropDownList:
//
- // Usage in `DropDownList`:
// Array of data elements.
//
- // Supported types: `[]string`, `string`, `[]fmt.Stringer`, `[]Color`, `[]SizeUnit`, `[]AngleUnit`, `[]any` containing
- // elements of `string`, `fmt.Stringer`, `bool`, `rune`, `float32`, `float64`, `int`, `int8` … `int64`, `uint`, `uint8` …
- // `uint64`.
+ // Supported types: []string, string, []fmt.Stringer, []Color, []SizeUnit, []AngleUnit, []any containing
+ // elements of string, fmt.Stringer, bool, rune, float32, float64, int, int8…int64, uint, uint8…uint64.
//
- // Internal type is `[]string`, other types converted to it during assignment.
+ // Internal type is []string, other types converted to it during assignment.
//
// Conversion rules:
- // `string` - contain single item.
- // `[]string` - an array of items.
- // `[]fmt.Stringer` - an array of objects convertible to string.
- // `[]Color` - An array of color values which will be converted to a string array.
- // `[]SizeUnit` - an array of size unit values which will be converted to a string array.
- // `[]any` - this array must contain only types which were listed in Types section.
+ // - string - contain single item.
+ // - []string - an array of items.
+ // - []fmt.Stringer - an array of objects convertible to string.
+ // - []Color - An array of color values which will be converted to a string array.
+ // - []SizeUnit - an array of size unit values which will be converted to a string array.
+ // - []any - this array must contain only types which were listed in Types section.
//
- // Usage in `ListView`:
- // List content. Main value is an implementation of `ListAdapter` interface.
+ // # Usage in ListView:
//
- // Supported types: `ListAdapter`, `[]View`, `[]string`, `[]any` containing elements of `View`, `string`, `fmt.Stringer`,
- // `float` and `int`.
+ // List content. Main value is an implementation of ListAdapter interface.
//
- // Internal type is either `[]View` or `ListAdapter`, other types converted to it during assignment.
+ // Supported types: ListAdapter, []View, []string, []any containing elements of View, string, fmt.Stringer, float and int.
+ //
+ // Internal type is either []View or ListAdapter, other types converted to it during assignment.
//
// Conversion rules:
- // `ListAdapter` - interface which provides an access to list items and other information, stored as is.
- // `[]View` - an array of list items, each in a form of some view-based element. Stored as is.
- // `[]string` - an array of text. Converted into an internal implementation of `ListAdapter`, each list item will be an instance of `TextView`.
- // `[]any` - an array of items of arbitrary type, where types like `string`, `fmt.Stringer`, `float` and `int` will be converted to `TextView`. `View` type will remain unchanged. All values after conversion will be wrapped by internal implementation of `ListAdapter`.
+ // - ListAdapter - interface which provides an access to list items and other information, stored as is.
+ // - []View - an array of list items, each in a form of some view-based element. Stored as is.
+ // - []string - an array of text. Converted into an internal implementation of ListAdapter, each list item will be an instance of TextView.
+ // - []any - an array of items of arbitrary type, where types like string, fmt.Stringer, float and int will be converted to TextView. View type will remain unchanged. All values after conversion will be wrapped by internal implementation of ListAdapter.
+ //
+ // # Usage in Popup:
//
- // Usage in `Popup`:
// Array of menu items.
//
- // Supported types: `ListAdapter`, `[]string`.
+ // Supported types: ListAdapter, []string.
//
- // Internal type is `ListAdapter` internal implementation, other types converted to it during assignment.
+ // Internal type is ListAdapter internal implementation, other types converted to it during assignment.
Items PropertyName = "items"
// DisabledItems is the constant for "disabled-items" property tag.
//
- // Used by `DropDownList`.
+ // Used by DropDownList.
// An array of disabled(non selectable) items indices.
//
- // Supported types: `[]int`, `string`, `[]string`, `[]any` containing elements of `string` or `int`.
+ // Supported types: []int, string, []string, []any containing elements of string or int.
//
- // Internal type is `[]int`, other types converted to it during assignment.
+ // Internal type is []int, other types converted to it during assignment.
// Rules of conversion.
- // `[]int` - Array of indices.
- // `string` - Single index value or multiple index values separated by comma(`,`).
- // `[]string` - Array of indices in text format.
- // `[]any` - Array of strings or integer values.
+ // - []int - Array of indices.
+ // - string - Single index value or multiple index values separated by comma(,).
+ // - []string - Array of indices in text format.
+ // - []any - Array of strings or integer values.
DisabledItems PropertyName = "disabled-items"
// ItemSeparators is the constant for "item-separators" property tag.
//
- // Used by `DropDownList`.
- // An array of indices of `DropDownList` items after which a separator should be added.
+ // Used by DropDownList.
+ // An array of indices of DropDownList items after which a separator should be added.
//
- // Supported types: `[]int`, `string`, `[]string`, `[]any` containing elements of `string` or `int`.
+ // Supported types: []int, string, []string, []any containing elements of string or int.
//
- // Internal type is `[]int`, other types converted to it during assignment.
+ // Internal type is []int, other types converted to it during assignment.
// Rules of conversion.
- // `[]int` - Array of indices.
- // `string` - Single index value or multiple index values separated by comma(`,`).
- // `[]string` - Array of indices in text format.
- // `[]any` - Array of strings or integer values.
+ // - []int - Array of indices.
+ // - string - Single index value or multiple index values separated by comma(,).
+ // - []string - Array of indices in text format.
+ // - []any - Array of strings or integer values.
ItemSeparators PropertyName = "item-separators"
// Current is the constant for "current" property tag.
//
- // Used by `DropDownList`, `ListView`, `StackLayout`, `TableView`, `TabsLayout`.
+ // Used by DropDownList, ListView, TableView, TabsLayout.
+ //
+ // # Usage in DropDownList:
//
- // Usage in `DropDownList`:
// Current selected item.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `-1` or "-1" - No item has been selected.
- // >PropertyName = `0` or >PropertyName = "0" - Index of selected item.
+ // - negative value - No item has been selected.
+ // - not negative value - Index of selected item.
+ //
+ // # Usage in ListView:
//
- // Usage in `ListView`:
// Set or get index of selected item.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `-1` or "-1" - No item has been selected.
- // >PropertyName = `0` or >PropertyName = "0" - Index of selected item.
+ // - negative value - No item has been selected.
+ // - not negative value - Index of selected item.
//
- // Usage in `StackLayout`:
- // Set or Index of current(visible) view.
+ // # Usage in TableView:
//
- // Supported types: `int`, `string`.
- //
- // Values:
- // `-1` or "-1" - No visible view.
- // >PropertyName = `0` or >PropertyName = "0" - Index of visible view.
- //
- // Usage in `TableView`:
// Sets the coordinates of the selected cell/row.
//
- // Supported types: `CellIndex`, `int`, `string`.
+ // Supported types: CellIndex, int, string.
//
- // Internal type is `CellIndex`, other types converted to it during assignment.
- // See `CellIndex` description for more details.
+ // Internal type is CellIndex, other types converted to it during assignment.
+ // See CellIndex description for more details.
//
// Conversion rules:
- // `int` - specify index of current table row, current column index will be set to -1.
- // `string` - can be one integer value which specify current row or pair of integer values separated by comma(`,`). When two values provided then first value specify current row index and second one specify column index.
+ // - int - specify index of current table row, current column index will be set to -1.
+ // - string - can be one integer value which specify current row or pair of integer values separated by comma(,). When two values provided then first value specify current row index and second one specify column index.
+ //
+ // # Usage in TabsLayout:
//
- // Usage in `TabsLayout`:
// Defines index of the current active child view.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `-1` or "-1" - No visible tab.
- // >PropertyName = `0` or >PropertyName = "0" - Index of visible tab.
+ // - negative value - No visible tab.
+ // - not negative value - Index of visible tab.
Current PropertyName = "current"
// Type is the constant for "type" property tag.
//
- // Used by `EditView`, `NumberPicker`.
+ // Used by EditView, NumberPicker.
//
- // Usage in `EditView`:
- // Same as "edit-view-type".
+ // Usage in EditView:
+ // Same as "edit-view-type" [EditViewType].
//
- // Usage in `NumberPicker`:
- // Same as "number-picker-type".
+ // Usage in NumberPicker:
+ // Same as "number-picker-type" [NumberPickerType].
Type PropertyName = "type"
// Pattern is the constant for "pattern" property tag.
//
- // Used by `EditView`.
- // Same as "edit-view-pattern".
+ // Used by EditView.
+ // Same as "edit-view-pattern" [EditViewPattern].
Pattern PropertyName = "pattern"
// GridAutoFlow is the constant for "grid-auto-flow" property tag.
//
- // Used by `GridLayout`.
- // Controls how to place child controls if `Row` and `Column` properties were not set for children views.
+ // Used by GridLayout.
+ // Controls how to place child controls if Row and Column properties were not set for children views.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`RowAutoFlow`) or "row" - Views are placed by filling each row in turn, adding new rows as necessary.
- // `1`(`ColumnAutoFlow`) or "column" - Views are placed by filling each column in turn, adding new columns as necessary.
- // `2`(`RowDenseAutoFlow`) or "row-dense" - Views are placed by filling each row, adding new rows as necessary. "dense" packing algorithm attempts to fill in holes earlier in the grid, if smaller items come up later. This may cause views to appear out-of-order, when doing so would fill in holes left by larger views.
- // `3`(`ColumnDenseAutoFlow`) or "column-dense" - Views are placed by filling each column, adding new columns as necessary. "dense" packing algorithm attempts to fill in holes earlier in the grid, if smaller items come up later. This may cause views to appear out-of-order, when doing so would fill in holes left by larger views.
+ // - 0 (RowAutoFlow) or "row" - Views are placed by filling each row in turn, adding new rows as necessary.
+ // - 1 (ColumnAutoFlow) or "column" - Views are placed by filling each column in turn, adding new columns as necessary.
+ // - 2 (RowDenseAutoFlow) or "row-dense" - Views are placed by filling each row, adding new rows as necessary. "dense" packing algorithm attempts to fill in holes earlier in the grid, if smaller items come up later. This may cause views to appear out-of-order, when doing so would fill in holes left by larger views.
+ // - 3 (ColumnDenseAutoFlow) or "column-dense" - Views are placed by filling each column, adding new columns as necessary. "dense" packing algorithm attempts to fill in holes earlier in the grid, if smaller items come up later. This may cause views to appear out-of-order, when doing so would fill in holes left by larger views.
GridAutoFlow PropertyName = "grid-auto-flow"
// CellWidth is the constant for "cell-width" property tag.
//
- // Used by `GridLayout`.
- // Set a fixed width of `GridLayout` cells regardless of the size of the child elements. Each element in the array
+ // Used by GridLayout:
+ // Set a fixed width of GridLayout cells regardless of the size of the child elements. Each element in the array
// determines the size of the corresponding column. By default, the sizes of the cells are calculated based on the sizes
// of the child views placed in them.
//
- // Supported types: `SizeUnit`, `[]SizeUnit`, `SizeFunc`, `string`, `[]string`, `[]any` containing elements of `string` or
- // `SizeUnit`.
+ // Supported types: SizeUnit, []SizeUnit, SizeFunc, string, []string, []any containing elements of string or
+ // SizeUnit.
//
- // Internal type is either `SizeUnit` or `[]SizeUnit`, other types converted to it during assignment.
+ // Internal type is either SizeUnit or []SizeUnit, other types converted to it during assignment.
//
// Conversion rules:
- // `SizeUnit`, `SizeFunc` - stored as is and all cells are set to have the same width.
- // `[]SizeUnit` - stored as is and each column of the grid layout has width which is specified in an array.
- // `string` - containing textual representations of `SizeUnit` (or `SizeUnit` constants), may contain several values separated by comma(`,`). Each column of the grid layout has width which is specified in an array.
- // `[]string` - each element must be a textual representation of a `SizeUnit` (or a `SizeUnit` constant). Each column of the grid layout has width which is specified in an array.
- // If the number of elements in an array is less than the number of columns used, then the missing elements are set to have `Auto` size.
- // The values can use `SizeUnit` type `SizeInFraction`. This type means 1 part. The part is calculated as follows: the size of all cells that are not of type `SizeInFraction` is subtracted from the size of the container, and then the remaining size is divided by the number of parts. The `SizeUnit` value of type `SizeInFraction` can be either integer or fractional.
+ // - SizeUnit, SizeFunc - stored as is and all cells are set to have the same width.
+ // - []SizeUnit - stored as is and each column of the grid layout has width which is specified in an array.
+ // - string - containing textual representations of SizeUnit (or SizeUnit constants), may contain several values separated by comma(,). Each column of the grid layout has width which is specified in an array.
+ // - []string - each element must be a textual representation of a SizeUnit (or a SizeUnit constant). Each column of the grid layout has width which is specified in an array.
+ // If the number of elements in an array is less than the number of columns used, then the missing elements are set to have Auto size.
+ //
+ // The values can use SizeUnit type SizeInFraction. This type means 1 part. The part is calculated as follows: the size of all cells that are not of type SizeInFraction is subtracted from the size of the container, and then the remaining size is divided by the number of parts. The SizeUnit value of type SizeInFraction can be either integer or fractional.
CellWidth PropertyName = "cell-width"
// CellHeight is the constant for "cell-height" property tag.
//
- // Used by `GridLayout`.
- // Set a fixed height of `GridLayout` cells regardless of the size of the child elements. Each element in the array
+ // Used by GridLayout:
+ // Set a fixed height of GridLayout cells regardless of the size of the child elements. Each element in the array
// determines the size of the corresponding row. By default, the sizes of the cells are calculated based on the sizes of
// the child views placed in them.
//
- // Supported types: `SizeUnit`, `[]SizeUnit`, `SizeFunc`, `string`, `[]string`, `[]any` containing elements of `string` or
- // `SizeUnit`.
+ // Supported types: SizeUnit, []SizeUnit, SizeFunc, string, []string, []any containing elements of string or
+ // SizeUnit.
//
- // Internal type is either `SizeUnit` or `[]SizeUnit`, other types converted to it during assignment.
+ // Internal type is either SizeUnit or []SizeUnit, other types converted to it during assignment.
//
// Conversion rules:
- // `SizeUnit`, `SizeFunc` - stored as is and all cells are set to have the same height.
- // `[]SizeUnit` - stored as is and each row of the grid layout has height which is specified in an array.
- // `string` - containing textual representations of `SizeUnit` (or `SizeUnit` constants), may contain several values separated by comma(`,`). Each row of the grid layout has height which is specified in an array.
- // `[]string` - each element must be a textual representation of a `SizeUnit` (or a `SizeUnit` constant). Each row of the grid layout has height which is specified in an array.
- // If the number of elements in an array is less than the number of rows used, then the missing elements are set to have `Auto` size.
- // The values can use `SizeUnit` type `SizeInFraction`. This type means 1 part. The part is calculated as follows: the size of all cells that are not of type `SizeInFraction` is subtracted from the size of the container, and then the remaining size is divided by the number of parts. The `SizeUnit` value of type `SizeInFraction` can be either integer or fractional.
+ // - SizeUnit, SizeFunc - stored as is and all cells are set to have the same height.
+ // - []SizeUnit - stored as is and each row of the grid layout has height which is specified in an array.
+ // - string - containing textual representations of SizeUnit (or SizeUnit constants), may contain several values separated by comma(,). Each row of the grid layout has height which is specified in an array.
+ // - []string - each element must be a textual representation of a SizeUnit (or a SizeUnit constant). Each row of the grid layout has height which is specified in an array.
+ // If the number of elements in an array is less than the number of rows used, then the missing elements are set to have Auto size.
+ //
+ // The values can use SizeUnit type SizeInFraction. This type means 1 part. The part is calculated as follows: the size of all cells that are not of type SizeInFraction is subtracted from the size of the container, and then the remaining size is divided by the number of parts. The SizeUnit value of type SizeInFraction can be either integer or fractional.
CellHeight PropertyName = "cell-height"
// GridRowGap is the constant for "grid-row-gap" property tag.
//
- // Used by `GridLayout`.
+ // Used by GridLayout.
// Space between rows.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
GridRowGap PropertyName = "grid-row-gap"
// GridColumnGap is the constant for "grid-column-gap" property tag.
//
- // Used by `GridLayout`.
+ // Used by GridLayout.
// Space between columns.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
GridColumnGap PropertyName = "grid-column-gap"
// Source is the constant for "src" property tag.
//
- // Used by `AudioPlayer`, `ImageView`, `VideoPlayer`.
+ // Used by AudioPlayer, ImageView, VideoPlayer.
+ //
+ // # Usage in AudioPlayer
//
- // Usage in `AudioPlayer`:
// Specifies the location of the media file(s). Since different browsers support different file formats and codecs, it is
// recommended to specify multiple sources in different formats. The player chooses the most suitable one from the list of
// sources. Setting mime types makes this process easier for the browser.
//
- // Supported types: `string`, `MediaSource`, `[]MediaSource`.
+ // Supported types: string, MediaSource, []MediaSource.
//
- // Internal type is `[]MediaSource`, other types converted to it during assignment.
+ // Internal type is []MediaSource, other types converted to it during assignment.
+ //
+ // # Usage in ImageView
//
- // Usage in `ImageView`:
// Set either the name of the image in the "images" folder of the resources, or the URL of the image or inline-image. An
// inline-image is the content of an image file encoded in base64 format.
//
- // Supported types: `string`.
+ // Supported types: string.
+ //
+ // # Usage in VideoPlayer
//
- // Usage in `VideoPlayer`:
// Specifies the location of the media file(s). Since different browsers support different file formats and codecs, it is
// recommended to specify multiple sources in different formats. The player chooses the most suitable one from the list of
// sources. Setting mime types makes this process easier for the browser.
//
- // Supported types: `string`, `MediaSource`, `[]MediaSource`.
+ // Supported types: string, MediaSource, []MediaSource.
//
- // Internal type is `[]MediaSource`, other types converted to it during assignment.
+ // Internal type is []MediaSource, other types converted to it during assignment.
Source PropertyName = "src"
// SrcSet is the constant for "srcset" property tag.
//
- // Used by `ImageView`.
- // String which identifies one or more image candidate strings, separated using comma(`,`) each specifying image resources
+ // Used by ImageView.
+ // String which identifies one or more image candidate strings, separated using comma(,) each specifying image resources
// to use under given screen density. This property is only used if building an application for js/wasm platform.
//
- // Supported types: `string`.
+ // Supported types: string.
SrcSet PropertyName = "srcset"
// Fit is the constant for "fit" property tag.
//
- // Used by `ImageView`, `BackgroundElement`.
+ // Used by ImageView, BackgroundElement.
+ //
+ // # Usage in ImageView
//
- // Usage in `ImageView`:
// Defines the image scaling parameters.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneFit`) or "none" - The image is not resized.
- // `1`(`ContainFit`) or "contain" - The image is scaled to maintain its aspect ratio while fitting within the element’s content box. The entire object is made to fill the box, while preserving its aspect ratio, so the object will be "letterboxed" if its aspect ratio does not match the aspect ratio of the box.
- // `2`(`CoverFit`) or "cover" - The image is sized to maintain its aspect ratio while filling the element’s entire content box. If the object's aspect ratio does not match the aspect ratio of its box, then the object will be clipped to fit.
- // `3`(`FillFit`) or "fill" - The image to fill the element’s content box. The entire object will completely fill the box. If the object's aspect ratio does not match the aspect ratio of its box, then the object will be stretched to fit.
- // `4`(`ScaleDownFit`) or "scale-down" - The image is sized as if NoneFit or ContainFit were specified, whichever would result in a smaller concrete object size.
+ // - 0 (NoneFit) or "none" - The image is not resized.
+ // - 1 (ContainFit) or "contain" - The image is scaled to maintain its aspect ratio while fitting within the element’s content box. The entire object is made to fill the box, while preserving its aspect ratio, so the object will be "letterboxed" if its aspect ratio does not match the aspect ratio of the box.
+ // - 2 (CoverFit) or "cover" - The image is sized to maintain its aspect ratio while filling the element’s entire content box. If the object's aspect ratio does not match the aspect ratio of its box, then the object will be clipped to fit.
+ // - 3 (FillFit) or "fill" - The image to fill the element’s content box. The entire object will completely fill the box. If the object's aspect ratio does not match the aspect ratio of its box, then the object will be stretched to fit.
+ // - 4 (ScaleDownFit) or "scale-down" - The image is sized as if NoneFit or ContainFit were specified, whichever would result in a smaller concrete object size.
+ //
+ // # Usage in BackgroundElement
//
- // Usage in `BackgroundElement`:
// Used for image background only. Defines the image scaling parameters.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneFit`) or "none" - The image is not resized.
- // `1`(`ContainFit`) or "contain" - The image is scaled to maintain its aspect ratio while fitting within the element’s content box. The entire object is made to fill the box, while preserving its aspect ratio, so the object will be "letterboxed" if its aspect ratio does not match the aspect ratio of the box.
- // `2`(`CoverFit`) or "cover" - The image is sized to maintain its aspect ratio while filling the element’s entire content box. If the object's aspect ratio does not match the aspect ratio of its box, then the object will be clipped to fit.
+ // - 0 (NoneFit) or "none" - The image is not resized.
+ // - 1 (ContainFit) or "contain" - The image is scaled to maintain its aspect ratio while fitting within the element’s content box. The entire object is made to fill the box, while preserving its aspect ratio, so the object will be "letterboxed" if its aspect ratio does not match the aspect ratio of the box.
+ // - 2 (CoverFit) or "cover" - The image is sized to maintain its aspect ratio while filling the element’s entire content box. If the object's aspect ratio does not match the aspect ratio of its box, then the object will be clipped to fit.
Fit PropertyName = "fit"
backgroundFit PropertyName = "background-fit"
// Repeat is the constant for "repeat" property tag.
//
- // Used by `BackgroundElement`.
- // Used for image background only. Specifying the repetition of the image. Used only for a background image. Default value
- // is "no-repeat".
+ // Used by BackgroundElement.
+ // Used for image background only. Specifying the repetition of the image. Default value is "no-repeat".
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoRepeat`) or "no-repeat" - Image does not repeat.
- // `1`(`RepeatXY`) or "repeat" - Image repeat horizontally and vertically.
- // `2`(`RepeatX`) or "repeat-x" - Image repeat only horizontally.
- // `3`(`RepeatY`) or "repeat-y" - Image repeat only vertically.
- // `4`(`RepeatRound`) or "round" - Image is repeated so that an integer number of images fit into the background area. If this fails, then the background images are scaled.
- // `5`(`RepeatSpace`) or "space" - Image is repeated as many times as necessary to fill the background area. If this fails, an empty space is added between the pictures.
+ // - 0 (NoRepeat) or "no-repeat" - Image does not repeat.
+ // - 1 (RepeatXY) or "repeat" - Image repeat horizontally and vertically.
+ // - 2 (RepeatX) or "repeat-x" - Image repeat only horizontally.
+ // - 3 (RepeatY) or "repeat-y" - Image repeat only vertically.
+ // - 4 (RepeatRound) or "round" - Image is repeated so that an integer number of images fit into the background area. If this fails, then the background images are scaled.
+ // - 5 (RepeatSpace) or "space" - Image is repeated as many times as necessary to fill the background area. If this fails, an empty space is added between the pictures.
Repeat PropertyName = "repeat"
// Attachment is the constant for "attachment" property tag.
//
- // Used by `BackgroundElement`.
+ // Used by BackgroundElement.
// Used for image background only. Sets whether a background image's position is fixed within the viewport or scrolls with
// its containing block.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`ScrollAttachment`) or "scroll" - The background image will scroll with the page.
- // `1`(`FixedAttachment`) or "fixed" - The background image will not scroll with the page.
- // `2`(`LocalAttachment`) or "local" - The background image will scroll with the element's contents.
+ // - 0 (ScrollAttachment) or "scroll" - The background image will scroll with the page.
+ // - 1 (FixedAttachment) or "fixed" - The background image will not scroll with the page.
+ // - 2 (LocalAttachment) or "local" - The background image will scroll with the element's contents.
Attachment PropertyName = "attachment"
// BackgroundClip is the constant for "background-clip" property tag.
//
- // Used by `View`.
+ // Used by View.
// Determines how the background color and/or background image will be displayed below the box borders.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`BorderBoxClip`) or "border-box" - The background extends to the outer edge of the border(but below the border in z-order).
- // `1`(`PaddingBoxClip`) or "padding-box" - The background extends to the outer edge of the padding. No background is drawn below the border.
- // `2`(`ContentBoxClip`) or "content-box" - The background is painted inside(clipped) of the content box.
+ // - 0 (BorderBoxClip) or "border-box" - The background extends to the outer edge of the border(but below the border in z-order).
+ // - 1 (PaddingBoxClip) or "padding-box" - The background extends to the outer edge of the padding. No background is drawn below the border.
+ // - 2 (ContentBoxClip) or "content-box" - The background is painted inside(clipped) of the content box.
BackgroundClip PropertyName = "background-clip"
// BackgroundOrigin is the constant for "background-origin" property tag.
//
- // Used by `View`.
+ // Used by View.
// Determines the background's origin: from the border start, inside the border, or inside the padding.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`BorderBox`) or "border-box" - The background is positioned relative to the border box.
- // `1`(`PaddingBox`) or "padding-box" - The background is positioned relative to the padding box.
- // `2`(`ContentBox`) or "content-box" - The background is positioned relative to the content box.
+ // - 0 (BorderBox) or "border-box" - The background is positioned relative to the border box.
+ // - 1 (PaddingBox) or "padding-box" - The background is positioned relative to the padding box.
+ // - 2 (ContentBox) or "content-box" - The background is positioned relative to the content box.
BackgroundOrigin PropertyName = "background-origin"
// MaskClip is the constant for "mask-clip" property tag.
//
- // Used by `View`.
+ // Used by View.
// Determines how image/gradient masks will be used below the box borders.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`BorderBox`) or "border-box" - The mask extends to the outer edge of the border.
- // `1`(`PaddingBox`) or "padding-box" - The mask extends to the outer edge of the padding.
- // `2`(`ContentBox`) or "content-box" - The mask is used inside(clipped) of the content box.
+ // - 0 (BorderBox) or "border-box" - The mask extends to the outer edge of the border.
+ // - 1 (PaddingBox) or "padding-box" - The mask extends to the outer edge of the padding.
+ // - 2 (ContentBox) or "content-box" - The mask is used inside(clipped) of the content box.
MaskClip PropertyName = "mask-clip"
// MaskOrigin is the constant for "mask-origin" property tag.
//
- // Used by `View`.
+ // Used by View.
// Determines the mask's origin: from the border start, inside the border, or inside the padding.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`BorderBox`) or "border-box" - The mask is positioned relative to the border box.
- // `1`(`PaddingBox`) or "padding-box" - The mask is positioned relative to the padding box.
- // `2`(`ContentBox`) or "content-box" - The mask is positioned relative to the content box.
+ // - 0 (BorderBox) or "border-box" - The mask is positioned relative to the border box.
+ // - 1 (PaddingBox) or "padding-box" - The mask is positioned relative to the padding box.
+ // - 2 (ContentBox) or "content-box" - The mask is positioned relative to the content box.
MaskOrigin PropertyName = "mask-origin"
// Gradient is the constant for "gradient" property tag.
//
- // Used by `BackgroundElement`.
+ // Used by BackgroundElement.
// Describe gradient stop points. This is a mandatory property while describing background gradients.
//
- // Supported types: `[]BackgroundGradientPoint`, `[]BackgroundGradientAngle`, `[]GradientPoint`, `[]Color`, `string`.
+ // Supported types: []BackgroundGradientPoint, []BackgroundGradientAngle, []GradientPoint, []Color, string.
//
- // Internal type is `[]BackgroundGradientPoint` or `[]BackgroundGradientAngle`, other types converted to it during assignment.
- // See `BackgroundGradientPoint`, `[]BackgroundGradientAngle`, `[]GradientPoint` description for more details.
+ // Internal type is []BackgroundGradientPoint or []BackgroundGradientAngle, other types converted to it during assignment.
+ // See BackgroundGradientPoint, []BackgroundGradientAngle, []GradientPoint description for more details.
//
// Conversion rules:
- // `[]BackgroundGradientPoint` - stored as is, no conversion performed. Used to set gradient stop points for linear and radial gradients.
- // `[]BackgroundGradientAngle` - stored as is, no conversion performed. Used to set gradient stop points for conic gradient.
- // `[]GradientPoint` - converted to `[]BackgroundGradientPoint`. Used to set gradient stop points for linear and radial gradients. Since `GradientPoint` contains values from `0` to `1.0` they will be converted to precent values.
- // `[]Color` - converted to `[]BackgroundGradientPoint`. Used for setting gradient stop points which are uniformly distributed across gradient diretion.
- // `string` - string representation of stop points or color values. Format: "color1 pos1,color2 pos2"... . Position of stop points can be described either in `SizeUnit` or `AngleUnit` string representations. Examples: "white 0deg, black 90deg, gray 360deg", "white 0%, black 100%".
+ // - []BackgroundGradientPoint - stored as is, no conversion performed. Used to set gradient stop points for linear and radial gradients.
+ // - []BackgroundGradientAngle - stored as is, no conversion performed. Used to set gradient stop points for conic gradient.
+ // - []GradientPoint - converted to []BackgroundGradientPoint. Used to set gradient stop points for linear and radial gradients. Since GradientPoint contains values from 0 to 1.0 they will be converted to precent values.
+ // - []Color - converted to []BackgroundGradientPoint. Used for setting gradient stop points which are uniformly distributed across gradient diretion.
+ // - string - string representation of stop points or color values. Format: "color1 pos1,color2 pos2"... . Position of stop points can be described either in SizeUnit or AngleUnit string representations. Examples: "white 0deg, black 90deg, gray 360deg", "white 0%, black 100%".
Gradient PropertyName = "gradient"
// Direction is the constant for "direction" property tag.
//
- // Used by `BackgroundElement`.
- // Used for linear gradient only. Defines the direction of the gradient line. Default is `4`(`ToBottomGradient`) or
+ // Used by BackgroundElement.
+ // Used for linear gradient only. Defines the direction of the gradient line. Default is 4 (ToBottomGradient) or
// "to-bottom".
//
- // Supported types: `AngleUnit`, `int`, `string`.
+ // Supported types: AngleUnit, int, string.
//
- // See `AngleUnit` description for more details.
+ // See AngleUnit description for more details.
//
// Values:
- // `0`(`ToTopGradient`) or "to-top" - Line goes from bottom to top.
- // `1`(`ToRightTopGradient`) or "to-right-top" - From bottom left to top right.
- // `2`(`ToRightGradient`) or "to-right" - From left to right.
- // `3`(`ToRightBottomGradient`) or "to-right-bottom" - From top left to bottom right.
- // `4`(`ToBottomGradient`) or "to-bottom" - From top to bottom.
- // `5`(`ToLeftBottomGradient`) or "to-left-bottom" - From the upper right corner to the lower left.
- // `6`(`ToLeftGradient`) or "to-left" - From right to left.
- // `7`(`ToLeftTopGradient`) or "to-left-top" - From the bottom right corner to the top left.
+ // - 0 (ToTopGradient) or "to-top" - Line goes from bottom to top.
+ // - 1 (ToRightTopGradient) or "to-right-top" - From bottom left to top right.
+ // - 2 (ToRightGradient) or "to-right" - From left to right.
+ // - 3 (ToRightBottomGradient) or "to-right-bottom" - From top left to bottom right.
+ // - 4 (ToBottomGradient) or "to-bottom" - From top to bottom.
+ // - 5 (ToLeftBottomGradient) or "to-left-bottom" - From the upper right corner to the lower left.
+ // - 6 (ToLeftGradient) or "to-left" - From right to left.
+ // - 7 (ToLeftTopGradient) or "to-left-top" - From the bottom right corner to the top left.
Direction PropertyName = "direction"
// Repeating is the constant for "repeating" property tag.
//
- // Used by `BackgroundElement`.
+ // Used by BackgroundElement.
// Define whether stop points needs to be repeated after the last one.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - Gradient will repeat after the last key point.
- // `false` or `0` or "false", "no", "off", "0" - No repetition of gradient stop points. Value of the last point used will be extrapolated.
+ // - true, 1, "true", "yes", "on", or "1" - Gradient will repeat after the last key point.
+ // - false, 0, "false", "no", "off", or "0" - No repetition of gradient stop points. Value of the last point used will be extrapolated.
Repeating PropertyName = "repeating"
// From is the constant for "from" property tag.
//
- // Used by `BackgroundElement`.
+ // Used by BackgroundElement.
// Used for conic gradient only. Start angle position of the gradient.
//
- // Supported types: `AngleUnit`, `string`, `float`, `int`.
+ // Supported types: AngleUnit, string, float, int.
//
- // Internal type is `AngleUnit`, other types converted to it during assignment.
- // See `AngleUnit` description for more details.
+ // Internal type is AngleUnit, other types converted to it during assignment.
+ // See AngleUnit description for more details.
From PropertyName = "from"
// RadialGradientRadius is the constant for "radial-gradient-radius" property tag.
//
- // Used by `BackgroundElement`.
+ // Used by BackgroundElement.
// Define radius of the radial gradient.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
RadialGradientRadius PropertyName = "radial-gradient-radius"
// RadialGradientShape is the constant for "radial-gradient-shape" property tag.
//
- // Used by `BackgroundElement`.
- // Define shape of the radial gradient. The default is `0`(`EllipseGradient` or "ellipse".
+ // Used by BackgroundElement.
+ // Define shape of the radial gradient. The default is 0 (EllipseGradient or "ellipse".
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`EllipseGradient`) or "ellipse" - The shape is an axis-aligned ellipse.
- // `1`(`CircleGradient`) or "circle" - The shape is a circle with a constant radius.
+ // - EllipseGradient (0) or "ellipse" - The shape is an axis-aligned ellipse.
+ // - CircleGradient (1) or "circle" - The shape is a circle with a constant radius.
RadialGradientShape PropertyName = "radial-gradient-shape"
// Shape is the constant for "shape" property tag.
//
- // Used by `BackgroundElement`.
+ // Used by BackgroundElement.
// Same as "radial-gradient-shape".
Shape PropertyName = "shape"
// CenterX is the constant for "center-x" property tag.
//
- // Used by `BackgroundElement`.
+ // Used by BackgroundElement.
// Used for conic and radial gradients only. Center X point of the gradient.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
CenterX PropertyName = "center-x"
// CenterY is the constant for "center-y" property tag.
//
- // Used by `BackgroundElement`.
+ // Used by BackgroundElement.
// Used for conic and radial gradients only. Center Y point of the gradient.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
CenterY PropertyName = "center-y"
// AltText is the constant for "alt-text" property tag.
//
- // Used by `ImageView`.
+ // Used by ImageView.
// Set a description of the image.
//
- // Supported types: `string`.
+ // Supported types: string.
AltText PropertyName = "alt-text"
altTag PropertyName = "alt"
// AvoidBreak is the constant for "avoid-break" property tag.
//
- // Used by `ColumnLayout`.
+ // Used by ColumnLayout.
// Controls how region breaks should behave inside a generated box.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - Avoid any break from being inserted within the principal box.
- // `false` or `0` or "false", "no", "off", "0" - Allow, but does not force, any break to be inserted within the principal box.
+ // - true, 1, "true", "yes", "on", or "1" - Avoid any break from being inserted within the principal box.
+ // - false, 0, "false", "no", "off", or "0" - Allow, but does not force, any break to be inserted within the principal box.
AvoidBreak PropertyName = "avoid-break"
// ItemWidth is the constant for "item-width" property tag.
//
- // Used by `ListView`.
+ // Used by ListView.
// Fixed width of list elements.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
ItemWidth PropertyName = "item-width"
// ItemHeight is the constant for "item-height" property tag.
//
- // Used by `ListView`.
+ // Used by ListView.
// Fixed height of list elements.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
ItemHeight PropertyName = "item-height"
// ListWrap is the constant for "list-wrap" property tag.
//
- // Used by `ListLayout`, `ListView`.
+ // Used by ListLayout, ListView.
//
- // Usage in `ListLayout`:
+ // Usage in ListLayout:
// Defines the position of elements in case of reaching the border of the container.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`ListWrapOff`) or "off" - The column or row of elements continues and goes beyond the bounds of the visible area.
- // `1`(`ListWrapOn`) or "on" - Starts a new column or row of elements as necessary. The new column is positioned towards the end.
- // `2`(`ListWrapReverse`) or "reverse" - Starts a new column or row of elements as necessary. The new column is positioned towards the beginning.
+ // - 0 (ListWrapOff) or "off" - The column or row of elements continues and goes beyond the bounds of the visible area.
+ // - 1 (ListWrapOn) or "on" - Starts a new column or row of elements as necessary. The new column is positioned towards the end.
+ // - 2 (ListWrapReverse) or "reverse" - Starts a new column or row of elements as necessary. The new column is positioned towards the beginning.
//
- // Usage in `ListView`:
+ // Usage in ListView:
// Defines the position of elements in case of reaching the border of the container.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`ListWrapOff`) or "off" - The column or row of elements continues and goes beyond the bounds of the visible area.
- // `1`(`ListWrapOn`) or "on" - Starts a new column or row of elements as necessary. The new column is positioned towards the end.
- // `2`(`ListWrapReverse`) or "reverse" - Starts a new column or row of elements as necessary. The new column is positioned towards the beginning.
+ // - 0 (ListWrapOff) or "off" - The column or row of elements continues and goes beyond the bounds of the visible area.
+ // - 1 (ListWrapOn) or "on" - Starts a new column or row of elements as necessary. The new column is positioned towards the end.
+ // - 2 (ListWrapReverse) or "reverse" - Starts a new column or row of elements as necessary. The new column is positioned towards the beginning.
ListWrap PropertyName = "list-wrap"
// EditWrap is the constant for "edit-wrap" property tag.
//
- // Used by `EditView`.
- // Controls whether the text will wrap around when edit view border has been reached. Default value is `false`.
+ // Used by EditView.
+ // Controls whether the text will wrap around when edit view border has been reached. Default value is false.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - Text wrapped to the next line.
- // `false` or `0` or "false", "no", "off", "0" - Do not wrap text. Horizontal scrolling will appear if necessary.
+ // - true, 1, "true", "yes", "on", or "1" - Text wrapped to the next line.
+ // - false, 0, "false", "no", "off", or "0" - Do not wrap text. Horizontal scrolling will appear if necessary.
EditWrap PropertyName = "edit-wrap"
// CaretColor is the constant for "caret-color" property tag.
//
- // Used by `EditView`, `View`.
+ // Used by EditView.
//
- // Usage in `EditView`:
// Sets the color of the insertion caret, the visible marker where the next character typed will be inserted. This is
// sometimes referred to as the text input cursor.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
- //
- // Usage in `View`:
- // Sets the color of the insertion caret, the visible marker where the next character typed will be inserted. This is
- // sometimes referred to as the text input cursor.
- //
- // Supported types: `Color`, `string`.
- //
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See [Color] description for more details.
CaretColor PropertyName = "caret-color"
// Min is the constant for "min" property tag.
//
- // Used by `DatePicker`, `NumberPicker`, `TimePicker`.
+ // Used by DatePicker, NumberPicker, TimePicker.
//
- // Usage in `DatePicker`:
- // Same as "date-picker-min".
+ // Usage in DatePicker:
+ // Same as "date-picker-min" [DatePickerMin].
//
- // Usage in `NumberPicker`:
- // Same as "number-picker-min".
+ // Usage in NumberPicker:
+ // Same as "number-picker-min" [NumberPickerMin].
//
- // Usage in `TimePicker`:
- // Same as "time-picker-min".
+ // Usage in TimePicker:
+ // Same as "time-picker-min" [TimePickerMin].
Min PropertyName = "min"
// Max is the constant for "max" property tag.
//
- // Used by `DatePicker`, `NumberPicker`, `ProgressBar`, `TimePicker`.
+ // Used by DatePicker, NumberPicker, ProgressBar, TimePicker.
//
- // Usage in `DatePicker`:
- // Same as "date-picker-max".
+ // Usage in DatePicker:
+ // Same as "date-picker-max" [DatePickerMax].
//
- // Usage in `NumberPicker`:
- // Same as "number-picker-max".
+ // Usage in NumberPicker:
+ // Same as "number-picker-max" [NumberPickerMax].
//
- // Usage in `ProgressBar`:
- // Same as "progress-max".
+ // Usage in ProgressBar:
+ // Same as "progress-max" [ProgressBarMax].
//
- // Usage in `TimePicker`:
- // Same as "time-picker-max".
+ // Usage in TimePicker:
+ // Same as "time-picker-max" [TimePickerMax].
Max PropertyName = "max"
// Step is the constant for "step" property tag.
//
- // Used by `DatePicker`, `NumberPicker`, `TimePicker`.
+ // Used by DatePicker, NumberPicker, TimePicker.
//
- // Usage in `DatePicker`:
- // Same as "date-picker-step".
+ // Usage in DatePicker:
+ // Same as "date-picker-step" [DatePickerStep].
//
- // Usage in `NumberPicker`:
- // Same as "number-picker-step".
+ // Usage in NumberPicker:
+ // Same as "number-picker-step" [NumberPickerStep].
//
- // Usage in `TimePicker`:
- // Same as "time-picker-step".
+ // Usage in TimePicker:
+ // Same as "time-picker-step" [TimePickerStep].
Step PropertyName = "step"
// Value is the constant for "value" property tag.
//
- // Used by `DatePicker`, `NumberPicker`, `ProgressBar`, `TimePicker`.
+ // Used by DatePicker, NumberPicker, ProgressBar, TimePicker.
//
- // Usage in `DatePicker`:
- // Same as "date-picker-value".
+ // Usage in DatePicker:
+ // Same as "date-picker-value" [DatePickerValue].
//
- // Usage in `NumberPicker`:
- // Same as "number-picker-value".
+ // Usage in NumberPicker:
+ // Same as "number-picker-value" [NumberPickerValue].
//
- // Usage in `ProgressBar`:
- // Same as "progress-value".
+ // Usage in ProgressBar:
+ // Same as "progress-value" [ProgressBarValue].
//
- // Usage in `TimePicker`:
- // Same as "time-picker-value".
+ // Usage in TimePicker:
+ // Same as "time-picker-value" [TimePickerValue].
Value PropertyName = "value"
// Orientation is the constant for "orientation" property tag.
//
- // Used by `ListLayout`, `ListView`, `View`.
+ // Used by ListLayout, ListView.
//
- // Usage in `ListLayout`:
// Specifies how the children will be positioned relative to each other.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`TopDownOrientation`) or "up-down" - Child elements are arranged in a column from top to bottom.
- // `1`(`StartToEndOrientation`) or "start-to-end" - Child elements are laid out in a row from beginning to end.
- // `2`(`BottomUpOrientation`) or "bottom-up" - Child elements are arranged in a column from bottom to top.
- // `3`(`EndToStartOrientation`) or "end-to-start" - Child elements are laid out in a line from end to beginning.
- //
- // Usage in `ListView`:
- // Specifies how the children will be positioned relative to each other.
- //
- // Supported types: `int`, `string`.
- //
- // Values:
- // `0`(`TopDownOrientation`) or "up-down" - Child elements are arranged in a column from top to bottom.
- // `1`(`StartToEndOrientation`) or "start-to-end" - Child elements are laid out in a row from beginning to end.
- // `2`(`BottomUpOrientation`) or "bottom-up" - Child elements are arranged in a column from bottom to top.
- // `3`(`EndToStartOrientation`) or "end-to-start" - Child elements are laid out in a line from end to beginning.
- //
- // Usage in `View`:
- // Specify layout of the children or view.
- //
- // Supported types: `int`, `string`.
- //
- // Values:
- // `0`(`TopDownOrientation`) or "up-down" - Child elements are arranged in a column from top to bottom.
- // `1`(`StartToEndOrientation`) or "start-to-end" - Child elements are laid out in a row from beginning to end.
- // `2`(`BottomUpOrientation`) or "bottom-up" - Child elements are arranged in a column from bottom to top.
- // `3`(`EndToStartOrientation`) or "end-to-start" - Child elements are laid out in a line from end to beginning.
+ // - 0 (TopDownOrientation) or "up-down" - Child elements are arranged in a column from top to bottom.
+ // - 1 (StartToEndOrientation) or "start-to-end" - Child elements are laid out in a row from beginning to end.
+ // - 2 (BottomUpOrientation) or "bottom-up" - Child elements are arranged in a column from bottom to top.
+ // - 3 (EndToStartOrientation) or "end-to-start" - Child elements are laid out in a line from end to beginning.
Orientation PropertyName = "orientation"
// Gap is the constant for "gap" property tag.
//
- // Used by `GridLayout`, `ListLayout`, `ListView`, `TableView`.
+ // Used by GridLayout, ListLayout, ListView, TableView.
+ //
+ // # Usage in GridLayout
//
- // Usage in `GridLayout`:
// Specify both "grid-column-gap" and "grid-row-gap".
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
+ //
+ // # Usage in ListLayout and ListView
//
- // Usage in `ListLayout`:
// Specify both "list-column-gap" and "list-row-gap".
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
//
- // Usage in `ListView`:
- // Specify both "list-column-gap" and "list-row-gap".
+ // # Usage in TableView
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
- //
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
- //
- // Usage in `TableView`:
// Define the gap between rows and columns of a table.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
Gap PropertyName = "gap"
// ListRowGap is the constant for "list-row-gap" property tag.
//
- // Used by `ListLayout`, `ListView`.
+ // Used by ListLayout, ListView.
//
- // Usage in `ListLayout`:
- // Set the distance between the rows of the `ListLayout`. Default value 0px.
+ // Set the distance between the rows of the ListLayout. Default value 0px.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
- //
- // Usage in `ListView`:
- // Set the distance between the rows of the `ListLayout`. Default value 0px.
- //
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
- //
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
ListRowGap PropertyName = "list-row-gap"
// ListColumnGap is the constant for "list-column-gap" property tag.
//
- // Used by `ListLayout`, `ListView`.
+ // Used by ListLayout, ListView.
//
- // Usage in `ListLayout`:
- // Set the distance between the columns of the `ListLayout`. Default value 0px.
+ // Set the distance between the columns of the ListLayout. Default value 0px.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
- //
- // Usage in `ListView`:
- // Set the distance between the columns of the `ListLayout`. Default value 0px.
- //
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
- //
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See [SizeUnit] description for more details.
ListColumnGap PropertyName = "list-column-gap"
// Text is the constant for "text" property tag.
//
- // Used by `EditView`, `TextView`.
+ // Used by EditView, TextView.
//
- // Usage in `EditView`:
+ // Usage in EditView:
// Edit view text.
//
- // Supported types: `string`.
+ // Supported types: string.
//
- // Usage in `TextView`:
+ // Usage in TextView:
// Text to display.
//
- // Supported types: `string`.
+ // Supported types: string.
Text PropertyName = "text"
// VerticalAlign is the constant for "vertical-align" property tag.
//
- // Used by `Checkbox`, `ListLayout`, `ListView`, `Popup`, `SvgImageView`.
+ // Used by Checkbox, ListLayout, ListView, Popup, SvgImageView.
+ //
+ // # Usage in Checkbox
//
- // Usage in `Checkbox`:
// Sets the vertical alignment of the content inside a block element.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`TopAlign`) or "top" - Content aligned to top side of the content area.
- // `1`(`BottomAlign`) or "bottom" - Content aligned to bottom side of the content area.
- // `2`(`CenterAlign`) or "center" - Content aligned in the center of the content area.
- // `3`(`StretchAlign`) or "stretch" - Content relaxed to fill all content area.
+ // - 0 (TopAlign) or "top" - Content aligned to top side of the content area.
+ // - 1 (BottomAlign) or "bottom" - Content aligned to bottom side of the content area.
+ // - 2 (CenterAlign) or "center" - Content aligned in the center of the content area.
+ // - 3 (StretchAlign) or "stretch" - Content relaxed to fill all content area.
+ //
+ // # Usage in ListLayout and ListView
//
- // Usage in `ListLayout`:
// Sets the vertical alignment of the content inside a block element.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`TopAlign`) or "top" - Top alignment.
- // `1`(`BottomAlign`) or "bottom" - Bottom alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
- // `3`(`StretchAlign`) or "stretch" - Height alignment.
+ // - 0 (TopAlign) or "top" - Top alignment.
+ // - 1 (BottomAlign) or "bottom" - Bottom alignment.
+ // - 2 (CenterAlign) or "center" - Center alignment.
+ // - 3 (StretchAlign) or "stretch" - Height alignment.
//
- // Usage in `ListView`:
- // Sets the vertical alignment of the content inside a block element.
+ // # Usage in Popup
//
- // Supported types: `int`, `string`.
- //
- // Values:
- // `0`(`TopAlign`) or "top" - Top alignment.
- // `1`(`BottomAlign`) or "bottom" - Bottom alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
- // `3`(`StretchAlign`) or "stretch" - Height alignment.
- //
- // Usage in `Popup`:
// Vertical alignment of the popup on the screen.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`TopAlign`) or "top" - Top alignment.
- // `1`(`BottomAlign`) or "bottom" - Bottom alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
- // `3`(`StretchAlign`) or "stretch" - Height alignment.
+ // - 0 (TopAlign) or "top" - Top alignment.
+ // - 1 (BottomAlign) or "bottom" - Bottom alignment.
+ // - 2 (CenterAlign) or "center" - Center alignment.
+ // - 3 (StretchAlign) or "stretch" - Height alignment.
+ //
+ // # Usage in SvgImageView
//
- // Usage in `SvgImageView`:
// Sets the vertical alignment of the image relative to its bounds.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`TopAlign`) or "top" - Top alignment.
- // `1`(`BottomAlign`) or "bottom" - Bottom alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
+ // - 0 (TopAlign) or "top" - Top alignment.
+ // - 1 (BottomAlign) or "bottom" - Bottom alignment.
+ // - 2 (CenterAlign) or "center" - Center alignment.
VerticalAlign PropertyName = "vertical-align"
// HorizontalAlign is the constant for "horizontal-align" property tag.
//
- // Used by `Checkbox`, `ListLayout`, `ListView`, `Popup`, `SvgImageView`.
+ // Used by Checkbox, ListLayout, ListView, Popup, SvgImageView.
+ //
+ // # Usage in Checkbox
//
- // Usage in `Checkbox`:
// Sets the horizontal alignment of the content inside a block element.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`LeftAlign`) or "left" - Content aligned to left side of the content area.
- // `1`(`RightAlign`) or "right" - Content aligned to right side of the content area.
- // `2`(`CenterAlign`) or "center" - Content aligned in the center of the content area.
- // `3`(`StretchAlign`) or "stretch" - Content relaxed to fill all content area.
+ // - 0 (LeftAlign) or "left" - Content aligned to left side of the content area.
+ // - 1 (RightAlign) or "right" - Content aligned to right side of the content area.
+ // - 2 (CenterAlign) or "center" - Content aligned in the center of the content area.
+ // - 3 (StretchAlign) or "stretch" - Content relaxed to fill all content area.
+ //
+ // # Usage in ListLayout and ListView
//
- // Usage in `ListLayout`:
// Sets the horizontal alignment of the content inside a block element.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`LeftAlign`) or "left" - Left alignment.
- // `1`(`RightAlign`) or "right" - Right alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
- // `3`(`StretchAlign`) or "stretch" - Width alignment.
+ // - 0 (LeftAlign) or "left" - Left alignment.
+ // - 1 (RightAlign) or "right" - Right alignment.
+ // - 2 (CenterAlign) or "center" - Center alignment.
+ // - 3 (StretchAlign) or "stretch" - Width alignment.
//
- // Usage in `ListView`:
- // Sets the horizontal alignment of the content inside a block element.
+ // # Usage in Popup
//
- // Supported types: `int`, `string`.
- //
- // Values:
- // `0`(`LeftAlign`) or "left" - Left alignment.
- // `1`(`RightAlign`) or "right" - Right alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
- // `3`(`StretchAlign`) or "stretch" - Width alignment.
- //
- // Usage in `Popup`:
// Horizontal alignment of the popup on the screen.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`LeftAlign`) or "left" - Left alignment.
- // `1`(`RightAlign`) or "right" - Right alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
- // `3`(`StretchAlign`) or "stretch" - Width alignment.
+ // - 0 (LeftAlign) or "left" - Left alignment.
+ // - 1 (RightAlign) or "right" - Right alignment.
+ // - 2 (CenterAlign) or "center" - Center alignment.
+ // - 3 (StretchAlign) or "stretch" - Width alignment.
+ //
+ // # Usage in SvgImageView
//
- // Usage in `SvgImageView`:
// Sets the horizontal alignment of the image relative to its bounds.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`LeftAlign`) or "left" - Left alignment.
- // `1`(`RightAlign`) or "right" - Right alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
+ // - 0 (LeftAlign) or "left" - Left alignment.
+ // - 1 (RightAlign) or "right" - Right alignment.
+ // - 2 (CenterAlign) or "center" - Center alignment.
HorizontalAlign PropertyName = "horizontal-align"
// ImageVerticalAlign is the constant for "image-vertical-align" property tag.
//
- // Used by `ImageView`.
+ // Used by ImageView.
// Sets the vertical alignment of the image relative to its bounds.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`TopAlign`) or "top" - Top alignment.
- // `1`(`BottomAlign`) or "bottom" - Bottom alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
+ // - 0 (TopAlign) or "top" - Top alignment.
+ // - 1 (BottomAlign) or "bottom" - Bottom alignment.
+ // - 2 (CenterAlign) or "center" - Center alignment.
ImageVerticalAlign PropertyName = "image-vertical-align"
// ImageHorizontalAlign is the constant for "image-horizontal-align" property tag.
//
- // Used by `ImageView`.
+ // Used by ImageView.
// Sets the horizontal alignment of the image relative to its bounds.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`LeftAlign`) or "left" - Left alignment.
- // `1`(`RightAlign`) or "right" - Right alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
+ // - 0 (LeftAlign) or "left" - Left alignment.
+ // - 1 (RightAlign) or "right" - Right alignment.
+ // - 2 (CenterAlign) or "center" - Center alignment.
ImageHorizontalAlign PropertyName = "image-horizontal-align"
// Checked is the constant for "checked" property tag.
//
- // Used by `Checkbox`, `ListView`.
+ // Used by Checkbox, ListView.
+ //
+ // # Usage in Checkbox
//
- // Usage in `Checkbox`:
// Current state of the checkbox.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - Checkbox is checked.
- // `false` or `0` or "false", "no", "off", "0" - Checkbox is unchecked.
+ // - true, 1, "true", "yes", "on", or "1" - Checkbox is checked.
+ // - false, 0, "false", "no", "off", or "0" - Checkbox is unchecked.
+ //
+ // # Usage in ListView
//
- // Usage in `ListView`:
// Set or get the list of checked items. Stores array of indices of checked items.
//
- // Supported types: `[]int`, `int`, `string`.
+ // Supported types: []int, int, string.
//
- // Internal type is `[]int`, other types converted to it during assignment.
+ // Internal type is []int, other types converted to it during assignment.
//
// Conversion rules:
- // `[]int` - contains indices of selected list items. Stored as is.
- // `int` - contains index of one selected list item, converted to `[]int`.
- // `string` - contains one or several indices of selected list items separated by comma(`,`).
+ // - []int - contains indices of selected list items. Stored as is.
+ // - int - contains index of one selected list item, converted to []int.
+ // - string - contains one or several indices of selected list items separated by comma(,).
Checked PropertyName = "checked"
// ItemVerticalAlign is the constant for "item-vertical-align" property tag.
//
- // Used by `ListView`.
+ // Used by ListView.
// Sets the vertical alignment of the contents of the list items.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`TopAlign`) or "top" - Top alignment.
- // `1`(`BottomAlign`) or "bottom" - Bottom alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
- // `3`(`StretchAlign`) or "stretch" - Height alignment.
+ // - 0 (TopAlign) or "top" - Top alignment.
+ // - 1 (BottomAlign) or "bottom" - Bottom alignment.
+ // - 2 (CenterAlign) or "center" - Center alignment.
+ // - 3 (StretchAlign) or "stretch" - Height alignment.
ItemVerticalAlign PropertyName = "item-vertical-align"
// ItemHorizontalAlign is the constant for "item-horizontal-align" property tag.
//
- // Used by `ListView`.
+ // Used by ListView.
// Sets the horizontal alignment of the contents of the list items.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`LeftAlign`) or "left" - Left alignment.
- // `1`(`RightAlign`) or "right" - Right alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
- // `3`(`StretchAlign`) or "stretch" - Height alignment.
+ // - 0 (LeftAlign) or "left" - Left alignment.
+ // - 1 (RightAlign) or "right" - Right alignment.
+ // - 2 (CenterAlign) or "center" - Center alignment.
+ // - 3 (StretchAlign) or "stretch" - Height alignment.
ItemHorizontalAlign PropertyName = "item-horizontal-align"
// ItemCheckbox is the constant for "checkbox" property tag.
//
- // Used by `ListView`.
+ // Used by ListView.
// Style of checkbox used to mark items in a list. Default value is "none".
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneCheckbox`) or "none" - There is no checkbox.
- // `1`(`SingleCheckbox`) or "single" - A checkbox that allows you to mark only one item, example: ◉.
- // `2`(`MultipleCheckbox`) or "multiple" - A checkbox that allows you to mark several items, example: ☑.
+ // - 0 (NoneCheckbox) or "none" - There is no checkbox.
+ // - 1 (SingleCheckbox) or "single" - A checkbox that allows you to mark only one item, example: ◉.
+ // - 2 (MultipleCheckbox) or "multiple" - A checkbox that allows you to mark several items, example: ☑.
ItemCheckbox PropertyName = "checkbox"
// CheckboxHorizontalAlign is the constant for "checkbox-horizontal-align" property tag.
//
- // Used by `Checkbox`, `ListView`.
+ // Used by Checkbox, ListView.
+ //
+ // # Usage in Checkbox
//
- // Usage in `Checkbox`:
// Horizontal alignment of checkbox inside the checkbox container.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`LeftAlign`) or "left" - Checkbox on the left edge, content on the right.
- // `1`(`RightAlign`) or "right" - Checkbox on the right edge, content on the left.
- // `2`(`CenterAlign`) or "center" - Center horizontally. Content below or above.
+ // - 0 (LeftAlign) or "left" - Checkbox on the left edge, content on the right.
+ // - 1 (RightAlign) or "right" - Checkbox on the right edge, content on the left.
+ // - 2 (CenterAlign) or "center" - Center horizontally. Content below or above.
+ //
+ // # Usage in ListView
//
- // Usage in `ListView`:
// Checkbox horizontal alignment(if enabled by "checkbox" property).
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`LeftAlign`) or "left" - Checkbox on the left edge, content on the right.
- // `1`(`RightAlign`) or "right" - Checkbox on the right edge, content on the left.
- // `2`(`CenterAlign`) or "center" - Center horizontally. Content below or above.
+ // - 0 (LeftAlign) or "left" - Checkbox on the left edge, content on the right.
+ // - 1 (RightAlign) or "right" - Checkbox on the right edge, content on the left.
+ // - 2 (CenterAlign) or "center" - Center horizontally. Content below or above.
CheckboxHorizontalAlign PropertyName = "checkbox-horizontal-align"
// CheckboxVerticalAlign is the constant for "checkbox-vertical-align" property tag.
//
- // Used by `Checkbox`, `ListView`.
+ // Used by Checkbox, ListView.
+ //
+ // # Usage in Checkbox
//
- // Usage in `Checkbox`:
// Vertical alignment of checkbox inside the checkbox container.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`TopAlign`) or "top" - Checkbox on the top, content on the bottom.
- // `1`(`BottomAlign`) or "bottom" - Checkbox on the bottom, content on the top.
- // `2`(`CenterAlign`) or "center" - Checkbox on the top, content on the bottom.
+ // - 0 (TopAlign) or "top" - Checkbox on the top, content on the bottom.
+ // - 1 (BottomAlign) or "bottom" - Checkbox on the bottom, content on the top.
+ // - 2 (CenterAlign) or "center" - Checkbox on the top, content on the bottom.
+ //
+ // # Usage in ListView
//
- // Usage in `ListView`:
// Checkbox vertical alignment(if enabled by "checkbox" property).
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`TopAlign`) or "top" - Top alignment.
- // `1`(`BottomAlign`) or "bottom" - Bottom alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
+ // - 0 (TopAlign) or "top" - Top alignment.
+ // - 1 (BottomAlign) or "bottom" - Bottom alignment.
+ // - 2 (CenterAlign) or "center" - Center alignment.
CheckboxVerticalAlign PropertyName = "checkbox-vertical-align"
// NotTranslate is the constant for "not-translate" property tag.
//
- // Used by `DetailsView`, `TextView`, `View`.
+ // Used by TextView, View.
//
- // Usage in `DetailsView`:
- // Controls whether the label set for the details view require translation. This is an inherited property, i.e. if it is
- // not defined, then the value of the parent view is used. Default value is `false`.
- //
- // Supported types: `bool`, `int`, `string`.
- //
- // Values:
- // `true` or `1` or "true", "yes", "on", "1" - No need to lookup for label text translation in resources.
- // `false` or `0` or "false", "no", "off", "0" - Lookup for label text translation.
- //
- // Usage in `TextView`:
// Controls whether the text set for the text view require translation. This is an inherited property, i.e. if it is not
- // defined, then the value of the parent view is used. Default value is `false`.
+ // defined, then the value of the parent view is used. Default value is false.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - No need to lookup for text translation in resources.
- // `false` or `0` or "false", "no", "off", "0" - Lookup for text translation.
- //
- // Usage in `View`:
- // Controls whether the text require translation. This is an inherited property, i.e. if it is not defined, then the value
- // of the parent view is used. Default value is `false`.
- //
- // Supported types: `bool`, `int`, `string`.
- //
- // Values:
- // `true` or `1` or "true", "yes", "on", "1" - No need to lookup for text translation in resources.
- // `false` or `0` or "false", "no", "off", "0" - Lookup for text translation.
+ // - true, 1, "true", "yes", "on", or "1" - No need to lookup for text translation in resources.
+ // - false, 0, "false", "no", "off", or "0" - Lookup for text translation.
NotTranslate PropertyName = "not-translate"
// Filter is the constant for "filter" property tag.
//
- // Used by `View`.
+ // Used by View.
// Applies graphical effects to a view, such as blurring, color shifting, changing brightness/contrast, etc.
//
- // Supported types: `ViewFilter`.
+ // Supported types: ViewFilter.
//
- // See `ViewFilter` description for more details.
+ // See ViewFilter description for more details.
Filter PropertyName = "filter"
// BackdropFilter is the constant for "backdrop-filter" property tag.
//
- // Used by `View`.
+ // Used by View.
// Applies graphical effects to the area behind a view, such as blurring, color shifting, changing brightness/contrast,
// etc.
//
- // Supported types: `ViewFilter`.
+ // Supported types: ViewFilter.
//
- // See `ViewFilter` description for more details.
+ // See ViewFilter description for more details.
BackdropFilter PropertyName = "backdrop-filter"
// Clip is the constant for "clip" property tag.
//
- // Used by `View`.
+ // Used by View.
// Creates a clipping region that sets what part of a view should be shown.
//
- // Supported types: `ClipShape`, `string`.
+ // Supported types: ClipShape, string.
//
- // Internal type is `ClipShape`, other types converted to it during assignment.
- // See `ClipShape` description for more details.
+ // Internal type is ClipShape, other types converted to it during assignment.
+ // See ClipShape description for more details.
Clip PropertyName = "clip"
// Points is the constant for "points" property tag.
//
- // Used by `ClipShape`.
+ // Used by ClipShape.
// Points which describe polygon clip area. Values are in a sequence of pair like: x1, y1, x2, y2 ...
//
- // Supported types: `[]SizeUnit`, `string`.
+ // Supported types: []SizeUnit, string.
Points PropertyName = "points"
// ShapeOutside is the constant for "shape-outside" property tag.
//
- // Used by `View`.
+ // Used by View.
// __WARNING__ Currently not supported. Property defines a shape(which may be non-rectangular) around which adjacent
// inline content should wrap. By default, inline content wraps around its margin box. Property provides a way to
// customize this wrapping, making it possible to wrap text around complex objects rather than simple boxes.
//
- // Supported types: `ClipShape`, `string`.
+ // Supported types: ClipShape, string.
//
- // Internal type is `ClipShape`, other types converted to it during assignment.
- // See `ClipShape` description for more details.
+ // Internal type is ClipShape, other types converted to it during assignment.
+ // See ClipShape description for more details.
ShapeOutside PropertyName = "shape-outside"
// Float is the constant for "float" property tag.
//
- // Used by `View`.
+ // Used by View.
// Places a view on the left or right side of its container, allowing text and inline views to wrap around it.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneFloat`) or "none" - Text and other views inside the container will not wrap around this view.
- // `1`(`LeftFloat`) or "left" - Text and other views inside the container will wrap around this view on the right side.
- // `2`(`RightFloat`) or "right" - Text and other views inside the container will wrap around this view on the left side.
+ // - 0 (NoneFloat) or "none" - Text and other views inside the container will not wrap around this view.
+ // - 1 (LeftFloat) or "left" - Text and other views inside the container will wrap around this view on the right side.
+ // - 2 (RightFloat) or "right" - Text and other views inside the container will wrap around this view on the left side.
Float PropertyName = "float"
// UserData is the constant for "user-data" property tag.
//
- // Used by `View`.
+ // Used by View.
// Can contain any user data.
//
- // Supported types: `any`.
+ // Supported types: any.
UserData PropertyName = "user-data"
// Resize is the constant for "resize" property tag.
//
- // Used by `View`.
+ // Used by View.
// Sets whether view is resizable, and if so, in which directions. Default value is "none".
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneResize`) or "none" - View cannot be resized.
- // `1`(`BothResize`) or "both" - The View displays a mechanism for allowing the user to resize it, which may be resized both horizontally and vertically.
- // `2`(`HorizontalResize`) or "horizontal" - The View displays a mechanism for allowing the user to resize it in the horizontal direction.
- // `3`(`VerticalResize`) or "vertical" - The View displays a mechanism for allowing the user to resize it in the vertical direction.
+ // - 0 (NoneResize) or "none" - View cannot be resized.
+ // - 1 (BothResize) or "both" - The View displays a mechanism for allowing the user to resize it, which may be resized both horizontally and vertically.
+ // - 2 (HorizontalResize) or "horizontal" - The View displays a mechanism for allowing the user to resize it in the horizontal direction.
+ // - 3 (VerticalResize) or "vertical" - The View displays a mechanism for allowing the user to resize it in the vertical direction.
Resize PropertyName = "resize"
// UserSelect is the constant for "user-select" property tag.
//
- // Used by `View`.
+ // Used by View.
// Controls whether the user can select the text. This is an inherited property, i.e. if it is not defined, then the value
- // of the parent view is used. Default value is `false`.
+ // of the parent view is used. Default value is false.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - User can select the text.
- // `false` or `0` or "false", "no", "off", "0" - Text is not selectable.
+ // - true, 1, "true", "yes", "on", or "1" - User can select the text.
+ // - false, 0, "false", "no", "off", or "0" - Text is not selectable.
UserSelect PropertyName = "user-select"
// Order is the constant for "Order" property tag.
//
- // Used by `GridLayout`, `ListLayout`, `ListView`, `View`.
+ // Used by View.
//
- // Usage in `GridLayout`:
- // Used in child views to specify visual order of the view inside the `GridLayout`. Items in a container are sorted by
- // ascending order value and then by their addition to the container order.
- //
- // Supported types: `int`, `string`.
- //
- // Values:
- // < `0` or < "0" - Views with lower value will be at the beginning.
- // >PropertyName = `0` or >PropertyName = "0" - Views with higher value will be at the end.
- //
- // Usage in `ListLayout`:
- // Used in child views to specify visual order of the view inside the `ListLayout`. Items in a container are sorted by
- // ascending order value and then by their addition to the container order.
- //
- // Supported types: `int`, `string`.
- //
- // Values:
- // < `0` or < "0" - Views with lower value will be at the beginning.
- // >PropertyName = `0` or >PropertyName = "0" - Views with higher value will be at the end.
- //
- // Usage in `ListView`:
- // Used in child views to specify visual order of the view inside the `ListLayout`. Items in a container are sorted by
- // ascending order value and then by their addition to the container order.
- //
- // Supported types: `int`, `string`.
- //
- // Values:
- // < `0` or < "0" - Views with lower value will be at the beginning.
- // >PropertyName = `0` or >PropertyName = "0" - Views with higher value will be at the end.
- //
- // Usage in `View`:
- // Set the order to layout an item in a `ListLayout` or `GridLayout` container. Items in a container are sorted by
+ // Set the order to layout an item in a ViewsContainer container. Items in a container are sorted by
// ascending order value and then by their addition to container order.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // < `0` or < "0" - Views with lower value will be at the beginning.
- // >PropertyName = `0` or >PropertyName = "0" - Views with higher value will be at the end.
+ // - negative value - Views with lower value will be at the beginning.
+ // - not negative value - Views with higher value will be at the end.
Order PropertyName = "Order"
// BackgroundBlendMode is the constant for "background-blend-mode" property tag.
//
- // Used by `View`.
+ // Used by View.
// Sets how view's background images should blend with each other and with the view's background color.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`BlendNormal`) or "normal" - The final color is the top color, regardless of what the bottom color is. The effect is like two opaque pieces of paper overlapping.
- // `1`(`BlendMultiply`) or "multiply" - The final color is the result of multiplying the top and bottom colors. A black layer leads to a black final layer, and a white layer leads to no change. The effect is like two images printed on transparent film overlapping.
- // `2`(`BlendScreen`) or "screen" - The final color is the result of inverting the colors, multiplying them, and inverting that value. A black layer leads to no change, and a white layer leads to a white final layer. The effect is like two images shone onto a projection screen.
- // `3`(`BlendOverlay`) or "overlay" - The final color is the result of multiply if the bottom color is darker, or screen if the bottom color is lighter. This blend mode is equivalent to hard-light but with the layers swapped.
- // `4`(`BlendDarken`) or "darken" - The final color is composed of the darkest values of each color channel.
- // `5`(`BlendLighten`) or "lighten" - The final color is composed of the lightest values of each color channel.
- // `6`(`BlendColorDodge`) or "color-dodge" - The final color is the result of dividing the bottom color by the inverse of the top color. A black foreground leads to no change. A foreground with the inverse color of the backdrop leads to a fully lit color. This blend mode is similar to screen, but the foreground need only be as light as the inverse of the backdrop to create a fully lit color.
- // `7`(`BlendColorBurn`) or "color-burn" - The final color is the result of inverting the bottom color, dividing the value by the top color, and inverting that value. A white foreground leads to no change. A foreground with the inverse color of the backdrop leads to a black final image. This blend mode is similar to multiply, but the foreground need only be as dark as the inverse of the backdrop to make the final image black.
- // `8`(`BlendHardLight`) or "hard-light" - The final color is the result of multiply if the top color is darker, or screen if the top color is lighter. This blend mode is equivalent to overlay but with the layers swapped. The effect is similar to shining a harsh spotlight on the backdrop.
- // `9`(`BlendSoftLight`) or "soft-light" - The final color is similar to hard-light, but softer. This blend mode behaves similar to hard-light. The effect is similar to shining a diffused spotlight on the backdrop.
- // `10`(`BlendDifference`) or "difference" - The final color is the result of subtracting the darker of the two colors from the lighter one. A black layer has no effect, while a white layer inverts the other layer's color.
- // `11`(`BlendExclusion`) or "exclusion" - The final color is similar to difference, but with less contrast. As with difference, a black layer has no effect, while a white layer inverts the other layer's color.
- // `12`(`BlendHue`) or "hue" - The final color has the hue of the top color, while using the saturation and luminosity of the bottom color.
- // `13`(`BlendSaturation`) or "saturation" - The final color has the saturation of the top color, while using the hue and luminosity of the bottom color. A pure gray backdrop, having no saturation, will have no effect.
- // `14`(`BlendColor`) or "color" - The final color has the hue and saturation of the top color, while using the luminosity of the bottom color. The effect preserves gray levels and can be used to colorize the foreground.
- // `15`(`BlendLuminosity`) or "luminosity" - The final color has the luminosity of the top color, while using the hue and saturation of the bottom color. This blend mode is equivalent to `BlendColor`, but with the layers swapped.
+ // - 0 (BlendNormal) or "normal" - The final color is the top color, regardless of what the bottom color is.
+ // The effect is like two opaque pieces of paper overlapping.
+ // - 1 (BlendMultiply) or "multiply" - The final color is the result of multiplying the top and bottom colors.
+ // A black layer leads to a black final layer, and a white layer leads to no change.
+ // The effect is like two images printed on transparent film overlapping.
+ // - 2 (BlendScreen) or "screen" - The final color is the result of inverting the colors, multiplying them,
+ // and inverting that value. A black layer leads to no change, and a white layer leads to a white final layer.
+ // The effect is like two images shone onto a projection screen.
+ // - 3 (BlendOverlay) or "overlay" - The final color is the result of multiply if the bottom color is darker,
+ // or screen if the bottom color is lighter. This blend mode is equivalent to hard-light but with the layers swapped.
+ // - 4 (BlendDarken) or "darken" - The final color is composed of the darkest values of each color channel.
+ // - 5 (BlendLighten) or "lighten" - The final color is composed of the lightest values of each color channel.
+ // - 6 (BlendColorDodge) or "color-dodge" - The final color is the result of dividing the bottom color by the inverse of the top color.
+ // A black foreground leads to no change. A foreground with the inverse color of the backdrop leads to a fully lit color.
+ // This blend mode is similar to screen, but the foreground need only be as light as the inverse of the backdrop to create a fully lit color.
+ // - 7 (BlendColorBurn) or "color-burn" - The final color is the result of inverting the bottom color, dividing the value by the top color,
+ // and inverting that value. A white foreground leads to no change. A foreground with the inverse color of the backdrop leads to a black final image.
+ // This blend mode is similar to multiply, but the foreground need only be as dark as the inverse of the backdrop to make the final image black.
+ // - 8 (BlendHardLight) or "hard-light" - The final color is the result of multiply if the top color is darker, or screen if the top color is lighter.
+ // This blend mode is equivalent to overlay but with the layers swapped. The effect is similar to shining a harsh spotlight on the backdrop.
+ // - 9 (BlendSoftLight) or "soft-light" - The final color is similar to hard-light, but softer. This blend mode behaves similar to hard-light.
+ // The effect is similar to shining a diffused spotlight on the backdrop.
+ // - 10 (BlendDifference) or "difference" - The final color is the result of subtracting the darker of the two colors from the lighter one.
+ // A black layer has no effect, while a white layer inverts the other layer's color.
+ // - 11 (BlendExclusion) or "exclusion" - The final color is similar to difference, but with less contrast.
+ // As with difference, a black layer has no effect, while a white layer inverts the other layer's color.
+ // - 12 (BlendHue) or "hue" - The final color has the hue of the top color, while using the saturation and luminosity of the bottom color.
+ // - 13 (BlendSaturation) or "saturation" - The final color has the saturation of the top color, while using the hue and luminosity of the bottom color.
+ // A pure gray backdrop, having no saturation, will have no effect.
+ // - 14 (BlendColor) or "color" - The final color has the hue and saturation of the top color, while using the luminosity of the bottom color.
+ // The effect preserves gray levels and can be used to colorize the foreground.
+ // - 15 (BlendLuminosity) or "luminosity" - The final color has the luminosity of the top color, while using the hue and saturation of the bottom color.
+ // This blend mode is equivalent to BlendColor, but with the layers swapped.
BackgroundBlendMode PropertyName = "background-blend-mode"
// MixBlendMode is the constant for "mix-blend-mode" property tag.
//
- // Used by `View`.
+ // Used by View.
// Sets how view's content should blend with the content of the view's parent and the view's background.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`BlendNormal`) or "normal" - The final color is the top color, regardless of what the bottom color is. The effect is like two opaque pieces of paper overlapping.
- // `1`(`BlendMultiply`) or "multiply" - The final color is the result of multiplying the top and bottom colors. A black layer leads to a black final layer, and a white layer leads to no change. The effect is like two images printed on transparent film overlapping.
- // `2`(`BlendScreen`) or "screen" - The final color is the result of inverting the colors, multiplying them, and inverting that value. A black layer leads to no change, and a white layer leads to a white final layer. The effect is like two images shone onto a projection screen.
- // `3`(`BlendOverlay`) or "overlay" - The final color is the result of multiply if the bottom color is darker, or screen if the bottom color is lighter. This blend mode is equivalent to hard-light but with the layers swapped.
- // `4`(`BlendDarken`) or "darken" - The final color is composed of the darkest values of each color channel.
- // `5`(`BlendLighten`) or "lighten" - The final color is composed of the lightest values of each color channel.
- // `6`(`BlendColorDodge`) or "color-dodge" - The final color is the result of dividing the bottom color by the inverse of the top color. A black foreground leads to no change. A foreground with the inverse color of the backdrop leads to a fully lit color. This blend mode is similar to screen, but the foreground need only be as light as the inverse of the backdrop to create a fully lit color.
- // `7`(`BlendColorBurn`) or "color-burn" - The final color is the result of inverting the bottom color, dividing the value by the top color, and inverting that value. A white foreground leads to no change. A foreground with the inverse color of the backdrop leads to a black final image. This blend mode is similar to multiply, but the foreground need only be as dark as the inverse of the backdrop to make the final image black.
- // `8`(`BlendHardLight`) or "hard-light" - The final color is the result of multiply if the top color is darker, or screen if the top color is lighter. This blend mode is equivalent to overlay but with the layers swapped. The effect is similar to shining a harsh spotlight on the backdrop.
- // `9`(`BlendSoftLight`) or "soft-light" - The final color is similar to hard-light, but softer. This blend mode behaves similar to hard-light. The effect is similar to shining a diffused spotlight on the backdrop.
- // `10`(`BlendDifference`) or "difference" - The final color is the result of subtracting the darker of the two colors from the lighter one. A black layer has no effect, while a white layer inverts the other layer's color.
- // `11`(`BlendExclusion`) or "exclusion" - The final color is similar to difference, but with less contrast. As with difference, a black layer has no effect, while a white layer inverts the other layer's color.
- // `12`(`BlendHue`) or "hue" - The final color has the hue of the top color, while using the saturation and luminosity of the bottom color.
- // `13`(`BlendSaturation`) or "saturation" - The final color has the saturation of the top color, while using the hue and luminosity of the bottom color. A pure gray backdrop, having no saturation, will have no effect.
- // `14`(`BlendColor`) or "color" - The final color has the hue and saturation of the top color, while using the luminosity of the bottom color. The effect preserves gray levels and can be used to colorize the foreground.
- // `15`(`BlendLuminosity`) or "luminosity" - The final color has the luminosity of the top color, while using the hue and saturation of the bottom color. This blend mode is equivalent to `BlendColor`, but with the layers swapped.
+ // - 0 (BlendNormal) or "normal" - The final color is the top color, regardless of what the bottom color is.
+ // The effect is like two opaque pieces of paper overlapping.
+ // - 1 (BlendMultiply) or "multiply" - The final color is the result of multiplying the top and bottom colors.
+ // A black layer leads to a black final layer, and a white layer leads to no change.
+ // The effect is like two images printed on transparent film overlapping.
+ // - 2 (BlendScreen) or "screen" - The final color is the result of inverting the colors, multiplying them,
+ // and inverting that value. A black layer leads to no change, and a white layer leads to a white final layer.
+ // The effect is like two images shone onto a projection screen.
+ // - 3 (BlendOverlay) or "overlay" - The final color is the result of multiply if the bottom color is darker,
+ // or screen if the bottom color is lighter. This blend mode is equivalent to hard-light but with the layers swapped.
+ // - 4 (BlendDarken) or "darken" - The final color is composed of the darkest values of each color channel.
+ // - 5 (BlendLighten) or "lighten" - The final color is composed of the lightest values of each color channel.
+ // - 6 (BlendColorDodge) or "color-dodge" - The final color is the result of dividing the bottom color by the inverse of the top color.
+ // A black foreground leads to no change. A foreground with the inverse color of the backdrop leads to a fully lit color.
+ // This blend mode is similar to screen, but the foreground need only be as light as the inverse of the backdrop to create a fully lit color.
+ // - 7 (BlendColorBurn) or "color-burn" - The final color is the result of inverting the bottom color, dividing the value by the top color,
+ // and inverting that value. A white foreground leads to no change. A foreground with the inverse color of the backdrop leads to a black final image.
+ // This blend mode is similar to multiply, but the foreground need only be as dark as the inverse of the backdrop to make the final image black.
+ // - 8 (BlendHardLight) or "hard-light" - The final color is the result of multiply if the top color is darker, or screen if the top color is lighter.
+ // This blend mode is equivalent to overlay but with the layers swapped. The effect is similar to shining a harsh spotlight on the backdrop.
+ // - 9 (BlendSoftLight) or "soft-light" - The final color is similar to hard-light, but softer. This blend mode behaves similar to hard-light.
+ // The effect is similar to shining a diffused spotlight on the backdrop.
+ // - 10 (BlendDifference) or "difference" - The final color is the result of subtracting the darker of the two colors from the lighter one.
+ // A black layer has no effect, while a white layer inverts the other layer's color.
+ // - 11 (BlendExclusion) or "exclusion" - The final color is similar to difference, but with less contrast.
+ // As with difference, a black layer has no effect, while a white layer inverts the other layer's color.
+ // - 12 (BlendHue) or "hue" - The final color has the hue of the top color, while using the saturation and luminosity of the bottom color.
+ // - 13 (BlendSaturation) or "saturation" - The final color has the saturation of the top color, while using the hue and luminosity of the bottom color.
+ // A pure gray backdrop, having no saturation, will have no effect.
+ // - 14 (BlendColor) or "color" - The final color has the hue and saturation of the top color, while using the luminosity of the bottom color.
+ // The effect preserves gray levels and can be used to colorize the foreground.
+ // - 15 (BlendLuminosity) or "luminosity" - The final color has the luminosity of the top color, while using the hue and saturation of the bottom color.
+ // This blend mode is equivalent to BlendColor, but with the layers swapped.
MixBlendMode PropertyName = "mix-blend-mode"
// TabIndex is the constant for "tabindex" property tag.
//
- // Used by `View`.
+ // Used by View.
// Indicates that view can be focused, and where it participates in sequential keyboard navigation(usually with the Tab
// key).
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // < `0` or < "0" - View can be selected with the mouse or touch, but does not participate in sequential navigation.
- // `0` or "0" - View can be selected and reached using sequential navigation, the order of navigation is determined by the browser(usually in order of addition).
- // > `0` or > "0" - View will be reached(and selected) using sequential navigation, and navigation is performed by ascending "tabindex" value.
+ // - negative value - View can be selected with the mouse or touch, but does not participate in sequential navigation.
+ // - 0 - View can be selected and reached using sequential navigation, the order of navigation is determined by the browser(usually in order of addition).
+ // - positive value - View will be reached(and selected) using sequential navigation, and navigation is performed by ascending "tabindex" value.
TabIndex PropertyName = "tabindex"
// Tooltip is the constant for "tooltip" property tag.
//
- // Used by `View`.
+ // Used by View.
// Specifies the tooltip text. Tooltip pops up when hovering the mouse cursor over the view. HTML tags are supported when
// formatting tooltip text.
//
- // Supported types: `string`.
+ // Supported types: string.
Tooltip PropertyName = "tooltip"
)
diff --git a/propertyValues.go b/propertyValues.go
index 47c67c0..7d462c7 100644
--- a/propertyValues.go
+++ b/propertyValues.go
@@ -149,9 +149,9 @@ const (
WhiteSpacePreLine = 4
// WhiteSpaceBreakSpaces - the behavior is identical to that of WhiteSpacePreWrap, except that:
- // * Any sequence of preserved white space always takes up space, including at the end of the line.
- // * A line breaking opportunity exists after every preserved white space character, including between white space characters.
- // * Such preserved spaces take up space and do not hang, and thus affect the box’s intrinsic sizes (min-content size and max-content size).
+ // - Any sequence of preserved white space always takes up space, including at the end of the line.
+ // - A line breaking opportunity exists after every preserved white space character, including between white space characters.
+ // - Such preserved spaces take up space and do not hang, and thus affect the box’s intrinsic sizes (min-content size and max-content size).
WhiteSpaceBreakSpaces = 5
// WordBreakNormal - use the default line break rule.
diff --git a/radius.go b/radius.go
index 7241a53..1525dff 100644
--- a/radius.go
+++ b/radius.go
@@ -9,382 +9,382 @@ import (
const (
// Radius is the constant for "radius" property tag.
//
- // Used by `View`, `BackgroundElement`, `ClipShape`.
+ // Used by View, BackgroundElement, ClipShape.
//
- // Usage in `View`:
+ // Usage in View:
// Specifies the corners rounding radius of an element's outer border edge.
//
- // Supported types: `RadiusProperty`, `SizeUnit`, `SizeFunc`, `BoxRadius`, `string`, `float`, `int`.
+ // Supported types: RadiusProperty, SizeUnit, SizeFunc, BoxRadius, string, float, int.
//
- // Internal type is either `RadiusProperty` or `SizeUnit`, other types converted to them during assignment.
- // See `RadiusProperty`, `SizeUnit`, `SizeFunc` and `BoxRadius` description for more details.
+ // Internal type is either RadiusProperty or SizeUnit, other types converted to them during assignment.
+ // See RadiusProperty, SizeUnit, SizeFunc and BoxRadius description for more details.
//
// Conversion rules:
- // `RadiusProperty` - stored as is, no conversion performed.
- // `SizeUnit` - stored as is and set all corners to have the same value.
- // `BoxRadius` - a new `RadiusProperty` will be created and all corresponding elliptical radius values will be set.
- // `string` - if one value will be provided then it will be set as a radius for all corners. If two values will be provided divided by (`/`) then x and y radius will be set for all corners. Examples: "1em", "1em/0.5em", "2/4". Values which doesn't have size prefix will use size in pixels by default.
- // `float` - values of this type will set radius for all corners in pixels.
- // `int` - values of this type will set radius for all corners in pixels.
+ // - RadiusProperty - stored as is, no conversion performed.
+ // - SizeUnit - stored as is and set all corners to have the same value.
+ // - BoxRadius - a new RadiusProperty will be created and all corresponding elliptical radius values will be set.
+ // - string - if one value will be provided then it will be set as a radius for all corners. If two values will be provided divided by (/) then x and y radius will be set for all corners. Examples: "1em", "1em/0.5em", "2/4". Values which doesn't have size prefix will use size in pixels by default.
+ // - float - values of this type will set radius for all corners in pixels.
+ // - int - values of this type will set radius for all corners in pixels.
//
- // Usage in `BackgroundElement`:
+ // Usage in BackgroundElement:
// Same as "radial-gradient-radius".
//
- // Usage in `ClipShape`:
+ // Usage in ClipShape:
// Specifies the radius of the corners or the radius of the cropping area.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
Radius PropertyName = "radius"
// RadiusX is the constant for "radius-x" property tag.
//
- // Used by `View`, `ClipShape`.
+ // Used by View, ClipShape.
//
- // Usage in `View`:
+ // Usage in View:
// Specifies the x-axis corners elliptic rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
//
- // Usage in `ClipShape`:
+ // Usage in ClipShape:
// Specifies the x-axis corners elliptic rounding radius of the elliptic clip shape.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
RadiusX PropertyName = "radius-x"
// RadiusY is the constant for "radius-y" property tag.
//
- // Used by `View`, `ClipShape`.
+ // Used by View, ClipShape.
//
- // Usage in `View`:
+ // Usage in View:
// Specifies the y-axis corners elliptic rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
//
- // Usage in `ClipShape`:
+ // Usage in ClipShape:
// Specifies the y-axis corners elliptic rounding radius of of the elliptic clip shape.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
RadiusY PropertyName = "radius-y"
// RadiusTopLeft is the constant for "radius-top-left" property tag.
//
- // Used by `View`.
+ // Used by View.
// Specifies the top-left corner rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
RadiusTopLeft PropertyName = "radius-top-left"
// RadiusTopLeftX is the constant for "radius-top-left-x" property tag.
//
- // Used by `View`.
+ // Used by View.
// Specifies the x-axis top-left corner elliptic rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
RadiusTopLeftX PropertyName = "radius-top-left-x"
// RadiusTopLeftY is the constant for "radius-top-left-y" property tag.
//
- // Used by `View`.
+ // Used by View.
// Specifies the y-axis top-left corner elliptic rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
RadiusTopLeftY PropertyName = "radius-top-left-y"
// RadiusTopRight is the constant for "radius-top-right" property tag.
//
- // Used by `View`.
+ // Used by View.
// Specifies the top-right corner rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
RadiusTopRight PropertyName = "radius-top-right"
// RadiusTopRightX is the constant for "radius-top-right-x" property tag.
//
- // Used by `View`.
+ // Used by View.
// Specifies the x-axis top-right corner elliptic rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
RadiusTopRightX PropertyName = "radius-top-right-x"
// RadiusTopRightY is the constant for "radius-top-right-y" property tag.
//
- // Used by `View`.
+ // Used by View.
// Specifies the y-axis top-right corner elliptic rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
RadiusTopRightY PropertyName = "radius-top-right-y"
// RadiusBottomLeft is the constant for "radius-bottom-left" property tag.
//
- // Used by `View`.
+ // Used by View.
// Specifies the bottom-left corner rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
RadiusBottomLeft PropertyName = "radius-bottom-left"
// RadiusBottomLeftX is the constant for "radius-bottom-left-x" property tag.
//
- // Used by `View`.
+ // Used by View.
// Specifies the x-axis bottom-left corner elliptic rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
RadiusBottomLeftX PropertyName = "radius-bottom-left-x"
// RadiusBottomLeftY is the constant for "radius-bottom-left-y" property tag.
//
- // Used by `View`.
+ // Used by View.
// Specifies the y-axis bottom-left corner elliptic rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
RadiusBottomLeftY PropertyName = "radius-bottom-left-y"
// RadiusBottomRight is the constant for "radius-bottom-right" property tag.
//
- // Used by `View`.
+ // Used by View.
// Specifies the bottom-right corner rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
RadiusBottomRight PropertyName = "radius-bottom-right"
// RadiusBottomRightX is the constant for "radius-bottom-right-x" property tag.
//
- // Used by `View`.
+ // Used by View.
// Specifies the x-axis bottom-right corner elliptic rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
RadiusBottomRightX PropertyName = "radius-bottom-right-x"
// RadiusBottomRightY is the constant for "radius-bottom-right-y" property tag.
//
- // Used by `View`.
+ // Used by View.
// Specifies the y-axis bottom-right corner elliptic rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
RadiusBottomRightY PropertyName = "radius-bottom-right-y"
// X is the constant for "x" property tag.
//
- // Used by `ClipShape`, `RadiusProperty`.
+ // Used by ClipShape, RadiusProperty.
//
- // Usage in `ClipShape`:
+ // Usage in ClipShape:
// Specifies x-axis position of the clip shape.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
//
- // Usage in `RadiusProperty`:
+ // Usage in RadiusProperty:
// Determines the x-axis elliptic rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
X PropertyName = "x"
// Y is the constant for "y" property tag.
//
- // Used by `ClipShape`, `RadiusProperty`.
+ // Used by ClipShape, RadiusProperty.
//
- // Usage in `ClipShape`:
+ // Usage in ClipShape:
// Specifies y-axis position of the clip shape.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
//
- // Usage in `RadiusProperty`:
+ // Usage in RadiusProperty:
// Determines the y-axis elliptic rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
Y PropertyName = "y"
// TopLeft is the constant for "top-left" property tag.
//
- // Used by `RadiusProperty`.
+ // Used by RadiusProperty.
// Determines the top-left corner rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
TopLeft PropertyName = "top-left"
// TopLeftX is the constant for "top-left-x" property tag.
//
- // Used by `RadiusProperty`.
+ // Used by RadiusProperty.
// Determines the x-axis top-left corner elliptic rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
TopLeftX PropertyName = "top-left-x"
// TopLeftY is the constant for "top-left-y" property tag.
//
- // Used by `RadiusProperty`.
+ // Used by RadiusProperty.
// Determines the y-axis top-left corner elliptic rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
TopLeftY PropertyName = "top-left-y"
// TopRight is the constant for "top-right" property tag.
//
- // Used by `RadiusProperty`.
+ // Used by RadiusProperty.
// Determines the top-right corner rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
TopRight PropertyName = "top-right"
// TopRightX is the constant for "top-right-x" property tag.
//
- // Used by `RadiusProperty`.
+ // Used by RadiusProperty.
// Determines the x-axis top-right corner elliptic rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
TopRightX PropertyName = "top-right-x"
// TopRightY is the constant for "top-right-y" property tag.
//
- // Used by `RadiusProperty`.
+ // Used by RadiusProperty.
// Determines the y-axis top-right corner elliptic rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
TopRightY PropertyName = "top-right-y"
// BottomLeft is the constant for "bottom-left" property tag.
//
- // Used by `RadiusProperty`.
+ // Used by RadiusProperty.
// Determines the bottom-left corner rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
BottomLeft PropertyName = "bottom-left"
// BottomLeftX is the constant for "bottom-left-x" property tag.
//
- // Used by `RadiusProperty`.
+ // Used by RadiusProperty.
// Determines the x-axis bottom-left corner elliptic rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
BottomLeftX PropertyName = "bottom-left-x"
// BottomLeftY is the constant for "bottom-left-y" property tag.
//
- // Used by `RadiusProperty`.
+ // Used by RadiusProperty.
// Determines the y-axis bottom-left corner elliptic rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
BottomLeftY PropertyName = "bottom-left-y"
// BottomRight is the constant for "bottom-right" property tag.
//
- // Used by `RadiusProperty`.
+ // Used by RadiusProperty.
// Determines the bottom-right corner rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
BottomRight PropertyName = "bottom-right"
// BottomRightX is the constant for "bottom-right-x" property tag.
//
- // Used by `RadiusProperty`.
+ // Used by RadiusProperty.
// Determines the x-axis bottom-right corner elliptic rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
BottomRightX PropertyName = "bottom-right-x"
// BottomRightY is the constant for "bottom-right-y" property tag.
//
- // Used by `RadiusProperty`.
+ // Used by RadiusProperty.
// Determines the y-axis bottom-right corner elliptic rounding radius of an element's outer border edge.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
BottomRightY PropertyName = "bottom-right-y"
)
@@ -403,35 +403,22 @@ type radiusPropertyData struct {
}
// NewRadiusProperty creates the new RadiusProperty
+//
// The following properties can be used:
-//
-// "x" (X) - Determines the x-axis elliptic rounding radius of an element's outer border edge.
-//
-// "y" (Y) - Determines the y-axis corner elliptic rounding radius of an element's outer border edge.
-//
-// "top-left" (TopLeft) - Determines the top-left corner rounding radius of an element's outer border edge.
-//
-// "top-left-x" (TopLeftX) - Determines the x-axis top-left corner elliptic rounding radius of an element's outer border edge.
-//
-// "top-left-y" (TopLeftY) - Determines the y-axis top-left corner elliptic rounding radius of an element's outer border edge.
-//
-// "top-right" (TopRight) - Determines the top-right corner rounding radius of an element's outer border edge.
-//
-// "top-right-x" (TopRightX) - Determines the x-axis top-right corner elliptic rounding radius of an element's outer border edge.
-//
-// "top-right-y" (TopRightY) - Determines the y-axis top-right corner elliptic rounding radius of an element's outer border edge.
-//
-// "bottom-left" (BottomLeft) - Determines the bottom-left corner rounding radius of an element's outer border edge.
-//
-// "bottom-left-x" (BottomLeftX) - Determines the x-axis bottom-left corner elliptic rounding radius of an element's outer border edge.
-//
-// "bottom-left-y" (BottomLeftY) - Determines the y-axis bottom-left corner elliptic rounding radius of an element's outer border edge.
-//
-// "bottom-right" (BottomRight) - Determines the bottom-right corner rounding radius of an element's outer border edge.
-//
-// "bottom-right-x" (BottomRightX) - Determines the x-axis bottom-right corner elliptic rounding radius of an element's outer border edge.
-//
-// "bottom-right-y" (BottomRightY) - Determines the y-axis bottom-right corner elliptic rounding radius of an element's outer border edge.
+// - "x" (X) - Determines the x-axis elliptic rounding radius of an element's outer border edge.
+// - "y" (Y) - Determines the y-axis corner elliptic rounding radius of an element's outer border edge.
+// - "top-left" (TopLeft) - Determines the top-left corner rounding radius of an element's outer border edge.
+// - "top-left-x" (TopLeftX) - Determines the x-axis top-left corner elliptic rounding radius of an element's outer border edge.
+// - "top-left-y" (TopLeftY) - Determines the y-axis top-left corner elliptic rounding radius of an element's outer border edge.
+// - "top-right" (TopRight) - Determines the top-right corner rounding radius of an element's outer border edge.
+// - "top-right-x" (TopRightX) - Determines the x-axis top-right corner elliptic rounding radius of an element's outer border edge.
+// - "top-right-y" (TopRightY) - Determines the y-axis top-right corner elliptic rounding radius of an element's outer border edge.
+// - "bottom-left" (BottomLeft) - Determines the bottom-left corner rounding radius of an element's outer border edge.
+// - "bottom-left-x" (BottomLeftX) - Determines the x-axis bottom-left corner elliptic rounding radius of an element's outer border edge.
+// - "bottom-left-y" (BottomLeftY) - Determines the y-axis bottom-left corner elliptic rounding radius of an element's outer border edge.
+// - "bottom-right" (BottomRight) - Determines the bottom-right corner rounding radius of an element's outer border edge.
+// - "bottom-right-x" (BottomRightX) - Determines the x-axis bottom-right corner elliptic rounding radius of an element's outer border edge.
+// - "bottom-right-y" (BottomRightY) - Determines the y-axis bottom-right corner elliptic rounding radius of an element's outer border edge.
func NewRadiusProperty(params Params) RadiusProperty {
result := new(radiusPropertyData)
result.init()
@@ -447,6 +434,7 @@ func NewRadiusProperty(params Params) RadiusProperty {
}
// NewRadiusProperty creates the new RadiusProperty which having the same elliptical radii for all angles.
+//
// Arguments determines the x- and y-axis elliptic rounding radius. if an argument is specified as int or float64, the value is considered to be in pixels
func NewEllipticRadius[xType SizeUnit | int | float64, yType SizeUnit | int | float64](x xType, y yType) RadiusProperty {
return NewRadiusProperty(Params{
@@ -456,7 +444,9 @@ func NewEllipticRadius[xType SizeUnit | int | float64, yType SizeUnit | int | fl
}
// NewRadius creates the new RadiusProperty.
+//
// The arguments specify the radii in a clockwise direction: "top-right", "bottom-right", "bottom-left", and "top-left".
+//
// if an argument is specified as int or float64, the value is considered to be in pixels
func NewRadii[topRightType SizeUnit | int | float64, bottomRightType SizeUnit | int | float64, bottomLeftType SizeUnit | int | float64, topLeftType SizeUnit | int | float64](
topRight topRightType, bottomRight bottomRightType, bottomLeft bottomLeftType, topLeft topLeftType) RadiusProperty {
diff --git a/resizable.go b/resizable.go
index 0860406..52b0076 100644
--- a/resizable.go
+++ b/resizable.go
@@ -10,29 +10,29 @@ import (
const (
// Side is the constant for "side" property tag.
//
- // Used by `Resizable`.
+ // Used by Resizable.
// Determines which side of the container is used to resize. The value of property is an or-combination of values listed.
// Default value is "all".
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `1`(`TopSide`) or "top" - Top frame side.
- // `2`(`RightSide`) or "right" - Right frame side.
- // `4`(`BottomSide`) or "bottom" - Bottom frame side.
- // `8`(`LeftSide`) or "left" - Left frame side.
- // `15`(`AllSides`) or "all" - All frame sides.
+ // - 1 (TopSide) or "top" - Top frame side.
+ // - 2 (RightSide) or "right" - Right frame side.
+ // - 4 (BottomSide) or "bottom" - Bottom frame side.
+ // - 8 (LeftSide) or "left" - Left frame side.
+ // - 15 (AllSides) or "all" - All frame sides.
Side = "side"
// ResizeBorderWidth is the constant for "resize-border-width" property tag.
//
- // Used by `Resizable`.
+ // Used by Resizable.
// Specifies the width of the resizing border.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
ResizeBorderWidth = "resize-border-width"
)
diff --git a/resizeEvent.go b/resizeEvent.go
index 16dfd6b..bae4fbc 100644
--- a/resizeEvent.go
+++ b/resizeEvent.go
@@ -2,20 +2,22 @@ package rui
// ResizeEvent is the constant for "resize-event" property tag.
//
-// Used by `View`.
+// Used by View.
// Is fired when the view changes its size.
//
// General listener format:
-// `func(view rui.View, frame rui.Frame)`.
+//
+// func(view rui.View, frame rui.Frame)
//
// where:
-// view - Interface of a view which generated this event,
-// frame - New offset and size of the view's visible area.
+// - view - Interface of a view which generated this event,
+// - frame - New offset and size of the view's visible area.
//
// Allowed listener formats:
-// `func(frame rui.Frame)`,
-// `func(view rui.View)`,
-// `func()`.
+//
+// func(frame rui.Frame)
+// func(view rui.View)
+// func()
const ResizeEvent PropertyName = "resize-event"
func (view *viewData) onResize(self View, x, y, width, height float64) {
diff --git a/scrollEvent.go b/scrollEvent.go
index 5b44845..294538e 100644
--- a/scrollEvent.go
+++ b/scrollEvent.go
@@ -2,20 +2,22 @@ package rui
// ScrollEvent is the constant for "scroll-event" property tag.
//
-// Used by `View`.
+// Used by View.
// Is fired when the content of the view is scrolled.
//
// General listener format:
-// `func(view rui.View, frame rui.Frame)`.
+//
+// func(view rui.View, frame rui.Frame)
//
// where:
-// view - Interface of a view which generated this event,
-// frame - New offset and size of the view's visible area.
+// - view - Interface of a view which generated this event,
+// - frame - New offset and size of the view's visible area.
//
// Allowed listener formats:
-// `func(frame rui.Frame)`,
-// `func(view rui.View)`,
-// `func()`.
+//
+// func(frame rui.Frame)
+// func(view rui.View)
+// func()
const ScrollEvent PropertyName = "scroll-event"
func (view *viewData) onScroll(self View, x, y, width, height float64) {
diff --git a/shadow.go b/shadow.go
index 937d45f..ab5ce78 100644
--- a/shadow.go
+++ b/shadow.go
@@ -9,97 +9,101 @@ import (
const (
// ColorTag is the constant for "color" property tag.
//
- // Used by `ColumnSeparatorProperty`, `BorderProperty`, `OutlineProperty`, `ShadowProperty`.
+ // Used by ColumnSeparatorProperty, BorderProperty, OutlineProperty, ShadowProperty.
+ //
+ // # Usage in ColumnSeparatorProperty
//
- // Usage in `ColumnSeparatorProperty`:
// Line color.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See Color description for more details.
+ //
+ // # Usage in BorderProperty
//
- // Usage in `BorderProperty`:
// Border line color.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See Color description for more details.
+ //
+ // # Usage in OutlineProperty
//
- // Usage in `OutlineProperty`:
// Outline line color.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See Color description for more details.
+ //
+ // # Usage in ShadowProperty
//
- // Usage in `ShadowProperty`:
// Color property of the shadow.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See Color description for more details.
ColorTag PropertyName = "color"
// Inset is the constant for "inset" property tag.
//
- // Used by `ShadowProperty`.
+ // Used by ShadowProperty.
// Controls whether to draw shadow inside the frame or outside. Inset shadows are drawn inside the border(even transparent
// ones), above the background, but below content.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - Drop shadow inside the frame(as if the content was depressed inside the box).
- // `false` or `0` or "false", "no", "off", "0" - Shadow is assumed to be a drop shadow(as if the box were raised above the content).
+ // - true, 1, "true", "yes", "on", "1" - Drop shadow inside the frame(as if the content was depressed inside the box).
+ // - false, 0, "false", "no", "off", "0" - Shadow is assumed to be a drop shadow(as if the box were raised above the content).
Inset PropertyName = "inset"
// XOffset is the constant for "x-offset" property tag.
//
- // Used by `ShadowProperty`.
+ // Used by ShadowProperty.
// Determines the shadow horizontal offset. Negative values place the shadow to the left of the element.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
XOffset PropertyName = "x-offset"
// YOffset is the constant for "y-offset" property tag.
//
- // Used by `ShadowProperty`.
+ // Used by ShadowProperty.
// Determines the shadow vertical offset. Negative values place the shadow above the element.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
YOffset PropertyName = "y-offset"
// BlurRadius is the constant for "blur" property tag.
//
- // Used by `ShadowProperty`.
+ // Used by ShadowProperty.
// Determines the radius of the blur effect. The larger this value, the bigger the blur, so the shadow becomes bigger and
// lighter. Negative values are not allowed.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
BlurRadius PropertyName = "blur"
// SpreadRadius is the constant for "spread-radius" property tag.
//
- // Used by `ShadowProperty`.
+ // Used by ShadowProperty.
// Positive values will cause the shadow to expand and grow bigger, negative values will cause the shadow to shrink.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
SpreadRadius PropertyName = "spread-radius"
)
@@ -118,14 +122,10 @@ type shadowPropertyData struct {
}
// NewShadow create the new shadow property for a view. Arguments:
-//
-// offsetX, offsetY is x and y offset of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
-//
-// blurRadius is the blur radius of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
-//
-// spreadRadius is the spread radius of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
-//
-// color is the color of the shadow.
+// - offsetX, offsetY is x and y offset of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
+// - blurRadius is the blur radius of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
+// - spreadRadius is the spread radius of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
+// - color is the color of the shadow.
func NewShadow[xOffsetType SizeUnit | int | float64, yOffsetType SizeUnit | int | float64, blurType SizeUnit | int | float64, spreadType SizeUnit | int | float64](
xOffset xOffsetType, yOffset yOffsetType, blurRadius blurType, spreadRadius spreadType, color Color) ShadowProperty {
return NewShadowProperty(Params{
@@ -138,14 +138,10 @@ func NewShadow[xOffsetType SizeUnit | int | float64, yOffsetType SizeUnit | int
}
// NewInsetShadow create the new inset shadow property for a view. Arguments:
-//
-// offsetX, offsetY is x and y offset of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
-//
-// blurRadius is the blur radius of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
-//
-// spreadRadius is the spread radius of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
-//
-// color is the color of the shadow.
+// - offsetX, offsetY is x and y offset of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
+// - blurRadius is the blur radius of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
+// - spreadRadius is the spread radius of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
+// - color is the color of the shadow.
func NewInsetShadow[xOffsetType SizeUnit | int | float64, yOffsetType SizeUnit | int | float64, blurType SizeUnit | int | float64, spreadType SizeUnit | int | float64](
xOffset xOffsetType, yOffset yOffsetType, blurRadius blurType, spreadRadius spreadType, color Color) ShadowProperty {
return NewShadowProperty(Params{
@@ -159,12 +155,9 @@ func NewInsetShadow[xOffsetType SizeUnit | int | float64, yOffsetType SizeUnit |
}
// NewTextShadow create the new text shadow property. Arguments:
-//
-// offsetX, offsetY is the x- and y-offset of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
-//
-// blurRadius is the blur radius of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
-//
-// color is the color of the shadow.
+// - offsetX, offsetY is the x- and y-offset of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
+// - blurRadius is the blur radius of the shadow (if the argument is specified as int or float64, the value is considered to be in pixels);
+// - color is the color of the shadow.
func NewTextShadow[xOffsetType SizeUnit | int | float64, yOffsetType SizeUnit | int | float64, blurType SizeUnit | int | float64](
xOffset xOffsetType, yOffset yOffsetType, blurRadius blurType, color Color) ShadowProperty {
return NewShadowProperty(Params{
@@ -176,19 +169,14 @@ func NewTextShadow[xOffsetType SizeUnit | int | float64, yOffsetType SizeUnit |
}
// NewShadowProperty create the new shadow property for a view.
+//
// The following properties can be used:
-//
-// "color" (ColorTag). Determines the color of the shadow (Color);
-//
-// "x-offset" (XOffset). Determines the shadow horizontal offset (SizeUnit);
-//
-// "y-offset" (YOffset). Determines the shadow vertical offset (SizeUnit);
-//
-// "blur" (BlurRadius). Determines the radius of the blur effect (SizeUnit);
-//
-// "spread-radius" (SpreadRadius). Positive values (SizeUnit) will cause the shadow to expand and grow bigger, negative values will cause the shadow to shrink;
-//
-// "inset" (Inset). Controls (bool) whether to draw shadow inside the frame or outside.
+// - "color" (ColorTag). Determines the color of the shadow (Color);
+// - "x-offset" (XOffset). Determines the shadow horizontal offset (SizeUnit);
+// - "y-offset" (YOffset). Determines the shadow vertical offset (SizeUnit);
+// - "blur" (BlurRadius). Determines the radius of the blur effect (SizeUnit);
+// - "spread-radius" (SpreadRadius). Positive values (SizeUnit) will cause the shadow to expand and grow bigger, negative values will cause the shadow to shrink;
+// - "inset" (Inset). Controls (bool) whether to draw shadow inside the frame or outside.
func NewShadowProperty(params Params) ShadowProperty {
shadow := new(shadowPropertyData)
shadow.init()
diff --git a/sizeFunc.go b/sizeFunc.go
index 8b80666..59fb218 100644
--- a/sizeFunc.go
+++ b/sizeFunc.go
@@ -7,7 +7,9 @@ import (
)
// SizeFunc describes a function that calculates the SizeUnit size.
+//
// Used as the value of the SizeUnit properties.
+//
// "min", "max", "clamp", "sum", "sub", "mul", "div", mod,
// "round", "round-up", "round-down" and "round-to-zero" functions are available.
type SizeFunc interface {
diff --git a/stackLayout.go b/stackLayout.go
index 9972bb3..e27ce36 100644
--- a/stackLayout.go
+++ b/stackLayout.go
@@ -9,239 +9,241 @@ import (
const (
// PushTransform is the constant for "push-transform" property tag.
//
- // Used by `StackLayout`.
+ // Used by StackLayout.
// Specify start translation, scale and rotation over x, y and z axes as well as a distortion
// for an animated pushing of a child view.
//
- // Supported types: `TransformProperty`, `string`.
+ // Supported types: TransformProperty, string.
//
- // See `TransformProperty` description for more details.
+ // See TransformProperty description for more details.
//
// Conversion rules:
- // `TransformProperty` - stored as is, no conversion performed.
- // `string` - string representation of `Transform` interface. Example: "_{translate-x = 10px, scale-y = 1.1}".
+ // - TransformProperty - stored as is, no conversion performed.
+ // - string - string representation of Transform interface. Example: "_{translate-x = 10px, scale-y = 1.1}".
PushTransform = "push-transform"
// PushDuration is the constant for "push-duration" property tag.
//
- // Used by `StackLayout`.
+ // Used by StackLayout.
// Sets the length of time in seconds that an push/pop animation takes to complete.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
PushDuration = "push-duration"
// PushTiming is the constant for "push-timing" property tag.
//
- // Used by `StackLayout`.
+ // Used by StackLayout.
// Set how an push/pop animation progresses through the duration of each cycle.
//
- // Supported types: `string`.
+ // Supported types: string.
//
// Values:
- // "ease"(`EaseTiming`) - Speed increases towards the middle and slows down at the end.
- // "ease-in"(`EaseInTiming`) - Speed is slow at first, but increases in the end.
- // "ease-out"(`EaseOutTiming`) - Speed is fast at first, but decreases in the end.
- // "ease-in-out"(`EaseInOutTiming`) - Speed is slow at first, but quickly increases and at the end it decreases again.
- // "linear"(`LinearTiming`) - Constant speed.
+ // - "ease" (EaseTiming) - Speed increases towards the middle and slows down at the end.
+ // - "ease-in" (EaseInTiming) - Speed is slow at first, but increases in the end.
+ // - "ease-out" (EaseOutTiming) - Speed is fast at first, but decreases in the end.
+ // - "ease-in-out" (EaseInOutTiming) - Speed is slow at first, but quickly increases and at the end it decreases again.
+ // - "linear" (LinearTiming) - Constant speed.
+ // - "step(n)" (StepTiming(n int) function) - Timing function along stepCount stops along the transition, displaying each stop for equal lengths of time.
+ // - "cubic-bezier(x1, y1, x2, y2)" (CubicBezierTiming(x1, y1, x2, y2 float64) function) - Cubic-Bezier curve timing function. x1 and x2 must be in the range [0, 1].
PushTiming = "push-timing"
// MoveToFrontAnimation is the constant for "move-to-front-animation" property tag.
//
- // Used by `StackLayout`.
+ // Used by StackLayout.
// Specifies whether animation is used when calling the MoveToFront/MoveToFrontByID method of StackLayout interface.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - animation is used (default value).
- // `false` or `0` or "false", "no", "off", "0" - animation is not used.
+ // - true, 1, "true", "yes", "on", "1" - animation is used (default value).
+ // - false, 0, "false", "no", "off", "0" - animation is not used.
MoveToFrontAnimation = "move-to-front-animation"
// PushPerspective is the constant for "push-perspective" property tag.
//
- // Used by `StackLayout`.
+ // Used by StackLayout.
//
// Used to access the "perspective" property of StackLayout "push-transform" property:
// Distance between the z-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).
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
PushPerspective PropertyName = "push-perspective"
// PushTranslateX is the constant for "push-translate-x" property tag.
//
- // Used by `StackLayout`.
+ // Used by StackLayout.
//
// Used to access the "translate-x" property of StackLayout "push-transform" property:
// x-axis translation value of a 2D/3D translation.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
PushTranslateX PropertyName = "push-translate-x"
// PushTranslateY is the constant for "push-translate-y" property tag.
//
- // Used by `StackLayout`.
+ // Used by StackLayout.
//
// Used to access the "translate-y" property of StackLayout "push-transform" property:
// y-axis translation value of a 2D/3D translation.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
PushTranslateY PropertyName = "push-translate-y"
// PushTranslateZ is the constant for "push-translate-z" property tag.
//
- // Used by `StackLayout`.
+ // Used by StackLayout.
//
// Used to access the "translate-z" property of StackLayout "push-transform" property:
// z-axis translation value of a 3D translation.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
PushTranslateZ PropertyName = "push-translate-z"
// PushScaleX is the constant for "push-scale-x" property tag.
//
- // Used by `StackLayout`.
+ // Used by StackLayout.
//
// Used to access the "scale-x" property of StackLayout "push-transform" property:
// x-axis scaling value of a 2D/3D scale. The original scale is 1. Values between 0 and 1 are used to decrease original
// scale, more than 1 - to increase. The default value is 1.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
PushScaleX PropertyName = "push-scale-x"
// PushScaleY is the constant for "push-scale-y" property tag.
//
- // Used by `StackLayout`.
+ // Used by StackLayout.
//
// Used to access the "scale-y" property of StackLayout "push-transform" property:
// y-axis scaling value of a 2D/3D scale. The original scale is 1. Values between 0 and 1 are used to decrease original
// scale, more than 1 - to increase. The default value is 1.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
PushScaleY PropertyName = "push-scale-y"
// PushScaleZ is the constant for "push-scale-z" property tag.
//
- // Used by `StackLayout`.
+ // Used by StackLayout.
//
// Used to access the "scale-z" property of StackLayout "push-transform" property:
// z-axis scaling value of a 3D scale. The original scale is 1. Values between 0 and 1 are used to decrease original
// scale, more than 1 - to increase. The default value is 1.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
PushScaleZ PropertyName = "push-scale-z"
// PushRotate is the constant for "push-rotate" property tag.
//
- // Used by `StackLayout`.
+ // Used by StackLayout.
//
// Used to access the "rotate" property of StackLayout "push-transform" property:
// Angle of the view rotation. A positive angle denotes a clockwise rotation, a negative angle a counter-clockwise.
//
- // Supported types: `AngleUnit`, `string`, `float`, `int`.
+ // Supported types: AngleUnit, string, float, int.
//
- // Internal type is `AngleUnit`, other types will be converted to it during assignment.
- // See `AngleUnit` description for more details.
+ // Internal type is AngleUnit, other types will be converted to it during assignment.
+ // See AngleUnit description for more details.
//
// Conversion rules:
- // `AngleUnit` - stored as is, no conversion performed.
- // `string` - must contain string representation of `AngleUnit`. If numeric value will be provided without any suffix then `AngleUnit` with value and `Radian` value type will be created.
- // `float` - a new `AngleUnit` value will be created with `Radian` as a type.
- // `int` - a new `AngleUnit` value will be created with `Radian` as a type.
+ // - AngleUnit - stored as is, no conversion performed.
+ // - string - must contain string representation of AngleUnit. If numeric value will be provided without any suffix then AngleUnit with value and Radian value type will be created.
+ // - float - a new AngleUnit value will be created with Radian as a type.
+ // - int - a new AngleUnit value will be created with Radian as a type.
PushRotate PropertyName = "push-rotate"
// PushRotateX is the constant for "push-rotate-x" property tag.
//
- // Used by `StackLayout`.
+ // Used by StackLayout.
//
// Used to access the "rotate-x" property of StackLayout "push-transform" property:
// x-coordinate of the vector denoting the axis of rotation in range 0 to 1.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
PushRotateX PropertyName = "push-rotate-x"
// PushRotateY is the constant for "push-rotate-y" property tag.
//
- // Used by `StackLayout`.
+ // Used by StackLayout.
//
// Used to access the "rotate-y" property of StackLayout "push-transform" property:
// y-coordinate of the vector denoting the axis of rotation in range 0 to 1.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
PushRotateY PropertyName = "push-rotate-y"
// PushRotateZ is the constant for "push-rotate-z" property tag.
//
- // Used by `StackLayout`.
+ // Used by StackLayout.
//
// Used to access the "rotate-z" property of StackLayout "push-transform" property:
// z-coordinate of the vector denoting the axis of rotation in range 0 to 1.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
PushRotateZ PropertyName = "push-rotate-z"
// PushSkewX is the constant for "push-skew-x" property tag.
//
- // Used by `StackLayout`.
+ // Used by StackLayout.
//
// Used to access the "skew-x" property of StackLayout "push-transform" property:
// Angle to use to distort the element along the abscissa. The default value is 0.
//
- // Supported types: `AngleUnit`, `string`, `float`, `int`.
+ // Supported types: AngleUnit, string, float, int.
//
- // Internal type is `AngleUnit`, other types will be converted to it during assignment.
- // See `AngleUnit` description for more details.
+ // Internal type is AngleUnit, other types will be converted to it during assignment.
+ // See AngleUnit description for more details.
//
// Conversion rules:
- // `AngleUnit` - stored as is, no conversion performed.
- // `string` - must contain string representation of `AngleUnit`. If numeric value will be provided without any suffix then `AngleUnit` with value and `Radian` value type will be created.
- // `float` - a new `AngleUnit` value will be created with `Radian` as a type.
- // `int` - a new `AngleUnit` value will be created with `Radian` as a type.
+ // - AngleUnit - stored as is, no conversion performed.
+ // - string - must contain string representation of AngleUnit. If numeric value will be provided without any suffix then AngleUnit with value and Radian value type will be created.
+ // - float - a new AngleUnit value will be created with Radian as a type.
+ // - int - a new AngleUnit value will be created with Radian as a type.
PushSkewX PropertyName = "push-skew-x"
// PushSkewY is the constant for "push-skew-y" property tag.
//
- // Used by `StackLayout`.
+ // Used by StackLayout.
//
// Used to access the "skew-y" property of StackLayout "push-transform" property:
// Angle to use to distort the element along the ordinate. The default value is 0.
//
- // Supported types: `AngleUnit`, `string`, `float`, `int`.
+ // Supported types: AngleUnit, string, float, int.
//
- // Internal type is `AngleUnit`, other types will be converted to it during assignment.
- // See `AngleUnit` description for more details.
+ // Internal type is AngleUnit, other types will be converted to it during assignment.
+ // See AngleUnit description for more details.
//
// Conversion rules:
- // `AngleUnit` - stored as is, no conversion performed.
- // `string` - must contain string representation of `AngleUnit`. If numeric value will be provided without any suffix then `AngleUnit` with value and `Radian` value type will be created.
- // `float` - a new `AngleUnit` value will be created with `Radian` as a type.
- // `int` - a new `AngleUnit` value will be created with `Radian` as a type.
+ // - AngleUnit - stored as is, no conversion performed.
+ // - string - must contain string representation of AngleUnit. If numeric value will be provided without any suffix then AngleUnit with value and Radian value type will be created.
+ // - float - a new AngleUnit value will be created with Radian as a type.
+ // - int - a new AngleUnit value will be created with Radian as a type.
PushSkewY PropertyName = "push-skew-y"
)
@@ -256,28 +258,36 @@ type StackLayout interface {
RemovePeek() View
// MoveToFront makes the given View current.
+ //
// The second argument is a function called after the move to front animation ends.
+ //
// Returns true if successful, false otherwise.
MoveToFront(view View, onShown ...func(View)) bool
// MoveToFrontByID makes the View current by viewID.
+ //
// The second argument is a function called after the move to front animation ends.
+ //
// Returns true if successful, false otherwise.
MoveToFrontByID(viewID string, onShown ...func(View)) bool
// Push adds a new View to the container and makes it current.
+ //
// It is similar to Append, but the addition is done using an animation effect.
+ //
// The animation type is specified by the second argument and can take the following values:
- // * DefaultAnimation (0) - Default animation. For the Push function it is EndToStartAnimation, for Pop - StartToEndAnimation;
- // * StartToEndAnimation (1) - Animation from beginning to end. The beginning and the end are determined by the direction of the text output;
- // * EndToStartAnimation (2) - End-to-Beginning animation;
- // * TopDownAnimation (3) - Top-down animation;
- // * BottomUpAnimation (4) - Bottom up animation.
+ // - DefaultAnimation (0) - Default animation. For the Push function it is EndToStartAnimation, for Pop - StartToEndAnimation;
+ // - StartToEndAnimation (1) - Animation from beginning to end. The beginning and the end are determined by the direction of the text output;
+ // - EndToStartAnimation (2) - End-to-Beginning animation;
+ // - TopDownAnimation (3) - Top-down animation;
+ // - BottomUpAnimation (4) - Bottom up animation.
// The second argument `onPushFinished` is the function to be called when the animation ends.
Push(view View, onPushFinished ...func())
// Pop removes the current View from the container using animation.
+ //
// The argument `onPopFinished` is the function to be called when the animation ends.
+ //
// The function will return false if the StackLayout is empty and true if the current item has been removed.
Pop(onPopFinished ...func(View)) bool
}
diff --git a/tableAdapter.go b/tableAdapter.go
index 1fdcc65..2d8610c 100644
--- a/tableAdapter.go
+++ b/tableAdapter.go
@@ -9,19 +9,20 @@ type TableAdapter interface {
ColumnCount() int
// Cell returns the contents of a table cell. The function can return elements of the following types:
- // * string
- // * rune
- // * float32, float64
- // * integer values: int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64
- // * bool
- // * rui.Color
- // * rui.View
- // * fmt.Stringer
- // * rui.VerticalTableJoin, rui.HorizontalTableJoin
+ // - string
+ // - rune
+ // - float32, float64
+ // - integer values: int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64
+ // - bool
+ // - rui.Color
+ // - rui.View
+ // - fmt.Stringer
+ // - rui.VerticalTableJoin, rui.HorizontalTableJoin
Cell(row, column int) any
}
// TableColumnStyle describes the style of [TableView] columns.
+//
// To set column styles, you must either implement the [TableColumnStyle] interface in the table adapter
// or assign its separate implementation to the "column-style" property.
type TableColumnStyle interface {
@@ -30,6 +31,7 @@ type TableColumnStyle interface {
}
// TableRowStyle describes the style of [TableView] rows.
+//
// To set row styles, you must either implement the [TableRowStyle] interface in the table adapter
// or assign its separate implementation to the "row-style" property.
type TableRowStyle interface {
@@ -38,6 +40,7 @@ type TableRowStyle interface {
}
// TableCellStyle describes the style of [TableView] cells.
+//
// To set row cells, you must either implement the [TableCellStyle] interface in the table adapter
// or assign its separate implementation to the "cell-style" property.
type TableCellStyle interface {
@@ -46,7 +49,9 @@ type TableCellStyle interface {
}
// TableAllowCellSelection determines whether [TableView] cell selection is allowed.
+//
// It is only used if the "selection-mode" property is set to CellSelection (1).
+//
// To set cell selection allowing, you must either implement the TableAllowCellSelection interface
// in the table adapter or assign its separate implementation to the "allow-selection" property.
type TableAllowCellSelection interface {
@@ -55,7 +60,9 @@ type TableAllowCellSelection interface {
}
// TableAllowRowSelection determines whether [TableView] row selection is allowed.
+//
// It is only used if the "selection-mode" property is set to RowSelection (2).
+//
// To set row selection allowing, you must either implement the TableAllowRowSelection interface
// in the table adapter or assign its separate implementation to the "allow-selection" property.
type TableAllowRowSelection interface {
@@ -65,6 +72,7 @@ type TableAllowRowSelection interface {
// SimpleTableAdapter is implementation of [TableAdapter] where the content
// defines as [][]any.
+//
// When you assign [][]any value to the "content" property, it is converted to SimpleTableAdapter
type SimpleTableAdapter interface {
TableAdapter
diff --git a/tableView.go b/tableView.go
index ca74885..322f20e 100644
--- a/tableView.go
+++ b/tableView.go
@@ -10,519 +10,527 @@ import (
const (
// TableVerticalAlign is the constant for "table-vertical-align" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the vertical alignment of the content inside a table cell.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`TopAlign`) or "top" - Top alignment.
- // `1`(`BottomAlign`) or "bottom" - Bottom alignment.
- // `2`(`CenterAlign`) or "center" - Center alignment.
- // `3`(`StretchAlign`) or "stretch" - Work as baseline alignment, see below.
- // `4`(`BaselineAlign`) or "baseline" - Baseline alignment.
+ // - 0 (TopAlign) or "top" - Top alignment.
+ // - 1 (BottomAlign) or "bottom" - Bottom alignment.
+ // - 2 (CenterAlign) or "center" - Center alignment.
+ // - 3 (StretchAlign) or "stretch" - Work as baseline alignment, see below.
+ // - 4 (BaselineAlign) or "baseline" - Baseline alignment.
TableVerticalAlign PropertyName = "table-vertical-align"
// HeadHeight is the constant for "head-height" property tag.
//
- // Used by `TableView`.
- // Sets the number of rows in the table header. The default value is `0` (no header).
+ // Used by TableView.
+ // Sets the number of rows in the table header. The default value is 0 (no header).
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0` or "0" - No header.
- // > `0` or > "0" - Number of rows act as a header.
+ // - 0 or "0" - No header.
+ // - positive value - Number of rows act as a header.
HeadHeight PropertyName = "head-height"
// HeadStyle is the constant for "head-style" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the header style name or description of style properties.
//
- // Supported types: `string`, `Params`.
+ // Supported types: string, Params.
//
- // Internal type is either `string` or `Params`.
+ // Internal type is either string or Params.
//
// Conversion rules:
- // `string` - must contain style name defined in resources.
- // `Params` - must contain style properties.
+ // - string - must contain style name defined in resources.
+ // - Params - must contain style properties.
HeadStyle PropertyName = "head-style"
// FootHeight is the constant for "foot-height" property tag.
//
- // Used by `TableView`.
- // Sets the number of rows in the table footer. The default value is `0` (no footer).
+ // Used by TableView.
+ // Sets the number of rows in the table footer. The default value is 0 (no footer).
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0` or "0" - No footer.
- // > `0` or > "0" - Number of rows act as a footer.
+ // - 0 or "0" - No footer.
+ // - positive value - Number of rows act as a footer.
FootHeight PropertyName = "foot-height"
// FootStyle is the constant for "foot-style" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the footer style name or description of style properties.
//
- // Supported types: `string`, `Params`.
+ // Supported types: string, Params.
//
- // Internal type is either `string` or `Params`.
+ // Internal type is either string or Params.
//
// Conversion rules:
- // `string` - must contain style name defined in resources.
- // `Params` - must contain style properties.
+ // - string - must contain style name defined in resources.
+ // - Params - must contain style properties.
FootStyle PropertyName = "foot-style"
// RowSpan is the constant for "row-span" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the number of table row to span. Used only when specifying cell parameters in the implementation of
- // `TableCellStyle`.
+ // TableCellStyle.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0` or "0" - No merging will be applied.
- // > `0` or > "0" - Number of rows including current one to be merged together.
+ // - 0 or "0" - No merging will be applied.
+ // - positive value - Number of rows including current one to be merged together.
RowSpan PropertyName = "row-span"
// ColumnSpan is the constant for "column-span" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Sets the number of table column cells to be merged together. Used only when specifying cell parameters in the
- // implementation of `TableCellStyle`.
+ // implementation of TableCellStyle.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0` or "0" - No merging will be applied.
- // > `0` or > "0" - Number of columns including current one to be merged together.
+ // - 0 or "0" - No merging will be applied.
+ // - positive value - Number of columns including current one to be merged together.
ColumnSpan PropertyName = "column-span"
// RowStyle is the constant for "row-style" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the adapter which specifies styles of each table row.
//
- // Supported types: `TableRowStyle`, `[]Params`.
+ // Supported types: TableRowStyle, []Params.
//
- // Internal type is `TableRowStyle`, other types converted to it during assignment.
- // See `TableRowStyle` description for more details.
+ // Internal type is TableRowStyle, other types converted to it during assignment.
+ // See TableRowStyle description for more details.
RowStyle PropertyName = "row-style"
// ColumnStyle is the constant for "column-style" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the adapter which specifies styles of each table column.
//
- // Supported types: `TableColumnStyle`, `[]Params`.
+ // Supported types: TableColumnStyle, []Params.
//
- // Internal type is `TableColumnStyle`, other types converted to it during assignment.
- // See `TableColumnStyle` description for more details.
+ // Internal type is TableColumnStyle, other types converted to it during assignment.
+ // See TableColumnStyle description for more details.
ColumnStyle PropertyName = "column-style"
// CellStyle is the constant for "cell-style" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the adapter which specifies styles of each table cell. This property can be assigned only by an implementation of
- // `TableCellStyle` interface.
+ // TableCellStyle interface.
//
- // Supported types: `TableCellStyle`.
+ // Supported types: TableCellStyle.
CellStyle PropertyName = "cell-style"
// CellPadding is the constant for "cell-padding" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Sets the padding area on all four sides of a table cell at once. An element's padding area is the space between its
// content and its border.
//
- // Supported types: `BoundsProperty`, `Bounds`, `SizeUnit`, `float32`, `float64`, `int`.
+ // Supported types: BoundsProperty, Bounds, SizeUnit, float32, float64, int.
//
- // Internal type is `BoundsProperty`, other types converted to it during assignment.
- // See `BoundsProperty`, `Bounds` and `SizeUnit` description for more details.
+ // Internal type is BoundsProperty, other types converted to it during assignment.
+ // See BoundsProperty, Bounds and SizeUnit description for more details.
CellPadding PropertyName = "cell-padding"
// CellPaddingLeft is the constant for "cell-padding-left" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the width of the padding area to the left of a cell content. An element's padding area is the space between its
// content and its border.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
CellPaddingLeft PropertyName = "cell-padding-left"
// CellPaddingRight is the constant for "cell-padding-right" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the width of the padding area to the left of a cell content. An element's padding area is the space between its
// content and its border.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
CellPaddingRight PropertyName = "cell-padding-right"
// CellPaddingTop is the constant for "cell-padding-top" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the height of the padding area to the top of a cell content. An element's padding area is the space between its
// content and its border.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
CellPaddingTop PropertyName = "cell-padding-top"
// CellPaddingBottom is the constant for "cell-padding-bottom" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the height of the padding area to the bottom of a cell content.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
CellPaddingBottom PropertyName = "cell-padding-bottom"
// CellBorder is the constant for "cell-border" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set a table cell's border. It sets the values of a border width, style, and color. Can also be used when setting
// parameters in properties "row-style", "column-style", "foot-style" and "head-style".
//
- // Supported types: `BorderProperty`, `ViewBorder`, `ViewBorders`.
+ // Supported types: BorderProperty, ViewBorder, ViewBorders.
//
- // Internal type is `BorderProperty`, other types converted to it during assignment.
- // See `BorderProperty`, `ViewBorder` and `ViewBorders` description for more details.
+ // Internal type is BorderProperty, other types converted to it during assignment.
+ // See BorderProperty, ViewBorder and ViewBorders description for more details.
CellBorder PropertyName = "cell-border"
// CellBorderLeft is the constant for "cell-border-left" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set a view's left border. It sets the values of a border width, style, and color. This property can be assigned a value
- // of `BorderProperty`, `ViewBorder` types or `BorderProperty` text representation.
+ // of BorderProperty, ViewBorder types or BorderProperty text representation.
//
- // Supported types: `ViewBorder`, `BorderProperty`, `string`.
+ // Supported types: ViewBorder, BorderProperty, string.
//
- // Internal type is `BorderProperty`, other types converted to it during assignment.
- // See `ViewBorder` and `BorderProperty` description for more details.
+ // Internal type is BorderProperty, other types converted to it during assignment.
+ // See ViewBorder and BorderProperty description for more details.
CellBorderLeft PropertyName = "cell-border-left"
// CellBorderRight is the constant for "cell-border-right" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set a view's right border. It sets the values of a border width, style, and color. This property can be assigned a
- // value of `BorderProperty`, `ViewBorder` types or `BorderProperty` text representation.
+ // value of BorderProperty, ViewBorder types or BorderProperty text representation.
//
- // Supported types: `ViewBorder`, `BorderProperty`, `string`.
+ // Supported types: ViewBorder, BorderProperty, string.
//
- // Internal type is `BorderProperty`, other types converted to it during assignment.
- // See `ViewBorder` and `BorderProperty` description for more details.
+ // Internal type is BorderProperty, other types converted to it during assignment.
+ // See ViewBorder and BorderProperty description for more details.
CellBorderRight PropertyName = "cell-border-right"
// CellBorderTop is the constant for "cell-border-top" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set a view's top border. It sets the values of a border width, style, and color. This property can be assigned a value
- // of `BorderProperty`, `ViewBorder` types or `BorderProperty` text representation.
+ // of BorderProperty, ViewBorder types or BorderProperty text representation.
//
- // Supported types: `ViewBorder`, `BorderProperty`, `string`.
+ // Supported types: ViewBorder, BorderProperty, string.
//
- // Internal type is `BorderProperty`, other types converted to it during assignment.
- // See `ViewBorder` and `BorderProperty` description for more details.
+ // Internal type is BorderProperty, other types converted to it during assignment.
+ // See ViewBorder and BorderProperty description for more details.
CellBorderTop PropertyName = "cell-border-top"
// CellBorderBottom is the constant for "cell-border-bottom" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set a view's bottom border. It sets the values of a border width, style, and color.
//
- // Supported types: `ViewBorder`, `BorderProperty`, `string`.
+ // Supported types: ViewBorder, BorderProperty, string.
//
- // Internal type is `BorderProperty`, other types converted to it during assignment.
- // See `ViewBorder` and `BorderProperty` description for more details.
+ // Internal type is BorderProperty, other types converted to it during assignment.
+ // See ViewBorder and BorderProperty description for more details.
CellBorderBottom PropertyName = "cell-border-bottom"
// CellBorderStyle is the constant for "cell-border-style" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the line style for all four sides of a table cell's border. Default value is "none".
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneLine`) or "none" - The border will not be drawn.
- // `1`(`SolidLine`) or "solid" - Solid line as a border.
- // `2`(`DashedLine`) or "dashed" - Dashed line as a border.
- // `3`(`DottedLine`) or "dotted" - Dotted line as a border.
- // `4`(`DoubleLine`) or "double" - Double line as a border.
+ // - 0 (NoneLine) or "none" - The border will not be drawn.
+ // - 1 (SolidLine) or "solid" - Solid line as a border.
+ // - 2 (DashedLine) or "dashed" - Dashed line as a border.
+ // - 3 (DottedLine) or "dotted" - Dotted line as a border.
+ // - 4 (DoubleLine) or "double" - Double line as a border.
CellBorderStyle PropertyName = "cell-border-style"
// CellBorderLeftStyle is the constant for "cell-border-left-style" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the line style of a table cell's left border. Default value is "none".
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneLine`) or "none" - The border will not be drawn.
- // `1`(`SolidLine`) or "solid" - Solid line as a border.
- // `2`(`DashedLine`) or "dashed" - Dashed line as a border.
- // `3`(`DottedLine`) or "dotted" - Dotted line as a border.
- // `4`(`DoubleLine`) or "double" - Double line as a border.
+ // - 0 (NoneLine) or "none" - The border will not be drawn.
+ // - 1 (SolidLine) or "solid" - Solid line as a border.
+ // - 2 (DashedLine) or "dashed" - Dashed line as a border.
+ // - 3 (DottedLine) or "dotted" - Dotted line as a border.
+ // - 4 (DoubleLine) or "double" - Double line as a border.
CellBorderLeftStyle PropertyName = "cell-border-left-style"
// CellBorderRightStyle is the constant for "cell-border-right-style" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the line style of a table cell's right border. Default value is "none".
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneLine`) or "none" - The border will not be drawn.
- // `1`(`SolidLine`) or "solid" - Solid line as a border.
- // `2`(`DashedLine`) or "dashed" - Dashed line as a border.
- // `3`(`DottedLine`) or "dotted" - Dotted line as a border.
- // `4`(`DoubleLine`) or "double" - Double line as a border.
+ // - 0 (NoneLine) or "none" - The border will not be drawn.
+ // - 1 (SolidLine) or "solid" - Solid line as a border.
+ // - 2 (DashedLine) or "dashed" - Dashed line as a border.
+ // - 3 (DottedLine) or "dotted" - Dotted line as a border.
+ // - 4 (DoubleLine) or "double" - Double line as a border.
CellBorderRightStyle PropertyName = "cell-border-right-style"
// CellBorderTopStyle is the constant for "cell-border-top-style" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the line style of a table cell's top border. Default value is "none".
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneLine`) or "none" - The border will not be drawn.
- // `1`(`SolidLine`) or "solid" - Solid line as a border.
- // `2`(`DashedLine`) or "dashed" - Dashed line as a border.
- // `3`(`DottedLine`) or "dotted" - Dotted line as a border.
- // `4`(`DoubleLine`) or "double" - Double line as a border.
+ // - 0 (NoneLine) or "none" - The border will not be drawn.
+ // - 1 (SolidLine) or "solid" - Solid line as a border.
+ // - 2 (DashedLine) or "dashed" - Dashed line as a border.
+ // - 3 (DottedLine) or "dotted" - Dotted line as a border.
+ // - 4 (DoubleLine) or "double" - Double line as a border.
CellBorderTopStyle PropertyName = "cell-border-top-style"
// CellBorderBottomStyle is the constant for "cell-border-bottom-style" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Sets the line style of a table cell's bottom border. Default value is "none".
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneLine`) or "none" - The border will not be drawn.
- // `1`(`SolidLine`) or "solid" - Solid line as a border.
- // `2`(`DashedLine`) or "dashed" - Dashed line as a border.
- // `3`(`DottedLine`) or "dotted" - Dotted line as a border.
- // `4`(`DoubleLine`) or "double" - Double line as a border.
+ // - 0 (NoneLine) or "none" - The border will not be drawn.
+ // - 1 (SolidLine) or "solid" - Solid line as a border.
+ // - 2 (DashedLine) or "dashed" - Dashed line as a border.
+ // - 3 (DottedLine) or "dotted" - Dotted line as a border.
+ // - 4 (DoubleLine) or "double" - Double line as a border.
CellBorderBottomStyle PropertyName = "cell-border-bottom-style"
// CellBorderWidth is the constant for "cell-border-width" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the line width for all four sides of a table cell's border.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
CellBorderWidth PropertyName = "cell-border-width"
// CellBorderLeftWidth is the constant for "cell-border-left-width" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the line width of a table cell's left border.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
CellBorderLeftWidth PropertyName = "cell-border-left-width"
// CellBorderRightWidth is the constant for "cell-border-right-width" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the line width of a table cell's right border.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
CellBorderRightWidth PropertyName = "cell-border-right-width"
// CellBorderTopWidth is the constant for "cell-border-top-width" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the line width of a table cell's top border.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
CellBorderTopWidth PropertyName = "cell-border-top-width"
// CellBorderBottomWidth is the constant for "cell-border-bottom-width" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the line width of a table cell's bottom border.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
CellBorderBottomWidth PropertyName = "cell-border-bottom-width"
// CellBorderColor is the constant for "cell-border-color" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the line color for all four sides of a table cell's border.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See Color description for more details.
CellBorderColor PropertyName = "cell-border-color"
// CellBorderLeftColor is the constant for "cell-border-left-color" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the line color of a table cell's left border.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See Color description for more details.
CellBorderLeftColor PropertyName = "cell-border-left-color"
// CellBorderRightColor is the constant for "cell-border-right-color" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the line color of a table cell's right border.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See Color description for more details.
CellBorderRightColor PropertyName = "cell-border-right-color"
// CellBorderTopColor is the constant for "cell-border-top-color" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the line color of a table cell's top border.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See Color description for more details.
CellBorderTopColor PropertyName = "cell-border-top-color"
// CellBorderBottomColor is the constant for "cell-border-bottom-color" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the line color of a table cell's bottom border.
//
- // Supported types: `Color`, `string`.
+ // Supported types: Color, string.
//
- // Internal type is `Color`, other types converted to it during assignment.
- // See `Color` description for more details.
+ // Internal type is Color, other types converted to it during assignment.
+ // See Color description for more details.
CellBorderBottomColor PropertyName = "cell-border-bottom-color"
// SelectionMode is the constant for "selection-mode" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Sets the mode of the table elements selection. Default value is "none".
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`NoneSelection`) or "none" - Table elements are not selectable. The table cannot receive input focus.
- // `1`(`CellSelection`) or "cell" - One table cell can be selected(highlighted). The cell is selected interactively using the mouse or keyboard(using the cursor keys).
- // `2`(`RowSelection`) or "row" - The entire table row can be selected (highlighted). The row is selected interactively using the mouse or keyboard (using the cursor keys).
+ // - 0 (NoneSelection) or "none" - Table elements are not selectable. The table cannot receive input focus.
+ // - 1 (CellSelection) or "cell" - One table cell can be selected(highlighted). The cell is selected interactively using the mouse or keyboard(using the cursor keys).
+ // - 2 (RowSelection) or "row" - The entire table row can be selected (highlighted). The row is selected interactively using the mouse or keyboard (using the cursor keys).
SelectionMode PropertyName = "selection-mode"
// TableCellClickedEvent is the constant for "table-cell-clicked" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Occur when the user clicks on a table cell.
//
// General listener format:
- // `func(table rui.TableView, row, col int)`.
+ //
+ // func(table rui.TableView, row, col int)
//
// where:
- // table - Interface of a table view which generated this event,
- // row - Row of the clicked cell,
- // col - Column of the clicked cell.
+ // - table - Interface of a table view which generated this event,
+ // - row - Row of the clicked cell,
+ // - col - Column of the clicked cell.
//
// Allowed listener formats:
- // `func(row, col int)`.
+ //
+ // func(row, col int)
TableCellClickedEvent PropertyName = "table-cell-clicked"
// TableCellSelectedEvent is the constant for "table-cell-selected" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Occur when a table cell becomes selected.
//
// General listener format:
- // `func(table rui.TableView, row, col int)`.
+ //
+ // func(table rui.TableView, row, col int)
//
// where:
- // table - Interface of a table view which generated this event,
- // row - Row of the selected cell,
- // col - Column of the selected cell.
+ // - table - Interface of a table view which generated this event,
+ // - row - Row of the selected cell,
+ // - col - Column of the selected cell.
//
// Allowed listener formats:
- // `func(row, col int)`.
+ //
+ // func(row, col int)
TableCellSelectedEvent PropertyName = "table-cell-selected"
// TableRowClickedEvent is the constant for "table-row-clicked" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Occur when the user clicks on a table row.
//
// General listener format:
- // `func(table rui.TableView, row int)`.
+ //
+ // func(table rui.TableView, row int)
//
// where:
- // table - Interface of a table view which generated this event,
- // row - Clicked row.
+ // - table - Interface of a table view which generated this event,
+ // - row - Clicked row.
//
// Allowed listener formats:
- // `func(row int)`.
+ //
+ // func(row int)
TableRowClickedEvent PropertyName = "table-row-clicked"
// TableRowSelectedEvent is the constant for "table-row-selected" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Occur when a table row becomes selected.
//
// General listener format:
- // `func(table rui.TableView, row int)`.
+ //
+ // func(table rui.TableView, row int)
//
// where:
- // table - Interface of a table view which generated this event,
- // row - Selected row.
+ // - table - Interface of a table view which generated this event,
+ // - row - Selected row.
//
// Allowed listener formats:
- // `func(row int)`.
+ //
+ // func(row int)
TableRowSelectedEvent PropertyName = "table-row-selected"
// AllowSelection is the constant for "allow-selection" property tag.
//
- // Used by `TableView`.
+ // Used by TableView.
// Set the adapter which specifies whether cell/row selection is allowed. This property can be assigned by an
- // implementation of `TableAllowCellSelection` or `TableAllowRowSelection` interface.
+ // implementation of TableAllowCellSelection or TableAllowRowSelection interface.
//
- // Supported types: `TableAllowCellSelection`, `TableAllowRowSelection`.
+ // Supported types: TableAllowCellSelection, TableAllowRowSelection.
//
- // Internal type is either `TableAllowCellSelection`, `TableAllowRowSelection`, see their description for more details.
+ // Internal type is either TableAllowCellSelection, TableAllowRowSelection, see their description for more details.
AllowSelection PropertyName = "allow-selection"
)
diff --git a/tabsLayout.go b/tabsLayout.go
index 1e00a3e..99de2c7 100644
--- a/tabsLayout.go
+++ b/tabsLayout.go
@@ -9,104 +9,108 @@ import (
const (
// CurrentTabChangedEvent is the constant for "current-tab-changed" property tag.
//
- // Used by `TabsLayout`.
+ // Used by TabsLayout.
// Occur when the new tab becomes active.
//
// General listener format:
- // `func(tabsLayout rui.TabsLayout, newTab, oldTab int)`.
+ //
+ // func(tabsLayout rui.TabsLayout, newTab, oldTab int)
//
// where:
- // tabsLayout - Interface of a tabs layout which generated this event,
- // newTab - Index of a new active tab,
- // oldTab - Index of an old active tab.
+ // - tabsLayout - Interface of a tabs layout which generated this event,
+ // - newTab - Index of a new active tab,
+ // - oldTab - Index of an old active tab.
//
// Allowed listener formats:
- // `func(tabsLayout rui.TabsLayout, newTab int)`,
- // `func(newTab, oldTab int)`,
- // `func(newTab int)`,
- // `func()`.
+ //
+ // func(tabsLayout rui.TabsLayout, newTab int)
+ // func(newTab, oldTab int)
+ // func(newTab int)
+ // func()
CurrentTabChangedEvent PropertyName = "current-tab-changed"
// Icon is the constant for "icon" property tag.
//
- // Used by `TabsLayout`.
- // Defines the icon name that is displayed in the tab. The property is set for the child view of `TabsLayout`.
+ // Used by TabsLayout.
+ // Defines the icon name that is displayed in the tab. The property is set for the child view of TabsLayout.
//
- // Supported types: `string`.
+ // Supported types: string.
Icon = "icon"
// TabCloseButton is the constant for "tab-close-button" property tag.
//
- // Used by `TabsLayout`.
+ // Used by TabsLayout.
// Controls whether to add close button to a tab(s). This property can be set separately for each child view or for tabs
// layout itself. Property set for child view takes precedence over the value set for tabs layout. Default value is
- // `false`.
+ // false.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - Tab(s) has close button.
- // `false` or `0` or "false", "no", "off", "0" - No close button in tab(s).
+ // - true, 1, "true", "yes", "on", "1" - Tab(s) has close button.
+ // - false, 0, "false", "no", "off", "0" - No close button in tab(s).
TabCloseButton PropertyName = "tab-close-button"
// TabCloseEvent is the constant for "tab-close-event" property tag.
//
- // Used by `TabsLayout`.
+ // Used by TabsLayout.
// Occurs when the user clicks on the tab close button.
//
// General listener format:
- // `func(tabsLayout rui.TabsLayout, tab int)`.
+ //
+ // func(tabsLayout rui.TabsLayout, tab int)
//
// where:
- // tabsLayout - Interface of a tabs layout which generated this event,
- // tab - Index of the tab.
+ // - tabsLayout - Interface of a tabs layout which generated this event,
+ // - tab - Index of the tab.
//
// Allowed listener formats:
- // `func(tab int)`,
- // `func(tabsLayout rui.TabsLayout)`,
- // `func()`.
+ //
+ // func(tab int)
+ // func(tabsLayout rui.TabsLayout)
+ // func()
TabCloseEvent PropertyName = "tab-close-event"
// Tabs is the constant for "tabs" property tag.
//
- // Used by `TabsLayout`.
+ // Used by TabsLayout.
// Sets where the tabs are located. Default value is "top".
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // `0`(`TopTabs`) or "top" - Tabs on the top.
- // `1`(`BottomTabs`) or "bottom" - Tabs on the bottom.
- // `2`(`LeftTabs`) or "left" - Tabs on the left. Each tab is rotated 90° counterclockwise.
- // `3`(`RightTabs`) or "right" - Tabs located on the right. Each tab is rotated 90° clockwise.
- // `4`(`LeftListTabs`) or "left-list" - Tabs on the left. The tabs are displayed as a list.
- // `5`(`RightListTabs`) or "right-list" - Tabs on the right. The tabs are displayed as a list.
- // `6`(`HiddenTabs`) or "hidden" - Tabs are hidden.
+ // - 0 (TopTabs) or "top" - Tabs on the top.
+ // - 1 (BottomTabs) or "bottom" - Tabs on the bottom.
+ // - 2 (LeftTabs) or "left" - Tabs on the left. Each tab is rotated 90° counterclockwise.
+ // - 3 (RightTabs) or "right" - Tabs located on the right. Each tab is rotated 90° clockwise.
+ // - 4 (LeftListTabs) or "left-list" - Tabs on the left. The tabs are displayed as a list.
+ // - 5 (RightListTabs) or "right-list" - Tabs on the right. The tabs are displayed as a list.
+ // - 6 (HiddenTabs) or "hidden" - Tabs are hidden.
Tabs PropertyName = "tabs"
// TabBarStyle is the constant for "tab-bar-style" property tag.
//
- // Used by `TabsLayout`.
+ // Used by TabsLayout.
// Set the style for the display of the tab bar. The default value is "ruiTabBar".
//
- // Supported types: `string`.
+ // Supported types: string.
TabBarStyle PropertyName = "tab-bar-style"
// TabStyle is the constant for "tab-style" property tag.
//
- // Used by `TabsLayout`.
+ // Used by TabsLayout.
// Set the style for the display of the tab. The default value is "ruiTab" or "ruiVerticalTab".
//
- // Supported types: `string`.
+ // Supported types: string.
TabStyle PropertyName = "tab-style"
// CurrentTabStyle is the constant for "current-tab-style" property tag.
//
- // Used by `TabsLayout`.
+ // Used by TabsLayout.
// Set the style for the display of the current(selected) tab. The default value is "ruiCurrentTab" or
// "ruiCurrentVerticalTab".
//
- // Supported types: `string`.
+ // Supported types: string.
CurrentTabStyle PropertyName = "current-tab-style"
inactiveTabStyle = "data-inactiveTabStyle"
diff --git a/timePicker.go b/timePicker.go
index 3652dd5..7db5be1 100644
--- a/timePicker.go
+++ b/timePicker.go
@@ -10,85 +10,85 @@ import (
const (
// TimeChangedEvent is the constant for "time-changed" property tag.
//
- // Used by `TimePicker`.
+ // Used by TimePicker.
// Occur when current time of the time picker has been changed.
//
// General listener format:
- // `func(picker rui.TimePicker, newTime, oldTime time.Time)`.
+ // func(picker rui.TimePicker, newTime time.Time, oldTime time.Time).
//
// where:
- // picker - Interface of a time picker which generated this event,
- // newTime - New time value,
- // oldTime - Old time value.
+ // - picker - Interface of a time picker which generated this event,
+ // - newTime - New time value,
+ // - oldTime - Old time value.
//
// Allowed listener formats:
- // `func(picker rui.TimePicker, newTime time.Time)`,
- // `func(newTime, oldTime time.Time)`,
- // `func(newTime time.Time)`,
- // `func(picker rui.TimePicker)`,
- // `func()`.
+ // func(picker rui.TimePicker, newTime time.Time),
+ // func(newTime time.Time, oldTime time.Time),
+ // func(newTime time.Time),
+ // func(picker rui.TimePicker),
+ // func().
TimeChangedEvent PropertyName = "time-changed"
// TimePickerMin is the constant for "time-picker-min" property tag.
//
- // Used by `TimePicker`.
+ // Used by TimePicker.
// The minimum value of the time.
//
- // Supported types: `time.Time`, `string`.
+ // Supported types: time.Time, string.
//
- // Internal type is `time.Time`, other types converted to it during assignment.
+ // Internal type is time.Time, other types converted to it during assignment.
//
// Conversion rules:
- // `string` - values of this type parsed and converted to `time.Time`. The following formats are supported:
- // "HH:MM:SS" - "08:15:00".
- // "HH:MM:SS PM" - "08:15:00 AM".
- // "HH:MM" - "08:15".
- // "HH:MM PM" - "08:15 AM".
+ // string - values of this type parsed and converted to time.Time. The following formats are supported:
+ // - "HH:MM:SS" - "08:15:00".
+ // - "HH:MM:SS PM" - "08:15:00 AM".
+ // - "HH:MM" - "08:15".
+ // - "HH:MM PM" - "08:15 AM".
TimePickerMin PropertyName = "time-picker-min"
// TimePickerMax is the constant for "time-picker-max" property tag.
//
- // Used by `TimePicker`.
+ // Used by TimePicker.
// The maximum value of the time.
//
- // Supported types: `time.Time`, `string`.
+ // Supported types: time.Time, string.
//
- // Internal type is `time.Time`, other types converted to it during assignment.
+ // Internal type is time.Time, other types converted to it during assignment.
//
// Conversion rules:
- // `string` - values of this type parsed and converted to `time.Time`. The following formats are supported:
- // "HH:MM:SS" - "08:15:00".
- // "HH:MM:SS PM" - "08:15:00 AM".
- // "HH:MM" - "08:15".
- // "HH:MM PM" - "08:15 AM".
+ // string - values of this type parsed and converted to time.Time. The following formats are supported:
+ // - "HH:MM:SS" - "08:15:00".
+ // - "HH:MM:SS PM" - "08:15:00 AM".
+ // - "HH:MM" - "08:15".
+ // - "HH:MM PM" - "08:15 AM".
TimePickerMax PropertyName = "time-picker-max"
// TimePickerStep is the constant for "time-picker-step" property tag.
//
- // Used by `TimePicker`.
+ // Used by TimePicker.
// Time step in seconds.
//
- // Supported types: `int`, `string`.
+ // Supported types: int, string.
//
// Values:
- // >= `0` or >= "0" - Step value in seconds used to increment or decrement time.
+ // positive value - Step value in seconds used to increment or decrement time.
TimePickerStep PropertyName = "time-picker-step"
// TimePickerValue is the constant for "time-picker-value" property tag.
//
- // Used by `TimePicker`.
+ // Used by TimePicker.
// Current value.
//
- // Supported types: `time.Time`, `string`.
+ // Supported types: time.Time, string.
//
- // Internal type is `time.Time`, other types converted to it during assignment.
+ // Internal type is time.Time, other types converted to it during assignment.
//
// Conversion rules:
- // `string` - values of this type parsed and converted to `time.Time`. The following formats are supported:
- // "HH:MM:SS" - "08:15:00".
- // "HH:MM:SS PM" - "08:15:00 AM".
- // "HH:MM" - "08:15".
- // "HH:MM PM" - "08:15 AM".
+ // string - values of this type parsed and converted to time.Time. The following formats are supported:
+ // - "HH:MM:SS" - "08:15:00".
+ // - "HH:MM:SS PM" - "08:15:00 AM".
+ // - "HH:MM" - "08:15".
+ // - "HH:MM PM" - "08:15 AM".
TimePickerValue PropertyName = "time-picker-value"
timeFormat = "15:04:05"
diff --git a/touchEvents.go b/touchEvents.go
index 93230c2..ccf91b5 100644
--- a/touchEvents.go
+++ b/touchEvents.go
@@ -8,75 +8,83 @@ import (
const (
// TouchStart is the constant for "touch-start" property tag.
//
- // Used by `View`.
+ // Used by View.
// Is fired when one or more touch points are placed on the touch surface.
//
// General listener format:
- // `func(view rui.View, event rui.TouchEvent)`.
+ //
+ // func(view rui.View, event rui.TouchEvent)
//
// where:
- // view - Interface of a view which generated this event,
- // event - Touch event.
+ // - view - Interface of a view which generated this event,
+ // - event - Touch event.
//
// Allowed listener formats:
- // `func(event rui.TouchEvent)`,
- // `func(view rui.View)`,
- // `func()`.
+ //
+ // func(event rui.TouchEvent)
+ // func(view rui.View)
+ // func()
TouchStart PropertyName = "touch-start"
// TouchEnd is the constant for "touch-end" property tag.
//
- // Used by `View`.
+ // Used by View.
// Fired when one or more touch points are removed from the touch surface.
//
// General listener format:
- // `func(view rui.View, event rui.TouchEvent)`.
+ //
+ // func(view rui.View, event rui.TouchEvent)
//
// where:
- // view - Interface of a view which generated this event,
- // event - Touch event.
+ // - view - Interface of a view which generated this event,
+ // - event - Touch event.
//
// Allowed listener formats:
- // `func(event rui.TouchEvent)`,
- // `func(view rui.View)`,
- // `func()`.
+ //
+ // func(event rui.TouchEvent)
+ // func(view rui.View)
+ // func()
TouchEnd PropertyName = "touch-end"
// TouchMove is the constant for "touch-move" property tag.
//
- // Used by `View`.
+ // Used by View.
// Is fired when one or more touch points are moved along the touch surface.
//
// General listener format:
- // `func(view rui.View, event rui.TouchEvent)`.
+ //
+ // func(view rui.View, event rui.TouchEvent)
//
// where:
- // view - Interface of a view which generated this event,
- // event - Touch event.
+ // - view - Interface of a view which generated this event,
+ // - event - Touch event.
//
// Allowed listener formats:
- // `func(event rui.TouchEvent)`,
- // `func(view rui.View)`,
- // `func()`.
+ //
+ // func(event rui.TouchEvent)
+ // func(view rui.View)
+ // func()
TouchMove PropertyName = "touch-move"
// TouchCancel is the constant for "touch-cancel" property tag.
//
- // Used by `View`.
+ // Used by View.
// Is fired when one or more touch points have been disrupted in an implementation-specific manner (for example, too many
// touch points are created).
//
// General listener format:
- // `func(view rui.View, event rui.TouchEvent)`.
+ //
+ // func(view rui.View, event rui.TouchEvent)
//
// where:
- // view - Interface of a view which generated this event,
- // event - Touch event.
+ // - view - Interface of a view which generated this event,
+ // - event - Touch event.
//
// Allowed listener formats:
- // `func(event rui.TouchEvent)`,
- // `func(view rui.View)`,
- // `func()`.
+ //
+ // func(event rui.TouchEvent)
+ // func(view rui.View)
+ // func()
TouchCancel PropertyName = "touch-cancel"
)
diff --git a/transform.go b/transform.go
index 5ecfa32..8b862fb 100644
--- a/transform.go
+++ b/transform.go
@@ -10,385 +10,263 @@ import (
const (
// Transform is the constant for "transform" property tag.
//
- // Used by `View`.
+ // Used by View.
// Specify translation, scale and rotation over x, y and z axes as well as a distortion of a view along x and y axes.
//
- // Supported types: `TransformProperty`, `string`.
+ // Supported types: TransformProperty, string.
//
- // See `TransformProperty` description for more details.
+ // See TransformProperty description for more details.
//
// Conversion rules:
- // `TransformProperty` - stored as is, no conversion performed.
- // `string` - string representation of `TransformProperty` interface. Example: "_{translate-x = 10px, scale-y = 1.1}".
+ // - TransformProperty - stored as is, no conversion performed.
+ // - string - string representation of TransformProperty interface. Example: "_{translate-x = 10px, scale-y = 1.1}".
Transform PropertyName = "transform"
// Perspective is the constant for "perspective" property tag.
//
- // Used by `View`, `TransformProperty`.
+ // Used by View, TransformProperty.
// Distance between the z-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).
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
Perspective PropertyName = "perspective"
// PerspectiveOriginX is the constant for "perspective-origin-x" property tag.
//
- // Used by `View`.
+ // Used by View.
// x-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%.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
PerspectiveOriginX PropertyName = "perspective-origin-x"
// PerspectiveOriginY is the constant for "perspective-origin-y" property tag.
//
- // Used by `View`.
+ // Used by View.
// 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%.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
PerspectiveOriginY PropertyName = "perspective-origin-y"
// BackfaceVisible is the constant for "backface-visibility" property tag.
//
- // Used by `View`.
- // Controls whether the back face of a view is visible when turned towards the user. Default value is `true`.
+ // Used by View.
+ // Controls whether the back face of a view is visible when turned towards the user. Default value is true.
//
- // Supported types: `bool`, `int`, `string`.
+ // Supported types: bool, int, string.
//
// Values:
- // `true` or `1` or "true", "yes", "on", "1" - Back face is visible when turned towards the user.
- // `false` or `0` or "false", "no", "off", "0" - Back face is hidden, effectively making the view invisible when turned away from the user.
+ // - true, 1, "true", "yes", "on", "1" - Back face is visible when turned towards the user.
+ // - false, 0, "false", "no", "off", "0" - Back face is hidden, effectively making the view invisible when turned away from the user.
BackfaceVisible PropertyName = "backface-visibility"
// TransformOriginX is the constant for "transform-origin-x" property tag.
//
- // Used by `View`.
+ // Used by View.
// x-coordinate of the point around which a view transformation is applied. The default value is 50%.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
TransformOriginX PropertyName = "transform-origin-x"
// TransformOriginY is the constant for "transform-origin-y" property tag.
//
- // Used by `View`.
+ // Used by View.
// y-coordinate of the point around which a view transformation is applied. The default value is 50%.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
TransformOriginY PropertyName = "transform-origin-y"
// TransformOriginZ is the constant for "transform-origin-z" property tag.
//
- // Used by `View`.
+ // Used by View.
// z-coordinate of the point around which a view transformation is applied. The default value is 50%.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
TransformOriginZ PropertyName = "transform-origin-z"
// TranslateX is the constant for "translate-x" property tag.
//
- // Used by `View`, `TransformProperty`.
+ // Used by View, TransformProperty.
//
- // Usage in `View`:
// x-axis translation value of a 2D/3D translation.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
- //
- // Usage in `TransformProperty`:
- // x-axis translation value of a 2D/3D translation.
- //
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
- //
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
TranslateX PropertyName = "translate-x"
// TranslateY is the constant for "translate-y" property tag.
//
- // Used by `View`, `TransformProperty`.
+ // Used by View, TransformProperty.
//
- // Usage in `View`:
- // y-axis translation value of a 2D/3D translation.
- //
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
- //
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
- //
- // Usage in `TransformProperty`:
// x-axis translation value of a 2D/3D translation.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
TranslateY PropertyName = "translate-y"
// TranslateZ is the constant for "translate-z" property tag.
//
- // Used by `View`, `TransformProperty`.
+ // Used by View, TransformProperty.
//
- // Usage in `View`:
// z-axis translation value of a 3D translation.
//
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
+ // Supported types: SizeUnit, SizeFunc, string, float, int.
//
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
- //
- // Usage in `TransformProperty`:
- // z-axis translation value of a 3D translation.
- //
- // Supported types: `SizeUnit`, `SizeFunc`, `string`, `float`, `int`.
- //
- // Internal type is `SizeUnit`, other types converted to it during assignment.
- // See `SizeUnit` description for more details.
+ // Internal type is SizeUnit, other types converted to it during assignment.
+ // See SizeUnit description for more details.
TranslateZ PropertyName = "translate-z"
// ScaleX is the constant for "scale-x" property tag.
//
- // Used by `View`, `TransformProperty`.
+ // Used by View, TransformProperty.
//
- // Usage in `View`:
// x-axis scaling value of a 2D/3D scale. The original scale is 1. Values between 0 and 1 are used to decrease original
// scale, more than 1 - to increase. The default value is 1.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
- //
- // Usage in `TransformProperty`:
- // x-axis scaling value of a 2D/3D scale. The original scale is 1. Values between 0 and 1 are used to decrease original
- // scale, more than 1 - to increase. The default value is 1.
- //
- // Supported types: `float`, `int`, `string`.
- //
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
ScaleX PropertyName = "scale-x"
// ScaleY is the constant for "scale-y" property tag.
//
- // Used by `View`, `TransformProperty`.
+ // Used by View, TransformProperty.
//
- // Usage in `View`:
// y-axis scaling value of a 2D/3D scale. The original scale is 1. Values between 0 and 1 are used to decrease original
// scale, more than 1 - to increase. The default value is 1.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
- //
- // Usage in `TransformProperty`:
- // y-axis scaling value of a 2D/3D scale. The original scale is 1. Values between 0 and 1 are used to decrease original
- // scale, more than 1 - to increase. The default value is 1.
- //
- // Supported types: `float`, `int`, `string`.
- //
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
ScaleY PropertyName = "scale-y"
// ScaleZ is the constant for "scale-z" property tag.
//
- // Used by `View`, `TransformProperty`.
+ // Used by View, TransformProperty.
//
- // Usage in `View`:
// z-axis scaling value of a 3D scale. The original scale is 1. Values between 0 and 1 are used to decrease original
// scale, more than 1 - to increase. The default value is 1.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
- //
- // Usage in `TransformProperty`:
- // z-axis scaling value of a 3D scale. The original scale is 1. Values between 0 and 1 are used to decrease original
- // scale, more than 1 - to increase. The default value is 1.
- //
- // Supported types: `float`, `int`, `string`.
- //
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
ScaleZ PropertyName = "scale-z"
// Rotate is the constant for "rotate" property tag.
//
- // Used by `View`, `TransformProperty`.
+ // Used by View, TransformProperty.
//
- // Usage in `View`:
// Angle of the view rotation. A positive angle denotes a clockwise rotation, a negative angle a counter-clockwise.
//
- // Supported types: `AngleUnit`, `string`, `float`, `int`.
+ // Supported types: AngleUnit, string, float, int.
//
- // Internal type is `AngleUnit`, other types will be converted to it during assignment.
- // See `AngleUnit` description for more details.
+ // Internal type is AngleUnit, other types will be converted to it during assignment.
+ // See AngleUnit description for more details.
//
// Conversion rules:
- // `AngleUnit` - stored as is, no conversion performed.
- // `string` - must contain string representation of `AngleUnit`. If numeric value will be provided without any suffix then `AngleUnit` with value and `Radian` value type will be created.
- // `float` - a new `AngleUnit` value will be created with `Radian` as a type.
- // `int` - a new `AngleUnit` value will be created with `Radian` as a type.
- //
- // Usage in `TransformProperty`:
- // Angle of the view rotation. A positive angle denotes a clockwise rotation, a negative angle a counter-clockwise.
- //
- // Supported types: `AngleUnit`, `string`, `float`, `int`.
- //
- // Internal type is `AngleUnit`, other types will be converted to it during assignment.
- // See `AngleUnit` description for more details.
- //
- // Conversion rules:
- // `AngleUnit` - stored as is, no conversion performed.
- // `string` - must contain string representation of `AngleUnit`. If numeric value will be provided without any suffix then `AngleUnit` with value and `Radian` value type will be created.
- // `float` - a new `AngleUnit` value will be created with `Radian` as a type.
- // `int` - a new `AngleUnit` value will be created with `Radian` as a type.
+ // - AngleUnit - stored as is, no conversion performed.
+ // - string - must contain string representation of AngleUnit. If numeric value will be provided without any suffix then AngleUnit with value and Radian value type will be created.
+ // - float - a new AngleUnit value will be created with Radian as a type.
+ // - int - a new AngleUnit value will be created with Radian as a type.
Rotate PropertyName = "rotate"
// RotateX is the constant for "rotate-x" property tag.
//
- // Used by `View`, `TransformProperty`.
+ // Used by View, TransformProperty.
//
- // Usage in `View`:
// x-coordinate of the vector denoting the axis of rotation in range 0 to 1.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
- //
- // Usage in `TransformProperty`:
- // x-coordinate of the vector denoting the axis of rotation in range 0 to 1.
- //
- // Supported types: `float`, `int`, `string`.
- //
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
RotateX PropertyName = "rotate-x"
// RotateY is the constant for "rotate-y" property tag.
//
- // Used by `View`, `TransformProperty`.
+ // Used by View, TransformProperty.
//
- // Usage in `View`:
// y-coordinate of the vector denoting the axis of rotation in range 0 to 1.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
- //
- // Usage in `TransformProperty`:
- // y-coordinate of the vector denoting the axis of rotation in range 0 to 1.
- //
- // Supported types: `float`, `int`, `string`.
- //
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
RotateY PropertyName = "rotate-y"
// RotateZ is the constant for "rotate-z" property tag.
//
- // Used by `View`, `TransformProperty`.
+ // Used by View, TransformProperty.
//
- // Usage in `View`:
// z-coordinate of the vector denoting the axis of rotation in range 0 to 1.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
- //
- // Usage in `TransformProperty`:
- // z-coordinate of the vector denoting the axis of rotation in range 0 to 1.
- //
- // Supported types: `float`, `int`, `string`.
- //
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
RotateZ PropertyName = "rotate-z"
// SkewX is the constant for "skew-x" property tag.
//
- // Used by `View`, `TransformProperty`.
+ // Used by View, TransformProperty.
//
- // Usage in `View`:
// Angle to use to distort the element along the abscissa. The default value is 0.
//
- // Supported types: `AngleUnit`, `string`, `float`, `int`.
+ // Supported types: AngleUnit, string, float, int.
//
- // Internal type is `AngleUnit`, other types will be converted to it during assignment.
- // See `AngleUnit` description for more details.
+ // Internal type is AngleUnit, other types will be converted to it during assignment.
+ // See AngleUnit description for more details.
//
// Conversion rules:
- // `AngleUnit` - stored as is, no conversion performed.
- // `string` - must contain string representation of `AngleUnit`. If numeric value will be provided without any suffix then `AngleUnit` with value and `Radian` value type will be created.
- // `float` - a new `AngleUnit` value will be created with `Radian` as a type.
- // `int` - a new `AngleUnit` value will be created with `Radian` as a type.
- //
- // Usage in `TransformProperty`:
- // Angle to use to distort the element along the abscissa. The default value is 0.
- //
- // Supported types: `AngleUnit`, `string`, `float`, `int`.
- //
- // Internal type is `AngleUnit`, other types will be converted to it during assignment.
- // See `AngleUnit` description for more details.
- //
- // Conversion rules:
- // `AngleUnit` - stored as is, no conversion performed.
- // `string` - must contain string representation of `AngleUnit`. If numeric value will be provided without any suffix then `AngleUnit` with value and `Radian` value type will be created.
- // `float` - a new `AngleUnit` value will be created with `Radian` as a type.
- // `int` - a new `AngleUnit` value will be created with `Radian` as a type.
+ // - AngleUnit - stored as is, no conversion performed.
+ // - string - must contain string representation of AngleUnit. If numeric value will be provided without any suffix then AngleUnit with value and Radian value type will be created.
+ // - float - a new AngleUnit value will be created with Radian as a type.
+ // - int - a new AngleUnit value will be created with Radian as a type.
SkewX PropertyName = "skew-x"
// SkewY is the constant for "skew-y" property tag.
//
- // Used by `View`, `TransformProperty`.
+ // Used by View, TransformProperty.
//
- // Usage in `View`:
// Angle to use to distort the element along the ordinate. The default value is 0.
//
- // Supported types: `AngleUnit`, `string`, `float`, `int`.
+ // Supported types: AngleUnit, string, float, int.
//
- // Internal type is `AngleUnit`, other types will be converted to it during assignment.
- // See `AngleUnit` description for more details.
+ // Internal type is AngleUnit, other types will be converted to it during assignment.
+ // See AngleUnit description for more details.
//
// Conversion rules:
- // `AngleUnit` - stored as is, no conversion performed.
- // `string` - must contain string representation of `AngleUnit`. If numeric value will be provided without any suffix then `AngleUnit` with value and `Radian` value type will be created.
- // `float` - a new `AngleUnit` value will be created with `Radian` as a type.
- // `int` - a new `AngleUnit` value will be created with `Radian` as a type.
- //
- // Usage in `TransformProperty`:
- // Angle to use to distort the element along the ordinate. The default value is 0.
- //
- // Supported types: `AngleUnit`, `string`, `float`, `int`.
- //
- // Internal type is `AngleUnit`, other types will be converted to it during assignment.
- // See `AngleUnit` description for more details.
- //
- // Conversion rules:
- // `AngleUnit` - stored as is, no conversion performed.
- // `string` - must contain string representation of `AngleUnit`. If numeric value will be provided without any suffix then `AngleUnit` with value and `Radian` value type will be created.
- // `float` - a new `AngleUnit` value will be created with `Radian` as a type.
- // `int` - a new `AngleUnit` value will be created with `Radian` as a type.
+ // - AngleUnit - stored as is, no conversion performed.
+ // - string - must contain string representation of AngleUnit. If numeric value will be provided without any suffix then AngleUnit with value and Radian value type will be created.
+ // - float - a new AngleUnit value will be created with Radian as a type.
+ // - int - a new AngleUnit value will be created with Radian as a type.
SkewY PropertyName = "skew-y"
)
// TransformProperty interface specifies view transformation parameters: the x-, y-, and z-axis translation values,
// the x-, y-, and z-axis scaling values, the angle to use to distort the element along the abscissa and ordinate,
// the angle of the view rotation.
+//
// Valid property tags: Perspective ("perspective"), TranslateX ("translate-x"), TranslateY ("translate-y"), TranslateZ ("translate-z"),
// ScaleX ("scale-x"), ScaleY ("scale-y"), ScaleZ ("scale-z"), Rotate ("rotate"), RotateX ("rotate-x"),
// RotateY ("rotate-y"), RotateZ ("rotate-z"), SkewX ("skew-x"), and SkewY ("skew-y")
@@ -406,6 +284,12 @@ type transformPropertyData struct {
}
// NewTransform creates a new transform property data and return its interface
+//
+// The following properties can be used:
+//
+// Perspective ("perspective"), TranslateX ("translate-x"), TranslateY ("translate-y"), TranslateZ ("translate-z"),
+// ScaleX ("scale-x"), ScaleY ("scale-y"), ScaleZ ("scale-z"), Rotate ("rotate"), RotateX ("rotate-x"),
+// RotateY ("rotate-y"), RotateZ ("rotate-z"), SkewX ("skew-x"), and SkewY ("skew-y")
func NewTransformProperty(params Params) TransformProperty {
transform := new(transformPropertyData)
transform.init()
diff --git a/videoPlayer.go b/videoPlayer.go
index f78acdc..1a4bb5f 100644
--- a/videoPlayer.go
+++ b/videoPlayer.go
@@ -8,32 +8,32 @@ import (
const (
// VideoWidth is the constant for "video-width" property tag.
//
- // Used by `VideoPlayer`.
+ // Used by VideoPlayer.
// Defines the width of the video's display area in pixels.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
// Values:
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
VideoWidth PropertyName = "video-width"
// VideoHeight is the constant for "video-height" property tag.
//
- // Used by `VideoPlayer`.
+ // Used by VideoPlayer.
// Defines the height of the video's display area in pixels.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
VideoHeight PropertyName = "video-height"
// Poster is the constant for "poster" property tag.
//
- // Used by `VideoPlayer`.
+ // Used by VideoPlayer.
// Defines an URL for an image to be shown while the video is downloading. If this attribute isn't specified, nothing is
// displayed until the first frame is available, then the first frame is shown as the poster frame.
//
- // Supported types: `string`.
+ // Supported types: string.
Poster PropertyName = "poster"
)
diff --git a/view.go b/view.go
index 1131d7b..016f71a 100644
--- a/view.go
+++ b/view.go
@@ -55,8 +55,8 @@ type View interface {
Scroll() Frame
// SetParams sets properties with name "tag" of the "rootView" subview. Result:
- // * true - all properties were set successful,
- // * false - error (incompatible type or invalid format of a string value, see AppLog).
+ // - true - all properties were set successful,
+ // - false - error (incompatible type or invalid format of a string value, see AppLog).
SetParams(params Params) bool
// SetAnimated sets the value (second argument) of the property with name defined by the first argument.
diff --git a/viewClip.go b/viewClip.go
index ca918e8..c470436 100644
--- a/viewClip.go
+++ b/viewClip.go
@@ -31,11 +31,11 @@ type polygonClip struct {
}
// InsetClip creates a rectangle View clipping area.
-// top - offset from the top border of a View;
-// right - offset from the right border of a View;
-// bottom - offset from the bottom border of a View;
-// left - offset from the left border of a View;
-// radius - corner radius, pass nil if you don't need to round corners
+// - top - offset from the top border of a View;
+// - right - offset from the right border of a View;
+// - bottom - offset from the bottom border of a View;
+// - left - offset from the left border of a View;
+// - radius - corner radius, pass nil if you don't need to round corners
func InsetClip(top, right, bottom, left SizeUnit, radius RadiusProperty) ClipShape {
clip := new(insetClip)
clip.init()
@@ -71,6 +71,7 @@ func EllipseClip(x, y, rx, ry SizeUnit) ClipShape {
}
// PolygonClip creates a polygon View clipping area.
+//
// The elements of the function argument can be or text constants,
// or the text representation of SizeUnit, or elements of SizeUnit type.
func PolygonClip(points []any) ClipShape {
diff --git a/viewFilter.go b/viewFilter.go
index 96c7bb0..4731b4b 100644
--- a/viewFilter.go
+++ b/viewFilter.go
@@ -9,122 +9,122 @@ import (
const (
// Blur is the constant for "blur" property tag.
//
- // Used by `ViewFilter`.
+ // Used by ViewFilter.
// Applies a Gaussian blur. The value of radius defines the value of the standard deviation to the Gaussian function, or
// how many pixels on the screen blend into each other, so a larger value will create more blur. The lacuna value for
// interpolation is 0. The parameter is specified as a length in pixels.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
Blur PropertyName = "blur"
// Brightness is the constant for "brightness" property tag.
//
- // Used by `ViewFilter`.
+ // Used by ViewFilter.
// Applies a linear multiplier to input image, making it appear more or less bright. A value of 0% will create an image
// that is completely black. A value of 100% leaves the input unchanged. Other values are linear multipliers on the
// effect. Values of an amount over 100% are allowed, providing brighter results.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
Brightness PropertyName = "brightness"
// Contrast is the constant for "contrast" property tag.
//
- // Used by `ViewFilter`.
+ // Used by ViewFilter.
// Adjusts the contrast of the input. A value of 0% will create an image that is completely black. A value of 100% leaves
// the input unchanged. Values of amount over 100% are allowed, providing results with less contrast.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
Contrast PropertyName = "contrast"
// DropShadow is the constant for "drop-shadow" property tag.
//
- // Used by `ViewFilter`.
+ // Used by ViewFilter.
// Applies a drop shadow effect to the input image. A drop shadow is effectively a blurred, offset version of the input
// image's alpha mask drawn in a particular color, composited below the image. Shadow parameters are set using the
- // `ShadowProperty` interface.
+ // ShadowProperty interface.
//
- // Supported types: `[]ShadowProperty`, `ShadowProperty`, `string`.
+ // Supported types: []ShadowProperty, ShadowProperty, string.
//
- // Internal type is `[]ShadowProperty`, other types converted to it during assignment.
- // See `ShadowProperty` description for more details.
+ // Internal type is []ShadowProperty, other types converted to it during assignment.
+ // See ShadowProperty description for more details.
//
// Conversion rules:
- // `[]ShadowProperty` - stored as is, no conversion performed.
- // `ShadowProperty` - converted to `[]ShadowProperty`.
- // `string` - string representation of `ShadowProperty`. Example: "_{blur = 1em, color = black, spread-radius = 0.5em}".
+ // - []ShadowProperty - stored as is, no conversion performed.
+ // - ShadowProperty - converted to []ShadowProperty.
+ // - string - string representation of ShadowProperty. Example: "_{blur = 1em, color = black, spread-radius = 0.5em}".
DropShadow PropertyName = "drop-shadow"
// Grayscale is the constant for "grayscale" property tag.
//
- // Used by `ViewFilter`.
+ // Used by ViewFilter.
// Converts the input image to grayscale. The value of ‘amount’ defines the proportion of the conversion. A value of 100%
// is completely grayscale. A value of 0% leaves the input unchanged. Values between 0% and 100% are linear multipliers on
// the effect.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
Grayscale PropertyName = "grayscale"
// HueRotate is the constant for "hue-rotate" property tag.
//
- // Used by `ViewFilter`.
+ // Used by ViewFilter.
// Applies a hue rotation on the input image. The value of ‘angle’ defines the number of degrees around the color circle
// the input samples will be adjusted. A value of 0deg leaves the input unchanged. If the ‘angle’ parameter is missing, a
// value of 0deg is used. Though there is no maximum value, the effect of values above 360deg wraps around.
//
- // Supported types: `AngleUnit`, `string`, `float`, `int`.
+ // Supported types: AngleUnit, string, float, int.
//
- // Internal type is `AngleUnit`, other types will be converted to it during assignment.
- // See `AngleUnit` description for more details.
+ // Internal type is AngleUnit, other types will be converted to it during assignment.
+ // See AngleUnit description for more details.
//
// Conversion rules:
- // `AngleUnit` - stored as is, no conversion performed.
- // `string` - must contain string representation of `AngleUnit`. If numeric value will be provided without any suffix then `AngleUnit` with value and `Radian` value type will be created.
- // `float` - a new `AngleUnit` value will be created with `Radian` as a type.
- // `int` - a new `AngleUnit` value will be created with `Radian` as a type.
+ // - AngleUnit - stored as is, no conversion performed.
+ // - string - must contain string representation of AngleUnit. If numeric value will be provided without any suffix then AngleUnit with value and Radian value type will be created.
+ // - float - a new AngleUnit value will be created with Radian as a type.
+ // - int - a new AngleUnit value will be created with Radian as a type.
HueRotate PropertyName = "hue-rotate"
// Invert is the constant for "invert" property tag.
//
- // Used by `ViewFilter`.
+ // Used by ViewFilter.
// Inverts the samples in the input image. The value of ‘amount’ defines the proportion of the conversion. A value of 100%
// is completely inverted. A value of 0% leaves the input unchanged. Values between 0% and 100% are linear multipliers on
// the effect.
//
- // Supported types: `float64`, `int`, `string`.
+ // Supported types: float64, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
Invert PropertyName = "invert"
// Saturate is the constant for "saturate" property tag.
//
- // Used by `ViewFilter`.
+ // Used by ViewFilter.
// Saturates the input image. The value of ‘amount’ defines the proportion of the conversion. A value of 0% is completely
// un-saturated. A value of 100% leaves the input unchanged. Other values are linear multipliers on the effect. Values of
// amount over 100% are allowed, providing super-saturated results.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
Saturate PropertyName = "saturate"
// Sepia is the constant for "sepia" property tag.
//
- // Used by `ViewFilter`.
+ // Used by ViewFilter.
// Converts the input image to sepia. The value of ‘amount’ defines the proportion of the conversion. A value of 100% is
// completely sepia. A value of 0% leaves the input unchanged. Values between 0% and 100% are linear multipliers on the
// effect.
//
- // Supported types: `float`, `int`, `string`.
+ // Supported types: float, int, string.
//
- // Internal type is `float`, other types converted to it during assignment.
+ // Internal type is float, other types converted to it during assignment.
Sepia PropertyName = "sepia"
)
diff --git a/viewUtils.go b/viewUtils.go
index 1a278ba..f3b82fd 100644
--- a/viewUtils.go
+++ b/viewUtils.go
@@ -1,7 +1,9 @@
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.
//
// If the second argument (subviewID) is "" then a listener for the first argument (view) is get
@@ -19,10 +21,8 @@ func Get(rootView View, viewID string, tag PropertyName) any {
}
// Set sets the property with name "tag" of the "rootView" subview with "viewID" id by value. Result:
-//
-// true - success,
-//
-// false - error (incompatible type or invalid format of a string value, see AppLog).
+// - true - success,
+// - false - error (incompatible type or invalid format of a string value, see AppLog).
//
// If the second argument (subviewID) is "" then a listener for the first argument (view) is set
func Set(rootView View, viewID string, tag PropertyName, value any) bool {
@@ -39,6 +39,7 @@ func Set(rootView View, viewID string, tag PropertyName, value any) bool {
}
// SetChangeListener sets a listener for changing a subview property value.
+//
// If the second argument (subviewID) is "" then a listener for the first argument (view) is set
func SetChangeListener(view View, viewID string, tag PropertyName, listener func(View, PropertyName)) {
if viewID != "" {
@@ -50,8 +51,8 @@ func SetChangeListener(view View, viewID string, tag PropertyName, listener func
}
// SetParams sets properties with name "tag" of the "rootView" subview. Result:
-// true - all properties were set successful,
-// false - error (incompatible type or invalid format of a string value, see AppLog).
+// - true - all properties were set successful,
+// - false - error (incompatible type or invalid format of a string value, see AppLog).
func SetParams(rootView View, viewID string, params Params) bool {
if viewID != "" {
rootView = ViewByID(rootView, viewID)
From 5039998cf9f662a7e3e1534fa77a45d2d23d5c97 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Fri, 6 Dec 2024 18:38:43 +0300
Subject: [PATCH 33/43] Renamed ClipShape -> ClipShapeProperty
---
CHANGELOG.md | 9 +-
README-ru.md | 12 +-
README.md | 12 +-
viewClip.go => clipShape.go | 252 +++++++++++++++++++++++++-----------
popup.go | 8 +-
propertyNames.go | 30 ++---
radius.go | 24 ++--
view.go | 4 +-
viewStyle.go | 4 +-
viewStyleSet.go | 2 +-
10 files changed, 235 insertions(+), 122 deletions(-)
rename viewClip.go => clipShape.go (60%)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6936f2d..89806b0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,10 +18,17 @@
NewInsetViewShadow function -> NewInsetShadow
NewShadowWithParams function -> NewShadowProperty
NewColumnSeparator function -> NewColumnSeparatorProperty
+ ClipShape interface -> ClipShapeProperty
+ InsetClip function -> NewInsetClip
+ CircleClip function -> NewCircleClip
+ EllipseClip function -> NewEllipseClip
+ PolygonClip function -> NewPolygonClip
+ PolygonPointsClip function -> NewPolygonPointsClip
* Added functions: NewBounds, NewEllipticRadius, NewRadii, NewLinearGradient, NewCircleRadialGradient,
NewEllipseRadialGradient, GetPushTransform, GetPushDuration, GetPushTiming, IsMoveToFrontAnimation,
-GetBackground, GetMask, GetBackgroundClip,GetBackgroundOrigin, GetMaskClip, GetMaskOrigin, NewColumnSeparator.
+GetBackground, GetMask, GetBackgroundClip,GetBackgroundOrigin, GetMaskClip, GetMaskOrigin, NewColumnSeparator,
+NewClipShapeProperty.
* Added SetConicGradientFillStyle and SetConicGradientStrokeStyle methods to Canvas interface.
diff --git a/README-ru.md b/README-ru.md
index 6cb42d9..c2442b2 100644
--- a/README-ru.md
+++ b/README-ru.md
@@ -1322,14 +1322,14 @@ AngleUnit или string (угловая константа или текстов
### Свойство "clip"
-Свойство "clip" (константа Clip) типа ClipShape задает задает область образки.
+Свойство "clip" (константа Clip) типа ClipShapeProperty задает задает область образки.
Есть 4 типа областей обрезки
#### inset
Прямоугольная область обрезки. Создается с помощью функции:
- func InsetClip(top, right, bottom, left SizeUnit, radius RadiusProperty) ClipShape
+ func NewInsetClip(top, right, bottom, left SizeUnit, radius RadiusProperty) ClipShapeProperty
где top, right, bottom, left это расстояние от соответственно верхней, правой, нижней и левой границы
View до одноименной границы обрезки; radius - задает радиусы скругления углов области обрезки
@@ -1346,7 +1346,7 @@ radius необходимо передать nil
Круглая область обрезки. Создается с помощью функции:
- func CircleClip(x, y, radius SizeUnit) ClipShape
+ func NewCircleClip(x, y, radius SizeUnit) ClipShapeProperty
где x, y - координаты центра окружности; radius - радиус
@@ -1358,7 +1358,7 @@ radius необходимо передать nil
Эллиптическая область обрезки. Создается с помощью функции:
- func EllipseClip(x, y, rx, ry SizeUnit) ClipShape
+ func NewEllipseClip(x, y, rx, ry SizeUnit) ClipShapeProperty
где x, y - координаты центра эллипса; rх - радиус эллипса по оси X; ry - радиус эллипса по оси Y.
@@ -1370,8 +1370,8 @@ radius необходимо передать nil
Многоугольная область обрезки. Создается с помощью функций:
- func PolygonClip(points []any) ClipShape
- func PolygonPointsClip(points []SizeUnit) ClipShape
+ func NewPolygonClip(points []any) ClipShapeProperty
+ func NewPolygonPointsClip(points []SizeUnit) ClipShapeProperty
в качестве аргумента передается массив угловых точек многоугольника в следующем порядке: x1, y1, x2, y2, …
В качестве элементов аргумента функции PolygonClip могут быть или текстовые константы, или
diff --git a/README.md b/README.md
index 12c66d5..9b06c64 100644
--- a/README.md
+++ b/README.md
@@ -1301,14 +1301,14 @@ You can get the value of this property using the function
### "clip" property
-The "clip" property (Clip constant) of the ClipShape type specifies the crop area.
+The "clip" property (Clip constant) of the ClipShapeProperty type specifies the crop area.
There are 4 types of crop areas
#### inset
Rectangular cropping area. Created with the function:
- func InsetClip(top, right, bottom, left SizeUnit, radius RadiusProperty) ClipShape
+ func InsetClip(top, right, bottom, left SizeUnit, radius RadiusProperty) ClipShapeProperty
where top, right, bottom, left are the distance from respectively the top, right, bottom and left borders of the View
to the cropping border of the same name; radius - sets the radii of the corners of the cropping area
@@ -1324,7 +1324,7 @@ The textual description of the rectangular cropping area is in the following for
Round cropping area. Created with the function:
- func CircleClip(x, y, radius SizeUnit) ClipShape
+ func CircleClip(x, y, radius SizeUnit) ClipShapeProperty
where x, y - coordinates of the center of the circle; radius - radius
@@ -1336,7 +1336,7 @@ The textual description of the circular cropping area is in the following format
Elliptical cropping area. Created with the function:
- func EllipseClip(x, y, rx, ry SizeUnit) ClipShape
+ func EllipseClip(x, y, rx, ry SizeUnit) ClipShapeProperty
where x, y - coordinates of the center of the ellipse; rх - radius of the ellipse along the X axis; ry is the radius of the ellipse along the Y axis.
@@ -1348,8 +1348,8 @@ The textual description of the elliptical clipping region is in the following fo
Polygonal cropping area. Created using functions:
- func PolygonClip(points []any) ClipShape
- func PolygonPointsClip(points []SizeUnit) ClipShape
+ func PolygonClip(points []any) ClipShapeProperty
+ func PolygonPointsClip(points []SizeUnit) ClipShapeProperty
an array of corner points of the polygon is passed as an argument in the following order: x1, y1, x2, y2, …
The elements of the argument to the PolygonClip function can be either text constants,
diff --git a/viewClip.go b/clipShape.go
similarity index 60%
rename from viewClip.go
rename to clipShape.go
index c470436..7233bdd 100644
--- a/viewClip.go
+++ b/clipShape.go
@@ -5,39 +5,120 @@ import (
"strings"
)
-// ClipShape defines a View clipping area
-type ClipShape interface {
+type ClipShape string
+
+const (
+ InsetClip ClipShape = "inset"
+ CircleClip ClipShape = "circle"
+ EllipseClip ClipShape = "ellipse"
+ PolygonClip ClipShape = "polygon"
+)
+
+// ClipShapeProperty defines a View clipping area
+type ClipShapeProperty interface {
Properties
fmt.Stringer
stringWriter
+
+ // Shape returns the clip shape type
+ Shape() ClipShape
cssStyle(session Session) string
valid(session Session) bool
}
-type insetClip struct {
+type insetClipData struct {
dataProperty
}
-type ellipseClip struct {
+type ellipseClipData struct {
dataProperty
}
-type circleClip struct {
+type circleClipData struct {
dataProperty
}
-type polygonClip struct {
+type polygonClipData struct {
dataProperty
}
-// InsetClip creates a rectangle View clipping area.
+// NewClipShapeProperty creates ClipShapeProperty.
+//
+// The following properties can be used for shapes:
+//
+// InsetClip:
+// - "top" (Top) - offset (SizeUnit) from the top border of a View;
+// - "right" (Right) - offset (SizeUnit) from the right border of a View;
+// - "bottom" (Bottom) - offset (SizeUnit) from the bottom border of a View;
+// - "left" (Left) - offset (SizeUnit) from the left border of a View;
+// - "radius" (Radius) - corner radius (RadiusProperty).
+//
+// CircleClip:
+// - "x" (X) - x-axis position (SizeUnit) of the circle clip center;
+// - "y" (Y) - y-axis position (SizeUnit) of the circle clip center;
+// - "radius" (Radius) - radius (SizeUnit) of the circle clip center.
+//
+// EllipseClip:
+// - "x" (X) - x-axis position (SizeUnit) of the ellipse clip center;
+// - "y" (Y) - y-axis position (SizeUnit) of the ellipse clip center;
+// - "radius-x" (RadiusX) - x-axis radius (SizeUnit) of the ellipse clip center;
+// - "radius-y" (RadiusY) - y-axis radius (SizeUnit) of the ellipse clip center.
+//
+// PolygonClip:
+// - "points" (Points) - an array ([]SizeUnit) of corner points of the polygon in the following order: x1, y1, x2, y2, ….
+//
+// The function will return nil if no properties are specified, unsupported properties are specified, or at least one property has an invalid value.
+func NewClipShapeProperty(shape ClipShape, params Params) ClipShapeProperty {
+ if len(params) == 0 {
+ ErrorLog("No ClipShapeProperty params")
+ return nil
+ }
+
+ var result ClipShapeProperty
+
+ switch shape {
+ case InsetClip:
+ clip := new(insetClipData)
+ clip.init()
+ result = clip
+
+ case CircleClip:
+ clip := new(circleClipData)
+ clip.init()
+ result = clip
+
+ case EllipseClip:
+ clip := new(ellipseClipData)
+ clip.init()
+ result = clip
+
+ case PolygonClip:
+ clip := new(polygonClipData)
+ clip.init()
+ result = clip
+
+ default:
+ ErrorLog("Unknown ClipShape: " + string(shape))
+ return nil
+ }
+
+ for tag, value := range params {
+ if !result.Set(tag, value) {
+ return nil
+ }
+ }
+
+ return result
+}
+
+// NewInsetClip creates a rectangle View clipping area.
// - top - offset from the top border of a View;
// - right - offset from the right border of a View;
// - bottom - offset from the bottom border of a View;
// - left - offset from the left border of a View;
// - radius - corner radius, pass nil if you don't need to round corners
-func InsetClip(top, right, bottom, left SizeUnit, radius RadiusProperty) ClipShape {
- clip := new(insetClip)
+func NewInsetClip(top, right, bottom, left SizeUnit, radius RadiusProperty) ClipShapeProperty {
+ clip := new(insetClipData)
clip.init()
clip.setRaw(Top, top)
clip.setRaw(Right, right)
@@ -49,9 +130,12 @@ func InsetClip(top, right, bottom, left SizeUnit, radius RadiusProperty) ClipSha
return clip
}
-// CircleClip creates a circle View clipping area.
-func CircleClip(x, y, radius SizeUnit) ClipShape {
- clip := new(circleClip)
+// NewCircleClip creates a circle View clipping area.
+// - x - x-axis position of the circle clip center;
+// - y - y-axis position of the circle clip center;
+// - radius - radius of the circle clip center.
+func NewCircleClip(x, y, radius SizeUnit) ClipShapeProperty {
+ clip := new(circleClipData)
clip.init()
clip.setRaw(X, x)
clip.setRaw(Y, y)
@@ -59,9 +143,13 @@ func CircleClip(x, y, radius SizeUnit) ClipShape {
return clip
}
-// EllipseClip creates a ellipse View clipping area.
-func EllipseClip(x, y, rx, ry SizeUnit) ClipShape {
- clip := new(ellipseClip)
+// NewEllipseClip creates a ellipse View clipping area.
+// - x - x-axis position of the ellipse clip center;
+// - y - y-axis position of the ellipse clip center;
+// - rx - x-axis radius of the ellipse clip center;
+// - ry - y-axis radius of the ellipse clip center.
+func NewEllipseClip(x, y, rx, ry SizeUnit) ClipShapeProperty {
+ clip := new(ellipseClipData)
clip.init()
clip.setRaw(X, x)
clip.setRaw(Y, y)
@@ -70,32 +158,34 @@ func EllipseClip(x, y, rx, ry SizeUnit) ClipShape {
return clip
}
-// PolygonClip creates a polygon View clipping area.
+// NewPolygonClip creates a polygon View clipping area.
+// - points - an array of corner points of the polygon in the following order: x1, y1, x2, y2, …
//
// The elements of the function argument can be or text constants,
// or the text representation of SizeUnit, or elements of SizeUnit type.
-func PolygonClip(points []any) ClipShape {
- clip := new(polygonClip)
+func NewPolygonClip(points []any) ClipShapeProperty {
+ clip := new(polygonClipData)
clip.init()
- if polygonClipSet(clip, Points, points) != nil {
+ if polygonClipDataSet(clip, Points, points) != nil {
return clip
}
return nil
}
-// PolygonPointsClip creates a polygon View clipping area.
-func PolygonPointsClip(points []SizeUnit) ClipShape {
- clip := new(polygonClip)
+// NewPolygonPointsClip creates a polygon View clipping area.
+// - points - an array of corner points of the polygon in the following order: x1, y1, x2, y2, …
+func NewPolygonPointsClip(points []SizeUnit) ClipShapeProperty {
+ clip := new(polygonClipData)
clip.init()
- if polygonClipSet(clip, Points, points) != nil {
+ if polygonClipDataSet(clip, Points, points) != nil {
return clip
}
return nil
}
-func (clip *insetClip) init() {
+func (clip *insetClipData) init() {
clip.dataProperty.init()
- clip.set = insetClipSet
+ clip.set = insetClipDataSet
clip.supportedProperties = []PropertyName{
Top, Right, Bottom, Left, Radius,
RadiusX, RadiusY, RadiusTopLeft, RadiusTopLeftX, RadiusTopLeftY,
@@ -105,7 +195,11 @@ func (clip *insetClip) init() {
}
}
-func insetClipSet(properties Properties, tag PropertyName, value any) []PropertyName {
+func (clip *insetClipData) Shape() ClipShape {
+ return InsetClip
+}
+
+func insetClipDataSet(properties Properties, tag PropertyName, value any) []PropertyName {
switch tag {
case Top, Right, Bottom, Left:
return setSizeProperty(properties, tag, value)
@@ -127,11 +221,11 @@ func insetClipSet(properties Properties, tag PropertyName, value any) []Property
return nil
}
-func (clip *insetClip) String() string {
+func (clip *insetClipData) String() string {
return runStringWriter(clip)
}
-func (clip *insetClip) writeString(buffer *strings.Builder, indent string) {
+func (clip *insetClipData) writeString(buffer *strings.Builder, indent string) {
buffer.WriteString("inset { ")
comma := false
for _, tag := range []PropertyName{Top, Right, Bottom, Left, Radius} {
@@ -149,7 +243,7 @@ func (clip *insetClip) writeString(buffer *strings.Builder, indent string) {
buffer.WriteString(" }")
}
-func (clip *insetClip) cssStyle(session Session) string {
+func (clip *insetClipData) cssStyle(session Session) string {
buffer := allocStringBuilder()
defer freeStringBuilder(buffer)
@@ -171,7 +265,7 @@ func (clip *insetClip) cssStyle(session Session) string {
return buffer.String()
}
-func (clip *insetClip) valid(session Session) bool {
+func (clip *insetClipData) valid(session Session) bool {
for _, tag := range []PropertyName{Top, Right, Bottom, Left, Radius, RadiusX, RadiusY} {
if value, ok := sizeProperty(clip, tag, session); ok && value.Type != Auto && value.Value != 0 {
return true
@@ -180,13 +274,17 @@ func (clip *insetClip) valid(session Session) bool {
return false
}
-func (clip *circleClip) init() {
+func (clip *circleClipData) init() {
clip.dataProperty.init()
- clip.set = circleClipSet
+ clip.set = circleClipDataSet
clip.supportedProperties = []PropertyName{X, Y, Radius}
}
-func circleClipSet(properties Properties, tag PropertyName, value any) []PropertyName {
+func (clip *circleClipData) Shape() ClipShape {
+ return CircleClip
+}
+
+func circleClipDataSet(properties Properties, tag PropertyName, value any) []PropertyName {
switch tag {
case X, Y, Radius:
return setSizeProperty(properties, tag, value)
@@ -196,11 +294,11 @@ func circleClipSet(properties Properties, tag PropertyName, value any) []Propert
return nil
}
-func (clip *circleClip) String() string {
+func (clip *circleClipData) String() string {
return runStringWriter(clip)
}
-func (clip *circleClip) writeString(buffer *strings.Builder, indent string) {
+func (clip *circleClipData) writeString(buffer *strings.Builder, indent string) {
buffer.WriteString("circle { ")
comma := false
for _, tag := range []PropertyName{Radius, X, Y} {
@@ -218,7 +316,7 @@ func (clip *circleClip) writeString(buffer *strings.Builder, indent string) {
buffer.WriteString(" }")
}
-func (clip *circleClip) cssStyle(session Session) string {
+func (clip *circleClipData) cssStyle(session Session) string {
buffer := allocStringBuilder()
defer freeStringBuilder(buffer)
@@ -239,20 +337,24 @@ func (clip *circleClip) cssStyle(session Session) string {
return buffer.String()
}
-func (clip *circleClip) valid(session Session) bool {
+func (clip *circleClipData) valid(session Session) bool {
if value, ok := sizeProperty(clip, Radius, session); ok && value.Value == 0 {
return false
}
return true
}
-func (clip *ellipseClip) init() {
+func (clip *ellipseClipData) init() {
clip.dataProperty.init()
- clip.set = ellipseClipSet
+ clip.set = ellipseClipDataSet
clip.supportedProperties = []PropertyName{X, Y, Radius, RadiusX, RadiusY}
}
-func ellipseClipSet(properties Properties, tag PropertyName, value any) []PropertyName {
+func (clip *ellipseClipData) Shape() ClipShape {
+ return EllipseClip
+}
+
+func ellipseClipDataSet(properties Properties, tag PropertyName, value any) []PropertyName {
switch tag {
case X, Y, RadiusX, RadiusY:
return setSizeProperty(properties, tag, value)
@@ -269,11 +371,11 @@ func ellipseClipSet(properties Properties, tag PropertyName, value any) []Proper
return nil
}
-func (clip *ellipseClip) String() string {
+func (clip *ellipseClipData) String() string {
return runStringWriter(clip)
}
-func (clip *ellipseClip) writeString(buffer *strings.Builder, indent string) {
+func (clip *ellipseClipData) writeString(buffer *strings.Builder, indent string) {
buffer.WriteString("ellipse { ")
comma := false
for _, tag := range []PropertyName{RadiusX, RadiusY, X, Y} {
@@ -291,7 +393,7 @@ func (clip *ellipseClip) writeString(buffer *strings.Builder, indent string) {
buffer.WriteString(" }")
}
-func (clip *ellipseClip) cssStyle(session Session) string {
+func (clip *ellipseClipData) cssStyle(session Session) string {
buffer := allocStringBuilder()
defer freeStringBuilder(buffer)
@@ -315,19 +417,23 @@ func (clip *ellipseClip) cssStyle(session Session) string {
return buffer.String()
}
-func (clip *ellipseClip) valid(session Session) bool {
+func (clip *ellipseClipData) valid(session Session) bool {
rx, _ := sizeProperty(clip, RadiusX, session)
ry, _ := sizeProperty(clip, RadiusY, session)
return rx.Value != 0 && ry.Value != 0
}
-func (clip *polygonClip) init() {
+func (clip *polygonClipData) init() {
clip.dataProperty.init()
- clip.set = polygonClipSet
+ clip.set = polygonClipDataSet
clip.supportedProperties = []PropertyName{Points}
}
-func polygonClipSet(properties Properties, tag PropertyName, value any) []PropertyName {
+func (clip *polygonClipData) Shape() ClipShape {
+ return PolygonClip
+}
+
+func polygonClipDataSet(properties Properties, tag PropertyName, value any) []PropertyName {
if Points == tag {
switch value := value.(type) {
case []any:
@@ -385,11 +491,11 @@ func polygonClipSet(properties Properties, tag PropertyName, value any) []Proper
return nil
}
-func (clip *polygonClip) String() string {
+func (clip *polygonClipData) String() string {
return runStringWriter(clip)
}
-func (clip *polygonClip) points() []any {
+func (clip *polygonClipData) points() []any {
if value := clip.getRaw(Points); value != nil {
if points, ok := value.([]any); ok {
return points
@@ -398,7 +504,7 @@ func (clip *polygonClip) points() []any {
return nil
}
-func (clip *polygonClip) writeString(buffer *strings.Builder, indent string) {
+func (clip *polygonClipData) writeString(buffer *strings.Builder, indent string) {
buffer.WriteString("inset { ")
@@ -417,7 +523,7 @@ func (clip *polygonClip) writeString(buffer *strings.Builder, indent string) {
buffer.WriteRune('}')
}
-func (clip *polygonClip) cssStyle(session Session) string {
+func (clip *polygonClipData) cssStyle(session Session) string {
points := clip.points()
count := len(points)
@@ -459,47 +565,47 @@ func (clip *polygonClip) cssStyle(session Session) string {
return buffer.String()
}
-func (clip *polygonClip) valid(session Session) bool {
+func (clip *polygonClipData) valid(session Session) bool {
return len(clip.points()) > 0
}
-func parseClipShape(obj DataObject) ClipShape {
+func parseClipShapeProperty(obj DataObject) ClipShapeProperty {
switch obj.Tag() {
case "inset":
- clip := new(insetClip)
+ clip := new(insetClipData)
clip.init()
for _, tag := range []PropertyName{Top, Right, Bottom, Left, Radius, RadiusX, RadiusY} {
if value, ok := obj.PropertyValue(string(tag)); ok {
- insetClipSet(clip, tag, value)
+ insetClipDataSet(clip, tag, value)
}
}
return clip
case "circle":
- clip := new(ellipseClip)
+ clip := new(circleClipData)
clip.init()
for _, tag := range []PropertyName{X, Y, Radius} {
if value, ok := obj.PropertyValue(string(tag)); ok {
- circleClipSet(clip, tag, value)
+ circleClipDataSet(clip, tag, value)
}
}
return clip
case "ellipse":
- clip := new(ellipseClip)
+ clip := new(ellipseClipData)
clip.init()
for _, tag := range []PropertyName{X, Y, RadiusX, RadiusY} {
if value, ok := obj.PropertyValue(string(tag)); ok {
- ellipseClipSet(clip, tag, value)
+ ellipseClipDataSet(clip, tag, value)
}
}
return clip
case "polygon":
- clip := new(ellipseClip)
+ clip := new(polygonClipData)
clip.init()
if value, ok := obj.PropertyValue(string(Points)); ok {
- polygonClipSet(clip, Points, value)
+ polygonClipDataSet(clip, Points, value)
}
return clip
}
@@ -507,9 +613,9 @@ func parseClipShape(obj DataObject) ClipShape {
return nil
}
-func setClipShapeProperty(properties Properties, tag PropertyName, value any) []PropertyName {
+func setClipShapePropertyProperty(properties Properties, tag PropertyName, value any) []PropertyName {
switch value := value.(type) {
- case ClipShape:
+ case ClipShapeProperty:
properties.setRaw(tag, value)
return []PropertyName{tag}
@@ -520,21 +626,21 @@ func setClipShapeProperty(properties Properties, tag PropertyName, value any) []
}
if obj := NewDataObject(value); obj == nil {
- if clip := parseClipShape(obj); clip != nil {
+ if clip := parseClipShapeProperty(obj); clip != nil {
properties.setRaw(tag, clip)
return []PropertyName{tag}
}
}
case DataObject:
- if clip := parseClipShape(value); clip != nil {
+ if clip := parseClipShapeProperty(value); clip != nil {
properties.setRaw(tag, clip)
return []PropertyName{tag}
}
case DataValue:
if value.IsObject() {
- if clip := parseClipShape(value.Object()); clip != nil {
+ if clip := parseClipShapeProperty(value.Object()); clip != nil {
properties.setRaw(tag, clip)
return []PropertyName{tag}
}
@@ -545,16 +651,16 @@ func setClipShapeProperty(properties Properties, tag PropertyName, value any) []
return nil
}
-func getClipShape(prop Properties, tag PropertyName, session Session) ClipShape {
+func getClipShapeProperty(prop Properties, tag PropertyName, session Session) ClipShapeProperty {
if value := prop.getRaw(tag); value != nil {
switch value := value.(type) {
- case ClipShape:
+ case ClipShapeProperty:
return value
case string:
if text, ok := session.resolveConstants(value); ok {
if obj := NewDataObject(text); obj == nil {
- return parseClipShape(obj)
+ return parseClipShapeProperty(obj)
}
}
}
@@ -565,9 +671,9 @@ func getClipShape(prop Properties, tag PropertyName, session Session) ClipShape
// GetClip returns a View clipping area.
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
-func GetClip(view View, subviewID ...string) ClipShape {
+func GetClip(view View, subviewID ...string) ClipShapeProperty {
if view = getSubview(view, subviewID); view != nil {
- return getClipShape(view, Clip, view.Session())
+ return getClipShapeProperty(view, Clip, view.Session())
}
return nil
@@ -575,9 +681,9 @@ func GetClip(view View, subviewID ...string) ClipShape {
// GetShapeOutside returns a shape around which adjacent inline content.
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
-func GetShapeOutside(view View, subviewID ...string) ClipShape {
+func GetShapeOutside(view View, subviewID ...string) ClipShapeProperty {
if view = getSubview(view, subviewID); view != nil {
- return getClipShape(view, ShapeOutside, view.Session())
+ return getClipShapeProperty(view, ShapeOutside, view.Session())
}
return nil
diff --git a/popup.go b/popup.go
index be1d6e4..a008305 100644
--- a/popup.go
+++ b/popup.go
@@ -381,28 +381,28 @@ func (arrow *popupArrow) createView(popupView View) View {
case TopArrow:
params[Row] = 0
params[Column] = 1
- params[Clip] = PolygonClip([]any{"0%", "100%", "50%", "0%", "100%", "100%"})
+ params[Clip] = NewPolygonClip([]any{"0%", "100%", "50%", "0%", "100%", "100%"})
params[Width] = arrow.width
params[Height] = arrow.size
case RightArrow:
params[Row] = 1
params[Column] = 0
- params[Clip] = PolygonClip([]any{"0%", "0%", "100%", "50%", "0%", "100%"})
+ params[Clip] = NewPolygonClip([]any{"0%", "0%", "100%", "50%", "0%", "100%"})
params[Width] = arrow.size
params[Height] = arrow.width
case BottomArrow:
params[Row] = 0
params[Column] = 1
- params[Clip] = PolygonClip([]any{"0%", "0%", "50%", "100%", "100%", "0%"})
+ params[Clip] = NewPolygonClip([]any{"0%", "0%", "50%", "100%", "100%", "0%"})
params[Width] = arrow.width
params[Height] = arrow.size
case LeftArrow:
params[Row] = 1
params[Column] = 0
- params[Clip] = PolygonClip([]any{"100%", "0%", "0%", "50%", "100%", "100%"})
+ params[Clip] = NewPolygonClip([]any{"100%", "0%", "0%", "50%", "100%", "100%"})
params[Width] = arrow.size
params[Height] = arrow.width
}
diff --git a/propertyNames.go b/propertyNames.go
index b62e9a3..14b1b23 100644
--- a/propertyNames.go
+++ b/propertyNames.go
@@ -228,7 +228,7 @@ const (
// Left is the constant for "left" property tag.
//
- // Used by View, BoundsProperty, ClipShape.
+ // Used by View, BoundsProperty, ClipShapeProperty.
//
// # Usage in View:
//
@@ -248,7 +248,7 @@ const (
// Internal type is SizeUnit, other types converted to it during assignment.
// See [SizeUnit] description for more details.
//
- // # Usage in ClipShape:
+ // # Usage in ClipShapeProperty:
//
// Specifies the left border position of inset clip shape.
//
@@ -260,7 +260,7 @@ const (
// Right is the constant for "right" property tag.
//
- // Used by View, BoundsProperty, ClipShape.
+ // Used by View, BoundsProperty, ClipShapeProperty.
//
// # Usage in View:
//
@@ -280,7 +280,7 @@ const (
// Internal type is SizeUnit, other types converted to it during assignment.
// See [SizeUnit] description for more details.
//
- // # Usage in ClipShape:
+ // # Usage in ClipShapeProperty:
//
// Specifies the right border position of inset clip shape.
//
@@ -292,7 +292,7 @@ const (
// Top is the constant for "top" property tag.
//
- // Used by View, BoundsProperty, ClipShape.
+ // Used by View, BoundsProperty, ClipShapeProperty.
//
// # Usage in View:
//
@@ -312,7 +312,7 @@ const (
// Internal type is SizeUnit, other types converted to it during assignment.
// See [SizeUnit] description for more details.
//
- // # Usage in ClipShape:
+ // # Usage in ClipShapeProperty:
//
// Specifies the top border position of inset clip shape.
//
@@ -324,7 +324,7 @@ const (
// Bottom is the constant for "bottom" property tag.
//
- // Used by View, BoundsProperty, ClipShape.
+ // Used by View, BoundsProperty, ClipShapeProperty.
//
// # Usage in View:
//
@@ -344,7 +344,7 @@ const (
// Internal type is SizeUnit, other types converted to it during assignment.
// See [SizeUnit] description for more details.
//
- // # Usage in ClipShape:
+ // # Usage in ClipShapeProperty:
//
// Specifies the bottom border position of inset clip shape.
//
@@ -2526,15 +2526,15 @@ const (
// Used by View.
// Creates a clipping region that sets what part of a view should be shown.
//
- // Supported types: ClipShape, string.
+ // Supported types: ClipShapeProperty, string.
//
- // Internal type is ClipShape, other types converted to it during assignment.
- // See ClipShape description for more details.
+ // Internal type is ClipShapeProperty, other types converted to it during assignment.
+ // See ClipShapeProperty description for more details.
Clip PropertyName = "clip"
// Points is the constant for "points" property tag.
//
- // Used by ClipShape.
+ // Used by ClipShapeProperty.
// Points which describe polygon clip area. Values are in a sequence of pair like: x1, y1, x2, y2 ...
//
// Supported types: []SizeUnit, string.
@@ -2547,10 +2547,10 @@ const (
// inline content should wrap. By default, inline content wraps around its margin box. Property provides a way to
// customize this wrapping, making it possible to wrap text around complex objects rather than simple boxes.
//
- // Supported types: ClipShape, string.
+ // Supported types: ClipShapeProperty, string.
//
- // Internal type is ClipShape, other types converted to it during assignment.
- // See ClipShape description for more details.
+ // Internal type is ClipShapeProperty, other types converted to it during assignment.
+ // See ClipShapeProperty description for more details.
ShapeOutside PropertyName = "shape-outside"
// Float is the constant for "float" property tag.
diff --git a/radius.go b/radius.go
index 1525dff..3108f36 100644
--- a/radius.go
+++ b/radius.go
@@ -9,7 +9,7 @@ import (
const (
// Radius is the constant for "radius" property tag.
//
- // Used by View, BackgroundElement, ClipShape.
+ // Used by View, BackgroundElement, ClipShapeProperty.
//
// Usage in View:
// Specifies the corners rounding radius of an element's outer border edge.
@@ -30,7 +30,7 @@ const (
// Usage in BackgroundElement:
// Same as "radial-gradient-radius".
//
- // Usage in ClipShape:
+ // Usage in ClipShapeProperty:
// Specifies the radius of the corners or the radius of the cropping area.
//
// Supported types: SizeUnit, SizeFunc, string, float, int.
@@ -41,7 +41,7 @@ const (
// RadiusX is the constant for "radius-x" property tag.
//
- // Used by View, ClipShape.
+ // Used by View, ClipShapeProperty.
//
// Usage in View:
// Specifies the x-axis corners elliptic rounding radius of an element's outer border edge.
@@ -51,7 +51,7 @@ const (
// Internal type is SizeUnit, other types converted to it during assignment.
// See SizeUnit description for more details.
//
- // Usage in ClipShape:
+ // Usage in ClipShapeProperty:
// Specifies the x-axis corners elliptic rounding radius of the elliptic clip shape.
//
// Supported types: SizeUnit, SizeFunc, string, float, int.
@@ -62,7 +62,7 @@ const (
// RadiusY is the constant for "radius-y" property tag.
//
- // Used by View, ClipShape.
+ // Used by View, ClipShapeProperty.
//
// Usage in View:
// Specifies the y-axis corners elliptic rounding radius of an element's outer border edge.
@@ -72,7 +72,7 @@ const (
// Internal type is SizeUnit, other types converted to it during assignment.
// See SizeUnit description for more details.
//
- // Usage in ClipShape:
+ // Usage in ClipShapeProperty:
// Specifies the y-axis corners elliptic rounding radius of of the elliptic clip shape.
//
// Supported types: SizeUnit, SizeFunc, string, float, int.
@@ -215,10 +215,10 @@ const (
// X is the constant for "x" property tag.
//
- // Used by ClipShape, RadiusProperty.
+ // Used by ClipShapeProperty, RadiusProperty.
//
- // Usage in ClipShape:
- // Specifies x-axis position of the clip shape.
+ // Usage in ClipShapeProperty:
+ // Specifies x-axis position of the clip shape center.
//
// Supported types: SizeUnit, SizeFunc, string, float, int.
//
@@ -236,10 +236,10 @@ const (
// Y is the constant for "y" property tag.
//
- // Used by ClipShape, RadiusProperty.
+ // Used by ClipShapeProperty, RadiusProperty.
//
- // Usage in ClipShape:
- // Specifies y-axis position of the clip shape.
+ // Usage in ClipShapeProperty:
+ // Specifies y-axis position of the clip shape center.
//
// Supported types: SizeUnit, SizeFunc, string, float, int.
//
diff --git a/view.go b/view.go
index 016f71a..b57e8c6 100644
--- a/view.go
+++ b/view.go
@@ -560,14 +560,14 @@ func (view *viewData) propertyChanged(tag PropertyName) {
}
case Clip:
- if clip := getClipShape(view, Clip, session); clip != nil && clip.valid(session) {
+ if clip := getClipShapeProperty(view, Clip, session); clip != nil && clip.valid(session) {
session.updateCSSProperty(htmlID, `clip-path`, clip.cssStyle(session))
} else {
session.updateCSSProperty(htmlID, `clip-path`, "none")
}
case ShapeOutside:
- if clip := getClipShape(view, ShapeOutside, session); clip != nil && clip.valid(session) {
+ if clip := getClipShapeProperty(view, ShapeOutside, session); clip != nil && clip.valid(session) {
session.updateCSSProperty(htmlID, string(ShapeOutside), clip.cssStyle(session))
} else {
session.updateCSSProperty(htmlID, string(ShapeOutside), "none")
diff --git a/viewStyle.go b/viewStyle.go
index 1352ce3..1e17e40 100644
--- a/viewStyle.go
+++ b/viewStyle.go
@@ -382,11 +382,11 @@ func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) {
style.writeViewTransformCSS(builder, session)
- if clip := getClipShape(style, Clip, session); clip != nil && clip.valid(session) {
+ if clip := getClipShapeProperty(style, Clip, session); clip != nil && clip.valid(session) {
builder.add(`clip-path`, clip.cssStyle(session))
}
- if clip := getClipShape(style, ShapeOutside, session); clip != nil && clip.valid(session) {
+ if clip := getClipShapeProperty(style, ShapeOutside, session); clip != nil && clip.valid(session) {
builder.add(`shape-outside`, clip.cssStyle(session))
}
diff --git a/viewStyleSet.go b/viewStyleSet.go
index 0139e87..227b742 100644
--- a/viewStyleSet.go
+++ b/viewStyleSet.go
@@ -412,7 +412,7 @@ func viewStyleSet(style Properties, tag PropertyName, value any) []PropertyName
return nil
case Clip, ShapeOutside:
- return setClipShapeProperty(style, tag, value)
+ return setClipShapePropertyProperty(style, tag, value)
case Filter, BackdropFilter:
return setFilterProperty(style, tag, value)
From ec796b36976dbb1021ca8b2e9d19cf4a67875eb3 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Fri, 6 Dec 2024 18:44:28 +0300
Subject: [PATCH 34/43] Update README.md
---
README.md | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 9b06c64..c7537c8 100644
--- a/README.md
+++ b/README.md
@@ -1308,7 +1308,7 @@ There are 4 types of crop areas
Rectangular cropping area. Created with the function:
- func InsetClip(top, right, bottom, left SizeUnit, radius RadiusProperty) ClipShapeProperty
+ func NewInsetClip(top, right, bottom, left SizeUnit, radius RadiusProperty) ClipShapeProperty
where top, right, bottom, left are the distance from respectively the top, right, bottom and left borders of the View
to the cropping border of the same name; radius - sets the radii of the corners of the cropping area
@@ -1324,7 +1324,7 @@ The textual description of the rectangular cropping area is in the following for
Round cropping area. Created with the function:
- func CircleClip(x, y, radius SizeUnit) ClipShapeProperty
+ func NewCircleClip(x, y, radius SizeUnit) ClipShapeProperty
where x, y - coordinates of the center of the circle; radius - radius
@@ -1336,7 +1336,7 @@ The textual description of the circular cropping area is in the following format
Elliptical cropping area. Created with the function:
- func EllipseClip(x, y, rx, ry SizeUnit) ClipShapeProperty
+ func NewEllipseClip(x, y, rx, ry SizeUnit) ClipShapeProperty
where x, y - coordinates of the center of the ellipse; rх - radius of the ellipse along the X axis; ry is the radius of the ellipse along the Y axis.
@@ -1348,8 +1348,8 @@ The textual description of the elliptical clipping region is in the following fo
Polygonal cropping area. Created using functions:
- func PolygonClip(points []any) ClipShapeProperty
- func PolygonPointsClip(points []SizeUnit) ClipShapeProperty
+ func NewPolygonClip(points []any) ClipShapeProperty
+ func NewPolygonPointsClip(points []SizeUnit) ClipShapeProperty
an array of corner points of the polygon is passed as an argument in the following order: x1, y1, x2, y2, …
The elements of the argument to the PolygonClip function can be either text constants,
From 1a60488537fdfa50cfac9938f05d7b0eb0dfafff Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Fri, 6 Dec 2024 18:52:34 +0300
Subject: [PATCH 35/43] Renamed ViewFilter interface -> FilterProperty
---
CHANGELOG.md | 2 ++
README-ru.md | 8 ++---
README.md | 10 +++---
viewFilter.go => filter.go | 68 +++++++++++++++++++-------------------
propertyNames.go | 12 +++----
view.go | 4 +--
viewStyle.go | 4 +--
7 files changed, 55 insertions(+), 53 deletions(-)
rename viewFilter.go => filter.go (86%)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 89806b0..cecc189 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -24,6 +24,8 @@
EllipseClip function -> NewEllipseClip
PolygonClip function -> NewPolygonClip
PolygonPointsClip function -> NewPolygonPointsClip
+ ViewFilter interface -> FilterProperty
+ NewViewFilter function -> NewFilterProperty
* Added functions: NewBounds, NewEllipticRadius, NewRadii, NewLinearGradient, NewCircleRadialGradient,
NewEllipseRadialGradient, GetPushTransform, GetPushDuration, GetPushTiming, IsMoveToFrontAnimation,
diff --git a/README-ru.md b/README-ru.md
index c2442b2..0ee8d23 100644
--- a/README-ru.md
+++ b/README-ru.md
@@ -1435,10 +1435,10 @@ radius необходимо передать nil
Свойство "filter" (константа Filter) применяет ко View такие графические эффекты, как размытие, смещение цвета, изменение яркости/контрастности и т.п.
Свойства "backdrop-filter" (константа BackdropFilter) применяет такие же эффекты но к содержимому располагающемся ниже View.
-В качестве значения свойств "filter" и "backdrop-filter" используется только интерфейс ViewFilter. ViewFilter создается с помощью
+В качестве значения свойств "filter" и "backdrop-filter" используется только интерфейс FilterProperty. FilterProperty создается с помощью
функции
- func NewViewFilter(params Params) ViewFilter
+ func NewFilterProperty(params Params) FilterProperty
В аргументе перечисляются применяемые эффекты. Возможны следующие эффекты:
@@ -1457,8 +1457,8 @@ radius необходимо передать nil
Получить значение текущего фильтра можно с помощью функций
- func GetFilter(view View, subviewID ...string) ViewFilter
- func GetBackdropFilter(view View, subviewID ...string) ViewFilter
+ func GetFilter(view View, subviewID ...string) FilterProperty
+ func GetBackdropFilter(view View, subviewID ...string) FilterProperty
### Свойство "semantics"
diff --git a/README.md b/README.md
index c7537c8..e233f6f 100644
--- a/README.md
+++ b/README.md
@@ -1413,10 +1413,10 @@ You can get the value of this property using the function
The "filter" property (Filter constant) applies graphical effects to the View, such as blurring, color shifting, changing brightness/contrast, etc.
The "backdrop-filter" property (BackdropFilter constant) applies the same effects but to the area behind a View.
-Only the ViewFilter interface is used as the value of the "filter" properties.
-ViewFilter is created using the function
+Only the FilterProperty interface is used as the value of the "filter" properties.
+FilterProperty is created using the function
- func NewViewFilter(params Params) ViewFilter
+ func NewFilterProperty(params Params) FilterProperty
The argument lists the effects to apply. The following effects are possible:
@@ -1442,8 +1442,8 @@ Example
You can get the value of the current filter using functions
- func GetFilter(view View, subviewID ...string) ViewFilter
- func GetBackdropFilter(view View, subviewID ...string) ViewFilter
+ func GetFilter(view View, subviewID ...string) FilterProperty
+ func GetBackdropFilter(view View, subviewID ...string) FilterProperty
### "semantics" property
diff --git a/viewFilter.go b/filter.go
similarity index 86%
rename from viewFilter.go
rename to filter.go
index 4731b4b..11d701a 100644
--- a/viewFilter.go
+++ b/filter.go
@@ -5,11 +5,11 @@ import (
"strings"
)
-// Constants for [ViewFilter] specific properties and events
+// Constants for [FilterProperty] specific properties and events
const (
// Blur is the constant for "blur" property tag.
//
- // Used by ViewFilter.
+ // Used by FilterProperty.
// Applies a Gaussian blur. The value of radius defines the value of the standard deviation to the Gaussian function, or
// how many pixels on the screen blend into each other, so a larger value will create more blur. The lacuna value for
// interpolation is 0. The parameter is specified as a length in pixels.
@@ -21,7 +21,7 @@ const (
// Brightness is the constant for "brightness" property tag.
//
- // Used by ViewFilter.
+ // Used by FilterProperty.
// Applies a linear multiplier to input image, making it appear more or less bright. A value of 0% will create an image
// that is completely black. A value of 100% leaves the input unchanged. Other values are linear multipliers on the
// effect. Values of an amount over 100% are allowed, providing brighter results.
@@ -33,7 +33,7 @@ const (
// Contrast is the constant for "contrast" property tag.
//
- // Used by ViewFilter.
+ // Used by FilterProperty.
// Adjusts the contrast of the input. A value of 0% will create an image that is completely black. A value of 100% leaves
// the input unchanged. Values of amount over 100% are allowed, providing results with less contrast.
//
@@ -44,7 +44,7 @@ const (
// DropShadow is the constant for "drop-shadow" property tag.
//
- // Used by ViewFilter.
+ // Used by FilterProperty.
// Applies a drop shadow effect to the input image. A drop shadow is effectively a blurred, offset version of the input
// image's alpha mask drawn in a particular color, composited below the image. Shadow parameters are set using the
// ShadowProperty interface.
@@ -62,7 +62,7 @@ const (
// Grayscale is the constant for "grayscale" property tag.
//
- // Used by ViewFilter.
+ // Used by FilterProperty.
// Converts the input image to grayscale. The value of ‘amount’ defines the proportion of the conversion. A value of 100%
// is completely grayscale. A value of 0% leaves the input unchanged. Values between 0% and 100% are linear multipliers on
// the effect.
@@ -74,7 +74,7 @@ const (
// HueRotate is the constant for "hue-rotate" property tag.
//
- // Used by ViewFilter.
+ // Used by FilterProperty.
// Applies a hue rotation on the input image. The value of ‘angle’ defines the number of degrees around the color circle
// the input samples will be adjusted. A value of 0deg leaves the input unchanged. If the ‘angle’ parameter is missing, a
// value of 0deg is used. Though there is no maximum value, the effect of values above 360deg wraps around.
@@ -93,7 +93,7 @@ const (
// Invert is the constant for "invert" property tag.
//
- // Used by ViewFilter.
+ // Used by FilterProperty.
// Inverts the samples in the input image. The value of ‘amount’ defines the proportion of the conversion. A value of 100%
// is completely inverted. A value of 0% leaves the input unchanged. Values between 0% and 100% are linear multipliers on
// the effect.
@@ -105,7 +105,7 @@ const (
// Saturate is the constant for "saturate" property tag.
//
- // Used by ViewFilter.
+ // Used by FilterProperty.
// Saturates the input image. The value of ‘amount’ defines the proportion of the conversion. A value of 0% is completely
// un-saturated. A value of 100% leaves the input unchanged. Other values are linear multipliers on the effect. Values of
// amount over 100% are allowed, providing super-saturated results.
@@ -117,7 +117,7 @@ const (
// Sepia is the constant for "sepia" property tag.
//
- // Used by ViewFilter.
+ // Used by FilterProperty.
// Converts the input image to sepia. The value of ‘amount’ defines the proportion of the conversion. A value of 100% is
// completely sepia. A value of 0% leaves the input unchanged. Values between 0% and 100% are linear multipliers on the
// effect.
@@ -128,23 +128,23 @@ const (
Sepia PropertyName = "sepia"
)
-// ViewFilter defines an applied to a View a graphical effects like blur or color shift.
+// FilterProperty defines an applied to a View a graphical effects like blur or color shift.
// Allowable properties are Blur, Brightness, Contrast, DropShadow, Grayscale, HueRotate, Invert, Opacity, Saturate, and Sepia
-type ViewFilter interface {
+type FilterProperty interface {
Properties
fmt.Stringer
stringWriter
cssStyle(session Session) string
}
-type viewFilter struct {
+type filterData struct {
dataProperty
}
-// NewViewFilter creates the new ViewFilter
-func NewViewFilter(params Params) ViewFilter {
+// NewFilterProperty creates the new FilterProperty
+func NewFilterProperty(params Params) FilterProperty {
if len(params) > 0 {
- filter := new(viewFilter)
+ filter := new(filterData)
filter.init()
for tag, value := range params {
if !filter.Set(tag, value) {
@@ -156,8 +156,8 @@ func NewViewFilter(params Params) ViewFilter {
return nil
}
-func newViewFilter(obj DataObject) ViewFilter {
- filter := new(viewFilter)
+func newFilterProperty(obj DataObject) FilterProperty {
+ filter := new(filterData)
filter.init()
for i := 0; i < obj.PropertyCount(); i++ {
if node := obj.Property(i); node != nil {
@@ -186,13 +186,13 @@ func newViewFilter(obj DataObject) ViewFilter {
return nil
}
-func (filter *viewFilter) init() {
+func (filter *filterData) init() {
filter.dataProperty.init()
- filter.set = viewFilterSet
+ filter.set = filterDataSet
filter.supportedProperties = []PropertyName{Blur, Brightness, Contrast, Saturate, Grayscale, Invert, Opacity, Sepia, HueRotate, DropShadow}
}
-func viewFilterSet(properties Properties, tag PropertyName, value any) []PropertyName {
+func filterDataSet(properties Properties, tag PropertyName, value any) []PropertyName {
switch tag {
case Blur, Brightness, Contrast, Saturate:
return setFloatProperty(properties, tag, value, 0, 10000)
@@ -213,11 +213,11 @@ func viewFilterSet(properties Properties, tag PropertyName, value any) []Propert
return nil
}
-func (filter *viewFilter) String() string {
+func (filter *filterData) String() string {
return runStringWriter(filter)
}
-func (filter *viewFilter) writeString(buffer *strings.Builder, indent string) {
+func (filter *filterData) writeString(buffer *strings.Builder, indent string) {
buffer.WriteString("filter { ")
comma := false
tags := filter.AllTags()
@@ -235,7 +235,7 @@ func (filter *viewFilter) writeString(buffer *strings.Builder, indent string) {
buffer.WriteString(" }")
}
-func (filter *viewFilter) cssStyle(session Session) string {
+func (filter *filterData) cssStyle(session Session) string {
buffer := allocStringBuilder()
defer freeStringBuilder(buffer)
@@ -287,27 +287,27 @@ func (filter *viewFilter) cssStyle(session Session) string {
func setFilterProperty(properties Properties, tag PropertyName, value any) []PropertyName {
switch value := value.(type) {
- case ViewFilter:
+ case FilterProperty:
properties.setRaw(tag, value)
return []PropertyName{tag}
case string:
if obj := NewDataObject(value); obj == nil {
- if filter := newViewFilter(obj); filter != nil {
+ if filter := newFilterProperty(obj); filter != nil {
properties.setRaw(tag, filter)
return []PropertyName{tag}
}
}
case DataObject:
- if filter := newViewFilter(value); filter != nil {
+ if filter := newFilterProperty(value); filter != nil {
properties.setRaw(tag, filter)
return []PropertyName{tag}
}
case DataValue:
if value.IsObject() {
- if filter := newViewFilter(value.Object()); filter != nil {
+ if filter := newFilterProperty(value.Object()); filter != nil {
properties.setRaw(tag, filter)
return []PropertyName{tag}
}
@@ -320,15 +320,15 @@ func setFilterProperty(properties Properties, tag PropertyName, value any) []Pro
// GetFilter returns a View graphical effects like blur or color shift.
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
-func GetFilter(view View, subviewID ...string) ViewFilter {
+func GetFilter(view View, subviewID ...string) FilterProperty {
if view = getSubview(view, subviewID); view != nil {
if value := view.getRaw(Filter); value != nil {
- if filter, ok := value.(ViewFilter); ok {
+ if filter, ok := value.(FilterProperty); ok {
return filter
}
}
if value := valueFromStyle(view, Filter); value != nil {
- if filter, ok := value.(ViewFilter); ok {
+ if filter, ok := value.(FilterProperty); ok {
return filter
}
}
@@ -339,15 +339,15 @@ func GetFilter(view View, subviewID ...string) ViewFilter {
// GetBackdropFilter returns the area behind a View graphical effects like blur or color shift.
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
-func GetBackdropFilter(view View, subviewID ...string) ViewFilter {
+func GetBackdropFilter(view View, subviewID ...string) FilterProperty {
if view = getSubview(view, subviewID); view != nil {
if value := view.getRaw(BackdropFilter); value != nil {
- if filter, ok := value.(ViewFilter); ok {
+ if filter, ok := value.(FilterProperty); ok {
return filter
}
}
if value := valueFromStyle(view, BackdropFilter); value != nil {
- if filter, ok := value.(ViewFilter); ok {
+ if filter, ok := value.(FilterProperty); ok {
return filter
}
}
diff --git a/propertyNames.go b/propertyNames.go
index 14b1b23..3fd422c 100644
--- a/propertyNames.go
+++ b/propertyNames.go
@@ -162,7 +162,7 @@ const (
// Opacity is the constant for "opacity" property tag.
//
- // Used by View, ViewFilter.
+ // Used by View, FilterProperty.
//
// # Usage in View:
//
@@ -173,7 +173,7 @@ const (
//
// Internal type is float, other types converted to it during assignment.
//
- // # Usage in ViewFilter:
+ // # Usage in FilterProperty:
//
// Opacity is the degree to which content behind the view is hidden, and is the opposite of transparency. Value is in
// range 0% to 100%, where 0% is fully transparent.
@@ -2505,9 +2505,9 @@ const (
// Used by View.
// Applies graphical effects to a view, such as blurring, color shifting, changing brightness/contrast, etc.
//
- // Supported types: ViewFilter.
+ // Supported types: FilterProperty.
//
- // See ViewFilter description for more details.
+ // See FilterProperty description for more details.
Filter PropertyName = "filter"
// BackdropFilter is the constant for "backdrop-filter" property tag.
@@ -2516,9 +2516,9 @@ const (
// Applies graphical effects to the area behind a view, such as blurring, color shifting, changing brightness/contrast,
// etc.
//
- // Supported types: ViewFilter.
+ // Supported types: FilterProperty.
//
- // See ViewFilter description for more details.
+ // See FilterProperty description for more details.
BackdropFilter PropertyName = "backdrop-filter"
// Clip is the constant for "clip" property tag.
diff --git a/view.go b/view.go
index b57e8c6..49bf2ee 100644
--- a/view.go
+++ b/view.go
@@ -576,7 +576,7 @@ func (view *viewData) propertyChanged(tag PropertyName) {
case Filter:
text := ""
if value := view.getRaw(Filter); value != nil {
- if filter, ok := value.(ViewFilter); ok {
+ if filter, ok := value.(FilterProperty); ok {
text = filter.cssStyle(session)
}
}
@@ -585,7 +585,7 @@ func (view *viewData) propertyChanged(tag PropertyName) {
case BackdropFilter:
text := ""
if value := view.getRaw(BackdropFilter); value != nil {
- if filter, ok := value.(ViewFilter); ok {
+ if filter, ok := value.(FilterProperty); ok {
text = filter.cssStyle(session)
}
}
diff --git a/viewStyle.go b/viewStyle.go
index 1e17e40..d172038 100644
--- a/viewStyle.go
+++ b/viewStyle.go
@@ -391,7 +391,7 @@ func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) {
}
if value := style.getRaw(Filter); value != nil {
- if filter, ok := value.(ViewFilter); ok {
+ if filter, ok := value.(FilterProperty); ok {
if text := filter.cssStyle(session); text != "" {
builder.add(string(Filter), text)
}
@@ -399,7 +399,7 @@ func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) {
}
if value := style.getRaw(BackdropFilter); value != nil {
- if filter, ok := value.(ViewFilter); ok {
+ if filter, ok := value.(FilterProperty); ok {
if text := filter.cssStyle(session); text != "" {
builder.add(`-webkit-backdrop-filter`, text)
builder.add(string(BackdropFilter), text)
From 0c2bea9a750903f002cbbc9c3ce1410a82eb2a3e Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Fri, 6 Dec 2024 19:15:23 +0300
Subject: [PATCH 36/43] Renamed Animation interface -> AnimationProperty
---
CHANGELOG.md | 2 +
README-ru.md | 26 ++++++-------
README.md | 26 ++++++-------
animation.go | 100 ++++++++++++++++++++++++------------------------
animationRun.go | 12 +++---
customView.go | 10 ++---
view.go | 28 +++++++-------
viewStyle.go | 12 +++---
viewStyleSet.go | 6 +--
9 files changed, 112 insertions(+), 110 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cecc189..c0227ba 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,8 @@
PolygonPointsClip function -> NewPolygonPointsClip
ViewFilter interface -> FilterProperty
NewViewFilter function -> NewFilterProperty
+ Animation interface -> AnimationProperty
+ AnimationTag constant -> Animation
* Added functions: NewBounds, NewEllipticRadius, NewRadii, NewLinearGradient, NewCircleRadialGradient,
NewEllipseRadialGradient, GetPushTransform, GetPushDuration, GetPushTiming, IsMoveToFrontAnimation,
diff --git a/README-ru.md b/README-ru.md
index 0ee8d23..2beca26 100644
--- a/README-ru.md
+++ b/README-ru.md
@@ -5038,14 +5038,14 @@ onNo или onCancel (если она не nil).
* Анимированное изменения значения свойства (далее "анимация перехода")
* Сценарий анимированного изменения одного или нескольких свойств (далее просто "сценарий анимации")
-### Интерфейс Animation
+### Интерфейс AnimationProperty
-Для задания параметров анимации используется интерфейс Animation. Он расширяет интерфейс Properties.
+Для задания параметров анимации используется интерфейс AnimationProperty. Он расширяет интерфейс Properties.
Интерфейс создается с помощью функции:
- func NewAnimation(params Params) Animation
+ func NewAnimation(params Params) AnimationProperty
-Часть свойств интерфейса Animation используется в обоих типах анимации, остальные используются
+Часть свойств интерфейса AnimationProperty используется в обоих типах анимации, остальные используются
только в сценариях анимации.
Общими свойствами являются
@@ -5112,7 +5112,7 @@ x1 и x2 должны быть в диапазоне [0, 1]. Вы можете
Однократная анимация запускается с помощью функции SetAnimated интерфейса View. Данная функция имеет следующее
описание:
- SetAnimated(tag string, value any, animation Animation) bool
+ SetAnimated(tag string, value any, animation AnimationProperty) bool
Она присваивает свойству новое значение, при этом изменение происходит с использованием заданной анимации.
Например,
@@ -5124,11 +5124,11 @@ x1 и x2 должны быть в диапазоне [0, 1]. Вы можете
Есть также глобальная функция для анимированного однократного изменения значения свойства дочернего View
- func SetAnimated(rootView View, viewID, tag string, value any, animation Animation) bool
+ func SetAnimated(rootView View, viewID, tag string, value any, animation AnimationProperty) bool
Постоянная анимация запускается каждый раз когда изменяется значение свойства. Для задания постоянной
анимации перехода используется свойство "transition" (константа Transition). В качества значения данному
-Свойству присваивается rui.Params, где в качестве ключа должно быть имя свойства, а значение - интерфейс Animation.
+Свойству присваивается rui.Params, где в качестве ключа должно быть имя свойства, а значение - интерфейс AnimationProperty.
Например,
view.Set(rui.Transition, rui.Params{
@@ -5151,7 +5151,7 @@ x1 и x2 должны быть в диапазоне [0, 1]. Вы можете
Добавлять новые анимации перехода рекомендуется с помощью функции
- func AddTransition(view View, subviewID, tag string, animation Animation) bool
+ func AddTransition(view View, subviewID, tag string, animation AnimationProperty) bool
Вызов данной функции эквивалентен следующему коду
@@ -5192,7 +5192,7 @@ x1 и x2 должны быть в диапазоне [0, 1]. Вы можете
### Сценарий анимации
Сценарий анимации описывает более сложную анимацию, по сравнению с анимацией перехода. Для этого
-в Animation добавляются дополнительные свойства:
+в AnimationProperty добавляются дополнительные свойства:
#### Свойство "property"
@@ -5256,11 +5256,11 @@ KeyFrames - промежуточные значения свойства (клю
#### Запуск анимации
-Для запуска сценария анимации необходимо созданный Animation интерфейс присвоить свойству "animation"
-(константа AnimationTag). Если View уже отображается на экране, то анимация запускается сразу (с учетом
+Для запуска сценария анимации необходимо созданный AnimationProperty интерфейс присвоить свойству "animation"
+(константа Animation). Если View уже отображается на экране, то анимация запускается сразу (с учетом
заданной задержки), в противоположном случае анимация запускается как только View отобразится на экране.
-Свойству "animation" можно присваивать Animation и []Animation, т.е. можно запускать несколько анимаций
+Свойству "animation" можно присваивать AnimationProperty и []AnimationProperty, т.е. можно запускать несколько анимаций
одновременно для одного View
Пример,
@@ -5278,7 +5278,7 @@ KeyFrames - промежуточные значения свойства (клю
rui.Duration: 2,
rui.TimingFunction: LinearTiming,
})
- rui.Set(view, "subview", rui.AnimationTag, animation)
+ rui.Set(view, "subview", rui.Animation, animation)
#### Свойство "animation-paused"
diff --git a/README.md b/README.md
index e233f6f..c63510c 100644
--- a/README.md
+++ b/README.md
@@ -5009,14 +5009,14 @@ The library supports two types of animation:
* Animated property value changes (hereinafter "transition animation")
* Script animated change of one or more properties (hereinafter simply "animation script")
-### Animation interface
+### AnimationProperty interface
-The Animation interface is used to set animation parameters. It extends the Properties interface.
+The AnimationProperty interface is used to set animation parameters. It extends the Properties interface.
The interface is created using the function:
- func NewAnimation(params Params) Animation
+ func NewAnimation(params Params) AnimationProperty
-Some of the properties of the Animation interface are used in both types of animation, the rest are used only
+Some of the properties of the AnimationProperty interface are used in both types of animation, the rest are used only
in animation scripts.
Common properties are
@@ -5082,7 +5082,7 @@ There are two types of transition animations:
A one-time animation is triggered using the SetAnimated function of the View interface.
This function has the following description:
- SetAnimated(tag string, value any, animation Animation) bool
+ SetAnimated(tag string, value any, animation AnimationProperty) bool
It assigns a new value to the property, and the change occurs using the specified animation.
For example,
@@ -5094,12 +5094,12 @@ For example,
There is also a global function for animated one-time change of the property value of the child View
- func SetAnimated(rootView View, viewID, tag string, value any, animation Animation) bool
+ func SetAnimated(rootView View, viewID, tag string, value any, animation AnimationProperty) bool
A persistent animation runs every time the property value changes.
To set the constant animation of the transition, use the "transition" property (the Transition constant).
As a value, this property is assigned rui.Params, where the property name should be the key,
-and the value should be the Animation interface.
+and the value should be the AnimationProperty interface.
For example,
view.Set(rui.Transition, rui.Params{
@@ -5122,7 +5122,7 @@ To get the current list of permanent transition animations, use the function
It is recommended to add new transition animations using the function
- func AddTransition(view View, subviewID, tag string, animation Animation) bool
+ func AddTransition(view View, subviewID, tag string, animation AnimationProperty) bool
Calling this function is equivalent to the following code
@@ -5162,7 +5162,7 @@ Get lists of listeners for transition animation events using functions:
### Animation script
-An animation script describes a more complex animation than a transition animation. To do this, additional properties are added to Animation:
+An animation script describes a more complex animation than a transition animation. To do this, additional properties are added to AnimationProperty:
#### "property" property
@@ -5228,12 +5228,12 @@ backward playback of the sequence. It can take the following values:
#### Animation start
-To start the animation script, you must assign the interface created by Animation to the "animation" property
-(the AnimationTag constant). If the View is already displayed on the screen, then the animation starts immediately
+To start the animation script, you must assign the interface created by AnimationProperty to the "animation" property
+(the Animation constant). If the View is already displayed on the screen, then the animation starts immediately
(taking into account the specified delay), otherwise the animation starts as soon as the View is displayed
on the screen.
-The "animation" property can be assigned Animation and [] Animation, ie. you can run several animations
+The "animation" property can be assigned AnimationProperty and [] AnimationProperty, ie. you can run several animations
at the same time for one View
Example,
@@ -5251,7 +5251,7 @@ Example,
rui.Duration: 2,
rui.TimingFunction: LinearTiming,
})
- rui.Set(view, "subview", rui.AnimationTag, animation)
+ rui.Set(view, "subview", rui.Animation, animation)
#### "animation-paused" property
diff --git a/animation.go b/animation.go
index b187f20..f2e3034 100644
--- a/animation.go
+++ b/animation.go
@@ -9,20 +9,20 @@ import (
// Constants which related to view's animation
const (
- // AnimationTag is the constant for "animation" property tag.
+ // Animation is the constant for "animation" property tag.
//
// Used by View.
// Sets and starts animations.
//
- // Supported types: Animation, []Animation.
+ // Supported types: AnimationProperty, []AnimationProperty.
//
- // Internal type is []Animation, other types converted to it during assignment.
- // See Animation description for more details.
- AnimationTag PropertyName = "animation"
+ // Internal type is []AnimationProperty, other types converted to it during assignment.
+ // See AnimationProperty description for more details.
+ Animation PropertyName = "animation"
// AnimationPaused is the constant for "animation-paused" property tag.
//
- // Used by Animation.
+ // Used by AnimationProperty.
// Controls whether the animation is running or paused.
//
// Supported types: bool, int, string.
@@ -36,7 +36,7 @@ const (
//
// Used by View.
//
- // Sets transition animation of view properties. Each provided property must contain Animation which describe how
+ // Sets transition animation of view properties. Each provided property must contain AnimationProperty which describe how
// particular property will be animated on property value change. Transition animation can be applied to properties of the
// type SizeUnit, Color, AngleUnit, float64 and composite properties that contain elements of the listed types(for
// example, "shadow", "border", etc.). If we'll try to animate other properties with internal type like bool or
@@ -49,7 +49,7 @@ const (
// PropertyTag is the constant for "property" property tag.
//
- // Used by Animation.
+ // Used by AnimationProperty.
//
// Describes a scenario for changing a View's property. Used only for animation script.
//
@@ -61,7 +61,7 @@ const (
// Duration is the constant for "duration" property tag.
//
- // Used by Animation.
+ // Used by AnimationProperty.
//
// Sets the length of time in seconds that an animation takes to complete one cycle.
//
@@ -72,7 +72,7 @@ const (
// Delay is the constant for "delay" property tag.
//
- // Used by Animation.
+ // Used by AnimationProperty.
//
// Specifies the amount of time in seconds to wait from applying the animation to an element before beginning to perform
// the animation. The animation can start later, immediately from its beginning or immediately and partway through the
@@ -85,7 +85,7 @@ const (
// TimingFunction is the constant for "timing-function" property tag.
//
- // Used by Animation.
+ // Used by AnimationProperty.
//
// Set how an animation progresses through the duration of each cycle.
//
@@ -103,7 +103,7 @@ const (
// IterationCount is the constant for "iteration-count" property tag.
//
- // Used by Animation.
+ // Used by AnimationProperty.
//
// Sets the number of times an animation sequence should be played before stopping. Used only for animation script.
//
@@ -114,7 +114,7 @@ const (
// AnimationDirection is the constant for "animation-direction" property tag.
//
- // Used by Animation.
+ // Used by AnimationProperty.
//
// Whether an animation should play forward, backward, or alternate back and forth between playing the sequence forward
// and backward. Used only for animation script.
@@ -208,21 +208,21 @@ type animationData struct {
keyFramesName string
usageCounter int
view View
- listener func(view View, animation Animation, event PropertyName)
+ listener func(view View, animation AnimationProperty, event PropertyName)
oldListeners map[PropertyName][]func(View, PropertyName)
- oldAnimation []Animation
+ oldAnimation []AnimationProperty
}
-// Animation interface is used to set animation parameters. Used properties:
+// AnimationProperty interface is used to set animation parameters. Used properties:
//
// "property", "id", "duration", "delay", "timing-function", "iteration-count", and "animation-direction"
-type Animation interface {
+type AnimationProperty interface {
Properties
fmt.Stringer
// Start starts the animation for the view specified by the first argument.
// The second argument specifies the animation event listener (can be nil)
- Start(view View, listener func(view View, animation Animation, event PropertyName)) bool
+ Start(view View, listener func(view View, animation AnimationProperty, event PropertyName)) bool
// Stop stops the animation
Stop()
// Pause pauses the animation
@@ -239,7 +239,7 @@ type Animation interface {
unused(session Session)
}
-func parseAnimation(obj DataObject) Animation {
+func parseAnimation(obj DataObject) AnimationProperty {
animation := new(animationData)
animation.init()
@@ -257,7 +257,7 @@ func parseAnimation(obj DataObject) Animation {
}
// NewAnimation creates a new animation object and return its interface
-func NewAnimation(params Params) Animation {
+func NewAnimation(params Params) AnimationProperty {
animation := new(animationData)
animation.init()
@@ -269,7 +269,7 @@ func NewAnimation(params Params) Animation {
func (animation *animationData) init() {
animation.dataProperty.init()
- animation.normalize = normalizeAnimationTag
+ animation.normalize = normalizeAnimation
animation.set = animationSet
animation.supportedProperties = []PropertyName{ID, PropertyTag, Duration, Delay, TimingFunction, IterationCount, AnimationDirection}
}
@@ -314,7 +314,7 @@ func (animation *animationData) unused(session Session) {
}
}
-func normalizeAnimationTag(tag PropertyName) PropertyName {
+func normalizeAnimation(tag PropertyName) PropertyName {
tag = defaultNormalize(tag)
if tag == Direction {
return AnimationDirection
@@ -777,7 +777,7 @@ func (session *sessionData) registerAnimation(props []AnimatedProperty) string {
return name
}
-func (view *viewData) SetAnimated(tag PropertyName, value any, animation Animation) bool {
+func (view *viewData) SetAnimated(tag PropertyName, value any, animation AnimationProperty) bool {
if animation == nil {
return view.Set(tag, value)
}
@@ -790,7 +790,7 @@ func (view *viewData) SetAnimated(tag PropertyName, value any, animation Animati
session.updateProperty(htmlID, "ontransitioncancel", "transitionCancelEvent(this, event)")
transitions := getTransitionProperty(view)
- var prevAnimation Animation = nil
+ var prevAnimation AnimationProperty = nil
if transitions != nil {
if prev, ok := transitions[tag]; ok {
prevAnimation = prev
@@ -812,8 +812,8 @@ func (view *viewData) SetAnimated(tag PropertyName, value any, animation Animati
}
func animationCSS(properties Properties, session Session) string {
- if value := properties.getRaw(AnimationTag); value != nil {
- if animations, ok := value.([]Animation); ok {
+ if value := properties.getRaw(Animation); value != nil {
+ if animations, ok := value.([]AnimationProperty); ok {
buffer := allocStringBuilder()
defer freeStringBuilder(buffer)
@@ -874,7 +874,7 @@ func (view *viewData) updateTransitionCSS() {
}
*/
-func (style *viewStyle) Transition(tag PropertyName) Animation {
+func (style *viewStyle) Transition(tag PropertyName) AnimationProperty {
if transitions := getTransitionProperty(style); transitions != nil {
if anim, ok := transitions[tag]; ok {
return anim
@@ -883,26 +883,26 @@ func (style *viewStyle) Transition(tag PropertyName) Animation {
return nil
}
-func (style *viewStyle) Transitions() map[PropertyName]Animation {
- result := map[PropertyName]Animation{}
+func (style *viewStyle) Transitions() map[PropertyName]AnimationProperty {
+ result := map[PropertyName]AnimationProperty{}
for tag, animation := range getTransitionProperty(style) {
result[tag] = animation
}
return result
}
-func (style *viewStyle) SetTransition(tag PropertyName, animation Animation) {
+func (style *viewStyle) SetTransition(tag PropertyName, animation AnimationProperty) {
setTransition(style, style.normalize(tag), animation)
}
-func (view *viewData) SetTransition(tag PropertyName, animation Animation) {
+func (view *viewData) SetTransition(tag PropertyName, animation AnimationProperty) {
setTransition(view, view.normalize(tag), animation)
if view.created {
view.session.updateCSSProperty(view.htmlID(), "transition", transitionCSS(view, view.session))
}
}
-func setTransition(properties Properties, tag PropertyName, animation Animation) {
+func setTransition(properties Properties, tag PropertyName, animation AnimationProperty) {
transitions := getTransitionProperty(properties)
if animation == nil {
@@ -915,13 +915,13 @@ func setTransition(properties Properties, tag PropertyName, animation Animation)
} else if transitions != nil {
transitions[tag] = animation
} else {
- properties.setRaw(Transition, map[PropertyName]Animation{tag: animation})
+ properties.setRaw(Transition, map[PropertyName]AnimationProperty{tag: animation})
}
}
-func getTransitionProperty(properties Properties) map[PropertyName]Animation {
+func getTransitionProperty(properties Properties) map[PropertyName]AnimationProperty {
if value := properties.getRaw(Transition); value != nil {
- if transitions, ok := value.(map[PropertyName]Animation); ok {
+ if transitions, ok := value.(map[PropertyName]AnimationProperty); ok {
return transitions
}
}
@@ -930,7 +930,7 @@ func getTransitionProperty(properties Properties) map[PropertyName]Animation {
func setAnimationProperty(properties Properties, tag PropertyName, value any) bool {
- set := func(animations []Animation) {
+ set := func(animations []AnimationProperty) {
properties.setRaw(tag, animations)
for _, animation := range animations {
animation.used()
@@ -938,22 +938,22 @@ func setAnimationProperty(properties Properties, tag PropertyName, value any) bo
}
switch value := value.(type) {
- case Animation:
- set([]Animation{value})
+ case AnimationProperty:
+ set([]AnimationProperty{value})
return true
- case []Animation:
+ case []AnimationProperty:
set(value)
return true
case DataObject:
if animation := parseAnimation(value); animation.hasAnimatedProperty() {
- set([]Animation{animation})
+ set([]AnimationProperty{animation})
return true
}
case DataNode:
- animations := []Animation{}
+ animations := []AnimationProperty{}
result := true
for i := 0; i < value.ArraySize(); i++ {
if obj := value.ArrayElement(i).Object(); obj != nil {
@@ -980,7 +980,7 @@ func setAnimationProperty(properties Properties, tag PropertyName, value any) bo
// SetAnimated sets the property with name "tag" of the "rootView" subview with "viewID" id by value. Result:
// true - success,
// false - error (incompatible type or invalid format of a string value, see AppLog).
-func SetAnimated(rootView View, viewID string, tag PropertyName, value any, animation Animation) bool {
+func SetAnimated(rootView View, viewID string, tag PropertyName, value any, animation AnimationProperty) bool {
if view := ViewByID(rootView, viewID); view != nil {
return view.SetAnimated(tag, value, animation)
}
@@ -995,17 +995,17 @@ func IsAnimationPaused(view View, subviewID ...string) bool {
// GetTransitions returns the subview transitions. The result is always non-nil.
// If the second argument (subviewID) is not specified or it is "" then transitions of the first argument (view) is returned
-func GetTransitions(view View, subviewID ...string) map[PropertyName]Animation {
+func GetTransitions(view View, subviewID ...string) map[PropertyName]AnimationProperty {
if view = getSubview(view, subviewID); view != nil {
return view.Transitions()
}
- return map[PropertyName]Animation{}
+ return map[PropertyName]AnimationProperty{}
}
// GetTransition returns the subview property transition. If there is no transition for the given property then nil is returned.
// If the second argument (subviewID) is not specified or it is "" then transitions of the first argument (view) is returned
-func GetTransition(view View, subviewID string, tag PropertyName) Animation {
+func GetTransition(view View, subviewID string, tag PropertyName) AnimationProperty {
if subviewID != "" {
view = ViewByID(view, subviewID)
}
@@ -1019,7 +1019,7 @@ func GetTransition(view View, subviewID string, tag PropertyName) Animation {
// AddTransition adds the transition for the subview property.
// If the second argument (subviewID) is not specified or it is "" then the transition is added to the first argument (view)
-func AddTransition(view View, subviewID string, tag PropertyName, animation Animation) bool {
+func AddTransition(view View, subviewID string, tag PropertyName, animation AnimationProperty) bool {
if tag != "" {
if subviewID != "" {
view = ViewByID(view, subviewID)
@@ -1035,14 +1035,14 @@ func AddTransition(view View, subviewID string, tag PropertyName, animation Anim
// GetAnimation returns the subview animations. The result is always non-nil.
// If the second argument (subviewID) is not specified or it is "" then transitions of the first argument (view) is returned
-func GetAnimation(view View, subviewID ...string) []Animation {
+func GetAnimation(view View, subviewID ...string) []AnimationProperty {
if view = getSubview(view, subviewID); view != nil {
- if value := view.getRaw(AnimationTag); value != nil {
- if animations, ok := value.([]Animation); ok && animations != nil {
+ if value := view.getRaw(Animation); value != nil {
+ if animations, ok := value.([]AnimationProperty); ok && animations != nil {
return animations
}
}
}
- return []Animation{}
+ return []AnimationProperty{}
}
diff --git a/animationRun.go b/animationRun.go
index 683e359..e9f1eeb 100644
--- a/animationRun.go
+++ b/animationRun.go
@@ -1,6 +1,6 @@
package rui
-func (animation *animationData) Start(view View, listener func(view View, animation Animation, event PropertyName)) bool {
+func (animation *animationData) Start(view View, listener func(view View, animation AnimationProperty, event PropertyName)) bool {
if view == nil {
ErrorLog("nil View in animation.Start() function")
return false
@@ -13,8 +13,8 @@ func (animation *animationData) Start(view View, listener func(view View, animat
animation.listener = listener
animation.oldAnimation = nil
- if value := view.Get(AnimationTag); value != nil {
- if oldAnimation, ok := value.([]Animation); ok && len(oldAnimation) > 0 {
+ if value := view.Get(Animation); value != nil {
+ if oldAnimation, ok := value.([]AnimationProperty); ok && len(oldAnimation) > 0 {
animation.oldAnimation = oldAnimation
}
}
@@ -42,7 +42,7 @@ func (animation *animationData) Start(view View, listener func(view View, animat
setListeners(AnimationCancelEvent, animation.onAnimationCancel)
setListeners(AnimationIterationEvent, animation.onAnimationIteration)
- view.Set(AnimationTag, animation)
+ view.Set(Animation, animation)
return true
}
@@ -57,10 +57,10 @@ func (animation *animationData) finish() {
}
if animation.oldAnimation != nil {
- animation.view.Set(AnimationTag, animation.oldAnimation)
+ animation.view.Set(Animation, animation.oldAnimation)
animation.oldAnimation = nil
} else {
- animation.view.Set(AnimationTag, "")
+ animation.view.Set(Animation, "")
}
animation.oldListeners = map[PropertyName][]func(View, PropertyName){}
diff --git a/customView.go b/customView.go
index 06c673d..e8f8afb 100644
--- a/customView.go
+++ b/customView.go
@@ -89,7 +89,7 @@ func (customView *CustomViewData) Set(tag PropertyName, value any) bool {
// SetAnimated sets the value (second argument) of the property with name defined by the first argument.
// Return "true" if the value has been set, in the opposite case "false" are returned and
// a description of the error is written to the log
-func (customView *CustomViewData) SetAnimated(tag PropertyName, value any, animation Animation) bool {
+func (customView *CustomViewData) SetAnimated(tag PropertyName, value any, animation AnimationProperty) bool {
return customView.superView.SetAnimated(tag, value, animation)
}
@@ -323,7 +323,7 @@ func (customView *CustomViewData) setScroll(x, y, width, height float64) {
}
// Transition returns the transition animation of the property(tag). Returns nil is there is no transition animation.
-func (customView *CustomViewData) Transition(tag PropertyName) Animation {
+func (customView *CustomViewData) Transition(tag PropertyName) AnimationProperty {
if customView.superView != nil {
return customView.superView.Transition(tag)
}
@@ -331,17 +331,17 @@ func (customView *CustomViewData) Transition(tag PropertyName) Animation {
}
// Transitions returns a map of transition animations. The result is always non-nil.
-func (customView *CustomViewData) Transitions() map[PropertyName]Animation {
+func (customView *CustomViewData) Transitions() map[PropertyName]AnimationProperty {
if customView.superView != nil {
return customView.superView.Transitions()
}
- return map[PropertyName]Animation{}
+ return map[PropertyName]AnimationProperty{}
}
// SetTransition sets the transition animation for the property if "animation" argument is not nil, and
// removes the transition animation of the property if "animation" argument is nil.
// The "tag" argument is the property name.
-func (customView *CustomViewData) SetTransition(tag PropertyName, animation Animation) {
+func (customView *CustomViewData) SetTransition(tag PropertyName, animation AnimationProperty) {
if customView.superView != nil {
customView.superView.SetTransition(tag, animation)
}
diff --git a/view.go b/view.go
index 49bf2ee..d6ee7f8 100644
--- a/view.go
+++ b/view.go
@@ -62,7 +62,7 @@ type View interface {
// SetAnimated sets the value (second argument) of the property with name defined by the first argument.
// Return "true" if the value has been set, in the opposite case "false" are returned and
// a description of the error is written to the log
- SetAnimated(tag PropertyName, value any, animation Animation) bool
+ SetAnimated(tag PropertyName, value any, animation AnimationProperty) bool
// SetChangeListener set the function to track the change of the View property
SetChangeListener(tag PropertyName, listener func(View, PropertyName))
@@ -102,7 +102,7 @@ type viewData struct {
parentID string
systemClass string
changeListener map[PropertyName]func(View, PropertyName)
- singleTransition map[PropertyName]Animation
+ singleTransition map[PropertyName]AnimationProperty
addCSS map[string]string
frame Frame
scroll Frame
@@ -155,7 +155,7 @@ func (view *viewData) init(session Session) {
view.changeListener = map[PropertyName]func(View, PropertyName){}
view.addCSS = map[string]string{}
//view.animation = map[string]AnimationEndListener{}
- view.singleTransition = map[PropertyName]Animation{}
+ view.singleTransition = map[PropertyName]AnimationProperty{}
view.noResizeEvent = false
view.created = false
view.hasHtmlDisabled = false
@@ -294,16 +294,16 @@ func (view *viewData) removeFunc(tag PropertyName) []PropertyName {
changedTags = []PropertyName{}
}
- case AnimationTag:
- if val := view.getRaw(AnimationTag); val != nil {
- if animations, ok := val.([]Animation); ok {
+ case Animation:
+ if val := view.getRaw(Animation); val != nil {
+ if animations, ok := val.([]AnimationProperty); ok {
for _, animation := range animations {
animation.unused(view.session)
}
}
- view.setRaw(AnimationTag, nil)
- changedTags = []PropertyName{AnimationTag}
+ view.setRaw(Animation, nil)
+ changedTags = []PropertyName{Animation}
}
default:
@@ -326,10 +326,10 @@ func (view *viewData) setFunc(tag PropertyName, value any) []PropertyName {
notCompatibleType(ID, value)
return nil
- case AnimationTag:
- oldAnimations := []Animation{}
- if val := view.getRaw(AnimationTag); val != nil {
- if animation, ok := val.([]Animation); ok {
+ case Animation:
+ oldAnimations := []AnimationProperty{}
+ if val := view.getRaw(Animation); val != nil {
+ if animation, ok := val.([]AnimationProperty); ok {
oldAnimations = animation
}
}
@@ -341,7 +341,7 @@ func (view *viewData) setFunc(tag PropertyName, value any) []PropertyName {
for _, animation := range oldAnimations {
animation.unused(view.session)
}
- return []PropertyName{AnimationTag}
+ return []PropertyName{Animation}
case TabIndex, "tab-index":
return setIntProperty(view, TabIndex, value)
@@ -635,7 +635,7 @@ func (view *viewData) propertyChanged(tag PropertyName) {
case Transition:
session.updateCSSProperty(htmlID, "transition", transitionCSS(view, session))
- case AnimationTag:
+ case Animation:
session.updateCSSProperty(htmlID, "animation", animationCSS(view, session))
case AnimationPaused:
diff --git a/viewStyle.go b/viewStyle.go
index d172038..40f1931 100644
--- a/viewStyle.go
+++ b/viewStyle.go
@@ -12,15 +12,15 @@ type ViewStyle interface {
Properties
// Transition returns the transition animation of the property. Returns nil is there is no transition animation.
- Transition(tag PropertyName) Animation
+ Transition(tag PropertyName) AnimationProperty
// Transitions returns the map of transition animations. The result is always non-nil.
- Transitions() map[PropertyName]Animation
+ Transitions() map[PropertyName]AnimationProperty
// SetTransition sets the transition animation for the property if "animation" argument is not nil, and
// removes the transition animation of the property if "animation" argument is nil.
// The "tag" argument is the property name.
- SetTransition(tag PropertyName, animation Animation)
+ SetTransition(tag PropertyName, animation AnimationProperty)
cssViewStyle(buffer cssBuilder, session Session)
}
@@ -412,7 +412,7 @@ func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) {
}
if animation := animationCSS(style, session); animation != "" {
- builder.add(string(AnimationTag), animation)
+ builder.add(string(Animation), animation)
}
if pause, ok := boolProperty(style, AnimationPaused, session); ok {
@@ -566,7 +566,7 @@ func supportedPropertyValue(value any) bool {
case []BackgroundElement:
case []BackgroundGradientPoint:
case []BackgroundGradientAngle:
- case map[PropertyName]Animation:
+ case map[PropertyName]AnimationProperty:
default:
return false
}
@@ -775,7 +775,7 @@ func writePropertyValue(buffer *strings.Builder, tag PropertyName, value any, in
}
buffer.WriteRune('"')
- case map[PropertyName]Animation:
+ case map[PropertyName]AnimationProperty:
switch count := len(value); count {
case 0:
buffer.WriteString("[]")
diff --git a/viewStyleSet.go b/viewStyleSet.go
index 227b742..184c1e8 100644
--- a/viewStyleSet.go
+++ b/viewStyleSet.go
@@ -6,7 +6,7 @@ import (
func setTransitionProperty(properties Properties, value any) bool {
- transitions := map[PropertyName]Animation{}
+ transitions := map[PropertyName]AnimationProperty{}
setObject := func(obj DataObject) bool {
if obj != nil {
@@ -33,7 +33,7 @@ func setTransitionProperty(properties Properties, value any) bool {
}
if val != nil {
- if animation, ok := val.(Animation); ok {
+ if animation, ok := val.(AnimationProperty); ok {
transitions[PropertyName(tag)] = animation
} else {
notCompatibleType(Transition, val)
@@ -424,7 +424,7 @@ func viewStyleSet(style Properties, tag PropertyName, value any) []PropertyName
return nil
}
- case AnimationTag:
+ case Animation:
if setAnimationProperty(style, tag, value) {
return []PropertyName{tag}
} else {
From 28881bac9a61e5b2df4f085a4c84f5b1ee3976c7 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Fri, 6 Dec 2024 19:52:57 +0300
Subject: [PATCH 37/43] Added NewTransitionAnimation, NewAnimation
---
CHANGELOG.md | 3 +-
README-ru.md | 14 +++----
README.md | 14 +++----
animation.go | 97 +++++++++++++++++++++++++++++++++++++++++++++++-
popup.go | 2 +-
propertyNames.go | 4 +-
6 files changed, 114 insertions(+), 20 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c0227ba..0f5c1c6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -28,11 +28,12 @@
NewViewFilter function -> NewFilterProperty
Animation interface -> AnimationProperty
AnimationTag constant -> Animation
+ NewAnimation function -> NewAnimationProperty
* Added functions: NewBounds, NewEllipticRadius, NewRadii, NewLinearGradient, NewCircleRadialGradient,
NewEllipseRadialGradient, GetPushTransform, GetPushDuration, GetPushTiming, IsMoveToFrontAnimation,
GetBackground, GetMask, GetBackgroundClip,GetBackgroundOrigin, GetMaskClip, GetMaskOrigin, NewColumnSeparator,
-NewClipShapeProperty.
+NewClipShapeProperty, NewTransitionAnimation, NewAnimation.
* Added SetConicGradientFillStyle and SetConicGradientStrokeStyle methods to Canvas interface.
diff --git a/README-ru.md b/README-ru.md
index 2beca26..ad9b748 100644
--- a/README-ru.md
+++ b/README-ru.md
@@ -5043,7 +5043,7 @@ onNo или onCancel (если она не nil).
Для задания параметров анимации используется интерфейс AnimationProperty. Он расширяет интерфейс Properties.
Интерфейс создается с помощью функции:
- func NewAnimation(params Params) AnimationProperty
+ func NewAnimationProperty(params Params) AnimationProperty
Часть свойств интерфейса AnimationProperty используется в обоих типах анимации, остальные используются
только в сценариях анимации.
@@ -5082,13 +5082,13 @@ onNo или onCancel (если она не nil).
Например
- animation := rui.NewAnimation(rui.Params{
+ animation := rui.NewAnimationProperty(rui.Params{
rui.TimingFunction: rui.StepsTiming(10),
})
эквивалентно
- animation := rui.NewAnimation(rui.Params{
+ animation := rui.NewAnimationProperty(rui.Params{
rui.TimingFunction: "steps(10)",
})
@@ -5117,7 +5117,7 @@ x1 и x2 должны быть в диапазоне [0, 1]. Вы можете
Она присваивает свойству новое значение, при этом изменение происходит с использованием заданной анимации.
Например,
- view.SetAnimated(rui.Width, rui.Px(400), rui.NewAnimation(rui.Params{
+ view.SetAnimated(rui.Width, rui.Px(400), rui.NewAnimationProperty(rui.Params{
rui.Duration: 0.75,
rui.TimingFunction: rui.EaseOutTiming,
}))
@@ -5132,11 +5132,11 @@ x1 и x2 должны быть в диапазоне [0, 1]. Вы можете
Например,
view.Set(rui.Transition, rui.Params{
- rui.Height: rui.NewAnimation(rui.Params{
+ rui.Height: rui.NewAnimationProperty(rui.Params{
rui.Duration: 0.75,
rui.TimingFunction: rui.EaseOutTiming,
},
- rui.BackgroundColor: rui.NewAnimation(rui.Params{
+ rui.BackgroundColor: rui.NewAnimationProperty(rui.Params{
rui.Duration: 1.5,
rui.Delay: 0.5,
rui.TimingFunction: rui.Linear,
@@ -5273,7 +5273,7 @@ KeyFrames - промежуточные значения свойства (клю
90: rui.Px(220),
}
}
- animation := rui.NewAnimation(rui.Params{
+ animation := rui.NewAnimationProperty(rui.Params{
rui.PropertyTag: []rui.AnimatedProperty{prop},
rui.Duration: 2,
rui.TimingFunction: LinearTiming,
diff --git a/README.md b/README.md
index c63510c..fb4c579 100644
--- a/README.md
+++ b/README.md
@@ -5014,7 +5014,7 @@ The library supports two types of animation:
The AnimationProperty interface is used to set animation parameters. It extends the Properties interface.
The interface is created using the function:
- func NewAnimation(params Params) AnimationProperty
+ func NewAnimationProperty(params Params) AnimationProperty
Some of the properties of the AnimationProperty interface are used in both types of animation, the rest are used only
in animation scripts.
@@ -5053,13 +5053,13 @@ You can specify this function either as text or using the function:
For example
- animation := rui.NewAnimation(rui.Params{
+ animation := rui.NewAnimationProperty(rui.Params{
rui.TimingFunction: rui.StepsTiming(10),
})
equivalent to
- animation := rui.NewAnimation(rui.Params{
+ animation := rui.NewAnimationProperty(rui.Params{
rui.TimingFunction: "steps(10)",
})
@@ -5087,7 +5087,7 @@ This function has the following description:
It assigns a new value to the property, and the change occurs using the specified animation.
For example,
- view.SetAnimated(rui.Width, rui.Px(400), rui.NewAnimation(rui.Params{
+ view.SetAnimated(rui.Width, rui.Px(400), rui.NewAnimationProperty(rui.Params{
rui.Duration: 0.75,
rui.TimingFunction: rui.EaseOutTiming,
}))
@@ -5103,11 +5103,11 @@ and the value should be the AnimationProperty interface.
For example,
view.Set(rui.Transition, rui.Params{
- rui.Height: rui.NewAnimation(rui.Params{
+ rui.Height: rui.NewAnimationProperty(rui.Params{
rui.Duration: 0.75,
rui.TimingFunction: rui.EaseOutTiming,
},
- rui.BackgroundColor: rui.NewAnimation(rui.Params{
+ rui.BackgroundColor: rui.NewAnimationProperty(rui.Params{
rui.Duration: 1.5,
rui.Delay: 0.5,
rui.TimingFunction: rui.Linear,
@@ -5246,7 +5246,7 @@ Example,
90: rui.Px(220),
}
}
- animation := rui.NewAnimation(rui.Params{
+ animation := rui.NewAnimationProperty(rui.Params{
rui.PropertyTag: []rui.AnimatedProperty{prop},
rui.Duration: 2,
rui.TimingFunction: LinearTiming,
diff --git a/animation.go b/animation.go
index f2e3034..41d8423 100644
--- a/animation.go
+++ b/animation.go
@@ -256,8 +256,19 @@ func parseAnimation(obj DataObject) AnimationProperty {
return animation
}
-// NewAnimation creates a new animation object and return its interface
-func NewAnimation(params Params) AnimationProperty {
+// NewAnimationProperty creates a new animation object and return its interface
+//
+// The following properties can be used:
+// - "id" (ID) - specifies the animation identifier. Used only for animation script.
+// - "duration" (Duration) - specifies the length of time in seconds that an animation takes to complete one cycle;
+// - "delay" (Delay) - specifies the amount of time in seconds to wait from applying the animation to an element before beginning to perform
+// the animation. The animation can start later, immediately from its beginning or immediately and partway through the animation;
+// - "timing-function" (TimingFunction) - specifies how an animation progresses through the duration of each cycle;
+// - "iteration-count" (IterationCount) - specifies the number of times an animation sequence should be played before stopping. Used only for animation script;
+// - "animation-direction" (AnimationDirection) - specifies whether an animation should play forward, backward,
+// or alternate back and forth between playing the sequence forward and backward. Used only for animation script;
+// - "property" (PropertyTag) - describes a scenario for changing a View's property. Used only for animation script.
+func NewAnimationProperty(params Params) AnimationProperty {
animation := new(animationData)
animation.init()
@@ -267,6 +278,88 @@ func NewAnimation(params Params) AnimationProperty {
return animation
}
+// NewTransitionAnimation creates animation data for the transition.
+// - timingFunc - specifies how an animation progresses through the duration of each cycle. If it is "" then "easy" function is used;
+// - duration - specifies the length of time in seconds that an animation takes to complete one cycle. Must be > 0;
+// - delay - specifies the amount of time in seconds to wait from applying the animation to an element before beginning to perform
+// the animation. The animation can start later, immediately from its beginning or immediately and partway through the animation.
+func NewTransitionAnimation(timingFunc string, duration float64, delay float64) AnimationProperty {
+ animation := new(animationData)
+ animation.init()
+
+ if duration <= 0 {
+ ErrorLog("Animation duration must be greater than 0")
+ return nil
+ }
+
+ if !animation.Set(Duration, duration) {
+ return nil
+ }
+
+ if timingFunc != "" {
+ if !animation.Set(TimingFunction, timingFunc) {
+ return nil
+ }
+ }
+
+ if delay != 0 {
+ animation.Set(Delay, delay)
+ }
+
+ return animation
+}
+
+// NewTransitionAnimation creates the animation scenario.
+// - id - specifies the animation identifier.
+// - timingFunc - specifies how an animation progresses through the duration of each cycle. If it is "" then "easy" function is used;
+// - duration - specifies the length of time in seconds that an animation takes to complete one cycle. Must be > 0;
+// - delay - specifies the amount of time in seconds to wait from applying the animation to an element before beginning to perform
+// the animation. The animation can start later, immediately from its beginning or immediately and partway through the animation.
+// - direction - specifies whether an animation should play forward, backward,
+// or alternate back and forth between playing the sequence forward and backward. Only the following values can be used:
+// 0 (NormalAnimation), 1 (ReverseAnimation), 2 (AlternateAnimation), and 3 (AlternateReverseAnimation);
+// - iterationCount - specifies the number of times an animation sequence should be played before stopping;
+// - property - describes a scenario for changing a View's property.
+func NewAnimation(id string, timingFunc string, duration float64, delay float64, direction int, iterationCount int, property ...AnimatedProperty) AnimationProperty {
+ animation := new(animationData)
+ animation.init()
+
+ if duration <= 0 {
+ ErrorLog("Animation duration must be greater than 0")
+ return nil
+ }
+
+ if !animation.Set(Duration, duration) {
+ return nil
+ }
+
+ if id != "" {
+ animation.Set(ID, id)
+ }
+
+ if timingFunc != "" {
+ animation.Set(TimingFunction, timingFunc)
+ }
+
+ if delay != 0 {
+ animation.Set(Delay, delay)
+ }
+
+ if direction > 0 {
+ animation.Set(AnimationDirection, direction)
+ }
+
+ if iterationCount > 0 {
+ animation.Set(IterationCount, iterationCount)
+ }
+
+ if len(property) > 0 {
+ animation.Set(PropertyTag, property)
+ }
+
+ return animation
+}
+
func (animation *animationData) init() {
animation.dataProperty.init()
animation.normalize = normalizeAnimation
diff --git a/popup.go b/popup.go
index a008305..00c0230 100644
--- a/popup.go
+++ b/popup.go
@@ -797,7 +797,7 @@ func (popup *popupData) init(view View, popupParams Params) {
popup.layerView = NewGridLayout(session, layerParams)
if popup.showOpacity != 1 || popup.showTransform != nil {
- animation := NewAnimation(Params{
+ animation := NewAnimationProperty(Params{
Duration: popup.showDuration,
TimingFunction: popup.showTiming,
})
diff --git a/propertyNames.go b/propertyNames.go
index 3fd422c..b2259d9 100644
--- a/propertyNames.go
+++ b/propertyNames.go
@@ -6,14 +6,14 @@ type PropertyName string
const (
// ID is the constant for "id" property tag.
//
- // # Used by View, Animation.
+ // # Used by View, AnimationProperty.
//
// Usage in View:
// Optional textual identifier for the view. Used to reference view from source code if needed.
//
// Supported types: string.
//
- // # Usage in Animation:
+ // # Usage in AnimationProperty:
//
// Specifies the animation identifier. Used only for animation script.
//
From 5971cd9105f4944606e4676da61e6aea9bf606dd Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Fri, 6 Dec 2024 19:56:51 +0300
Subject: [PATCH 38/43] Update animation.go
---
animation.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/animation.go b/animation.go
index 41d8423..1bab006 100644
--- a/animation.go
+++ b/animation.go
@@ -318,7 +318,7 @@ func NewTransitionAnimation(timingFunc string, duration float64, delay float64)
// - direction - specifies whether an animation should play forward, backward,
// or alternate back and forth between playing the sequence forward and backward. Only the following values can be used:
// 0 (NormalAnimation), 1 (ReverseAnimation), 2 (AlternateAnimation), and 3 (AlternateReverseAnimation);
-// - iterationCount - specifies the number of times an animation sequence should be played before stopping;
+// - iterationCount - specifies the number of times an animation sequence should be played before stopping. A negative value specifies infinite repetition;
// - property - describes a scenario for changing a View's property.
func NewAnimation(id string, timingFunc string, duration float64, delay float64, direction int, iterationCount int, property ...AnimatedProperty) AnimationProperty {
animation := new(animationData)
@@ -349,7 +349,7 @@ func NewAnimation(id string, timingFunc string, duration float64, delay float64,
animation.Set(AnimationDirection, direction)
}
- if iterationCount > 0 {
+ if iterationCount != 0 {
animation.Set(IterationCount, iterationCount)
}
From 0bdfe48f09b873e8dfd36d4bb27f43bad16f7ce3 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Fri, 6 Dec 2024 20:00:53 +0300
Subject: [PATCH 39/43] Update animation.go
---
animation.go | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/animation.go b/animation.go
index 1bab006..b170980 100644
--- a/animation.go
+++ b/animation.go
@@ -319,8 +319,8 @@ func NewTransitionAnimation(timingFunc string, duration float64, delay float64)
// or alternate back and forth between playing the sequence forward and backward. Only the following values can be used:
// 0 (NormalAnimation), 1 (ReverseAnimation), 2 (AlternateAnimation), and 3 (AlternateReverseAnimation);
// - iterationCount - specifies the number of times an animation sequence should be played before stopping. A negative value specifies infinite repetition;
-// - property - describes a scenario for changing a View's property.
-func NewAnimation(id string, timingFunc string, duration float64, delay float64, direction int, iterationCount int, property ...AnimatedProperty) AnimationProperty {
+// - property, properties - describes a scenario for changing a View's property.
+func NewAnimation(id string, timingFunc string, duration float64, delay float64, direction int, iterationCount int, property AnimatedProperty, properties ...AnimatedProperty) AnimationProperty {
animation := new(animationData)
animation.init()
@@ -353,7 +353,9 @@ func NewAnimation(id string, timingFunc string, duration float64, delay float64,
animation.Set(IterationCount, iterationCount)
}
- if len(property) > 0 {
+ if len(properties) > 0 {
+ animation.Set(PropertyTag, append([]AnimatedProperty{property}, properties...))
+ } else {
animation.Set(PropertyTag, property)
}
From 848606a3be98bb239a5f463fd50c360ea00700e4 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Sat, 7 Dec 2024 19:24:54 +0300
Subject: [PATCH 40/43] Added "hide-summary-marker" DetailsView property
---
CHANGELOG.md | 4 +++-
README-ru.md | 9 +++++----
README.md | 9 +++++----
app_styles.css | 8 ++++++++
detailsView.go | 46 +++++++++++++++++++++++++++++++++++++++++++---
propertySet.go | 1 +
6 files changed, 65 insertions(+), 12 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0f5c1c6..f4c2a5a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -33,7 +33,7 @@
* Added functions: NewBounds, NewEllipticRadius, NewRadii, NewLinearGradient, NewCircleRadialGradient,
NewEllipseRadialGradient, GetPushTransform, GetPushDuration, GetPushTiming, IsMoveToFrontAnimation,
GetBackground, GetMask, GetBackgroundClip,GetBackgroundOrigin, GetMaskClip, GetMaskOrigin, NewColumnSeparator,
-NewClipShapeProperty, NewTransitionAnimation, NewAnimation.
+NewClipShapeProperty, NewTransitionAnimation, NewAnimation, IsSummaryMarkerHidden.
* Added SetConicGradientFillStyle and SetConicGradientStrokeStyle methods to Canvas interface.
@@ -49,6 +49,8 @@ NewClipShapeProperty, NewTransitionAnimation, NewAnimation.
* Added "mask", "mask-clip", "mask-origin", and "background-origin" properties.
+* Added "hide-summary-marker" DetailsView property.
+
* Added LineJoin type. Type of constants MiterJoin, RoundJoin, and BevelJoin changed to LineJoin. Type of Canvas.SetLineJoin function argument changed to LineJoin.
* Added LineCap type. Type of constants ButtCap, RoundCap, and SquareCap changed to LineCap. Type of Canvas.SetLineCap function argument changed to LineCap.
diff --git a/README-ru.md b/README-ru.md
index ad9b748..973dd32 100644
--- a/README-ru.md
+++ b/README-ru.md
@@ -2980,13 +2980,14 @@ DetailsView переключается между состояниями по к
"expanded" (константа Expanded). Соответственно значение "true" показывает дочерние
View, "false" - скрывает.
-Получить значение свойства "expanded" можно с помощью функции
+По умолчанию в начале элемента "summary" отображается маркер ▶︎/▼. Его можно спрятать.
+Для этого используется свойство "hide-summary-marker" (константа DetailsView) типа bool.
- func IsDetailsExpanded(view View, subviewID ...string) bool
-
-а значение свойства "summary" можно получить с помощью функции
+Получить значение свойств "summary", "expanded" и "hide-summary-marker" можно с помощью функций
func GetDetailsSummary(view View, subviewID ...string) View
+ func IsDetailsExpanded(view View, subviewID ...string) bool
+ func IsSummaryMarkerHidden(view View, subviewID ...string) bool
## Resizable
diff --git a/README.md b/README.md
index fb4c579..908d7f8 100644
--- a/README.md
+++ b/README.md
@@ -2963,13 +2963,14 @@ DetailsView switches between states by clicking on "summary" view.
For forced switching of the DetailsView states, the bool property "expanded" (Expanded constant) is used.
Accordingly, the value "true" shows child Views, "false" - hides.
-You can get the value of the "expanded" property using the function
+By default, a ▶︎/▼ marker is displayed at the beginning of the "summary" element. It can be hidden.
+For this, the "hide-summary-marker" bool property (DetailsView constant) is used.
- func IsDetailsExpanded(view View, subviewID ...string) bool
-
-and the value of the "summary" property can be obtained using the function
+The value of the "summary", "expanded" and "hide-summary-marker" properties can be obtained using the functions
func GetDetailsSummary(view View, subviewID ...string) View
+ func IsDetailsExpanded(view View, subviewID ...string) bool
+ func IsSummaryMarkerHidden(view View, subviewID ...string) bool
## Resizable
diff --git a/app_styles.css b/app_styles.css
index ba496a7..30fd215 100644
--- a/app_styles.css
+++ b/app_styles.css
@@ -181,6 +181,14 @@ ul:focus {
overflow: auto;
}
+.hiddenMarker {
+ list-style: none;
+}
+
+.hiddenMarker::-webkit-details-marker {
+ display: none;
+}
+
/*
@media (prefers-color-scheme: light) {
body {
diff --git a/detailsView.go b/detailsView.go
index 90c4ecc..c4b9401 100644
--- a/detailsView.go
+++ b/detailsView.go
@@ -25,6 +25,18 @@ const (
// - true, 1, "true", "yes", "on", or "1" - Content is visible.
// - false, 0, "false", "no", "off", or "0" - Content is collapsed (hidden).
Expanded PropertyName = "expanded"
+
+ // HideSummaryMarker is the constant for "hide-summary-marker" property tag.
+ //
+ // Used by DetailsView.
+ // Allows you to hide the summary marker (▶︎). Default value is false.
+ //
+ // Supported types: bool, int, string.
+ //
+ // Values:
+ // - true, 1, "true", "yes", "on", or "1" - The summary marker is hidden.
+ // - false, 0, "false", "no", "off", or "0" - The summary marker is displayed (default value).
+ HideSummaryMarker PropertyName = "hide-summary-marker"
)
// DetailsView represent a DetailsView view, which is a collapsible container of views
@@ -99,7 +111,7 @@ func (detailsView *detailsViewData) setFunc(tag PropertyName, value any) []Prope
func (detailsView *detailsViewData) propertyChanged(tag PropertyName) {
switch tag {
- case Summary:
+ case Summary, HideSummaryMarker:
updateInnerHTML(detailsView.htmlID(), detailsView.Session())
case Expanded:
@@ -130,24 +142,46 @@ func (detailsView *detailsViewData) htmlProperties(self View, buffer *strings.Bu
}
func (detailsView *detailsViewData) htmlSubviews(self View, buffer *strings.Builder) {
+ summary := false
+ hidden := IsSummaryMarkerHidden(detailsView)
+
if value, ok := detailsView.properties[Summary]; ok {
+
switch value := value.(type) {
case string:
if !GetNotTranslate(detailsView) {
value, _ = detailsView.session.GetString(value)
}
- buffer.WriteString("")
+ if hidden {
+ buffer.WriteString(``)
+ } else {
+ buffer.WriteString("")
+ }
buffer.WriteString(value)
buffer.WriteString("")
+ summary = true
case View:
- if value.htmlTag() == "div" {
+ if hidden {
+ buffer.WriteString(``)
+ viewHTML(value, buffer, "")
+ buffer.WriteString("")
+ } else if value.htmlTag() == "div" {
viewHTML(value, buffer, "summary")
} else {
buffer.WriteString(`
")
}
+ summary = true
+ }
+ }
+
+ if !summary {
+ if hidden {
+ buffer.WriteString(``)
+ } else {
+ buffer.WriteString("")
}
}
@@ -189,3 +223,9 @@ func GetDetailsSummary(view View, subviewID ...string) View {
func IsDetailsExpanded(view View, subviewID ...string) bool {
return boolStyledProperty(view, subviewID, Expanded, false)
}
+
+// IsDetailsExpanded returns a value of the HideSummaryMarker property of DetailsView.
+// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
+func IsSummaryMarkerHidden(view View, subviewID ...string) bool {
+ return boolStyledProperty(view, subviewID, HideSummaryMarker, false)
+}
diff --git a/propertySet.go b/propertySet.go
index 41d43b3..6cac614 100644
--- a/propertySet.go
+++ b/propertySet.go
@@ -63,6 +63,7 @@ var boolProperties = []PropertyName{
UserSelect,
ColumnSpanAll,
MoveToFrontAnimation,
+ HideSummaryMarker,
}
var intProperties = []PropertyName{
From 86e58ef33a61440ac69e72edb4b8ab204bfb3392 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Sun, 8 Dec 2024 20:47:43 +0300
Subject: [PATCH 41/43] Bug fixing
---
timePicker.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/timePicker.go b/timePicker.go
index 7db5be1..a85ad18 100644
--- a/timePicker.go
+++ b/timePicker.go
@@ -316,7 +316,7 @@ func (picker *timePickerData) handleCommand(self View, command PropertyName, dat
switch command {
case "textChanged":
if text, ok := data.PropertyValue("text"); ok {
- if value, err := time.Parse(timeFormat, text); err == nil {
+ if value, ok := stringToTime(text); ok {
oldValue := GetTimePickerValue(picker)
picker.properties[TimePickerValue] = value
if value != oldValue {
From 0e0b73fdb93da2c6f68a89d066a7471be41f18d6 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Sun, 8 Dec 2024 21:11:46 +0300
Subject: [PATCH 42/43] Bug fixing
---
app_scripts.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app_scripts.js b/app_scripts.js
index e187c4a..df8abb9 100644
--- a/app_scripts.js
+++ b/app_scripts.js
@@ -633,6 +633,7 @@ function listItemClickEvent(element, event) {
const list = element.parentNode.parentNode
if (list) {
const number = getListItemNumber(element.id)
+ selectListItem(list, element)
sendMessage("itemClick{session=" + sessionID + ",id=" + list.id + ",number=" + number + "}");
}
}
@@ -692,7 +693,6 @@ function selectListItem(element, item) {
if (number != undefined) {
message = "itemSelected{session=" + sessionID + ",id=" + element.id + ",number=" + number + "}";
}
-
if (item.scrollIntoViewIfNeeded) {
item.scrollIntoViewIfNeeded()
From fa984dcf78afb24dbc80c335e2d7f60ec3af6770 Mon Sep 17 00:00:00 2001
From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com>
Date: Tue, 10 Dec 2024 18:23:04 +0300
Subject: [PATCH 43/43] Changed ViewByID functions
---
CHANGELOG.md | 2 +
canvasView.go | 11 +-
view.go | 13 +-
viewByID.go | 375 +++++++++++++++++++++++++++++++++-----------------
webBridge.go | 4 +-
5 files changed, 266 insertions(+), 139 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f4c2a5a..987bbc9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -35,6 +35,8 @@ NewEllipseRadialGradient, GetPushTransform, GetPushDuration, GetPushTiming, IsMo
GetBackground, GetMask, GetBackgroundClip,GetBackgroundOrigin, GetMaskClip, GetMaskOrigin, NewColumnSeparator,
NewClipShapeProperty, NewTransitionAnimation, NewAnimation, IsSummaryMarkerHidden.
+* Changed ViewByID functions
+
* Added SetConicGradientFillStyle and SetConicGradientStrokeStyle methods to Canvas interface.
* Changed Push, Pop, MoveToFront, and MoveToFrontByID methods of StackLayout interface.
diff --git a/canvasView.go b/canvasView.go
index daa2f5d..1c6ea10 100644
--- a/canvasView.go
+++ b/canvasView.go
@@ -39,7 +39,7 @@ func (canvasView *canvasViewData) init(session Session) {
canvasView.normalize = normalizeCanvasViewTag
canvasView.set = canvasView.setFunc
canvasView.remove = canvasView.removeFunc
-
+ canvasView.changed = canvasView.propertyChanged
}
func normalizeCanvasViewTag(tag PropertyName) PropertyName {
@@ -72,13 +72,20 @@ func (canvasView *canvasViewData) setFunc(tag PropertyName, value any) []Propert
notCompatibleType(tag, value)
return nil
}
- canvasView.Redraw()
return []PropertyName{DrawFunction}
}
return canvasView.viewData.setFunc(tag, value)
}
+func (canvasView *canvasViewData) propertyChanged(tag PropertyName) {
+ if tag == DrawFunction {
+ canvasView.Redraw()
+ } else {
+ canvasView.viewData.propertyChanged(tag)
+ }
+}
+
func (canvasView *canvasViewData) htmlTag() string {
return "canvas"
}
diff --git a/view.go b/view.go
index d6ee7f8..621296e 100644
--- a/view.go
+++ b/view.go
@@ -731,6 +731,13 @@ func (view *viewData) propertyChanged(tag PropertyName) {
case DataList:
updateInnerHTML(view.htmlID(), view.Session())
+ case Opacity:
+ if f, ok := floatTextProperty(view, Opacity, session, 0); ok {
+ session.updateCSSProperty(htmlID, string(Opacity), f)
+ } else {
+ session.updateCSSProperty(htmlID, string(Opacity), "")
+ }
+
default:
if cssTag, ok := sizeProperties[tag]; ok {
if size, ok := sizeProperty(view, tag, session); ok {
@@ -765,12 +772,6 @@ func (view *viewData) propertyChanged(tag PropertyName) {
}
return
}
-
- if f, ok := floatTextProperty(view, Opacity, session, 0); ok {
- session.updateCSSProperty(htmlID, string(Opacity), f)
- } else {
- session.updateCSSProperty(htmlID, string(Opacity), "")
- }
}
}
diff --git a/viewByID.go b/viewByID.go
index 45e67e3..eb7ff11 100644
--- a/viewByID.go
+++ b/viewByID.go
@@ -2,34 +2,45 @@ package rui
import "strings"
-// ViewByID return a View with id equal to the argument of the function or nil if there is no such View
-func ViewByID(rootView View, id string) View {
+// ViewByID returns the child View path to which is specified using the arguments id, ids. Example
+//
+// view := ViewByID(rootView, "id1", "id2", "id3")
+// view := ViewByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found, the function will return nil
+func ViewByID(rootView View, id string, ids ...string) View {
if rootView == nil {
ErrorLog(`ViewByID(nil, "` + id + `"): rootView is nil`)
return nil
}
- if rootView.ID() == id {
- return rootView
+
+ path := []string{id}
+ if len(ids) > 0 {
+ path = append(path, ids...)
}
- if container, ok := rootView.(ParentView); ok {
- if view := viewByID(container, id); view != nil {
- return view
- }
- }
-
- if index := strings.IndexRune(id, '/'); index > 0 {
- if view2 := ViewByID(rootView, id[:index]); view2 != nil {
- if view := ViewByID(view2, id[index+1:]); view != nil {
- return view
+ result := rootView
+ for _, id := range path {
+ if result.ID() != id {
+ if container, ok := result.(ParentView); ok {
+ if view := viewByID(container, id); view != nil {
+ result = view
+ } else if index := strings.IndexRune(id, '/'); index > 0 {
+ if view := ViewByID(result, id[:index], id[index+1:]); view != nil {
+ result = view
+ } else {
+ ErrorLog(`ViewByID(_, "` + id + `"): View not found`)
+ return nil
+ }
+ } else {
+ ErrorLog(`ViewByID(_, "` + id + `"): View not found`)
+ return nil
+ }
}
- return nil
}
- return nil
}
-
- ErrorLog(`ViewByID(_, "` + id + `"): View not found`)
- return nil
+ return result
}
func viewByID(rootView ParentView, id string) View {
@@ -49,10 +60,15 @@ func viewByID(rootView ParentView, id string) View {
return nil
}
-// ViewsContainerByID return a ViewsContainer with id equal to the argument of the function or
-// nil if there is no such View or View is not ViewsContainer
-func ViewsContainerByID(rootView View, id string) ViewsContainer {
- if view := ViewByID(rootView, id); view != nil {
+// ViewsContainerByID return the ViewsContainer path to which is specified using the arguments id, ids. Example
+//
+// view := ViewsContainerByID(rootView, "id1", "id2", "id3")
+// view := ViewsContainerByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not ViewsContainer, the function will return nil
+func ViewsContainerByID(rootView View, id string, ids ...string) ViewsContainer {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if list, ok := view.(ViewsContainer); ok {
return list
}
@@ -61,10 +77,15 @@ func ViewsContainerByID(rootView View, id string) ViewsContainer {
return nil
}
-// ListLayoutByID return a ListLayout with id equal to the argument of the function or
-// nil if there is no such View or View is not ListLayout
-func ListLayoutByID(rootView View, id string) ListLayout {
- if view := ViewByID(rootView, id); view != nil {
+// ListLayoutByID return the ListLayout path to which is specified using the arguments id, ids. Example
+//
+// view := ListLayoutByID(rootView, "id1", "id2", "id3")
+// view := ListLayoutByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not ListLayout, the function will return nil
+func ListLayoutByID(rootView View, id string, ids ...string) ListLayout {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if list, ok := view.(ListLayout); ok {
return list
}
@@ -73,10 +94,15 @@ func ListLayoutByID(rootView View, id string) ListLayout {
return nil
}
-// StackLayoutByID return a StackLayout with id equal to the argument of the function or
-// nil if there is no such View or View is not StackLayout
-func StackLayoutByID(rootView View, id string) StackLayout {
- if view := ViewByID(rootView, id); view != nil {
+// StackLayoutByID return the StackLayout path to which is specified using the arguments id, ids. Example
+//
+// view := StackLayoutByID(rootView, "id1", "id2", "id3")
+// view := StackLayoutByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not StackLayout, the function will return nil
+func StackLayoutByID(rootView View, id string, ids ...string) StackLayout {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if list, ok := view.(StackLayout); ok {
return list
}
@@ -85,10 +111,15 @@ func StackLayoutByID(rootView View, id string) StackLayout {
return nil
}
-// GridLayoutByID return a GridLayout with id equal to the argument of the function or
-// nil if there is no such View or View is not GridLayout
-func GridLayoutByID(rootView View, id string) GridLayout {
- if view := ViewByID(rootView, id); view != nil {
+// GridLayoutByID return the GridLayout path to which is specified using the arguments id, ids. Example
+//
+// view := GridLayoutByID(rootView, "id1", "id2", "id3")
+// view := GridLayoutByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not GridLayout, the function will return nil
+func GridLayoutByID(rootView View, id string, ids ...string) GridLayout {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if list, ok := view.(GridLayout); ok {
return list
}
@@ -97,10 +128,15 @@ func GridLayoutByID(rootView View, id string) GridLayout {
return nil
}
-// ColumnLayoutByID return a ColumnLayout with id equal to the argument of the function or
-// nil if there is no such View or View is not ColumnLayout
-func ColumnLayoutByID(rootView View, id string) ColumnLayout {
- if view := ViewByID(rootView, id); view != nil {
+// ColumnLayoutByID return the ColumnLayout path to which is specified using the arguments id, ids. Example
+//
+// view := ColumnLayoutByID(rootView, "id1", "id2", "id3")
+// view := ColumnLayoutByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not ColumnLayout, the function will return nil
+func ColumnLayoutByID(rootView View, id string, ids ...string) ColumnLayout {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if list, ok := view.(ColumnLayout); ok {
return list
}
@@ -109,10 +145,15 @@ func ColumnLayoutByID(rootView View, id string) ColumnLayout {
return nil
}
-// DetailsViewByID return a ColumnLayout with id equal to the argument of the function or
-// nil if there is no such View or View is not DetailsView
-func DetailsViewByID(rootView View, id string) DetailsView {
- if view := ViewByID(rootView, id); view != nil {
+// DetailsViewByID return the ColumnLayout path to which is specified using the arguments id, ids. Example
+//
+// view := DetailsViewByID(rootView, "id1", "id2", "id3")
+// view := DetailsViewByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not DetailsView, the function will return nil
+func DetailsViewByID(rootView View, id string, ids ...string) DetailsView {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if details, ok := view.(DetailsView); ok {
return details
}
@@ -121,10 +162,15 @@ func DetailsViewByID(rootView View, id string) DetailsView {
return nil
}
-// DropDownListByID return a DropDownListView with id equal to the argument of the function or
-// nil if there is no such View or View is not DropDownListView
-func DropDownListByID(rootView View, id string) DropDownList {
- if view := ViewByID(rootView, id); view != nil {
+// DropDownListByID return the DropDownListView path to which is specified using the arguments id, ids. Example
+//
+// view := DropDownListByID(rootView, "id1", "id2", "id3")
+// view := DropDownListByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not DropDownList, the function will return nil
+func DropDownListByID(rootView View, id string, ids ...string) DropDownList {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if list, ok := view.(DropDownList); ok {
return list
}
@@ -133,10 +179,15 @@ func DropDownListByID(rootView View, id string) DropDownList {
return nil
}
-// TabsLayoutByID return a TabsLayout with id equal to the argument of the function or
-// nil if there is no such View or View is not TabsLayout
-func TabsLayoutByID(rootView View, id string) TabsLayout {
- if view := ViewByID(rootView, id); view != nil {
+// TabsLayoutByID return the TabsLayout path to which is specified using the arguments id, ids. Example
+//
+// view := TabsLayoutByID(rootView, "id1", "id2", "id3")
+// view := TabsLayoutByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not TabsLayout, the function will return nil
+func TabsLayoutByID(rootView View, id string, ids ...string) TabsLayout {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if list, ok := view.(TabsLayout); ok {
return list
}
@@ -145,10 +196,15 @@ func TabsLayoutByID(rootView View, id string) TabsLayout {
return nil
}
-// ListViewByID return a ListView with id equal to the argument of the function or
-// nil if there is no such View or View is not ListView
-func ListViewByID(rootView View, id string) ListView {
- if view := ViewByID(rootView, id); view != nil {
+// ListViewByID return the ListView path to which is specified using the arguments id, ids. Example
+//
+// view := ListViewByID(rootView, "id1", "id2", "id3")
+// view := ListViewByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not ListView, the function will return nil
+func ListViewByID(rootView View, id string, ids ...string) ListView {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if list, ok := view.(ListView); ok {
return list
}
@@ -157,10 +213,15 @@ func ListViewByID(rootView View, id string) ListView {
return nil
}
-// TextViewByID return a TextView with id equal to the argument of the function or
-// nil if there is no such View or View is not TextView
-func TextViewByID(rootView View, id string) TextView {
- if view := ViewByID(rootView, id); view != nil {
+// TextViewByID return the TextView path to which is specified using the arguments id, ids. Example
+//
+// view := TextViewByID(rootView, "id1", "id2", "id3")
+// view := TextViewByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not TextView, the function will return nil
+func TextViewByID(rootView View, id string, ids ...string) TextView {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if text, ok := view.(TextView); ok {
return text
}
@@ -169,10 +230,15 @@ func TextViewByID(rootView View, id string) TextView {
return nil
}
-// ButtonByID return a Button with id equal to the argument of the function or
-// nil if there is no such View or View is not Button
-func ButtonByID(rootView View, id string) Button {
- if view := ViewByID(rootView, id); view != nil {
+// ButtonByID return the Button path to which is specified using the arguments id, ids. Example
+//
+// view := ButtonByID(rootView, "id1", "id2", "id3")
+// view := ButtonByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not Button, the function will return nil
+func ButtonByID(rootView View, id string, ids ...string) Button {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if button, ok := view.(Button); ok {
return button
}
@@ -181,10 +247,15 @@ func ButtonByID(rootView View, id string) Button {
return nil
}
-// CheckboxByID return a Checkbox with id equal to the argument of the function or
-// nil if there is no such View or View is not Checkbox
-func CheckboxByID(rootView View, id string) Checkbox {
- if view := ViewByID(rootView, id); view != nil {
+// CheckboxByID return the Checkbox path to which is specified using the arguments id, ids. Example
+//
+// view := CheckboxByID(rootView, "id1", "id2", "id3")
+// view := CheckboxByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not Checkbox, the function will return nil
+func CheckboxByID(rootView View, id string, ids ...string) Checkbox {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if checkbox, ok := view.(Checkbox); ok {
return checkbox
}
@@ -193,10 +264,15 @@ func CheckboxByID(rootView View, id string) Checkbox {
return nil
}
-// EditViewByID return a EditView with id equal to the argument of the function or
-// nil if there is no such View or View is not EditView
-func EditViewByID(rootView View, id string) EditView {
- if view := ViewByID(rootView, id); view != nil {
+// EditViewByID return the EditView path to which is specified using the arguments id, ids. Example
+//
+// view := EditViewByID(rootView, "id1", "id2", "id3")
+// view := EditViewByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not EditView, the function will return nil
+func EditViewByID(rootView View, id string, ids ...string) EditView {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if buttons, ok := view.(EditView); ok {
return buttons
}
@@ -205,10 +281,15 @@ func EditViewByID(rootView View, id string) EditView {
return nil
}
-// ProgressBarByID return a ProgressBar with id equal to the argument of the function or
-// nil if there is no such View or View is not ProgressBar
-func ProgressBarByID(rootView View, id string) ProgressBar {
- if view := ViewByID(rootView, id); view != nil {
+// ProgressBarByID return the ProgressBar path to which is specified using the arguments id, ids. Example
+//
+// view := ProgressBarByID(rootView, "id1", "id2", "id3")
+// view := ProgressBarByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not ProgressBar, the function will return nil
+func ProgressBarByID(rootView View, id string, ids ...string) ProgressBar {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if buttons, ok := view.(ProgressBar); ok {
return buttons
}
@@ -217,10 +298,15 @@ func ProgressBarByID(rootView View, id string) ProgressBar {
return nil
}
-// ColorPickerByID return a ColorPicker with id equal to the argument of the function or
-// nil if there is no such View or View is not ColorPicker
-func ColorPickerByID(rootView View, id string) ColorPicker {
- if view := ViewByID(rootView, id); view != nil {
+// ColorPickerByID return the ColorPicker path to which is specified using the arguments id, ids. Example
+//
+// view := ColorPickerByID(rootView, "id1", "id2", "id3")
+// view := ColorPickerByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not ColorPicker, the function will return nil
+func ColorPickerByID(rootView View, id string, ids ...string) ColorPicker {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if input, ok := view.(ColorPicker); ok {
return input
}
@@ -229,10 +315,15 @@ func ColorPickerByID(rootView View, id string) ColorPicker {
return nil
}
-// NumberPickerByID return a NumberPicker with id equal to the argument of the function or
-// nil if there is no such View or View is not NumberPicker
-func NumberPickerByID(rootView View, id string) NumberPicker {
- if view := ViewByID(rootView, id); view != nil {
+// NumberPickerByID return the NumberPicker path to which is specified using the arguments id, ids. Example
+//
+// view := NumberPickerByID(rootView, "id1", "id2", "id3")
+// view := NumberPickerByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not NumberPicker, the function will return nil
+func NumberPickerByID(rootView View, id string, ids ...string) NumberPicker {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if input, ok := view.(NumberPicker); ok {
return input
}
@@ -241,10 +332,15 @@ func NumberPickerByID(rootView View, id string) NumberPicker {
return nil
}
-// TimePickerByID return a TimePicker with id equal to the argument of the function or
-// nil if there is no such View or View is not TimePicker
-func TimePickerByID(rootView View, id string) TimePicker {
- if view := ViewByID(rootView, id); view != nil {
+// TimePickerByID return the TimePicker path to which is specified using the arguments id, ids. Example
+//
+// view := TimePickerByID(rootView, "id1", "id2", "id3")
+// view := TimePickerByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not TimePicker, the function will return nil
+func TimePickerByID(rootView View, id string, ids ...string) TimePicker {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if input, ok := view.(TimePicker); ok {
return input
}
@@ -253,10 +349,15 @@ func TimePickerByID(rootView View, id string) TimePicker {
return nil
}
-// DatePickerByID return a DatePicker with id equal to the argument of the function or
-// nil if there is no such View or View is not DatePicker
-func DatePickerByID(rootView View, id string) DatePicker {
- if view := ViewByID(rootView, id); view != nil {
+// DatePickerByID return the DatePicker path to which is specified using the arguments id, ids. Example
+//
+// view := DatePickerByID(rootView, "id1", "id2", "id3")
+// view := DatePickerByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not DatePicker, the function will return nil
+func DatePickerByID(rootView View, id string, ids ...string) DatePicker {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if input, ok := view.(DatePicker); ok {
return input
}
@@ -265,10 +366,15 @@ func DatePickerByID(rootView View, id string) DatePicker {
return nil
}
-// FilePickerByID return a FilePicker with id equal to the argument of the function or
-// nil if there is no such View or View is not FilePicker
-func FilePickerByID(rootView View, id string) FilePicker {
- if view := ViewByID(rootView, id); view != nil {
+// FilePickerByID return the FilePicker path to which is specified using the arguments id, ids. Example
+//
+// view := FilePickerByID(rootView, "id1", "id2", "id3")
+// view := FilePickerByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not FilePicker, the function will return nil
+func FilePickerByID(rootView View, id string, ids ...string) FilePicker {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if input, ok := view.(FilePicker); ok {
return input
}
@@ -277,10 +383,15 @@ func FilePickerByID(rootView View, id string) FilePicker {
return nil
}
-// CanvasViewByID return a CanvasView with id equal to the argument of the function or
-// nil if there is no such View or View is not CanvasView
-func CanvasViewByID(rootView View, id string) CanvasView {
- if view := ViewByID(rootView, id); view != nil {
+// CanvasViewByID return the CanvasView path to which is specified using the arguments id, ids. Example
+//
+// view := CanvasViewByID(rootView, "id1", "id2", "id3")
+// view := CanvasViewByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not CanvasView, the function will return nil
+func CanvasViewByID(rootView View, id string, ids ...string) CanvasView {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if canvas, ok := view.(CanvasView); ok {
return canvas
}
@@ -289,24 +400,15 @@ func CanvasViewByID(rootView View, id string) CanvasView {
return nil
}
-/*
-// TableViewByID return a TableView with id equal to the argument of the function or
-// nil if there is no such View or View is not TableView
-func TableViewByID(rootView View, id string) TableView {
- if view := ViewByID(rootView, id); view != nil {
- if canvas, ok := view.(TableView); ok {
- return canvas
- }
- ErrorLog(`TableViewByID(_, "` + id + `"): The found View is not TableView`)
- }
- return nil
-}
-*/
-
-// AudioPlayerByID return a AudioPlayer with id equal to the argument of the function or
-// nil if there is no such View or View is not AudioPlayer
-func AudioPlayerByID(rootView View, id string) AudioPlayer {
- if view := ViewByID(rootView, id); view != nil {
+// AudioPlayerByID return the AudioPlayer path to which is specified using the arguments id, ids. Example
+//
+// view := AudioPlayerByID(rootView, "id1", "id2", "id3")
+// view := AudioPlayerByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not AudioPlayer, the function will return nil
+func AudioPlayerByID(rootView View, id string, ids ...string) AudioPlayer {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if canvas, ok := view.(AudioPlayer); ok {
return canvas
}
@@ -315,10 +417,15 @@ func AudioPlayerByID(rootView View, id string) AudioPlayer {
return nil
}
-// VideoPlayerByID return a VideoPlayer with id equal to the argument of the function or
-// nil if there is no such View or View is not VideoPlayer
-func VideoPlayerByID(rootView View, id string) VideoPlayer {
- if view := ViewByID(rootView, id); view != nil {
+// VideoPlayerByID return the VideoPlayer path to which is specified using the arguments id, ids. Example
+//
+// view := VideoPlayerByID(rootView, "id1", "id2", "id3")
+// view := VideoPlayerByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not VideoPlayer, the function will return nil
+func VideoPlayerByID(rootView View, id string, ids ...string) VideoPlayer {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if canvas, ok := view.(VideoPlayer); ok {
return canvas
}
@@ -327,10 +434,15 @@ func VideoPlayerByID(rootView View, id string) VideoPlayer {
return nil
}
-// ImageViewByID return a ImageView with id equal to the argument of the function or
-// nil if there is no such View or View is not ImageView
-func ImageViewByID(rootView View, id string) ImageView {
- if view := ViewByID(rootView, id); view != nil {
+// ImageViewByID return the ImageView path to which is specified using the arguments id, ids. Example
+//
+// view := ImageViewByID(rootView, "id1", "id2", "id3")
+// view := ImageViewByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not ImageView, the function will return nil
+func ImageViewByID(rootView View, id string, ids ...string) ImageView {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if canvas, ok := view.(ImageView); ok {
return canvas
}
@@ -339,10 +451,15 @@ func ImageViewByID(rootView View, id string) ImageView {
return nil
}
-// TableViewByID return a TableView with id equal to the argument of the function or
-// nil if there is no such View or View is not TableView
-func TableViewByID(rootView View, id string) TableView {
- if view := ViewByID(rootView, id); view != nil {
+// TableViewByID return the TableView path to which is specified using the arguments id, ids. Example
+//
+// view := TableViewByID(rootView, "id1", "id2", "id3")
+// view := TableViewByID(rootView, "id1/id2/id3")
+//
+// These two function calls are equivalent.
+// If a View with this path is not found or View is not TableView, the function will return nil
+func TableViewByID(rootView View, id string, ids ...string) TableView {
+ if view := ViewByID(rootView, id, ids...); view != nil {
if canvas, ok := view.(TableView); ok {
return canvas
}
diff --git a/webBridge.go b/webBridge.go
index 5901585..9c94a70 100644
--- a/webBridge.go
+++ b/webBridge.go
@@ -421,8 +421,8 @@ func (bridge *webBridge) remoteValue(funcName string, args ...any) (DataObject,
funcArgs := append([]any{answerID}, args...)
var result DataObject = nil
- ok := bridge.callFuncImmediately(funcName, funcArgs...)
- if ok {
+
+ if bridge.callFuncImmediately(funcName, funcArgs...) {
result = <-answer
}