リビジョン | 28f57fff9a280f85c77cb6e82e03e3899e44eddd (tree) |
---|---|
日時 | 2022-03-31 05:26:05 |
作者 | Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fast...> |
コミッター | Jaime Marquínez Ferrándiz |
Initial commit
@@ -0,0 +1,7 @@ | ||
1 | +# SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +# | |
3 | +# SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +.vscode | |
6 | + | |
7 | +out | |
\ No newline at end of file |
@@ -0,0 +1,10 @@ | ||
1 | +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ | |
2 | +Upstream-Name: haxeui-koreader | |
3 | +Upstream-Contact: Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
4 | +Source: | |
5 | + | |
6 | +# Sample paragraph, commented out: | |
7 | +# | |
8 | +# Files: src/* | |
9 | +# Copyright: $YEAR $NAME <$CONTACT> | |
10 | +# License: ... |
@@ -0,0 +1,10 @@ | ||
1 | +This is free and unencumbered software released into the public domain. | |
2 | + | |
3 | +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. | |
4 | + | |
5 | +In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and | |
6 | +successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. | |
7 | + | |
8 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
9 | + | |
10 | +For more information, please refer to <http://unlicense.org/> |
@@ -0,0 +1,17 @@ | ||
1 | +# SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +# | |
3 | +# SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +DEMO = out/haxeui_demo.lua | |
6 | + | |
7 | +.PHONY: all $(DEMO) check check-license | |
8 | + | |
9 | +all: $(DEMO) check | |
10 | + | |
11 | +$(DEMO): src | |
12 | + haxe demo.hxml | |
13 | + | |
14 | +check: check-license | |
15 | + | |
16 | +check-license: | |
17 | + reuse lint | |
\ No newline at end of file |
@@ -0,0 +1,11 @@ | ||
1 | +<!-- | |
2 | +SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
3 | + | |
4 | +SPDX-License-Identifier: Unlicense | |
5 | +--> | |
6 | +haxeui-koreader | |
7 | +=============== | |
8 | + | |
9 | +Koreader backend for [Haxe UI](http://haxeui.org/) | |
10 | + | |
11 | +The project is released to the public domain under the Unlicense license. See LICENSES/Unlicense.txt. | |
\ No newline at end of file |
@@ -0,0 +1,23 @@ | ||
1 | +<!-- | |
2 | + SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
3 | + | |
4 | + SPDX-License-Identifier: Unlicense | |
5 | +--> | |
6 | +<vbox> | |
7 | + <hbox> | |
8 | + <vbox> | |
9 | + <button text="Button 1" id="btn1" /> | |
10 | + <button text="Inline event" onclick="this.text='Clicked'" /> | |
11 | + <button text="Buttton 2" id="btn2" /> | |
12 | + </vbox> | |
13 | + | |
14 | + <vbox> | |
15 | + <label text="Label 1" /> | |
16 | + <label text="Label 2" /> | |
17 | + <hbox> | |
18 | + <button text="X" /> | |
19 | + <button text="Y" /> | |
20 | + </hbox> | |
21 | + </vbox> | |
22 | + </hbox> | |
23 | +</vbox> | |
\ No newline at end of file |
@@ -0,0 +1,21 @@ | ||
1 | +# SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +# | |
3 | +# SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +--class-path src | |
6 | + | |
7 | +--macro include("haxe.ui.backend.koreader") | |
8 | +--macro include("haxe.ui.backend.koreader.behaviours") | |
9 | +--macro include("haxe.ui.backend.koreader.creators") | |
10 | + | |
11 | +--class-path demo | |
12 | +--main Main | |
13 | + | |
14 | +--library haxeui-core | |
15 | +--library haxe-koreader | |
16 | + | |
17 | +--dce full | |
18 | + | |
19 | +--lua out/haxeui_demo.lua | |
20 | + | |
21 | +--macro haxe.macro.Compiler.include("haxe.ui", ["haxe.ui.macros"]) | |
\ No newline at end of file |
@@ -0,0 +1,20 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package ; | |
6 | + | |
7 | +import haxe.ui.HaxeUIApp; | |
8 | + | |
9 | +class Main { | |
10 | + public static function main() { | |
11 | + var app = new HaxeUIApp(); | |
12 | + app.ready(function() { | |
13 | + var mainView = new MainView(); | |
14 | + | |
15 | + app.addComponent(mainView); | |
16 | + | |
17 | + app.start(); | |
18 | + }); | |
19 | + } | |
20 | +} |
@@ -0,0 +1,24 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package ; | |
6 | + | |
7 | +import haxe.ui.containers.HBox; | |
8 | +import haxe.ui.containers.VBox; | |
9 | +import haxe.ui.events.MouseEvent; | |
10 | + | |
11 | +@:build(haxe.ui.ComponentBuilder.build("assets/main-view.xml")) | |
12 | +class MainView extends VBox { | |
13 | + public function new() { | |
14 | + super(); | |
15 | + btn1.onClick = function(e) { | |
16 | + btn1.text = "Clicked!"; | |
17 | + } | |
18 | + } | |
19 | + | |
20 | + @:bind(btn2, MouseEvent.CLICK) | |
21 | + private function onMyButton(e:MouseEvent) { | |
22 | + btn2.text = "Clicked!"; | |
23 | + } | |
24 | +} | |
\ No newline at end of file |
@@ -0,0 +1,67 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend; | |
6 | + | |
7 | +import haxe.ui.backend.koreader.WidgetWrapper; | |
8 | +import koreader.Device; | |
9 | +import koreader.ffi.Blitbuffer; | |
10 | +import koreader.ui.UIManager; | |
11 | +import koreader.ui.Size; | |
12 | +import koreader.ui.widget.container.CenterContainer; | |
13 | +import koreader.ui.widget.container.FrameContainer; | |
14 | +import koreader.ui.widget.container.MovableContainer; | |
15 | +import koreader.ui.widget.VerticalGroup; | |
16 | + | |
17 | +class AppImpl extends AppBase { | |
18 | + private var _mainWindow : WidgetWrapper; | |
19 | + private var _mainContainer : WidgetWrapper; | |
20 | + | |
21 | + function new() { | |
22 | + | |
23 | + } | |
24 | + | |
25 | + override function build() { | |
26 | + super.build(); | |
27 | + | |
28 | + var frame = FrameContainer.create({ | |
29 | + background: Blitbuffer.COLOR_WHITE, | |
30 | + bordersize: Size.border.window, | |
31 | + radius: Size.radius.window, | |
32 | + padding: Size.padding.default_, | |
33 | + }); | |
34 | + | |
35 | + var group = VerticalGroup.create({}); | |
36 | + this._mainContainer = new WidgetWrapper(group); | |
37 | + frame.addWidget(group); | |
38 | + | |
39 | + var container = CenterContainer.create({ | |
40 | + dimen: Device.screen.getSize(), | |
41 | + widgets: [ | |
42 | + MovableContainer.create({ | |
43 | + widgets: [frame], | |
44 | + }), | |
45 | + ], | |
46 | + }); | |
47 | + this._mainWindow = new WidgetWrapper(container); | |
48 | + } | |
49 | + | |
50 | + override function start() { | |
51 | + super.start(); | |
52 | + | |
53 | + UIManager.show(this._mainWindow.widget); | |
54 | + UIManager.setDirty(this._mainWindow.widget, Partial); | |
55 | + } | |
56 | + | |
57 | + override function exit() { | |
58 | + UIManager.close(this._mainWindow.widget); | |
59 | + } | |
60 | + | |
61 | + override function getToolkitInit():ToolkitOptions { | |
62 | + return { | |
63 | + mainWindow: this._mainWindow, | |
64 | + mainContainer: this._mainContainer, | |
65 | + }; | |
66 | + } | |
67 | +} | |
\ No newline at end of file |
@@ -0,0 +1,8 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend; | |
6 | + | |
7 | +class AssetsImpl extends AssetsBase { | |
8 | +} | |
\ No newline at end of file |
@@ -0,0 +1,9 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend; | |
6 | + | |
7 | +class BackendImpl { | |
8 | + public static var id:String = "koreader"; | |
9 | +} | |
\ No newline at end of file |
@@ -0,0 +1,11 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend; | |
6 | + | |
7 | +class CallLaterImpl { | |
8 | + function new(fn:Void->Void) { | |
9 | + fn(); | |
10 | + } | |
11 | +} | |
\ No newline at end of file |
@@ -0,0 +1,57 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend; | |
6 | + | |
7 | +import haxe.ui.backend.koreader.creators.Creator; | |
8 | +import haxe.ui.backend.koreader.WidgetWrapper; | |
9 | +import haxe.ui.components.Button; | |
10 | +import haxe.ui.components.Label; | |
11 | +import haxe.ui.containers.HBox; | |
12 | +import haxe.ui.containers.VBox; | |
13 | +import haxe.ui.core.Component; | |
14 | +import haxe.ui.core.TextInput; | |
15 | +import haxe.ui.events.UIEvent; | |
16 | +import haxe.ui.events.MouseEvent; | |
17 | +import koreader.ui.Font; | |
18 | +import koreader.ui.UIManager; | |
19 | +import koreader.ui.widget.Widget; | |
20 | + | |
21 | +class ComponentImpl extends ComponentBase { | |
22 | + private var wrapper : WidgetWrapper; | |
23 | + | |
24 | + private var __parent : Component; | |
25 | + | |
26 | + override function handleAddComponent(child:Component):Component { | |
27 | + child.__parent = cast this; | |
28 | + return super.handleAddComponent(child); | |
29 | + } | |
30 | + | |
31 | + override function removeComponent(child:Component, dispose:Bool = true, invalidate:Bool = true):Component { | |
32 | + this.wrapper.children.remove(child); | |
33 | + return super.removeComponent(child, dispose, invalidate); | |
34 | + } | |
35 | + | |
36 | + override function handleReady() { | |
37 | + this.createWidget(this.__parent == null ? null : this.__parent.wrapper); | |
38 | + super.handleReady(); | |
39 | + } | |
40 | + | |
41 | + private function createWidget(parent:WidgetWrapper = null) { | |
42 | + if (parent == null) { | |
43 | + parent = Toolkit.screen.mainContainer; | |
44 | + } | |
45 | + | |
46 | + var creatorClass:String = Toolkit.nativeConfig.query('component[id=${className}].@creator', null, this); | |
47 | + if (creatorClass != null) { | |
48 | + var creator : Creator = Type.createInstance(Type.resolveClass(creatorClass), [this]); | |
49 | + this.wrapper = creator.createWrapper(parent); | |
50 | + } | |
51 | + else { | |
52 | + trace('There is no information for building ${className}'); | |
53 | + } | |
54 | + | |
55 | + parent.children.push(cast(this, Component)); | |
56 | + } | |
57 | +} | |
\ No newline at end of file |
@@ -0,0 +1,10 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend; | |
6 | + | |
7 | +class ComponentSurface { | |
8 | + function new() { | |
9 | + } | |
10 | +} | |
\ No newline at end of file |
@@ -0,0 +1,8 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend; | |
6 | + | |
7 | +class EventImpl extends EventBase { | |
8 | +} | |
\ No newline at end of file |
@@ -0,0 +1,9 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend; | |
6 | + | |
7 | +class FontData { | |
8 | + | |
9 | +} | |
\ No newline at end of file |
@@ -0,0 +1,9 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend; | |
6 | + | |
7 | +class ImageData { | |
8 | + | |
9 | +} | |
\ No newline at end of file |
@@ -0,0 +1,11 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend; | |
6 | + | |
7 | +class ImageDisplayImpl extends ImageBase { | |
8 | + function new() { | |
9 | + | |
10 | + } | |
11 | +} | |
\ No newline at end of file |
@@ -0,0 +1,9 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend; | |
6 | + | |
7 | +class ImageSurface { | |
8 | + | |
9 | +} | |
\ No newline at end of file |
@@ -0,0 +1,8 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend; | |
6 | + | |
7 | +class PlatformImpl extends PlatformBase { | |
8 | +} | |
\ No newline at end of file |
@@ -0,0 +1,28 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend; | |
6 | + | |
7 | +import haxe.ui.backend.koreader.WidgetWrapper; | |
8 | + | |
9 | +class ScreenImpl extends ScreenBase { | |
10 | + function new() { | |
11 | + | |
12 | + } | |
13 | + public var mainWindow(get, null) : WidgetWrapper; | |
14 | + private function get_mainWindow() : WidgetWrapper { | |
15 | + if (options == null) { | |
16 | + return null; | |
17 | + } | |
18 | + return options.mainWindow; | |
19 | + } | |
20 | + | |
21 | + public var mainContainer(get, null) : WidgetWrapper; | |
22 | + private function get_mainContainer() : WidgetWrapper { | |
23 | + if (options == null) { | |
24 | + return null; | |
25 | + } | |
26 | + return options.mainContainer; | |
27 | + } | |
28 | +} | |
\ No newline at end of file |
@@ -0,0 +1,8 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend; | |
6 | + | |
7 | +class TextDisplayImpl extends TextBase { | |
8 | +} | |
\ No newline at end of file |
@@ -0,0 +1,8 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend; | |
6 | + | |
7 | +class TextInputImpl extends TextDisplayImpl { | |
8 | +} | |
\ No newline at end of file |
@@ -0,0 +1,13 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend; | |
6 | + | |
7 | +class TimerImpl { | |
8 | + function new(delay : Int, callback : Void->Void) { | |
9 | + } | |
10 | + | |
11 | + public function stop() { | |
12 | + } | |
13 | +} | |
\ No newline at end of file |
@@ -0,0 +1,12 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend; | |
6 | + | |
7 | +import haxe.ui.backend.koreader.WidgetWrapper; | |
8 | + | |
9 | +typedef ToolkitOptions = { | |
10 | + ?mainWindow : WidgetWrapper, | |
11 | + ?mainContainer : WidgetWrapper, | |
12 | +} | |
\ No newline at end of file |
@@ -0,0 +1,22 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend.koreader; | |
6 | + | |
7 | +import haxe.ui.core.Component; | |
8 | +import koreader.ui.widget.Widget; | |
9 | + | |
10 | +/** | |
11 | + * A wrapper for `Widget` | |
12 | + */ | |
13 | +class WidgetWrapper { | |
14 | + public function new(wid: Widget) { | |
15 | + this.widget = wid; | |
16 | + this.children = []; | |
17 | + } | |
18 | + | |
19 | + public var widget : Widget; | |
20 | + | |
21 | + public var children : Array<Component>; | |
22 | +} | |
\ No newline at end of file |
@@ -0,0 +1,15 @@ | ||
1 | +/* | |
2 | + SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
3 | + | |
4 | + SPDX-License-Identifier: Unlicense | |
5 | +*/ | |
6 | + | |
7 | +* { | |
8 | + native: true; | |
9 | +} | |
10 | + | |
11 | +.component:native { | |
12 | + background-color: none; | |
13 | + color: none; | |
14 | + border: none; | |
15 | +} | |
\ No newline at end of file |
@@ -0,0 +1,29 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend.koreader.behaviours; | |
6 | + | |
7 | +import haxe.ui.behaviours.DataBehaviour; | |
8 | +import haxe.ui.util.Variant; | |
9 | +import koreader.ui.widget.Button; | |
10 | + | |
11 | +@:keep | |
12 | +@:access(haxe.ui.core.Component) | |
13 | +class WidgetText extends DataBehaviour { | |
14 | + override function get() : Variant { | |
15 | + if (_component.wrapper == null) { | |
16 | + return _value; | |
17 | + } else { | |
18 | + var ctrl : Button = cast _component.wrapper.widget; | |
19 | + var text = ctrl.text; | |
20 | + return text; | |
21 | + } | |
22 | + } | |
23 | + | |
24 | + override function validateData() { | |
25 | + super.validateData(); | |
26 | + var ctrl : Button = cast _component.wrapper.widget; | |
27 | + ctrl.setText(_value); | |
28 | + } | |
29 | +} | |
\ No newline at end of file |
@@ -0,0 +1,27 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend.koreader.creators; | |
6 | + | |
7 | +import haxe.ui.events.MouseEvent; | |
8 | +import koreader.ui.widget.Button; | |
9 | +import koreader.ui.widget.Widget; | |
10 | + | |
11 | +@:keep | |
12 | +class ButtonCreator extends Creator { | |
13 | + private var _button : haxe.ui.components.Button; | |
14 | + | |
15 | + function new(button : haxe.ui.components.Button) { | |
16 | + super(button); | |
17 | + this._button = button; | |
18 | + } | |
19 | + | |
20 | + function createWidget() : Widget { | |
21 | + return Button.create({text: this._button.text, callback: this.callback}); | |
22 | + } | |
23 | + | |
24 | + function callback() { | |
25 | + this._button.dispatch(new haxe.ui.events.MouseEvent(MouseEvent.CLICK)); | |
26 | + } | |
27 | +} | |
\ No newline at end of file |
@@ -0,0 +1,34 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend.koreader.creators; | |
6 | + | |
7 | +import haxe.ui.core.Component; | |
8 | + | |
9 | +abstract class Creator { | |
10 | + var component : Component; | |
11 | + | |
12 | + public function new(comp : Component) { | |
13 | + this.component = comp; | |
14 | + } | |
15 | + | |
16 | + /** | |
17 | + * Create the widget associated to the component | |
18 | + * @return The widget | |
19 | + */ | |
20 | + private abstract function createWidget() : koreader.ui.widget.Widget; | |
21 | + | |
22 | + | |
23 | + /** | |
24 | + * Create the wrapper for the component and adds it to the parent | |
25 | + * @param parent The parent of this component | |
26 | + * @return The wrapper | |
27 | + */ | |
28 | + public function createWrapper(parent : WidgetWrapper) : WidgetWrapper { | |
29 | + var widget = this.createWidget(); | |
30 | + var container : koreader.ui.widget.container.WidgetContainer = cast parent.widget; | |
31 | + container.addWidget(widget); | |
32 | + return new WidgetWrapper(widget); | |
33 | + } | |
34 | +} | |
\ No newline at end of file |
@@ -0,0 +1,12 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend.koreader.creators; | |
6 | + | |
7 | +@:keep | |
8 | +class HBoxCreator extends Creator { | |
9 | + function createWidget() { | |
10 | + return koreader.ui.widget.HorizontalGroup.create({}); | |
11 | + } | |
12 | +} | |
\ No newline at end of file |
@@ -0,0 +1,22 @@ | ||
1 | +package haxe.ui.backend.koreader.creators; | |
2 | + | |
3 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
4 | +// | |
5 | +// SPDX-License-Identifier: Unlicense | |
6 | + | |
7 | +import koreader.ui.Font; | |
8 | +import koreader.ui.widget.Widget; | |
9 | + | |
10 | +@:keep | |
11 | +class LabelCreator extends Creator { | |
12 | + private var _label : haxe.ui.components.Label; | |
13 | + | |
14 | + function new(label : haxe.ui.components.Label) { | |
15 | + super(label); | |
16 | + this._label = label; | |
17 | + } | |
18 | + | |
19 | + function createWidget() : Widget { | |
20 | + return koreader.ui.widget.TextWidget.create({text: this._label.text, face: Font.getFace()}); | |
21 | + } | |
22 | +} | |
\ No newline at end of file |
@@ -0,0 +1,12 @@ | ||
1 | +// SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
2 | +// | |
3 | +// SPDX-License-Identifier: Unlicense | |
4 | + | |
5 | +package haxe.ui.backend.koreader.creators; | |
6 | + | |
7 | +@:keep | |
8 | +class VBoxCreator extends Creator { | |
9 | + function createWidget() { | |
10 | + return koreader.ui.widget.VerticalGroup.create({}); | |
11 | + } | |
12 | +} | |
\ No newline at end of file |
@@ -0,0 +1,16 @@ | ||
1 | +<!-- | |
2 | + SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
3 | + | |
4 | + SPDX-License-Identifier: Unlicense | |
5 | +--> | |
6 | +<?xml version="1.0" encoding="utf-8" ?> | |
7 | +<module id="haxeui-koreader"> | |
8 | + <resources> | |
9 | + <resource path="/haxe/ui/backend/koreader/_module/styles" prefix="styles" /> | |
10 | + </resources> | |
11 | + <themes> | |
12 | + <global> | |
13 | + <style resource="styles/main.css" /> | |
14 | + </global> | |
15 | + </themes> | |
16 | +</module> | |
\ No newline at end of file |
@@ -0,0 +1,15 @@ | ||
1 | +<!-- | |
2 | + SPDX-FileCopyrightText: 2022 Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fastmail.net> | |
3 | + | |
4 | + SPDX-License-Identifier: Unlicense | |
5 | +--> | |
6 | +<?xml version="1.0" encoding="utf-8" ?> | |
7 | +<native> | |
8 | + <component id="haxe.ui.components.Button" allowChildren="false" creator="haxe.ui.backend.koreader.creators.ButtonCreator"> | |
9 | + <behaviour id="text" class="haxe.ui.backend.koreader.behaviours.WidgetText" /> | |
10 | + <behaviour id="value" class="haxe.ui.backend.koreader.behaviours.WidgetText" /> | |
11 | + </component> | |
12 | + <component id="haxe.ui.components.Label" allowChildren="false" creator="haxe.ui.backend.koreader.creators.LabelCreator" /> | |
13 | + <component id="haxe.ui.containers.HBox" allowChildren="true" creator="haxe.ui.backend.koreader.creators.HBoxCreator" /> | |
14 | + <component id="haxe.ui.containers.VBox" allowChildren="true" creator="haxe.ui.backend.koreader.creators.VBoxCreator" /> | |
15 | +</native> | |
\ No newline at end of file |