implement right-to-left
This commit is contained in:
@@ -46,11 +46,14 @@ void Node::async_end()
|
||||
App::I.async_end();
|
||||
}
|
||||
|
||||
void Node::watch(std::function<void(Node*)> observer)
|
||||
void Node::watch(std::function<bool(Node*)> observer)
|
||||
{
|
||||
observer(this);
|
||||
for (auto& c : m_children)
|
||||
c->watch(observer);
|
||||
bool cont = observer(this);
|
||||
if (cont)
|
||||
{
|
||||
for (auto& c : m_children)
|
||||
c->watch(observer);
|
||||
}
|
||||
}
|
||||
|
||||
void Node::destroy()
|
||||
@@ -532,6 +535,11 @@ void Node::SetAspectRatio(float ar)
|
||||
YGNodeStyleSetAspectRatio(y_node, ar);
|
||||
}
|
||||
|
||||
void Node::SetRTL(YGDirection dir)
|
||||
{
|
||||
YGNodeStyleSetDirection(y_node, dir);
|
||||
}
|
||||
|
||||
glm::vec2 Node::GetPosition()
|
||||
{
|
||||
return{ YGNodeLayoutGetLeft(y_node), YGNodeLayoutGetTop(y_node) };
|
||||
@@ -552,6 +560,11 @@ glm::vec2 Node::GetSize()
|
||||
return{ GetWidth(), GetHeight() };
|
||||
}
|
||||
|
||||
YGDirection Node::GetRTL()
|
||||
{
|
||||
return YGNodeStyleGetDirection(y_node);
|
||||
}
|
||||
|
||||
void Node::restore_context()
|
||||
{
|
||||
for (auto& c : m_children)
|
||||
@@ -809,6 +822,17 @@ void Node::parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr)
|
||||
case kAttribute::AspectRatio:
|
||||
YGNodeStyleSetAspectRatio(y_node, attr->FloatValue());
|
||||
break;
|
||||
case kAttribute::RTL:
|
||||
if (strcmp("rtl", attr->Value()) == 0)
|
||||
SetRTL(YGDirectionRTL);
|
||||
else if (strcmp("ltr", attr->Value()) == 0)
|
||||
SetRTL(YGDirectionLTR);
|
||||
else if (strcmp("inherit", attr->Value()) == 0)
|
||||
SetRTL(YGDirectionInherit);
|
||||
else
|
||||
{
|
||||
LOG("Attribute %s for RTL unrecognized", attr->Value());
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user