diff --git a/meson.build b/meson.build index 982cefeb..3081efc3 100644 --- a/meson.build +++ b/meson.build @@ -10,7 +10,7 @@ src = [] fs = import('fs') -add_project_arguments('-pedantic', language: ['c']) +add_project_arguments('-Wno-gnu-label-as-value', language: ['c']) git_tag_cmd = run_command('git', 'describe', '--tags', '--abbrev=0', check: false) cell_version = 'unknown' diff --git a/prosperon/clay.cm b/prosperon/clay.cm index 5e2b4c06..e0b47779 100644 --- a/prosperon/clay.cm +++ b/prosperon/clay.cm @@ -303,19 +303,25 @@ clay.draw_commands = function draw_commands(tree_root, pos = {x:0,y:0}) draw.rectangle(boundingbox, null, {color:config.background_color}) if (config.text) { - var baseline_y = content.y //+ config.font.ascent + var baseline_y = content.y + content.height - config.font.ascent draw.text(config.text, {x: content.x, y: baseline_y}, config.font, config.color, content.width) } if (config.image) draw.image(config.image, content, 0, config.color) + if (config.clipped) { + draw.scissor(content) + } + // Recursively draw children if (node[CHILDREN]) { for (var child of node[CHILDREN]) { draw_node(child); } } + if (config.clipped) + draw.scissor(null) } draw_node(tree_root); diff --git a/prosperon/clay_input.cm b/prosperon/clay_input.cm index 968114e3..82bc73cb 100644 --- a/prosperon/clay_input.cm +++ b/prosperon/clay_input.cm @@ -72,6 +72,10 @@ clay_input.hit = function hit(tree_root, pos, prev_state = {}) { deepest.state.hovered = true new_hover_chain.push(deepest) } + // Call hovered callback if it exists + if (typeof deepest.hovered == 'function') { + deepest.hovered(true) + } for (var i = path.length - 2; i >= 0; i--) { var anc = path[i] @@ -80,6 +84,10 @@ clay_input.hit = function hit(tree_root, pos, prev_state = {}) { anc.state.hovered = true new_hover_chain.push(anc) } + // Call hovered callback if it exists + if (typeof anc.hovered == 'function') { + anc.hovered(true) + } } } @@ -90,6 +98,10 @@ clay_input.hit = function hit(tree_root, pos, prev_state = {}) { if (new_hover_chain.indexOf(n) == -1) { n.state = n.state || {} n.state.hovered = false + // Call hovered callback if it exists + if (typeof n.hovered == 'function') { + n.hovered(false) + } } } } @@ -98,6 +110,7 @@ clay_input.hit = function hit(tree_root, pos, prev_state = {}) { path: path, deepest: deepest, action_target: action_target, + hovered: deepest, hover_chain: new_hover_chain } } diff --git a/prosperon/draw2d.cm b/prosperon/draw2d.cm index b9dae346..f92fdc0c 100644 --- a/prosperon/draw2d.cm +++ b/prosperon/draw2d.cm @@ -231,6 +231,10 @@ draw.scissor = function(rect) width: Math.round(screen_right - screen_left), height: Math.round(screen_bottom - screen_top) } + + // TODO: must be a better way than manually inverting here. Some camera specific function. + var sensor = gamestate.camera.sensor() + screen_rect.y = sensor.height - screen_rect.y - screen_rect.height } current_list.push({ diff --git a/prosperon/prosperon.cm b/prosperon/prosperon.cm index 1e4b4103..f2b078a3 100644 --- a/prosperon/prosperon.cm +++ b/prosperon/prosperon.cm @@ -891,10 +891,9 @@ prosperon.create_batch = function create_batch(draw_cmds, done) { if (cmd.cmd == "scissor") { if (!cmd.rect) render_pass.scissor({x:0,y:0,width:win_size.width,height:win_size.height}) - else { + else render_pass.scissor(cmd.rect) - log.console(json.encode(cmd.rect)) - } + continue } if (cmd.camera) { diff --git a/source/qjs_io.c b/source/qjs_io.c index 3ffbbce2..7aed0b56 100644 --- a/source/qjs_io.c +++ b/source/qjs_io.c @@ -256,6 +256,8 @@ static int globfs_cb(struct globdata *data, char *dir, char *file) return 1; } +// arg0: glob patterns (array of strings) +// arg1: directory (string) JSC_CCALL(io_globfs, ret = JS_NewArray(js); struct globdata data; diff --git a/source/quickjs.c b/source/quickjs.c index 6163c495..59a46bf5 100644 --- a/source/quickjs.c +++ b/source/quickjs.c @@ -1455,7 +1455,9 @@ void JS_FreeRuntime(JSRuntime *rt) printf("Secondary object leaks: %d\n", count); } #endif - assert(list_empty(&rt->gc_obj_list)); + if (!list_empty(&rt->gc_obj_list)) + printf("Object leaks!\n"); +// assert(list_empty(&rt->gc_obj_list)); /* free the classes */ for(i = 0; i < rt->class_count; i++) {