summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2026-05-03 05:15:48 +1000
committer Vas Crabb <vas@vastheman.com>2026-05-03 05:15:48 +1000
commit3dfb72cb6245da3cbdcafc02afd42315512d1557 (patch)
treec4f51d426d80e13012157bf2bb888bfeff95839c /src/emu
parent17adb7e5dbf0cd9a095be9550e5f1b3f5f25286f (diff)
ui: Added options to pause when showing menus and to open menus in active window.
* ui/ui.cpp: Dim all windows when paused. * ui/ui.cpp, menu/menu.cpp, ui/viewgfx.cpp: Broke assumption that UI elements will be drawn in the first window. * menu/menu.cpp: Allow menus to migrate between windows on activation. * ui/ui.cpp, ui/moptions.cpp, ui/submenu.cpp: Added an option to automatically pause when a menu is displayed. * Added an option to open menus in the most recently active window (alos affcts the profiler, speed display and popup messages).
Diffstat (limited to 'src/emu')
-rw-r--r--src/emu/render.cpp79
-rw-r--r--src/emu/render.h3
-rw-r--r--src/emu/uiinput.cpp7
-rw-r--r--src/emu/uiinput.h8
4 files changed, 49 insertions, 48 deletions
diff --git a/src/emu/render.cpp b/src/emu/render.cpp
index 37862f03ea1..13f7513c1ea 100644
--- a/src/emu/render.cpp
+++ b/src/emu/render.cpp
@@ -3443,66 +3443,51 @@ render_target *render_manager::target_by_index(int index) const
// fonts
//-------------------------------------------------
-float render_manager::ui_aspect(render_container *rc)
+float render_manager::ui_aspect(render_target &target)
{
- // work out if this is a UI container
- render_target *target = nullptr;
- if (!rc)
- {
- target = &ui_target();
- rc = target->ui_container();
- assert(rc);
- }
- else
- {
- for (render_target &t : m_targetlist)
- {
- if (t.ui_container() == rc)
- {
- target = &t;
- break;
- }
- }
- }
+ assert(target.ui_container());
+ // based on the orientation of the target, compute height/width or width/height
+ int const orient = orientation_add(target.orientation(), target.ui_container()->orientation());
float aspect;
+ if (!(orient & ORIENTATION_SWAP_XY))
+ aspect = float(target.height()) / float(target.width());
+ else
+ aspect = float(target.width()) / float(target.height());
- if (target)
+ // if we have a valid pixel aspect, apply that and return
+ if (target.pixel_aspect() != 0.0F)
{
- // UI container, aggregated multi-screen target
+ float pixel_aspect = target.pixel_aspect();
- // based on the orientation of the target, compute height/width or width/height
- int const orient = orientation_add(target->orientation(), rc->orientation());
- if (!(orient & ORIENTATION_SWAP_XY))
- aspect = float(target->height()) / float(target->width());
- else
- aspect = float(target->width()) / float(target->height());
+ if (orient & ORIENTATION_SWAP_XY)
+ pixel_aspect = 1.0F / pixel_aspect;
- // if we have a valid pixel aspect, apply that and return
- if (target->pixel_aspect() != 0.0f)
- {
- float pixel_aspect = target->pixel_aspect();
+ return aspect / pixel_aspect;
+ }
- if (orient & ORIENTATION_SWAP_XY)
- pixel_aspect = 1.0f / pixel_aspect;
+ // clamp for extreme proportions
+ return std::clamp(aspect, 0.66F, 1.5F);
+}
- return aspect /= pixel_aspect;
- }
- }
- else
+float render_manager::ui_aspect(render_container &rc)
+{
+ // deal with UI containers
+ for (render_target &target : m_targetlist)
{
- // single screen container
-
- // based on the orientation of the target, compute height/width or width/height
- int const orient = rc->orientation();
- if (!(orient & ORIENTATION_SWAP_XY))
- aspect = (float)rc->screen()->visible_area().height() / (float)rc->screen()->visible_area().width();
- else
- aspect = (float)rc->screen()->visible_area().width() / (float)rc->screen()->visible_area().height();
+ if (target.ui_container() == &rc)
+ return ui_aspect(target);
}
+ // based on the orientation of the target, compute height/width or width/height
+ assert(rc.screen());
+ int const orient = rc.orientation();
+ float const viswidth = rc.screen()->visible_area().width();
+ float const visheight = rc.screen()->visible_area().height();
+ float const aspect = !(orient & ORIENTATION_SWAP_XY) ? (visheight / viswidth) : (viswidth / visheight);
+
// clamp for extreme proportions
- return std::clamp(aspect, 0.66f, 1.5f);
+ return std::clamp(aspect, 0.66F, 1.5F);
}
diff --git a/src/emu/render.h b/src/emu/render.h
index c4c0f504edd..afdbc4b6c42 100644
--- a/src/emu/render.h
+++ b/src/emu/render.h
@@ -679,7 +679,8 @@ public:
// UI targets
render_target &ui_target() const { assert(m_ui_target != nullptr); return *m_ui_target; }
void set_ui_target(render_target &target) { m_ui_target = &target; }
- float ui_aspect(render_container *rc = nullptr);
+ float ui_aspect(render_target &target); // gets result for target's UI container - target must not be a hidden target with no UI container
+ float ui_aspect(render_container &rc); // rc must be a screen container or a UI container for a render target; requires an O(n) scan of render targets
// UI containers
render_container &ui_container() const { assert(ui_target().ui_container()); return *ui_target().ui_container(); }
diff --git a/src/emu/uiinput.cpp b/src/emu/uiinput.cpp
index 12ba8a08bb0..55a64fd8cd7 100644
--- a/src/emu/uiinput.cpp
+++ b/src/emu/uiinput.cpp
@@ -35,6 +35,8 @@ enum
ui_input_manager::ui_input_manager(running_machine &machine)
: m_machine(machine)
+ , m_focused_target(nullptr)
+ , m_last_focused_target(nullptr)
, m_presses_enabled(true)
, m_events_start(0)
, m_events_end(0)
@@ -192,6 +194,8 @@ bool ui_input_manager::pressed_repeat(int code, int speed)
void ui_input_manager::push_window_focus_event(render_target *target)
{
+ m_focused_target = m_last_focused_target = target;
+
ui_event event = { ui_event::type::NONE };
event.event_type = ui_event::type::WINDOW_FOCUS;
event.target = target;
@@ -205,6 +209,9 @@ void ui_input_manager::push_window_focus_event(render_target *target)
void ui_input_manager::push_window_defocus_event(render_target *target)
{
+ if (m_focused_target == target)
+ m_focused_target = nullptr;
+
ui_event event = { ui_event::type::NONE };
event.event_type = ui_event::type::WINDOW_DEFOCUS;
event.target = target;
diff --git a/src/emu/uiinput.h b/src/emu/uiinput.h
index 54170bad7ec..2fba1983f36 100644
--- a/src/emu/uiinput.h
+++ b/src/emu/uiinput.h
@@ -88,6 +88,10 @@ public:
// return true if a key down for the given user interface sequence is detected, or if autorepeat at the given speed is triggered
bool pressed_repeat(int code, int speed);
+ // get current or most recently focused render target
+ render_target *focused_target() const { return m_focused_target; }
+ render_target *last_focused_target() const { return m_last_focused_target; }
+
// getters
running_machine &machine() const { return m_machine; }
@@ -109,6 +113,10 @@ private:
// internal state
running_machine & m_machine;
+ // track focused render target;
+ render_target * m_focused_target;
+ render_target * m_last_focused_target;
+
// pressed states; retrieved with pressed() or pressed_repeat()
bool m_presses_enabled;
osd_ticks_t m_next_repeat[IPT_COUNT];