summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/render.cpp
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2021-06-04 07:29:56 -0700
committer Aaron Giles <aaron@aarongiles.com>2021-06-04 07:29:56 -0700
commit43a5da3703baf8ab37a2ef29d6f5791d2db385bd (patch)
treed1560a73d5a677389fc97539217e0122c524e07f /src/emu/render.cpp
parent3f3e0eda38bc08c9ad67ae46543ff7a0f45a856e (diff)
Add support for dragging position-animated layout items.draggable-layout
Diffstat (limited to 'src/emu/render.cpp')
-rw-r--r--src/emu/render.cpp31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/emu/render.cpp b/src/emu/render.cpp
index b7a66b7bd2a..640e100653b 100644
--- a/src/emu/render.cpp
+++ b/src/emu/render.cpp
@@ -1493,7 +1493,7 @@ bool render_target::map_point_container(s32 target_x, s32 target_y, render_conta
// field, if possible
//-------------------------------------------------
-bool render_target::map_point_input(s32 target_x, s32 target_y, ioport_port *&input_port, ioport_value &input_mask, float &input_x, float &input_y)
+bool render_target::map_point_input(s32 target_x, s32 target_y, ioport_port *&input_port, ioport_value &input_mask, item_handle &input_item, float &input_x, float &input_y)
{
std::pair<float, float> target_f(map_point_internal(target_x, target_y));
if (m_orientation & ORIENTATION_FLIP_X)
@@ -1535,8 +1535,9 @@ bool render_target::map_point_input(s32 target_x, s32 target_y, ioport_port *&in
{
// point successfully mapped
std::tie(input_port, input_mask) = item.input_tag_and_mask();
- input_x = (target_f.first - bounds.x0) / bounds.width();
- input_y = (target_f.second - bounds.y0) / bounds.height();
+ input_x = target_f.first - ((bounds.x0 + bounds.x1) / 2);
+ input_y = target_f.second - ((bounds.y0 + bounds.y1) / 2);
+ input_item = reinterpret_cast<item_handle>(&item);
return true;
}
else
@@ -1551,11 +1552,35 @@ bool render_target::map_point_input(s32 target_x, s32 target_y, ioport_port *&in
input_port = nullptr;
input_mask = 0;
input_x = input_y = -1.0f;
+ input_item = nullptr;
return false;
}
//-------------------------------------------------
+// interpolated_value - return the interpolated
+// value of an item given x,y coordinates and
+// an x,y offset from the item's center
+//-------------------------------------------------
+
+ioport_value render_target::interpolated_value(s32 target_x, s32 target_y, item_handle item, float xoffs, float yoffs)
+{
+ std::pair<float, float> target_f(map_point_internal(target_x, target_y));
+ if (m_orientation & ORIENTATION_FLIP_X)
+ target_f.first = 1.0f - target_f.first;
+ if (m_orientation & ORIENTATION_FLIP_Y)
+ target_f.second = 1.0f - target_f.second;
+ if (m_orientation & ORIENTATION_SWAP_XY)
+ std::swap(target_f.first, target_f.second);
+
+ target_f.first -= xoffs;
+ target_f.second -= yoffs;
+
+ return reinterpret_cast<layout_view::item *>(item)->state_from_position(target_f.first, target_f.second);
+}
+
+
+//-------------------------------------------------
// invalidate_all - if any of our primitive lists
// contain a reference to the given pointer,
// clear them