• R/O
  • SSH

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Haxe bindings for koreader


Commit MetaInfo

Revision1d4e7e1afd1f7edab6b2724973ad4707c7e152c0 (tree)
Time2022-03-04 07:27:15
AuthorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fast...>
CommiterJaime Marquínez Ferrándiz

Log Message

Add ButtonDialog

Change Summary

Incremental Difference

diff -r 7e51cfe8fc64 -r 1d4e7e1afd1f demo/haxeplug/HaxePlugin.hx
--- a/demo/haxeplug/HaxePlugin.hx Tue Mar 01 23:09:22 2022 +0100
+++ b/demo/haxeplug/HaxePlugin.hx Thu Mar 03 23:27:15 2022 +0100
@@ -6,6 +6,7 @@
66 import koreader.ffi.Blitbuffer;
77 import koreader.ui.UIManager;
88 import koreader.ui.widget.Button;
9+import koreader.ui.widget.ButtonDialog;
910 import koreader.ui.widget.ConfirmBox;
1011 import koreader.ui.widget.container.CenterContainer;
1112 import koreader.ui.widget.container.FrameContainer;
@@ -78,6 +79,10 @@
7879 callback: displayRegexTest,
7980 }),
8081 Button.create({
82+ text: "Button dialog",
83+ callback: displayButtonDialog,
84+ }),
85+ Button.create({
8186 text: "Close",
8287 callback: function close() {
8388 UIManager.close(mainWindow, Partial);
@@ -140,4 +145,14 @@
140145 var message = InfoMessage.create({text: "Regex result:\n" + text});
141146 UIManager.show(message);
142147 }
148+
149+ public static function displayButtonDialog() {
150+ var callback = () -> UIManager.show(InfoMessage.create({text: "Pressed"}));
151+ UIManager.show(ButtonDialog.create({
152+ buttons: [[
153+ { text: "Button 1", callback: callback, enabled: false},
154+ { text: "Button 2", callback: callback},
155+ ]],
156+ }));
157+ }
143158 }
\ No newline at end of file
diff -r 7e51cfe8fc64 -r 1d4e7e1afd1f src/koreader/hxutils/LuaArray.lua.hx
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/koreader/hxutils/LuaArray.lua.hx Thu Mar 03 23:27:15 2022 +0100
@@ -0,0 +1,23 @@
1+package koreader.hxutils;
2+
3+import lua.Table;
4+
5+/**
6+ Helper class to pass arrays to koreader functions
7+**/
8+abstract LuaArray<T>(lua.Table<Int, T>)
9+{
10+ inline function new(t:lua.Table<Int, T>) {
11+ this = t;
12+ }
13+
14+ @:from
15+ static public function fromArray<T>(arr:Array<T>) {
16+ return new LuaArray(lua.Table.fromArray(arr));
17+ }
18+
19+ @:to
20+ public function toArray() {
21+ return Table.toArray(this);
22+ }
23+}
\ No newline at end of file
diff -r 7e51cfe8fc64 -r 1d4e7e1afd1f src/koreader/ui/widget/ButtonDialog.lua.hx
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/koreader/ui/widget/ButtonDialog.lua.hx Thu Mar 03 23:27:15 2022 +0100
@@ -0,0 +1,20 @@
1+package koreader.ui.widget;
2+
3+import koreader.hxutils.LuaArray;
4+import koreader.ui.widget.Button.ButtonParams;
5+import koreader.ui.widget.container.InputContainer;
6+
7+@:luaRequire("ui/widget/buttondialog")
8+@:build(KoreaderMacros.setupKoreaderExternClass())
9+extern class ButtonDialog extends InputContainer {
10+ @:native("new")
11+ @:constructor
12+ private function create(params: ButtonDialogParams) : ButtonDialog;
13+}
14+
15+typedef ButtonDialogParams = {
16+ > InputContainerParams,
17+ ?buttons : LuaArray<LuaArray<ButtonParams>>,
18+ ?tap_close_callback : () -> Void,
19+ ?alpha : Float,
20+}
\ No newline at end of file