Updated fork to match current version of Godot.
This commit is contained in:
parent
e44444ea2d
commit
d8d329883e
2 changed files with 18 additions and 0 deletions
|
@ -178,6 +178,8 @@ void GridContainer::_bind_methods() {
|
|||
|
||||
ClassDB::bind_method(D_METHOD("set_columns", "columns"), &GridContainer::set_columns);
|
||||
ClassDB::bind_method(D_METHOD("get_columns"), &GridContainer::get_columns);
|
||||
ClassDB::bind_method(D_METHOD("get_child_control_at_cell", "row", "column"),
|
||||
&GridContainer::get_child_control_at_cell);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "columns", PROPERTY_HINT_RANGE, "1,1024,1"), "set_columns", "get_columns");
|
||||
}
|
||||
|
@ -232,6 +234,21 @@ Size2 GridContainer::get_minimum_size() const {
|
|||
return ms;
|
||||
}
|
||||
|
||||
Control *GridContainer::get_child_control_at_cell(int row, int column) {
|
||||
Control *c;
|
||||
int grid_index = row * columns + column;
|
||||
for (int i = 0; i < get_child_count(); i++) {
|
||||
c = Object::cast_to<Control>(get_child(i));
|
||||
if (!c || !c->is_visible_in_tree())
|
||||
continue;
|
||||
|
||||
if (grid_index == i) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
GridContainer::GridContainer() {
|
||||
|
||||
set_mouse_filter(MOUSE_FILTER_PASS);
|
||||
|
|
|
@ -47,6 +47,7 @@ public:
|
|||
void set_columns(int p_columns);
|
||||
int get_columns() const;
|
||||
virtual Size2 get_minimum_size() const;
|
||||
Control *get_child_control_at_cell(int row, int column);
|
||||
|
||||
GridContainer();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue