Add better click through semantics
This commit is contained in:
+10
-5
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user