summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/ui.c
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2010-10-13 06:20:10 +0000
committer Aaron Giles <aaron@aarongiles.com>2010-10-13 06:20:10 +0000
commit3beb0ec2462e3251000e4c479bbaeaf775cb44d2 (patch)
tree8ede7cad7423199a79f6abc18df352d564d49384 /src/emu/ui.c
parentf391c5f8d797a190a789ab3bc35e0e3fbce5df29 (diff)
Converted render.c objects into C++ objects. Updated all callers.
Diffstat (limited to 'src/emu/ui.c')
-rw-r--r--src/emu/ui.c155
1 files changed, 73 insertions, 82 deletions
diff --git a/src/emu/ui.c b/src/emu/ui.c
index db551a63cd5..872b34b43fe 100644
--- a/src/emu/ui.c
+++ b/src/emu/ui.c
@@ -240,7 +240,7 @@ int ui_init(running_machine *machine)
machine->add_notifier(MACHINE_NOTIFY_EXIT, ui_exit);
/* allocate the font and messagebox string */
- ui_font = render_font_alloc("ui.bdf");
+ ui_font = render_font_alloc(*machine, "ui.bdf");
/* initialize the other UI bits */
ui_menu_init(machine);
@@ -374,7 +374,7 @@ void ui_set_startup_text(running_machine *machine, const char *text, int force)
void ui_update_and_render(running_machine *machine, render_container *container)
{
/* always start clean */
- render_container_empty(container);
+ container->empty();
/* if we're paused, dim the whole screen */
if (machine->phase() >= MACHINE_PHASE_RESET && (single_step || machine->paused()))
@@ -385,7 +385,7 @@ void ui_update_and_render(running_machine *machine, render_container *container)
if (alpha > 255)
alpha = 255;
if (alpha >= 0)
- render_container_add_rect(container, 0.0f, 0.0f, 1.0f, 1.0f, MAKE_ARGB(alpha,0x00,0x00,0x00), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
+ container->add_rect(0.0f, 0.0f, 1.0f, 1.0f, MAKE_ARGB(alpha,0x00,0x00,0x00), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
}
/* render any cheat stuff at the bottom */
@@ -422,17 +422,14 @@ render_font *ui_get_font(void)
of a line
-------------------------------------------------*/
-float ui_get_line_height(void)
+float ui_get_line_height(running_machine &machine)
{
INT32 raw_font_pixel_height = render_font_get_pixel_height(ui_font);
- INT32 target_pixel_width, target_pixel_height;
+ render_target &ui_target = machine.render().ui_target();
+ INT32 target_pixel_height = ui_target.height();
float one_to_one_line_height;
- float target_aspect;
float scale_factor;
- /* get info about the UI target */
- render_target_get_bounds(render_get_ui_target(), &target_pixel_width, &target_pixel_height, &target_aspect);
-
/* compute the font pixel height at the nominal size */
one_to_one_line_height = (float)raw_font_pixel_height / (float)target_pixel_height;
@@ -470,9 +467,9 @@ float ui_get_line_height(void)
single character
-------------------------------------------------*/
-float ui_get_char_width(unicode_char ch)
+float ui_get_char_width(running_machine &machine, unicode_char ch)
{
- return render_font_get_char_width(ui_font, ui_get_line_height(), render_get_ui_aspect(), ch);
+ return render_font_get_char_width(ui_font, ui_get_line_height(machine), machine.render().ui_aspect(), ch);
}
@@ -481,9 +478,9 @@ float ui_get_char_width(unicode_char ch)
character string
-------------------------------------------------*/
-float ui_get_string_width(const char *s)
+float ui_get_string_width(running_machine &machine, const char *s)
{
- return render_font_get_utf8string_width(ui_font, ui_get_line_height(), render_get_ui_aspect(), s);
+ return render_font_get_utf8string_width(ui_font, ui_get_line_height(machine), machine.render().ui_aspect(), s);
}
@@ -495,11 +492,11 @@ float ui_get_string_width(const char *s)
void ui_draw_outlined_box(render_container *container, float x0, float y0, float x1, float y1, rgb_t backcolor)
{
- render_container_add_rect(container, x0, y0, x1, y1, backcolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
- render_container_add_line(container, x0, y0, x1, y0, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
- render_container_add_line(container, x1, y0, x1, y1, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
- render_container_add_line(container, x1, y1, x0, y1, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
- render_container_add_line(container, x0, y1, x0, y0, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
+ container->add_rect(x0, y0, x1, y1, backcolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
+ container->add_line(x0, y0, x1, y0, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
+ container->add_line(x1, y0, x1, y1, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
+ container->add_line(x1, y1, x0, y1, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
+ container->add_line(x0, y1, x0, y0, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
}
@@ -521,7 +518,8 @@ void ui_draw_text(render_container *container, const char *buf, float x, float y
void ui_draw_text_full(render_container *container, const char *origs, float x, float y, float origwrapwidth, int justify, int wrap, int draw, rgb_t fgcolor, rgb_t bgcolor, float *totalwidth, float *totalheight)
{
- float lineheight = ui_get_line_height();
+ running_machine &machine = container->manager().machine();
+ float lineheight = ui_get_line_height(machine);
const char *ends = origs + strlen(origs);
float wrapwidth = origwrapwidth;
const char *s = origs;
@@ -576,7 +574,7 @@ void ui_draw_text_full(render_container *container, const char *origs, float x,
break;
/* get the width of this character */
- chwidth = ui_get_char_width(schar);
+ chwidth = ui_get_char_width(machine, schar);
/* if we hit a space, remember the location and width *without* the space */
if (schar == ' ')
@@ -620,7 +618,7 @@ void ui_draw_text_full(render_container *container, const char *origs, float x,
if (scharcount == -1)
break;
- curwidth -= ui_get_char_width(schar);
+ curwidth -= ui_get_char_width(machine, schar);
}
}
@@ -628,7 +626,7 @@ void ui_draw_text_full(render_container *container, const char *origs, float x,
else if (wrap == WRAP_TRUNCATE)
{
/* add in the width of the ... */
- curwidth += 3.0f * ui_get_char_width('.');
+ curwidth += 3.0f * ui_get_char_width(machine, '.');
/* while we are above the wrap width, back up one character */
while (curwidth > wrapwidth && s > linestart)
@@ -639,7 +637,7 @@ void ui_draw_text_full(render_container *container, const char *origs, float x,
if (scharcount == -1)
break;
- curwidth -= ui_get_char_width(schar);
+ curwidth -= ui_get_char_width(machine, schar);
}
}
}
@@ -656,7 +654,7 @@ void ui_draw_text_full(render_container *container, const char *origs, float x,
/* if opaque, add a black box */
if (draw == DRAW_OPAQUE)
- render_container_add_rect(container, curx, cury, curx + curwidth, cury + lineheight, bgcolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
+ container->add_rect(curx, cury, curx + curwidth, cury + lineheight, bgcolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
/* loop from the line start and add the characters */
while (linestart < s)
@@ -669,8 +667,8 @@ void ui_draw_text_full(render_container *container, const char *origs, float x,
if (draw != DRAW_NONE)
{
- render_container_add_char(container, curx, cury, lineheight, render_get_ui_aspect(), fgcolor, ui_font, linechar);
- curx += ui_get_char_width(linechar);
+ container->add_char(curx, cury, lineheight, machine.render().ui_aspect(), fgcolor, *ui_font, linechar);
+ curx += ui_get_char_width(machine, linechar);
}
linestart += linecharcount;
}
@@ -678,12 +676,12 @@ void ui_draw_text_full(render_container *container, const char *origs, float x,
/* append ellipses if needed */
if (wrap == WRAP_TRUNCATE && *s != 0 && draw != DRAW_NONE)
{
- render_container_add_char(container, curx, cury, lineheight, render_get_ui_aspect(), fgcolor, ui_font, '.');
- curx += ui_get_char_width('.');
- render_container_add_char(container, curx, cury, lineheight, render_get_ui_aspect(), fgcolor, ui_font, '.');
- curx += ui_get_char_width('.');
- render_container_add_char(container, curx, cury, lineheight, render_get_ui_aspect(), fgcolor, ui_font, '.');
- curx += ui_get_char_width('.');
+ container->add_char(curx, cury, lineheight, machine.render().ui_aspect(), fgcolor, *ui_font, '.');
+ curx += ui_get_char_width(machine, '.');
+ container->add_char(curx, cury, lineheight, machine.render().ui_aspect(), fgcolor, *ui_font, '.');
+ curx += ui_get_char_width(machine, '.');
+ container->add_char(curx, cury, lineheight, machine.render().ui_aspect(), fgcolor, *ui_font, '.');
+ curx += ui_get_char_width(machine, '.');
}
/* if we're not word-wrapping, we're done */
@@ -732,7 +730,7 @@ void ui_draw_text_box(render_container *container, const char *text, int justify
ui_draw_text_full(container, text, 0, 0, 1.0f - 2.0f * UI_BOX_LR_BORDER,
justify, WRAP_WORD, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &target_width, &target_height);
if (target_height > 1.0f - 2.0f * UI_BOX_TB_BORDER)
- target_height = floor((1.0f - 2.0f * UI_BOX_TB_BORDER) / ui_get_line_height()) * ui_get_line_height();
+ target_height = floor((1.0f - 2.0f * UI_BOX_TB_BORDER) / ui_get_line_height(container->manager().machine())) * ui_get_line_height(container->manager().machine());
/* determine the target location */
target_x = xpos - 0.5f * target_width;
@@ -1848,18 +1846,17 @@ static INT32 slider_refresh(running_machine *machine, void *arg, astring *string
static INT32 slider_brightness(running_machine *machine, void *arg, astring *string, INT32 newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
- render_container *container = render_container_get_screen(screen);
- render_container_user_settings settings;
+ render_container::user_settings settings;
- render_container_get_user_settings(container, &settings);
+ screen->container().get_user_settings(settings);
if (newval != SLIDER_NOCHANGE)
{
- settings.brightness = (float)newval * 0.001f;
- render_container_set_user_settings(container, &settings);
+ settings.m_brightness = (float)newval * 0.001f;
+ screen->container().set_user_settings(settings);
}
if (string != NULL)
- string->printf("%.3f", settings.brightness);
- return floor(settings.brightness * 1000.0f + 0.5f);
+ string->printf("%.3f", settings.m_brightness);
+ return floor(settings.m_brightness * 1000.0f + 0.5f);
}
@@ -1871,18 +1868,17 @@ static INT32 slider_brightness(running_machine *machine, void *arg, astring *str
static INT32 slider_contrast(running_machine *machine, void *arg, astring *string, INT32 newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
- render_container *container = render_container_get_screen(screen);
- render_container_user_settings settings;
+ render_container::user_settings settings;
- render_container_get_user_settings(container, &settings);
+ screen->container().get_user_settings(settings);
if (newval != SLIDER_NOCHANGE)
{
- settings.contrast = (float)newval * 0.001f;
- render_container_set_user_settings(container, &settings);
+ settings.m_contrast = (float)newval * 0.001f;
+ screen->container().set_user_settings(settings);
}
if (string != NULL)
- string->printf("%.3f", settings.contrast);
- return floor(settings.contrast * 1000.0f + 0.5f);
+ string->printf("%.3f", settings.m_contrast);
+ return floor(settings.m_contrast * 1000.0f + 0.5f);
}
@@ -1893,18 +1889,17 @@ static INT32 slider_contrast(running_machine *machine, void *arg, astring *strin
static INT32 slider_gamma(running_machine *machine, void *arg, astring *string, INT32 newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
- render_container *container = render_container_get_screen(screen);
- render_container_user_settings settings;
+ render_container::user_settings settings;
- render_container_get_user_settings(container, &settings);
+ screen->container().get_user_settings(settings);
if (newval != SLIDER_NOCHANGE)
{
- settings.gamma = (float)newval * 0.001f;
- render_container_set_user_settings(container, &settings);
+ settings.m_gamma = (float)newval * 0.001f;
+ screen->container().set_user_settings(settings);
}
if (string != NULL)
- string->printf("%.3f", settings.gamma);
- return floor(settings.gamma * 1000.0f + 0.5f);
+ string->printf("%.3f", settings.m_gamma);
+ return floor(settings.m_gamma * 1000.0f + 0.5f);
}
@@ -1916,18 +1911,17 @@ static INT32 slider_gamma(running_machine *machine, void *arg, astring *string,
static INT32 slider_xscale(running_machine *machine, void *arg, astring *string, INT32 newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
- render_container *container = render_container_get_screen(screen);
- render_container_user_settings settings;
+ render_container::user_settings settings;
- render_container_get_user_settings(container, &settings);
+ screen->container().get_user_settings(settings);
if (newval != SLIDER_NOCHANGE)
{
- settings.xscale = (float)newval * 0.001f;
- render_container_set_user_settings(container, &settings);
+ settings.m_xscale = (float)newval * 0.001f;
+ screen->container().set_user_settings(settings);
}
if (string != NULL)
- string->printf("%.3f", settings.xscale);
- return floor(settings.xscale * 1000.0f + 0.5f);
+ string->printf("%.3f", settings.m_xscale);
+ return floor(settings.m_xscale * 1000.0f + 0.5f);
}
@@ -1939,18 +1933,17 @@ static INT32 slider_xscale(running_machine *machine, void *arg, astring *string,
static INT32 slider_yscale(running_machine *machine, void *arg, astring *string, INT32 newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
- render_container *container = render_container_get_screen(screen);
- render_container_user_settings settings;
+ render_container::user_settings settings;
- render_container_get_user_settings(container, &settings);
+ screen->container().get_user_settings(settings);
if (newval != SLIDER_NOCHANGE)
{
- settings.yscale = (float)newval * 0.001f;
- render_container_set_user_settings(container, &settings);
+ settings.m_yscale = (float)newval * 0.001f;
+ screen->container().set_user_settings(settings);
}
if (string != NULL)
- string->printf("%.3f", settings.yscale);
- return floor(settings.yscale * 1000.0f + 0.5f);
+ string->printf("%.3f", settings.m_yscale);
+ return floor(settings.m_yscale * 1000.0f + 0.5f);
}
@@ -1962,18 +1955,17 @@ static INT32 slider_yscale(running_machine *machine, void *arg, astring *string,
static INT32 slider_xoffset(running_machine *machine, void *arg, astring *string, INT32 newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
- render_container *container = render_container_get_screen(screen);
- render_container_user_settings settings;
+ render_container::user_settings settings;
- render_container_get_user_settings(container, &settings);
+ screen->container().get_user_settings(settings);
if (newval != SLIDER_NOCHANGE)
{
- settings.xoffset = (float)newval * 0.001f;
- render_container_set_user_settings(container, &settings);
+ settings.m_xoffset = (float)newval * 0.001f;
+ screen->container().set_user_settings(settings);
}
if (string != NULL)
- string->printf("%.3f", settings.xoffset);
- return floor(settings.xoffset * 1000.0f + 0.5f);
+ string->printf("%.3f", settings.m_xoffset);
+ return floor(settings.m_xoffset * 1000.0f + 0.5f);
}
@@ -1985,18 +1977,17 @@ static INT32 slider_xoffset(running_machine *machine, void *arg, astring *string
static INT32 slider_yoffset(running_machine *machine, void *arg, astring *string, INT32 newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
- render_container *container = render_container_get_screen(screen);
- render_container_user_settings settings;
+ render_container::user_settings settings;
- render_container_get_user_settings(container, &settings);
+ screen->container().get_user_settings(settings);
if (newval != SLIDER_NOCHANGE)
{
- settings.yoffset = (float)newval * 0.001f;
- render_container_set_user_settings(container, &settings);
+ settings.m_yoffset = (float)newval * 0.001f;
+ screen->container().set_user_settings(settings);
}
if (string != NULL)
- string->printf("%.3f", settings.yoffset);
- return floor(settings.yoffset * 1000.0f + 0.5f);
+ string->printf("%.3f", settings.m_yoffset);
+ return floor(settings.m_yoffset * 1000.0f + 0.5f);
}