Added missing comments for exported types like constants, variables, functions, structs and interfaces

This commit is contained in:
Mikalai Turankou 2024-09-12 14:05:11 +03:00
parent 5707ca3088
commit 1a21487540
68 changed files with 752 additions and 200 deletions

View File

@ -2,7 +2,7 @@ package rui
import "strings" import "strings"
// AbsoluteLayout - list-container of View // AbsoluteLayout represent an AbsoluteLayout view where child views can be arbitrary positioned
type AbsoluteLayout interface { type AbsoluteLayout interface {
ViewsContainer ViewsContainer
} }

View File

@ -11,6 +11,7 @@ import (
// Can take the following values: Radian, Degree, Gradian, and Turn // Can take the following values: Radian, Degree, Gradian, and Turn
type AngleUnitType uint8 type AngleUnitType uint8
// Constants which represent values or the [AngleUnitType]
const ( const (
// Radian - angle in radians // Radian - angle in radians
Radian AngleUnitType = 0 Radian AngleUnitType = 0
@ -24,9 +25,12 @@ const (
Turn AngleUnitType = 4 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 AngleUnit struct {
// Type of the angle value
Type AngleUnitType Type AngleUnitType
// Value of the angle in Type units
Value float64 Value float64
} }

View File

@ -7,6 +7,7 @@ import (
"strings" "strings"
) )
// Constants which related to view's animation
const ( const (
// AnimationTag is the constant for the "animation" property tag. // AnimationTag is the constant for the "animation" property tag.
// The "animation" property sets and starts animations. // The "animation" property sets and starts animations.
@ -168,6 +169,7 @@ func parseAnimation(obj DataObject) Animation {
return animation return animation
} }
// NewAnimation creates a new animation object and return its interface
func NewAnimation(params Params) Animation { func NewAnimation(params Params) Animation {
animation := new(animationData) animation := new(animationData)
animation.init() animation.init()

View File

@ -2,6 +2,7 @@ package rui
import "strings" import "strings"
// Constants which describe values for view's animation events properties
const ( const (
// TransitionRunEvent is the constant for "transition-run-event" property tag. // TransitionRunEvent is the constant for "transition-run-event" property tag.
// The "transition-run-event" is fired when a transition is first created, // The "transition-run-event" is fired when a transition is first created,

View File

@ -415,6 +415,7 @@ func StartApp(addr string, createContentFunc func(Session) SessionContent, param
} }
} }
// FinishApp finishes application
func FinishApp() { func FinishApp() {
for _, app := range apps { for _, app := range apps {
app.Finish() app.Finish()
@ -422,6 +423,8 @@ func FinishApp() {
apps = []*application{} 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 { func OpenBrowser(url string) bool {
var err error var err error

View File

@ -14,10 +14,14 @@ var appStyles string
//go:embed defaultTheme.rui //go:embed defaultTheme.rui
var defaultThemeText string var defaultThemeText string
// Application - app interface // Application represent generic application interface, see also [Session]
type Application interface { type Application interface {
// Finish finishes the application
Finish() Finish()
// Params returns application parameters set by StartApp function
Params() AppParams Params() AppParams
removeSession(id int) removeSession(id int)
} }

View File

@ -1,5 +1,6 @@
package rui package rui
// AudioPlayer is a type of a [View] which can play audio files
type AudioPlayer interface { type AudioPlayer interface {
MediaPlayer MediaPlayer
} }

View File

@ -5,6 +5,7 @@ import (
"strings" "strings"
) )
// Constants related to view's background description
const ( const (
// NoRepeat is value of the Repeat property of an background image: // NoRepeat is value of the Repeat property of an background image:
// The image is not repeated (and hence the background image painting area // The image is not repeated (and hence the background image painting area
@ -61,13 +62,18 @@ const (
ContentBoxClip = 2 ContentBoxClip = 2
) )
// BackgroundElement describes the background element. // BackgroundElement describes the background element
type BackgroundElement interface { type BackgroundElement interface {
Properties Properties
fmt.Stringer fmt.Stringer
stringWriter stringWriter
cssStyle(session Session) string cssStyle(session Session) string
// Tag returns type of the background element.
// Possible values are: "image", "conic-gradient", "linear-gradient" and "radial-gradient"
Tag() string Tag() string
// Clone creates a new copy of BackgroundElement
Clone() BackgroundElement Clone() BackgroundElement
} }

View File

@ -28,6 +28,7 @@ func NewBackgroundConicGradient(params Params) BackgroundElement {
return result return result
} }
// String convert internal representation of [BackgroundGradientAngle] into a string.
func (point *BackgroundGradientAngle) String() string { func (point *BackgroundGradientAngle) String() string {
result := "black" result := "black"
if point.Color != nil { if point.Color != nil {

View File

@ -2,6 +2,7 @@ package rui
import "strings" import "strings"
// Constants related to view's background gradient description
const ( const (
// ToTopGradient is value of the Direction property of a linear gradient. The value is equivalent to the 0deg angle // 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 return 0, false
} }
// String convert internal representation of [BackgroundGradientPoint] into a string.
func (point *BackgroundGradientPoint) String() string { func (point *BackgroundGradientPoint) String() string {
result := "black" result := "black"
if point.Color != nil { if point.Color != nil {

View File

@ -5,6 +5,7 @@ import (
"strings" "strings"
) )
// Constants related to view's border description
const ( const (
// NoneLine constant specifies that there is no border // NoneLine constant specifies that there is no border
NoneLine = 0 NoneLine = 0
@ -50,7 +51,10 @@ type BorderProperty interface {
Properties Properties
fmt.Stringer fmt.Stringer
stringWriter stringWriter
// ViewBorders returns top, right, bottom and left borders information all together
ViewBorders(session Session) ViewBorders ViewBorders(session Session) ViewBorders
delete(tag string) delete(tag string)
cssStyle(builder cssBuilder, session Session) cssStyle(builder cssBuilder, session Session)
cssWidth(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 // ViewBorder describes parameters of a view border
type ViewBorder struct { type ViewBorder struct {
// Style of the border line
Style int Style int
// Color of the border line
Color Color Color Color
// Width of the border line
Width SizeUnit Width SizeUnit
} }

View File

@ -5,11 +5,13 @@ import (
"strings" "strings"
) )
// BorderProperty is the interface of a bounds property data // BorderProperty is an interface of a bounds property data
type BoundsProperty interface { type BoundsProperty interface {
Properties Properties
fmt.Stringer fmt.Stringer
stringWriter stringWriter
// Bounds returns top, right, bottom and left size of the bounds
Bounds(session Session) Bounds Bounds(session Session) Bounds
} }

View File

@ -1,6 +1,6 @@
package rui package rui
// Button - button view // Button represent a Button view
type Button interface { type Button interface {
CustomView CustomView
} }

View File

@ -6,6 +6,7 @@ import (
"strings" "strings"
) )
// Constants related to canvas view operations
const ( const (
// MiterJoin - Connected segments are joined by extending their outside edges // MiterJoin - Connected segments are joined by extending their outside edges
// to connect at a single point, with the effect of filling an additional // to connect at a single point, with the effect of filling an additional
@ -91,7 +92,7 @@ type TextMetrics struct {
Right float64 Right float64
} }
// Canvas is a drawing interface // Canvas is a drawing interface used by the [CanvasView]
type Canvas interface { type Canvas interface {
// View return the view for the drawing // View return the view for the drawing
View() CanvasView View() CanvasView

View File

@ -10,6 +10,8 @@ const DrawFunction = "draw-function"
// CanvasView interface of a custom draw view // CanvasView interface of a custom draw view
type CanvasView interface { type CanvasView interface {
View View
// Redraw forces CanvasView to redraw its content
Redraw() Redraw()
} }

View File

@ -9,7 +9,7 @@ import (
// The main listener format: func(Checkbox, bool), where the second argument is the checkbox state. // The main listener format: func(Checkbox, bool), where the second argument is the checkbox state.
const CheckboxChangedEvent = "checkbox-event" const CheckboxChangedEvent = "checkbox-event"
// Checkbox - checkbox view // Checkbox represent a Checkbox view
type Checkbox interface { type Checkbox interface {
ViewsContainer ViewsContainer
} }

View File

@ -2,6 +2,7 @@ package rui
import "sort" import "sort"
// A set of predefined colors used in the library
const ( const (
// Black color constant // Black color constant
Black Color = 0xff000000 Black Color = 0xff000000
@ -449,8 +450,12 @@ var colorConstants = map[string]Color{
"yellowgreen": 0xff9acd32, "yellowgreen": 0xff9acd32,
} }
// NamedColor make a relation between color and its name
type NamedColor struct { type NamedColor struct {
// Name of a color
Name string Name string
// Color value
Color Color Color Color
} }

View File

@ -4,12 +4,19 @@ import (
"strings" "strings"
) )
// Constants for [ColorPicker] specific properties and events.
const ( 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" ColorChangedEvent = "color-changed"
// ColorPickerValue is the constant for "color-picker-value" property tag.
// The "color-picker-value" define current color picker value.
ColorPickerValue = "color-picker-value" ColorPickerValue = "color-picker-value"
) )
// ColorPicker - ColorPicker view // ColorPicker represent a ColorPicker view
type ColorPicker interface { type ColorPicker interface {
View View
} }

View File

@ -5,6 +5,7 @@ import (
"strings" "strings"
) )
// Constants for [ColumnLayout] specific properties and events
const ( const (
// ColumnCount is the constant for the "column-count" property tag. // 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 // The "column-count" int property specifies number of columns into which the content is break
@ -52,7 +53,7 @@ const (
ColumnSpanAll = "column-span-all" ColumnSpanAll = "column-span-all"
) )
// ColumnLayout - grid-container of View // ColumnLayout represent a ColumnLayout view
type ColumnLayout interface { type ColumnLayout interface {
ViewsContainer ViewsContainer
} }

View File

@ -10,7 +10,10 @@ type ColumnSeparatorProperty interface {
Properties Properties
fmt.Stringer fmt.Stringer
stringWriter stringWriter
// ViewBorder returns column separator description in a form of ViewBorder
ViewBorder(session Session) ViewBorder ViewBorder(session Session) ViewBorder
cssValue(session Session) string cssValue(session Session) string
} }

View File

@ -5,8 +5,13 @@ import "strings"
// CustomView defines a custom view interface // CustomView defines a custom view interface
type CustomView interface { type CustomView interface {
ViewsContainer ViewsContainer
// CreateSuperView must be implemented to create a base view from which custom control has been built
CreateSuperView(session Session) View CreateSuperView(session Session) View
// SuperView must be implemented to return a base view from which custom control has been built
SuperView() View SuperView() View
setSuperView(view View) setSuperView(view View)
setTag(tag string) setTag(tag string)
} }
@ -71,10 +76,14 @@ func (customView *CustomViewData) Set(tag string, value any) bool {
return customView.superView.Set(tag, value) 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 { func (customView *CustomViewData) SetAnimated(tag string, value any, animation Animation) bool {
return customView.superView.SetAnimated(tag, value, animation) 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)) { func (customView *CustomViewData) SetChangeListener(tag string, listener func(View, string)) {
customView.superView.SetChangeListener(tag, listener) customView.superView.SetChangeListener(tag, listener)
} }
@ -151,10 +160,12 @@ func (customView *CustomViewData) Frame() Frame {
return customView.superView.Frame() return customView.superView.Frame()
} }
// Scroll returns a location and size of a scrollable view in pixels
func (customView *CustomViewData) Scroll() Frame { func (customView *CustomViewData) Scroll() Frame {
return customView.superView.Scroll() return customView.superView.Scroll()
} }
// HasFocus returns "true" if the view has focus
func (customView *CustomViewData) HasFocus() bool { func (customView *CustomViewData) HasFocus() bool {
return customView.superView.HasFocus() return customView.superView.HasFocus()
} }
@ -272,6 +283,7 @@ func (customView *CustomViewData) exscludeTags() []string {
return nil return nil
} }
// String convert internal representation of a [CustomViewData] into a string.
func (customView *CustomViewData) String() string { func (customView *CustomViewData) String() string {
if customView.superView != nil { if customView.superView != nil {
return getViewString(customView, customView.exscludeTags()) 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 { func (customView *CustomViewData) Transition(tag string) Animation {
if customView.superView != nil { if customView.superView != nil {
return customView.superView.Transition(tag) return customView.superView.Transition(tag)
@ -292,6 +305,7 @@ func (customView *CustomViewData) Transition(tag string) Animation {
return nil return nil
} }
// Transitions returns a map of transition animations. The result is always non-nil.
func (customView *CustomViewData) Transitions() map[string]Animation { func (customView *CustomViewData) Transitions() map[string]Animation {
if customView.superView != nil { if customView.superView != nil {
return customView.superView.Transitions() return customView.superView.Transitions()
@ -299,6 +313,9 @@ func (customView *CustomViewData) Transitions() map[string]Animation {
return 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) { func (customView *CustomViewData) SetTransition(tag string, animation Animation) {
if customView.superView != nil { if customView.superView != nil {
customView.superView.SetTransition(tag, animation) customView.superView.SetTransition(tag, animation)

39
data.go
View File

@ -7,25 +7,49 @@ import (
// DataValue interface of a data node value // DataValue interface of a data node value
type DataValue interface { type DataValue interface {
// IsObject returns "true" if data value is an object
IsObject() bool IsObject() bool
// Object returns data value as a data object
Object() DataObject Object() DataObject
// Value returns value as a string
Value() string Value() string
} }
// DataObject interface of a data object // DataObject interface of a data object
type DataObject interface { type DataObject interface {
DataValue DataValue
// Tag returns data object tag
Tag() string Tag() string
// PropertyCount returns properties count
PropertyCount() int PropertyCount() int
// Property returns a data node corresponding to a property with specific index
Property(index int) DataNode Property(index int) DataNode
// PropertyByTag returns a data node corresponding to a property tag
PropertyByTag(tag string) DataNode PropertyByTag(tag string) DataNode
// PropertyValue returns a string value of a property with a specific tag
PropertyValue(tag string) (string, bool) PropertyValue(tag string) (string, bool)
// PropertyObject returns an object value of a property with a specific tag
PropertyObject(tag string) DataObject PropertyObject(tag string) DataObject
// SetPropertyValue sets a string value of a property with a specific tag
SetPropertyValue(tag, value string) SetPropertyValue(tag, value string)
// SetPropertyObject sets an object value of a property with a specific tag
SetPropertyObject(tag string, object DataObject) SetPropertyObject(tag string, object DataObject)
// ToParams create a params(map) representation of a data object
ToParams() Params ToParams() Params
} }
// Constants which are used to describe a node type, see [DataNode]
const ( const (
// TextNode - node is the pair "tag - text value". Syntax: <tag> = <text> // TextNode - node is the pair "tag - text value". Syntax: <tag> = <text>
TextNode = 0 TextNode = 0
@ -37,13 +61,28 @@ const (
// DataNode interface of a data node // DataNode interface of a data node
type DataNode interface { type DataNode interface {
// Tag returns a tag name
Tag() string Tag() string
// Type returns a node type. Possible values are TextNode, ObjectNode and ArrayNode
Type() int Type() int
// Text returns node text
Text() string Text() string
// Object returns node as object if that node type is an object
Object() DataObject Object() DataObject
// ArraySize returns array size if that node type is an array
ArraySize() int ArraySize() int
// ArrayElement returns a value of an array if that node type is an array
ArrayElement(index int) DataValue ArrayElement(index int) DataValue
// ArrayElements returns an array of objects if that node is an array
ArrayElements() []DataValue ArrayElements() []DataValue
// ArrayAsParams returns an array of a params(map) if that node is an array
ArrayAsParams() []Params ArrayAsParams() []Params
} }

View File

@ -6,16 +6,33 @@ import (
"time" "time"
) )
// Constants for [DatePicker] specific properties and events.
const ( 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" DateChangedEvent = "date-changed"
// DatePickerMin is the constant for "date-picker-min" property tag.
// The "date-picker-min" define minimum date value.
DatePickerMin = "date-picker-min" 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" 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" 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" DatePickerValue = "date-picker-value"
dateFormat = "2006-01-02" dateFormat = "2006-01-02"
) )
// DatePicker - DatePicker view // DatePicker represent a DatePicker view
type DatePicker interface { type DatePicker interface {
View View
} }

View File

@ -2,6 +2,7 @@ package rui
import "strings" import "strings"
// Constants for [DetailsView] specific properties and events
const ( const (
// Summary is the constant for the "summary" property tag. // Summary is the constant for the "summary" property tag.
// The contents of the "summary" property are used as the label for the disclosure widget. // The contents of the "summary" property are used as the label for the disclosure widget.
@ -12,7 +13,7 @@ const (
Expanded = "expanded" Expanded = "expanded"
) )
// DetailsView - collapsible container of View // DetailsView represent a DetailsView view, which is a collapsible container of views
type DetailsView interface { type DetailsView interface {
ViewsContainer ViewsContainer
} }

View File

@ -11,7 +11,7 @@ import (
// The main listener format: func(DropDownList, int), where the second argument is the item index. // The main listener format: func(DropDownList, int), where the second argument is the item index.
const DropDownEvent = "drop-down-event" const DropDownEvent = "drop-down-event"
// DropDownList - the interface of a drop-down list view // DropDownList represent a DropDownList view
type DropDownList interface { type DropDownList interface {
View View
getItems() []string getItems() []string

View File

@ -5,6 +5,7 @@ import (
"strings" "strings"
) )
// Constants for [EditView] specific properties and events
const ( const (
// EditTextChangedEvent is the constant for the "edit-text-changed" property tag. // EditTextChangedEvent is the constant for the "edit-text-changed" property tag.
EditTextChangedEvent = "edit-text-changed" EditTextChangedEvent = "edit-text-changed"
@ -19,6 +20,7 @@ const (
Spellcheck = "spellcheck" Spellcheck = "spellcheck"
) )
// Constants for the values of an [EditView] "edit-view-type" property
const ( const (
// SingleLineText - single-line text type of EditView // SingleLineText - single-line text type of EditView
SingleLineText = 0 SingleLineText = 0
@ -36,9 +38,11 @@ const (
MultiLineText = 6 MultiLineText = 6
) )
// EditView - grid-container of View // EditView represent an EditView view
type EditView interface { type EditView interface {
View View
// AppendText appends text to the current text of an EditView view
AppendText(text string) AppendText(text string)
} }

View File

@ -7,6 +7,7 @@ import (
"time" "time"
) )
// Constants for [FilePicker] specific properties and events
const ( const (
// FileSelectedEvent is the constant for "file-selected-event" property tag. // FileSelectedEvent is the constant for "file-selected-event" property tag.
// The "file-selected-event" is fired when user selects file(s) in the FilePicker. // The "file-selected-event" is fired when user selects file(s) in the FilePicker.
@ -31,7 +32,7 @@ type FileInfo struct {
MimeType string MimeType string
} }
// FilePicker - the control view for the files selecting // FilePicker represents the FilePicker view
type FilePicker interface { type FilePicker interface {
View View
// Files returns the list of selected files. // Files returns the list of selected files.

View File

@ -2,6 +2,7 @@ package rui
import "strings" import "strings"
// Constants which represent [View] specific focus events properties
const ( const (
// FocusEvent is the constant for "focus-event" property tag. // FocusEvent is the constant for "focus-event" property tag.
// The "focus-event" event occurs when the View takes input focus. // The "focus-event" event occurs when the View takes input focus.

View File

@ -5,6 +5,7 @@ import (
"strings" "strings"
) )
// Constants related to [GridLayout] specific properties and events
const ( const (
// CellVerticalAlign is the constant for the "cell-vertical-align" property tag. // CellVerticalAlign is the constant for the "cell-vertical-align" property tag.
// The "cell-vertical-align" int property sets the default vertical alignment // The "cell-vertical-align" int property sets the default vertical alignment
@ -43,6 +44,8 @@ const (
CellHorizontalSelfAlign = "cell-horizontal-self-align" 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 { type GridAdapter interface {
// GridColumnCount returns the number of columns in the grid // GridColumnCount returns the number of columns in the grid
GridColumnCount() int GridColumnCount() int
@ -54,21 +57,21 @@ type GridAdapter interface {
GridCellContent(row, column int, session Session) View 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 { type GridCellColumnSpanAdapter interface {
// GridCellColumnSpan returns the number of columns that a cell spans. // GridCellColumnSpan returns the number of columns that a cell spans.
// Values less than 1 are ignored. // Values less than 1 are ignored.
GridCellColumnSpan(row, column int) int 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 { type GridCellRowSpanAdapter interface {
// GridCellRowSpan returns the number of rows that a cell spans // GridCellRowSpan returns the number of rows that a cell spans
// Values less than 1 are ignored. // Values less than 1 are ignored.
GridCellRowSpan(row, column int) int GridCellRowSpan(row, column int) int
} }
// GridLayout - grid-container of View // GridLayout represents a GridLayout view
type GridLayout interface { type GridLayout interface {
ViewsContainer ViewsContainer

View File

@ -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...).
NewHandler is used to embed the rui application in third-party web frameworks (net/http, gin, echo...). //
Example for echo: // Example for echo:
//
e := echo.New() // e := echo.New()
e.Any(`/ui/*`, func()echo.HandlerFunc{ // e.Any(`/ui/*`, func()echo.HandlerFunc{
rui.AddEmbedResources(&resources) // rui.AddEmbedResources(&resources)
//
h := rui.NewHandler("/ui", CreateSessionContent, rui.AppParams{ // h := rui.NewHandler("/ui", CreateSessionContent, rui.AppParams{
Title: `Awesome app`, // Title: `Awesome app`,
Icon: `favicon.png`, // Icon: `favicon.png`,
}) // })
//
return func(c echo.Context) error { // return func(c echo.Context) error {
h.ServeHTTP(c.Response(), c.Request()) // h.ServeHTTP(c.Response(), c.Request())
return nil // return nil
} // }
}) // })
*/
func NewHandler(urlPrefix string, createContentFunc func(Session) SessionContent, params AppParams) *httpHandler { func NewHandler(urlPrefix string, createContentFunc func(Session) SessionContent, params AppParams) *httpHandler {
app := new(application) app := new(application)
app.params = params app.params = params

View File

@ -4,6 +4,7 @@ import (
"strconv" "strconv"
) )
// Constants which represent return values of the LoadingStatus function of an [Image] view
const ( const (
// ImageLoading is the image loading status: in the process of loading // ImageLoading is the image loading status: in the process of loading
ImageLoading = 0 ImageLoading = 0

View File

@ -5,6 +5,7 @@ import (
"strings" "strings"
) )
// Constants which represent [ImageView] specific properties and events
const ( const (
// LoadedEvent is the constant for the "loaded-event" property tag. // LoadedEvent is the constant for the "loaded-event" property tag.
// The "loaded-event" event occurs event occurs when the image has been loaded. // The "loaded-event" event occurs event occurs when the image has been loaded.
@ -33,7 +34,7 @@ const (
ScaleDownFit = 4 ScaleDownFit = 4
) )
// ImageView - image View // ImageView represents an ImageView view
type ImageView interface { type ImageView interface {
View View
// NaturalSize returns the intrinsic, density-corrected size (width, height) of the image in pixels. // NaturalSize returns the intrinsic, density-corrected size (width, height) of the image in pixels.

View File

@ -2,6 +2,7 @@ package rui
import "strings" import "strings"
// Constants which represent [View] specific keyboard events properties
const ( const (
// KeyDown is the constant for "key-down-event" property tag. // KeyDown is the constant for "key-down-event" property tag.
// The "key-down-event" event is fired when a key is pressed. // The "key-down-event" event is fired when a key is pressed.
@ -20,9 +21,15 @@ const (
KeyUpEvent = "key-up-event" KeyUpEvent = "key-up-event"
) )
// ControlKeyMask represent ORed state of keyboard's control keys like [AltKey], [CtrlKey], [ShiftKey] and [MetaKey]
type ControlKeyMask int 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 type KeyCode string
// Constants for specific keyboard keys.
const ( const (
// AltKey is the mask of the "alt" key // AltKey is the mask of the "alt" key
AltKey ControlKeyMask = 1 AltKey ControlKeyMask = 1
@ -33,114 +40,326 @@ const (
// MetaKey is the mask of the "meta" key // MetaKey is the mask of the "meta" key
MetaKey ControlKeyMask = 8 MetaKey ControlKeyMask = 8
// KeyA reresent "A" key on the keyboard
KeyA KeyCode = "KeyA" KeyA KeyCode = "KeyA"
// KeyB reresent "B" key on the keyboard
KeyB KeyCode = "KeyB" KeyB KeyCode = "KeyB"
// KeyC reresent "C" key on the keyboard
KeyC KeyCode = "KeyC" KeyC KeyCode = "KeyC"
// KeyD reresent "D" key on the keyboard
KeyD KeyCode = "KeyD" KeyD KeyCode = "KeyD"
// KeyE reresent "E" key on the keyboard
KeyE KeyCode = "KeyE" KeyE KeyCode = "KeyE"
// KeyF reresent "F" key on the keyboard
KeyF KeyCode = "KeyF" KeyF KeyCode = "KeyF"
// KeyG reresent "G" key on the keyboard
KeyG KeyCode = "KeyG" KeyG KeyCode = "KeyG"
// KeyH reresent "H" key on the keyboard
KeyH KeyCode = "KeyH" KeyH KeyCode = "KeyH"
// KeyI reresent "I" key on the keyboard
KeyI KeyCode = "KeyI" KeyI KeyCode = "KeyI"
// KeyJ reresent "J" key on the keyboard
KeyJ KeyCode = "KeyJ" KeyJ KeyCode = "KeyJ"
// KeyK reresent "K" key on the keyboard
KeyK KeyCode = "KeyK" KeyK KeyCode = "KeyK"
// KeyL reresent "L" key on the keyboard
KeyL KeyCode = "KeyL" KeyL KeyCode = "KeyL"
// KeyM reresent "M" key on the keyboard
KeyM KeyCode = "KeyM" KeyM KeyCode = "KeyM"
// KeyN reresent "N" key on the keyboard
KeyN KeyCode = "KeyN" KeyN KeyCode = "KeyN"
// KeyO reresent "O" key on the keyboard
KeyO KeyCode = "KeyO" KeyO KeyCode = "KeyO"
// KeyP reresent "P" key on the keyboard
KeyP KeyCode = "KeyP" KeyP KeyCode = "KeyP"
// KeyQ reresent "Q" key on the keyboard
KeyQ KeyCode = "KeyQ" KeyQ KeyCode = "KeyQ"
// KeyR reresent "R" key on the keyboard
KeyR KeyCode = "KeyR" KeyR KeyCode = "KeyR"
// KeyS reresent "S" key on the keyboard
KeyS KeyCode = "KeyS" KeyS KeyCode = "KeyS"
// KeyT reresent "T" key on the keyboard
KeyT KeyCode = "KeyT" KeyT KeyCode = "KeyT"
// KeyU reresent "U" key on the keyboard
KeyU KeyCode = "KeyU" KeyU KeyCode = "KeyU"
// KeyV reresent "V" key on the keyboard
KeyV KeyCode = "KeyV" KeyV KeyCode = "KeyV"
// KeyW reresent "W" key on the keyboard
KeyW KeyCode = "KeyW" KeyW KeyCode = "KeyW"
// KeyX reresent "X" key on the keyboard
KeyX KeyCode = "KeyX" KeyX KeyCode = "KeyX"
// KeyY reresent "Y" key on the keyboard
KeyY KeyCode = "KeyY" KeyY KeyCode = "KeyY"
// KeyZ reresent "Z" key on the keyboard
KeyZ KeyCode = "KeyZ" KeyZ KeyCode = "KeyZ"
// Digit0Key reresent "Digit0" key on the keyboard
Digit0Key KeyCode = "Digit0" Digit0Key KeyCode = "Digit0"
// Digit1Key reresent "Digit1" key on the keyboard
Digit1Key KeyCode = "Digit1" Digit1Key KeyCode = "Digit1"
// Digit2Key reresent "Digit2" key on the keyboard
Digit2Key KeyCode = "Digit2" Digit2Key KeyCode = "Digit2"
// Digit3Key reresent "Digit3" key on the keyboard
Digit3Key KeyCode = "Digit3" Digit3Key KeyCode = "Digit3"
// Digit4Key reresent "Digit4" key on the keyboard
Digit4Key KeyCode = "Digit4" Digit4Key KeyCode = "Digit4"
// Digit5Key reresent "Digit5" key on the keyboard
Digit5Key KeyCode = "Digit5" Digit5Key KeyCode = "Digit5"
// Digit6Key reresent "Digit6" key on the keyboard
Digit6Key KeyCode = "Digit6" Digit6Key KeyCode = "Digit6"
// Digit7Key reresent "Digit7" key on the keyboard
Digit7Key KeyCode = "Digit7" Digit7Key KeyCode = "Digit7"
// Digit8Key reresent "Digit8" key on the keyboard
Digit8Key KeyCode = "Digit8" Digit8Key KeyCode = "Digit8"
// Digit9Key reresent "Digit9" key on the keyboard
Digit9Key KeyCode = "Digit9" Digit9Key KeyCode = "Digit9"
// SpaceKey reresent "Space" key on the keyboard
SpaceKey KeyCode = "Space" SpaceKey KeyCode = "Space"
// MinusKey reresent "Minus" key on the keyboard
MinusKey KeyCode = "Minus" MinusKey KeyCode = "Minus"
// EqualKey reresent "Equal" key on the keyboard
EqualKey KeyCode = "Equal" EqualKey KeyCode = "Equal"
// IntlBackslashKey reresent "IntlBackslash" key on the keyboard
IntlBackslashKey KeyCode = "IntlBackslash" IntlBackslashKey KeyCode = "IntlBackslash"
// BracketLeftKey reresent "BracketLeft" key on the keyboard
BracketLeftKey KeyCode = "BracketLeft" BracketLeftKey KeyCode = "BracketLeft"
// BracketRightKey reresent "BracketRight" key on the keyboard
BracketRightKey KeyCode = "BracketRight" BracketRightKey KeyCode = "BracketRight"
// SemicolonKey reresent "Semicolon" key on the keyboard
SemicolonKey KeyCode = "Semicolon" SemicolonKey KeyCode = "Semicolon"
// CommaKey reresent "Comma" key on the keyboard
CommaKey KeyCode = "Comma" CommaKey KeyCode = "Comma"
// PeriodKey reresent "Period" key on the keyboard
PeriodKey KeyCode = "Period" PeriodKey KeyCode = "Period"
// QuoteKey reresent "Quote" key on the keyboard
QuoteKey KeyCode = "Quote" QuoteKey KeyCode = "Quote"
// BackquoteKey reresent "Backquote" key on the keyboard
BackquoteKey KeyCode = "Backquote" BackquoteKey KeyCode = "Backquote"
// SlashKey reresent "Slash" key on the keyboard
SlashKey KeyCode = "Slash" SlashKey KeyCode = "Slash"
// EscapeKey reresent "Escape" key on the keyboard
EscapeKey KeyCode = "Escape" EscapeKey KeyCode = "Escape"
// EnterKey reresent "Enter" key on the keyboard
EnterKey KeyCode = "Enter" EnterKey KeyCode = "Enter"
// TabKey reresent "Tab" key on the keyboard
TabKey KeyCode = "Tab" TabKey KeyCode = "Tab"
// CapsLockKey reresent "CapsLock" key on the keyboard
CapsLockKey KeyCode = "CapsLock" CapsLockKey KeyCode = "CapsLock"
// DeleteKey reresent "Delete" key on the keyboard
DeleteKey KeyCode = "Delete" DeleteKey KeyCode = "Delete"
// InsertKey reresent "Insert" key on the keyboard
InsertKey KeyCode = "Insert" InsertKey KeyCode = "Insert"
// HelpKey reresent "Help" key on the keyboard
HelpKey KeyCode = "Help" HelpKey KeyCode = "Help"
// BackspaceKey reresent "Backspace" key on the keyboard
BackspaceKey KeyCode = "Backspace" BackspaceKey KeyCode = "Backspace"
// PrintScreenKey reresent "PrintScreen" key on the keyboard
PrintScreenKey KeyCode = "PrintScreen" PrintScreenKey KeyCode = "PrintScreen"
// ScrollLockKey reresent "ScrollLock" key on the keyboard
ScrollLockKey KeyCode = "ScrollLock" ScrollLockKey KeyCode = "ScrollLock"
// PauseKey reresent "Pause" key on the keyboard
PauseKey KeyCode = "Pause" PauseKey KeyCode = "Pause"
// ContextMenuKey reresent "ContextMenu" key on the keyboard
ContextMenuKey KeyCode = "ContextMenu" ContextMenuKey KeyCode = "ContextMenu"
// ArrowLeftKey reresent "ArrowLeft" key on the keyboard
ArrowLeftKey KeyCode = "ArrowLeft" ArrowLeftKey KeyCode = "ArrowLeft"
// ArrowRightKey reresent "ArrowRight" key on the keyboard
ArrowRightKey KeyCode = "ArrowRight" ArrowRightKey KeyCode = "ArrowRight"
// ArrowUpKey reresent "ArrowUp" key on the keyboard
ArrowUpKey KeyCode = "ArrowUp" ArrowUpKey KeyCode = "ArrowUp"
// ArrowDownKey reresent "ArrowDown" key on the keyboard
ArrowDownKey KeyCode = "ArrowDown" ArrowDownKey KeyCode = "ArrowDown"
// HomeKey reresent "Home" key on the keyboard
HomeKey KeyCode = "Home" HomeKey KeyCode = "Home"
// EndKey reresent "End" key on the keyboard
EndKey KeyCode = "End" EndKey KeyCode = "End"
// PageUpKey reresent "PageUp" key on the keyboard
PageUpKey KeyCode = "PageUp" PageUpKey KeyCode = "PageUp"
// PageDownKey reresent "PageDown" key on the keyboard
PageDownKey KeyCode = "PageDown" PageDownKey KeyCode = "PageDown"
// F1Key reresent "F1" key on the keyboard
F1Key KeyCode = "F1" F1Key KeyCode = "F1"
// F2Key reresent "F2" key on the keyboard
F2Key KeyCode = "F2" F2Key KeyCode = "F2"
// F3Key reresent "F3" key on the keyboard
F3Key KeyCode = "F3" F3Key KeyCode = "F3"
// F4Key reresent "F4" key on the keyboard
F4Key KeyCode = "F4" F4Key KeyCode = "F4"
// F5Key reresent "F5" key on the keyboard
F5Key KeyCode = "F5" F5Key KeyCode = "F5"
// F6Key reresent "F6" key on the keyboard
F6Key KeyCode = "F6" F6Key KeyCode = "F6"
// F7Key reresent "F7" key on the keyboard
F7Key KeyCode = "F7" F7Key KeyCode = "F7"
// F8Key reresent "F8" key on the keyboard
F8Key KeyCode = "F8" F8Key KeyCode = "F8"
// F9Key reresent "F9" key on the keyboard
F9Key KeyCode = "F9" F9Key KeyCode = "F9"
// F10Key reresent "F10" key on the keyboard
F10Key KeyCode = "F10" F10Key KeyCode = "F10"
// F11Key reresent "F11" key on the keyboard
F11Key KeyCode = "F11" F11Key KeyCode = "F11"
// F12Key reresent "F12" key on the keyboard
F12Key KeyCode = "F12" F12Key KeyCode = "F12"
// F13Key reresent "F13" key on the keyboard
F13Key KeyCode = "F13" F13Key KeyCode = "F13"
// NumLockKey reresent "NumLock" key on the keyboard
NumLockKey KeyCode = "NumLock" NumLockKey KeyCode = "NumLock"
// NumpadKey0 reresent "Numpad0" key on the keyboard
NumpadKey0 KeyCode = "Numpad0" NumpadKey0 KeyCode = "Numpad0"
// NumpadKey1 reresent "Numpad1" key on the keyboard
NumpadKey1 KeyCode = "Numpad1" NumpadKey1 KeyCode = "Numpad1"
// NumpadKey2 reresent "Numpad2" key on the keyboard
NumpadKey2 KeyCode = "Numpad2" NumpadKey2 KeyCode = "Numpad2"
// NumpadKey3 reresent "Numpad3" key on the keyboard
NumpadKey3 KeyCode = "Numpad3" NumpadKey3 KeyCode = "Numpad3"
// NumpadKey4 reresent "Numpad4" key on the keyboard
NumpadKey4 KeyCode = "Numpad4" NumpadKey4 KeyCode = "Numpad4"
// NumpadKey5 reresent "Numpad5" key on the keyboard
NumpadKey5 KeyCode = "Numpad5" NumpadKey5 KeyCode = "Numpad5"
// NumpadKey6 reresent "Numpad6" key on the keyboard
NumpadKey6 KeyCode = "Numpad6" NumpadKey6 KeyCode = "Numpad6"
// NumpadKey7 reresent "Numpad7" key on the keyboard
NumpadKey7 KeyCode = "Numpad7" NumpadKey7 KeyCode = "Numpad7"
// NumpadKey8 reresent "Numpad8" key on the keyboard
NumpadKey8 KeyCode = "Numpad8" NumpadKey8 KeyCode = "Numpad8"
// NumpadKey9 reresent "Numpad9" key on the keyboard
NumpadKey9 KeyCode = "Numpad9" NumpadKey9 KeyCode = "Numpad9"
// NumpadDecimalKey reresent "NumpadDecimal" key on the keyboard
NumpadDecimalKey KeyCode = "NumpadDecimal" NumpadDecimalKey KeyCode = "NumpadDecimal"
// NumpadEnterKey reresent "NumpadEnter" key on the keyboard
NumpadEnterKey KeyCode = "NumpadEnter" NumpadEnterKey KeyCode = "NumpadEnter"
// NumpadAddKey reresent "NumpadAdd" key on the keyboard
NumpadAddKey KeyCode = "NumpadAdd" NumpadAddKey KeyCode = "NumpadAdd"
// NumpadSubtractKey reresent "NumpadSubtract" key on the keyboard
NumpadSubtractKey KeyCode = "NumpadSubtract" NumpadSubtractKey KeyCode = "NumpadSubtract"
// NumpadMultiplyKey reresent "NumpadMultiply" key on the keyboard
NumpadMultiplyKey KeyCode = "NumpadMultiply" NumpadMultiplyKey KeyCode = "NumpadMultiply"
// NumpadDivideKey reresent "NumpadDivide" key on the keyboard
NumpadDivideKey KeyCode = "NumpadDivide" NumpadDivideKey KeyCode = "NumpadDivide"
// ShiftLeftKey reresent "ShiftLeft" key on the keyboard
ShiftLeftKey KeyCode = "ShiftLeft" ShiftLeftKey KeyCode = "ShiftLeft"
// ShiftRightKey reresent "ShiftRight" key on the keyboard
ShiftRightKey KeyCode = "ShiftRight" ShiftRightKey KeyCode = "ShiftRight"
// ControlLeftKey reresent "ControlLeft" key on the keyboard
ControlLeftKey KeyCode = "ControlLeft" ControlLeftKey KeyCode = "ControlLeft"
// ControlRightKey reresent "ControlRight" key on the keyboard
ControlRightKey KeyCode = "ControlRight" ControlRightKey KeyCode = "ControlRight"
// AltLeftKey reresent "AltLeft" key on the keyboard
AltLeftKey KeyCode = "AltLeft" AltLeftKey KeyCode = "AltLeft"
// AltRightKey reresent "AltRight" key on the keyboard
AltRightKey KeyCode = "AltRight" AltRightKey KeyCode = "AltRight"
// MetaLeftKey reresent "MetaLeft" key on the keyboard
MetaLeftKey KeyCode = "MetaLeft" MetaLeftKey KeyCode = "MetaLeft"
// MetaRightKey reresent "MetaRight" key on the keyboard
MetaRightKey KeyCode = "MetaRight" MetaRightKey KeyCode = "MetaRight"
) )
// KeyEvent represent a keyboard event
type KeyEvent struct { type KeyEvent struct {
// TimeStamp is the time at which the event was created (in milliseconds). // TimeStamp is the time at which the event was created (in milliseconds).
// This value is time since epoch—but in reality, browsers' definitions vary. // This value is time since epoch—but in reality, browsers' definitions vary.

View File

@ -4,6 +4,7 @@ import (
"strings" "strings"
) )
// Constants which represent values of the "orientation" property of the [ListLayout]
const ( const (
// TopDownOrientation - subviews are arranged from top to bottom. Synonym of VerticalOrientation // TopDownOrientation - subviews are arranged from top to bottom. Synonym of VerticalOrientation
TopDownOrientation = 0 TopDownOrientation = 0
@ -16,7 +17,10 @@ const (
// EndToStartOrientation - subviews are arranged from right to left // EndToStartOrientation - subviews are arranged from right to left
EndToStartOrientation = 3 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 - subviews are scrolled and "true" if a new row/column starts
ListWrapOff = 0 ListWrapOff = 0
@ -27,7 +31,7 @@ const (
ListWrapReverse = 2 ListWrapReverse = 2
) )
// ListLayout - list-container of View // ListLayout represents a ListLayout view
type ListLayout interface { type ListLayout interface {
ViewsContainer ViewsContainer
// UpdateContent updates child Views if the "content" property value is set to ListAdapter, // UpdateContent updates child Views if the "content" property value is set to ListAdapter,

View File

@ -6,6 +6,7 @@ import (
"strings" "strings"
) )
// Constants which represent [ListView] specific properties and events
const ( const (
// ListItemClickedEvent is the constant for "list-item-clicked" property tag. // 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. // 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" 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 ( const (
// VerticalOrientation is the vertical ListView orientation // VerticalOrientation is the vertical ListView orientation
VerticalOrientation = 0 VerticalOrientation = 0
// HorizontalOrientation is the horizontal ListView orientation // HorizontalOrientation is the horizontal ListView orientation
HorizontalOrientation = 1 HorizontalOrientation = 1
)
// Constants which represent values of a "checkbox" property of [ListView]
const (
// NoneCheckbox is value of "checkbox" property: no checkbox // NoneCheckbox is value of "checkbox" property: no checkbox
NoneCheckbox = 0 NoneCheckbox = 0
// SingleCheckbox is value of "checkbox" property: only one item can be checked // SingleCheckbox is value of "checkbox" property: only one item can be checked
@ -49,7 +55,7 @@ const (
MultipleCheckbox = 2 MultipleCheckbox = 2
) )
// ListView - the list view interface // ListView represents a ListView view
type ListView interface { type ListView interface {
View View
ParentView ParentView

View File

@ -7,6 +7,7 @@ import (
"strings" "strings"
) )
// Constants which related to media player properties and events
const ( const (
// Controls is the constant for the "autoplay" controls tag. // 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 // If the "controls" bool property is "true", the browser will offer controls to allow the user
@ -156,6 +157,7 @@ const (
PlayerErrorSourceNotSupported = 4 PlayerErrorSourceNotSupported = 4
) )
// MediaPlayer is a common interface for media player views like [AudioPlayer] and [VideoPlayer].
type MediaPlayer interface { type MediaPlayer interface {
View View
@ -200,8 +202,12 @@ type mediaPlayerData struct {
viewData viewData
} }
// MediaSource represent one media file source
type MediaSource struct { type MediaSource struct {
// Url of the source
Url string Url string
// MimeType of the source
MimeType string MimeType string
} }

View File

@ -5,6 +5,7 @@ import (
"strings" "strings"
) )
// Constants related to [View] mouse events properties
const ( const (
// ClickEvent is the constant for "click-event" property tag. // ClickEvent is the constant for "click-event" property tag.
// The "click-event" event occurs when the user clicks on the View. // The "click-event" event occurs when the user clicks on the View.
@ -112,6 +113,7 @@ const (
MouseMask5 = 16 MouseMask5 = 16
) )
// MouseEvent represent a mouse event
type MouseEvent struct { type MouseEvent struct {
// TimeStamp is the time at which the event was created (in milliseconds). // TimeStamp is the time at which the event was created (in milliseconds).
// This value is time since epoch—but in reality, browsers' definitions vary. // This value is time since epoch—but in reality, browsers' definitions vary.

View File

@ -6,6 +6,7 @@ import (
"strings" "strings"
) )
// Constants related to [NumberPicker] specific properties and events
const ( const (
// NumberChangedEvent is the constant for the "" property tag. // NumberChangedEvent is the constant for the "" property tag.
// The "number-changed" property sets listener(s) that track the change in the entered value. // The "number-changed" property sets listener(s) that track the change in the entered value.
@ -34,6 +35,7 @@ const (
NumberPickerValue = "number-picker-value" NumberPickerValue = "number-picker-value"
) )
// Constants which describe values of the "number-picker-type" property of a [NumberPicker]
const ( const (
// NumberEditor - type of NumberPicker. NumberPicker is presented by editor // NumberEditor - type of NumberPicker. NumberPicker is presented by editor
NumberEditor = 0 NumberEditor = 0
@ -42,7 +44,7 @@ const (
NumberSlider = 1 NumberSlider = 1
) )
// NumberPicker - NumberPicker view // NumberPicker represents a NumberPicker view
type NumberPicker interface { type NumberPicker interface {
View View
} }

View File

@ -5,10 +5,13 @@ import (
"strings" "strings"
) )
// OutlineProperty defines a view's outside border
type OutlineProperty interface { type OutlineProperty interface {
Properties Properties
stringWriter stringWriter
fmt.Stringer fmt.Stringer
// ViewOutline returns style color and line width of an outline
ViewOutline(session Session) ViewOutline ViewOutline(session Session) ViewOutline
} }
@ -98,8 +101,13 @@ func (outline *outlinePropertyData) ViewOutline(session Session) ViewOutline {
// ViewOutline describes parameters of a view border // ViewOutline describes parameters of a view border
type ViewOutline struct { type ViewOutline struct {
// Style of the outline line
Style int Style int
// Color of the outline line
Color Color Color Color
// Width of the outline line
Width SizeUnit Width SizeUnit
} }

View File

@ -5,6 +5,8 @@ import "sort"
// Params defines a type of a parameters list // Params defines a type of a parameters list
type Params map[string]any 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 { func (params Params) Get(tag string) any {
return params.getRaw(tag) return params.getRaw(tag)
} }
@ -16,6 +18,8 @@ func (params Params) getRaw(tag string) any {
return nil 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 { func (params Params) Set(tag string, value any) bool {
params.setRaw(tag, value) params.setRaw(tag, value)
return true 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) { func (params Params) Remove(tag string) {
delete(params, tag) delete(params, tag)
} }
// Clear removes all properties from a map.
func (params Params) Clear() { func (params Params) Clear() {
for tag := range params { for tag := range params {
delete(params, tag) delete(params, tag)
} }
} }
// AllTags returns a sorted slice of all properties.
func (params Params) AllTags() []string { func (params Params) AllTags() []string {
tags := make([]string, 0, len(params)) tags := make([]string, 0, len(params))
for t := range params { for t := range params {

View File

@ -4,6 +4,7 @@ import (
"strings" "strings"
) )
// Constants for [View] specific pointer events properties
const ( const (
// PointerDown is the constant for "pointer-down" property tag. // 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 // 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" PointerOver = "pointer-over"
) )
// PointerEvent represent a stylus events. Also inherit [MouseEvent] attributes
type PointerEvent struct { type PointerEvent struct {
MouseEvent MouseEvent

View File

@ -4,6 +4,7 @@ import (
"strings" "strings"
) )
// Constants for [Popup] specific properties and events
const ( const (
// Title is the constant for the "title" property tag. // Title is the constant for the "title" property tag.
// The "title" property is defined the Popup/Tabs title // The "title" property is defined the Popup/Tabs title
@ -78,7 +79,10 @@ const (
// LeftArrow is value of the popup "arrow" property: // LeftArrow is value of the popup "arrow" property:
// Arrow on the left side of the pop-up window // Arrow on the left side of the pop-up window
LeftArrow = 4 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 is the constant of the popup button type: the normal button
NormalButton PopupButtonType = 0 NormalButton PopupButtonType = 0
// DefaultButton is the constant of the popup button type: button that fires when the "Enter" key is pressed // 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 CancelButton PopupButtonType = 2
) )
// PopupButtonType represent popup button type
type PopupButtonType int type PopupButtonType int
// PopupButton describes a button that will be placed at the bottom of the window. // PopupButton describes a button that will be placed at the bottom of the window.
type PopupButton struct { type PopupButton struct {
// Title of the button
Title string Title string
// Type of the button
Type PopupButtonType Type PopupButtonType
// OnClick is the handler function that gets called when the button is pressed
OnClick func(Popup) OnClick func(Popup)
} }
// Popup interface // Popup represents a Popup view
type Popup interface { type Popup interface {
// View returns a content view of the popup
View() View View() View
// Session returns current client session
Session() Session Session() Session
// Show displays a popup
Show() Show()
// Dismiss closes a popup
Dismiss() Dismiss()
onDismiss() onDismiss()
html(buffer *strings.Builder) html(buffer *strings.Builder)
viewByHTMLID(id string) View viewByHTMLID(id string) View

View File

@ -5,12 +5,18 @@ import (
"strings" "strings"
) )
// Constants for [ProgressBar] specific properties and events
const ( const (
// ProgressBarMax is the constant for "progress-max" property tag.
// The "progress-max" define maximum value of the ProgressBar, default is 1.
ProgressBarMax = "progress-max" 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" ProgressBarValue = "progress-value"
) )
// ProgressBar - ProgressBar view // ProgressBar represents a ProgressBar view
type ProgressBar interface { type ProgressBar interface {
View View
} }

View File

@ -1,5 +1,6 @@
package rui package rui
// Constants for various properties and events of Views'.
const ( const (
// ID is the constant for the "id" property tag. // ID is the constant for the "id" property tag.
// The "id" property is an optional textual identifier for the View. // 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. // * A positive value means View should be focusable in sequential keyboard navigation, with its order defined by the value of the number.
TabIndex = "tabindex" 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" Tooltip = "tooltip"
) )

View File

@ -1,5 +1,6 @@
package rui package rui
// Constants for various specific properties of a views
const ( const (
// Visible - default value of the view Visibility property: View is visible // Visible - default value of the view Visibility property: View is visible
Visible = 0 Visible = 0

View File

@ -5,6 +5,7 @@ import (
"strings" "strings"
) )
// Constants for [RadiusProperty] specific properties
const ( const (
// Radius is the SizeUnit view property that determines the corners rounding radius // Radius is the SizeUnit view property that determines the corners rounding radius
// of an element's outer border edge. // of an element's outer border edge.
@ -95,10 +96,13 @@ const (
BottomRightY = "bottom-right-y" BottomRightY = "bottom-right-y"
) )
// RadiusProperty is a description of the [View] (shape) elliptical corner radius.
type RadiusProperty interface { type RadiusProperty interface {
Properties Properties
stringWriter stringWriter
fmt.Stringer fmt.Stringer
// BoxRadius returns x and y radius of the corners of the element
BoxRadius(session Session) BoxRadius BoxRadius(session Session) BoxRadius
} }

View File

@ -6,6 +6,7 @@ import (
"strings" "strings"
) )
// Constants for [Resizable] specific properties and events
const ( const (
// Side is the constant for the "side" property tag. // Side is the constant for the "side" property tag.
// The "side" int property determines which side of the container is used to resize. // 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. // ResizeBorderWidth is the constant for the "resize-border-width" property tag.
// The "ResizeBorderWidth" SizeUnit property determines the width of the resizing border // The "ResizeBorderWidth" SizeUnit property determines the width of the resizing border
ResizeBorderWidth = "resize-border-width" 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 is value of the "side" property: the top side is used to resize
TopSide = 1 TopSide = 1
@ -32,7 +36,7 @@ const (
AllSides = TopSide | RightSide | BottomSide | LeftSide AllSides = TopSide | RightSide | BottomSide | LeftSide
) )
// Resizable - grid-container of View // Resizable represents a Resizable view
type Resizable interface { type Resizable interface {
View View
ParentView ParentView

View File

@ -45,6 +45,7 @@ var resources = resourceManager{
imageSrcSets: map[string][]scaledImage{}, imageSrcSets: map[string][]scaledImage{},
} }
// AddEmbedResources adds embedded resources to the list of application resources
func AddEmbedResources(fs *embed.FS) { func AddEmbedResources(fs *embed.FS) {
resources.embedFS = append(resources.embedFS, fs) resources.embedFS = append(resources.embedFS, fs)
rootDirs := resources.embedRootDirs(fs) rootDirs := resources.embedRootDirs(fs)
@ -457,6 +458,7 @@ func AllImageResources() []string {
return result return result
} }
// AddTheme adds theme to application
func AddTheme(theme Theme) { func AddTheme(theme Theme) {
if theme != nil { if theme != nil {
name := theme.Name() name := theme.Name()

View File

@ -36,6 +36,8 @@ type bridge interface {
// SessionContent is the interface of a session content // SessionContent is the interface of a session content
type SessionContent interface { type SessionContent interface {
// CreateRootView will be called by the library to create a root view of the application
CreateRootView(session Session) View CreateRootView(session Session) View
} }

View File

@ -4,31 +4,42 @@ import "time"
// SessionStartListener is the listener interface of a session start event // SessionStartListener is the listener interface of a session start event
type SessionStartListener interface { 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) OnStart(session Session)
} }
// SessionFinishListener is the listener interface of a session start event // SessionFinishListener is the listener interface of a session start event
type SessionFinishListener interface { 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) OnFinish(session Session)
} }
// SessionResumeListener is the listener interface of a session resume event // SessionResumeListener is the listener interface of a session resume event
type SessionResumeListener interface { 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) OnResume(session Session)
} }
// SessionPauseListener is the listener interface of a session pause event // SessionPauseListener is the listener interface of a session pause event
type SessionPauseListener interface { 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) OnPause(session Session)
} }
// SessionPauseListener is the listener interface of a session disconnect event // SessionPauseListener is the listener interface of a session disconnect event
type SessionDisconnectListener interface { 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) OnDisconnect(session Session)
} }
// SessionPauseListener is the listener interface of a session reconnect event // SessionPauseListener is the listener interface of a session reconnect event
type SessionReconnectListener interface { 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) OnReconnect(session Session)
} }

View File

@ -5,6 +5,7 @@ import (
"strings" "strings"
) )
// Constants for [ViewShadow] specific properties
const ( const (
// ColorTag is the name of the color property of the shadow. // ColorTag is the name of the color property of the shadow.
ColorTag = "color" ColorTag = "color"

View File

@ -13,6 +13,7 @@ import (
// SizeInDIP, SizeInPt, SizeInInch, SizeInMM, SizeInFraction // SizeInDIP, SizeInPt, SizeInInch, SizeInMM, SizeInFraction
type SizeUnitType uint8 type SizeUnitType uint8
// Constants which represent values of a [SizeUnitType]
const ( const (
// Auto is the SizeUnit type: default value. // Auto is the SizeUnit type: default value.
Auto SizeUnitType = 0 Auto SizeUnitType = 0
@ -44,8 +45,14 @@ const (
// SizeUnit describe a size (Value field) and size unit (Type field). // SizeUnit describe a size (Value field) and size unit (Type field).
type SizeUnit struct { type SizeUnit struct {
// Type or dimension of the value
Type SizeUnitType Type SizeUnitType
// Value of the size in Type units
Value float64 Value float64
// Function representation of a size unit.
// When setting this value type should be set to SizeFunction
Function SizeFunc Function SizeFunc
} }

View File

@ -6,6 +6,7 @@ import (
"strings" "strings"
) )
// Constants which represent [StackLayout] animation type during pushing or popping views
const ( const (
// DefaultAnimation - default animation of StackLayout push // DefaultAnimation - default animation of StackLayout push
DefaultAnimation = 0 DefaultAnimation = 0
@ -19,7 +20,7 @@ const (
BottomUpAnimation = 4 BottomUpAnimation = 4
) )
// StackLayout - list-container of View // StackLayout represents a StackLayout view
type StackLayout interface { type StackLayout interface {
ViewsContainer ViewsContainer

View File

@ -7,7 +7,7 @@ import (
"strings" "strings"
) )
// SvgImageView - image View // SvgImageView represents an SvgImageView view
type SvgImageView interface { type SvgImageView interface {
View View
} }

View File

@ -1,6 +1,6 @@
package rui package rui
// TableAdapter describes the TableView content // TableAdapter describes the [TableView] content
type TableAdapter interface { type TableAdapter interface {
// RowCount returns number of rows in the table // RowCount returns number of rows in the table
RowCount() int RowCount() int
@ -21,44 +21,49 @@ type TableAdapter interface {
Cell(row, column int) any Cell(row, column int) any
} }
// TableColumnStyle describes the style of TableView columns. // TableColumnStyle describes the style of [TableView] columns.
// To set column styles, you must either implement the TableColumnStyle interface in the table adapter // 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. // or assign its separate implementation to the "column-style" property.
type TableColumnStyle interface { type TableColumnStyle interface {
// ColumnStyle returns a map of properties which describe the style of the column
ColumnStyle(column int) Params ColumnStyle(column int) Params
} }
// TableRowStyle describes the style of TableView rows. // TableRowStyle describes the style of [TableView] rows.
// To set row styles, you must either implement the TableRowStyle interface in the table adapter // 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. // or assign its separate implementation to the "row-style" property.
type TableRowStyle interface { type TableRowStyle interface {
// RowStyle returns a map of properties which describe the style of the row
RowStyle(row int) Params RowStyle(row int) Params
} }
// TableCellStyle describes the style of TableView cells. // TableCellStyle describes the style of [TableView] cells.
// To set row cells, you must either implement the TableCellStyle interface in the table adapter // 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. // or assign its separate implementation to the "cell-style" property.
type TableCellStyle interface { type TableCellStyle interface {
// CellStyle returns a map of properties which describe the style of the cell
CellStyle(row, column int) Params 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). // 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 // 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. // in the table adapter or assign its separate implementation to the "allow-selection" property.
type TableAllowCellSelection interface { 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 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). // 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 // 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. // in the table adapter or assign its separate implementation to the "allow-selection" property.
type TableAllowRowSelection interface { type TableAllowRowSelection interface {
// AllowRowSelection returns "true" if we allow the user to select particular row in the table
AllowRowSelection(row int) bool AllowRowSelection(row int) bool
} }
// SimpleTableAdapter is implementation of TableAdapter where the content // SimpleTableAdapter is implementation of [TableAdapter] where the content
// defines as [][]any. // defines as [][]any.
// When you assign [][]any value to the "content" property, it is converted to SimpleTableAdapter // When you assign [][]any value to the "content" property, it is converted to SimpleTableAdapter
type SimpleTableAdapter interface { type SimpleTableAdapter interface {
@ -71,7 +76,7 @@ type simpleTableAdapter struct {
columnCount int columnCount int
} }
// TextTableAdapter is implementation of TableAdapter where the content // TextTableAdapter is implementation of [TableAdapter] where the content
// defines as [][]string. // defines as [][]string.
// When you assign [][]string value to the "content" property, it is converted to TextTableAdapter // When you assign [][]string value to the "content" property, it is converted to TextTableAdapter
type TextTableAdapter interface { type TextTableAdapter interface {

View File

@ -6,6 +6,7 @@ import (
"strings" "strings"
) )
// Constants for [TableView] specific properties and events
const ( const (
// TableVerticalAlign is the constant for the "table-vertical-align" property tag. // 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. // 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 // This property can be assigned or by an implementation of TableAllowCellSelection
// or TableAllowRowSelection interface. // or TableAllowRowSelection interface.
AllowSelection = "allow-selection" 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 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 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 RowSelection = 2
) )
// CellIndex defines coordinates of the TableView cell // CellIndex defines coordinates of the [TableView] cell
type CellIndex struct { type CellIndex struct {
Row, Column int Row, Column int
} }
// TableView - text View // TableView represents a TableView view
type TableView interface { type TableView interface {
View View
ParentView ParentView
// ReloadTableData forces the table view to reload all data and redraw the entire table
ReloadTableData() ReloadTableData()
// ReloadCell forces the table view to reload the data for a specific cell and redraw it
ReloadCell(row, column int) 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 CellFrame(row, column int) Frame
content() TableAdapter content() TableAdapter

View File

@ -5,6 +5,7 @@ import (
"strings" "strings"
) )
// Constants for [TabsLayout] specific properties and events
const ( const (
// CurrentTabChangedEvent is the constant for "current-tab-changed" property tag. // CurrentTabChangedEvent is the constant for "current-tab-changed" property tag.
// The "current-tab-changed" event occurs when the new tab becomes active. // The "current-tab-changed" event occurs when the new tab becomes active.
@ -46,6 +47,12 @@ const (
// The default value is "ruiCurrentTab" or "ruiCurrentVerticalTab". // The default value is "ruiCurrentTab" or "ruiCurrentVerticalTab".
CurrentTabStyle = "current-tab-style" 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 - tabs of TabsLayout are on the top
TopTabs = 0 TopTabs = 0
// BottomTabs - tabs of TabsLayout are on the bottom // BottomTabs - tabs of TabsLayout are on the bottom
@ -60,12 +67,9 @@ const (
RightListTabs = 5 RightListTabs = 5
// HiddenTabs - tabs of TabsLayout are hidden // HiddenTabs - tabs of TabsLayout are hidden
HiddenTabs = 6 HiddenTabs = 6
inactiveTabStyle = "data-inactiveTabStyle"
activeTabStyle = "data-activeTabStyle"
) )
// TabsLayout - multi-tab container of View // TabsLayout represents a TabsLayout view
type TabsLayout interface { type TabsLayout interface {
ViewsContainer ViewsContainer
ListAdapter ListAdapter

View File

@ -5,7 +5,7 @@ import (
"strings" "strings"
) )
// TextView - text View // TextView represents a TextView view
type TextView interface { type TextView interface {
View View
} }

View File

@ -7,17 +7,33 @@ import (
"strings" "strings"
) )
// Constants used as a values for [MediaStyleParams] member Orientation
const ( const (
// DefaultMedia means that style appliance will not be related to client's window orientation
DefaultMedia = 0 DefaultMedia = 0
// PortraitMedia means that style apply on clients with portrait window orientation
PortraitMedia = 1 PortraitMedia = 1
// PortraitMedia means that style apply on clients with landscape window orientation
LandscapeMedia = 2 LandscapeMedia = 2
) )
// MediaStyleParams define rules when particular style will be applied
type MediaStyleParams struct { type MediaStyleParams struct {
// Orientation for which particular style will be applied
Orientation int Orientation int
// MinWidth for which particular style will be applied
MinWidth int MinWidth int
// MaxWidth for which particular style will be applied
MaxWidth int MaxWidth int
// MinHeight for which particular style will be applied
MinHeight int MinHeight int
// MaxHeight for which particular style will be applied
MaxHeight int MaxHeight int
} }
@ -38,31 +54,65 @@ type theme struct {
mediaStyles []mediaStyle mediaStyles []mediaStyle
} }
// Theme interface to describe application's theme
type Theme interface { type Theme interface {
fmt.Stringer fmt.Stringer
// Name returns a name of the theme
Name() string Name() string
// Constant returns normal and touch theme constant value with specific tag
Constant(tag string) (string, string) Constant(tag string) (string, string)
// SetConstant sets a value for a constant
SetConstant(tag string, value, touchUIValue string) SetConstant(tag string, value, touchUIValue string)
// ConstantTags returns the list of all available constants // ConstantTags returns the list of all available constants
ConstantTags() []string ConstantTags() []string
// Color returns normal and dark theme color constant value with specific tag
Color(tag string) (string, string) Color(tag string) (string, string)
// SetColor sets normal and dark theme color constant value with specific tag
SetColor(tag, color, darkUIColor string) SetColor(tag, color, darkUIColor string)
// ColorTags returns the list of all available color constants // ColorTags returns the list of all available color constants
ColorTags() []string ColorTags() []string
// Image returns normal and dark theme image constant value with specific tag
Image(tag string) (string, string) Image(tag string) (string, string)
// SetImage sets normal and dark theme image constant value with specific tag
SetImage(tag, image, darkUIImage string) SetImage(tag, image, darkUIImage string)
// ImageConstantTags returns the list of all available image constants // ImageConstantTags returns the list of all available image constants
ImageConstantTags() []string ImageConstantTags() []string
// Style returns view style by its tag
Style(tag string) ViewStyle Style(tag string) ViewStyle
// SetStyle sets style for a tag
SetStyle(tag string, style ViewStyle) SetStyle(tag string, style ViewStyle)
// RemoveStyle removes style with provided tag
RemoveStyle(tag string) RemoveStyle(tag string)
// MediaStyle returns media style which correspond to provided media style parameters
MediaStyle(tag string, params MediaStyleParams) ViewStyle 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) SetMediaStyle(tag string, params MediaStyleParams, style ViewStyle)
// StyleTags returns all tags which describe a style
StyleTags() []string StyleTags() []string
// MediaStyles returns all media style settings which correspond to a style tag
MediaStyles(tag string) []struct { MediaStyles(tag string) []struct {
Selectors string Selectors string
Params MediaStyleParams Params MediaStyleParams
} }
// Append theme to a list of themes
Append(anotherTheme Theme) Append(anotherTheme Theme)
constant(tag string, touchUI bool) string constant(tag string, touchUI bool) string
@ -196,6 +246,7 @@ func parseMediaRule(text string) (mediaStyle, bool) {
var defaultTheme = NewTheme("") var defaultTheme = NewTheme("")
// NewTheme creates a new theme with specific name and return its interface.
func NewTheme(name string) Theme { func NewTheme(name string) Theme {
result := new(theme) result := new(theme)
result.init() result.init()
@ -203,6 +254,7 @@ func NewTheme(name string) Theme {
return result return result
} }
// CreateThemeFromText creates a new theme from text and return its interface on success.
func CreateThemeFromText(text string) (Theme, bool) { func CreateThemeFromText(text string) (Theme, bool) {
result := new(theme) result := new(theme)
result.init() result.init()

View File

@ -6,16 +6,33 @@ import (
"time" "time"
) )
// Constants for [TimePicker] specific properties and events.
const ( 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" TimeChangedEvent = "time-changed"
// 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" 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" 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" 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" TimePickerValue = "time-picker-value"
timeFormat = "15:04:05" timeFormat = "15:04:05"
) )
// TimePicker - TimePicker view // TimePicker represents a TimePicker view
type TimePicker interface { type TimePicker interface {
View View
} }

View File

@ -5,6 +5,7 @@ import (
"strings" "strings"
) )
// Constants which represent [View] specific touch events properties
const ( const (
// TouchStart is the constant for "touch-start" property tag. // 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. // The "touch-start" event is fired when one or more touch points are placed on the touch surface.

View File

@ -36,6 +36,7 @@ func freeStringBuilder(builder *strings.Builder) {
} }
} }
// GetLocalIP return IP address of the machine interface
func GetLocalIP() string { func GetLocalIP() string {
addrs, err := net.InterfaceAddrs() addrs, err := net.InterfaceAddrs()
if err != nil { if err != nil {

View File

@ -4,6 +4,7 @@ import (
"strings" "strings"
) )
// Constants for [VideoPlayer] specific properties and events
const ( const (
// VideoWidth is the constant for the "video-width" property tag of VideoPlayer. // 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. // The "video-width" float property defines the width of the video's display area in pixels.
@ -20,6 +21,7 @@ const (
Poster = "poster" Poster = "poster"
) )
// VideoPlayer is a type of a [View] which can play video files
type VideoPlayer interface { type VideoPlayer interface {
MediaPlayer MediaPlayer
} }

View File

@ -28,7 +28,7 @@ func (frame Frame) Bottom() float64 {
return frame.Top + frame.Height return frame.Top + frame.Height
} }
// View - base view interface // View represents a base view interface
type View interface { type View interface {
ViewStyle ViewStyle
fmt.Stringer fmt.Stringer

View File

@ -5,6 +5,7 @@ import (
"strings" "strings"
) )
// Constants for [ViewFilter] specific properties and events
const ( const (
// Blur is the constant for the "blur" property tag of the ViewFilter interface. // 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 // The "blur" float64 property applies a Gaussian blur. The value of radius defines the value

View File

@ -6,6 +6,7 @@ import (
"strings" "strings"
) )
// Constants for [Transform] specific properties
const ( const (
// Perspective is the name of the SizeUnit property that determines the distance between the z = 0 plane // 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 // and the user in order to give a 3D-positioned element some perspective. Each 3D element
@ -115,6 +116,7 @@ type transformData struct {
propertyList propertyList
} }
// NewTransform creates a new transform property data and return its interface
func NewTransform(params Params) Transform { func NewTransform(params Params) Transform {
transform := new(transformData) transform := new(transformData)
transform.properties = map[string]any{} transform.properties = map[string]any{}

View File

@ -694,6 +694,8 @@ func GetAvoidBreak(view View, subviewID ...string) bool {
return boolStyledProperty(view, subviewID, AvoidBreak, true) 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 { func GetNotTranslate(view View, subviewID ...string) bool {
return boolStyledProperty(view, subviewID, NotTranslate, true) return boolStyledProperty(view, subviewID, NotTranslate, true)
} }

View File

@ -2,12 +2,13 @@ package rui
import "strings" import "strings"
// ParentView describe a view which can have a child views
type ParentView interface { type ParentView interface {
// Views return a list of child views // Views return a list of child views
Views() []View Views() []View
} }
// ViewsContainer - mutable list-container of Views // ViewsContainer represent a mutable list-container of views
type ViewsContainer interface { type ViewsContainer interface {
View View
ParentView ParentView