NagView: properly rescale on scale change (#1379)
* drop font option since style.font is always used
This commit is contained in:
parent
e800a5de3c
commit
d784133777
|
@ -44,8 +44,8 @@ local function save(filename)
|
|||
else
|
||||
core.error(err)
|
||||
core.nag_view:show("Saving failed", string.format("Could not save \"%s\" do you want to save to another location?", doc().filename), {
|
||||
{ font = style.font, text = "No", default_no = true },
|
||||
{ font = style.font, text = "Yes" , default_yes = true }
|
||||
{ text = "No", default_no = true },
|
||||
{ text = "Yes", default_yes = true }
|
||||
}, function(item)
|
||||
if item.text == "Yes" then
|
||||
core.add_thread(function()
|
||||
|
|
|
@ -820,8 +820,8 @@ function core.init()
|
|||
|
||||
if #plugins_refuse_list.userdir.plugins > 0 or #plugins_refuse_list.datadir.plugins > 0 then
|
||||
local opt = {
|
||||
{ font = style.font, text = "Exit", default_no = true },
|
||||
{ font = style.font, text = "Continue" , default_yes = true }
|
||||
{ text = "Exit", default_no = true },
|
||||
{ text = "Continue", default_yes = true }
|
||||
}
|
||||
local msg = {}
|
||||
for _, entry in pairs(plugins_refuse_list) do
|
||||
|
@ -866,8 +866,8 @@ function core.confirm_close_docs(docs, close_fn, ...)
|
|||
end
|
||||
local args = {...}
|
||||
local opt = {
|
||||
{ font = style.font, text = "Yes", default_yes = true },
|
||||
{ font = style.font, text = "No" , default_no = true }
|
||||
{ text = "Yes", default_yes = true },
|
||||
{ text = "No", default_no = true }
|
||||
}
|
||||
core.nag_view:show("Unsaved Changes", text, opt, function(item)
|
||||
if item.text == "Yes" then close_fn(table.unpack(args)) end
|
||||
|
|
|
@ -91,7 +91,7 @@ function NagView:each_option()
|
|||
|
||||
for i = #self.options, 1, -1 do
|
||||
opt = self.options[i]
|
||||
bw = opt.font:get_width(opt.text) + 2 * BORDER_WIDTH + style.padding.x
|
||||
bw = style.font:get_width(opt.text) + 2 * BORDER_WIDTH + style.padding.x
|
||||
|
||||
ox = ox - bw - style.padding.x
|
||||
coroutine.yield(i, opt, ox,oy,bw,bh)
|
||||
|
@ -230,7 +230,7 @@ local function draw_nagview_message(self)
|
|||
renderer.draw_rect(lx,ly,uw,UNDERLINE_WIDTH, style.nagbar_text)
|
||||
end
|
||||
|
||||
common.draw_text(opt.font, style.nagbar_text, opt.text, "center", fx,fy,fw,fh)
|
||||
common.draw_text(style.font, style.nagbar_text, opt.text, "center", fx,fy,fw,fh)
|
||||
end
|
||||
|
||||
self:draw_scrollbar()
|
||||
|
@ -245,6 +245,16 @@ function NagView:draw()
|
|||
core.root_view:defer_draw(draw_nagview_message, self)
|
||||
end
|
||||
|
||||
function NagView:on_scale_change(new_scale, old_scale)
|
||||
BORDER_WIDTH = common.round(1 * new_scale)
|
||||
UNDERLINE_WIDTH = common.round(2 * new_scale)
|
||||
UNDERLINE_MARGIN = common.round(1 * new_scale)
|
||||
self.target_height = math.max(
|
||||
self:get_message_height(),
|
||||
self:get_buttons_height()
|
||||
)
|
||||
end
|
||||
|
||||
function NagView:get_message_height()
|
||||
local h = 0
|
||||
for str in string.gmatch(self.message, "(.-)\n") do
|
||||
|
|
|
@ -46,8 +46,8 @@ end
|
|||
local function check_prompt_reload(doc)
|
||||
if doc and doc.deferred_reload then
|
||||
core.nag_view:show("File Changed", doc.filename .. " has changed. Reload this file?", {
|
||||
{ font = style.font, text = "Yes", default_yes = true },
|
||||
{ font = style.font, text = "No" , default_no = true }
|
||||
{ text = "Yes", default_yes = true },
|
||||
{ text = "No", default_no = true }
|
||||
}, function(item)
|
||||
if item.text == "Yes" then reload_doc(doc) end
|
||||
doc.deferred_reload = false
|
||||
|
|
|
@ -709,8 +709,8 @@ command.add(
|
|||
local file_type = file_info.type == "dir" and "Directory" or "File"
|
||||
-- Ask before deleting
|
||||
local opt = {
|
||||
{ font = style.font, text = "Yes", default_yes = true },
|
||||
{ font = style.font, text = "No" , default_no = true }
|
||||
{ text = "Yes", default_yes = true },
|
||||
{ text = "No", default_no = true }
|
||||
}
|
||||
core.nag_view:show(
|
||||
string.format("Delete %s", file_type),
|
||||
|
|
Loading…
Reference in New Issue