diff --git a/src/framework/luafunctions.cpp b/src/framework/luafunctions.cpp index 2a6b3450..da5a6287 100644 --- a/src/framework/luafunctions.cpp +++ b/src/framework/luafunctions.cpp @@ -73,6 +73,7 @@ void Application::registerLuaFunctions() g_lua.bindClassMemberFunction("unlockChild", &UIWidget::unlockChild); g_lua.bindClassMemberFunction("applyStyle", &UIWidget::applyStyle); g_lua.bindClassMemberFunction("addAnchor", &UIWidget::addAnchor); + g_lua.bindClassMemberFunction("removeAnchor", &UIWidget::removeAnchor); g_lua.bindClassMemberFunction("fill", &UIWidget::fill); g_lua.bindClassMemberFunction("centerIn", &UIWidget::centerIn); g_lua.bindClassMemberFunction("breakAnchors", &UIWidget::breakAnchors); diff --git a/src/framework/ui/uiwidget.cpp b/src/framework/ui/uiwidget.cpp index fabf5d2e..ee7cac10 100644 --- a/src/framework/ui/uiwidget.cpp +++ b/src/framework/ui/uiwidget.cpp @@ -489,6 +489,11 @@ void UIWidget::addAnchor(Fw::AnchorEdge anchoredEdge, const std::string& hookedW logError("cannot add anchors to widget ", m_id, ": the parent doesn't use anchors layout"); } +void UIWidget::removeAnchor(Fw::AnchorEdge anchoredEdge) +{ + addAnchor(anchoredEdge, "none", Fw::AnchorNone); +} + void UIWidget::centerIn(const std::string& hookedWidgetId) { if(m_destroyed) diff --git a/src/framework/ui/uiwidget.h b/src/framework/ui/uiwidget.h index 218bb942..3fcaaff1 100644 --- a/src/framework/ui/uiwidget.h +++ b/src/framework/ui/uiwidget.h @@ -92,6 +92,7 @@ public: void unlockChild(const UIWidgetPtr& child); void applyStyle(const OTMLNodePtr& styleNode); void addAnchor(Fw::AnchorEdge anchoredEdge, const std::string& hookedWidgetId, Fw::AnchorEdge hookedEdge); + void removeAnchor(Fw::AnchorEdge anchoredEdge); void fill(const std::string& hookedWidgetId); void centerIn(const std::string& hookedWidgetId); void breakAnchors(); diff --git a/src/framework/ui/uiwidgetbasestyle.cpp b/src/framework/ui/uiwidgetbasestyle.cpp index 6b743fa2..6437547f 100644 --- a/src/framework/ui/uiwidgetbasestyle.cpp +++ b/src/framework/ui/uiwidgetbasestyle.cpp @@ -278,20 +278,24 @@ void UIWidget::parseBaseStyle(const OTMLNodePtr& styleNode) } else { Fw::AnchorEdge anchoredEdge = Fw::translateAnchorEdge(what); - std::vector split = Fw::split(node->value(), "."); - if(split.size() != 2) - throw OTMLException(node, "invalid anchor description"); + if(node->value() == "none") { + removeAnchor(anchoredEdge); + } else { + std::vector split = Fw::split(node->value(), "."); + if(split.size() != 2) + throw OTMLException(node, "invalid anchor description"); - std::string hookedWidgetId = split[0]; - Fw::AnchorEdge hookedEdge = Fw::translateAnchorEdge(split[1]); + std::string hookedWidgetId = split[0]; + Fw::AnchorEdge hookedEdge = Fw::translateAnchorEdge(split[1]); - if(anchoredEdge == Fw::AnchorNone) - throw OTMLException(node, "invalid anchor edge"); + if(anchoredEdge == Fw::AnchorNone) + throw OTMLException(node, "invalid anchor edge"); - if(hookedEdge == Fw::AnchorNone) - throw OTMLException(node, "invalid anchor target edge"); + if(hookedEdge == Fw::AnchorNone) + throw OTMLException(node, "invalid anchor target edge"); - addAnchor(anchoredEdge, hookedWidgetId, hookedEdge); + addAnchor(anchoredEdge, hookedWidgetId, hookedEdge); + } } // lua functions } else if(boost::starts_with(node->tag(), "@")) {