This commit is contained in:
2025-11-18 19:12:30 -06:00
parent 0082eab729
commit dbf9f8ef30
7 changed files with 32 additions and 6 deletions

View File

@@ -10,7 +10,7 @@ src = []
fs = import('fs') 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) git_tag_cmd = run_command('git', 'describe', '--tags', '--abbrev=0', check: false)
cell_version = 'unknown' cell_version = 'unknown'

View File

@@ -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}) draw.rectangle(boundingbox, null, {color:config.background_color})
if (config.text) { 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) draw.text(config.text, {x: content.x, y: baseline_y}, config.font, config.color, content.width)
} }
if (config.image) if (config.image)
draw.image(config.image, content, 0, config.color) draw.image(config.image, content, 0, config.color)
if (config.clipped) {
draw.scissor(content)
}
// Recursively draw children // Recursively draw children
if (node[CHILDREN]) { if (node[CHILDREN]) {
for (var child of node[CHILDREN]) { for (var child of node[CHILDREN]) {
draw_node(child); draw_node(child);
} }
} }
if (config.clipped)
draw.scissor(null)
} }
draw_node(tree_root); draw_node(tree_root);

View File

@@ -72,6 +72,10 @@ clay_input.hit = function hit(tree_root, pos, prev_state = {}) {
deepest.state.hovered = true deepest.state.hovered = true
new_hover_chain.push(deepest) 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--) { for (var i = path.length - 2; i >= 0; i--) {
var anc = path[i] var anc = path[i]
@@ -80,6 +84,10 @@ clay_input.hit = function hit(tree_root, pos, prev_state = {}) {
anc.state.hovered = true anc.state.hovered = true
new_hover_chain.push(anc) 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) { if (new_hover_chain.indexOf(n) == -1) {
n.state = n.state || {} n.state = n.state || {}
n.state.hovered = false 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, path: path,
deepest: deepest, deepest: deepest,
action_target: action_target, action_target: action_target,
hovered: deepest,
hover_chain: new_hover_chain hover_chain: new_hover_chain
} }
} }

View File

@@ -231,6 +231,10 @@ draw.scissor = function(rect)
width: Math.round(screen_right - screen_left), width: Math.round(screen_right - screen_left),
height: Math.round(screen_bottom - screen_top) 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({ current_list.push({

View File

@@ -891,10 +891,9 @@ prosperon.create_batch = function create_batch(draw_cmds, done) {
if (cmd.cmd == "scissor") { if (cmd.cmd == "scissor") {
if (!cmd.rect) if (!cmd.rect)
render_pass.scissor({x:0,y:0,width:win_size.width,height:win_size.height}) render_pass.scissor({x:0,y:0,width:win_size.width,height:win_size.height})
else { else
render_pass.scissor(cmd.rect) render_pass.scissor(cmd.rect)
log.console(json.encode(cmd.rect))
}
continue continue
} }
if (cmd.camera) { if (cmd.camera) {

View File

@@ -256,6 +256,8 @@ static int globfs_cb(struct globdata *data, char *dir, char *file)
return 1; return 1;
} }
// arg0: glob patterns (array of strings)
// arg1: directory (string)
JSC_CCALL(io_globfs, JSC_CCALL(io_globfs,
ret = JS_NewArray(js); ret = JS_NewArray(js);
struct globdata data; struct globdata data;

View File

@@ -1455,7 +1455,9 @@ void JS_FreeRuntime(JSRuntime *rt)
printf("Secondary object leaks: %d\n", count); printf("Secondary object leaks: %d\n", count);
} }
#endif #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 */ /* free the classes */
for(i = 0; i < rt->class_count; i++) { for(i = 0; i < rt->class_count; i++) {