GUI2/Widget: add const overload of get_parent_grid

This commit is contained in:
Charles Dang 2024-10-05 15:19:20 -04:00
parent 2931816979
commit ad736266c1
2 changed files with 11 additions and 0 deletions

View file

@ -152,6 +152,16 @@ grid* widget::get_parent_grid()
return result ? dynamic_cast<grid*>(result) : nullptr;
}
const grid* widget::get_parent_grid() const
{
const widget* result = parent_;
while(result && dynamic_cast<const grid*>(result) == nullptr) {
result = result->parent_;
}
return result ? dynamic_cast<const grid*>(result) : nullptr;
}
void widget::set_parent(widget* parent)
{
parent_ = parent;

View file

@ -198,6 +198,7 @@ public:
* @retval nullptr No parent grid found.
*/
grid* get_parent_grid();
const grid* get_parent_grid() const;
/*** *** *** *** *** *** Setters and getters. *** *** *** *** *** ***/