mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-26 13:47:12 +01:00
Make EditorPropertyLayersGrid
responsive to touch taps
This commit is contained in:
parent
0947677049
commit
88fa0e459b
@ -849,18 +849,16 @@ public:
|
||||
return String();
|
||||
}
|
||||
|
||||
void _gui_input(const Ref<InputEvent> &p_ev) {
|
||||
const Ref<InputEventMouseMotion> mm = p_ev;
|
||||
if (mm.is_valid()) {
|
||||
void _update_hovered(const Vector2 &p_position) {
|
||||
bool expand_was_hovered = expand_hovered;
|
||||
expand_hovered = expand_rect.has_point(mm->get_position());
|
||||
expand_hovered = expand_rect.has_point(p_position);
|
||||
if (expand_hovered != expand_was_hovered) {
|
||||
update();
|
||||
}
|
||||
|
||||
if (!expand_hovered) {
|
||||
for (int i = 0; i < flag_rects.size(); i++) {
|
||||
if (flag_rects[i].has_point(mm->get_position())) {
|
||||
if (flag_rects[i].has_point(p_position)) {
|
||||
// Used to highlight the hovered flag in the layers grid.
|
||||
hovered_index = i;
|
||||
update();
|
||||
@ -874,12 +872,20 @@ public:
|
||||
hovered_index = -1;
|
||||
update();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const Ref<InputEventMouseButton> mb = p_ev;
|
||||
if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
|
||||
void _on_hover_exit() {
|
||||
if (expand_hovered) {
|
||||
expand_hovered = false;
|
||||
update();
|
||||
}
|
||||
if (hovered_index != -1) {
|
||||
hovered_index = -1;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void _update_flag() {
|
||||
if (hovered_index >= 0) {
|
||||
// Toggle the flag.
|
||||
// We base our choice on the hovered flag, so that it always matches the hovered flag.
|
||||
@ -897,6 +903,19 @@ public:
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void _gui_input(const Ref<InputEvent> &p_ev) {
|
||||
const Ref<InputEventMouseMotion> mm = p_ev;
|
||||
if (mm.is_valid()) {
|
||||
_update_hovered(mm->get_position());
|
||||
return;
|
||||
}
|
||||
|
||||
const Ref<InputEventMouseButton> mb = p_ev;
|
||||
if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
|
||||
_update_hovered(mb->get_position());
|
||||
_update_flag();
|
||||
}
|
||||
}
|
||||
|
||||
void _notification(int p_what) {
|
||||
@ -1027,14 +1046,7 @@ public:
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_MOUSE_EXIT: {
|
||||
if (expand_hovered) {
|
||||
expand_hovered = false;
|
||||
update();
|
||||
}
|
||||
if (hovered_index != -1) {
|
||||
hovered_index = -1;
|
||||
update();
|
||||
}
|
||||
_on_hover_exit();
|
||||
} break;
|
||||
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user