~akkartik/carousel.love

84b9169337d04a348b4712d9ec8bc1eae98cdbe2 — Kartik K. Agaram 3 months ago 56268f0
extract functions for computing editor dimensions

Thanks Ryan for the suggestion.
4 files changed, 11 insertions(+), 5 deletions(-)

M 0031-on.resize
M 0070-code_editor_state
A 0169-editor_right_margin
A 0171-code_editor_bottom_margin
M 0031-on.resize => 0031-on.resize +2 -2
@@ 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

M 0070-code_editor_state => 0070-code_editor_state +3 -3
@@ 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
\ No newline at end of file

A 0169-editor_right_margin => 0169-editor_right_margin +3 -0
@@ 0,0 1,3 @@
editor_right_margin = function()
	return math.min(100+30*Font:getWidth('m'), Safe_width*2/3)
end
\ No newline at end of file

A 0171-code_editor_bottom_margin => 0171-code_editor_bottom_margin +3 -0
@@ 0,0 1,3 @@
code_editor_bottom_margin = function()
	return Safe_height/2-Line_height
end
\ No newline at end of file