only normalize component bounds in layout_element::layout_element() when components exist (nw)

avoids division by zero for sets using src/emu/layout/vertical.lay
This commit is contained in:
Oliver Stöneberg 2014-10-23 15:32:31 +02:00
parent 124803b476
commit 38b44ae386

View File

@ -452,19 +452,22 @@ layout_element::layout_element(running_machine &machine, xml_data_node &elemnode
m_maxstate = 65536; m_maxstate = 65536;
} }
// determine the scale/offset for normalization if (m_complist.first() != NULL)
float xoffs = bounds.x0;
float yoffs = bounds.y0;
float xscale = 1.0f / (bounds.x1 - bounds.x0);
float yscale = 1.0f / (bounds.y1 - bounds.y0);
// normalize all the component bounds
for (component *curcomp = m_complist.first(); curcomp != NULL; curcomp = curcomp->next())
{ {
curcomp->m_bounds.x0 = (curcomp->m_bounds.x0 - xoffs) * xscale; // determine the scale/offset for normalization
curcomp->m_bounds.x1 = (curcomp->m_bounds.x1 - xoffs) * xscale; float xoffs = bounds.x0;
curcomp->m_bounds.y0 = (curcomp->m_bounds.y0 - yoffs) * yscale; float yoffs = bounds.y0;
curcomp->m_bounds.y1 = (curcomp->m_bounds.y1 - yoffs) * yscale; float xscale = 1.0f / (bounds.x1 - bounds.x0);
float yscale = 1.0f / (bounds.y1 - bounds.y0);
// normalize all the component bounds
for (component *curcomp = m_complist.first(); curcomp != NULL; curcomp = curcomp->next())
{
curcomp->m_bounds.x0 = (curcomp->m_bounds.x0 - xoffs) * xscale;
curcomp->m_bounds.x1 = (curcomp->m_bounds.x1 - xoffs) * xscale;
curcomp->m_bounds.y0 = (curcomp->m_bounds.y0 - yoffs) * yscale;
curcomp->m_bounds.y1 = (curcomp->m_bounds.y1 - yoffs) * yscale;
}
} }
// allocate an array of element textures for the states // allocate an array of element textures for the states