aboutsummaryrefslogtreecommitdiff
path: root/builtin/fstk/tabview.lua
diff options
context:
space:
mode:
authorMinetest-j45 <55553015+Minetest-j45@users.noreply.github.com>2021-08-30 15:22:40 +0100
committerGitHub <noreply@github.com>2021-08-30 15:22:40 +0100
commit7824a4956bf489b4e2cc35e0c97272eee06be6ba (patch)
tree70243765dc1743a83596f9c6eec122fb417ef92c /builtin/fstk/tabview.lua
parent607add326feb44e078b843464ce4a8de09f28743 (diff)
parent35445d24f425c6291a0580b468919ca83de716fd (diff)
downloaddragonfireclient-7824a4956bf489b4e2cc35e0c97272eee06be6ba.tar.xz
Merge pull request #1 from EliasFleckenstein03/master
update
Diffstat (limited to 'builtin/fstk/tabview.lua')
-rw-r--r--builtin/fstk/tabview.lua50
1 files changed, 17 insertions, 33 deletions
diff --git a/builtin/fstk/tabview.lua b/builtin/fstk/tabview.lua
index 3715e231b..424d329fb 100644
--- a/builtin/fstk/tabview.lua
+++ b/builtin/fstk/tabview.lua
@@ -58,26 +58,20 @@ end
--------------------------------------------------------------------------------
local function get_formspec(self)
- local formspec = ""
+ if self.hidden or (self.parent ~= nil and self.parent.hidden) then
+ return ""
+ end
+ local tab = self.tablist[self.last_tab_index]
- if not self.hidden and (self.parent == nil or not self.parent.hidden) then
+ local content, prepend = tab.get_formspec(self, tab.name, tab.tabdata, tab.tabsize)
- if self.parent == nil then
- local tsize = self.tablist[self.last_tab_index].tabsize or
- {width=self.width, height=self.height}
- formspec = formspec ..
- string.format("size[%f,%f,%s]",tsize.width,tsize.height,
- dump(self.fixed_size))
- end
- formspec = formspec .. self:tab_header()
- formspec = formspec ..
- self.tablist[self.last_tab_index].get_formspec(
- self,
- self.tablist[self.last_tab_index].name,
- self.tablist[self.last_tab_index].tabdata,
- self.tablist[self.last_tab_index].tabsize
- )
+ if self.parent == nil and not prepend then
+ local tsize = tab.tabsize or {width=self.width, height=self.height}
+ prepend = string.format("size[%f,%f,%s]", tsize.width, tsize.height,
+ dump(self.fixed_size))
end
+
+ local formspec = (prepend or "") .. self:tab_header() .. content
return formspec
end
@@ -97,14 +91,9 @@ local function handle_buttons(self,fields)
return true
end
- if self.tablist[self.last_tab_index].button_handler ~= nil then
- return
- self.tablist[self.last_tab_index].button_handler(
- self,
- fields,
- self.tablist[self.last_tab_index].name,
- self.tablist[self.last_tab_index].tabdata
- )
+ local tab = self.tablist[self.last_tab_index]
+ if tab.button_handler ~= nil then
+ return tab.button_handler(self, fields, tab.name, tab.tabdata)
end
return false
@@ -122,14 +111,9 @@ local function handle_events(self,event)
return true
end
- if self.tablist[self.last_tab_index].evt_handler ~= nil then
- return
- self.tablist[self.last_tab_index].evt_handler(
- self,
- event,
- self.tablist[self.last_tab_index].name,
- self.tablist[self.last_tab_index].tabdata
- )
+ local tab = self.tablist[self.last_tab_index]
+ if tab.evt_handler ~= nil then
+ return tab.evt_handler(self, event, tab.name, tab.tabdata)
end
return false