Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Nov 23, 2017
2 parents de477e1 + 263ee83 commit 81d7e31
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
"repositoryURL": "https://github.com/PureSwift/Silica.git",
"state": {
"branch": null,
"revision": "b504b0368de794dde11c6e9da71fbd4ae4845c99",
"version": "1.3.0"
"revision": "6239656493fba609a11bef46efd495fca2379090",
"version": "1.3.2"
}
}
]
Expand Down
7 changes: 5 additions & 2 deletions Sources/Cacao/UIApplication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,13 @@ public final class UIApplication: UIResponder {
/// after handling the event in your implementation.
public func sendEvent(_ event: UIEvent) {

keyWindow?.sendEvent(event)
self.windows.forEach { $0.sendEvent(event) }
}

public func sendAction(_ selector: String, to target: AnyObject?, from sender: AnyObject?, for event: UIEvent?) {
public func sendAction(_ selector: String,
to target: AnyObject?,
from sender: AnyObject?,
for event: UIEvent?) {


}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Cacao/UIEventEnvironment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal final class UIEventEnvironment {
guard let event = event(for: sdlEvent)
else { handleNonUIEvent(sdlEvent); continue }


application.sendEvent(event)
}

// clear queue
Expand Down
9 changes: 0 additions & 9 deletions Sources/Cacao/UIView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -694,15 +694,6 @@ open class UIView: UIResponder {
// CoreGraphics drawing
draw(in: context)

/// FIXME: temporary workaround for Linux
/// We have to convert the surface to PNG, even though we discard it.
/// For some reason this changes something internally in Cairo,
/// even though the texture and surface pixel buffer doesn't seem to change.
#if os(Linux)
let pngData = try! surface.writePNG()
assert(pngData.isEmpty == false)
#endif

/// flush surface
surface.flush()
surface.finish()
Expand Down
44 changes: 38 additions & 6 deletions Sources/Cacao/UIWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,29 @@ open class UIWindow: UIView {

let gestureEnvironment = UIApplication.shared.gestureEnvironment

switch event.type {
// handle touches event
if let touchesEvent = event as? UITouchesEvent {

case .touches:
gestureEnvironment.updateGestures(for: event, window: self)

sendTouches(for: touchesEvent)

} else if let pressesEvent = event as? UIPressesEvent {

guard isUserInteractionEnabled else { return }

gestureEnvironment.updateGestures(for: event, window: self)

/*
sendButtons(for: pressesEvent)
}



/*
switch event.type {

case .touches:

let touches = event.touches(for: self) ?? []

let gestureRecognizers = touches.reduce([UIGestureRecognizer](), { $0 + ($1.gestureRecognizers ?? []) })
Expand Down Expand Up @@ -104,12 +120,12 @@ open class UIWindow: UIView {
case .ended: touch.view?.touchesEnded(touches, with: event)
case .cancelled: touch.view?.touchesCancelled(touches, with: event)
}
}*/
}

default:

fatalError("\(event.type) events not implemented")
}
}*/
}

// MARK: - Subclassed Methods
Expand Down Expand Up @@ -140,7 +156,23 @@ open class UIWindow: UIView {
layoutIfNeeded()
}

private func sendTouches(for event: UIEvent) {
private func sendTouches(for event: UITouchesEvent) {

let touches = event.touches

for touch in touches {

switch touch.phase {
case .began: touch.view?.touchesBegan(touches, with: event)
case .moved: touch.view?.touchesMoved(touches, with: event)
case .stationary: break
case .ended: touch.view?.touchesEnded(touches, with: event)
case .cancelled: touch.view?.touchesCancelled(touches, with: event)
}
}
}

private func sendButtons(for event: UIPressesEvent) {


}
Expand Down
2 changes: 1 addition & 1 deletion Sources/CacaoDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class AppDelegate: NSObject, UIApplicationDelegate {

self.window = UIWindow(frame: UIScreen.main.bounds)

self.window?.rootViewController = TimerViewController()
self.window?.rootViewController = SwitchViewController()

self.window?.makeKeyAndVisible()

Expand Down

0 comments on commit 81d7e31

Please sign in to comment.