add support for simple text alignment in layout files, defaulting to center

eg. align to the left of the textbox like this:
<text string="hello there" align="1">
This commit is contained in:
Michaël Banaan Ananas 2012-02-11 16:53:30 +00:00
parent 4c31089ae1
commit 755c23a8e7
2 changed files with 22 additions and 1 deletions

View File

@ -625,6 +625,7 @@ layout_element::component::component(running_machine &machine, xml_data_node &co
{
m_type = CTYPE_TEXT;
m_string = xml_get_attribute_string_with_subst(machine, compnode, "string", "");
m_textalign = xml_get_attribute_int_with_subst(machine, compnode, "align", 0);
}
// dotmatrix nodes
@ -846,7 +847,26 @@ void layout_element::component::draw_text(running_machine &machine, bitmap_argb3
break;
aspect *= 0.9f;
}
INT32 curx = bounds.min_x + (bounds.width() - width) / 2;
// get alignment
INT32 curx;
switch (m_textalign)
{
// left
case 1:
curx = bounds.min_x;
break;
// right
case 2:
curx = bounds.max_x - width;
break;
// default to center
default:
curx = bounds.min_x + (bounds.width() - width) / 2;
break;
}
// allocate a temporary bitmap
bitmap_argb32 tempbitmap(dest.width(), dest.height());

View File

@ -152,6 +152,7 @@ private:
render_bounds m_bounds; // bounds of the element
render_color m_color; // color of the element
astring m_string; // string for text components
int m_textalign; // text alignment to box
bitmap_argb32 m_bitmap; // source bitmap for images
astring m_dirname; // directory name of image file (for lazy loading)
emu_file * m_file; // file object for reading image/alpha files