mock-up of reply buttons
Doesn't do anything yet, just changes color.
This commit is contained in:
parent
2a32a1468b
commit
b0ca118a7a
|
@ -27,6 +27,12 @@ on.mouse_press = function(x,y, mouse_button)
|
|||
edit.mouse_press(node.editor, x,y, mouse_button)
|
||||
return
|
||||
end
|
||||
local button = on_button(x,y)
|
||||
if button then
|
||||
-- HERE
|
||||
button.bg = {r=1,g=0,b=0}
|
||||
A()
|
||||
end
|
||||
-- pan surface
|
||||
Pan = {x=Viewport.x+x/Viewport.zoom,y=Viewport.y+y/Viewport.zoom}
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
on_text = function(x,y)
|
||||
for _,node in ipairs(Surface) do
|
||||
if node.type == 'text' then
|
||||
if node.type == 'text' and not node.button then
|
||||
if x >= vx(node.x) and node.w and x < vx(node.x + node.w) then
|
||||
if y >= vy(node.y) and node.h and y < vy(node.y + node.h) then
|
||||
return node
|
||||
|
|
|
@ -4,6 +4,7 @@ initialize_editor = function(obj)
|
|||
local scaled_fontsize = scale(20)
|
||||
local scaled_lineheight = math.floor(scaled_fontsize*1.3)
|
||||
obj.editor = edit.initialize_state(Menu_bar_height + vy(obj.y), math.floor(vx(obj.x)), math.ceil(vx(obj.x+obj.w)), scaled_fontsize, scaled_lineheight)
|
||||
obj.editor.filename = obj.filename
|
||||
obj.editor.lines = obj.data
|
||||
Text.redraw_all(obj.editor)
|
||||
end
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
mouse_press_on_surface = function(x,y, mouse_button)
|
||||
if Cursor_node then
|
||||
Cursor_node.show_cursor = nil
|
||||
Cursor_node = nil
|
||||
end
|
||||
if mouse_press_consumed_by_any_button_handler(HUD, x,y, mouse_button) then
|
||||
return
|
||||
end
|
||||
local node = on_text(x,y)
|
||||
if node then
|
||||
-- position cursor in node
|
||||
Cursor_node = node
|
||||
edit.mouse_press(node.editor, x,y, mouse_button)
|
||||
return
|
||||
end
|
||||
-- pan surface
|
||||
Pan = {x=Viewport.x+x/Viewport.zoom,y=Viewport.y+y/Viewport.zoom}
|
||||
end
|
|
@ -5,18 +5,19 @@ load_subtree = function(filename, out, depth)
|
|||
-- every item is a row consisting of two columns:
|
||||
-- one column of padding and another of text
|
||||
local row = cols(Inter_comment_spacing)
|
||||
table.insert(out, row)
|
||||
table.insert(row.data,
|
||||
{type='rectangle', w=depth*Indent, h=0})
|
||||
local item_stuff = rows()
|
||||
table.insert(row.data, item_stuff)
|
||||
table.insert(item_stuff.data, item)
|
||||
table.insert(item_stuff.data, {
|
||||
type='text', data={{data='reply'}},
|
||||
button=true, name=filename,
|
||||
margin=20,
|
||||
bg=Reply_button_color,
|
||||
border=Reply_button_border_color,
|
||||
})
|
||||
table.insert(row.data, item_stuff)
|
||||
table.insert(out, row)
|
||||
for i,reply_id in ipairs(item.metadata.replies) do
|
||||
local reply = load_subtree(reply_id, out, depth+1)
|
||||
end
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
on_button = function(x,y, mouse_button)
|
||||
for _,node in ipairs(Surface) do
|
||||
if node.type == 'text' and node.button then
|
||||
if x >= vx(node.x) and node.w and x < vx(node.x + node.w) then
|
||||
if y >= vy(node.y) and node.h and y < vy(node.y + node.h) then
|
||||
return node
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue