add read-only UI contentOffset property

This commit is contained in:
MihailRis
2024-10-15 05:56:15 +03:00
parent fbca439b2d
commit 08ebfa15db
7 changed files with 86 additions and 79 deletions
+60 -59
View File
@@ -19,7 +19,7 @@ The element id cannot be changed from a script.
The following tables will use abbreviated type descriptions, such as:
- vec2 - an array of two numbers.
- ivec2 - an array of two integers.
- rgba - an array of four integers in the range *\[0..255\]* denoting RGBA constituent colors.
- rgba - an array of four integers in the range `[0..255]` denoting RGBA constituent colors.
Element methods, according to OOP features in Lua, are called using the `:` operator instead of `.`
@@ -32,28 +32,29 @@ document["worlds-panel"]:clear()
Properties that apply to all elements:
| Title | Type | Reading | Record | Description |
| ------------ | ------ | ------- | ------ | ------------------------------------------- |
| id | string | yes | *no* | element id |
| pos | vec2 | yes | yes | element position inside a container |
| wpos | vec2 | yes | yes | element position inside the window |
| size | vec2 | yes | yes | element size |
| interactive | bool | yes | yes | ability to interact with the element |
| enabled | bool | yes | yes | visually indicated version of *interactive* |
| visible | bool | yes | yes | element visibility |
| focused | bool | yes | yes | focus on element |
| color | rgba | yes | yes | element color |
| hoverColor | rgba | yes | yes | hover color |
| pressedColor | rgba | yes | yes | color when pressed |
| tooltip | string | yes | yes | tooltip text |
| tooltipDelay | float | yes | yes | tooltip delay |
| Title | Type | Read | Write | Description |
| ------------- | ------ | ---- | ----- | ------------------------------------------- |
| id | string | yes | *no* | element id |
| pos | vec2 | yes | yes | element position inside a container |
| wpos | vec2 | yes | yes | element position inside the window |
| size | vec2 | yes | yes | element size |
| interactive | bool | yes | yes | ability to interact with the element |
| enabled | bool | yes | yes | visually indicated version of *interactive* |
| visible | bool | yes | yes | element visibility |
| focused | bool | yes | yes | focus on element |
| color | rgba | yes | yes | element color |
| hoverColor | rgba | yes | yes | hover color |
| pressedColor | rgba | yes | yes | color when pressed |
| tooltip | string | yes | yes | tooltip text |
| tooltipDelay | float | yes | yes | tooltip delay |
| contentOffset | vec2 | yes | *no* | element content offset |
Common element methods:
| Method | Description |
| ------------------- | ----------------------------------------------------------------------- |
| Method | Description |
| ------------------- | ----------------------------------------------------------------------------------- |
| moveInto(container) | moves the element to the specified container (the element is specified, not the id) |
| destruct() | removes element |
| destruct() | removes element |
## Containers
@@ -69,86 +70,86 @@ Common methods for containers (elements: container, panel, button, pagebox):
Properties:
| Title | Type | Reading | Record | Description |
| ----------- | ------ | ------- | ------ | ------------------------------------------------------------------------------------ |
| text | string | yes | yes | entered text or placeholder |
| placeholder | string | yes | yes | placeholder (used if nothing has been entered) |
| caret | int | yes | yes | carriage position. `textbox.caret = -1` will set the position to the end of the text |
| editable | bool | yes | yes | text mutability |
| multiline | bool | yes | yes | multiline support |
| textWrap | bool | yes | yes | automatic text wrapping (only with multiline: "true") |
| valid | bool | yes | no | is the entered text correct |
| Title | Type | Read | Write | Description |
| ----------- | ------ | ---- | ----- | ------------------------------------------------------------------------------------ |
| text | string | yes | yes | entered text or placeholder |
| placeholder | string | yes | yes | placeholder (used if nothing has been entered) |
| caret | int | yes | yes | carriage position. `textbox.caret = -1` will set the position to the end of the text |
| editable | bool | yes | yes | text mutability |
| multiline | bool | yes | yes | multiline support |
| textWrap | bool | yes | yes | automatic text wrapping (only with multiline: "true") |
| valid | bool | yes | no | is the entered text correct |
Methods:
| Method | Description |
| ----------- | -------------------------------------------- |
| Method | Description |
| ----------- | ------------------------------------------------ |
| paste(text) | inserts the specified text at the caret position |
## Slider (trackbar)
Properties:
| Title | Type | Reading | Record | Description |
| ---------- | ----- | ------- | ------ | --------------------- |
| value | float | yes | yes | current value |
| min | float | yes | yes | minimum value |
| max | float | yes | yes | maximum value |
| step | float | yes | yes | division step |
| trackWidth | float | yes | yes | control element width |
| trackColor | rgba | yes | yes | control element color |
| Title | Type | Read | Write | Description |
| ---------- | ----- | ---- | ----- | --------------------- |
| value | float | yes | yes | current value |
| min | float | yes | yes | minimum value |
| max | float | yes | yes | maximum value |
| step | float | yes | yes | division step |
| trackWidth | float | yes | yes | control element width |
| trackColor | rgba | yes | yes | control element color |
## Menu (pagebox)
Properties:
| Title | Type | Reading | Record | Description |
| -------- | ------ | ------ | ------ | ---------------- |
| page | string | yes | yes | current page |
| Title | Type | Read | Write | Description |
| ----- | ------ | ---- | ----- | ------------ |
| page | string | yes | yes | current page |
Methods:
| Method | Description |
| ------- | ------------------------------------------ |
| back() | switches to previous page |
| Method | Description |
| ------- | --------------------------------- |
| back() | switches to previous page |
| reset() | resets page and switching history |
## Checkbox
Properties:
| Title | Type | Reading | Record | Description |
| -------- | ---- | ------ | ------ | ----------------- |
| checked | bool | yes | yes | mark status |
| Title | Type | Read | Write | Description |
| ------- | ---- | ---- | ----- | ----------- |
| checked | bool | yes | yes | mark status |
## Button
Properties:
| Title | Type | Reading | Record | Description |
| -------- | ------ | ------ | ------ | ------------ |
| text | string | yes | yes | button text |
| Title | Type | Read | Write | Description |
| ----- | ------ | ---- | ----- | ------------ |
| text | string | yes | yes | button text |
## Label
Properties:
| Title | Type | Reading | Record | Description |
| -------- | ------ | ------ | ------ | ----------- |
| text | string | yes | yes | label text |
| Title | Type | Read | Write | Description |
| ----- | ------ | ---- | ----- | ----------- |
| text | string | yes | yes | label text |
## Image
Properties:
| Title | Type | Reading | Record | Description |
| ----- | ------ | ------- | ------ | ------------ |
| src | string | yes | yes | texture name |
| Title | Type | Read | Write | Description |
| ----- | ------ | ---- | ----- | ------------ |
| src | string | yes | yes | texture name |
## Inventory
Properties:
| Title | Type | Reading | Record | Description |
| --------- | ---- | ------- | ------ | ------------------------------------------------- |
| inventory | int | yes | yes | id of the inventory to which the element is bound |
| Title | Type | Read | Write | Description |
| --------- | ---- | ---- | ----- | ------------------------------------------------- |
| inventory | int | yes | yes | id of the inventory to which the element is bound |