Skip to content

Commit a7273a8

Browse files
committed
[[ FullscreenMode ]] Fix popup menu location & mouse mapping on Win32
[[ FullscreenMode ]] Update localLoc & globalLoc functions to work with view transform
1 parent a84aa20 commit a7273a8

5 files changed

Lines changed: 68 additions & 17 deletions

File tree

engine/src/funcs.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2620,8 +2620,14 @@ Exec_stat MCGlobalLoc::eval(MCExecPoint &ep)
26202620
(EE_GLOBALLOC_NAP, line, pos, ep.getsvalue());
26212621
return ES_ERROR;
26222622
}
2623-
MCRectangle trect = MCdefaultstackptr->getrect();
2624-
ep.setpoint(x + trect.x, y + trect.y - MCdefaultstackptr->getscroll());
2623+
2624+
// IM-2013-10-09: [[ FullscreenMode ]] Update to use stack coord conversion methods
2625+
MCPoint t_loc;
2626+
t_loc = MCPointMake(x, y);
2627+
t_loc = MCdefaultstackptr->stacktogloballoc(t_loc);
2628+
2629+
ep.setpoint(t_loc.x, t_loc.y);
2630+
26252631
return ES_NORMAL;
26262632
#endif /* MCGlobalLoc */
26272633
}
@@ -3264,8 +3270,14 @@ Exec_stat MCLocalLoc::eval(MCExecPoint &ep)
32643270
(EE_LOCALLOC_NAP, line, pos, ep.getsvalue());
32653271
return ES_ERROR;
32663272
}
3267-
MCRectangle trect = MCdefaultstackptr->getrect();
3268-
ep.setpoint(x - trect.x, y - trect.y + MCdefaultstackptr->getscroll());
3273+
3274+
// IM-2013-10-09: [[ FullscreenMode ]] Update to use stack coord conversion methods
3275+
MCPoint t_loc;
3276+
t_loc = MCPointMake(x, y);
3277+
t_loc = MCdefaultstackptr->globaltostackloc(t_loc);
3278+
3279+
ep.setpoint(t_loc.x, t_loc.y);
3280+
32693281
return ES_NORMAL;
32703282
#endif /* MCLocalLoc */
32713283
}

engine/src/stack.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class MCStack : public MCObject
314314
MCRectangle view_constrainstackviewport(const MCRectangle &p_viewport);
315315

316316
// Return the rect of the view in logical screen coords.
317-
MCRectangle view_getrect(void);
317+
MCRectangle view_getrect(void) const;
318318

319319
// Set view to fullscreen
320320
void view_setfullscreen(bool p_fullscreen);
@@ -391,6 +391,10 @@ class MCStack : public MCObject
391391
MCPoint stacktowindowloc(const MCPoint &p_stackloc) const;
392392
MCPoint windowtostackloc(const MCPoint &p_windowloc) const;
393393

394+
// IM-2013-10-09: [[ FullscreenMode ]] transform to / from stack & global coords, taking stack scroll into account
395+
MCPoint stacktogloballoc(const MCPoint &p_stackloc) const;
396+
MCPoint globaltostackloc(const MCPoint &p_globalloc) const;
397+
394398
void setgeom();
395399
//////////
396400

engine/src/stack2.cpp

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,12 +1860,13 @@ Exec_stat MCStack::openrect(const MCRectangle &rel, Window_mode wm, MCStack *par
18601860
MCscreen->querymouse(trect.x, trect.y);
18611861
else
18621862
{
1863-
/* OVERHAUL - REVISIT [[ FullscreenMode ]] */
18641863
//WEBREV
1865-
MCRectangle srect = MCmousestackptr->getrect();
1866-
trect.x = MCmousex + srect.x;
1867-
trect.y = MCmousey + srect.y
1868-
- MCmousestackptr->getscroll();
1864+
// IM-2013-10-09: [[ FullscreenMode ]] Reimplement using MCStack::stacktogloballoc
1865+
MCPoint t_globalloc;
1866+
t_globalloc = MCmousestackptr->stacktogloballoc(MCPointMake(MCmousex, MCmousey));
1867+
1868+
trect.x = t_globalloc.x;
1869+
trect.y = t_globalloc.y;
18691870
}
18701871
trect.width = trect.height = 1;
18711872
positionrel(trect, OP_ALIGN_LEFT, OP_ALIGN_TOP);
@@ -2692,3 +2693,33 @@ MCPoint MCStack::stacktowindowloc(const MCPoint &p_stackloc) const
26922693
}
26932694

26942695
////////////////////////////////////////////////////////////////////////////////
2696+
2697+
MCPoint MCStack::globaltostackloc(const MCPoint &p_windowloc) const
2698+
{
2699+
MCPoint t_loc;
2700+
t_loc = p_windowloc;
2701+
2702+
MCRectangle t_view_rect;
2703+
t_view_rect = view_getrect();
2704+
2705+
t_loc.x -= t_view_rect.x;
2706+
t_loc.y -= t_view_rect.y;
2707+
2708+
return windowtostackloc(t_loc);
2709+
}
2710+
2711+
MCPoint MCStack::stacktogloballoc(const MCPoint &p_stackloc) const
2712+
{
2713+
MCPoint t_loc;
2714+
t_loc = stacktowindowloc(p_stackloc);
2715+
2716+
MCRectangle t_view_rect;
2717+
t_view_rect = view_getrect();
2718+
2719+
t_loc.x += t_view_rect.x;
2720+
t_loc.y += t_view_rect.y;
2721+
2722+
return t_loc;
2723+
}
2724+
2725+
////////////////////////////////////////////////////////////////////////////////

engine/src/stack3.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
5959
#include "license.h"
6060
#include "stacksecurity.h"
6161

62+
#include "graphics_util.h"
63+
6264
#define STACK_EXTRA_ORIGININFO (1U << 0)
6365

6466
IO_stat MCStack::load_substacks(IO_handle stream, const char *version)
@@ -1267,14 +1269,16 @@ MCStack *MCStack::findsubstackid(uint4 fid)
12671269

12681270
void MCStack::translatecoords(MCStack *dest, int2 &x, int2 &y)
12691271
{
1270-
/* OVERHAUL - REVISIT [[ Fullscreen Mode ]] - redo using view_stacktoviewrect, etc */
12711272
// WEBREV
1272-
MCRectangle srect;
1273-
1274-
srect = getrect();
1273+
// IM-2013-10-09: [[ FullscreenMode ]] Reimplement using MCStack::stacktogloballoc
1274+
MCPoint t_loc;
1275+
t_loc = MCPointMake(x, y);
1276+
1277+
t_loc = stacktogloballoc(t_loc);
1278+
t_loc = dest->globaltostackloc(t_loc);
12751279

1276-
x += srect.x - dest->rect.x;
1277-
y += srect.y - dest->rect.y - getscroll();
1280+
x = t_loc.x;
1281+
y = t_loc.y;
12781282
}
12791283

12801284
uint4 MCStack::newid()

engine/src/stackview.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ MCGAffineTransform MCStack::view_getviewtransform(void) const
179179
return m_view_transform;
180180
}
181181

182-
MCRectangle MCStack::view_getrect(void)
182+
MCRectangle MCStack::view_getrect(void) const
183183
{
184184
return m_view_rect;
185185
}

0 commit comments

Comments
 (0)