Not sure what you meant by "sometimes they don't" maybe you could share a minimal example that does that?
Basically the following code generates the following view. Some of the Text Labels dont show (probably drawn over) and its like the Labels are positioning evenly across the bar. The list view does not stop, I commented out the limiting code in panel for screen shot.
Code:
function ItemSideBar:init(info)
self.panel_width = 50
self:addviews{
widgets.Label{
text = {
self.prompt, '\n\n',
'Category: ', { text = self:cb_getfield('context_str'), pen = COLOR_CYAN }
},
text_pen = COLOR_WHITE,
frame = { l = 0, t = 0 },
},
widgets.Label{
view_id = 'back',
visible = false,
text = { { key = 'LEAVESCREEN', text = ': Back' } },
frame = { r = 0, b = 0 },
auto_width = true,
},
widgets.Panel{
-- on_layout = function(body)
-- body.height = math.max(1, math.ceil(body.height / 2))
-- body.y2 = body.y1 + body.height
-- end,
subviews = {
ItemList{
view_id = 'list',
not_found_label = 'No matching items',
frame = { l = 0, r = 0, t = 4, b = 2 },
icon_width = 2,
on_submit = self:callback('onSubmitItem'),
text_pen = COLOR_GREY,
text_dpen = COLOR_DARKGREY,
cursor_pen = COLOR_LIGHTCYAN
},
}
},
HorizontalBar{ frame = {}, },
widgets.Label{
view_id = 'info',
text = { {
text = 'Testing:'
} },
frame = { l = 0, r = 0, t = 1, b = 1 },
},
widgets.Label{
text = { {
key = 'SELECT', text = ': Select',
disabled = function() return false end
} },
frame = { l = 0, b = 0 },
},
}
self:initBuiltinMode()
end
Image:
Also imho you could do "the Qt way" i.e. containers that manage the layout. E.g. you could make a grid layout, where you can say which columns and rows are fixed and which grow.
Yes, I plan to adopt some old code. I cannot find the article its based on right now. Anyway, easier to port than to develop from scratch and the concepts are solid. Basically its like most layout engines where you have fixed, percent, tofit, rest. I can take advantage and draw the separators with correct characters presumably.
I'm confused between the frame_rect and body_rect in the widgets. Is frame supposed to be relative to screen and body relative to frame?
The only other issue I keep having with this is lua class inheritance via the defclass is wonky. It seems like super should be the base class of the parent and allow calling base methods but doesn't seem to work for me consistently. There is a lot of code that seems to work though. Not sure if its because its in a different lua file or something.
Edit: After reviewing documentation again I think it does explain parts that confused me previously with regard to alignment. So before I embark on a code journey I'll see if inheriting from Widget for my HorizontalBar and using the frame attr correctly will help me.