diff options
author | Nathan Woods <npwoods@mess.org> | 2016-07-10 17:07:41 -0400 |
---|---|---|
committer | Nathan Woods <npwoods@mess.org> | 2016-07-10 17:22:49 -0400 |
commit | 649e4c797bde09a6a6f2f9d819d568931355a501 (patch) | |
tree | ce44ba39eb502eeebc505c68baf3bf68e7cc7ef0 /src/frontend/mame/ui/menu.cpp | |
parent | cac7270d8f608a45db720b3fd2ed4a1687724905 (diff) |
Split "widgets" code out of ui::menu::global_state into a separate module
Diffstat (limited to 'src/frontend/mame/ui/menu.cpp')
-rw-r--r-- | src/frontend/mame/ui/menu.cpp | 108 |
1 files changed, 2 insertions, 106 deletions
diff --git a/src/frontend/mame/ui/menu.cpp b/src/frontend/mame/ui/menu.cpp index 4001c208b12..f3a95d81dca 100644 --- a/src/frontend/mame/ui/menu.cpp +++ b/src/frontend/mame/ui/menu.cpp @@ -82,61 +82,12 @@ bool menu::exclusive_input_pressed(int &iptkey, int key, int repeat) ***************************************************************************/ menu::global_state::global_state(running_machine &machine, ui_options const &options) - : m_machine(machine) + : widgets_manager(machine, options) + , m_machine(machine) , m_cleanup_callbacks() - , m_hilight_bitmap(std::make_unique<bitmap_argb32>(256, 1)) - , m_hilight_texture() - , m_hilight_main_bitmap(std::make_unique<bitmap_argb32>(1, 128)) - , m_hilight_main_texture() - , m_bgrnd_bitmap() - , m_bgrnd_texture() , m_stack() , m_free() { - render_manager &render(machine.render()); - auto const texture_free([&render](render_texture *texture) { render.texture_free(texture); }); - - // create a texture for hilighting items - for (unsigned x = 0; x < 256; ++x) - { - unsigned const alpha((x < 25) ? (0xff * x / 25) : (x > (256 - 25)) ? (0xff * (255 - x) / 25) : 0xff); - m_hilight_bitmap->pix32(0, x) = rgb_t(alpha, 0xff, 0xff, 0xff); - } - m_hilight_texture = texture_ptr(render.texture_alloc(), texture_free); - m_hilight_texture->set_bitmap(*m_hilight_bitmap, m_hilight_bitmap->cliprect(), TEXFORMAT_ARGB32); - - // create a texture for hilighting items in main menu - for (unsigned y = 0; y < 128; ++y) - { - constexpr unsigned r1(0), g1(169), b1 = (255); // any start color - constexpr unsigned r2(0), g2(39), b2 = (130); // any stop color - unsigned const r = r1 + (y * (r2 - r1) / 128); - unsigned const g = g1 + (y * (g2 - g1) / 128); - unsigned const b = b1 + (y * (b2 - b1) / 128); - m_hilight_main_bitmap->pix32(y, 0) = rgb_t(r, g, b); - } - m_hilight_main_texture = texture_ptr(render.texture_alloc(), texture_free); - m_hilight_main_texture->set_bitmap(*m_hilight_main_bitmap, m_hilight_main_bitmap->cliprect(), TEXFORMAT_ARGB32); - - // create a texture for arrow icons - m_arrow_texture = texture_ptr(render.texture_alloc(render_triangle), texture_free); - - // create a texture for main menu background - m_bgrnd_texture = texture_ptr(render.texture_alloc(render_texture::hq_scale), texture_free); - if (options.use_background_image() && (&machine.system() == &GAME_NAME(___empty))) - { - m_bgrnd_bitmap = std::make_unique<bitmap_argb32>(0, 0); - emu_file backgroundfile(".", OPEN_FLAG_READ); - render_load_jpeg(*m_bgrnd_bitmap, backgroundfile, nullptr, "background.jpg"); - - if (!m_bgrnd_bitmap->valid()) - render_load_png(*m_bgrnd_bitmap, backgroundfile, nullptr, "background.png"); - - if (m_bgrnd_bitmap->valid()) - m_bgrnd_texture->set_bitmap(*m_bgrnd_bitmap, m_bgrnd_bitmap->cliprect(), TEXFORMAT_ARGB32); - else - m_bgrnd_bitmap->reset(); - } } @@ -1206,61 +1157,6 @@ UINT32 menu::ui_handler(render_container &container, mame_ui_manager &mui) ***************************************************************************/ //------------------------------------------------- -// render_triangle - render a triangle that -// is used for up/down arrows and left/right -// indicators -//------------------------------------------------- - -void menu::render_triangle(bitmap_argb32 &dest, bitmap_argb32 &source, const rectangle &sbounds, void *param) -{ - int halfwidth = dest.width() / 2; - int height = dest.height(); - int x, y; - - // start with all-transparent - dest.fill(rgb_t(0x00,0x00,0x00,0x00)); - - // render from the tip to the bottom - for (y = 0; y < height; y++) - { - int linewidth = (y * (halfwidth - 1) + (height / 2)) * 255 * 2 / height; - UINT32 *target = &dest.pix32(y, halfwidth); - - // don't antialias if height < 12 - if (dest.height() < 12) - { - int pixels = (linewidth + 254) / 255; - if (pixels % 2 == 0) pixels++; - linewidth = pixels * 255; - } - - // loop while we still have data to generate - for (x = 0; linewidth > 0; x++) - { - int dalpha; - - // first column we only consume one pixel - if (x == 0) - { - dalpha = MIN(0xff, linewidth); - target[x] = rgb_t(dalpha,0xff,0xff,0xff); - } - - // remaining columns consume two pixels, one on each side - else - { - dalpha = MIN(0x1fe, linewidth); - target[x] = target[-x] = rgb_t(dalpha/2,0xff,0xff,0xff); - } - - // account for the weight we consumed */ - linewidth -= dalpha; - } - } -} - - -//------------------------------------------------- // highlight //------------------------------------------------- |