Skip to content

Commit d138069

Browse files
committed
Allow layout items to be sized with width/height (temporary implementation?)
1 parent f5530d9 commit d138069

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

changelog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
v0.1.3:
2+
- Fix element not found error
3+
- Remove unit testing files from release
4+
- Implemented universal selector *
5+
16
v0.1.2:
27
- Entire area of buttons is now clickable, including the padding
38
- Slider can now be bound to values on subtables (one.two.three)

elements/Layout.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ function Layout:_GetInnerAndOuterDimensions(gui, data_context)
6161
local child_width, child_height = child:GetDimensions(gui, data_context)
6262
local child_total_width = child_width + child.style.margin_left + child.style.margin_right
6363
local child_total_height = child_height + child.style.margin_top + child.style.margin_bottom
64+
child_total_width = math.max(child_total_width, child.style.width or 0)
65+
child_total_height = math.max(child_total_height, child.style.height or 0)
6466
if self.style.direction == "horizontal" then
6567
inner_width = inner_width + child_total_width
6668
inner_height = math.max(inner_height, child_total_height)
@@ -130,6 +132,8 @@ function Layout:Render(gui, new_id, data_context, layout)
130132
local child_width, child_height = child:GetDimensions(gui, data_context)
131133
local child_total_width = child_width + child.style.margin_left + child.style.margin_right
132134
local child_total_height = child_height + child.style.margin_top + child.style.margin_bottom
135+
child_total_width = math.max(child_total_width, child.style.width or 0)
136+
child_total_height = math.max(child_total_height, child.style.height or 0)
133137
if self.attr.debug then
134138
-- Content
135139
local x, y = self:GetPositionForWidget(child, child_width, child_height)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ezgui",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "You make an XML file that contains your GUI definition, just like single file components in Vue.js.\r A root Layout element is mandatory.\r ```xml\r <Layout>\r <Button @click=\"a_method('with a string arg')\">Click me!</Button>\r <Text forEach=\"element in collection\">{{ element }}</Text>\r </Layout>\r <Style>\r Layout {\r direction: vertical;\r padding: 2;\r }\r Layout > Button {\r margin: [button_margin]; // Can also databind to CSS properties!\r }\r </Style>\r ```\r Then in your init.lua you can render this GUI:\r ```lua\r -- Dofiling EZGUI.lua returns a table with an init function that you need to call and pass in the path to the library, which in turn will return a render function you can call to render a GUI\r local render_gui = dofile_once(\"mods/your_mod_id/lib/EZGUI/EZGUI.lua\").init(\"mods/your_mod_id/lib/EZGUI\")\r -- This is the data context table, here lives your data that you can bind to\r local data = {\r collection = { \"Bloo\", \"Blaa\", \"Blee\" },\r button_margin = 5,\r -- Methods defined here can be used in @click, arg1 is the data_context itself, arg2 the element that was clicked, arg3 the first custom arg\r a_method = function(data, element, arg1)\r print(arg1)\r end,\r }",
55
"main": "build.js",
66
"directories": {

0 commit comments

Comments
 (0)