Add better click through semantics

This commit is contained in:
2026-05-21 08:55:27 +01:00
parent 2bff3eb93f
commit 72304ee925
6 changed files with 180 additions and 57 deletions
+10 -5
View File
@@ -10,6 +10,10 @@ enum Type { IMAGE,
TEXT,
RECT };
enum ClickMode { PASS,
BLOCK,
IGNORE };
namespace app {
struct Element {
Type type;
@@ -19,7 +23,7 @@ struct Element {
Vec2<float> scale = {1, 1};
float alpha = 1.0f;
float z = 0;
bool click_through = false;
ClickMode click_mode = ClickMode::BLOCK;
Ruby::Block on_click;
Element(Type type) : type(type) {}
@@ -191,11 +195,12 @@ struct Scene {
Vec2<float> size = e->size();
Rect rect = Rect::from(size);
if (rect.contains(world_to_local(position, e))) {
result.push_back(*it);
if (e->click_through)
continue;
else
if (e->click_mode == ClickMode::PASS) {
result.push_back(*it);
} else if (e->click_mode == ClickMode::BLOCK) {
result.push_back(*it);
break;
}
}
}