Layout system

Yue uses Facebook Yoga as layout engine, which provides Flexbox style layout system.

Yue does not support CSS itself, it only uses the concept of Flexbox for layout, and you have to manually set style for each View.

view:setstyle{flexDirection='column', flex=1}

It should be noted that not all CSS properties are supported, and there is no plan for support of tables, floats, or similar CSS concepts.

View and Container

In Yue all widgets are inherited from the virtual class View, which represents a leaf node in the layout system. The Container is a View that can have multiple child Views, in the layout system the child Views of Container are treated as child nodes.

There are Views that can have content view like Group or Scroll, but their content views are treated as root nodes in layout system, instead of being child nodes of their parents.

Following code is an example of list view.

local listview = gui.Scroll.create()
local contentview = gui.Container.create()
contentview:setstyle{flexdirection='column'}

for i = 1, 100 do
  local item = gui.Label.create(i)
  local g = math.floor(155 / 100 * i + 100)
  item:setbackgroundcolor(gui.Color.rgb(100, g, 100))
  contentview:addchildview(item)
end

listview:setcontentsize(contentview:getpreferredsize())
listview:setcontentview(contentview)

Style properties

For a complete list of supported style properties, it is recommended to read the documentation of Yoga.