From 755c23a8e7b2e8f9c3eceb37dc722b4dbf1153d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Banaan=20Ananas?= Date: Sat, 11 Feb 2012 16:53:30 +0000 Subject: [PATCH] add support for simple text alignment in layout files, defaulting to center eg. align to the left of the textbox like this: --- src/emu/rendlay.c | 22 +++++++++++++++++++++- src/emu/rendlay.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/emu/rendlay.c b/src/emu/rendlay.c index 27610f63f98..377dbbf9cf2 100644 --- a/src/emu/rendlay.c +++ b/src/emu/rendlay.c @@ -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()); diff --git a/src/emu/rendlay.h b/src/emu/rendlay.h index 463882e96ff..bdc65553d45 100644 --- a/src/emu/rendlay.h +++ b/src/emu/rendlay.h @@ -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