forked from msink/kotlin-libui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable data binding for textfield and label ui components
Add possibility to do data binding to label and textfield and introduce a simple example in the samples, to showcase a shared string value between an input and a label. Refer to issue: msink#8 Co-authored-by: Andreas Mausch <[email protected]>
- Loading branch information
1 parent
d58a4e1
commit 10db0cb
Showing
6 changed files
with
119 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apply plugin: 'konan' | ||
|
||
def konanUserDir = System.getenv("KONAN_DATA_DIR") ?: "${System.getProperty("user.home")}/.konan" | ||
def windresDir = "$konanUserDir/dependencies/msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1/bin" | ||
def rcFile = file('src/main/resources/samples.rc') | ||
def resFile = file("$buildDir/konan/resources/samples.res") | ||
task windowsResources(type: Exec) { | ||
inputs.file rcFile | ||
outputs.file resFile | ||
commandLine "$windresDir/windres", rcFile, '-O', 'coff', '-o', resFile | ||
environment 'PATH', "$windresDir;${System.getenv('PATH')}" | ||
} | ||
|
||
konanArtifacts { | ||
program('data-binding-1') { | ||
libraries { | ||
artifact project(':libui-ktx'), 'libui-ktx' | ||
} | ||
target('mingw') { | ||
dependsOn 'windowsResources' | ||
inputs.file resFile | ||
linkerOpts "$resFile -mwindows" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import libui.ktx.* | ||
import libui.ktx.databinding.* | ||
|
||
fun main(args: Array<String>) { | ||
class Model { | ||
val myString = ModelEntry<String>("Hello kotlin-libui!") | ||
} | ||
val model = Model() | ||
|
||
appWindow( | ||
title = "Data-binding Example #1", | ||
width = 320, | ||
height = 100 | ||
) { | ||
vbox { | ||
label(modelEntry = model.myString) | ||
textfield(modelEntry = model.myString) | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
samples/data-binding-1/src/main/resources/samples.manifest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> | ||
<assemblyIdentity | ||
version="1.0.0.0" | ||
processorArchitecture="*" | ||
name="CompanyName.ProductName.YourApplication" | ||
type="win32" | ||
/> | ||
<description>Your application description here.</description> | ||
<dependency> | ||
<dependentAssembly> | ||
<assemblyIdentity | ||
type="win32" | ||
name="Microsoft.Windows.Common-Controls" | ||
version="6.0.0.0" | ||
processorArchitecture="*" | ||
publicKeyToken="6595b64144ccf1df" | ||
language="*" | ||
/> | ||
</dependentAssembly> | ||
</dependency> | ||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
<security> | ||
<requestedPrivileges> | ||
<requestedExecutionLevel level="asInvoker"/> | ||
</requestedPrivileges> | ||
</security> | ||
</trustInfo> | ||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> | ||
<application> | ||
<!--The ID below indicates application support for Windows Vista --> | ||
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> | ||
<!--The ID below indicates application support for Windows 7 --> | ||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> | ||
<!--The ID below indicates application support for Windows 8 --> | ||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> | ||
<!--The ID below indicates application support for Windows 8.1 --> | ||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> | ||
<!--The ID below indicates application support for Windows 10 --> | ||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> | ||
</application> | ||
</compatibility> | ||
</assembly> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// this is a UTF-8 file | ||
#pragma code_page(65001) | ||
|
||
// this is the Common Controls 6 manifest | ||
// 1 is the value of CREATEPROCESS_MANIFEST_RESOURCE_ID and 24 is the value of RT_MANIFEST | ||
1 24 "samples.manifest" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters