@@ -5297,154 +5297,6 @@ static void cn1_renderViewIntoContext(UIView *renderView, UIView *rootView, CGCo
52975297 CGContextRestoreGState (ctx);
52985298}
52995299
5300- static void cn1_collectViewHierarchy (UIView *view, NSMutableArray <NSString *> *lines, NSInteger depth, UIView *targetView, UIView *rootView) {
5301- if (view == nil || lines == nil ) {
5302- return ;
5303- }
5304-
5305- NSMutableString *line = [NSMutableString string ];
5306- for (NSInteger i = 0 ; i < depth; i++) {
5307- [line appendString: @" " ];
5308- }
5309-
5310- NSString *className = NSStringFromClass ([view class ]);
5311- [line appendFormat: @" %@ <%p >" , className, view];
5312-
5313- if (view == rootView) {
5314- [line appendString: @" [captureRoot]" ];
5315- }
5316-
5317- if (view == targetView) {
5318- [line appendString: @" [targetView]" ];
5319- }
5320-
5321- CGRect frame = view.frame ;
5322- [line appendFormat: @" frame=%@ " , NSStringFromCGRect(frame)];
5323-
5324- [line appendFormat: @" hidden=%@ " , view.hidden ? @" YES" : @" NO" ];
5325- [line appendFormat: @" alpha=%.2f " , view.alpha];
5326- [line appendFormat: @" userInteraction=%@ " , view.userInteractionEnabled ? @" YES" : @" NO" ];
5327-
5328- if (view.tag != 0 ) {
5329- [line appendFormat: @" tag=%ld " , (long )view.tag];
5330- }
5331-
5332- NSString *identifier = nil ;
5333- if ([view respondsToSelector: @selector (accessibilityIdentifier )]) {
5334- identifier = view.accessibilityIdentifier ;
5335- }
5336-
5337- if (identifier.length > 0 ) {
5338- [line appendFormat: @" accessibilityIdentifier=%@ " , identifier];
5339- }
5340-
5341- [lines addObject: line];
5342-
5343- for (UIView *subview in view.subviews ) {
5344- cn1_collectViewHierarchy (subview, lines, depth + 1 , targetView, rootView);
5345- }
5346- }
5347-
5348- static void cn1_appendWindowHierarchyLines (NSArray <UIWindow *> *windows, UIWindow *targetWindow, UIView *targetView, NSMutableArray <NSString *> *lines) {
5349- if (windows == nil || lines == nil || windows.count == 0 ) {
5350- return ;
5351- }
5352-
5353- [lines addObject: @" Window capture order (back to front):" ];
5354-
5355- NSInteger index = 0 ;
5356- for (UIWindow *window in windows) {
5357- NSMutableString *header = [NSMutableString string ];
5358- [header appendFormat: @" [%ld ] %@ <%p >" , (long )index, NSStringFromClass ([window class ]), window];
5359- if (window == targetWindow) {
5360- [header appendString: @" [targetWindow]" ];
5361- }
5362- [header appendFormat: @" level=%.2f " , window.windowLevel];
5363- [header appendFormat: @" hidden=%@ " , window.hidden ? @" YES" : @" NO" ];
5364- [header appendFormat: @" alpha=%.2f " , window.alpha];
5365- [header appendFormat: @" frame=%@ " , NSStringFromCGRect(window.frame)];
5366- [lines addObject: header];
5367- cn1_collectViewHierarchy (window, lines, 1 , targetView, targetWindow);
5368- index++;
5369- }
5370- }
5371-
5372- static void cn1_drawHierarchyOverlay (CGContextRef ctx, UIView *rootView, CGRect targetRect, NSArray <NSString *> *lines) {
5373- if (ctx == nil || rootView == nil || lines == nil || lines.count == 0 ) {
5374- return ;
5375- }
5376-
5377- NSString *text = [lines componentsJoinedByString: @" \n " ];
5378- if (text.length == 0 ) {
5379- return ;
5380- }
5381-
5382- UIFont *font = nil ;
5383- #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
5384- if (@available (iOS 13.0 , *)) {
5385- font = [UIFont monospacedSystemFontOfSize: 12.0 weight: UIFontWeightRegular];
5386- }
5387- #endif
5388- if (font == nil ) {
5389- font = [UIFont fontWithName: @" Menlo" size: 12.0 ];
5390- }
5391- if (font == nil ) {
5392- font = [UIFont systemFontOfSize: 12.0 ];
5393- }
5394-
5395- NSDictionary <NSAttributedStringKey , id > *attributes = @{ NSFontAttributeName : font, NSForegroundColorAttributeName : [UIColor whiteColor ] };
5396-
5397- CGSize canvasSize = rootView.bounds .size ;
5398- if (canvasSize.width <= 0 .0f || canvasSize.height <= 0 .0f ) {
5399- return ;
5400- }
5401-
5402- CGFloat outerPadding = 12 .0f ;
5403- CGFloat innerPadding = 8 .0f ;
5404- CGFloat availableWidth = MAX (0 .0f , canvasSize.width - (outerPadding * 2 .0f ));
5405- CGSize constraint = CGSizeMake (availableWidth, CGFLOAT_MAX);
5406- CGRect textBounds = [text boundingRectWithSize: constraint options: NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes: attributes context: nil ];
5407- textBounds.size .width = ceil (textBounds.size .width );
5408- textBounds.size .height = ceil (textBounds.size .height );
5409-
5410- if (CGRectIsNull (targetRect) || CGRectIsInfinite (targetRect)) {
5411- targetRect = rootView.bounds ;
5412- }
5413-
5414- CGPoint anchor = CGPointMake (CGRectGetMinX (targetRect) + outerPadding, CGRectGetMinY (targetRect) + outerPadding);
5415-
5416- CGRect backgroundRect = CGRectMake (anchor.x - innerPadding,
5417- anchor.y - innerPadding,
5418- textBounds.size .width + innerPadding * 2 .0f ,
5419- textBounds.size .height + innerPadding * 2 .0f );
5420-
5421- if (backgroundRect.origin .x < outerPadding) {
5422- backgroundRect.origin .x = outerPadding;
5423- }
5424- if (backgroundRect.origin .y < outerPadding) {
5425- backgroundRect.origin .y = outerPadding;
5426- }
5427-
5428- if (CGRectGetMaxX (backgroundRect) > canvasSize.width - outerPadding) {
5429- backgroundRect.origin .x = MAX (outerPadding, canvasSize.width - outerPadding - backgroundRect.size .width );
5430- }
5431-
5432- if (CGRectGetMaxY (backgroundRect) > canvasSize.height - outerPadding) {
5433- backgroundRect.origin .y = MAX (outerPadding, canvasSize.height - outerPadding - backgroundRect.size .height );
5434- }
5435-
5436- CGRect textRect = CGRectMake (backgroundRect.origin .x + innerPadding,
5437- backgroundRect.origin .y + innerPadding,
5438- textBounds.size .width ,
5439- textBounds.size .height );
5440-
5441- UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect: backgroundRect cornerRadius: 8 .0f ];
5442- [[UIColor colorWithWhite: 0 alpha: 0 .7f ] setFill ];
5443- [path fill ];
5444-
5445- [text drawInRect: textRect withAttributes: attributes];
5446- }
5447-
54485300static void cn1_renderPeerComponents (UIView *rootView, CGContextRef ctx) {
54495301 CodenameOne_GLViewController *controller = [CodenameOne_GLViewController instance ];
54505302 EAGLView *glView = [controller eaglView ];
@@ -5549,16 +5401,6 @@ static void cn1_renderPeerComponents(UIView *rootView, CGContextRef ctx) {
55495401 return nil ;
55505402 }
55515403
5552- CGRect overlayTargetRect = rootView.bounds ;
5553- if (rootView != view && view != nil ) {
5554- CGRect converted = [rootView convertRect: view.bounds fromView: view];
5555- if (!CGRectIsNull (converted) && converted.size .width > 0 && converted.size .height > 0 ) {
5556- overlayTargetRect = converted;
5557- }
5558- }
5559-
5560- NSMutableArray <NSString *> *hierarchyLines = [NSMutableArray array ];
5561-
55625404 UIGraphicsBeginImageContextWithOptions (size, rootView.opaque , 0.0 );
55635405 CGContextRef ctx = UIGraphicsGetCurrentContext ();
55645406 if ([rootView isKindOfClass: [UIWindow class ]]) {
@@ -5602,8 +5444,6 @@ static void cn1_renderPeerComponents(UIView *rootView, CGContextRef ctx) {
56025444 }];
56035445 }
56045446
5605- cn1_appendWindowHierarchyLines (orderedWindows, targetWindow, view, hierarchyLines);
5606-
56075447 for (UIWindow *window in orderedWindows) {
56085448 if (window.hidden || window.alpha <= 0 .0f ) {
56095449 continue ;
@@ -5639,12 +5479,6 @@ static void cn1_renderPeerComponents(UIView *rootView, CGContextRef ctx) {
56395479 cn1_renderPeerComponents (rootView, ctx);
56405480 }
56415481
5642- if (hierarchyLines.count == 0 ) {
5643- cn1_collectViewHierarchy (rootView, hierarchyLines, 0 , view, rootView);
5644- }
5645-
5646- cn1_drawHierarchyOverlay (ctx, rootView, overlayTargetRect, hierarchyLines);
5647-
56485482 UIImage *image = UIGraphicsGetImageFromCurrentImageContext ();
56495483 UIGraphicsEndImageContext ();
56505484
0 commit comments