ui.focus(self)
if button == 1 then self.mouse_down = true end
return true
-end;
+end
function drag_rect.mousereleased(self, button, x, y)
if button == 1 then self.mouse_down = false end
end
end
-
local function_block = { extends = "drag_rect" }
function function_block.init(self, wasm_function, wasm_mod)
self.func = wasm_function
function function_block.mousereleased(self, button, x, y)
drag_rect.mousereleased(self, button, x, y)
- if button == 2 then self.resize_down = false end
+ if ui.focused == self and button == 2 then self.resize_down = false end
+
+ if ui.focused == self and button == 3 then
+ ui.insert_child(self, with(ui.make_element "rect") {
+ rect = Rectangle(50, 40, 80, 60);
+ color = { 1, 0, 0 };
+ })
+ end
end
function function_block.focus(self)
end
if love.keyboard.isDown "up" then
self.scroll = self.scroll - 300 * dt
+ if self.scroll < 0 then self.scroll = 0 end
self.redraw = true
end
end
end
love.graphics.setColor(1, 1, 1)
- love.graphics.draw(self.canvas, self.rect.x, self.rect.y)
+ love.graphics.push()
+ love.graphics.translate(self.rect.x, self.rect.y)
+ love.graphics.draw(self.canvas, 0, 0)
end
-function function_block.postdraw(self) end
+function function_block.postdraw(self)
+ love.graphics.pop()
+end
local scrolling = {}
function scrolling.init(self)
if self.mouse_down then
self.offset.x = self.offset.x + dx
self.offset.y = self.offset.y + dy
+
+ return true
end
- return true
+ return false
end
function scrolling.change_zoom(self, multiplier)
function scrolling.wheelmoved(self, dx, dy)
if ui.focused == self then
scrolling.change_zoom(self, dy > 0 and 1.05 or (1 / 1.05))
+ return true
end
end
rect = Rectangle(0, 0, 0, 0);
}
- -- ui.insert_child(self.ui, with(ui.make_element "rect") {
- -- rect = Rectangle(0, 0, 1200, 50);
- -- color = COLORS.dark_background;
- -- })
-
self.scroller = with(ui.make_element "scrolling") {
rect = Rectangle(0, 0, 1200, 900);
background_color = COLORS.background;
- line_color = COLORS.primary_dark;
+ line_color = COLORS.dark_background;
layer = 10;
}
local i = 0
for _, func in ipairs(wasm_mod.funcs) do
- ui.insert_child(self.scroller, with(ui.make_element("function_block", func, wasm_mod)) {
- rect = Rectangle(i * 400, 0, 400, 400);
- layer = i + 1
- })
-
- i = i + 1
+ if not func.imported then
+ ui.insert_child(self.scroller, with(ui.make_element("function_block", func, wasm_mod)) {
+ rect = Rectangle(0, i * 22, 400, 400);
+ layer = 30 - i
+ })
+
+ i = i + 1
+ if i > 20 then break end
+ end
end
end;