summaryrefslogtreecommitdiff
path: root/scene/gui/grid_container.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2018-05-01 16:32:30 +0200
committerGitHub <noreply@github.com>2018-05-01 16:32:30 +0200
commitb6a7c5693f13c40b381e5e6efa255fe723742311 (patch)
tree5f357e8d561e2352465a11b75f4ab019e622f136 /scene/gui/grid_container.cpp
parent422e636c9a3eec3563c815e7d914881a2ca84a92 (diff)
parentd8d329883e86d6887967b3793828f8358491af49 (diff)
Merge pull request #16977 from SASUPERNOVA/master
Created a new function named get_element in GridContainer. This funct…
Diffstat (limited to 'scene/gui/grid_container.cpp')
-rw-r--r--scene/gui/grid_container.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/scene/gui/grid_container.cpp b/scene/gui/grid_container.cpp
index bb1d1d7695..278e4123d7 100644
--- a/scene/gui/grid_container.cpp
+++ b/scene/gui/grid_container.cpp
@@ -184,6 +184,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");
}
@@ -239,6 +241,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);