add API to remove widget anchors
This commit is contained in:
parent
248ea9e8bc
commit
218f2e4994
|
@ -73,6 +73,7 @@ void Application::registerLuaFunctions()
|
|||
g_lua.bindClassMemberFunction<UIWidget>("unlockChild", &UIWidget::unlockChild);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("applyStyle", &UIWidget::applyStyle);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("addAnchor", &UIWidget::addAnchor);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("removeAnchor", &UIWidget::removeAnchor);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("fill", &UIWidget::fill);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("centerIn", &UIWidget::centerIn);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("breakAnchors", &UIWidget::breakAnchors);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -278,6 +278,9 @@ void UIWidget::parseBaseStyle(const OTMLNodePtr& styleNode)
|
|||
} else {
|
||||
Fw::AnchorEdge anchoredEdge = Fw::translateAnchorEdge(what);
|
||||
|
||||
if(node->value() == "none") {
|
||||
removeAnchor(anchoredEdge);
|
||||
} else {
|
||||
std::vector<std::string> split = Fw::split(node->value(), ".");
|
||||
if(split.size() != 2)
|
||||
throw OTMLException(node, "invalid anchor description");
|
||||
|
@ -293,6 +296,7 @@ void UIWidget::parseBaseStyle(const OTMLNodePtr& styleNode)
|
|||
|
||||
addAnchor(anchoredEdge, hookedWidgetId, hookedEdge);
|
||||
}
|
||||
}
|
||||
// lua functions
|
||||
} else if(boost::starts_with(node->tag(), "@")) {
|
||||
// load once
|
||||
|
|
Loading…
Reference in New Issue