Skip to content

Commit

Permalink
MT07379: better automatic group bounds behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
cuavas committed Aug 19, 2019
1 parent 450a575 commit 60c035e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/emu/render.h
Expand Up @@ -749,6 +749,7 @@ class layout_group
util::xml::data_node const &parentnode,
group_map &groupmap,
std::vector<layout_group const *> &seen,
bool empty,
bool repeat,
bool init);

Expand Down
24 changes: 19 additions & 5 deletions src/emu/rendlay.cpp
Expand Up @@ -1062,8 +1062,9 @@ void layout_group::resolve_bounds(environment &env, group_map &groupmap, std::ve
seen.push_back(this);
if (!m_bounds_resolved)
{
set_render_bounds_xy(m_bounds, 0.0F, 0.0F, 1.0F, 1.0F);
environment local(env);
resolve_bounds(local, m_groupnode, groupmap, seen, false, true);
resolve_bounds(local, m_groupnode, groupmap, seen, true, false, true);
}
seen.pop_back();
}
Expand All @@ -1073,6 +1074,7 @@ void layout_group::resolve_bounds(
util::xml::data_node const &parentnode,
group_map &groupmap,
std::vector<layout_group const *> &seen,
bool empty,
bool repeat,
bool init)
{
Expand Down Expand Up @@ -1110,7 +1112,11 @@ void layout_group::resolve_bounds(
{
render_bounds itembounds;
env.parse_bounds(itemnode->get_child("bounds"), itembounds);
union_render_bounds(m_bounds, itembounds);
if (empty)
m_bounds = itembounds;
else
union_render_bounds(m_bounds, itembounds);
empty = false;
}
else if (!strcmp(itemnode->get_name(), "group"))
{
Expand All @@ -1119,7 +1125,11 @@ void layout_group::resolve_bounds(
{
render_bounds itembounds;
env.parse_bounds(itemboundsnode, itembounds);
union_render_bounds(m_bounds, itembounds);
if (empty)
m_bounds = itembounds;
else
union_render_bounds(m_bounds, itembounds);
empty = false;
}
else
{
Expand All @@ -1139,7 +1149,11 @@ void layout_group::resolve_bounds(
found->second.m_bounds.y0,
(orientation & ORIENTATION_SWAP_XY) ? (found->second.m_bounds.x0 + found->second.m_bounds.y1 - found->second.m_bounds.y0) : found->second.m_bounds.x1,
(orientation & ORIENTATION_SWAP_XY) ? (found->second.m_bounds.y0 + found->second.m_bounds.x1 - found->second.m_bounds.x0) : found->second.m_bounds.y1 };
union_render_bounds(m_bounds, itembounds);
if (empty)
m_bounds = itembounds;
else
union_render_bounds(m_bounds, itembounds);
empty = false;
}
}
else if (!strcmp(itemnode->get_name(), "repeat"))
Expand All @@ -1150,7 +1164,7 @@ void layout_group::resolve_bounds(
environment local(env);
for (int i = 0; !m_bounds_resolved && (count > i); ++i)
{
resolve_bounds(local, *itemnode, groupmap, seen, true, !i);
resolve_bounds(local, *itemnode, groupmap, seen, empty, true, !i);
local.increment_parameters();
}
}
Expand Down

0 comments on commit 60c035e

Please sign in to comment.