Haxe bindings for koreader
修訂 | 750f85b086c7572f297a8a108a32cda5ddaaf30f (tree) |
---|---|
時間 | 2021-03-21 21:09:52 |
作者 | Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fast...> |
Commiter | Jaime Marquínez Ferrándiz |
Add CenterContainer
@@ -1,9 +1,11 @@ | ||
1 | +import koreader.ui.widget.container.CenterContainer; | |
1 | 2 | import koreader.ui.widget.VerticalGroup; |
2 | 3 | import koreader.ui.widget.Button; |
3 | 4 | import koreader.ui.widget.HorizontalGroup; |
4 | 5 | import koreader.ui.UIManager; |
5 | 6 | import koreader.ui.widget.InfoMessage; |
6 | 7 | import koreader.ui.widget.ConfirmBox; |
8 | +import koreader.Device; | |
7 | 9 | import koreader.Logger; |
8 | 10 | |
9 | 11 | class Main { |
@@ -47,6 +49,13 @@ | ||
47 | 49 | ], |
48 | 50 | }); |
49 | 51 | |
50 | - UIManager.show(grp); | |
52 | + var container = CenterContainer.create({ | |
53 | + dimen: Device.screen.getSize(), | |
54 | + widgets: [ | |
55 | + grp, | |
56 | + ], | |
57 | + }); | |
58 | + | |
59 | + UIManager.show(container); | |
51 | 60 | } |
52 | 61 | } |
\ No newline at end of file |
@@ -0,0 +1,19 @@ | ||
1 | +package koreader; | |
2 | + | |
3 | +import koreader.ui.Geom; | |
4 | + | |
5 | +@:luaRequire("device") | |
6 | +@:build(KoreaderMacros.setupKoreaderExternClass()) | |
7 | +extern class Device { | |
8 | + private var screen : Screen; | |
9 | + | |
10 | + public static var screen(get, never) : Screen; | |
11 | + | |
12 | + public inline static function get_screen() : Screen { | |
13 | + return instance.screen; | |
14 | + } | |
15 | +} | |
16 | + | |
17 | +extern class Screen { | |
18 | + public function getSize() : Geom; | |
19 | +} | |
\ No newline at end of file |
@@ -0,0 +1,17 @@ | ||
1 | +package koreader.ui.widget.container; | |
2 | + | |
3 | +import lua.Table; | |
4 | +import koreader.hxutils.Tables; | |
5 | +import koreader.ui.widget.container.WidgetContainer.WidgetContainerParams; | |
6 | + | |
7 | +@:luaRequire("ui/widget/container/centercontainer") | |
8 | +@:build(KoreaderMacros.setupKoreaderExternClass()) | |
9 | +extern class CenterContainer extends WidgetContainer { | |
10 | + @:native("new") | |
11 | + private function create(params: Table<Dynamic, Dynamic>) : CenterContainer; | |
12 | + | |
13 | + public inline static function create(params: WidgetContainerParams) : CenterContainer { | |
14 | + var t = Tables.createTable(params, params.widgets); | |
15 | + return instance.create(t); | |
16 | + } | |
17 | +} | |
\ No newline at end of file |