// Updates the position of the document based on the style properties. void ElementDocument::UpdatePosition() { // We are only positioned relative to our parent, so if we're not parented we may as well bail now. if (GetParentNode() == NULL) return; Vector2f position; // Work out our containing block; relative offsets are calculated against it. Vector2f containing_block = GetParentNode()->GetBox().GetSize(Box::CONTENT); const Property *left = GetLocalProperty(LEFT); const Property *right = GetLocalProperty(RIGHT); if (left != NULL && left->unit != Property::KEYWORD) position.x = ResolveProperty(LEFT, containing_block.x); else if (right != NULL && right->unit != Property::KEYWORD) position.x = (containing_block.x - GetBox().GetSize(Box::MARGIN).x) - ResolveProperty(RIGHT, containing_block.x); else position.x = GetBox().GetEdge(Box::MARGIN, Box::LEFT); const Property *top = GetLocalProperty(TOP); const Property *bottom = GetLocalProperty(BOTTOM); if (top != NULL && top->unit != Property::KEYWORD) position.y = ResolveProperty(TOP, containing_block.y); else if (bottom != NULL && bottom->unit != Property::KEYWORD) position.y = (containing_block.y - GetBox().GetSize(Box::MARGIN).y) - ResolveProperty(BOTTOM, containing_block.y); else position.y = GetBox().GetEdge(Box::MARGIN, Box::TOP); SetOffset(position, NULL); }
void ElementDataGrid::OnUpdate() { Core::ElementDocument* document = GetOwnerDocument(); document->LockLayout(true); if (!new_data_source.Empty()) { root->SetDataSource(new_data_source); new_data_source = ""; } bool any_new_children = root->UpdateChildren(); if (any_new_children) { DispatchEvent("rowupdate", Rocket::Core::Dictionary()); } if (!body_visible && (!any_new_children || root->GetNumLoadedChildren() >= Rocket::Core::Math::RealToInteger(ResolveProperty("min-rows", 0)))) { body->SetProperty("display", "block"); body_visible = true; } document->LockLayout(false); }