diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/ios/qiosintegration.h | 6 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosintegration.mm | 11 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosviewcontroller.mm | 51 | ||||
-rw-r--r-- | src/plugins/platforms/ios/quiview.mm | 14 |
4 files changed, 82 insertions, 0 deletions
diff --git a/src/plugins/platforms/ios/qiosintegration.h b/src/plugins/platforms/ios/qiosintegration.h index c22c43e455..0fe318dce7 100644 --- a/src/plugins/platforms/ios/qiosintegration.h +++ b/src/plugins/platforms/ios/qiosintegration.h @@ -48,6 +48,7 @@ class QIOSServices; class QIOSIntegration : public QPlatformNativeInterface, public QPlatformIntegration { Q_OBJECT + Q_PROPERTY(bool debugWindowManagement READ debugWindowManagement WRITE setDebugWindowManagement); public: QIOSIntegration(); @@ -87,6 +88,9 @@ public: void *nativeResourceForWindow(const QByteArray &resource, QWindow *window); + void setDebugWindowManagement(bool); + bool debugWindowManagement() const; + private: QPlatformFontDatabase *m_fontDatabase; QPlatformClipboard *m_clipboard; @@ -96,6 +100,8 @@ private: QIOSServices *m_platformServices; mutable QPlatformAccessibility *m_accessibility; QIOSFileEngineFactory m_fileEngineFactory; + + bool m_debugWindowManagement; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm index fcfd6c7cc8..e395c832f1 100644 --- a/src/plugins/platforms/ios/qiosintegration.mm +++ b/src/plugins/platforms/ios/qiosintegration.mm @@ -67,6 +67,7 @@ QIOSIntegration::QIOSIntegration() , m_inputContext(0) , m_platformServices(new QIOSServices) , m_accessibility(0) + , m_debugWindowManagement(false) { if (![UIApplication sharedApplication]) { qFatal("Error: You are creating QApplication before calling UIApplicationMain.\n" \ @@ -249,6 +250,16 @@ void *QIOSIntegration::nativeResourceForWindow(const QByteArray &resource, QWind return 0; } +void QIOSIntegration::setDebugWindowManagement(bool enabled) +{ + m_debugWindowManagement = enabled; +} + +bool QIOSIntegration::debugWindowManagement() const +{ + return m_debugWindowManagement; +} + // --------------------------------------------------------- #include "moc_qiosintegration.cpp" diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm index d144b419aa..9abd105d94 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.mm +++ b/src/plugins/platforms/ios/qiosviewcontroller.mm @@ -41,6 +41,7 @@ #include <QtGui/private/qwindow_p.h> +#include "qiosintegration.h" #include "qiosscreen.h" #include "qiosglobal.h" #include "qioswindow.h" @@ -64,6 +65,56 @@ @implementation QIOSDesktopManagerView +- (id)init +{ + if (!(self = [super init])) + return nil; + + QIOSIntegration *iosIntegration = QIOSIntegration::instance(); + if (iosIntegration && iosIntegration->debugWindowManagement()) { + static UIImage *gridPattern = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + CGFloat dimension = 100.f; + + UIGraphicsBeginImageContextWithOptions(CGSizeMake(dimension, dimension), YES, 0.0f); + CGContextRef context = UIGraphicsGetCurrentContext(); + + CGContextTranslateCTM(context, -0.5, -0.5); + + #define gridColorWithBrightness(br) \ + [UIColor colorWithHue:0.6 saturation:0.0 brightness:br alpha:1.0].CGColor + + CGContextSetFillColorWithColor(context, gridColorWithBrightness(0.05)); + CGContextFillRect(context, CGRectMake(0, 0, dimension, dimension)); + + CGFloat gridLines[][2] = { { 10, 0.1 }, { 20, 0.2 }, { 100, 0.3 } }; + for (size_t l = 0; l < sizeof(gridLines) / sizeof(gridLines[0]); ++l) { + CGFloat step = gridLines[l][0]; + for (int c = step; c <= dimension; c += step) { + CGContextMoveToPoint(context, c, 0); + CGContextAddLineToPoint(context, c, dimension); + CGContextMoveToPoint(context, 0, c); + CGContextAddLineToPoint(context, dimension, c); + } + + CGFloat brightness = gridLines[l][1]; + CGContextSetStrokeColorWithColor(context, gridColorWithBrightness(brightness)); + CGContextStrokePath(context); + } + + gridPattern = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + + [gridPattern retain]; + }); + + self.backgroundColor = [UIColor colorWithPatternImage:gridPattern]; + } + + return self; +} + - (void)didAddSubview:(UIView *)subview { Q_UNUSED(subview); diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index f36cbaf685..a56db1d6f5 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -73,6 +73,20 @@ self.hidden = YES; self.multipleTouchEnabled = YES; + + if (QIOSIntegration::instance()->debugWindowManagement()) { + static CGFloat hue = 0.0; + CGFloat lastHue = hue; + for (CGFloat diff = 0; diff < 0.1 || diff > 0.9; diff = fabsf(hue - lastHue)) + hue = drand48(); + + #define colorWithBrightness(br) \ + [UIColor colorWithHue:hue saturation:0.5 brightness:br alpha:1.0].CGColor + + self.layer.backgroundColor = colorWithBrightness(0.5); + self.layer.borderColor = colorWithBrightness(1.0); + self.layer.borderWidth = 1.0; + } } return self; |