Skip to content

Commit

Permalink
More scrolling tweaks; adding 2-axis scrolling view to example project
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian William Wolter committed Sep 27, 2011
1 parent 91c7aa9 commit d434ab9
Show file tree
Hide file tree
Showing 8 changed files with 320 additions and 107 deletions.
6 changes: 5 additions & 1 deletion ExampleProject/ConcordeExample/ExampleAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@

@interface ExampleAppDelegate : NSObject <NSApplicationDelegate>
{
NSWindow *window;
NSWindow * tableViewWindow;
NSWindow * scrollViewWindow;
}

-(IBAction)showTableViewExampleWindow:(id)sender;
-(IBAction)showScrollViewExampleWindow:(id)sender;

@end
67 changes: 48 additions & 19 deletions ExampleProject/ConcordeExample/ExampleAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,67 @@

#import "ExampleAppDelegate.h"
#import "ExampleView.h"
#import "ExampleScrollView.h"

@implementation ExampleAppDelegate

- (void)dealloc
{
[window release];
[tableViewWindow release];
[scrollViewWindow release];
[super dealloc];
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
CGRect b = CGRectMake(0, 0, 500, 450);

window = [[NSWindow alloc] initWithContentRect:b
styleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask
backing:NSBackingStoreBuffered
defer:NO];
[window setMinSize:NSMakeSize(300, 250)];
[window center];
/** Table View */
tableViewWindow = [[NSWindow alloc] initWithContentRect:b styleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask backing:NSBackingStoreBuffered defer:NO];
[tableViewWindow setReleasedWhenClosed:FALSE];
[tableViewWindow setMinSize:NSMakeSize(300, 250)];
[tableViewWindow center];

/* TUINSView is the bridge between the standard AppKit NSView-based heirarchy and the TUIView-based heirarchy */
TUINSView *tuiTableViewContainer = [[TUINSView alloc] initWithFrame:b];
[tableViewWindow setContentView:tuiTableViewContainer];
[tuiTableViewContainer release];

ExampleView *tableExample = [[ExampleView alloc] initWithFrame:b];
tuiTableViewContainer.rootView = tableExample;
[tableExample release];

/** Scroll View */
scrollViewWindow = [[NSWindow alloc] initWithContentRect:b styleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask backing:NSBackingStoreBuffered defer:YES];
[scrollViewWindow setReleasedWhenClosed:FALSE];
[scrollViewWindow setMinSize:NSMakeSize(300, 250)];
[scrollViewWindow setFrameTopLeftPoint:[tableViewWindow cascadeTopLeftFromPoint:CGPointMake(tableViewWindow.frame.origin.x, tableViewWindow.frame.origin.y + tableViewWindow.frame.size.height)]];

/* TUINSView is the bridge between the standard AppKit NSView-based heirarchy and the TUIView-based heirarchy */
TUINSView *tuiScrollViewContainer = [[TUINSView alloc] initWithFrame:b];
[scrollViewWindow setContentView:tuiScrollViewContainer];
[tuiScrollViewContainer release];

ExampleScrollView *scrollExample = [[ExampleScrollView alloc] initWithFrame:b];
tuiScrollViewContainer.rootView = scrollExample;
[scrollExample release];

[self showTableViewExampleWindow:nil];

}

/**
* @brief Show the table view example
*/
-(IBAction)showTableViewExampleWindow:(id)sender {
[tableViewWindow makeKeyAndOrderFront:sender];
}

/*
TUINSView is the bridge between the standard AppKit NSView-based heirarchy and the TUIView-based heirarchy
*/
TUINSView *tuiContainer = [[TUINSView alloc] initWithFrame:b];
[window setContentView:tuiContainer];
[tuiContainer release];

ExampleView *example = [[ExampleView alloc] initWithFrame:b];
tuiContainer.rootView = example;
[example release];

[window makeKeyAndOrderFront:nil];
/**
* @brief Show the scroll view example
*/
-(IBAction)showScrollViewExampleWindow:(id)sender {
[scrollViewWindow makeKeyAndOrderFront:sender];
}

@end
25 changes: 25 additions & 0 deletions ExampleProject/ConcordeExample/ExampleScrollView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
Copyright 2011 Twitter, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this work except in compliance with the License.
You may obtain a copy of the License in the LICENSE file, or at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#import "TUIKit.h"
#import "ExampleTabBar.h"

@interface ExampleScrollView : TUIView
{
TUIScrollView * _scrollView;
}

@end
46 changes: 46 additions & 0 deletions ExampleProject/ConcordeExample/ExampleScrollView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
Copyright 2011 Twitter, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this work except in compliance with the License.
You may obtain a copy of the License in the LICENSE file, or at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#import "ExampleScrollView.h"

@implementation ExampleScrollView

- (id)initWithFrame:(CGRect)frame
{
if((self = [super initWithFrame:frame])) {
self.backgroundColor = [TUIColor colorWithWhite:0.9 alpha:1.0];

_scrollView = [[TUIScrollView alloc] initWithFrame:self.bounds];
_scrollView.autoresizingMask = TUIViewAutoresizingFlexibleSize;
_scrollView.scrollIndicatorStyle = TUIScrollViewIndicatorStyleDark;
[self addSubview:_scrollView];

TUIImageView *imageView = [[TUIImageView alloc] initWithImage:[TUIImage imageNamed:@"large-image.jpeg"]];
[_scrollView addSubview:imageView];
[_scrollView setContentSize:imageView.frame.size];
[imageView release];

}
return self;
}

- (void)dealloc
{
[_scrollView release];
[super dealloc];
}

@end
Loading

0 comments on commit d434ab9

Please sign in to comment.