Skip to content

Commit

Permalink
Merge pull request #15 from JasonTait/SwipeView-and-UIKit
Browse files Browse the repository at this point in the history
PinchRecognizer added to Swipeview; UIPopoverPresentationController to UIKit
  • Loading branch information
kingj5 committed May 4, 2018
2 parents dbae6d1 + eb4e589 commit ad3df0b
Show file tree
Hide file tree
Showing 5 changed files with 502 additions and 230 deletions.
27 changes: 24 additions & 3 deletions Modules/Extensions/SwipeView.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,31 @@ Inherits iOSUserControl

#tag Event
Sub Open()
dim useGestures as Boolean = raiseEvent UsesGestures
Dim useGestures As Boolean = RaiseEvent UsesGestures

if useGestures then
LeftRecognizer = new UISwipeGestureRecognizer(UISwipeGestureRecognizer.SwipeDirection.Left)
RightRecognizer = new UISwipeGestureRecognizer(UISwipeGestureRecognizer.SwipeDirection.Right)
UpRecognizer = new UISwipeGestureRecognizer(UISwipeGestureRecognizer.SwipeDirection.Up)
DownRecognizer = new UISwipeGestureRecognizer(UISwipeGestureRecognizer.SwipeDirection.Down)
TapRecognizer = new UITapGestureRecognizer
TapRecognizer = New UITapGestureRecognizer
PinchRecognizer = New UIPinchGestureRecognizer

AddHandler LeftRecognizer.Gesture, AddressOf HandleLeftSwipe
AddHandler RightRecognizer.Gesture, AddressOf HandleRightSwipe
AddHandler UpRecognizer.Gesture, AddressOf HandleUpSwipe
AddHandler DownRecognizer.Gesture, AddressOf HandleDownSwipe
AddHandler TapRecognizer.Gesture, AddressOf HandleTap
AddHandler PinchRecognizer.Gesture, AddressOf HandlePinch

declare sub addGestureRecognizer lib UIKitLib selector "addGestureRecognizer:" _
(view as ptr, recognizer as ptr)
addGestureRecognizer(self.Handle, LeftRecognizer)
addGestureRecognizer(self.Handle, RightRecognizer)
addGestureRecognizer(self.Handle, UpRecognizer)
addGestureRecognizer(self.Handle, DownRecognizer)
addGestureRecognizer(self.Handle, TapRecognizer)
addGestureRecognizer(Self.Handle, TapRecognizer)
addGestureRecognizer(Self.Handle, PinchRecognizer)
else
declare sub setMultipleTouchEnabled lib UIKitLib selector "setMultipleTouchEnabled:" (obj_id as ptr, yesNo as Boolean)
setMultipleTouchEnabled(self.Handle,True)
Expand All @@ -80,6 +83,16 @@ Inherits iOSUserControl
End Sub
#tag EndMethod

#tag Method, Flags = &h21
Private Sub HandlePinch(sender as UIKit.UIPinchGestureRecognizer, additionalData as UIKit.UIGestureRecognizer)
dim tmp as NSPoint = additionalData.locationInView(new UIView(self.Handle))
Pinch(new xojo.Core.Point(tmp.x,tmp.y), sender.scale, sender.velocity)

#Pragma Unused sender

End Sub
#tag EndMethod

#tag Method, Flags = &h21
Private Sub HandleRightSwipe(sender as UIKit.UISwipeGestureRecognizer, additionalData as UIKit.UIGestureRecognizer)
SwipeRight(additionalData)
Expand Down Expand Up @@ -465,6 +478,10 @@ Inherits iOSUserControl
Event Paint(g as iOSGraphics)
#tag EndHook

#tag Hook, Flags = &h0
Event Pinch(location as xojo.Core.Point, scale as double, velocity as double)
#tag EndHook

#tag Hook, Flags = &h0
Event ShakeBegan()
#tag EndHook
Expand Down Expand Up @@ -522,6 +539,10 @@ Inherits iOSUserControl
Private LeftRecognizer As UISwipeGestureRecognizer
#tag EndProperty

#tag Property, Flags = &h21
Private PinchRecognizer As UIKit.UIPinchGestureRecognizer
#tag EndProperty

#tag Property, Flags = &h21
Private RightRecognizer As UISwipeGestureRecognizer
#tag EndProperty
Expand Down
131 changes: 131 additions & 0 deletions Modules/UIKit/UINavigationController.xojo_code
Original file line number Diff line number Diff line change
@@ -1,7 +1,138 @@
#tag Class
Class UINavigationController
Inherits UIViewController
#tag Method, Flags = &h21
Private Shared Function ClassRef() As Ptr
static ref as ptr = NSClassFromString("UINavigationController")
return ref
End Function
#tag EndMethod

#tag Method, Flags = &h0
Sub Constructor(forView As iOSView)
// Calling the overridden superclass constructor.
// Note that this may need modifications if there are multiple constructor choices.
// Possible constructor calls:
// Constructor() -- From NSObject
// Constructor(ref as ptr) -- From NSObject


Declare function initWithRootViewController_ lib FoundationLib selector "initWithRootViewController:" (obj_id as ptr, rootViewController as ptr) as ptr

super.Constructor( initWithRootViewController_( Allocate(ClassRef), forView.ViewControllerHandle ) )


End Sub
#tag EndMethod

#tag Method, Flags = &h0
Shared Function Create(forView As iOSView) As ptr


Declare function initWithRootViewController_ lib FoundationLib selector "initWithRootViewController:" (obj_id as ptr, rootViewController as ptr) as ptr


return initWithRootViewController_( Allocate(ClassRef), forView.ViewControllerHandle )

'UINavigationController alloc] initWithRootViewController:self.frstVwCntlr]
'
'
'Declare Function alloc Lib FoundationLib selector "alloc" (classRef As Ptr) As Ptr
'
'
'declare function initWithRootViewController_ lib "UIKit" selector "initWithRootViewController:" (
'
'
'declare function NSClassFromString lib "Foundation" (classname as CFStringRef) as ptr
'declare function keyWindow lib "UIKit" selector "keyWindow" (obj_ref as ptr) as ptr
'declare function sharedApplication lib "UIKit" selector "sharedApplication" (obj_ref as ptr) as ptr
'declare function rootViewController lib "UIKit" selector "rootViewController" (obj_ref as ptr) as ptr
'declare function navigationBar lib "UIKit" selector "navigationBar" (obj_ref as ptr) as ptr
'
'declare function navigationController lib "UIKit" selector "navigationController" (viewController as ptr) as ptr
'dim navigationControllerRef as ptr = navigationController(v.ViewControllerHandle)
''dim sApp as ptr = sharedApplication(NSClassFromString("UIApplication"))
'dim navBar as ptr = navigationBar(navigationControllerRef)
'
'declare sub setTintColor lib UIKitLib selector "setTintColor:" (id as ptr, UIColor as Ptr)
'setTintColor navBar, new UIColor(buttonColor)
'
'declare sub setBarTintColor lib UIKitLib selector "setBarTintColor:" (id as ptr, UIColor as Ptr)
'setBarTintColor navBar, new UIColor(barColor)
'
''if translucent then
'declare sub setTranslucent lib UIKitLib selector "setTranslucent:" (id as ptr, value as Boolean)
'setTranslucent navBar, translucent
''end
'
'declare sub setBarStyle lib UIKitLib selector "setBarStyle:" (id as ptr, theStyle as integer)
'setBarStyle navBar, 1 //UIStatusBarStyleLightContent
''setBarStyle sApp, 1 //UIStatusBarStyleLightContent
'
'
''if isIPad and v.ParentSplitView <> Nil then
'
'//This is done in the plist
'
''declare function View lib UIKitLib selector "view" (id as ptr) as ptr
''Declare sub setNeedsLayout lib UIKitLib selector "setNeedsLayout" (id as ptr)
''
''dim view As ptr = View(v.ParentSplitView.ViewControllerHandle)
''setNeedsLayout (view)
'
''navigationControllerRef = navigationController(v.ParentSplitView.ViewControllerHandle)
''navigationControllerRef = navigationController(sApp)
''navBar = navigationBar(navigationControllerRef)
'
''setBarTintColor navBar, new UIColor(barColor)
'
''setBarStyle navBar, 1 //UIStatusBarStyleLightContent
''end if
End Function
#tag EndMethod


#tag ViewBehavior
#tag ViewProperty
Name="automaticallyAdjustsScrollViewInsets"
Group="Behavior"
Type="Boolean"
#tag EndViewProperty
#tag ViewProperty
Name="definesPresentationContext"
Group="Behavior"
Type="Boolean"
#tag EndViewProperty
#tag ViewProperty
Name="editing"
Group="Behavior"
Type="Boolean"
#tag EndViewProperty
#tag ViewProperty
Name="extendedLayoutIncludesOpaqueBars"
Group="Behavior"
Type="Boolean"
#tag EndViewProperty
#tag ViewProperty
Name="hidesBottomBarWhenPushed"
Group="Behavior"
Type="Boolean"
#tag EndViewProperty
#tag ViewProperty
Name="modalInPopover"
Group="Behavior"
Type="Boolean"
#tag EndViewProperty
#tag ViewProperty
Name="modalPresentationCapturesStatusBarAppearance"
Group="Behavior"
Type="Boolean"
#tag EndViewProperty
#tag ViewProperty
Name="providesPresentationContextTransitionStyle"
Group="Behavior"
Type="Boolean"
#tag EndViewProperty
#tag ViewProperty
Name="Index"
Visible=true
Expand Down
88 changes: 88 additions & 0 deletions Modules/UIKit/UIPopoverPresentationController.xojo_code
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#tag Class
Class UIPopoverPresentationController
Inherits UIResponder
#tag ComputedProperty, Flags = &h0
#tag Getter
Get
declare function barButtonItem_ lib UIKitLib selector "barButtonItem" (obj_id as ptr) as ptr
Return barButtonItem_(self)
End Get
#tag EndGetter
#tag Setter
Set
declare sub barButtonItem_ lib UIKitLib selector "setBarButtonItem:" (obj_id as ptr, btn as ptr)
barButtonItem_(self, value)
End Set
#tag EndSetter
barButtonItem As ptr
#tag EndComputedProperty

#tag ComputedProperty, Flags = &h0
#tag Setter
Set
#if Target32Bit
declare sub sourceRect_ lib UIKitLib selector "setSourceRect:" (obj_id as ptr, rect as NSRect32)
sourceRect_(self, value.Value32)
#elseif Target64Bit
declare sub sourceRect_ lib UIKitLib selector "setSourceRect:" (obj_id as ptr, rect as NSRect64)
sourceRect_(self, value.Value64)
#endif
End Set
#tag EndSetter
sourceRect As Foundation.NSRect
#tag EndComputedProperty

#tag ComputedProperty, Flags = &h0
#tag Getter
Get
declare function sourceView_ lib UIKitLib selector "sourceView" (obj_id as ptr) as ptr
Return new UIView(sourceView_(self))
End Get
#tag EndGetter
#tag Setter
Set
declare sub sourceView_ lib UIKitLib selector "setSourceView:" (obj_id as ptr, view as ptr)
sourceView_(self, value)
End Set
#tag EndSetter
sourceView As UIView
#tag EndComputedProperty


#tag ViewBehavior
#tag ViewProperty
Name="Index"
Visible=true
Group="ID"
InitialValue="-2147483648"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="Left"
Visible=true
Group="Position"
InitialValue="0"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="Name"
Visible=true
Group="ID"
Type="String"
#tag EndViewProperty
#tag ViewProperty
Name="Super"
Visible=true
Group="ID"
Type="String"
#tag EndViewProperty
#tag ViewProperty
Name="Top"
Visible=true
Group="Position"
InitialValue="0"
Type="Integer"
#tag EndViewProperty
#tag EndViewBehavior
End Class
#tag EndClass
31 changes: 30 additions & 1 deletion Modules/UIKit/UIViewController.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Inherits UIResponder
#tag EndMethod

#tag Method, Flags = &h0
Shared Sub AttemptRotationToDeviceOrientation()
Shared Sub AttemptRotationToDeviceOrientation()
declare sub attemptRotationToDeviceOrientation_ lib UIKitLib selector "attemptRotationToDeviceOrientation" (clsRef as ptr)
attemptRotationToDeviceOrientation_(ClassRef)
End Sub
Expand Down Expand Up @@ -195,6 +195,22 @@ Inherits UIResponder
modalPresentationCapturesStatusBarAppearance As Boolean
#tag EndComputedProperty

#tag ComputedProperty, Flags = &h0
#tag Getter
Get
declare function modalPresentationStyle_ lib UIKitLib selector "modalPresentationStyle" (obj_id as ptr) as UIModalPresentationStyle
Return modalPresentationStyle_(self)
End Get
#tag EndGetter
#tag Setter
Set
declare sub modalPresentationStyle_ lib UIKitLib selector "setModalPresentationStyle:" (obj_id as ptr, modalPresentationStyle as UIModalPresentationStyle)
modalPresentationStyle_(self, value)
End Set
#tag EndSetter
modalPresentationStyle As UIModalPresentationStyle
#tag EndComputedProperty

#tag ComputedProperty, Flags = &h0
#tag Getter
Get
Expand Down Expand Up @@ -318,6 +334,19 @@ Inherits UIResponder
#tag EndComputedProperty


#tag Enum, Name = UIModalPresentationStyle, Flags = &h0
Fullscreen = 0
PageSheet
FormSheet
CurrentContext
Custom
OverFullScreen
OverCurrentContext
Popover
None = -1
#tag EndEnum


#tag ViewBehavior
#tag ViewProperty
Name="automaticallyAdjustsScrollViewInsets"
Expand Down

0 comments on commit ad3df0b

Please sign in to comment.