MCStack *MCUIDC::getstackatpoint(int32_t x, int32_t y) { MCGFloat t_scale; t_scale = MCResGetPixelScale(); return device_getstackatpoint(x * t_scale, y * t_scale); }
void MCUIDC::setmouse(int2 x, int2 y) { MCGFloat t_scale; t_scale = MCResGetPixelScale(); device_setmouse(x * t_scale, y * t_scale); }
uint2 MCUIDC::getheight() { MCGFloat t_scale; t_scale = MCResGetPixelScale(); return ceil(device_getheight() / t_scale); }
void MCAndroidInneractiveAd::SetTopLeft(MCAdTopLeft p_top_left) { // MM-2013-09-30: [[ Bug 11227 ]] Make sure we take into account device scale when positioning ads. MCGFloat t_device_scale; t_device_scale = MCResGetPixelScale(); p_top_left . x = (uint32_t) p_top_left . x * t_device_scale; p_top_left . y = (uint32_t) p_top_left . y * t_device_scale; MCAndroidObjectRemoteCall(m_view, "setTopLeft", "vii", nil, p_top_left.x, p_top_left.y); }
void MCUIDC::querymouse(int2 &x, int2 &y) { int16_t t_x, t_y; device_querymouse(t_x, t_y); MCGFloat t_scale; t_scale = MCResGetPixelScale(); x = t_x / t_scale; y = t_y / t_scale; }
MCAdTopLeft MCAndroidInneractiveAd::GetTopLeft() { MCAdTopLeft t_top_left = {0,0}; MCAndroidObjectRemoteCall(m_view, "getLeft", "i", &t_top_left.x); MCAndroidObjectRemoteCall(m_view, "getTop", "i", &t_top_left.y); // MM-2013-09-30: [[ Bug 11227 ]] Make sure we take into account device scale when positioning ads. MCGFloat t_device_scale; t_device_scale = MCResGetPixelScale(); t_top_left . x = (uint32_t) t_top_left . x / t_device_scale; t_top_left . y = (uint32_t) t_top_left . y / t_device_scale; return t_top_left; }
void MCScreenDC::process_touch(MCEventTouchPhase p_phase, void *p_touch_handle, int32_t p_timestamp, int32_t p_x, int32_t p_y) { MCActiveTouch *t_touch, *t_previous_touch; t_previous_touch = nil; for(t_touch = m_active_touches; t_touch != nil; t_previous_touch = t_touch, t_touch = t_touch -> next) if (t_touch -> touch == p_touch_handle) break; if (p_phase == kMCEventTouchPhaseBegan) { if (t_touch == nil) { uint32_t t_touch_id; t_touch_id = ++m_last_touch_id; t_touch = new MCActiveTouch; t_touch -> ident = t_touch_id; t_touch -> touch = p_touch_handle; t_touch -> next = m_active_touches; m_active_touches = t_touch; } else return; } if (t_touch == nil) return; t_touch -> x = p_x; t_touch -> y = p_y; t_touch -> timestamp = p_timestamp; MCGFloat t_scale; t_scale = MCResGetPixelScale(); // IM-2013-08-02: [[ ResIndependence]] scale touch coords to user space MCEventQueuePostTouch((MCStack *)m_current_window, p_phase, t_touch -> ident, 1, p_x / t_scale, p_y / t_scale); if (p_phase == kMCEventTouchPhaseEnded || p_phase == kMCEventTouchPhaseCancelled) { if (t_previous_touch != nil) t_previous_touch -> next = t_touch -> next; else m_active_touches = t_touch -> next; delete t_touch; } }
void MCScreenDC::handle_mouse_move(uint32_t p_time, uint32_t p_modifiers, int32_t x, int32_t y) { if (m_current_window == nil) return; if (m_mouse_x == x && m_mouse_y == y) return; m_mouse_x = x; m_mouse_y = y; // IM-2013-08-02: [[ ResIndependence]] scale mouse coords to user space MCGFloat t_scale; t_scale = MCResGetPixelScale(); MCEventQueuePostMousePosition((MCStack *)m_current_window, p_time, p_modifiers, x / t_scale, y / t_scale); }
void MCScreenDC::handle_mouse_press(uint32_t p_time, uint32_t p_modifiers, int32_t x, int32_t y, int32_t p_button, MCMousePressState p_state) { if (m_current_window == nil) return; if (m_mouse_x != x || m_mouse_y != y) { m_mouse_x = x; m_mouse_y = y; // IM-2013-08-02: [[ ResIndependence]] scale mouse coords to user space MCGFloat t_scale; t_scale = MCResGetPixelScale(); MCEventQueuePostMousePosition((MCStack *)m_current_window, p_time, p_modifiers, x / t_scale, y / t_scale); } MCEventQueuePostMousePress((MCStack *)m_current_window, p_time, p_modifiers, p_state, p_button); }
bool MCWin32ApplyMaskToRasterRegion(MCGRaster &p_raster, uint32_t p_x_origin, uint32_t p_y_origin, const MCGRaster &p_mask, MCRegionRef p_region) { // IM-2013-09-11: [[ ResIndependence ]] reduce mask params to single MCGRaster bool t_success; t_success = true; MCGContextRef t_gcontext; t_gcontext = nil; if (t_success) t_success = MCGContextCreateWithRaster(p_raster, t_gcontext); MCGImageRef t_mask_image; t_mask_image = nil; if (t_success) t_success = MCGImageCreateWithRasterNoCopy(p_mask, t_mask_image); if (t_success) { // IM-2013-09-11: [[ ResIndependence ]] Apply scaled mask to target raster. // Drawing the mask directly will not work as the effective shape of the drawing operation // will be defined by the opaque parts of the mask - areas outside will be unaffected. Instead we // draw a solid rectangle over the intended areas using the mask as a pattern. MCGFloat t_scale; t_scale = MCResGetPixelScale(); MCGContextSetFillPattern(t_gcontext, t_mask_image, MCGAffineTransformMakeScale(t_scale, t_scale), kMCGImageFilterNearest); MCGContextTranslateCTM(t_gcontext, -(MCGFloat)p_x_origin, -(MCGFloat)p_y_origin); MCGContextSetBlendMode(t_gcontext, kMCGBlendModeDestinationIn); t_success = MCRegionForEachRect(p_region, __MCApplyMaskCallback, t_gcontext); } MCGImageRelease(t_mask_image); MCGContextRelease(t_gcontext); return t_success; }
MCGFloat MCResGetUIScale(void) { return MCResGetPixelScale() / MCResPlatformGetUIDeviceScale(); }