Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit f827a45

Browse files
committed
[[ FullscreenMode ]] Implementation of fullscreen scaling modes on iOS
1 parent 7e84649 commit f827a45

18 files changed

Lines changed: 286 additions & 83 deletions

engine/engine-mobile.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@
265265
E84A254E1680BFFD00EA7ACC /* image_rep.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E84A254C1680BFF600EA7ACC /* image_rep.cpp */; };
266266
E85A91BF16C2B4D300C07FA9 /* stackcache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E85A91BE16C2B4D300C07FA9 /* stackcache.cpp */; };
267267
E86481931439BCE100775960 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E86481921439BCE100775960 /* StoreKit.framework */; };
268+
E8B6EE1417F0A1C900F77E0E /* stackview.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E8B6EE1317F0A1C900F77E0E /* stackview.cpp */; };
268269
E8C22C46177B1700003785D3 /* cgimageutil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E8C22C45177B1700003785D3 /* cgimageutil.cpp */; };
269270
E8C22C53177B1BED003785D3 /* libgraphicsmobile.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E8C22C4C177B1B79003785D3 /* libgraphicsmobile.a */; };
270271
E8C22C54177B1BED003785D3 /* libskiamobile.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E8C22C52177B1B87003785D3 /* libskiamobile.a */; };
@@ -894,6 +895,7 @@
894895
E89112EB148E73EB00B554CF /* mbldialog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mbldialog.cpp; path = src/mbldialog.cpp; sourceTree = "<group>"; };
895896
E89A45D314EE7603007250AA /* mblnotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mblnotification.h; path = src/mblnotification.h; sourceTree = "<group>"; };
896897
E8B4FDD8152CAF8300CBAF90 /* mbliphonefs.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = mbliphonefs.mm; path = src/mbliphonefs.mm; sourceTree = "<group>"; };
898+
E8B6EE1317F0A1C900F77E0E /* stackview.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = stackview.cpp; path = src/stackview.cpp; sourceTree = "<group>"; };
897899
E8C22C45177B1700003785D3 /* cgimageutil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cgimageutil.cpp; path = src/cgimageutil.cpp; sourceTree = "<group>"; };
898900
E8C22C47177B1B78003785D3 /* libgraphics-mobile.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "libgraphics-mobile.xcodeproj"; path = "../libgraphics/libgraphics-mobile.xcodeproj"; sourceTree = "<group>"; };
899901
E8C22C4D177B1B87003785D3 /* libskia-mobile.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "libskia-mobile.xcodeproj"; path = "../thirdparty/libskia/libskia-mobile.xcodeproj"; sourceTree = "<group>"; };
@@ -1507,6 +1509,7 @@
15071509
4DD3DEE61040ADEF00CAC7EF /* stacke.cpp */,
15081510
4DD3DEE51040ADEF00CAC7EF /* stacklst.cpp */,
15091511
4DD3DEE41040ADEF00CAC7EF /* stacklst.h */,
1512+
E8B6EE1317F0A1C900F77E0E /* stackview.cpp */,
15101513
4DD3DF061040ADFC00CAC7EF /* styledtext.cpp */,
15111514
4DD3DF051040ADFC00CAC7EF /* styledtext.h */,
15121515
4DD3DF111040ADFC00CAC7EF /* tooltip.cpp */,
@@ -2173,6 +2176,7 @@
21732176
E8C22E57177B2884003785D3 /* imagelist.cpp in Sources */,
21742177
E8C22E73177B2960003785D3 /* graphicscontext.cpp in Sources */,
21752178
E8C22E75177B2B53003785D3 /* mbltheme.cpp in Sources */,
2179+
E8B6EE1417F0A1C900F77E0E /* stackview.cpp in Sources */,
21762180
);
21772181
runOnlyForDeploymentPostprocessing = 0;
21782182
};

engine/src/eventqueue.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
3030
#include "dispatch.h"
3131
#include "eventqueue.h"
3232

33+
#include "graphics_util.h"
3334

3435
////////////////////////////////////////////////////////////////////////////////
3536

@@ -357,13 +358,20 @@ static void MCEventQueueDispatchEvent(MCEvent *p_event)
357358
{
358359
MCeventtime = t_event -> mouse . time;
359360
MCmodifierstate = t_event -> mouse . position . modifiers;
360-
MCmousex = t_event -> mouse . position . x;
361-
MCmousey = t_event -> mouse . position . y;
362361

363362
MCObject *t_target;
364363
t_target = t_menu != nil ? t_menu : MCmousestackptr;
364+
365+
// IM-2013-09-30: [[ FullscreenMode ]] Translate mouse location to stack coords
366+
MCPoint t_mouseloc;
367+
t_mouseloc = MCPointMake(t_event->mouse.position.x, t_event->mouse.position.y);
368+
369+
t_mouseloc = t_target->getstack()->view_viewtostackloc(t_mouseloc);
370+
371+
MCmousex = t_mouseloc.x;
372+
MCmousey = t_mouseloc.y;
365373

366-
t_target -> mfocus(t_event -> mouse . position . x, t_event -> mouse . position . y);
374+
t_target -> mfocus(t_mouseloc . x, t_mouseloc . y);
367375
}
368376
break;
369377

@@ -966,6 +974,11 @@ static void handle_touch(MCStack *p_stack, MCEventTouchPhase p_phase, uint32_t p
966974

967975
MCObject *t_target;
968976
t_target = nil;
977+
978+
// IM-2013-09-30: [[ FullscreenMode ]] Translate touch location to stack coords
979+
MCPoint t_touch_loc;
980+
t_touch_loc = p_stack->view_viewtostackloc(MCPointMake(x, y));
981+
969982
if (p_phase != kMCEventTouchPhaseBegan)
970983
{
971984
for(t_touch = s_touches; t_touch != nil; t_previous_touch = t_touch, t_touch = t_touch -> next)
@@ -999,7 +1012,7 @@ static void handle_touch(MCStack *p_stack, MCEventTouchPhase p_phase, uint32_t p
9991012
t_touch -> next = s_touches;
10001013
t_touch -> id = p_id;
10011014

1002-
t_target = p_stack -> getcurcard() -> hittest(x, y);
1015+
t_target = p_stack -> getcurcard() -> hittest(t_touch_loc.x, t_touch_loc.y);
10031016
t_touch -> target = t_target -> gethandle();
10041017

10051018
s_touches = t_touch;
@@ -1013,7 +1026,7 @@ static void handle_touch(MCStack *p_stack, MCEventTouchPhase p_phase, uint32_t p
10131026
t_target -> message_with_args(MCM_touch_start, p_id);
10141027
break;
10151028
case kMCEventTouchPhaseMoved:
1016-
t_target -> message_with_args(MCM_touch_move, p_id, x, y);
1029+
t_target -> message_with_args(MCM_touch_move, p_id, t_touch_loc.x, t_touch_loc.y);
10171030
break;
10181031
case kMCEventTouchPhaseEnded:
10191032
t_target -> message_with_args(MCM_touch_end, p_id);

engine/src/graphics_util.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ inline MCGPoint MCPointToMCGPoint(MCPoint p_point)
8383
return t_point;
8484
}
8585

86+
inline MCRectangle MCRectangleGetTransformedBounds(const MCRectangle &p_rect, const MCGAffineTransform &p_transform)
87+
{
88+
return MCGRectangleGetIntegerBounds(MCGRectangleApplyAffineTransform(MCRectangleToMCGRectangle(p_rect), p_transform));
89+
}
90+
91+
inline MCPoint MCPointTransform(const MCPoint &p_point, const MCGAffineTransform &p_transform)
92+
{
93+
return MCGPointToMCPoint(MCGPointApplyAffineTransform(MCPointToMCGPoint(p_point), p_transform));
94+
}
95+
8696
#if defined(TARGET_SUBPLATFORM_ANDROID)
8797

8898
#include "mblandroidtypeface.h"

engine/src/mbldc.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,16 @@ void MCScreenDC::handle_touch(MCEventTouchPhase p_phase, void *p_touch, int32_t
376376

377377
////////////////////////////////////////////////////////////////////////////////
378378

379+
bool MCScreenDC::fullscreenwindows(void)
380+
{
381+
return true;
382+
}
383+
384+
MCRectangle MCScreenDC::fullscreenrect(const MCDisplay *p_display)
385+
{
386+
return p_display->workarea;
387+
}
388+
379389
void MCScreenDC::openwindow(Window p_window, Boolean override)
380390
{
381391
if (p_window == nil)

engine/src/mbldc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ class MCScreenDC: public MCUIDC
7676
void device_querymouse(int16_t &r_x, int16_t &r_y);
7777
void device_setmouse(int16_t p_x, int16_t p_y);
7878

79+
bool fullscreenwindows(void);
80+
MCRectangle fullscreenrect(const MCDisplay *p_display);
81+
7982
void resetcursors(void);
8083
void setcursor(Window w, MCCursorRef c);
8184

engine/src/mbliphonedc.mm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,13 @@ void MCIPhoneCallOnMainFiber(void (*handler)(void *), void *context)
299299

300300
bool MCScreenDC::device_getwindowgeometry(Window p_window, MCRectangle& r_rect)
301301
{
302-
r_rect = MCDeviceRectFromLogicalCGRect(MCIPhoneGetViewBounds());
302+
// IM-2013-09-30: [[ FullscreenMode ]] REVISIT - currently we just return the stack
303+
// rect here, though ideally if a new stack is being opened in the window of the
304+
// current one, it should use it's own rect rather than the current stack rect
305+
MCRectangle t_rect;
306+
t_rect = ((MCStack*)p_window)->getrect();
307+
308+
r_rect = MCGRectangleGetIntegerInterior(MCResUserToDeviceRect(t_rect));
303309
return true;
304310
}
305311

engine/src/mbliphonegfx.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,9 @@ - (void) drawRect: (CGRect)rect
330330
CGContextScaleCTM(t_cgcontext, 1.0 / t_scale, 1.0 / t_scale);
331331

332332
// IM-2013-08-23: [[ RefactorGraphics ]] pass scaled surface height to stack surface constructor
333+
// IM-2013-09-30: [[ FullscreenMode ]] Use the stack transform to get the device rect
333334
MCRectangle t_device_rect;
334-
t_device_rect = MCGRectangleGetIntegerBounds(MCResUserToDeviceRect(t_stack->getrect()));
335+
t_device_rect = MCRectangleGetTransformedBounds(t_stack->getrect(), t_stack->getdevicetransform());
335336

336337
MCUIKitStackSurface t_surface(t_dirty_rgn, t_device_rect.height, t_cgcontext);
337338

engine/src/mblstack.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,32 @@ void MCStack::destroywindowshape(void)
107107
{
108108
}
109109

110+
MCRectangle MCStack::device_setgeom(const MCRectangle &p_rect)
111+
{
112+
return p_rect;
113+
}
114+
115+
// IM-2013-09-30: [[ FullscreenMode ]] Mobile version of setgeom now calls view_setgeom
110116
void MCStack::setgeom(void)
111117
{
118+
if (MCnoui || !opened)
119+
return;
120+
121+
// IM-2013-08-08: [[ ResIndependence ]] Scale stack rect to device space
122+
MCRectangle t_old_device_rect;
123+
t_old_device_rect = view_setgeom(rect);
124+
112125
state &= ~CS_NEED_RESIZE;
126+
127+
// IM-2013-08-08: [[ ResIndependence ]] Scale old window rect to user space for comparison
128+
MCRectangle t_old_user_rect;
129+
t_old_user_rect = MCGRectangleGetIntegerBounds(MCResDeviceToUserRect(t_old_device_rect));
130+
131+
if (t_old_user_rect.x != rect.x || t_old_user_rect.y != rect.y || t_old_user_rect.width != rect.width || t_old_user_rect.height != rect.height)
132+
{
133+
resize(t_old_user_rect.width, t_old_user_rect.height);
134+
}
135+
113136
}
114137

115138
void MCStack::start_externals()

0 commit comments

Comments
 (0)