added very simple GPS GUI
This commit is contained in:
parent
5fa6c3ecbf
commit
8683eaf17a
54
src/bin/pathfinder/PFClient.hx
Normal file
54
src/bin/pathfinder/PFClient.hx
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package bin.pathfinder;
|
||||||
|
|
||||||
|
import lib.Pos3;
|
||||||
|
import lib.ui.elements.UIElement;
|
||||||
|
import lib.ui.elements.TextElement;
|
||||||
|
import lib.ui.elements.RootElement;
|
||||||
|
import kernel.ui.WindowContext;
|
||||||
|
import kernel.ps.ProcessHandle;
|
||||||
|
import kernel.ps.Process;
|
||||||
|
|
||||||
|
class PFClient implements Process {
|
||||||
|
private var handle:ProcessHandle;
|
||||||
|
|
||||||
|
private var ctx: WindowContext;
|
||||||
|
private var requestRender:Void -> Void;
|
||||||
|
private var root:RootElement;
|
||||||
|
|
||||||
|
public function new() {}
|
||||||
|
|
||||||
|
public function run(handle:ProcessHandle) {
|
||||||
|
this.handle = handle;
|
||||||
|
|
||||||
|
var stateless = handle.createStatelessWindowContext();
|
||||||
|
this.ctx = stateless.ctx;
|
||||||
|
this.requestRender = stateless.requestRender;
|
||||||
|
|
||||||
|
stateless.setRenderFunc(this.render);
|
||||||
|
|
||||||
|
this.root = new RootElement();
|
||||||
|
this.root.setTitle("Pathfinder");
|
||||||
|
|
||||||
|
this.ctx.delegateEvents(this.root);
|
||||||
|
|
||||||
|
this.requestRender();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function render() {
|
||||||
|
var acc = kernel.gps.GPS.instance.getAccuracy();
|
||||||
|
var pos: Pos3 = kernel.gps.GPS.instance.getPosition() ?? {x: 0, y: 0, z: 0};
|
||||||
|
|
||||||
|
var childre: Array<UIElement> = [
|
||||||
|
new TextElement('Acc: ${acc}'),
|
||||||
|
new TextElement('Pos: X:${pos.x} Y:${pos.y} Z:${pos.z}'),
|
||||||
|
new TextElement('UPDATE', { onClick: () -> {
|
||||||
|
kernel.gps.GPS.instance.locate().handle((pos) ->{
|
||||||
|
this.requestRender();
|
||||||
|
});
|
||||||
|
}}),
|
||||||
|
];
|
||||||
|
|
||||||
|
this.root.setChildren(childre);
|
||||||
|
this.root.render(ctx.getSize()).renderToContext(ctx);
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package kernel.binstore;
|
package kernel.binstore;
|
||||||
|
|
||||||
|
import bin.pathfinder.PFClient;
|
||||||
import bin.ID;
|
import bin.ID;
|
||||||
import bin.exporter.Res;
|
import bin.exporter.Res;
|
||||||
import bin.exporter.ResManager;
|
import bin.exporter.ResManager;
|
||||||
@ -41,7 +42,8 @@ class BinStore {
|
|||||||
{c: KSettings, name: "KSettings", aliases: ["ksettings","ks"]},
|
{c: KSettings, name: "KSettings", aliases: ["ksettings","ks"]},
|
||||||
{c: ResManager, name: "ResManager", aliases: ["resmanager","resmgr"]},
|
{c: ResManager, name: "ResManager", aliases: ["resmanager","resmgr"]},
|
||||||
{c: Res, name: "Res", aliases: ["res"]},
|
{c: Res, name: "Res", aliases: ["res"]},
|
||||||
{c: ID , name: "ID", aliases: ["id"]}
|
{c: ID , name: "ID", aliases: ["id"]},
|
||||||
|
{c: PFClient, name: "PFClient", aliases: ["pfclient"]}
|
||||||
];
|
];
|
||||||
|
|
||||||
@:allow(kernel.Init)
|
@:allow(kernel.Init)
|
||||||
|
@ -33,7 +33,8 @@ class HomeContext {
|
|||||||
|
|
||||||
private final listedApps:Array<String> = [
|
private final listedApps:Array<String> = [
|
||||||
"terminal",
|
"terminal",
|
||||||
"log"
|
"log",
|
||||||
|
"pfclient"
|
||||||
];
|
];
|
||||||
|
|
||||||
public function new() {}
|
public function new() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user