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)
|
edit.mouse_press(node.editor, x,y, mouse_button)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
local button = on_button(x,y)
|
||||||
|
if button then
|
||||||
|
-- HERE
|
||||||
|
button.bg = {r=1,g=0,b=0}
|
||||||
|
A()
|
||||||
|
end
|
||||||
-- pan surface
|
-- pan surface
|
||||||
Pan = {x=Viewport.x+x/Viewport.zoom,y=Viewport.y+y/Viewport.zoom}
|
Pan = {x=Viewport.x+x/Viewport.zoom,y=Viewport.y+y/Viewport.zoom}
|
||||||
end
|
end
|
|
@ -1,6 +1,6 @@
|
||||||
on_text = function(x,y)
|
on_text = function(x,y)
|
||||||
for _,node in ipairs(Surface) do
|
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 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
|
if y >= vy(node.y) and node.h and y < vy(node.y + node.h) then
|
||||||
return node
|
return node
|
||||||
|
|
|
@ -4,6 +4,7 @@ initialize_editor = function(obj)
|
||||||
local scaled_fontsize = scale(20)
|
local scaled_fontsize = scale(20)
|
||||||
local scaled_lineheight = math.floor(scaled_fontsize*1.3)
|
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 = 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
|
obj.editor.lines = obj.data
|
||||||
Text.redraw_all(obj.editor)
|
Text.redraw_all(obj.editor)
|
||||||
end
|
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:
|
-- every item is a row consisting of two columns:
|
||||||
-- one column of padding and another of text
|
-- one column of padding and another of text
|
||||||
local row = cols(Inter_comment_spacing)
|
local row = cols(Inter_comment_spacing)
|
||||||
|
table.insert(out, row)
|
||||||
table.insert(row.data,
|
table.insert(row.data,
|
||||||
{type='rectangle', w=depth*Indent, h=0})
|
{type='rectangle', w=depth*Indent, h=0})
|
||||||
local item_stuff = rows()
|
local item_stuff = rows()
|
||||||
|
table.insert(row.data, item_stuff)
|
||||||
table.insert(item_stuff.data, item)
|
table.insert(item_stuff.data, item)
|
||||||
table.insert(item_stuff.data, {
|
table.insert(item_stuff.data, {
|
||||||
type='text', data={{data='reply'}},
|
type='text', data={{data='reply'}},
|
||||||
|
button=true, name=filename,
|
||||||
margin=20,
|
margin=20,
|
||||||
bg=Reply_button_color,
|
bg=Reply_button_color,
|
||||||
border=Reply_button_border_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
|
for i,reply_id in ipairs(item.metadata.replies) do
|
||||||
local reply = load_subtree(reply_id, out, depth+1)
|
local reply = load_subtree(reply_id, out, depth+1)
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,4 +11,4 @@ initialize_item = function(filename, depth)
|
||||||
result.metadata = load_metadata(filename)
|
result.metadata = load_metadata(filename)
|
||||||
result.border = Border_color
|
result.border = Border_color
|
||||||
return result
|
return result
|
||||||
end
|
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