• R/O
  • SSH

Commit

Frequently used words (click to add to your profile)

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

Commit MetaInfo

Revisão49243744bee211cd36fd6907013714e4fe9e5cd1 (tree)
Hora2022-07-16 05:44:15
AutorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fast...>
CommiterJaime Marquínez Ferrándiz

Mensagem de Log

Allow opening dialogs

Mudança Sumário

Diff

diff -r 452e094b9e3f -r 49243744bee2 assets/custom-dialog.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/assets/custom-dialog.xml Fri Jul 15 22:44:15 2022 +0200
@@ -0,0 +1,6 @@
1+<dialog>
2+ <vbox>
3+ <label text="Custom dialog" />
4+ <button text="Close" id="btnClose"/>
5+ </vbox>
6+</dialog>
\ No newline at end of file
diff -r 452e094b9e3f -r 49243744bee2 assets/main-view.xml
--- a/assets/main-view.xml Tue Apr 05 21:34:31 2022 +0200
+++ b/assets/main-view.xml Fri Jul 15 22:44:15 2022 +0200
@@ -19,5 +19,7 @@
1919 <button text="Y" />
2020 </hbox>
2121 </vbox>
22+
23+ <button text="Open custom dialog" id="btnDialog" />
2224 </hbox>
2325 </vbox>
\ No newline at end of file
diff -r 452e094b9e3f -r 49243744bee2 demo.hxml
--- a/demo.hxml Tue Apr 05 21:34:31 2022 +0200
+++ b/demo.hxml Fri Jul 15 22:44:15 2022 +0200
@@ -2,6 +2,9 @@
22 #
33 # SPDX-License-Identifier: Unlicense
44
5+
6+--library haxeui-core
7+--library haxe-koreader
58 --class-path src
69
710 --macro include("haxe.ui.backend.koreader")
@@ -11,9 +14,6 @@
1114 --class-path demo
1215 --main Main
1316
14---library haxeui-core
15---library haxe-koreader
16-
1717 --dce full
1818
1919 --lua out/haxeui_demo.lua
diff -r 452e094b9e3f -r 49243744bee2 demo/CustomDialog.hx
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/demo/CustomDialog.hx Fri Jul 15 22:44:15 2022 +0200
@@ -0,0 +1,14 @@
1+import haxe.ui.events.MouseEvent;
2+import haxe.ui.containers.dialogs.Dialog;
3+
4+@:build(haxe.ui.ComponentBuilder.build("assets/custom-dialog.xml"))
5+class CustomDialog extends Dialog {
6+ public function new() {
7+ super();
8+ }
9+
10+ @:bind(btnClose, MouseEvent.CLICK)
11+ private function onOpenDialog(e:MouseEvent) {
12+ this.hide();
13+ }
14+}
\ No newline at end of file
diff -r 452e094b9e3f -r 49243744bee2 demo/MainView.hx
--- a/demo/MainView.hx Tue Apr 05 21:34:31 2022 +0200
+++ b/demo/MainView.hx Fri Jul 15 22:44:15 2022 +0200
@@ -21,4 +21,10 @@
2121 private function onMyButton(e:MouseEvent) {
2222 btn2.text = "Clicked!";
2323 }
24+
25+ @:bind(btnDialog, MouseEvent.CLICK)
26+ private function onOpenDialog(e:MouseEvent) {
27+ var dialog = new CustomDialog();
28+ dialog.showDialog();
29+ }
2430 }
\ No newline at end of file
diff -r 452e094b9e3f -r 49243744bee2 src/haxe/ui/backend/ComponentImpl.hx
--- a/src/haxe/ui/backend/ComponentImpl.hx Tue Apr 05 21:34:31 2022 +0200
+++ b/src/haxe/ui/backend/ComponentImpl.hx Fri Jul 15 22:44:15 2022 +0200
@@ -6,6 +6,7 @@
66
77 import haxe.ui.backend.koreader.creators.Creator;
88 import haxe.ui.backend.koreader.WidgetWrapper;
9+import haxe.ui.backend.koreader.DialogWrapper;
910 import haxe.ui.components.Button;
1011 import haxe.ui.components.Label;
1112 import haxe.ui.containers.HBox;
@@ -43,7 +44,7 @@
4344 parent = Toolkit.screen.mainContainer;
4445 }
4546
46- var creatorClass:String = Toolkit.nativeConfig.query('component[id=${className}].@creator', null, this);
47+ var creatorClass:String = this.getCreator();
4748 if (creatorClass != null) {
4849 var creator : Creator = Type.createInstance(Type.resolveClass(creatorClass), [this]);
4950 this.wrapper = creator.createWrapper(parent);
@@ -54,4 +55,42 @@
5455
5556 parent.children.push(cast(this, Component));
5657 }
58+
59+ private function getCreator() {
60+ var valueType = Type.typeof(this);
61+ switch (valueType) {
62+ case TClass(cls):
63+ return this.getCreatorClassname(cls);
64+ default:
65+ return null;
66+ }
67+ }
68+
69+ private function getCreatorClassname(cls : Class<Dynamic>) {
70+ if (cls == null) {
71+ trace('the class for the component ${className} is null');
72+ return null;
73+ }
74+ var clsName = Type.getClassName(cls);
75+ trace(clsName);
76+ var creatorClass = Toolkit.nativeConfig.query('component[id=${clsName}].@creator', null, this);
77+ if (creatorClass != null) {
78+ return creatorClass;
79+ } else {
80+ return this.getCreatorClassname(Type.getSuperClass(cls));
81+ }
82+ }
83+
84+ override function handleVisibility(show:Bool) {
85+ if (this.wrapper is DialogWrapper) {
86+ var dlgWrapper = cast(this.wrapper, DialogWrapper);
87+ if (show) {
88+ UIManager.show(dlgWrapper.dialog);
89+ UIManager.setDirty(dlgWrapper.dialog, Partial);
90+ } else {
91+ UIManager.close(dlgWrapper.dialog);
92+ UIManager.setDirty(dlgWrapper.dialog, Partial);
93+ }
94+ }
95+ }
5796 }
\ No newline at end of file
diff -r 452e094b9e3f -r 49243744bee2 src/haxe/ui/backend/DialogBase.hx
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/haxe/ui/backend/DialogBase.hx Fri Jul 15 22:44:15 2022 +0200
@@ -0,0 +1,40 @@
1+package haxe.ui.backend;
2+
3+import haxe.exceptions.NotImplementedException;
4+import haxe.ui.containers.Box;
5+import haxe.ui.containers.VBox;
6+import haxe.ui.containers.dialogs.Dialog.DialogButton;
7+import haxe.ui.core.Component;
8+
9+class DialogBase extends Component {
10+ public var modal:Bool = true;
11+ public var buttons:DialogButton = null;
12+ public var centerDialog:Bool = true;
13+ public var button:DialogButton = null;
14+
15+ public var dialogContentContainer:VBox;
16+ public var dialogContent:VBox;
17+ public var customDialogFooterContainer:Box;
18+ public var customDialogFooter:Box;
19+
20+ public var title:String;
21+
22+ public function new() {
23+ super();
24+ this._hidden = true;
25+ }
26+
27+ public function showDialog(modal:Bool = true) {
28+ this.modal = modal;
29+ show();
30+ }
31+
32+ override function show() {
33+ this.ready();
34+ super.show();
35+ }
36+
37+ private function createButtons() {
38+ throw new NotImplementedException();
39+ }
40+}
diff -r 452e094b9e3f -r 49243744bee2 src/haxe/ui/backend/koreader/DialogWrapper.hx
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/haxe/ui/backend/koreader/DialogWrapper.hx Fri Jul 15 22:44:15 2022 +0200
@@ -0,0 +1,12 @@
1+package haxe.ui.backend.koreader;
2+
3+import koreader.ui.widget.Widget;
4+
5+class DialogWrapper extends WidgetWrapper {
6+ public var dialog : Widget;
7+
8+ public function new(dialog : Widget, container : Widget) {
9+ super(container);
10+ this.dialog = dialog;
11+ }
12+}
\ No newline at end of file
diff -r 452e094b9e3f -r 49243744bee2 src/haxe/ui/backend/koreader/creators/DialogCreator.hx
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/haxe/ui/backend/koreader/creators/DialogCreator.hx Fri Jul 15 22:44:15 2022 +0200
@@ -0,0 +1,46 @@
1+package haxe.ui.backend.koreader.creators;
2+
3+import koreader.ui.widget.container.MovableContainer;
4+import koreader.Device;
5+import koreader.ui.widget.container.CenterContainer;
6+import koreader.ffi.Blitbuffer;
7+import koreader.ui.widget.VerticalGroup;
8+import koreader.ui.Size;
9+import koreader.ui.widget.container.FrameContainer;
10+import koreader.ui.widget.Widget;
11+
12+@:keep
13+class DialogCreator extends Creator {
14+ private var _dialog : haxe.ui.containers.dialogs.Dialog;
15+
16+ public function new(dialog : haxe.ui.containers.dialogs.Dialog) {
17+ super(dialog);
18+ this._dialog = dialog;
19+ }
20+
21+ function createWidget() : Widget {
22+ throw new haxe.exceptions.NotImplementedException();
23+ }
24+
25+ override function createWrapper(parent : WidgetWrapper) : WidgetWrapper {
26+ var frame = FrameContainer.create({
27+ background: Blitbuffer.COLOR_GRAY,
28+ bordersize: Size.border.window,
29+ radius: Size.radius.window,
30+ padding: Size.padding.default_,
31+ });
32+
33+ var group = VerticalGroup.create({});
34+ frame.addWidget(group);
35+
36+ var dialog = CenterContainer.create({
37+ dimen: Device.screen.getSize(),
38+ widgets: [
39+ MovableContainer.create({
40+ widgets: [frame],
41+ }),
42+ ],
43+ });
44+ return new DialogWrapper(dialog, group);
45+ }
46+}
\ No newline at end of file
diff -r 452e094b9e3f -r 49243744bee2 src/haxe/ui/backend/native.xml
--- a/src/haxe/ui/backend/native.xml Tue Apr 05 21:34:31 2022 +0200
+++ b/src/haxe/ui/backend/native.xml Fri Jul 15 22:44:15 2022 +0200
@@ -12,4 +12,5 @@
1212 <component id="haxe.ui.components.Label" allowChildren="false" creator="haxe.ui.backend.koreader.creators.LabelCreator" />
1313 <component id="haxe.ui.containers.HBox" allowChildren="true" creator="haxe.ui.backend.koreader.creators.HBoxCreator" />
1414 <component id="haxe.ui.containers.VBox" allowChildren="true" creator="haxe.ui.backend.koreader.creators.VBoxCreator" />
15+ <component id="haxe.ui.containers.dialogs.Dialog" allowChildren="true" creator="haxe.ui.backend.koreader.creators.DialogCreator" />
1516 </native>
\ No newline at end of file