Skip to content

Commit

Permalink
add splitresizer; mostly broken
Browse files Browse the repository at this point in the history
  • Loading branch information
grp committed Jul 19, 2011
1 parent 5f33efc commit a4ba8b0
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
7 changes: 7 additions & 0 deletions splitresizer/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include theos/makefiles/common.mk

TWEAK_NAME = SplitResizer
SplitResizer_FILES = Tweak.xm
SplitResizer_FRAMEWORKS = UIKit

include $(THEOS_MAKE_PATH)/tweak.mk
1 change: 1 addition & 0 deletions splitresizer/SplitResizer.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ Filter = { Bundles = ( "com.apple.UIKit" ); }; }
65 changes: 65 additions & 0 deletions splitresizer/Tweak.xm
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

#import <UIKit/UIKit.h>

@interface UISplitViewController (Private)

- (UIViewController *)masterViewController;
- (UIViewController *)detailViewController;
- (CGRect)_detailViewFrame;
- (CGRect)_masterViewFrame;

- (void)viewWillLayoutSubviews;

@end

@interface UINavigationController (Private)

- (void)_layoutTopViewController;

@end

#define kHandleWidth 16.0f

%hook UISplitViewController

- (void)setGutterWidth:(CGFloat)width {
%log;
%orig(kHandleWidth);
}

%new(v@:@)
- (void)panFromRecognizer:(UIPanGestureRecognizer *)recognizer {
%log;

if ([recognizer state] == UIGestureRecognizerStateBegan || [recognizer state] == UIGestureRecognizerStateChanged) {
CGPoint location = [recognizer locationInView:self.view];
CGFloat offset = location.x - (kHandleWidth / 2);

NSLog(@"Resizing view to offset: %f", offset);
[self setMasterColumnWidth:offset];
if ([[self masterViewController] isKindOfClass:[UINavigationController class]])
[(UINavigationController *) [self masterViewController] _layoutTopViewController];
if ([[self detailViewController] isKindOfClass:[UINavigationController class]])
[(UINavigationController *) [self detailViewController] _layoutTopViewController];
[recognizer.view setFrame:CGRectMake(offset, 0, kHandleWidth, [self.view bounds].size.height)];
}
}

- (void)_commonInit {
%orig;

[self setGutterWidth:kHandleWidth];

UIView *dragView = [[UIView alloc] initWithFrame:CGRectMake([self masterColumnWidth], 0, kHandleWidth, [self.view bounds].size.height)];
[dragView setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
[self.view addSubview:dragView];
[dragView release];

UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panFromRecognizer:)];
[dragView addGestureRecognizer:panRecognizer];
[panRecognizer release];
}

%end


9 changes: 9 additions & 0 deletions splitresizer/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Package: com.chpwn.splitresizer
Name: SplitResizer
Depends: mobilesubstrate
Version: 0.0.1
Architecture: iphoneos-arm
Description: An awesome MobileSubstrate tweak!
Maintainer: Grant Paul
Author: Grant Paul
Section: Tweaks

0 comments on commit a4ba8b0

Please sign in to comment.