diff --git a/absoluteLayout.go b/absoluteLayout.go index d55cdac..f1b886d 100644 --- a/absoluteLayout.go +++ b/absoluteLayout.go @@ -2,7 +2,7 @@ package rui import "strings" -// AbsoluteLayout - list-container of View +// AbsoluteLayout represent an AbsoluteLayout view where child views can be arbitrary positioned type AbsoluteLayout interface { ViewsContainer } diff --git a/angleUnit.go b/angleUnit.go index 7be546c..4f35342 100644 --- a/angleUnit.go +++ b/angleUnit.go @@ -11,6 +11,7 @@ import ( // Can take the following values: Radian, Degree, Gradian, and Turn type AngleUnitType uint8 +// Constants which represent values or the [AngleUnitType] const ( // Radian - angle in radians Radian AngleUnitType = 0 @@ -24,9 +25,12 @@ const ( Turn AngleUnitType = 4 ) -// AngleUnit describe a size (Value field) and size unit (Type field). +// AngleUnit used to represent an angular values type AngleUnit struct { - Type AngleUnitType + // Type of the angle value + Type AngleUnitType + + // Value of the angle in Type units Value float64 } diff --git a/animation.go b/animation.go index 2c7c9f8..49ee7cf 100644 --- a/animation.go +++ b/animation.go @@ -7,6 +7,7 @@ import ( "strings" ) +// Constants which related to view's animation const ( // AnimationTag is the constant for the "animation" property tag. // The "animation" property sets and starts animations. @@ -168,6 +169,7 @@ func parseAnimation(obj DataObject) Animation { return animation } +// NewAnimation creates a new animation object and return its interface func NewAnimation(params Params) Animation { animation := new(animationData) animation.init() diff --git a/animationEvents.go b/animationEvents.go index fb1d998..02ab84e 100644 --- a/animationEvents.go +++ b/animationEvents.go @@ -2,6 +2,7 @@ package rui import "strings" +// Constants which describe values for view's animation events properties const ( // TransitionRunEvent is the constant for "transition-run-event" property tag. // The "transition-run-event" is fired when a transition is first created, diff --git a/appServer.go b/appServer.go index f3863f7..8a2db52 100644 --- a/appServer.go +++ b/appServer.go @@ -415,6 +415,7 @@ func StartApp(addr string, createContentFunc func(Session) SessionContent, param } } +// FinishApp finishes application func FinishApp() { for _, app := range apps { app.Finish() @@ -422,6 +423,8 @@ func FinishApp() { apps = []*application{} } +// OpenBrowser open browser with specific URL locally. Useful for applications which run on local machine +// or for debug purposes. func OpenBrowser(url string) bool { var err error diff --git a/application.go b/application.go index 7f3e2e1..511270e 100644 --- a/application.go +++ b/application.go @@ -14,10 +14,14 @@ var appStyles string //go:embed defaultTheme.rui var defaultThemeText string -// Application - app interface +// Application represent generic application interface, see also [Session] type Application interface { + // Finish finishes the application Finish() + + // Params returns application parameters set by StartApp function Params() AppParams + removeSession(id int) } diff --git a/audioPlayer.go b/audioPlayer.go index 035c501..e9da3e9 100644 --- a/audioPlayer.go +++ b/audioPlayer.go @@ -1,5 +1,6 @@ package rui +// AudioPlayer is a type of a [View] which can play audio files type AudioPlayer interface { MediaPlayer } diff --git a/background.go b/background.go index ec83df6..fe889da 100644 --- a/background.go +++ b/background.go @@ -5,6 +5,7 @@ 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 @@ -61,13 +62,18 @@ const ( ContentBoxClip = 2 ) -// BackgroundElement describes the background element. +// BackgroundElement describes the background element type BackgroundElement interface { Properties fmt.Stringer stringWriter cssStyle(session Session) string + + // Tag returns type of the background element. + // Possible values are: "image", "conic-gradient", "linear-gradient" and "radial-gradient" Tag() string + + // Clone creates a new copy of BackgroundElement Clone() BackgroundElement } diff --git a/backgroundConicGradient.go b/backgroundConicGradient.go index 385e97f..b5d2b4e 100644 --- a/backgroundConicGradient.go +++ b/backgroundConicGradient.go @@ -28,6 +28,7 @@ func NewBackgroundConicGradient(params Params) BackgroundElement { return result } +// String convert internal representation of [BackgroundGradientAngle] into a string. func (point *BackgroundGradientAngle) String() string { result := "black" if point.Color != nil { diff --git a/backgroundGradient.go b/backgroundGradient.go index 12595d1..2f4de13 100644 --- a/backgroundGradient.go +++ b/backgroundGradient.go @@ -2,6 +2,7 @@ package rui 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 @@ -224,6 +225,7 @@ func (point *BackgroundGradientPoint) color(session Session) (Color, bool) { return 0, false } +// String convert internal representation of [BackgroundGradientPoint] into a string. func (point *BackgroundGradientPoint) String() string { result := "black" if point.Color != nil { diff --git a/border.go b/border.go index 209ec9e..ad8a114 100644 --- a/border.go +++ b/border.go @@ -5,6 +5,7 @@ import ( "strings" ) +// Constants related to view's border description const ( // NoneLine constant specifies that there is no border NoneLine = 0 @@ -50,7 +51,10 @@ type BorderProperty interface { Properties fmt.Stringer stringWriter + + // ViewBorders returns top, right, bottom and left borders information all together ViewBorders(session Session) ViewBorders + delete(tag string) cssStyle(builder cssBuilder, session Session) cssWidth(builder cssBuilder, session Session) @@ -703,8 +707,13 @@ func (border *borderProperty) cssColorValue(session Session) string { // ViewBorder describes parameters of a view border type ViewBorder struct { + // Style of the border line Style int + + // Color of the border line Color Color + + // Width of the border line Width SizeUnit } diff --git a/bounds.go b/bounds.go index 5de35bb..fc1ae79 100644 --- a/bounds.go +++ b/bounds.go @@ -5,11 +5,13 @@ import ( "strings" ) -// BorderProperty is the interface of a bounds property data +// BorderProperty is an interface of a bounds property data type BoundsProperty interface { Properties fmt.Stringer stringWriter + + // Bounds returns top, right, bottom and left size of the bounds Bounds(session Session) Bounds } diff --git a/button.go b/button.go index 94c6fd1..feef490 100644 --- a/button.go +++ b/button.go @@ -1,6 +1,6 @@ package rui -// Button - button view +// Button represent a Button view type Button interface { CustomView } diff --git a/canvas.go b/canvas.go index 76a92bc..e097fb5 100644 --- a/canvas.go +++ b/canvas.go @@ -6,6 +6,7 @@ import ( "strings" ) +// Constants related to canvas view operations const ( // MiterJoin - Connected segments are joined by extending their outside edges // to connect at a single point, with the effect of filling an additional @@ -91,7 +92,7 @@ type TextMetrics struct { Right float64 } -// Canvas is a drawing interface +// Canvas is a drawing interface used by the [CanvasView] type Canvas interface { // View return the view for the drawing View() CanvasView diff --git a/canvasView.go b/canvasView.go index 473bda4..08e98a0 100644 --- a/canvasView.go +++ b/canvasView.go @@ -10,6 +10,8 @@ const DrawFunction = "draw-function" // CanvasView interface of a custom draw view type CanvasView interface { View + + // Redraw forces CanvasView to redraw its content Redraw() } diff --git a/checkbox.go b/checkbox.go index 5f07f83..655a684 100644 --- a/checkbox.go +++ b/checkbox.go @@ -9,7 +9,7 @@ import ( // The main listener format: func(Checkbox, bool), where the second argument is the checkbox state. const CheckboxChangedEvent = "checkbox-event" -// Checkbox - checkbox view +// Checkbox represent a Checkbox view type Checkbox interface { ViewsContainer } diff --git a/colorConstants.go b/colorConstants.go index e59a709..3cc86fa 100644 --- a/colorConstants.go +++ b/colorConstants.go @@ -2,6 +2,7 @@ package rui import "sort" +// A set of predefined colors used in the library const ( // Black color constant Black Color = 0xff000000 @@ -449,8 +450,12 @@ var colorConstants = map[string]Color{ "yellowgreen": 0xff9acd32, } +// NamedColor make a relation between color and its name type NamedColor struct { - Name string + // Name of a color + Name string + + // Color value Color Color } diff --git a/colorPicker.go b/colorPicker.go index 3831983..760f7b3 100644 --- a/colorPicker.go +++ b/colorPicker.go @@ -4,12 +4,19 @@ import ( "strings" ) +// Constants for [ColorPicker] specific properties and events. const ( + // ColorChangedEvent is the constant for "color-changed" property tag. + // The "color-changed" event occurs when [ColorPicker] value has been changed. + // The main listener format: func(picker ColorPicker, newColor, oldColor Color). ColorChangedEvent = "color-changed" - ColorPickerValue = "color-picker-value" + + // ColorPickerValue is the constant for "color-picker-value" property tag. + // The "color-picker-value" define current color picker value. + ColorPickerValue = "color-picker-value" ) -// ColorPicker - ColorPicker view +// ColorPicker represent a ColorPicker view type ColorPicker interface { View } diff --git a/columnLayout.go b/columnLayout.go index b0d468c..015e9b3 100644 --- a/columnLayout.go +++ b/columnLayout.go @@ -5,6 +5,7 @@ import ( "strings" ) +// Constants for [ColumnLayout] specific properties and events const ( // ColumnCount is the constant for the "column-count" property tag. // The "column-count" int property specifies number of columns into which the content is break @@ -52,7 +53,7 @@ const ( ColumnSpanAll = "column-span-all" ) -// ColumnLayout - grid-container of View +// ColumnLayout represent a ColumnLayout view type ColumnLayout interface { ViewsContainer } diff --git a/columnSeparator.go b/columnSeparator.go index 8e3a1d4..c5ca505 100644 --- a/columnSeparator.go +++ b/columnSeparator.go @@ -10,7 +10,10 @@ type ColumnSeparatorProperty interface { Properties fmt.Stringer stringWriter + + // ViewBorder returns column separator description in a form of ViewBorder ViewBorder(session Session) ViewBorder + cssValue(session Session) string } diff --git a/customView.go b/customView.go index d74e9ed..1c00e24 100644 --- a/customView.go +++ b/customView.go @@ -5,8 +5,13 @@ import "strings" // CustomView defines a custom view interface type CustomView interface { ViewsContainer + + // CreateSuperView must be implemented to create a base view from which custom control has been built CreateSuperView(session Session) View + + // SuperView must be implemented to return a base view from which custom control has been built SuperView() View + setSuperView(view View) setTag(tag string) } @@ -71,10 +76,14 @@ func (customView *CustomViewData) Set(tag string, value any) bool { return customView.superView.Set(tag, value) } +// 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 string, value any, animation Animation) bool { return customView.superView.SetAnimated(tag, value, animation) } +// SetChangeListener set the function to track the change of the View property func (customView *CustomViewData) SetChangeListener(tag string, listener func(View, string)) { customView.superView.SetChangeListener(tag, listener) } @@ -151,10 +160,12 @@ func (customView *CustomViewData) Frame() Frame { return customView.superView.Frame() } +// Scroll returns a location and size of a scrollable view in pixels func (customView *CustomViewData) Scroll() Frame { return customView.superView.Scroll() } +// HasFocus returns "true" if the view has focus func (customView *CustomViewData) HasFocus() bool { return customView.superView.HasFocus() } @@ -272,6 +283,7 @@ func (customView *CustomViewData) exscludeTags() []string { return nil } +// String convert internal representation of a [CustomViewData] into a string. func (customView *CustomViewData) String() string { if customView.superView != nil { return getViewString(customView, customView.exscludeTags()) @@ -285,6 +297,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 string) Animation { if customView.superView != nil { return customView.superView.Transition(tag) @@ -292,6 +305,7 @@ func (customView *CustomViewData) Transition(tag string) Animation { return nil } +// Transitions returns a map of transition animations. The result is always non-nil. func (customView *CustomViewData) Transitions() map[string]Animation { if customView.superView != nil { return customView.superView.Transitions() @@ -299,6 +313,9 @@ func (customView *CustomViewData) Transitions() map[string]Animation { return map[string]Animation{} } +// 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 string, animation Animation) { if customView.superView != nil { customView.superView.SetTransition(tag, animation) diff --git a/data.go b/data.go index 038b3b3..992827a 100644 --- a/data.go +++ b/data.go @@ -7,25 +7,49 @@ import ( // DataValue interface of a data node value type DataValue interface { + // IsObject returns "true" if data value is an object IsObject() bool + + // Object returns data value as a data object Object() DataObject + + // Value returns value as a string Value() string } // DataObject interface of a data object type DataObject interface { DataValue + + // Tag returns data object tag Tag() string + + // PropertyCount returns properties count PropertyCount() int + + // Property returns a data node corresponding to a property with specific index Property(index int) DataNode + + // PropertyByTag returns a data node corresponding to a property tag PropertyByTag(tag string) DataNode + + // PropertyValue returns a string value of a property with a specific tag PropertyValue(tag string) (string, bool) + + // PropertyObject returns an object value of a property with a specific tag PropertyObject(tag string) DataObject + + // SetPropertyValue sets a string value of a property with a specific tag SetPropertyValue(tag, value string) + + // SetPropertyObject sets an object value of a property with a specific tag SetPropertyObject(tag string, object DataObject) + + // ToParams create a params(map) representation of a data object ToParams() Params } +// Constants which are used to describe a node type, see [DataNode] const ( // TextNode - node is the pair "tag - text value". Syntax: = TextNode = 0 @@ -37,13 +61,28 @@ const ( // DataNode interface of a data node type DataNode interface { + // Tag returns a tag name Tag() string + + // Type returns a node type. Possible values are TextNode, ObjectNode and ArrayNode Type() int + + // Text returns node text Text() string + + // Object returns node as object if that node type is an object Object() DataObject + + // ArraySize returns array size if that node type is an array ArraySize() int + + // ArrayElement returns a value of an array if that node type is an array ArrayElement(index int) DataValue + + // ArrayElements returns an array of objects if that node is an array ArrayElements() []DataValue + + // ArrayAsParams returns an array of a params(map) if that node is an array ArrayAsParams() []Params } diff --git a/datePicker.go b/datePicker.go index 9b05edf..7ff4f26 100644 --- a/datePicker.go +++ b/datePicker.go @@ -6,16 +6,33 @@ import ( "time" ) +// Constants for [DatePicker] specific properties and events. const ( + // DateChangedEvent is the constant for "date-changed" property tag. + // The "date-changed" event occur when [DatePicker] value has been changed. + // The main listener format: func(picker DatePicker, newDate, oldDate time.Time). DateChangedEvent = "date-changed" - DatePickerMin = "date-picker-min" - DatePickerMax = "date-picker-max" - DatePickerStep = "date-picker-step" - DatePickerValue = "date-picker-value" - dateFormat = "2006-01-02" + + // DatePickerMin is the constant for "date-picker-min" property tag. + // The "date-picker-min" define minimum date value. + DatePickerMin = "date-picker-min" + + // DatePickerMax is the constant for "date-picker-max" property tag. + // The "date-picker-max" define maximum date value. + DatePickerMax = "date-picker-max" + + // DatePickerStep is the constant for "date-picker-step" property tag. + // The "date-picker-step" define date step value in days. + DatePickerStep = "date-picker-step" + + // DatePickerValue is the constant for "date-picker-value" property tag. + // The "date-picker-value" define current date value. + DatePickerValue = "date-picker-value" + + dateFormat = "2006-01-02" ) -// DatePicker - DatePicker view +// DatePicker represent a DatePicker view type DatePicker interface { View } diff --git a/detailsView.go b/detailsView.go index af83dfd..7da6075 100644 --- a/detailsView.go +++ b/detailsView.go @@ -2,6 +2,7 @@ package rui import "strings" +// Constants for [DetailsView] specific properties and events const ( // Summary is the constant for the "summary" property tag. // The contents of the "summary" property are used as the label for the disclosure widget. @@ -12,7 +13,7 @@ const ( Expanded = "expanded" ) -// DetailsView - collapsible container of View +// DetailsView represent a DetailsView view, which is a collapsible container of views type DetailsView interface { ViewsContainer } diff --git a/dropDownList.go b/dropDownList.go index f345098..f39a0d7 100644 --- a/dropDownList.go +++ b/dropDownList.go @@ -11,7 +11,7 @@ import ( // The main listener format: func(DropDownList, int), where the second argument is the item index. const DropDownEvent = "drop-down-event" -// DropDownList - the interface of a drop-down list view +// DropDownList represent a DropDownList view type DropDownList interface { View getItems() []string diff --git a/editView.go b/editView.go index 31f1b6d..a025a6f 100644 --- a/editView.go +++ b/editView.go @@ -5,6 +5,7 @@ import ( "strings" ) +// Constants for [EditView] specific properties and events const ( // EditTextChangedEvent is the constant for the "edit-text-changed" property tag. EditTextChangedEvent = "edit-text-changed" @@ -19,6 +20,7 @@ const ( Spellcheck = "spellcheck" ) +// Constants for the values of an [EditView] "edit-view-type" property const ( // SingleLineText - single-line text type of EditView SingleLineText = 0 @@ -36,9 +38,11 @@ const ( MultiLineText = 6 ) -// EditView - grid-container of View +// EditView represent an EditView view type EditView interface { View + + // AppendText appends text to the current text of an EditView view AppendText(text string) } diff --git a/filePicker.go b/filePicker.go index b3e759d..2f743b9 100644 --- a/filePicker.go +++ b/filePicker.go @@ -7,6 +7,7 @@ import ( "time" ) +// Constants for [FilePicker] specific properties and events const ( // FileSelectedEvent is the constant for "file-selected-event" property tag. // The "file-selected-event" is fired when user selects file(s) in the FilePicker. @@ -31,7 +32,7 @@ type FileInfo struct { MimeType string } -// FilePicker - the control view for the files selecting +// FilePicker represents the FilePicker view type FilePicker interface { View // Files returns the list of selected files. diff --git a/focusEvents.go b/focusEvents.go index 6065b1b..271bb06 100644 --- a/focusEvents.go +++ b/focusEvents.go @@ -2,6 +2,7 @@ package rui import "strings" +// Constants which represent [View] specific focus events properties const ( // FocusEvent is the constant for "focus-event" property tag. // The "focus-event" event occurs when the View takes input focus. diff --git a/gridLayout.go b/gridLayout.go index ae22893..d8eee39 100644 --- a/gridLayout.go +++ b/gridLayout.go @@ -5,6 +5,7 @@ import ( "strings" ) +// Constants related to [GridLayout] specific properties and events const ( // CellVerticalAlign is the constant for the "cell-vertical-align" property tag. // The "cell-vertical-align" int property sets the default vertical alignment @@ -43,6 +44,8 @@ const ( CellHorizontalSelfAlign = "cell-horizontal-self-align" ) +// GridAdapter is an interface to define [GridLayout] content. [GridLayout] will query interface functions to populate +// its content type GridAdapter interface { // GridColumnCount returns the number of columns in the grid GridColumnCount() int @@ -54,21 +57,21 @@ type GridAdapter interface { GridCellContent(row, column int, session Session) View } -// GridCellColumnSpanAdapter implements the optional method of GridAdapter interface +// GridCellColumnSpanAdapter implements the optional method of the [GridAdapter] interface type GridCellColumnSpanAdapter interface { // GridCellColumnSpan returns the number of columns that a cell spans. // Values ​​less than 1 are ignored. GridCellColumnSpan(row, column int) int } -// GridCellColumnSpanAdapter implements the optional method of GridAdapter interface +// GridCellColumnSpanAdapter implements the optional method of the [GridAdapter] interface type GridCellRowSpanAdapter interface { // GridCellRowSpan returns the number of rows that a cell spans // Values ​​less than 1 are ignored. GridCellRowSpan(row, column int) int } -// GridLayout - grid-container of View +// GridLayout represents a GridLayout view type GridLayout interface { ViewsContainer diff --git a/httpHandler.go b/httpHandler.go index b0757fd..e7d5d79 100644 --- a/httpHandler.go +++ b/httpHandler.go @@ -22,26 +22,24 @@ func (h *httpHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { } } -/* -NewHandler is used to embed the rui application in third-party web frameworks (net/http, gin, echo...). -Example for echo: - - e := echo.New() - e.Any(`/ui/*`, func()echo.HandlerFunc{ - rui.AddEmbedResources(&resources) - - h := rui.NewHandler("/ui", CreateSessionContent, rui.AppParams{ - Title: `Awesome app`, - Icon: `favicon.png`, - }) - - return func(c echo.Context) error { - h.ServeHTTP(c.Response(), c.Request()) - return nil - } - }) -*/ - +// NewHandler is used to embed the rui application in third-party web frameworks (net/http, gin, echo...). +// +// Example for echo: +// +// e := echo.New() +// e.Any(`/ui/*`, func()echo.HandlerFunc{ +// rui.AddEmbedResources(&resources) +// +// h := rui.NewHandler("/ui", CreateSessionContent, rui.AppParams{ +// Title: `Awesome app`, +// Icon: `favicon.png`, +// }) +// +// return func(c echo.Context) error { +// h.ServeHTTP(c.Response(), c.Request()) +// return nil +// } +// }) func NewHandler(urlPrefix string, createContentFunc func(Session) SessionContent, params AppParams) *httpHandler { app := new(application) app.params = params diff --git a/image.go b/image.go index 3a740a4..0091f0a 100644 --- a/image.go +++ b/image.go @@ -4,6 +4,7 @@ import ( "strconv" ) +// Constants which represent return values of the LoadingStatus function of an [Image] view const ( // ImageLoading is the image loading status: in the process of loading ImageLoading = 0 diff --git a/imageView.go b/imageView.go index d87f3e9..e622791 100644 --- a/imageView.go +++ b/imageView.go @@ -5,6 +5,7 @@ import ( "strings" ) +// Constants which represent [ImageView] specific properties and events const ( // LoadedEvent is the constant for the "loaded-event" property tag. // The "loaded-event" event occurs event occurs when the image has been loaded. @@ -33,7 +34,7 @@ const ( ScaleDownFit = 4 ) -// ImageView - image View +// ImageView represents an ImageView view type ImageView interface { View // NaturalSize returns the intrinsic, density-corrected size (width, height) of the image in pixels. diff --git a/keyEvents.go b/keyEvents.go index b7ec325..c7d6b4f 100644 --- a/keyEvents.go +++ b/keyEvents.go @@ -2,6 +2,7 @@ package rui import "strings" +// Constants which represent [View] specific keyboard events properties const ( // KeyDown is the constant for "key-down-event" property tag. // The "key-down-event" event is fired when a key is pressed. @@ -20,9 +21,15 @@ const ( KeyUpEvent = "key-up-event" ) +// ControlKeyMask represent ORed state of keyboard's control keys like [AltKey], [CtrlKey], [ShiftKey] and [MetaKey] type ControlKeyMask int + +// KeyCode is a string representation the a physical key being pressed. +// The value is not affected by the current keyboard layout or modifier state, +// so a particular key will always have the same value. type KeyCode string +// Constants for specific keyboard keys. const ( // AltKey is the mask of the "alt" key AltKey ControlKeyMask = 1 @@ -33,114 +40,326 @@ const ( // MetaKey is the mask of the "meta" key MetaKey ControlKeyMask = 8 - KeyA KeyCode = "KeyA" - KeyB KeyCode = "KeyB" - KeyC KeyCode = "KeyC" - KeyD KeyCode = "KeyD" - KeyE KeyCode = "KeyE" - KeyF KeyCode = "KeyF" - KeyG KeyCode = "KeyG" - KeyH KeyCode = "KeyH" - KeyI KeyCode = "KeyI" - KeyJ KeyCode = "KeyJ" - KeyK KeyCode = "KeyK" - KeyL KeyCode = "KeyL" - KeyM KeyCode = "KeyM" - KeyN KeyCode = "KeyN" - KeyO KeyCode = "KeyO" - KeyP KeyCode = "KeyP" - KeyQ KeyCode = "KeyQ" - KeyR KeyCode = "KeyR" - KeyS KeyCode = "KeyS" - KeyT KeyCode = "KeyT" - KeyU KeyCode = "KeyU" - KeyV KeyCode = "KeyV" - KeyW KeyCode = "KeyW" - KeyX KeyCode = "KeyX" - KeyY KeyCode = "KeyY" - KeyZ KeyCode = "KeyZ" - Digit0Key KeyCode = "Digit0" - Digit1Key KeyCode = "Digit1" - Digit2Key KeyCode = "Digit2" - Digit3Key KeyCode = "Digit3" - Digit4Key KeyCode = "Digit4" - Digit5Key KeyCode = "Digit5" - Digit6Key KeyCode = "Digit6" - Digit7Key KeyCode = "Digit7" - Digit8Key KeyCode = "Digit8" - Digit9Key KeyCode = "Digit9" - SpaceKey KeyCode = "Space" - MinusKey KeyCode = "Minus" - EqualKey KeyCode = "Equal" - IntlBackslashKey KeyCode = "IntlBackslash" - BracketLeftKey KeyCode = "BracketLeft" - BracketRightKey KeyCode = "BracketRight" - SemicolonKey KeyCode = "Semicolon" - CommaKey KeyCode = "Comma" - PeriodKey KeyCode = "Period" - QuoteKey KeyCode = "Quote" - BackquoteKey KeyCode = "Backquote" - SlashKey KeyCode = "Slash" - EscapeKey KeyCode = "Escape" - EnterKey KeyCode = "Enter" - TabKey KeyCode = "Tab" - CapsLockKey KeyCode = "CapsLock" - DeleteKey KeyCode = "Delete" - InsertKey KeyCode = "Insert" - HelpKey KeyCode = "Help" - BackspaceKey KeyCode = "Backspace" - PrintScreenKey KeyCode = "PrintScreen" - ScrollLockKey KeyCode = "ScrollLock" - PauseKey KeyCode = "Pause" - ContextMenuKey KeyCode = "ContextMenu" - ArrowLeftKey KeyCode = "ArrowLeft" - ArrowRightKey KeyCode = "ArrowRight" - ArrowUpKey KeyCode = "ArrowUp" - ArrowDownKey KeyCode = "ArrowDown" - HomeKey KeyCode = "Home" - EndKey KeyCode = "End" - PageUpKey KeyCode = "PageUp" - PageDownKey KeyCode = "PageDown" - F1Key KeyCode = "F1" - F2Key KeyCode = "F2" - F3Key KeyCode = "F3" - F4Key KeyCode = "F4" - F5Key KeyCode = "F5" - F6Key KeyCode = "F6" - F7Key KeyCode = "F7" - F8Key KeyCode = "F8" - F9Key KeyCode = "F9" - F10Key KeyCode = "F10" - F11Key KeyCode = "F11" - F12Key KeyCode = "F12" - F13Key KeyCode = "F13" - NumLockKey KeyCode = "NumLock" - NumpadKey0 KeyCode = "Numpad0" - NumpadKey1 KeyCode = "Numpad1" - NumpadKey2 KeyCode = "Numpad2" - NumpadKey3 KeyCode = "Numpad3" - NumpadKey4 KeyCode = "Numpad4" - NumpadKey5 KeyCode = "Numpad5" - NumpadKey6 KeyCode = "Numpad6" - NumpadKey7 KeyCode = "Numpad7" - NumpadKey8 KeyCode = "Numpad8" - NumpadKey9 KeyCode = "Numpad9" - NumpadDecimalKey KeyCode = "NumpadDecimal" - NumpadEnterKey KeyCode = "NumpadEnter" - NumpadAddKey KeyCode = "NumpadAdd" + // KeyA reresent "A" key on the keyboard + KeyA KeyCode = "KeyA" + + // KeyB reresent "B" key on the keyboard + KeyB KeyCode = "KeyB" + + // KeyC reresent "C" key on the keyboard + KeyC KeyCode = "KeyC" + + // KeyD reresent "D" key on the keyboard + KeyD KeyCode = "KeyD" + + // KeyE reresent "E" key on the keyboard + KeyE KeyCode = "KeyE" + + // KeyF reresent "F" key on the keyboard + KeyF KeyCode = "KeyF" + + // KeyG reresent "G" key on the keyboard + KeyG KeyCode = "KeyG" + + // KeyH reresent "H" key on the keyboard + KeyH KeyCode = "KeyH" + + // KeyI reresent "I" key on the keyboard + KeyI KeyCode = "KeyI" + + // KeyJ reresent "J" key on the keyboard + KeyJ KeyCode = "KeyJ" + + // KeyK reresent "K" key on the keyboard + KeyK KeyCode = "KeyK" + + // KeyL reresent "L" key on the keyboard + KeyL KeyCode = "KeyL" + + // KeyM reresent "M" key on the keyboard + KeyM KeyCode = "KeyM" + + // KeyN reresent "N" key on the keyboard + KeyN KeyCode = "KeyN" + + // KeyO reresent "O" key on the keyboard + KeyO KeyCode = "KeyO" + + // KeyP reresent "P" key on the keyboard + KeyP KeyCode = "KeyP" + + // KeyQ reresent "Q" key on the keyboard + KeyQ KeyCode = "KeyQ" + + // KeyR reresent "R" key on the keyboard + KeyR KeyCode = "KeyR" + + // KeyS reresent "S" key on the keyboard + KeyS KeyCode = "KeyS" + + // KeyT reresent "T" key on the keyboard + KeyT KeyCode = "KeyT" + + // KeyU reresent "U" key on the keyboard + KeyU KeyCode = "KeyU" + + // KeyV reresent "V" key on the keyboard + KeyV KeyCode = "KeyV" + + // KeyW reresent "W" key on the keyboard + KeyW KeyCode = "KeyW" + + // KeyX reresent "X" key on the keyboard + KeyX KeyCode = "KeyX" + + // KeyY reresent "Y" key on the keyboard + KeyY KeyCode = "KeyY" + + // KeyZ reresent "Z" key on the keyboard + KeyZ KeyCode = "KeyZ" + + // Digit0Key reresent "Digit0" key on the keyboard + Digit0Key KeyCode = "Digit0" + + // Digit1Key reresent "Digit1" key on the keyboard + Digit1Key KeyCode = "Digit1" + + // Digit2Key reresent "Digit2" key on the keyboard + Digit2Key KeyCode = "Digit2" + + // Digit3Key reresent "Digit3" key on the keyboard + Digit3Key KeyCode = "Digit3" + + // Digit4Key reresent "Digit4" key on the keyboard + Digit4Key KeyCode = "Digit4" + + // Digit5Key reresent "Digit5" key on the keyboard + Digit5Key KeyCode = "Digit5" + + // Digit6Key reresent "Digit6" key on the keyboard + Digit6Key KeyCode = "Digit6" + + // Digit7Key reresent "Digit7" key on the keyboard + Digit7Key KeyCode = "Digit7" + + // Digit8Key reresent "Digit8" key on the keyboard + Digit8Key KeyCode = "Digit8" + + // Digit9Key reresent "Digit9" key on the keyboard + Digit9Key KeyCode = "Digit9" + + // SpaceKey reresent "Space" key on the keyboard + SpaceKey KeyCode = "Space" + + // MinusKey reresent "Minus" key on the keyboard + MinusKey KeyCode = "Minus" + + // EqualKey reresent "Equal" key on the keyboard + EqualKey KeyCode = "Equal" + + // IntlBackslashKey reresent "IntlBackslash" key on the keyboard + IntlBackslashKey KeyCode = "IntlBackslash" + + // BracketLeftKey reresent "BracketLeft" key on the keyboard + BracketLeftKey KeyCode = "BracketLeft" + + // BracketRightKey reresent "BracketRight" key on the keyboard + BracketRightKey KeyCode = "BracketRight" + + // SemicolonKey reresent "Semicolon" key on the keyboard + SemicolonKey KeyCode = "Semicolon" + + // CommaKey reresent "Comma" key on the keyboard + CommaKey KeyCode = "Comma" + + // PeriodKey reresent "Period" key on the keyboard + PeriodKey KeyCode = "Period" + + // QuoteKey reresent "Quote" key on the keyboard + QuoteKey KeyCode = "Quote" + + // BackquoteKey reresent "Backquote" key on the keyboard + BackquoteKey KeyCode = "Backquote" + + // SlashKey reresent "Slash" key on the keyboard + SlashKey KeyCode = "Slash" + + // EscapeKey reresent "Escape" key on the keyboard + EscapeKey KeyCode = "Escape" + + // EnterKey reresent "Enter" key on the keyboard + EnterKey KeyCode = "Enter" + + // TabKey reresent "Tab" key on the keyboard + TabKey KeyCode = "Tab" + + // CapsLockKey reresent "CapsLock" key on the keyboard + CapsLockKey KeyCode = "CapsLock" + + // DeleteKey reresent "Delete" key on the keyboard + DeleteKey KeyCode = "Delete" + + // InsertKey reresent "Insert" key on the keyboard + InsertKey KeyCode = "Insert" + + // HelpKey reresent "Help" key on the keyboard + HelpKey KeyCode = "Help" + + // BackspaceKey reresent "Backspace" key on the keyboard + BackspaceKey KeyCode = "Backspace" + + // PrintScreenKey reresent "PrintScreen" key on the keyboard + PrintScreenKey KeyCode = "PrintScreen" + + // ScrollLockKey reresent "ScrollLock" key on the keyboard + ScrollLockKey KeyCode = "ScrollLock" + + // PauseKey reresent "Pause" key on the keyboard + PauseKey KeyCode = "Pause" + + // ContextMenuKey reresent "ContextMenu" key on the keyboard + ContextMenuKey KeyCode = "ContextMenu" + + // ArrowLeftKey reresent "ArrowLeft" key on the keyboard + ArrowLeftKey KeyCode = "ArrowLeft" + + // ArrowRightKey reresent "ArrowRight" key on the keyboard + ArrowRightKey KeyCode = "ArrowRight" + + // ArrowUpKey reresent "ArrowUp" key on the keyboard + ArrowUpKey KeyCode = "ArrowUp" + + // ArrowDownKey reresent "ArrowDown" key on the keyboard + ArrowDownKey KeyCode = "ArrowDown" + + // HomeKey reresent "Home" key on the keyboard + HomeKey KeyCode = "Home" + + // EndKey reresent "End" key on the keyboard + EndKey KeyCode = "End" + + // PageUpKey reresent "PageUp" key on the keyboard + PageUpKey KeyCode = "PageUp" + + // PageDownKey reresent "PageDown" key on the keyboard + PageDownKey KeyCode = "PageDown" + + // F1Key reresent "F1" key on the keyboard + F1Key KeyCode = "F1" + + // F2Key reresent "F2" key on the keyboard + F2Key KeyCode = "F2" + + // F3Key reresent "F3" key on the keyboard + F3Key KeyCode = "F3" + + // F4Key reresent "F4" key on the keyboard + F4Key KeyCode = "F4" + + // F5Key reresent "F5" key on the keyboard + F5Key KeyCode = "F5" + + // F6Key reresent "F6" key on the keyboard + F6Key KeyCode = "F6" + + // F7Key reresent "F7" key on the keyboard + F7Key KeyCode = "F7" + + // F8Key reresent "F8" key on the keyboard + F8Key KeyCode = "F8" + + // F9Key reresent "F9" key on the keyboard + F9Key KeyCode = "F9" + + // F10Key reresent "F10" key on the keyboard + F10Key KeyCode = "F10" + + // F11Key reresent "F11" key on the keyboard + F11Key KeyCode = "F11" + + // F12Key reresent "F12" key on the keyboard + F12Key KeyCode = "F12" + + // F13Key reresent "F13" key on the keyboard + F13Key KeyCode = "F13" + + // NumLockKey reresent "NumLock" key on the keyboard + NumLockKey KeyCode = "NumLock" + + // NumpadKey0 reresent "Numpad0" key on the keyboard + NumpadKey0 KeyCode = "Numpad0" + + // NumpadKey1 reresent "Numpad1" key on the keyboard + NumpadKey1 KeyCode = "Numpad1" + + // NumpadKey2 reresent "Numpad2" key on the keyboard + NumpadKey2 KeyCode = "Numpad2" + + // NumpadKey3 reresent "Numpad3" key on the keyboard + NumpadKey3 KeyCode = "Numpad3" + + // NumpadKey4 reresent "Numpad4" key on the keyboard + NumpadKey4 KeyCode = "Numpad4" + + // NumpadKey5 reresent "Numpad5" key on the keyboard + NumpadKey5 KeyCode = "Numpad5" + + // NumpadKey6 reresent "Numpad6" key on the keyboard + NumpadKey6 KeyCode = "Numpad6" + + // NumpadKey7 reresent "Numpad7" key on the keyboard + NumpadKey7 KeyCode = "Numpad7" + + // NumpadKey8 reresent "Numpad8" key on the keyboard + NumpadKey8 KeyCode = "Numpad8" + + // NumpadKey9 reresent "Numpad9" key on the keyboard + NumpadKey9 KeyCode = "Numpad9" + + // NumpadDecimalKey reresent "NumpadDecimal" key on the keyboard + NumpadDecimalKey KeyCode = "NumpadDecimal" + + // NumpadEnterKey reresent "NumpadEnter" key on the keyboard + NumpadEnterKey KeyCode = "NumpadEnter" + + // NumpadAddKey reresent "NumpadAdd" key on the keyboard + NumpadAddKey KeyCode = "NumpadAdd" + + // NumpadSubtractKey reresent "NumpadSubtract" key on the keyboard NumpadSubtractKey KeyCode = "NumpadSubtract" + + // NumpadMultiplyKey reresent "NumpadMultiply" key on the keyboard NumpadMultiplyKey KeyCode = "NumpadMultiply" - NumpadDivideKey KeyCode = "NumpadDivide" - ShiftLeftKey KeyCode = "ShiftLeft" - ShiftRightKey KeyCode = "ShiftRight" - ControlLeftKey KeyCode = "ControlLeft" - ControlRightKey KeyCode = "ControlRight" - AltLeftKey KeyCode = "AltLeft" - AltRightKey KeyCode = "AltRight" - MetaLeftKey KeyCode = "MetaLeft" - MetaRightKey KeyCode = "MetaRight" + + // NumpadDivideKey reresent "NumpadDivide" key on the keyboard + NumpadDivideKey KeyCode = "NumpadDivide" + + // ShiftLeftKey reresent "ShiftLeft" key on the keyboard + ShiftLeftKey KeyCode = "ShiftLeft" + + // ShiftRightKey reresent "ShiftRight" key on the keyboard + ShiftRightKey KeyCode = "ShiftRight" + + // ControlLeftKey reresent "ControlLeft" key on the keyboard + ControlLeftKey KeyCode = "ControlLeft" + + // ControlRightKey reresent "ControlRight" key on the keyboard + ControlRightKey KeyCode = "ControlRight" + + // AltLeftKey reresent "AltLeft" key on the keyboard + AltLeftKey KeyCode = "AltLeft" + + // AltRightKey reresent "AltRight" key on the keyboard + AltRightKey KeyCode = "AltRight" + + // MetaLeftKey reresent "MetaLeft" key on the keyboard + MetaLeftKey KeyCode = "MetaLeft" + + // MetaRightKey reresent "MetaRight" key on the keyboard + MetaRightKey KeyCode = "MetaRight" ) +// KeyEvent represent a keyboard event type KeyEvent struct { // TimeStamp is the time at which the event was created (in milliseconds). // This value is time since epoch—but in reality, browsers' definitions vary. diff --git a/listLayout.go b/listLayout.go index 21a7c3a..18d6249 100644 --- a/listLayout.go +++ b/listLayout.go @@ -4,6 +4,7 @@ import ( "strings" ) +// Constants which represent values of the "orientation" property of the [ListLayout] const ( // TopDownOrientation - subviews are arranged from top to bottom. Synonym of VerticalOrientation TopDownOrientation = 0 @@ -16,7 +17,10 @@ const ( // EndToStartOrientation - subviews are arranged from right to left EndToStartOrientation = 3 +) +// Constants which represent values of the "list-wrap" property of the [ListLayout] +const ( // ListWrapOff - subviews are scrolled and "true" if a new row/column starts ListWrapOff = 0 @@ -27,7 +31,7 @@ const ( ListWrapReverse = 2 ) -// ListLayout - list-container of View +// ListLayout represents a ListLayout view type ListLayout interface { ViewsContainer // UpdateContent updates child Views if the "content" property value is set to ListAdapter, diff --git a/listView.go b/listView.go index b055f82..5f81ab2 100644 --- a/listView.go +++ b/listView.go @@ -6,6 +6,7 @@ import ( "strings" ) +// Constants which represent [ListView] specific properties and events const ( // ListItemClickedEvent is the constant for "list-item-clicked" property tag. // The "list-item-clicked" event occurs when the user clicks on an item in the list. @@ -35,12 +36,17 @@ const ( CurrentInactiveStyle = "current-inactive-style" ) +// Constants which represent values of the "orientation" property of the [ListView]. These are aliases for values used in +// [ListLayout] "orientation" property like TopDownOrientation and StartToEndOrientation const ( // VerticalOrientation is the vertical ListView orientation VerticalOrientation = 0 // HorizontalOrientation is the horizontal ListView orientation HorizontalOrientation = 1 +) +// Constants which represent values of a "checkbox" property of [ListView] +const ( // NoneCheckbox is value of "checkbox" property: no checkbox NoneCheckbox = 0 // SingleCheckbox is value of "checkbox" property: only one item can be checked @@ -49,7 +55,7 @@ const ( MultipleCheckbox = 2 ) -// ListView - the list view interface +// ListView represents a ListView view type ListView interface { View ParentView diff --git a/mediaPlayer.go b/mediaPlayer.go index 445be0a..24c75a7 100644 --- a/mediaPlayer.go +++ b/mediaPlayer.go @@ -7,6 +7,7 @@ import ( "strings" ) +// Constants which related to media player properties and events const ( // Controls is the constant for the "autoplay" controls tag. // If the "controls" bool property is "true", the browser will offer controls to allow the user @@ -156,6 +157,7 @@ const ( PlayerErrorSourceNotSupported = 4 ) +// MediaPlayer is a common interface for media player views like [AudioPlayer] and [VideoPlayer]. type MediaPlayer interface { View @@ -200,8 +202,12 @@ type mediaPlayerData struct { viewData } +// MediaSource represent one media file source type MediaSource struct { - Url string + // Url of the source + Url string + + // MimeType of the source MimeType string } diff --git a/mouseEvents.go b/mouseEvents.go index 03dd36f..e853f1f 100644 --- a/mouseEvents.go +++ b/mouseEvents.go @@ -5,6 +5,7 @@ import ( "strings" ) +// Constants related to [View] mouse events properties const ( // ClickEvent is the constant for "click-event" property tag. // The "click-event" event occurs when the user clicks on the View. @@ -112,6 +113,7 @@ const ( MouseMask5 = 16 ) +// MouseEvent represent a mouse event type MouseEvent struct { // TimeStamp is the time at which the event was created (in milliseconds). // This value is time since epoch—but in reality, browsers' definitions vary. diff --git a/numberPicker.go b/numberPicker.go index 145f11d..0a3f59e 100644 --- a/numberPicker.go +++ b/numberPicker.go @@ -6,6 +6,7 @@ import ( "strings" ) +// Constants related to [NumberPicker] specific properties and events const ( // NumberChangedEvent is the constant for the "" property tag. // The "number-changed" property sets listener(s) that track the change in the entered value. @@ -34,6 +35,7 @@ const ( NumberPickerValue = "number-picker-value" ) +// Constants which describe values of the "number-picker-type" property of a [NumberPicker] const ( // NumberEditor - type of NumberPicker. NumberPicker is presented by editor NumberEditor = 0 @@ -42,7 +44,7 @@ const ( NumberSlider = 1 ) -// NumberPicker - NumberPicker view +// NumberPicker represents a NumberPicker view type NumberPicker interface { View } diff --git a/outline.go b/outline.go index 342fa26..d9ba065 100644 --- a/outline.go +++ b/outline.go @@ -5,10 +5,13 @@ import ( "strings" ) +// OutlineProperty defines a view's outside border type OutlineProperty interface { Properties stringWriter fmt.Stringer + + // ViewOutline returns style color and line width of an outline ViewOutline(session Session) ViewOutline } @@ -98,8 +101,13 @@ func (outline *outlinePropertyData) ViewOutline(session Session) ViewOutline { // ViewOutline describes parameters of a view border type ViewOutline struct { + // Style of the outline line Style int + + // Color of the outline line Color Color + + // Width of the outline line Width SizeUnit } diff --git a/params.go b/params.go index b52b8d9..7e4feab 100644 --- a/params.go +++ b/params.go @@ -5,6 +5,8 @@ import "sort" // Params defines a type of a parameters list type Params map[string]any +// Get returns a value of the property with name defined by the argument. The type of return value depends +// on the property. If the property is not set then nil is returned. func (params Params) Get(tag string) any { return params.getRaw(tag) } @@ -16,6 +18,8 @@ func (params Params) getRaw(tag string) any { return nil } +// Set 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" is returned and a description of an error is written to the log func (params Params) Set(tag string, value any) bool { params.setRaw(tag, value) return true @@ -29,16 +33,19 @@ func (params Params) setRaw(tag string, value any) { } } +// Remove removes the property with name defined by the argument from a map. func (params Params) Remove(tag string) { delete(params, tag) } +// Clear removes all properties from a map. func (params Params) Clear() { for tag := range params { delete(params, tag) } } +// AllTags returns a sorted slice of all properties. func (params Params) AllTags() []string { tags := make([]string, 0, len(params)) for t := range params { diff --git a/pointerEvents.go b/pointerEvents.go index f97ec0b..a2a539d 100644 --- a/pointerEvents.go +++ b/pointerEvents.go @@ -4,6 +4,7 @@ import ( "strings" ) +// Constants for [View] specific pointer events properties const ( // PointerDown is the constant for "pointer-down" property tag. // The "pointer-down" event is fired when a pointer becomes active. For mouse, it is fired when @@ -49,6 +50,7 @@ const ( PointerOver = "pointer-over" ) +// PointerEvent represent a stylus events. Also inherit [MouseEvent] attributes type PointerEvent struct { MouseEvent diff --git a/popup.go b/popup.go index 281ead0..401c6aa 100644 --- a/popup.go +++ b/popup.go @@ -4,6 +4,7 @@ import ( "strings" ) +// Constants for [Popup] specific properties and events const ( // Title is the constant for the "title" property tag. // The "title" property is defined the Popup/Tabs title @@ -78,7 +79,10 @@ const ( // LeftArrow is value of the popup "arrow" property: // Arrow on the left side of the pop-up window LeftArrow = 4 +) +// Constants which are used as a values of [PopupButtonType] variables +const ( // NormalButton is the constant of the popup button type: the normal button NormalButton PopupButtonType = 0 // DefaultButton is the constant of the popup button type: button that fires when the "Enter" key is pressed @@ -87,21 +91,35 @@ const ( CancelButton PopupButtonType = 2 ) +// PopupButtonType represent popup button type type PopupButtonType int // PopupButton describes a button that will be placed at the bottom of the window. type PopupButton struct { - Title string - Type PopupButtonType + // Title of the button + Title string + + // Type of the button + Type PopupButtonType + + // OnClick is the handler function that gets called when the button is pressed OnClick func(Popup) } -// Popup interface +// Popup represents a Popup view type Popup interface { + // View returns a content view of the popup View() View + + // Session returns current client session Session() Session + + // Show displays a popup Show() + + // Dismiss closes a popup Dismiss() + onDismiss() html(buffer *strings.Builder) viewByHTMLID(id string) View diff --git a/progressBar.go b/progressBar.go index a5dac46..4744294 100644 --- a/progressBar.go +++ b/progressBar.go @@ -5,12 +5,18 @@ import ( "strings" ) +// Constants for [ProgressBar] specific properties and events const ( - ProgressBarMax = "progress-max" + // ProgressBarMax is the constant for "progress-max" property tag. + // The "progress-max" define maximum value of the ProgressBar, default is 1. + ProgressBarMax = "progress-max" + + // ProgressBarValue is the constant for "progress-value" property tag. + // The "progress-value" define current value of the ProgressBar, default is 0. ProgressBarValue = "progress-value" ) -// ProgressBar - ProgressBar view +// ProgressBar represents a ProgressBar view type ProgressBar interface { View } diff --git a/propertyNames.go b/propertyNames.go index cbabb9c..e3d9d44 100644 --- a/propertyNames.go +++ b/propertyNames.go @@ -1,5 +1,6 @@ package rui +// Constants for various properties and events of Views'. const ( // ID is the constant for the "id" property tag. // The "id" property is an optional textual identifier for the View. @@ -717,5 +718,8 @@ const ( // * A positive value means View should be focusable in sequential keyboard navigation, with its order defined by the value of the number. TabIndex = "tabindex" + // Tooltip is the constant for "tooltip" property tag. + // The "tooltip" string property specifies the tooltip text. Tooltip pops up when hovering the mouse cursor over the view. + // HTML tags are supported when formatting tooltip text. Tooltip = "tooltip" ) diff --git a/propertyValues.go b/propertyValues.go index d1c3760..47c67c0 100644 --- a/propertyValues.go +++ b/propertyValues.go @@ -1,5 +1,6 @@ package rui +// Constants for various specific properties of a views const ( // Visible - default value of the view Visibility property: View is visible Visible = 0 diff --git a/radius.go b/radius.go index fee7f1f..6c8a8dc 100644 --- a/radius.go +++ b/radius.go @@ -5,6 +5,7 @@ import ( "strings" ) +// Constants for [RadiusProperty] specific properties const ( // Radius is the SizeUnit view property that determines the corners rounding radius // of an element's outer border edge. @@ -95,10 +96,13 @@ const ( BottomRightY = "bottom-right-y" ) +// RadiusProperty is a description of the [View] (shape) elliptical corner radius. type RadiusProperty interface { Properties stringWriter fmt.Stringer + + // BoxRadius returns x and y radius of the corners of the element BoxRadius(session Session) BoxRadius } diff --git a/resizable.go b/resizable.go index c504f26..0bece40 100644 --- a/resizable.go +++ b/resizable.go @@ -6,6 +6,7 @@ import ( "strings" ) +// Constants for [Resizable] specific properties and events const ( // Side is the constant for the "side" property tag. // The "side" int property determines which side of the container is used to resize. @@ -15,7 +16,10 @@ const ( // ResizeBorderWidth is the constant for the "resize-border-width" property tag. // The "ResizeBorderWidth" SizeUnit property determines the width of the resizing border ResizeBorderWidth = "resize-border-width" +) +// Constants for values of [Resizable] "side" property. These constants can be ORed if needed. +const ( // TopSide is value of the "side" property: the top side is used to resize TopSide = 1 @@ -32,7 +36,7 @@ const ( AllSides = TopSide | RightSide | BottomSide | LeftSide ) -// Resizable - grid-container of View +// Resizable represents a Resizable view type Resizable interface { View ParentView diff --git a/resources.go b/resources.go index a0ae401..999b85d 100644 --- a/resources.go +++ b/resources.go @@ -45,6 +45,7 @@ var resources = resourceManager{ imageSrcSets: map[string][]scaledImage{}, } +// AddEmbedResources adds embedded resources to the list of application resources func AddEmbedResources(fs *embed.FS) { resources.embedFS = append(resources.embedFS, fs) rootDirs := resources.embedRootDirs(fs) @@ -457,6 +458,7 @@ func AllImageResources() []string { return result } +// AddTheme adds theme to application func AddTheme(theme Theme) { if theme != nil { name := theme.Name() diff --git a/session.go b/session.go index 9794564..11c3ce2 100644 --- a/session.go +++ b/session.go @@ -36,6 +36,8 @@ type bridge interface { // SessionContent is the interface of a session content type SessionContent interface { + + // CreateRootView will be called by the library to create a root view of the application CreateRootView(session Session) View } diff --git a/sessionEvents.go b/sessionEvents.go index 99a4916..1041b95 100644 --- a/sessionEvents.go +++ b/sessionEvents.go @@ -4,31 +4,42 @@ import "time" // SessionStartListener is the listener interface of a session start event type SessionStartListener interface { + // OnStart is a function that is called by the library after the creation of the root view of the application OnStart(session Session) } // SessionFinishListener is the listener interface of a session start event type SessionFinishListener interface { + // OnFinish is a function that is called by the library when the user closes the application page in the browser OnFinish(session Session) } // SessionResumeListener is the listener interface of a session resume event type SessionResumeListener interface { + // OnResume is a function that is called by the library when the application page in the client's browser becomes + // active and is also called immediately after OnStart OnResume(session Session) } // SessionPauseListener is the listener interface of a session pause event type SessionPauseListener interface { + // OnPause is a function that is called by the library when the application page in the client's browser becomes + // inactive and is also called when the user switches to a different browser tab/window, minimizes the browser, + // or switches to another application OnPause(session Session) } // SessionPauseListener is the listener interface of a session disconnect event type SessionDisconnectListener interface { + // OnDisconnect is a function that is called by the library if the server loses connection with the client and + // this happens when the connection is broken OnDisconnect(session Session) } // SessionPauseListener is the listener interface of a session reconnect event type SessionReconnectListener interface { + // OnReconnect is a function that is called by the library after the server reconnects with the client + // and this happens when the connection is restored OnReconnect(session Session) } diff --git a/shadow.go b/shadow.go index 3d0541a..1cce2c1 100644 --- a/shadow.go +++ b/shadow.go @@ -5,6 +5,7 @@ import ( "strings" ) +// Constants for [ViewShadow] specific properties const ( // ColorTag is the name of the color property of the shadow. ColorTag = "color" diff --git a/sizeUnit.go b/sizeUnit.go index 3106b63..579c507 100644 --- a/sizeUnit.go +++ b/sizeUnit.go @@ -13,6 +13,7 @@ import ( // SizeInDIP, SizeInPt, SizeInInch, SizeInMM, SizeInFraction type SizeUnitType uint8 +// Constants which represent values of a [SizeUnitType] const ( // Auto is the SizeUnit type: default value. Auto SizeUnitType = 0 @@ -44,8 +45,14 @@ const ( // SizeUnit describe a size (Value field) and size unit (Type field). type SizeUnit struct { - Type SizeUnitType - Value float64 + // Type or dimension of the value + Type SizeUnitType + + // Value of the size in Type units + Value float64 + + // Function representation of a size unit. + // When setting this value type should be set to SizeFunction Function SizeFunc } diff --git a/stackLayout.go b/stackLayout.go index 960bcb9..06ef0fb 100644 --- a/stackLayout.go +++ b/stackLayout.go @@ -6,6 +6,7 @@ import ( "strings" ) +// Constants which represent [StackLayout] animation type during pushing or popping views const ( // DefaultAnimation - default animation of StackLayout push DefaultAnimation = 0 @@ -19,7 +20,7 @@ const ( BottomUpAnimation = 4 ) -// StackLayout - list-container of View +// StackLayout represents a StackLayout view type StackLayout interface { ViewsContainer diff --git a/svgImageView.go b/svgImageView.go index b1a7e06..ed318fe 100644 --- a/svgImageView.go +++ b/svgImageView.go @@ -7,7 +7,7 @@ import ( "strings" ) -// SvgImageView - image View +// SvgImageView represents an SvgImageView view type SvgImageView interface { View } diff --git a/tableAdapter.go b/tableAdapter.go index f482f4b..09b826e 100644 --- a/tableAdapter.go +++ b/tableAdapter.go @@ -1,6 +1,6 @@ package rui -// TableAdapter describes the TableView content +// TableAdapter describes the [TableView] content type TableAdapter interface { // RowCount returns number of rows in the table RowCount() int @@ -21,44 +21,49 @@ type TableAdapter interface { 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 +// 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 { + // ColumnStyle returns a map of properties which describe the style of the column ColumnStyle(column int) Params } -// TableRowStyle describes the style of TableView rows. -// To set row styles, you must either implement the TableRowStyle interface in the table adapter +// 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 { + // RowStyle returns a map of properties which describe the style of the row RowStyle(row int) Params } -// TableCellStyle describes the style of TableView cells. -// To set row cells, you must either implement the TableCellStyle interface in the table adapter +// 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 { + // CellStyle returns a map of properties which describe the style of the cell CellStyle(row, column int) Params } -// TableAllowCellSelection determines whether TableView cell selection is allowed. +// 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 { + // AllowCellSelection returns "true" if we allow the user to select particular cell at specific rows and columns AllowCellSelection(row, column int) bool } -// TableAllowRowSelection determines whether TableView row selection is allowed. +// 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 { + // AllowRowSelection returns "true" if we allow the user to select particular row in the table AllowRowSelection(row int) bool } -// SimpleTableAdapter is implementation of TableAdapter where the content +// 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 { @@ -71,7 +76,7 @@ type simpleTableAdapter struct { columnCount int } -// TextTableAdapter is implementation of TableAdapter where the content +// TextTableAdapter is implementation of [TableAdapter] where the content // defines as [][]string. // When you assign [][]string value to the "content" property, it is converted to TextTableAdapter type TextTableAdapter interface { diff --git a/tableView.go b/tableView.go index 3bfc64b..aef41b2 100644 --- a/tableView.go +++ b/tableView.go @@ -6,6 +6,7 @@ import ( "strings" ) +// Constants for [TableView] specific properties and events const ( // TableVerticalAlign is the constant for the "table-vertical-align" property tag. // The "table-vertical-align" int property sets the vertical alignment of the content inside a table cell. @@ -201,26 +202,35 @@ const ( // This property can be assigned or by an implementation of TableAllowCellSelection // or TableAllowRowSelection interface. AllowSelection = "allow-selection" +) - // NoneSelection is the value of "selection-mode" property: the selection is forbidden. +// Constants which represent values of "selection-mode" property of a [TableView] +const ( + // NoneSelection the selection is forbidden. NoneSelection = 0 - // CellSelection is the value of "selection-mode" property: the selection of a single cell only is enabled. + // CellSelection the selection of a single cell only is enabled. CellSelection = 1 - // RowSelection is the value of "selection-mode" property: the selection of a table row only is enabled. + // RowSelection the selection of a table row only is enabled. RowSelection = 2 ) -// CellIndex defines coordinates of the TableView cell +// CellIndex defines coordinates of the [TableView] cell type CellIndex struct { Row, Column int } -// TableView - text View +// TableView represents a TableView view type TableView interface { View ParentView + + // ReloadTableData forces the table view to reload all data and redraw the entire table ReloadTableData() + + // ReloadCell forces the table view to reload the data for a specific cell and redraw it ReloadCell(row, column int) + + // CellFrame returns the frame of a specific cell, describing its position and size within the table view CellFrame(row, column int) Frame content() TableAdapter diff --git a/tabsLayout.go b/tabsLayout.go index 0f28558..28c698e 100644 --- a/tabsLayout.go +++ b/tabsLayout.go @@ -5,6 +5,7 @@ import ( "strings" ) +// Constants for [TabsLayout] specific properties and events const ( // CurrentTabChangedEvent is the constant for "current-tab-changed" property tag. // The "current-tab-changed" event occurs when the new tab becomes active. @@ -46,6 +47,12 @@ const ( // The default value is "ruiCurrentTab" or "ruiCurrentVerticalTab". CurrentTabStyle = "current-tab-style" + inactiveTabStyle = "data-inactiveTabStyle" + activeTabStyle = "data-activeTabStyle" +) + +// Constants that are the values of the "tabs" property of a [TabsLayout] +const ( // TopTabs - tabs of TabsLayout are on the top TopTabs = 0 // BottomTabs - tabs of TabsLayout are on the bottom @@ -60,12 +67,9 @@ const ( RightListTabs = 5 // HiddenTabs - tabs of TabsLayout are hidden HiddenTabs = 6 - - inactiveTabStyle = "data-inactiveTabStyle" - activeTabStyle = "data-activeTabStyle" ) -// TabsLayout - multi-tab container of View +// TabsLayout represents a TabsLayout view type TabsLayout interface { ViewsContainer ListAdapter diff --git a/textView.go b/textView.go index 21d9995..210deeb 100644 --- a/textView.go +++ b/textView.go @@ -5,7 +5,7 @@ import ( "strings" ) -// TextView - text View +// TextView represents a TextView view type TextView interface { View } diff --git a/theme.go b/theme.go index 009e4b1..250b192 100644 --- a/theme.go +++ b/theme.go @@ -7,18 +7,34 @@ import ( "strings" ) +// Constants used as a values for [MediaStyleParams] member Orientation const ( - DefaultMedia = 0 - PortraitMedia = 1 + // DefaultMedia means that style appliance will not be related to client's window orientation + DefaultMedia = 0 + + // PortraitMedia means that style apply on clients with portrait window orientation + PortraitMedia = 1 + + // PortraitMedia means that style apply on clients with landscape window orientation LandscapeMedia = 2 ) +// MediaStyleParams define rules when particular style will be applied type MediaStyleParams struct { + // Orientation for which particular style will be applied Orientation int - MinWidth int - MaxWidth int - MinHeight int - MaxHeight int + + // MinWidth for which particular style will be applied + MinWidth int + + // MaxWidth for which particular style will be applied + MaxWidth int + + // MinHeight for which particular style will be applied + MinHeight int + + // MaxHeight for which particular style will be applied + MaxHeight int } type mediaStyle struct { @@ -38,31 +54,65 @@ type theme struct { mediaStyles []mediaStyle } +// Theme interface to describe application's theme type Theme interface { fmt.Stringer + + // Name returns a name of the theme Name() string + + // Constant returns normal and touch theme constant value with specific tag Constant(tag string) (string, string) + + // SetConstant sets a value for a constant SetConstant(tag string, value, touchUIValue string) + // ConstantTags returns the list of all available constants ConstantTags() []string + + // Color returns normal and dark theme color constant value with specific tag Color(tag string) (string, string) + + // SetColor sets normal and dark theme color constant value with specific tag SetColor(tag, color, darkUIColor string) + // ColorTags returns the list of all available color constants ColorTags() []string + + // Image returns normal and dark theme image constant value with specific tag Image(tag string) (string, string) + + // SetImage sets normal and dark theme image constant value with specific tag SetImage(tag, image, darkUIImage string) + // ImageConstantTags returns the list of all available image constants ImageConstantTags() []string + + // Style returns view style by its tag Style(tag string) ViewStyle + + // SetStyle sets style for a tag SetStyle(tag string, style ViewStyle) + + // RemoveStyle removes style with provided tag RemoveStyle(tag string) + + // MediaStyle returns media style which correspond to provided media style parameters MediaStyle(tag string, params MediaStyleParams) ViewStyle + + // SetMediaStyle sets media style with provided media style parameters and a tag SetMediaStyle(tag string, params MediaStyleParams, style ViewStyle) + + // StyleTags returns all tags which describe a style StyleTags() []string + + // MediaStyles returns all media style settings which correspond to a style tag MediaStyles(tag string) []struct { Selectors string Params MediaStyleParams } + + // Append theme to a list of themes Append(anotherTheme Theme) constant(tag string, touchUI bool) string @@ -196,6 +246,7 @@ func parseMediaRule(text string) (mediaStyle, bool) { var defaultTheme = NewTheme("") +// NewTheme creates a new theme with specific name and return its interface. func NewTheme(name string) Theme { result := new(theme) result.init() @@ -203,6 +254,7 @@ func NewTheme(name string) Theme { return result } +// CreateThemeFromText creates a new theme from text and return its interface on success. func CreateThemeFromText(text string) (Theme, bool) { result := new(theme) result.init() diff --git a/timePicker.go b/timePicker.go index 5e2fdf8..e523fee 100644 --- a/timePicker.go +++ b/timePicker.go @@ -6,16 +6,33 @@ import ( "time" ) +// Constants for [TimePicker] specific properties and events. const ( + // TimeChangedEvent is the constant for "time-changed" property tag. + // The "time-changed" event occur when current time of the [TimePicker] has been changed. + // The main listener format: func(picker TimePicker, newTime, oldTime time.Time). TimeChangedEvent = "time-changed" - TimePickerMin = "time-picker-min" - TimePickerMax = "time-picker-max" - TimePickerStep = "time-picker-step" - TimePickerValue = "time-picker-value" - timeFormat = "15:04:05" + + // TimePickerMin is the constant for "time-picker-min" property tag. + // The "time-picker-min" define the minimum value of the time. + TimePickerMin = "time-picker-min" + + // TimePickerMax is the constant for "time-picker-max" property tag. + // The "time-picker-max" define the maximum value of the time. + TimePickerMax = "time-picker-max" + + // TimePickerStep is the constant for "time-picker-step" property tag. + // The "time-picker-step" define time step in seconds. + TimePickerStep = "time-picker-step" + + // TimePickerValue is the constant for "time-picker-value" property tag. + // The "time-picker-value" define current value of the TimePicker. + TimePickerValue = "time-picker-value" + + timeFormat = "15:04:05" ) -// TimePicker - TimePicker view +// TimePicker represents a TimePicker view type TimePicker interface { View } diff --git a/touchEvents.go b/touchEvents.go index a6a8b54..1dab574 100644 --- a/touchEvents.go +++ b/touchEvents.go @@ -5,6 +5,7 @@ import ( "strings" ) +// Constants which represent [View] specific touch events properties const ( // TouchStart is the constant for "touch-start" property tag. // The "touch-start" event is fired when one or more touch points are placed on the touch surface. diff --git a/utils.go b/utils.go index b1ad3e0..b532f7a 100644 --- a/utils.go +++ b/utils.go @@ -36,6 +36,7 @@ func freeStringBuilder(builder *strings.Builder) { } } +// GetLocalIP return IP address of the machine interface func GetLocalIP() string { addrs, err := net.InterfaceAddrs() if err != nil { diff --git a/videoPlayer.go b/videoPlayer.go index 0369fa2..abe0694 100644 --- a/videoPlayer.go +++ b/videoPlayer.go @@ -4,6 +4,7 @@ import ( "strings" ) +// Constants for [VideoPlayer] specific properties and events const ( // VideoWidth is the constant for the "video-width" property tag of VideoPlayer. // The "video-width" float property defines the width of the video's display area in pixels. @@ -20,6 +21,7 @@ const ( Poster = "poster" ) +// VideoPlayer is a type of a [View] which can play video files type VideoPlayer interface { MediaPlayer } diff --git a/view.go b/view.go index b1ca488..f53c8d0 100644 --- a/view.go +++ b/view.go @@ -28,7 +28,7 @@ func (frame Frame) Bottom() float64 { return frame.Top + frame.Height } -// View - base view interface +// View represents a base view interface type View interface { ViewStyle fmt.Stringer diff --git a/viewFilter.go b/viewFilter.go index 7b35939..a90ec2e 100644 --- a/viewFilter.go +++ b/viewFilter.go @@ -5,6 +5,7 @@ import ( "strings" ) +// Constants for [ViewFilter] specific properties and events const ( // Blur is the constant for the "blur" property tag of the ViewFilter interface. // The "blur" float64 property applies a Gaussian blur. The value of radius defines the value diff --git a/viewTransform.go b/viewTransform.go index 517b82f..c28d758 100644 --- a/viewTransform.go +++ b/viewTransform.go @@ -6,6 +6,7 @@ import ( "strings" ) +// Constants for [Transform] specific properties const ( // Perspective is the name of the SizeUnit property that determines the distance between the z = 0 plane // and the user in order to give a 3D-positioned element some perspective. Each 3D element @@ -115,6 +116,7 @@ type transformData struct { propertyList } +// NewTransform creates a new transform property data and return its interface func NewTransform(params Params) Transform { transform := new(transformData) transform.properties = map[string]any{} diff --git a/viewUtils.go b/viewUtils.go index 17cc55e..d327896 100644 --- a/viewUtils.go +++ b/viewUtils.go @@ -694,6 +694,8 @@ func GetAvoidBreak(view View, subviewID ...string) bool { return boolStyledProperty(view, subviewID, AvoidBreak, true) } +// GetNotTranslate returns value of "not-translate" property of the subview. If the second argument (subviewID) is not +// specified or is an empty string then a value from the first argument (view) is returned. func GetNotTranslate(view View, subviewID ...string) bool { return boolStyledProperty(view, subviewID, NotTranslate, true) } diff --git a/viewsContainer.go b/viewsContainer.go index 7ef7163..853a3eb 100644 --- a/viewsContainer.go +++ b/viewsContainer.go @@ -2,12 +2,13 @@ package rui import "strings" +// ParentView describe a view which can have a child views type ParentView interface { // Views return a list of child views Views() []View } -// ViewsContainer - mutable list-container of Views +// ViewsContainer represent a mutable list-container of views type ViewsContainer interface { View ParentView