testing file sources.

This commit is contained in:
David Lannan 2024-11-08 00:47:48 +10:30
parent fb6659908c
commit cef1333bd5
2 changed files with 52 additions and 5 deletions

View File

@ -122,6 +122,7 @@ local function cleanup()
end
-- --------------------------------------------------------------------------------------
local current_ctx = nil
local function input(event)
if(event.type == sapp.SAPP_EVENTTYPE_RESIZED) then
@ -137,7 +138,6 @@ local function input(event)
end
end
-- --------------------------------------------------------------------------------------
-- Extract config and build ffi objects for them
-- Each config property shall have a shadow ffi property labeled with _ffi
@ -245,8 +245,39 @@ local function project_panel(ctx)
end
-- --------------------------------------------------------------------------------------
local curr_tab = 1
local tabs = { { name = "Lua Source" }, { name = "Images" }, { name = "Data" } }
local curr_tab = 1
local files = {}
-- Fill with temp file list of dir /b
local fh = io.popen("dir /b", "r")
local d = fh:read("*a")
fh:close()
for f in string.gmatch(d, "(.-)\n") do
local newfile = { name = ffi.string(f)}
newfile.select = ffi.new("nk_bool[1]")
newfile.select[0] = nk.nk_false
table.insert(files, newfile)
end
local tabs = {
{
name = "Lua Source",
func = function(ctx)
local bounds = nk.nk_window_get_content_region(ctx)
nk.nk_layout_row_dynamic(ctx, bounds.h, 1)
wdgts.widget_list_selectable(ctx, "source_files", nk.NK_WINDOW_BORDER, files, bounds.w -40 )
end,
},
{
name = "Images"
},
{
name = "Data"
}
}
-- --------------------------------------------------------------------------------------
local function assets_panel(ctx)
@ -332,7 +363,7 @@ app_desc[0].cleanup_cb = cleanup
app_desc[0].event_cb = input
app_desc[0].width = 1280
app_desc[0].height = 800
app_desc[0].window_title = config.title
app_desc[0].window_title = config.rbuilder.title.value
app_desc[0].icon.sokol_default = true
app_desc[0].logger.func = slib.slog_func
app_desc[0].enable_clipboard = true

View File

@ -179,7 +179,7 @@ widgets.widget_notebook = function(ctx, tab_name, tabs, current_tab, height, tab
ctx[0].style.window.spacing = nk.nk_vec2(0,0)
local rounding = ctx[0].style.button.rounding
ctx[0].style.button.rounding = 0
nk.nk_layout_row_begin(ctx, nk.NK_STATIC, 20, 3)
nk.nk_layout_row_begin(ctx, nk.NK_STATIC, 24, 3)
for i, v in ipairs(tabs) do
-- /* make sure button perfectly fits text */
local f = ctx[0].style.font
@ -234,6 +234,22 @@ widgets.widget_combo_box = function(ctx, items, selected_item, height)
return selected_item
end
--------------------------------------------------------------------------------
widgets.widget_list_selectable = function(ctx, title, flags, items, width)
if (nk.nk_group_begin(ctx, title, flags) == true) then
for i, item in ipairs(items) do
nk.nk_layout_row_static(ctx, 22, width, 1)
if(nk.nk_selectable_label(ctx, item.name, nk.NK_TEXT_LEFT, item.select) == true) then
-- changed
print("changed:"..i)
end
end
nk.nk_group_end(ctx)
end
end
--------------------------------------------------------------------------------
-- returns struct nk_image