Permalink
Browse files

Finished TUIViewNSViewContainer

  • Loading branch information...
1 parent 91b4a21 commit 66c39d516feb192e0392659d2bf57a31d65b302c @jspahrsummers jspahrsummers committed Jul 17, 2012
@@ -481,6 +481,7 @@
D0C7655B15B6297300E7AC2C /* NSScrollView+TUIExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSScrollView+TUIExtensions.h"; sourceTree = "<group>"; };
D0C7655C15B6297300E7AC2C /* NSScrollView+TUIExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSScrollView+TUIExtensions.m"; sourceTree = "<group>"; };
D0C7656915B62EFA00E7AC2C /* TUINSView+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "TUINSView+Private.h"; sourceTree = "<group>"; };
+ D0C7656D15B6322A00E7AC2C /* TUIViewNSViewContainer+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "TUIViewNSViewContainer+Private.h"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -761,6 +762,7 @@
CBB74C8E13BE6E1900C85CB5 /* TUIViewController.m */,
CBB74C8F13BE6E1900C85CB5 /* TUIViewNSViewContainer.h */,
CBB74C9013BE6E1900C85CB5 /* TUIViewNSViewContainer.m */,
+ D0C7656D15B6322A00E7AC2C /* TUIViewNSViewContainer+Private.h */,
);
name = UIKit;
path = lib/UIKit;
View
@@ -53,6 +53,7 @@
#import "TUIView.h"
#import "TUIView+TUIBridgedView.h"
#import "TUIViewController.h"
+#import "TUIViewNSViewContainer.h"
extern CGContextRef TUIGraphicsGetCurrentContext(void);
extern void TUIGraphicsPushContext(CGContextRef context);
@@ -0,0 +1,58 @@
+//
+// TUIViewNSView+Private.h
+//
+// Created by James Lawton on 23.11.11.
+// Copyright (c) 2011 Bitswift. All rights reserved.
+//
+
+#import "TUIViewNSViewContainer.h"
+
+/**
+ * Private functionality of TUIViewNSViewContainer that needs to be exposed to other parts
+ * of the framework.
+ */
+@interface TUIViewNSViewContainer ()
+
+/**
+ * Whether the receiver is rendering its NSView.
+ */
+@property (nonatomic, getter = isRenderingContainedView, readonly) BOOL renderingContainedView;
+
+/**
+ * Renders the receiver's rootView once and caches into the receiver's layer,
+ * supporting an animation on the NSView as part of the TwUI hierarchy.
+ *
+ * This method can be called multiple times, but each call must eventually be
+ * balanced with a call to -stopRenderingContainedView.
+ */
+- (void)startRenderingContainedView;
+
+/**
+ * Balances a previous call to -startRenderingContainedView.
+ *
+ * If this balances the initial call to -startRenderingContainedView, the
+ * receiver stop rendering the rootView in its layer, and restore the normal
+ * AppKit rendering path.
+ *
+ * This method can be called multiple times to match multiple calls to
+ * -startRenderingContainedView.
+ */
+- (void)stopRenderingContainedView;
+
+/**
+ * The frame that the receiver's NSView should have at the time of call.
+ *
+ * This is used by -synchronizeNSViewGeometry to keep the NSView attached to
+ * its TwUI view.
+ *
+ * If the receiver has no host view, the value is undefined.
+ */
+@property (readonly) CGRect NSViewFrame;
+
+/**
+ * This will synchronize the geometry of the receiver's NSView with that of
+ * the receiver, ensuring that the NSView is laid out correctly on screen.
+ */
+- (void)synchronizeNSViewGeometry;
+
+@end
@@ -18,21 +18,47 @@
// which is copyright (c) 2012 Bitswift, Inc.
// See LICENSE.txt for more information.
+#import "NSView+TUIExtensions.h"
+#import "TUIHostView.h"
#import "TUIView.h"
-/*
- Stub class
- It would be nice to be able to embed NSView-based views inside of a
- TUIView-based view. The only ways I can think to do it are incredibly hacky.
- Plus, it still wouldn't work right if you apply CAAnimations. Maybe someone
- smarter than me can figure out a good way to do it.
+/**
+ * A view that is responsible for displaying and handling an NSView within the
+ * normal TwUI view hierarchy.
+ *
+ * TUIViewNSViewContainer is powerful, but many of its interactions with AppKit rely upon
+ * assumptions, magic, or unspecified behavior. To that end, there are several
+ * restrictions on what you can do with TUIViewNSViewContainer:
+ *
+ * - A TUIViewNSViewContainer must always appear on top of TwUI views. A TUIViewNSViewContainer
+ * should always appear at the end of a subview list. You should not attempt to
+ * add TwUI subviews directly to a TUIViewNSViewContainer. Instead, if you need TwUI
+ * views to appear on top, nest an TUINSView within the NSView and start
+ * a new TwUI hierarchy.
+ *
+ * - You must not modify the geometry of the hosted NSView. If you need to
+ * rearrange or resize the NSView, modify the TUIViewNSViewContainer and it will perform
+ * the necessary updates.
+ *
+ * - You must not touch the layer of the hosted NSView. If you wish to
+ * perform animations or apply other Core Animation effects, use the layer of
+ * the TUIViewNSViewContainer. Note that not all Core Animation features may be available.
+ *
+ * - You should not subclass TUIViewNSViewContainer. If you need additional features,
+ * create a new view class which contains a TUIViewNSViewContainer instead.
*/
+@interface TUIViewNSViewContainer : TUIView <TUIHostView>
-@interface TUIViewNSViewContainer : TUIView
-{
- NSView *nsView;
-}
+/**
+ * Initializes the receiver, setting its rootView to the given view.
+ *
+ * The frame of the receiver will automatically be set to that of the given view.
+ */
+- (id)initWithNSView:(NSView *)view;
-- (id)initWithNSView:(NSView *)v;
+/**
+ * The view displayed by the receiver.
+ */
+@property (nonatomic, strong) NSView *rootView;
@end
Oops, something went wrong.

0 comments on commit 66c39d5

Please sign in to comment.