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,20 +278,24 @@ void UIWidget::parseBaseStyle(const OTMLNodePtr& styleNode)
|
|||
} else {
|
||||
Fw::AnchorEdge anchoredEdge = Fw::translateAnchorEdge(what);
|
||||
|
||||
std::vector<std::string> split = Fw::split(node->value(), ".");
|
||||
if(split.size() != 2)
|
||||
throw OTMLException(node, "invalid anchor description");
|
||||
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");
|
||||
|
||||
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(), "@")) {
|
||||
|
|
Loading…
Reference in New Issue