Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
skiko
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liuqiang
skiko
Commits
db11bf1d
Unverified
Commit
db11bf1d
authored
Mar 27, 2023
by
dima.avdeev
Committed by
GitHub
Mar 27, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UIKit interop touches (#682)
parent
f21b1970
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
3 deletions
+51
-3
RELEASE.md
skiko/RELEASE.md
+6
-1
build.gradle.kts
skiko/build.gradle.kts
+8
-0
gradle.properties
skiko/gradle.properties
+3
-0
SkiaLayer.ios.kt
...o/src/iosMain/kotlin/org/jetbrains/skiko/SkiaLayer.ios.kt
+1
-0
SkikoUIView.kt
skiko/src/iosMain/kotlin/org/jetbrains/skiko/SkikoUIView.kt
+22
-2
ios.def
skiko/src/iosMain/objc/ios.def
+11
-0
No files found.
skiko/RELEASE.md
View file @
db11bf1d
...
@@ -19,11 +19,16 @@ build configuration.
...
@@ -19,11 +19,16 @@ build configuration.
## Publishing
## Publishing
##### Publish to Maven local
##### Publish
JVM target
to Maven local
```
```
./gradlew publishToMavenLocal
./gradlew publishToMavenLocal
```
```
##### Publish all targets to Maven Local
```
./gradlew publishToMavenLocal -Pskiko.native.enabled=true -Pskiko.wasm.enabled=true -Pskiko.android.enabled=true
```
##### Publish to `build/repo` directory
##### Publish to `build/repo` directory
```
```
./gradlew publishToBuildRepo
./gradlew publishToBuildRepo
...
...
skiko/build.gradle.kts
View file @
db11bf1d
...
@@ -441,6 +441,14 @@ fun configureNativeTarget(os: OS, arch: Arch, target: KotlinNativeTarget) {
...
@@ -441,6 +441,14 @@ fun configureNativeTarget(os: OS, arch: Arch, target: KotlinNativeTarget) {
val
allLibraries
=
skiaStaticLibraries
(
skiaDir
,
targetString
)
+
bridgesLibrary
val
allLibraries
=
skiaStaticLibraries
(
skiaDir
,
targetString
)
+
bridgesLibrary
if
(
os
==
OS
.
IOS
)
{
target
.
compilations
.
getByName
(
"main"
)
{
val
uikit
by
cinterops
.
creating
{
defFile
(
"src/iosMain/objc/ios.def"
)
packageName
(
"org.jetbrains.skiko.objc"
)
}
}
}
val
skiaBinDir
=
"$skiaDir/out/${buildType.id}-$targetString"
val
skiaBinDir
=
"$skiaDir/out/${buildType.id}-$targetString"
val
linkerFlags
=
when
(
os
)
{
val
linkerFlags
=
when
(
os
)
{
OS
.
MacOS
->
mutableListOf
(
"-linker-option"
,
"-framework"
,
"-linker-option"
,
"Metal"
,
OS
.
MacOS
->
mutableListOf
(
"-linker-option"
,
"-framework"
,
"-linker-option"
,
"Metal"
,
...
...
skiko/gradle.properties
View file @
db11bf1d
...
@@ -20,3 +20,6 @@ dependencies.skia.android-arm64=m110-ad42464-1
...
@@ -20,3 +20,6 @@ dependencies.skia.android-arm64=m110-ad42464-1
org.gradle.jvmargs
=
-Xmx3G -XX:MaxMetaspaceSize=512m
org.gradle.jvmargs
=
-Xmx3G -XX:MaxMetaspaceSize=512m
kotlin.native.cacheKind.macosX64
=
none
kotlin.native.cacheKind.macosX64
=
none
kotlin.native.cacheKind.iosX64
=
none
kotlin.native.cacheKind.iosX64
=
none
# This line needs for maven publication with ObjC defFile. Should be removed after Kotlin 1.8.20
kotlin.mpp.enableCInteropCommonization
=
true
skiko/src/iosMain/kotlin/org/jetbrains/skiko/SkiaLayer.ios.kt
View file @
db11bf1d
...
@@ -7,6 +7,7 @@ import org.jetbrains.skiko.context.MetalContextHandler
...
@@ -7,6 +7,7 @@ import org.jetbrains.skiko.context.MetalContextHandler
import
org.jetbrains.skiko.redrawer.MetalRedrawer
import
org.jetbrains.skiko.redrawer.MetalRedrawer
import
platform.UIKit.*
import
platform.UIKit.*
import
kotlin.system.getTimeNanos
import
kotlin.system.getTimeNanos
import
org.jetbrains.skia.*
actual
open
class
SkiaLayer
{
actual
open
class
SkiaLayer
{
...
...
skiko/src/iosMain/kotlin/org/jetbrains/skiko/SkikoUIView.kt
View file @
db11bf1d
package
org.jetbrains.skiko
package
org.jetbrains.skiko
import
kotlinx.cinterop.*
import
kotlinx.cinterop.*
import
org.jetbrains.skia.Point
import
org.jetbrains.skia.Rect
import
org.jetbrains.skia.Rect
import
platform.CoreGraphics.*
import
platform.CoreGraphics.*
import
platform.Foundation.*
import
platform.Foundation.*
...
@@ -9,9 +10,14 @@ import platform.darwin.NSInteger
...
@@ -9,9 +10,14 @@ import platform.darwin.NSInteger
import
kotlin.math.max
import
kotlin.math.max
import
kotlin.math.min
import
kotlin.math.min
/*
TODO: remove org.jetbrains.skiko.objc.UIViewExtensionProtocol after Kotlin 1.8.20
https://youtrack.jetbrains.com/issue/KT-40426
*/
@Suppress
(
"CONFLICTING_OVERLOADS"
)
@Suppress
(
"CONFLICTING_OVERLOADS"
)
@ExportObjCClass
@ExportObjCClass
class
SkikoUIView
:
UIView
,
UIKeyInputProtocol
,
UITextInputProtocol
{
class
SkikoUIView
:
UIView
,
UIKeyInputProtocol
,
UITextInputProtocol
,
org
.
jetbrains
.
skiko
.
objc
.
UIViewExtensionProtocol
{
@OverrideInit
@OverrideInit
constructor
(
frame
:
CValue
<
CGRect
>)
:
super
(
frame
)
constructor
(
frame
:
CValue
<
CGRect
>)
:
super
(
frame
)
...
@@ -19,6 +25,7 @@ class SkikoUIView : UIView, UIKeyInputProtocol, UITextInputProtocol {
...
@@ -19,6 +25,7 @@ class SkikoUIView : UIView, UIKeyInputProtocol, UITextInputProtocol {
constructor
(
coder
:
NSCoder
)
:
super
(
coder
)
constructor
(
coder
:
NSCoder
)
:
super
(
coder
)
private
var
skiaLayer
:
SkiaLayer
?
=
null
private
var
skiaLayer
:
SkiaLayer
?
=
null
private
lateinit
var
_pointInside
:
(
Point
,
UIEvent
?)
->
Boolean
private
var
_inputDelegate
:
UITextInputDelegateProtocol
?
=
null
private
var
_inputDelegate
:
UITextInputDelegateProtocol
?
=
null
private
var
_currentTextMenuActions
:
TextActions
?
=
null
private
var
_currentTextMenuActions
:
TextActions
?
=
null
var
currentKeyboardType
:
UIKeyboardType
=
UIKeyboardTypeDefault
var
currentKeyboardType
:
UIKeyboardType
=
UIKeyboardTypeDefault
...
@@ -30,8 +37,13 @@ class SkikoUIView : UIView, UIKeyInputProtocol, UITextInputProtocol {
...
@@ -30,8 +37,13 @@ class SkikoUIView : UIView, UIKeyInputProtocol, UITextInputProtocol {
var
currentAutocapitalizationType
:
UITextAutocapitalizationType
=
UITextAutocapitalizationType
.
UITextAutocapitalizationTypeSentences
var
currentAutocapitalizationType
:
UITextAutocapitalizationType
=
UITextAutocapitalizationType
.
UITextAutocapitalizationTypeSentences
var
currentAutocorrectionType
:
UITextAutocorrectionType
=
UITextAutocorrectionType
.
UITextAutocorrectionTypeYes
var
currentAutocorrectionType
:
UITextAutocorrectionType
=
UITextAutocorrectionType
.
UITextAutocorrectionTypeYes
constructor
(
skiaLayer
:
SkiaLayer
,
frame
:
CValue
<
CGRect
>
=
CGRectNull
.
readValue
())
:
super
(
frame
)
{
constructor
(
skiaLayer
:
SkiaLayer
,
frame
:
CValue
<
CGRect
>
=
CGRectNull
.
readValue
(),
pointInside
:
(
Point
,
UIEvent
?)
->
Boolean
=
{
_
,
_
->
true
}
)
:
super
(
frame
)
{
this
.
skiaLayer
=
skiaLayer
this
.
skiaLayer
=
skiaLayer
_pointInside
=
pointInside
}
}
/**
/**
...
@@ -157,6 +169,14 @@ class SkikoUIView : UIView, UIKeyInputProtocol, UITextInputProtocol {
...
@@ -157,6 +169,14 @@ class SkikoUIView : UIView, UIKeyInputProtocol, UITextInputProtocol {
super
.
pressesEnded
(
presses
,
withEvent
)
super
.
pressesEnded
(
presses
,
withEvent
)
}
}
/**
* https://developer.apple.com/documentation/uikit/uiview/1622533-point
*/
override
fun
pointInside
(
point
:
CValue
<
CGPoint
>,
withEvent
:
UIEvent
?):
Boolean
{
val
skiaPoint
:
Point
=
point
.
useContents
{
Point
(
x
.
toFloat
(),
y
.
toFloat
())
}
return
_pointInside
(
skiaPoint
,
withEvent
)
}
override
fun
touchesBegan
(
touches
:
Set
<
*
>,
withEvent
:
UIEvent
?)
{
override
fun
touchesBegan
(
touches
:
Set
<
*
>,
withEvent
:
UIEvent
?)
{
super
.
touchesBegan
(
touches
,
withEvent
)
super
.
touchesBegan
(
touches
,
withEvent
)
sendTouchEventToSkikoView
(
touches
,
SkikoTouchEventKind
.
STARTED
)
sendTouchEventToSkikoView
(
touches
,
SkikoTouchEventKind
.
STARTED
)
...
...
skiko/src/iosMain/objc/ios.def
0 → 100644
View file @
db11bf1d
package
=
org
.
jetbrains
.
skiko
.
objc
language
=
Objective
-
C
---
#
import
<
Foundation
/
Foundation
.
h
>
#
import
<
UIKit
/
UIView
.
h
>
//
This
protocol
helps
to
override
ObjC
UIView
extensions
in
Kotlin
@
protocol
UIViewExtension
-
(
BOOL
)
pointInside
:(
CGPoint
)
point
withEvent
:(
UIEvent
*)
event
;
@
end
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment