Skip to content

Commit

Permalink
Clean up formspec layout for vertical mode
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Feb 3, 2020
1 parent 39d1869 commit b09a817
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
27 changes: 22 additions & 5 deletions builtin/fstk/tabview_layouts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,40 +85,57 @@ tabview_layouts.vertical = {
mainbgcolor = "#0000008c",

get = function(self, view)
local tsize
if view.real_coordinates then
tsize = tab and tab.tabsize or { width = view.width, height = view.height }
else
tsize = tab and tab.tabsize or {
width = view.width * 5/4 + 2 * 0.375,
height = view.height * 15/13 + 2 * 0.375 + 0.2
}
end

local formspec = ""
local tab = view.tablist[view.last_tab_index]
if view.parent == nil then
local tsize = tab and tab.tabsize or {width=view.width, height=view.height}
formspec = formspec ..
string.format("formspec_version[3]size[%f,%f,%s]bgcolor[#00000000]",tsize.width+3,tsize.height,
dump(view.fixed_size))
end
formspec = formspec .. self:get_header(view)
formspec = formspec .. self:get_header(view, tsize)

if tab then
formspec = formspec .. "container[3,0]"

local mainbgcolor = view.mainbgcolor or self.mainbgcolor
formspec = formspec .. ("box[0,0;%f,%f;%s]"):format(view.width, view.height, mainbgcolor)
formspec = formspec .. ("box[0,0;%f,%f;%s]"):format(tsize.width, tsize.height, mainbgcolor)

if not view.real_coordinates then
formspec = formspec .. "formspec_version[1]real_coordinates[false]container[-0.525,0]"
end

formspec = formspec .. view.tablist[view.last_tab_index].get_formspec(
view,
view.tablist[view.last_tab_index].name,
view.tablist[view.last_tab_index].tabdata,
view.tablist[view.last_tab_index].tabsize)

if not view.real_coordinates then
formspec = formspec .. "container_end[]"
end

formspec = formspec .. "container_end[]"
end

return formspec
end,

get_header = function(self, view)
get_header = function(self, view, tsize)
local bgcolor = view.bgcolor or self.bgcolor
local selcolor = view.selcolor or self.selcolor
local mainbgcolor = view.mainbgcolor or self.mainbgcolor

local last_tab = view.tablist[view.last_tab_index]
local tsize = last_tab and last_tab.tabsize or {width=view.width, height=view.height}

local fs = {
("box[%f,%f;%f,%f;%s]"):format(0, 0, 3, tsize.height, mainbgcolor),
Expand Down
12 changes: 12 additions & 0 deletions builtin/mainmenu/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ local function init_globals()
end
end
ui.set_default("maintab")

tv_main:add({
name = "change_game",
caption = fgettext("Change Game"),
show = function(tabview, name, tabdata)
local change_game_dlg = change_game_dlg()
change_game_dlg:set_parent(tabdata)
tabdata:hide()
change_game_dlg:show()
end
})

tv_main:show()

ui.update()
Expand Down

0 comments on commit b09a817

Please sign in to comment.