Skip to content

Commit

Permalink
feat: uiwidget::recursiveGetChildrenByStyleName
Browse files Browse the repository at this point in the history
  • Loading branch information
mehah committed Apr 21, 2023
1 parent 518722f commit f4d6bb6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/framework/luafunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ void Application::registerLuaFunctions()
g_lua.bindClassMemberFunction<UIWidget>("recursiveGetChildrenByPos", &UIWidget::recursiveGetChildrenByPos);
g_lua.bindClassMemberFunction<UIWidget>("recursiveGetChildrenByMarginPos", &UIWidget::recursiveGetChildrenByMarginPos);
g_lua.bindClassMemberFunction<UIWidget>("recursiveGetChildrenByState", &UIWidget::recursiveGetChildrenByState);
g_lua.bindClassMemberFunction<UIWidget>("recursiveGetChildrenByStyleName", &UIWidget::recursiveGetChildrenByStyleName);
g_lua.bindClassMemberFunction<UIWidget>("backwardsGetWidgetById", &UIWidget::backwardsGetWidgetById);
g_lua.bindClassMemberFunction<UIWidget>("resize", &UIWidget::resize);
g_lua.bindClassMemberFunction<UIWidget>("move", &UIWidget::move);
Expand Down
10 changes: 10 additions & 0 deletions src/framework/ui/uiwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,16 @@ UIWidgetList UIWidget::recursiveGetChildrenByState(Fw::WidgetState state)
return children;
}

UIWidgetList UIWidget::recursiveGetChildrenByStyleName(const std::string_view styleName)
{
UIWidgetList children;
for (const auto& child : m_children) {
if (child->getStyleName() == styleName)
children.emplace_back(child);
}
return children;
}

UIWidgetPtr UIWidget::backwardsGetWidgetById(const std::string_view id)
{
UIWidgetPtr widget = getChildById(id);
Expand Down
1 change: 1 addition & 0 deletions src/framework/ui/uiwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ class UIWidget : public LuaObject
UIWidgetList recursiveGetChildrenByPos(const Point& childPos);
UIWidgetList recursiveGetChildrenByMarginPos(const Point& childPos);
UIWidgetList recursiveGetChildrenByState(Fw::WidgetState state);
UIWidgetList recursiveGetChildrenByStyleName(const std::string_view styleName);
UIWidgetPtr backwardsGetWidgetById(const std::string_view id);

void setProp(FlagProp prop, bool v);
Expand Down

0 comments on commit f4d6bb6

Please sign in to comment.