From 23be347272b469e80be69e1affd7d977af996ecd Mon Sep 17 00:00:00 2001 From: Alexey Glushkov Date: Sat, 21 Apr 2012 21:03:28 +0400 Subject: [PATCH 1/4] Add members' description in DCIntrospect class to be able to see them in the debugger --- DCIntrospect/DCIntrospect.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/DCIntrospect/DCIntrospect.h b/DCIntrospect/DCIntrospect.h index f7178bc..9ac02c5 100644 --- a/DCIntrospect/DCIntrospect.h +++ b/DCIntrospect/DCIntrospect.h @@ -27,6 +27,28 @@ @interface DCIntrospect : NSObject { + BOOL keyboardBindingsOn; + BOOL showStatusBarOverlay; + UIGestureRecognizer* invokeGestureRecognizer; + + BOOL on; + BOOL handleArrowKeys; + BOOL viewOutlines; + BOOL highlightNonOpaqueViews; + BOOL flashOnRedraw; + DCFrameView *frameView; + UITextView *inputTextView; + DCStatusBarOverlay *statusBarOverlay; + + NSMutableDictionary *objectNames; + + UIView *currentView; + CGRect originalFrame; + CGFloat originalAlpha; + + NSMutableArray *currentViewHistory; + + BOOL showingHelp; } @property (nonatomic) BOOL keyboardBindingsOn; // default: YES From b7f23e31dd80e10b6c2dd8031b574130d6bd74da Mon Sep 17 00:00:00 2001 From: Alexey Glushkov Date: Sat, 21 Apr 2012 21:52:36 +0400 Subject: [PATCH 2/4] Added three additional commands m - select view which is under the selected view and contains a clicked point n - select view whichg is over the selected view and contains a clicked point k - change the selected view's background color randomly --- DCIntrospect/DCIntrospect.h | 2 + DCIntrospect/DCIntrospect.m | 81 +++++++++++++++++++++++++++-- DCIntrospect/DCIntrospectSettings.h | 5 ++ 3 files changed, 83 insertions(+), 5 deletions(-) diff --git a/DCIntrospect/DCIntrospect.h b/DCIntrospect/DCIntrospect.h index 9ac02c5..405f6c8 100644 --- a/DCIntrospect/DCIntrospect.h +++ b/DCIntrospect/DCIntrospect.h @@ -47,6 +47,7 @@ CGFloat originalAlpha; NSMutableArray *currentViewHistory; + NSMutableArray *currentViewStack; BOOL showingHelp; } @@ -70,6 +71,7 @@ @property (nonatomic) CGRect originalFrame; @property (nonatomic) CGFloat originalAlpha; @property (nonatomic, retain) NSMutableArray *currentViewHistory; +@property (nonatomic, retain) NSMutableArray *currentViewStack; @property (nonatomic) BOOL showingHelp; diff --git a/DCIntrospect/DCIntrospect.m b/DCIntrospect/DCIntrospect.m index bde7f4f..f4dd299 100644 --- a/DCIntrospect/DCIntrospect.m +++ b/DCIntrospect/DCIntrospect.m @@ -60,6 +60,9 @@ @interface DCIntrospect () - (void)takeFirstResponder; +- (void)moveDownInViewStack; +- (void)moveUpInViewStack; + @end @@ -77,6 +80,7 @@ @implementation DCIntrospect @synthesize currentView, originalFrame, originalAlpha; @synthesize currentViewHistory; @synthesize showingHelp; +@synthesize currentViewStack; #pragma mark Setup @@ -322,14 +326,24 @@ - (void)touchAtPoint:(CGPoint)point CGPoint convertedTouchPoint = [[self mainWindow] convertPoint:point fromView:self.frameView]; // find all the views under that point – will be added in order on screen, ie mainWindow will be index 0, main view controller at index 1 etc. - NSMutableArray *views = [self viewsAtPoint:convertedTouchPoint inView:[self mainWindow]]; - if (views.count == 0) + self.currentViewStack = [self viewsAtPoint:convertedTouchPoint inView:[self mainWindow]]; + if (self.currentViewStack.count == 0) return; - // get the topmost view and setup the UI + // setup the UI and get the topmost view which has a non nil superview [self.currentViewHistory removeAllObjects]; - UIView *newView = [views lastObject]; - [self selectView:newView]; + + BOOL isViewFound = NO; + for( UIView* view in [self.currentViewStack reverseObjectEnumerator] ) + if(view.superview) + { + isViewFound = YES; + [self selectView:view]; + break; + } + + if(!isViewFound && [self.currentViewStack count]) + [self selectView:[self.currentViewStack lastObject]]; } - (void)selectView:(UIView *)view @@ -582,6 +596,24 @@ - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range r [self logCodeForCurrentViewChanges]; return NO; } + else if([string isEqualToString:kDCIntrospectKeysMoveDownInViewStack]) + { + [self moveDownInViewStack]; + return NO; + } + else if([string isEqualToString:kDCIntrospectKeysMoveUpInViewStack]) + { + [self moveUpInViewStack]; + return NO; + } + else if( [string isEqualToString:kDCIntrospectKeysGenerateBackgroundColor] ) + { + self.currentView.backgroundColor = [UIColor colorWithRed:(arc4random() % 256) / 256.0f + green:(arc4random() % 256) / 256.0f + blue:(arc4random() % 256) / 256.0f + alpha:1.0f]; + return NO; + } CGRect frame = self.currentView.frame; if ([string isEqualToString:kDCIntrospectKeysNudgeViewLeft]) @@ -964,6 +996,42 @@ - (void)flashRect:(CGRect)rect inView:(UIView *)view } } +- (void)moveDownInViewStack +{ + int indexOfCurrentView = [self.currentViewStack indexOfObject:self.currentView]; + if(indexOfCurrentView == NSNotFound) + { + NSLog(@"DCIntrospect: The current view was changed and the view stack doesn't contain it."); + return; + } + + if (indexOfCurrentView == 0) + { + NSLog(@"DCIntrospect: At bottom of the view stack."); + }else + { + [self selectView:[self.currentViewStack objectAtIndex:indexOfCurrentView - 1]]; + } +} + +- (void)moveUpInViewStack +{ + int indexOfCurrentView = [self.currentViewStack indexOfObject:self.currentView]; + if(indexOfCurrentView == NSNotFound) + { + NSLog(@"DCIntrospect: The current view was changed and the view stack doesn't contain it."); + return; + } + + if (indexOfCurrentView == [self.currentViewStack count]-1) + { + NSLog(@"DCIntrospect: At top of the view stack."); + }else + { + [self selectView:[self.currentViewStack objectAtIndex:indexOfCurrentView + 1]]; + } +} + #pragma mark Description Methods - (NSString *)describeProperty:(NSString *)propertyName value:(id)value @@ -1338,6 +1406,9 @@ - (void)toggleHelp [helpString appendFormat:@"
Enter GDB
%@
", kDCIntrospectKeysEnterGDB]; [helpString appendFormat:@"
Move up in view hierarchy
%@
", ([kDCIntrospectKeysMoveUpInViewHierarchy isEqualToString:@""]) ? @"page up" : kDCIntrospectKeysMoveUpInViewHierarchy]; [helpString appendFormat:@"
Move back down in view hierarchy
%@
", ([kDCIntrospectKeysMoveBackInViewHierarchy isEqualToString:@""]) ? @"page down" : kDCIntrospectKeysMoveBackInViewHierarchy]; + [helpString appendFormat:@"
Move up in a view stack
%@
", kDCIntrospectKeysMoveUpInViewStack]; + [helpString appendFormat:@"
Move down in a view stack
%@
", kDCIntrospectKeysMoveDownInViewStack]; + [helpString appendFormat:@"
Change the background color randomly
%@
", kDCIntrospectKeysGenerateBackgroundColor]; [helpString appendString:@"
"]; [helpString appendFormat:@"
Nudge Left
\uE235 / %@
", kDCIntrospectKeysNudgeViewLeft]; diff --git a/DCIntrospect/DCIntrospectSettings.h b/DCIntrospect/DCIntrospectSettings.h index cbd1985..a8e0340 100644 --- a/DCIntrospect/DCIntrospectSettings.h +++ b/DCIntrospect/DCIntrospectSettings.h @@ -52,5 +52,10 @@ #define kDCIntrospectKeysMoveToNextSiblingView @"j" #define kDCIntrospectKeysMoveToPrevSiblingView @"g" +#define kDCIntrospectKeysMoveUpInViewStack @"m" // select view which is under the selected view and contains a clicked point +#define kDCIntrospectKeysMoveDownInViewStack @"n" // select view whichg is over the selected view and contains a clicked point + +#define kDCIntrospectKeysGenerateBackgroundColor @"k" // change the selected view's background color randomly + #define kDCIntrospectKeysEnterGDB @"`" // enters GDB #define kDCIntrospectKeysDisableForPeriod @"~" // disables DCIntrospect for a given period (see kDCIntrospectTemporaryDisableDuration) From 0c5c49699633b77d9cb821a719932b64e1e9a6f5 Mon Sep 17 00:00:00 2001 From: Alexey Glushkov Date: Sat, 21 Apr 2012 22:03:10 +0400 Subject: [PATCH 3/4] Add a custom window support --- DCIntrospect/DCIntrospect.m | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/DCIntrospect/DCIntrospect.m b/DCIntrospect/DCIntrospect.m index f4dd299..76bd036 100644 --- a/DCIntrospect/DCIntrospect.m +++ b/DCIntrospect/DCIntrospect.m @@ -762,10 +762,12 @@ - (void)updateFrameView if (!self.frameView) { self.frameView = [[[DCFrameView alloc] initWithFrame:(CGRect){ CGPointZero, mainWindow.frame.size } delegate:self] autorelease]; - [mainWindow addSubview:self.frameView]; self.frameView.alpha = 0.0f; [self updateViews]; } + + //window can be changed + [mainWindow addSubview:self.frameView]; [mainWindow bringSubviewToFront:self.frameView]; @@ -1648,11 +1650,7 @@ - (NSArray *)subclassesOfClass:(Class)parentClass - (UIWindow *)mainWindow { - NSArray *windows = [[UIApplication sharedApplication] windows]; - if (windows.count == 0) - return nil; - - return [windows objectAtIndex:0]; + return [UIApplication sharedApplication].keyWindow; } - (NSMutableArray *)viewsAtPoint:(CGPoint)touchPoint inView:(UIView *)view From dbbe568e2c37e72bb56e4fbd96153af4bec409c2 Mon Sep 17 00:00:00 2001 From: Alexey Glushkov Date: Sat, 21 Apr 2012 22:15:16 +0400 Subject: [PATCH 4/4] Fixed the wrong position of the status bar when start an application in landscape orientation --- DCIntrospect/DCIntrospect.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DCIntrospect/DCIntrospect.m b/DCIntrospect/DCIntrospect.m index 76bd036..5c7e387 100644 --- a/DCIntrospect/DCIntrospect.m +++ b/DCIntrospect/DCIntrospect.m @@ -820,7 +820,10 @@ - (void)updateStatusBar } if (self.showStatusBarOverlay) + { + [self.statusBarOverlay updateBarFrame]; self.statusBarOverlay.hidden = NO; + } else self.statusBarOverlay.hidden = YES; }