Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #68 from bww/master

Various scroll view improvements
  • Loading branch information...
commit 65addb39e159c1f9f5ce58f040affce5119bbc64 2 parents a302717 + f2643b1
@atebits atebits authored
View
6 ExampleProject/ConcordeExample/ExampleAppDelegate.h
@@ -19,7 +19,11 @@
@interface ExampleAppDelegate : NSObject <NSApplicationDelegate>
{
- NSWindow *window;
+ NSWindow * tableViewWindow;
+ NSWindow * scrollViewWindow;
}
+-(IBAction)showTableViewExampleWindow:(id)sender;
+-(IBAction)showScrollViewExampleWindow:(id)sender;
+
@end
View
67 ExampleProject/ConcordeExample/ExampleAppDelegate.m
@@ -16,12 +16,14 @@
#import "ExampleAppDelegate.h"
#import "ExampleView.h"
+#import "ExampleScrollView.h"
@implementation ExampleAppDelegate
- (void)dealloc
{
- [window release];
+ [tableViewWindow release];
+ [scrollViewWindow release];
[super dealloc];
}
@@ -29,25 +31,52 @@ - (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
View
25 ExampleProject/ConcordeExample/ExampleScrollView.h
@@ -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
View
46 ExampleProject/ConcordeExample/ExampleScrollView.m
@@ -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
View
257 ExampleProject/ConcordeExample/en.lproj/MainMenu.xib
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
- <int key="IBDocument.SystemTarget">1060</int>
- <string key="IBDocument.SystemVersion">11A480e</string>
- <string key="IBDocument.InterfaceBuilderVersion">1592</string>
- <string key="IBDocument.AppKitVersion">1127</string>
- <string key="IBDocument.HIToolboxVersion">561.00</string>
+ <int key="IBDocument.SystemTarget">1070</int>
+ <string key="IBDocument.SystemVersion">11B26</string>
+ <string key="IBDocument.InterfaceBuilderVersion">1934</string>
+ <string key="IBDocument.AppKitVersion">1138</string>
+ <string key="IBDocument.HIToolboxVersion">566.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="NS.object.0">1592</string>
+ <string key="NS.object.0">1934</string>
</object>
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -21,11 +21,8 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSArray" key="dict.sortedKeys" id="0">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
- <reference key="dict.values" ref="0"/>
+ <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
+ <integer value="1" key="NS.object.0"/>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1048">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1273,6 +1270,34 @@
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
+ <object class="NSMenuItem" id="416175109">
+ <reference key="NSMenu" ref="835318025"/>
+ <string key="NSTitle">Table Example</string>
+ <string key="NSKeyEquiv">1</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="35465992"/>
+ <reference key="NSMixedImage" ref="502551668"/>
+ </object>
+ <object class="NSMenuItem" id="441024329">
+ <reference key="NSMenu" ref="835318025"/>
+ <string key="NSTitle">Scroll View Example</string>
+ <string key="NSKeyEquiv">2</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="35465992"/>
+ <reference key="NSMixedImage" ref="502551668"/>
+ </object>
+ <object class="NSMenuItem" id="193357256">
+ <reference key="NSMenu" ref="835318025"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="35465992"/>
+ <reference key="NSMixedImage" ref="502551668"/>
+ </object>
<object class="NSMenuItem" id="625202149">
<reference key="NSMenu" ref="835318025"/>
<string key="NSTitle">Bring All to Front</string>
@@ -1326,6 +1351,30 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
+ <string key="label">terminate:</string>
+ <reference key="source" ref="1050"/>
+ <reference key="destination" ref="632727374"/>
+ </object>
+ <int key="connectionID">449</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">orderFrontStandardAboutPanel:</string>
+ <reference key="source" ref="1021"/>
+ <reference key="destination" ref="238522557"/>
+ </object>
+ <int key="connectionID">142</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="1021"/>
+ <reference key="destination" ref="976324537"/>
+ </object>
+ <int key="connectionID">495</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
<string key="label">performMiniaturize:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="1011231497"/>
@@ -1366,14 +1415,6 @@
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
- <string key="label">orderFrontStandardAboutPanel:</string>
- <reference key="source" ref="1021"/>
- <reference key="destination" ref="238522557"/>
- </object>
- <int key="connectionID">142</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
<string key="label">performClose:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="776162233"/>
@@ -1614,46 +1655,6 @@
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
- <string key="label">addFontTrait:</string>
- <reference key="source" ref="755631768"/>
- <reference key="destination" ref="305399458"/>
- </object>
- <int key="connectionID">421</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">addFontTrait:</string>
- <reference key="source" ref="755631768"/>
- <reference key="destination" ref="814362025"/>
- </object>
- <int key="connectionID">422</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">modifyFont:</string>
- <reference key="source" ref="755631768"/>
- <reference key="destination" ref="885547335"/>
- </object>
- <int key="connectionID">423</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">orderFrontFontPanel:</string>
- <reference key="source" ref="755631768"/>
- <reference key="destination" ref="159677712"/>
- </object>
- <int key="connectionID">424</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">modifyFont:</string>
- <reference key="source" ref="755631768"/>
- <reference key="destination" ref="158063935"/>
- </object>
- <int key="connectionID">425</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
<string key="label">raiseBaseline:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="941806246"/>
@@ -1782,14 +1783,6 @@
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
- <string key="label">terminate:</string>
- <reference key="source" ref="1050"/>
- <reference key="destination" ref="632727374"/>
- </object>
- <int key="connectionID">449</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
<string key="label">toggleAutomaticSpellingCorrection:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="795346622"/>
@@ -1885,14 +1878,6 @@
<int key="connectionID">493</int>
</object>
<object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">delegate</string>
- <reference key="source" ref="1021"/>
- <reference key="destination" ref="976324537"/>
- </object>
- <int key="connectionID">495</int>
- </object>
- <object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">alignCenter:</string>
<reference key="source" ref="1014"/>
@@ -1996,13 +1981,71 @@
</object>
<int key="connectionID">530</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">addFontTrait:</string>
+ <reference key="source" ref="755631768"/>
+ <reference key="destination" ref="305399458"/>
+ </object>
+ <int key="connectionID">421</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">addFontTrait:</string>
+ <reference key="source" ref="755631768"/>
+ <reference key="destination" ref="814362025"/>
+ </object>
+ <int key="connectionID">422</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">modifyFont:</string>
+ <reference key="source" ref="755631768"/>
+ <reference key="destination" ref="885547335"/>
+ </object>
+ <int key="connectionID">423</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">orderFrontFontPanel:</string>
+ <reference key="source" ref="755631768"/>
+ <reference key="destination" ref="159677712"/>
+ </object>
+ <int key="connectionID">424</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">modifyFont:</string>
+ <reference key="source" ref="755631768"/>
+ <reference key="destination" ref="158063935"/>
+ </object>
+ <int key="connectionID">425</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">showTableViewExampleWindow:</string>
+ <reference key="source" ref="976324537"/>
+ <reference key="destination" ref="416175109"/>
+ </object>
+ <int key="connectionID">536</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">showScrollViewExampleWindow:</string>
+ <reference key="source" ref="976324537"/>
+ <reference key="destination" ref="441024329"/>
+ </object>
+ <int key="connectionID">537</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
- <reference key="object" ref="0"/>
+ <object class="NSArray" key="object" id="0">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
<reference key="children" ref="1048"/>
<nil key="parent"/>
</object>
@@ -2412,6 +2455,9 @@
<reference ref="625202149"/>
<reference ref="575023229"/>
<reference ref="1011231497"/>
+ <reference ref="416175109"/>
+ <reference ref="441024329"/>
+ <reference ref="193357256"/>
</object>
<reference key="parent" ref="713487014"/>
</object>
@@ -3023,6 +3069,21 @@
<reference key="object" ref="560145579"/>
<reference key="parent" ref="956096989"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">533</int>
+ <reference key="object" ref="416175109"/>
+ <reference key="parent" ref="835318025"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">534</int>
+ <reference key="object" ref="441024329"/>
+ <reference key="parent" ref="835318025"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">535</int>
+ <reference key="object" ref="193357256"/>
+ <reference key="parent" ref="835318025"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -3164,6 +3225,9 @@
<string>515.IBPluginDependency</string>
<string>516.IBPluginDependency</string>
<string>517.IBPluginDependency</string>
+ <string>533.IBPluginDependency</string>
+ <string>534.IBPluginDependency</string>
+ <string>535.IBPluginDependency</string>
<string>56.IBPluginDependency</string>
<string>57.IBPluginDependency</string>
<string>58.IBPluginDependency</string>
@@ -3332,6 +3396,9 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
@@ -3346,7 +3413,7 @@
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
- <int key="maxID">532</int>
+ <int key="maxID">537</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -3354,6 +3421,38 @@
<object class="IBPartialClassDescription">
<string key="className">ExampleAppDelegate</string>
<string key="superclassName">NSObject</string>
+ <object class="NSMutableDictionary" key="actions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>showScrollViewExampleWindow:</string>
+ <string>showTableViewExampleWindow:</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>id</string>
+ <string>id</string>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="actionInfosByName">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>showScrollViewExampleWindow:</string>
+ <string>showTableViewExampleWindow:</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBActionInfo">
+ <string key="name">showScrollViewExampleWindow:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBActionInfo">
+ <string key="name">showTableViewExampleWindow:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ </object>
+ </object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/ExampleAppDelegate.h</string>
@@ -3430,10 +3529,6 @@
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
- <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
- <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
- <integer value="1060" key="NS.object.0"/>
- </object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
<integer value="3000" key="NS.object.0"/>
View
BIN  ExampleProject/ConcordeExample/large-image.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
13 ExampleProject/Example.xcodeproj/project.pbxproj
@@ -68,6 +68,8 @@
5ED56736139DC35800031CDF /* CoreText+Additions.m in Sources */ = {isa = PBXBuildFile; fileRef = 5ED56732139DC35800031CDF /* CoreText+Additions.m */; };
D3502AAE13EA0FE4007C5CA7 /* TUITableView+Cell.m in Sources */ = {isa = PBXBuildFile; fileRef = D3502AAD13EA0FE4007C5CA7 /* TUITableView+Cell.m */; };
D3CE671313C6646B00D47B2D /* ExampleSectionHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = D3CE671213C6646B00D47B2D /* ExampleSectionHeaderView.m */; };
+ D3EC0C491432325A003C162C /* ExampleScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = D3EC0C471432325A003C162C /* ExampleScrollView.m */; };
+ D3EC0C4A1432325A003C162C /* large-image.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = D3EC0C481432325A003C162C /* large-image.jpeg */; };
D3FA4CA913F85B7100860379 /* TUITableViewSectionHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = D3FA4CA813F85B7100860379 /* TUITableViewSectionHeader.m */; };
D3FA4CBA13F85BC100860379 /* TUIAccessibilityElement.m in Sources */ = {isa = PBXBuildFile; fileRef = D3FA4CAF13F85BC100860379 /* TUIAccessibilityElement.m */; };
D3FA4CBB13F85BC100860379 /* TUIButton+Accessibility.m in Sources */ = {isa = PBXBuildFile; fileRef = D3FA4CB113F85BC100860379 /* TUIButton+Accessibility.m */; };
@@ -193,6 +195,9 @@
D3502AAD13EA0FE4007C5CA7 /* TUITableView+Cell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "TUITableView+Cell.m"; sourceTree = "<group>"; };
D3CE671113C6646B00D47B2D /* ExampleSectionHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExampleSectionHeaderView.h; sourceTree = "<group>"; };
D3CE671213C6646B00D47B2D /* ExampleSectionHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleSectionHeaderView.m; sourceTree = "<group>"; };
+ D3EC0C461432325A003C162C /* ExampleScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExampleScrollView.h; sourceTree = "<group>"; };
+ D3EC0C471432325A003C162C /* ExampleScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleScrollView.m; sourceTree = "<group>"; };
+ D3EC0C481432325A003C162C /* large-image.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "large-image.jpeg"; sourceTree = "<group>"; };
D3FA4CA713F85B7100860379 /* TUITableViewSectionHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TUITableViewSectionHeader.h; sourceTree = "<group>"; };
D3FA4CA813F85B7100860379 /* TUITableViewSectionHeader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TUITableViewSectionHeader.m; sourceTree = "<group>"; };
D3FA4CAE13F85BC100860379 /* TUIAccessibilityElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TUIAccessibilityElement.h; sourceTree = "<group>"; };
@@ -282,6 +287,8 @@
5ED5668A139DC30300031CDF /* ExampleAppDelegate.m */,
5C55D83213A667A0000ED768 /* ExampleView.h */,
5C55D83313A667A0000ED768 /* ExampleView.m */,
+ D3EC0C461432325A003C162C /* ExampleScrollView.h */,
+ D3EC0C471432325A003C162C /* ExampleScrollView.m */,
5C90DB9B13A7C08D00ECDD14 /* ExampleTabBar.h */,
5C90DB9C13A7C08D00ECDD14 /* ExampleTabBar.m */,
5C55D83513A66BD5000ED768 /* ExampleTableViewCell.h */,
@@ -297,6 +304,7 @@
5ED5667E139DC30300031CDF /* Supporting Files */ = {
isa = PBXGroup;
children = (
+ D3EC0C481432325A003C162C /* large-image.jpeg */,
5C57CF3C13A7E7C00032AC1F /* clock.png */,
5ED5667F139DC30300031CDF /* Example-Info.plist */,
5ED56680139DC30300031CDF /* InfoPlist.strings */,
@@ -440,6 +448,9 @@
/* Begin PBXProject section */
5ED5666A139DC30300031CDF /* Project object */ = {
isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0420;
+ };
buildConfigurationList = 5ED5666D139DC30300031CDF /* Build configuration list for PBXProject "Example" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
@@ -466,6 +477,7 @@
5ED56688139DC30300031CDF /* Credits.rtf in Resources */,
5ED5668E139DC30300031CDF /* MainMenu.xib in Resources */,
5C57CF3D13A7E7C00032AC1F /* clock.png in Resources */,
+ D3EC0C4A1432325A003C162C /* large-image.jpeg in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -537,6 +549,7 @@
D3FA4CBD13F85BC100860379 /* TUIControl+Private.m in Sources */,
D3FA4CBE13F85BC100860379 /* TUINSView+Accessibility.m in Sources */,
D3FA4CBF13F85BC100860379 /* TUIView+Accessibility.m in Sources */,
+ D3EC0C491432325A003C162C /* ExampleScrollView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
46 lib/UIKit/TUIScrollKnob.m
@@ -57,16 +57,16 @@ - (BOOL)isVertical
}
#define KNOB_CALCULATIONS(OFFSET, LENGTH, MIN_KNOB_SIZE) \
-float proportion = visible.size.LENGTH / contentSize.LENGTH; \
-float knobLength = trackBounds.size.LENGTH * proportion; \
-if(knobLength < MIN_KNOB_SIZE) knobLength = MIN_KNOB_SIZE; \
-float rangeOfMotion = trackBounds.size.LENGTH - knobLength; \
-float maxOffset = contentSize.LENGTH - visible.size.LENGTH; \
-float currentOffset = visible.origin.OFFSET; \
-float offsetProportion = 1.0 - (maxOffset - currentOffset) / maxOffset; \
-float knobOffset = offsetProportion * rangeOfMotion; \
-if(isnan(knobOffset)) knobOffset = 0.0; \
-if(isnan(knobLength)) knobLength = 0.0;
+ float proportion = visible.size.LENGTH / contentSize.LENGTH; \
+ float knobLength = trackBounds.size.LENGTH * proportion; \
+ if(knobLength < MIN_KNOB_SIZE) knobLength = MIN_KNOB_SIZE; \
+ float rangeOfMotion = trackBounds.size.LENGTH - knobLength; \
+ float maxOffset = contentSize.LENGTH - visible.size.LENGTH; \
+ float currentOffset = visible.origin.OFFSET; \
+ float offsetProportion = 1.0 - (maxOffset - currentOffset) / maxOffset; \
+ float knobOffset = offsetProportion * rangeOfMotion; \
+ if(isnan(knobOffset)) knobOffset = 0.0; \
+ if(isnan(knobLength)) knobLength = 0.0;
#define DEFAULT_MIN_KNOB_SIZE 25
@@ -81,23 +81,19 @@ - (void)_updateKnob
CGRect frame;
frame.origin.x = 0.0;
frame.origin.y = knobOffset;
- frame.size.height = knobLength;
+ frame.size.height = MIN(2000, knobLength);
frame.size.width = trackBounds.size.width;
-
- if(frame.size.height > 2000) {
- frame.size.height = 2000;
- }
-
knob.frame = ABRectRoundOrigin(CGRectInset(frame, 2, 4));
} else {
KNOB_CALCULATIONS(x, width, DEFAULT_MIN_KNOB_SIZE)
CGRect frame;
frame.origin.x = knobOffset;
frame.origin.y = 0.0;
- frame.size.width = knobLength;
+ frame.size.width = MIN(2000, knobLength);
frame.size.height = trackBounds.size.height;
- knob.frame = ABRectRoundOrigin(CGRectInset(frame, 2, 4));
+ knob.frame = ABRectRoundOrigin(CGRectInset(frame, 4, 2));
}
+
}
- (void)layoutSubviews
@@ -204,13 +200,13 @@ - (void)mouseUp:(NSEvent *)event
}
#define KNOB_CALCULATIONS_REVERSE(OFFSET, LENGTH) \
-CGRect knobFrame = _knobStartFrame; \
-knobFrame.origin.OFFSET += diff.LENGTH; \
-CGFloat knobOffset = knobFrame.origin.OFFSET; \
-CGFloat minKnobOffset = 0.0; \
-CGFloat maxKnobOffset = trackBounds.size.LENGTH - knobFrame.size.LENGTH; \
-CGFloat proportion = (knobOffset - 1.0) / (maxKnobOffset - minKnobOffset); \
-CGFloat maxContentOffset = contentSize.LENGTH - visible.size.LENGTH;
+ CGRect knobFrame = _knobStartFrame; \
+ knobFrame.origin.OFFSET += diff.LENGTH; \
+ CGFloat knobOffset = knobFrame.origin.OFFSET; \
+ CGFloat minKnobOffset = 0.0; \
+ CGFloat maxKnobOffset = trackBounds.size.LENGTH - knobFrame.size.LENGTH; \
+ CGFloat proportion = (knobOffset - 1.0) / (maxKnobOffset - minKnobOffset); \
+ CGFloat maxContentOffset = contentSize.LENGTH - visible.size.LENGTH;
- (void)mouseDragged:(NSEvent *)event
{
View
16 lib/UIKit/TUIScrollView.h
@@ -110,11 +110,12 @@ typedef enum {
BOOL bouncing;
} _bounce;
- struct {
- float x;
- float y;
- BOOL pulling; // horizontal pulling not done yet, this flag should be split
- } _pull;
+ struct {
+ float x;
+ float y;
+ BOOL xPulling;
+ BOOL yPulling;
+ } _pull;
CGPoint _dragScrollLocation;
@@ -123,6 +124,8 @@ typedef enum {
struct {
unsigned int didChangeContentInset:1;
unsigned int bounceEnabled:1;
+ unsigned int alwaysBounceVertical:1;
+ unsigned int alwaysBounceHorizontal:1;
unsigned int mouseInside:1;
unsigned int mouseDownInScrollKnob:1;
unsigned int ignoreNextScrollPhaseNormal_10_7:1;
@@ -146,6 +149,9 @@ typedef enum {
@property (nonatomic) CGPoint contentOffset;
@property (nonatomic) CGSize contentSize;
+@property (nonatomic) BOOL bounces;
+@property (nonatomic) BOOL alwaysBounceVertical;
+@property (nonatomic) BOOL alwaysBounceHorizontal;
@property (nonatomic) CGSize resizeKnobSize;
@property (nonatomic) TUIEdgeInsets contentInset;
@property (nonatomic, assign) id<TUIScrollViewDelegate> delegate;
View
288 lib/UIKit/TUIScrollView.m
@@ -41,12 +41,15 @@
};
@interface TUIScrollView (Private)
+
+- (BOOL)_pulling;
- (BOOL)_verticalScrollKnobNeededForContentSize:(CGSize)size;
- (BOOL)_horizonatlScrollKnobNeededForContentSize:(CGSize)size;
- (void)_updateScrollKnobs;
- (void)_updateScrollKnobsAnimated:(BOOL)animated;
- (void)_updateBounce;
- (void)_startTimer:(int)scrollMode;
+
@end
@implementation TUIScrollView
@@ -68,6 +71,8 @@ - (id)initWithFrame:(CGRect)frame
decelerationRate = 0.88;
_scrollViewFlags.bounceEnabled = (FORCE_ENABLE_BOUNCE || AtLeastLion || [[NSUserDefaults standardUserDefaults] boolForKey:@"ForceEnableScrollBouncing"]);
+ _scrollViewFlags.alwaysBounceVertical = FALSE;
+ _scrollViewFlags.alwaysBounceHorizontal = FALSE;
_scrollViewFlags.verticalScrollIndicatorVisibility = TUIScrollViewIndicatorVisibleDefault;
_scrollViewFlags.horizontalScrollIndicatorVisibility = TUIScrollViewIndicatorVisibleDefault;
@@ -217,13 +222,10 @@ - (void)setContentInset:(TUIEdgeInsets)i
{
if(!TUIEdgeInsetsEqualToEdgeInsets(i, _contentInset)) {
_contentInset = i;
-
- if(_pull.pulling) {
+ if(self._pulling){
_scrollViewFlags.didChangeContentInset = 1;
- } else {
- if(!self.dragging) {
- self.contentOffset = self.contentOffset;
- }
+ }else if(!self.dragging) {
+ self.contentOffset = self.contentOffset;
}
}
}
@@ -400,20 +402,22 @@ - (void)_updateScrollKnobsAnimated:(BOOL)animated {
break;
}
-// float bounceX = (-self.bounceOffset.x - self.pullOffset.x) * 1.2;
- float bounceY = (-self.bounceOffset.y - self.pullOffset.y) * 1.2;
+ float pullX = self.bounceOffset.x + self.pullOffset.x;
+ float pullY = -self.bounceOffset.y - self.pullOffset.y;
+ float bounceX = pullX * 1.2;
+ float bounceY = pullY * 1.2;
_verticalScrollKnob.frame = CGRectMake(
- round(-offset.x + bounds.size.width - knobSize), // x
- round(-offset.y + (hVisible?knobSize:0) + resizeKnobSize.height + bounceY), // y
+ round(-offset.x + bounds.size.width - knobSize - pullX), // x
+ round(-offset.y + (hVisible ? knobSize : 0) + resizeKnobSize.height + bounceY), // y
knobSize, // width
- bounds.size.height - (hVisible?knobSize:0) - resizeKnobSize.height // height
+ bounds.size.height - (hVisible ? knobSize : 0) - resizeKnobSize.height // height
);
_horizontalScrollKnob.frame = CGRectMake(
- round(-offset.x), // x
- round(-offset.y), // y
- bounds.size.width - (vVisible?knobSize:0) - resizeKnobSize.width, // width
+ round(-offset.x - bounceX), // x
+ round(-offset.y + pullY), // y
+ bounds.size.width - (vVisible ? knobSize : 0) - resizeKnobSize.width, // width
knobSize // height
);
@@ -505,29 +509,42 @@ static CGPoint PointLerp(CGPoint a, CGPoint b, CGFloat t)
- (CGPoint)contentOffset
{
CGPoint p = _unroundedContentOffset;
- p.x = roundf(p.x);
+ p.x = roundf(p.x + self.bounceOffset.x + self.pullOffset.x);
p.y = roundf(p.y + self.bounceOffset.y + self.pullOffset.y);
return p;
}
+/**
+ * @internal
+ * @brief Determine if we are pulling on either axis
+ * @return pulling or not
+ */
+- (BOOL)_pulling {
+ return _pull.xPulling || _pull.yPulling;
+}
+
- (CGPoint)pullOffset
{
- if(_scrollViewFlags.bounceEnabled)
- return _pull.pulling?CGPointMake(_pull.x, _pull.y):CGPointZero;
- return CGPointZero;
+ if(_scrollViewFlags.bounceEnabled){
+ return CGPointMake((_pull.xPulling) ? _pull.x : 0, (_pull.yPulling) ? _pull.y : 0);
+ }else{
+ return CGPointZero;
+ }
}
- (CGPoint)bounceOffset
{
- if(_scrollViewFlags.bounceEnabled)
- return _bounce.bouncing?CGPointMake(_bounce.x, _bounce.y):CGPointZero;
- return CGPointZero;
+ if(_scrollViewFlags.bounceEnabled){
+ return _bounce.bouncing ? CGPointMake(_bounce.x, _bounce.y) : CGPointZero;
+ }else{
+ return CGPointZero;
+ }
}
- (void)_setContentOffset:(CGPoint)p
{
_unroundedContentOffset = p;
- p.x = round(-p.x);
+ p.x = round(-p.x - self.bounceOffset.x - self.pullOffset.x);
p.y = round(-p.y - self.bounceOffset.y - self.pullOffset.y);
[((CAScrollLayer *)self.layer) scrollToPoint:p];
if(_scrollViewFlags.delegateScrollViewDidScroll){
@@ -556,6 +573,76 @@ - (CGFloat)topDestinationOffset
return -self.contentSize.height + visible.size.height;
}
+/**
+ * @brief Whether the scroll view bounces past the edge of content and back again
+ *
+ * If the value of this property is YES, the scroll view bounces when it encounters a boundary of the content. Bouncing visually indicates
+ * that scrolling has reached an edge of the content. If the value is NO, scrolling stops immediately at the content boundary without bouncing.
+ * The default value varies based on the current AppKit version, user preferences, and other factors.
+ *
+ * @return bounces or not
+ */
+-(BOOL)bounces {
+ return _scrollViewFlags.bounceEnabled;
+}
+
+/**
+ * @brief Whether the scroll view bounces past the edge of content and back again
+ *
+ * If the value of this property is YES, the scroll view bounces when it encounters a boundary of the content. Bouncing visually indicates
+ * that scrolling has reached an edge of the content. If the value is NO, scrolling stops immediately at the content boundary without bouncing.
+ * The default value varies based on the current AppKit version, user preferences, and other factors.
+ *
+ * @return bounces or not
+ */
+-(void)setBounces:(BOOL)bounces {
+ _scrollViewFlags.bounceEnabled = bounces;
+}
+
+/**
+ * @brief Always bounce content vertically
+ *
+ * If this property is set to YES and bounces is YES, vertical dragging is allowed even if the content is smaller than the bounds of the scroll view. The default value is NO.
+ *
+ * @return always bounce vertically or not
+ */
+-(BOOL)alwaysBounceVertical {
+ return _scrollViewFlags.alwaysBounceVertical;
+}
+
+/**
+ * @brief Always bounce content vertically
+ *
+ * If this property is set to YES and bounces is YES, vertical dragging is allowed even if the content is smaller than the bounds of the scroll view. The default value is NO.
+ *
+ * @param always always bounce vertically or not
+ */
+-(void)setAlwaysBounceVertical:(BOOL)always {
+ _scrollViewFlags.alwaysBounceVertical = always;
+}
+
+/**
+ * @brief Always bounce content horizontally
+ *
+ * If this property is set to YES and bounces is YES, horizontal dragging is allowed even if the content is smaller than the bounds of the scroll view. The default value is NO.
+ *
+ * @return always bounce vertically or not
+ */
+-(BOOL)alwaysBounceHorizontal {
+ return _scrollViewFlags.alwaysBounceHorizontal;
+}
+
+/**
+ * @brief Always bounce content horizontally
+ *
+ * If this property is set to YES and bounces is YES, horizontal dragging is allowed even if the content is smaller than the bounds of the scroll view. The default value is NO.
+ *
+ * @param always always bounce vertically or not
+ */
+-(void)setAlwaysBounceHorizontal:(BOOL)always {
+ _scrollViewFlags.alwaysBounceHorizontal = always;
+}
+
- (BOOL)isScrollingToTop
{
if(scrollTimer) {
@@ -624,10 +711,10 @@ static float clampBounce(float x) {
- (void)_startBounce
{
if(!_bounce.bouncing) {
- _bounce.bouncing = 1;
+ _bounce.bouncing = TRUE;
_bounce.x = 0.0f;
_bounce.y = 0.0f;
- _bounce.vx = clampBounce(-_throw.vx);
+ _bounce.vx = clampBounce( _throw.vx);
_bounce.vy = clampBounce(-_throw.vy);
_bounce.t = _throw.t;
}
@@ -645,7 +732,7 @@ - (void)_updateBounce
float dampiness = 0.3;
// spring
- F.x = -_bounce.x * tightness * 0.0; // no bounce for now
+ F.x = -_bounce.x * tightness;
F.y = -_bounce.y * tightness;
// damper
@@ -662,7 +749,7 @@ - (void)_updateBounce
_bounce.t = t;
- if(fabsf(_bounce.vy) < 1.0 && fabsf(_bounce.y) < 1.0) {
+ if(fabsf(_bounce.vy) < 1.0 && fabsf(_bounce.y) < 1.0 && fabsf(_bounce.vx) < 1.0 && fabsf(_bounce.x) < 1.0) {
[self _stopTimer];
}
@@ -690,7 +777,6 @@ - (void)tick:(NSTimer *)timer
o.y = o.y - _throw.vy * dt;
CGPoint fixedOffset = [self _fixProposedContentOffset:o];
- o.x = fixedOffset.x;
if(!CGPointEqualToPoint(fixedOffset, o)) {
[self _startBounce];
}
@@ -701,7 +787,7 @@ - (void)tick:(NSTimer *)timer
_throw.vy *= decelerationRate;
_throw.t = t;
- if(_throw.throwing && !_pull.pulling && !_bounce.bouncing) {
+ if(_throw.throwing && !self._pulling && !_bounce.bouncing) {
// may happen in the case where our we scrolled, then stopped, then lifted finger (didn't do a system-started throw, but timer started anyway to do something else)
// todo - handle this before it happens, but keep this sanity check
if(MAX(fabsf(_throw.vx), fabsf(_throw.vy)) < 0.1) {
@@ -825,68 +911,81 @@ - (BOOL)isDragging
- (void)beginGestureWithEvent:(NSEvent *)event
{
- if(_scrollViewFlags.delegateScrollViewWillBeginDragging)
+
+ if(_scrollViewFlags.delegateScrollViewWillBeginDragging){
[_delegate scrollViewWillBeginDragging:self];
+ }
if(_scrollViewFlags.bounceEnabled) {
_throw.throwing = 0;
_scrollViewFlags.gestureBegan = 1; // this won't happen if window isn't key on 10.6, lame
}
+
}
- (void)_startThrow
{
- if(!_pull.pulling) {
- if(fabsf(_lastScroll.dy) < 2.0)
- return; // don't bother throwing
- }
+
+ if(!self._pulling){
+ if(fabsf(_lastScroll.dy) < 2.0 && fabsf(_lastScroll.dx) < 2.0){
+ return; // don't bother throwing
+ }
+ }
if(!_throw.throwing) {
- _throw.throwing = 1;
+ _throw.throwing = TRUE;
CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
CFTimeInterval dt = t - _lastScroll.t;
- if(dt < 1/60.0)
- dt = 1/60.0;
+ if(dt < 1 / 60.0) dt = 1 / 60.0;
+
_throw.vx = _lastScroll.dx / dt;
_throw.vy = _lastScroll.dy / dt;
_throw.t = t;
[self _startTimer:AnimationModeThrow];
- if(_pull.pulling) {
- _pull.pulling = NO;
-
- if(signbit(_throw.vy) != signbit(_pull.y)) {
- _throw.vx = 0.0;
- _throw.vy = 0.0;
- }
-
+ if(_pull.xPulling) {
+ _pull.xPulling = NO;
+ if(signbit(_throw.vx) != signbit(_pull.x)) _throw.vx = 0.0;
+ [self _startBounce];
+ _bounce.x = _pull.x;
+ }
+
+ if(_pull.yPulling) {
+ _pull.yPulling = NO;
+ if(signbit(_throw.vy) != signbit(_pull.y)) _throw.vy = 0.0;
[self _startBounce];
_bounce.y = _pull.y;
-
- if(_scrollViewFlags.didChangeContentInset) {
- _scrollViewFlags.didChangeContentInset = 0;
- _bounce.y += _contentInset.top;
- _unroundedContentOffset.y -= _contentInset.top;
- }
}
+
+ if(self._pulling && _scrollViewFlags.didChangeContentInset){
+ _scrollViewFlags.didChangeContentInset = 0;
+ _bounce.x += _contentInset.left;
+ _bounce.y += _contentInset.top;
+ _unroundedContentOffset.x -= _contentInset.left;
+ _unroundedContentOffset.y -= _contentInset.top;
+ }
+
}
+
}
- (void)endGestureWithEvent:(NSEvent *)event
{
- if(_scrollViewFlags.delegateScrollViewDidEndDragging)
+
+ if(_scrollViewFlags.delegateScrollViewDidEndDragging){
[_delegate scrollViewDidEndDragging:self];
+ }
if(_scrollViewFlags.bounceEnabled) {
_scrollViewFlags.gestureBegan = 0;
[self _startThrow];
-
if(AtLeastLion) {
_scrollViewFlags.ignoreNextScrollPhaseNormal_10_7 = 1;
}
}
+
}
- (void)scrollWheel:(NSEvent *)event
@@ -940,14 +1039,18 @@ - (void)scrollWheel:(NSEvent *)event
double dy = 0.0;
if(isContinuous) {
- dx = CGEventGetDoubleValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis2);
- dy = CGEventGetDoubleValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis1);
+ if(_scrollViewFlags.alwaysBounceHorizontal || [self _horizontalScrollKnobNeededForContentSize:self.contentSize])
+ dx = CGEventGetDoubleValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis2);
+ if(_scrollViewFlags.alwaysBounceVertical || [self _verticalScrollKnobNeededForContentSize:self.contentSize])
+ dy = CGEventGetDoubleValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis1);
} else {
CGEventSourceRef source = CGEventCreateSourceFromEvent(cgEvent);
if(source) {
const double pixelsPerLine = CGEventSourceGetPixelsPerLine(source);
- dx = CGEventGetDoubleValueField(cgEvent, kCGScrollWheelEventFixedPtDeltaAxis2) * pixelsPerLine;
- dy = CGEventGetDoubleValueField(cgEvent, kCGScrollWheelEventFixedPtDeltaAxis1) * pixelsPerLine;
+ if(_scrollViewFlags.alwaysBounceHorizontal || [self _horizontalScrollKnobNeededForContentSize:self.contentSize])
+ dx = CGEventGetDoubleValueField(cgEvent, kCGScrollWheelEventFixedPtDeltaAxis2) * pixelsPerLine;
+ if(_scrollViewFlags.alwaysBounceVertical || [self _verticalScrollKnobNeededForContentSize:self.contentSize])
+ dy = CGEventGetDoubleValueField(cgEvent, kCGScrollWheelEventFixedPtDeltaAxis1) * pixelsPerLine;
CFRelease(source);
} else {
NSLog(@"Critical: NULL source from CGEventCreateSourceFromEvent");
@@ -962,46 +1065,51 @@ - (void)scrollWheel:(NSEvent *)event
CGPoint o = _unroundedContentOffset;
- if(!_pull.pulling) {
- o.x = o.x + dx;
- o.y = o.y - dy;
- }
+ if(!_pull.xPulling) o.x = o.x + dx;
+ if(!_pull.yPulling) o.y = o.y - dy;
- BOOL pulling = NO;
+ BOOL xPulling = FALSE;
+ BOOL yPulling = FALSE;
{
- CGPoint pullO = o;
- pullO.y += (_pull.pulling?_pull.y:0);
- CGPoint fixedOffset = [self _fixProposedContentOffset:pullO];
+ CGPoint pull = o;
+ pull.x += ((_pull.xPulling) ? _pull.x : 0);
+ pull.y += ((_pull.yPulling) ? _pull.y : 0);
+ CGPoint fixedOffset = [self _fixProposedContentOffset:pull];
o.x = fixedOffset.x;
- pulling = !CGPointEqualToPoint(fixedOffset, o);
+ o.y = fixedOffset.y;
+ xPulling = fixedOffset.x != pull.x;
+ yPulling = fixedOffset.y != pull.y;
}
- if(_scrollViewFlags.gestureBegan) {
- if(_pull.pulling) {
-
- float maxManualPull = 30.0;
- float counterPull = pow(M_E, -1/maxManualPull * fabsf(_pull.y));
-
- if(signbit(_pull.y) == signbit(dy)) // if un-pulling, don't restrict. [REDACTED] doesn't do this and it feels weird - rubber band fights you *both* ways
- counterPull = 1.0; // don't counter
-
- BOOL shouldEndPull = pulling;
-
- if(shouldEndPull) {
- _pull.pulling = NO;
- } else {
- _pull.y -= dy * counterPull;
- }
- } else {
-
- BOOL shouldStartPull = pulling;
-
- if(shouldStartPull) {
- _pull.pulling = YES;
- _pull.y = 0.0;
- _pull.y -= dy;
- }
+ if(_scrollViewFlags.gestureBegan){
+ float maxManualPull = 30.0;
+
+ if(_pull.xPulling){
+ CGFloat xCounter = pow(M_E, -1.0 / maxManualPull * fabsf(_pull.x));
+ // don't counter on un-pull
+ if(signbit(_pull.x) != signbit(dx))
+ xCounter = 1;
+ // update x-axis pulling
+ if(xPulling)
+ _pull.x += dx * xCounter;
+ }else if(xPulling){
+ _pull.x = dx;
+ }
+
+ if(_pull.yPulling){
+ CGFloat yCounter = pow(M_E, -1.0 / maxManualPull * fabsf(_pull.y));
+ // don't counter on un-pull
+ if(signbit(_pull.y) == signbit(dy))
+ yCounter = 1; // don't counter
+ // update y-axis pulling
+ if(yPulling)
+ _pull.y -= dy * yCounter;
+ }else if(yPulling){
+ _pull.y = -dy;
}
+
+ _pull.xPulling = xPulling;
+ _pull.yPulling = yPulling;
}
[self setContentOffset:o];
Please sign in to comment.
Something went wrong with that request. Please try again.