mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-01 17:38:41 +00:00
Improve formspec scaling (#14840)
This commit is contained in:
parent
1527cdf6a4
commit
041d67ceca
11 changed files with 176 additions and 87 deletions
|
@ -66,11 +66,22 @@ local function get_formspec(self)
|
|||
|
||||
local content, prepend = tab.get_formspec(self, tab.name, tab.tabdata, tab.tabsize)
|
||||
|
||||
local tsize = tab.tabsize or { width = self.width, height = self.height }
|
||||
local ENABLE_TOUCH = core.settings:get_bool("enable_touch")
|
||||
|
||||
local orig_tsize = tab.tabsize or { width = self.width, height = self.height }
|
||||
local tsize = { width = orig_tsize.width, height = orig_tsize.height }
|
||||
tsize.height = tsize.height
|
||||
+ TABHEADER_H -- tabheader included in formspec size
|
||||
+ (ENABLE_TOUCH and GAMEBAR_OFFSET_TOUCH or GAMEBAR_OFFSET_DESKTOP)
|
||||
+ GAMEBAR_H -- gamebar included in formspec size
|
||||
|
||||
if self.parent == nil and not prepend then
|
||||
prepend = string.format("size[%f,%f,%s]", tsize.width, tsize.height,
|
||||
dump(self.fixed_size))
|
||||
|
||||
local anchor_pos = TABHEADER_H + orig_tsize.height / 2
|
||||
prepend = prepend .. ("anchor[0.5,%f]"):format(anchor_pos / tsize.height)
|
||||
|
||||
if tab.formspec_version then
|
||||
prepend = ("formspec_version[%d]"):format(tab.formspec_version) .. prepend
|
||||
end
|
||||
|
@ -78,12 +89,15 @@ local function get_formspec(self)
|
|||
|
||||
local end_button_size = 0.75
|
||||
|
||||
local tab_header_size = { width = tsize.width, height = 0.85 }
|
||||
local tab_header_size = { width = tsize.width, height = TABHEADER_H }
|
||||
if self.end_button then
|
||||
tab_header_size.width = tab_header_size.width - end_button_size - 0.1
|
||||
end
|
||||
|
||||
local formspec = (prepend or "") .. self:tab_header(tab_header_size) .. content
|
||||
local formspec = (prepend or "")
|
||||
formspec = formspec .. ("bgcolor[;neither]container[0,%f]box[0,0;%f,%f;#0000008C]"):format(
|
||||
TABHEADER_H, orig_tsize.width, orig_tsize.height)
|
||||
formspec = formspec .. self:tab_header(tab_header_size) .. content
|
||||
|
||||
if self.end_button then
|
||||
formspec = formspec ..
|
||||
|
@ -98,6 +112,8 @@ local function get_formspec(self)
|
|||
self.end_button.name)
|
||||
end
|
||||
|
||||
formspec = formspec .. "container_end[]"
|
||||
|
||||
return formspec
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue