implement carousel buttons for inserting/switching current pane
This commit is contained in:
parent
e38191fc4f
commit
5a998feca7
|
@ -5,17 +5,7 @@ on.initialize = function()
|
|||
Menu_left, Menu_top, Safe_width, Safe_height = love.window.getSafeArea()
|
||||
Menu_height = 5 + Line_height + 5
|
||||
Menu_bottom = Menu_top + Menu_height
|
||||
Current_pane.editor_state = edit.initialize_state(
|
||||
Menu_bottom + 20, -- top
|
||||
Safe_height/2-Line_height, -- bottom
|
||||
Menu_left + 50 + Line_number_padding, -- left
|
||||
math.min(100+30*App.width('m'), Safe_width*2/3), -- right
|
||||
love.graphics.getFont():getHeight(), Line_height)
|
||||
Text.redraw_all(Current_pane.editor_state)
|
||||
Current_pane.output_editor_state = edit.initialize_state(
|
||||
Current_pane.editor_state.bottom+5+10+5, -- top
|
||||
nil, -- buttom
|
||||
Current_pane.editor_state.left, Current_pane.editor_state.right,
|
||||
love.graphics.getFont():getHeight(), Line_height)
|
||||
Text.redraw_all(Current_pane.output_editor_state)
|
||||
table.insert(Panes, new_pane())
|
||||
Current_pane_index = 1
|
||||
Current_pane = Panes[Current_pane_index]
|
||||
end
|
|
@ -42,17 +42,41 @@ draw_menu = function()
|
|||
end,
|
||||
})
|
||||
-- nav buttons along sides
|
||||
button(Global_state, 'left', {x=0, y=Menu_bottom, w=Menu_left+30, h=App.screen.height, bg={r=0.5, g=0.5, b=0.5, a=0.2},
|
||||
icon = function(p)
|
||||
App.color{r=0.4,g=0.4,b=0.4}
|
||||
love.graphics.polygon('fill', Menu_left+5, App.screen.height/2, Menu_left+25, App.screen.height/2-10, Menu_left+25, App.screen.height/2+10)
|
||||
end,
|
||||
})
|
||||
if Current_pane_index > 1 then
|
||||
button(Global_state, 'left', {x=0, y=Menu_bottom, w=Menu_left+30, h=App.screen.height, bg={r=0.5, g=0.5, b=0.5, a=0.2},
|
||||
icon = function(p)
|
||||
App.color{r=0.4,g=0.4,b=0.4}
|
||||
love.graphics.polygon('fill', Menu_left+5, App.screen.height/2, Menu_left+25, App.screen.height/2-10, Menu_left+25, App.screen.height/2+10)
|
||||
end,
|
||||
onpress1 = function()
|
||||
Current_pane_index = Current_pane_index-1
|
||||
Current_pane = Panes[Current_pane_index]
|
||||
end,
|
||||
})
|
||||
end
|
||||
local r = Menu_left + Safe_width
|
||||
button(Global_state, 'left', {x=r-30, y=Menu_bottom, w=100, h=App.screen.height, bg={r=0.5, g=0.5, b=0.5, a=0.2},
|
||||
icon = function(p)
|
||||
App.color{r=0.4,g=0.4,b=0.4}
|
||||
love.graphics.polygon('fill', r-25, App.screen.height/2-10, r-25, App.screen.height/2+10, r-5, App.screen.height/2)
|
||||
end,
|
||||
})
|
||||
if Current_pane_index == #Panes then
|
||||
button(Global_state, 'right', {x=r-30, y=Menu_bottom, w=100, h=App.screen.height, bg={r=0.5, g=0.5, b=0.5, a=0.2},
|
||||
icon = function(p)
|
||||
App.color{r=0.4,g=0.4,b=0.4}
|
||||
love.graphics.print('+', r-25, App.screen.height/2-10)
|
||||
end,
|
||||
onpress1 = function()
|
||||
table.insert(Panes, new_pane())
|
||||
Current_pane_index = Current_pane_index+1
|
||||
Current_pane = Panes[Current_pane_index]
|
||||
end,
|
||||
})
|
||||
else
|
||||
button(Global_state, 'right', {x=r-30, y=Menu_bottom, w=100, h=App.screen.height, bg={r=0.5, g=0.5, b=0.5, a=0.2},
|
||||
icon = function(p)
|
||||
App.color{r=0.4,g=0.4,b=0.4}
|
||||
love.graphics.polygon('fill', r-25, App.screen.height/2-10, r-25, App.screen.height/2+10, r-5, App.screen.height/2)
|
||||
end,
|
||||
onpress1 = function()
|
||||
Current_pane_index = Current_pane_index+1
|
||||
Current_pane = Panes[Current_pane_index]
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
|
@ -0,0 +1 @@
|
|||
Current_pane_index = 0
|
|
@ -0,0 +1 @@
|
|||
Panes = {}
|
|
@ -0,0 +1,17 @@
|
|||
new_pane = function()
|
||||
local result = {}
|
||||
result.editor_state = edit.initialize_state(
|
||||
Menu_bottom + 20, -- top
|
||||
Safe_height/2-Line_height, -- bottom
|
||||
Menu_left + 50 + Line_number_padding, -- left
|
||||
math.min(100+30*App.width('m'), Safe_width*2/3), -- right
|
||||
love.graphics.getFont():getHeight(), Line_height)
|
||||
Text.redraw_all(result.editor_state)
|
||||
result.output_editor_state = edit.initialize_state(
|
||||
result.editor_state.bottom+5+10+5, -- top
|
||||
nil, -- buttom
|
||||
result.editor_state.left, result.editor_state.right,
|
||||
love.graphics.getFont():getHeight(), Line_height)
|
||||
Text.redraw_all(result.output_editor_state)
|
||||
return result
|
||||
end
|
Loading…
Reference in New Issue