extract functions for computing editor dimensions
Thanks Ryan for the suggestion.
This commit is contained in:
parent
56268f09a4
commit
84b9169337
|
@ -1,12 +1,12 @@
|
|||
on.resize = function(w, h)
|
||||
_, _, Safe_width, Safe_height = love.window.getSafeArea()
|
||||
for _,pane in ipairs(Panes) do
|
||||
pane.editor_state.right = math.min(100+30*pane.editor_state.font:getWidth('m'), Safe_width*2/3)
|
||||
pane.editor_state.right = editor_right_margin()
|
||||
if pane.editor_state.right < pane.editor_state.left then
|
||||
pane.editor_state.right = pane.editor_state.left+1
|
||||
end
|
||||
pane.editor_state.width = pane.editor_state.right - pane.editor_state.left
|
||||
pane.editor_state.bottom = Safe_height/2-Line_height
|
||||
pane.editor_state.bottom = code_editor_bottom_margin()
|
||||
Text.redraw_all(pane.editor_state)
|
||||
update_output_editor(pane)
|
||||
end
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
code_editor_state = function()
|
||||
local result = edit.initialize_state(
|
||||
Menu_bottom + 20, -- top
|
||||
Safe_height/2-Line_height, -- bottom
|
||||
code_editor_bottom_margin(),
|
||||
Menu_left + 50 + Line_number_padding, -- left
|
||||
math.min(100+30*Font:getWidth('m'), Safe_width*2/3), -- right
|
||||
editor_right_margin(),
|
||||
Font, Font_height, Line_height)
|
||||
Text.redraw_all(result)
|
||||
return result
|
||||
end
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
editor_right_margin = function()
|
||||
return math.min(100+30*Font:getWidth('m'), Safe_width*2/3)
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
code_editor_bottom_margin = function()
|
||||
return Safe_height/2-Line_height
|
||||
end
|
Loading…
Reference in New Issue