mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
CPTabView: load tab view items asynchronously when possible (#2479)
When an item created with +tabViewItemWithViewController:, the view is loaded asynchronously Manual test CPTabViewNib have been modified to show a tab view item managed by a view controller. Any setup happens in -viewDidAppear: because we cannot use any more the tabView:didSelectTabViewItem: delegate method.
This commit is contained in:
+29
-2
@@ -335,13 +335,40 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 1,
|
||||
|
||||
[_tabs setSelectedSegment:anIndex];
|
||||
_selectedTabViewItem = aTabViewItem;
|
||||
[self _displayItemView:[aTabViewItem view]];
|
||||
[self _loadTabViewItem:aTabViewItem];
|
||||
|
||||
[self _sendDelegateDidSelectTabViewItem:aTabViewItem];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)_loadTabViewItem:(CPTabViewItem)aTabViewItem
|
||||
{
|
||||
var controller = [aTabViewItem viewController];
|
||||
|
||||
if (controller !== nil && ![controller isViewLoaded])
|
||||
{
|
||||
[controller loadViewWithCompletionHandler:function(view, error)
|
||||
{
|
||||
if (error !== nil)
|
||||
{
|
||||
CPLog.warn("Could not load the view for item " + aTabViewItem + ". " + error);
|
||||
}
|
||||
else if (view !== nil)
|
||||
{
|
||||
[aTabViewItem setView:view];
|
||||
|
||||
if ([self selectedTabViewItem] == aTabViewItem)
|
||||
[self _displayItemView:view];
|
||||
}
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self _displayItemView:[aTabViewItem view]];
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the current item being displayed.
|
||||
@return the tab view item currenly being displayed by the receiver
|
||||
@@ -848,4 +875,4 @@ var CPTabViewItemsKey = "CPTabViewItemsKey",
|
||||
return [super hitTest:aPoint];
|
||||
}
|
||||
|
||||
@end
|
||||
@end
|
||||
|
||||
@@ -270,7 +270,7 @@ CPPressedTab = 2;
|
||||
[self setLabel:title];
|
||||
|
||||
if ([_tabView selectedTabViewItem] == self)
|
||||
[_tabView _displayItemView:[_viewController view]];
|
||||
[_tabView _loadTabViewItem:self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
@import <AppKit/AppKit.j>
|
||||
@import <Foundation/CPObject.j>
|
||||
@import "TabViewController.j"
|
||||
|
||||
CPLogRegister(CPLogConsole);
|
||||
|
||||
@@ -15,7 +16,6 @@ CPLogRegister(CPLogConsole);
|
||||
CPWindow theWindow; //this "outlet" is connected automatically by the Cib
|
||||
@outlet CPTabView nibTabView;
|
||||
@outlet CPTabView nibTabViewEmpty;
|
||||
@outlet CPViewController viewController;
|
||||
@outlet CPStepper insertStepper;
|
||||
@outlet CPStepper removeStepper;
|
||||
@outlet CPButton fromViewController;
|
||||
@@ -23,23 +23,25 @@ CPLogRegister(CPLogConsole);
|
||||
|
||||
- (IBAction)insertTabViewItem:(id)sender
|
||||
{
|
||||
var idx = [insertStepper intValue],
|
||||
item;
|
||||
|
||||
if ([fromViewController state])
|
||||
item = [CPTabViewItem tabViewItemWithViewController:viewController];
|
||||
else
|
||||
{
|
||||
item = [[CPTabViewItem alloc] initWithIdentifier:@"Insert" + idx];
|
||||
var view = [[CPView alloc] initWithFrame:CGRectMakeZero()];
|
||||
[view setBackgroundColor:[CPColor randomColor]];
|
||||
[item setView:view];
|
||||
[item setLabel:@"Insert" + idx];
|
||||
}
|
||||
var idx = [insertStepper objectValue];
|
||||
var item = [[CPTabViewItem alloc] initWithIdentifier:@"Insert" + idx];
|
||||
var view = [[CPView alloc] initWithFrame:CGRectMakeZero()];
|
||||
[view setBackgroundColor:[CPColor randomColor]];
|
||||
[item setView:view];
|
||||
[item setLabel:@"Insert" + idx];
|
||||
|
||||
[nibTabView insertTabViewItem:item atIndex:idx];
|
||||
}
|
||||
|
||||
- (IBAction)insertViewControllerTabViewItem:(id)sender
|
||||
{
|
||||
var ctl = [[TabViewController alloc] initWithCibName:@"TabViewItem" bundle:nil];
|
||||
[ctl setTitle:@"View Controller"];
|
||||
var item = [CPTabViewItem tabViewItemWithViewController:ctl];
|
||||
|
||||
[nibTabView insertTabViewItem:item atIndex:0];
|
||||
}
|
||||
|
||||
- (IBAction)removeTabViewItem:(id)sender
|
||||
{
|
||||
var idx = [removeStepper intValue],
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15E65" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="NSViewController">
|
||||
<connections>
|
||||
<outlet property="view" destination="c22-O7-iKe" id="qxT-KH-2c6"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView id="c22-O7-iKe" customClass="CPView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="90" height="40"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2mc-qc-fMw">
|
||||
<rect key="frame" x="3" y="2" width="81" height="32"/>
|
||||
<buttonCell key="cell" type="push" title="Button" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Xfn-8O-d0Z">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<binding destination="-2" name="title" keyPath="representedObject" id="r8y-dc-uru"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<point key="canvasLocation" x="218" y="301"/>
|
||||
</customView>
|
||||
</objects>
|
||||
</document>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,31 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6751" systemVersion="14C109" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" customObjectInstantitationMethod="direct">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11191" systemVersion="15G31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6751"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11191"/>
|
||||
<capability name="box content view" minToolsVersion="7.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="NSViewController">
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="TabViewController">
|
||||
<connections>
|
||||
<outlet property="view" destination="c22-O7-iKe" id="DCH-07-kCx"/>
|
||||
<outlet property="view" destination="8Ad-lT-bWg" id="p21-3P-cjc"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView id="c22-O7-iKe" customClass="CPView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="406" height="263"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<customView misplaced="YES" id="8Ad-lT-bWg" customClass="CPView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="279" height="203"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="FdY-tR-zTk">
|
||||
<rect key="frame" x="97" y="120" width="212" height="22"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" borderStyle="bezel" alignment="center" title="CPViewController TabViewItem" id="z8j-pD-CWg">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<box misplaced="YES" boxType="custom" cornerRadius="4" title="Box" titlePosition="noTitle" id="9We-aw-hQG">
|
||||
<rect key="frame" x="0.0" y="0.0" width="279" height="203"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<view key="contentView" id="agn-Mc-GSl">
|
||||
<rect key="frame" x="1" y="1" width="277" height="201"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" id="Pte-FL-dac">
|
||||
<rect key="frame" x="18" y="92" width="241" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="This view was loaded asynchronously" id="gqq-al-SMS">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</subviews>
|
||||
</view>
|
||||
<color key="fillColor" red="0.28570679530201343" green="0.55335046140939592" blue="0.72320679530201337" alpha="1" colorSpace="calibratedRGB"/>
|
||||
</box>
|
||||
</subviews>
|
||||
<point key="canvasLocation" x="376" y="412.5"/>
|
||||
<point key="canvasLocation" x="185.5" y="313.5"/>
|
||||
</customView>
|
||||
<collectionViewItem nibName="CollectionViewItem" id="fGB-7s-LKj"/>
|
||||
</objects>
|
||||
</document>
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
@implementation TabViewController : CPViewController
|
||||
{
|
||||
}
|
||||
|
||||
- (void)viewDidAppear
|
||||
{
|
||||
CPLog.debug(_cmd);
|
||||
var view = [self view];
|
||||
|
||||
[view setFrameSize:[[view superview] frameSize]];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -31,8 +31,6 @@
|
||||
6841F2461AF98CE600CFE60E /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6841F2451AF98CE600CFE60E /* Images.xcassets */; };
|
||||
6841F26C1AF98DDD00CFE60E /* mod_pbxproj.py in Resources */ = {isa = PBXBuildFile; fileRef = 6841F2691AF98DDD00CFE60E /* mod_pbxproj.py */; };
|
||||
6841F26E1AF98DDD00CFE60E /* pbxprojModifier.py in Resources */ = {isa = PBXBuildFile; fileRef = 6841F26B1AF98DDD00CFE60E /* pbxprojModifier.py */; };
|
||||
6841F27C1AF990C300CFE60E /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 6841F27A1AF990C300CFE60E /* Debug.xcconfig */; };
|
||||
6841F27D1AF990C300CFE60E /* Release.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 6841F27B1AF990C300CFE60E /* Release.xcconfig */; };
|
||||
6841F2A51AF9932300CFE60E /* project.pbxproj in Resources */ = {isa = PBXBuildFile; fileRef = 6841F28A1AF9932300CFE60E /* project.pbxproj */; };
|
||||
6841F2B71AFA83D500CFE60E /* XCCUserDefaults.m in Sources */ = {isa = PBXBuildFile; fileRef = 6841F2B61AFA83D500CFE60E /* XCCUserDefaults.m */; };
|
||||
6841F2BF1AFA965300CFE60E /* XCCTaskLauncher.m in Sources */ = {isa = PBXBuildFile; fileRef = 6841F2BE1AFA965300CFE60E /* XCCTaskLauncher.m */; };
|
||||
@@ -324,7 +322,7 @@
|
||||
6841F2331AF98CE600CFE60E /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0630;
|
||||
LastUpgradeCheck = 0800;
|
||||
ORGANIZATIONNAME = "cappuccino-project";
|
||||
TargetAttributes = {
|
||||
6841F23A1AF98CE600CFE60E = {
|
||||
@@ -364,10 +362,8 @@
|
||||
021B94671B20D1F800F12DDA /* OperationsView.xib in Resources */,
|
||||
021B94711B20E31F00F12DDA /* SettingsView.xib in Resources */,
|
||||
0258004B1B1E67090000EB7D /* supawhich in Resources */,
|
||||
6841F27C1AF990C300CFE60E /* Debug.xcconfig in Resources */,
|
||||
6841F26E1AF98DDD00CFE60E /* pbxprojModifier.py in Resources */,
|
||||
6841F2A51AF9932300CFE60E /* project.pbxproj in Resources */,
|
||||
6841F27D1AF990C300CFE60E /* Release.xcconfig in Resources */,
|
||||
0257A65B1B3A2B0000015C1F /* MainMenu.xib in Resources */,
|
||||
6841F26C1AF98DDD00CFE60E /* mod_pbxproj.py in Resources */,
|
||||
021B94691B20D6FC00F12DDA /* ErrorsView.xib in Resources */,
|
||||
@@ -437,8 +433,10 @@
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
@@ -447,6 +445,7 @@
|
||||
DEPLOYMENT_LOCATION = YES;
|
||||
DSTROOT = /;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
@@ -462,7 +461,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.7;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.8;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = macosx;
|
||||
@@ -483,8 +482,10 @@
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
@@ -502,7 +503,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.7;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.8;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = macosx;
|
||||
};
|
||||
@@ -518,6 +519,7 @@
|
||||
INFOPLIST_FILE = XcodeCapp/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.7;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.cappuccino.xcodecapp;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Debug;
|
||||
@@ -532,6 +534,7 @@
|
||||
INFOPLIST_FILE = XcodeCapp/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.7;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.cappuccino.xcodecapp;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Release;
|
||||
|
||||
@@ -32,4 +32,4 @@
|
||||
- (IBAction)openAbout:(id)aSender;
|
||||
- (IBAction)openPreferences:(id)aSender;
|
||||
|
||||
@end
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user