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"
// AbsoluteLayout - list-container of View
// AbsoluteLayout represent an AbsoluteLayout view where child views can be arbitrary positioned
type AbsoluteLayout interface {
ViewsContainer
}

View File

@ -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 of the angle value
Type AngleUnitType
// Value of the angle in Type units
Value float64
}

View File

@ -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()

View File

@ -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,

View File

@ -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

View File

@ -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)
}

View File

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

View File

@ -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
}

View File

@ -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 {

View File

@ -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 {

View File

@ -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
}

View File

@ -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
}

View File

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

View File

@ -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

View File

@ -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()
}

View File

@ -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
}

View File

@ -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 of a color
Name string
// Color value
Color Color
}

View File

@ -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 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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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)

39
data.go
View File

@ -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: <tag> = <text>
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
}

View File

@ -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 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
}

View File

@ -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
}

View File

@ -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

View File

@ -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)
}

View File

@ -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.

View File

@ -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.

View File

@ -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

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...).
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

View File

@ -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

View File

@ -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.

View File

@ -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 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 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.

View File

@ -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,

View File

@ -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

View File

@ -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 of the source
Url string
// MimeType of the source
MimeType string
}

View File

@ -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.

View File

@ -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
}

View File

@ -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
}

View File

@ -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 {

View File

@ -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

View File

@ -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 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

View File

@ -5,12 +5,18 @@ import (
"strings"
)
// Constants for [ProgressBar] specific properties and events
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"
// 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
}

View File

@ -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"
)

View File

@ -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

View File

@ -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
}

View File

@ -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

View File

@ -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()

View File

@ -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
}

View File

@ -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)
}

View File

@ -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"

View File

@ -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 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
}

View File

@ -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

View File

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

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

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

View File

@ -7,17 +7,33 @@ import (
"strings"
)
// Constants used as a values for [MediaStyleParams] member Orientation
const (
// 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 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
}
@ -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()

View File

@ -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 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
}

View File

@ -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.

View File

@ -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 {

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -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{}

View File

@ -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)
}

View File

@ -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