Skip to content

Commit 7687adf

Browse files
docs(.List): document this and it's limitations
1 parent e2b2266 commit 7687adf

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

README.md

+53-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,59 @@ An experimental collection of extra widgets for [flow].
1818

1919
### Widgets
2020

21-
TODO
21+
#### Grid
22+
23+
> TODO:
24+
25+
#### List
26+
27+
```lua
28+
flow_extras.List{
29+
inventory_location = inventory_location,
30+
list_name = list_name,
31+
w = w,
32+
h = h,
33+
starting_item_index = starting_item_index,
34+
remainder = remainder ,
35+
remainder_v = remainder_v ,
36+
remainder_align = remainder_align,
37+
listring = listring,
38+
bgimg = bgimg,
39+
align_h = align_h,
40+
align_v = align_v,
41+
spacing = spacing
42+
}
43+
```
44+
45+
> TODO: link these
46+
47+
| Parameter | Type | Description |
48+
| :-------- | :--- | :---------- |
49+
| `inventory_location` | `string` | **Required**. [See minetest's documentation for `list[]`][list] for more information. |
50+
| `list_name` | `string` | **Required**. [See minetest's documentation for `list[]`][list] for more information. |
51+
| `w` | `number` | **Required**. Width of list in tiles. [See minetest's documentation for `list[]`][list] for more information. |
52+
| `h` | `number` | **Required**. Height of list in tiles. [See minetest's documentation for `list[]`][list] for more information. |
53+
| `starting_item_index` | `number` | **Optional**. (Default `0`) Zero-based offset index for this list. [See minetest's documentation for `list[]`][list] for more information. |
54+
| `remainder` | `number` | **Optional**. (Default `0`) If you'd like a row of list tiles that is less than one demention of the rest of the list, set this to a number > 0. |
55+
| `remainder_v` | `boolean` | **Optional**. (Default `false`) If `true`, the remainder will be below the rest of the [`list[]`][list]. Otherwise, it is to the right. |
56+
| `remainder_align` | `string` | **Optional**. Passed into `align_v` on a [`flow.widgets.VBox`][gui.VBox] if `remainder_v` or `align_h` on a [`flow.widgets.HBox`][gui.HBox] to align the remainder list. |
57+
| `listring` | `table` | **Optional**. A list of tables each passed to `flow.widgets.Listring`. Prepended with this `list[]`'s location and name, if provided. If not provided, [`listring[]`][listring]s are not generated. |
58+
| `bgimg` | `boolean` or `string` or `table` of `string`s | **Optional**. If present, applies each image in order, looping from left to right, top to bottom, on each list tile in the main list, followed by the remainder list, in the same pattern. By default, since `list[]` elements are opaque, you will not be able to see these images. Make use of [`flow.widgets.Listcolors`][listcolors] to adjust this as needed. If `bgimg` is `false`, then no `bgimg`s are rendered. If it is `nil`, it defaults to `{ "flow_extras_list_bg.png" }`. If it is a string, it is wrapped in a table. |
59+
| `align_h` | `string` | **Optional**. If there is a remainder or a listring, this is passed to the the [`flow.widgets.VBox`][gui.VBox] if `remainder_v` or [`flow.widgets.Hbox`][gui.HBox] that wraps the entire element. Otherwise, this element does not exist, and either a [`flow.widgets.Stack`][gui.Stack] or a [`flow.widgets.List`][List] is the root. |
60+
| `align_v` | `string` | **Optional**. If there is a remainder or a listring, this is passed to the the [`flow.widgets.VBox`][gui.VBox] if `remainder_v` or [`flow.widgets.Hbox`][gui.HBox] that wraps the entire element. Otherwise, this element does not exist, and either a [`flow.widgets.Stack`][gui.Stack] or a [`flow.widgets.List`][List] is the root. |
61+
| `spacing` | `number` | **Optional**. The amount of space between the list tiles. Defaults to `0.25` - the same amount as minetest out of the box. |
62+
63+
[list]: https://github.com/minetest/minetest/blob/master/doc/lua_api.md#listinventory-locationlist-namexywhstarting-item-index
64+
[listring]: https://github.com/minetest/minetest/blob/master/doc/lua_api.md#listringinventory-locationlist-name
65+
[gui.List]: https://gitlab.com/luk3yx/minetest-flow/-/blob/main/elements.md?ref_type=heads#guilist
66+
[gui.HBox]: https://gitlab.com/luk3yx/minetest-flow#guihbox
67+
[gui.VBox]: https://gitlab.com/luk3yx/minetest-flow#guivbox
68+
[gui.Stack]: https://gitlab.com/luk3yx/minetest-flow#guistack
69+
[listcolors]: https://github.com/minetest/minetest/blob/master/doc/lua_api.md#listcolorsslot_bg_normalslot_bg_hover
70+
71+
### Tools
72+
73+
> TODO:
2274
2375
### Textures
2476

widgets/list.lua

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ function flow_extras.List(fields)
5252
local remainder_v = fields.remainder_v
5353
local remainder_align = fields.remainder_align
5454
local listring = fields.listring or {}
55+
-- Only works when paired with gui.Listcolors{} is set to something (at least somewhat) transparent.
56+
-- https://github.com/minetest/minetest/blob/master/doc/lua_api.md#listcolorsslot_bg_normalslot_bg_hover
5557
local bgimg = fields.bgimg
5658
local align_h = fields.align_h
5759
local align_v = fields.align_v

0 commit comments

Comments
 (0)