interface name consistency

This commit is contained in:
Niklas Kapelle 2024-03-13 10:39:22 +01:00
parent 2ab5a38894
commit 4ab3d868c1
Signed by: niklas
GPG Key ID: 4EB651B36D841D16
37 changed files with 94 additions and 94 deletions

View File

@ -1,10 +1,10 @@
package bin; package bin;
import kernel.ps.ProcessHandle; import kernel.ps.ProcessHandle;
import kernel.ps.Process; import kernel.ps.IProcess;
@:build(macros.Binstore.includeBin("ID", ["id"])) @:build(macros.Binstore.includeBin("ID", ["id"]))
class ID implements Process { class ID implements IProcess {
public function new() {} public function new() {}
public function run(handle:ProcessHandle) { public function run(handle:ProcessHandle) {

View File

@ -1,7 +1,7 @@
package bin; package bin;
import kernel.ps.ProcessHandle; import kernel.ps.ProcessHandle;
import kernel.ps.Process; import kernel.ps.IProcess;
import lib.Color; import lib.Color;
import lib.MathI; import lib.MathI;
import kernel.log.Log; import kernel.log.Log;
@ -11,7 +11,7 @@ import lib.ui.UIApp;
using tink.CoreApi; using tink.CoreApi;
@:build(macros.Binstore.includeBin("Log", ["log"])) @:build(macros.Binstore.includeBin("Log", ["log"]))
class KernelLog implements Process { class KernelLog implements IProcess {
private var handle:ProcessHandle; private var handle:ProcessHandle;
private var ctx:WindowContext; private var ctx:WindowContext;

View File

@ -2,10 +2,10 @@ package bin;
import kernel.ps.ProcessManager; import kernel.ps.ProcessManager;
import kernel.ps.ProcessHandle; import kernel.ps.ProcessHandle;
import kernel.ps.Process; import kernel.ps.IProcess;
@:build(macros.Binstore.includeBin("LSPS", ["lsps"])) @:build(macros.Binstore.includeBin("LSPS", ["lsps"]))
class LSPS implements Process { class LSPS implements IProcess {
public function new() {} public function new() {}
public function run(handle:ProcessHandle) { public function run(handle:ProcessHandle) {

View File

@ -4,7 +4,7 @@ import kernel.EndOfLoop;
import lua.NativeStringTools; import lua.NativeStringTools;
import kernel.binstore.BinStore; import kernel.binstore.BinStore;
import kernel.ps.ProcessHandle; import kernel.ps.ProcessHandle;
import kernel.ps.Process; import kernel.ps.IProcess;
import kernel.ps.ProcessManager; import kernel.ps.ProcessManager;
import lib.Color; import lib.Color;
import kernel.ui.WindowContext; import kernel.ui.WindowContext;
@ -12,7 +12,7 @@ import kernel.ui.WindowContext;
using tink.CoreApi; using tink.CoreApi;
@:build(macros.Binstore.includeBin("Terminal", ["terminal"])) @:build(macros.Binstore.includeBin("Terminal", ["terminal"]))
class Terminal implements Process { class Terminal implements IProcess {
private static inline final MAX_BACKLOG:Int = 100; private static inline final MAX_BACKLOG:Int = 100;
private var handle:ProcessHandle; private var handle:ProcessHandle;

View File

@ -3,7 +3,7 @@ package bin.debug;
import kernel.log.Log; import kernel.log.Log;
import lib.turtle.InvManager; import lib.turtle.InvManager;
import kernel.ps.ProcessHandle; import kernel.ps.ProcessHandle;
import kernel.ps.Process; import kernel.ps.IProcess;
/** /**
Use this to test whatever you are working on. It will also print debug statements. Use this to test whatever you are working on. It will also print debug statements.
@ -12,7 +12,7 @@ import kernel.ps.Process;
#if debug #if debug
@:build(macros.Binstore.includeBin("Debug", ["dbg", "debug"])) @:build(macros.Binstore.includeBin("Debug", ["dbg", "debug"]))
#end #end
class Debug implements Process { class Debug implements IProcess {
public function new() {} public function new() {}
public function run(handle:ProcessHandle) { public function run(handle:ProcessHandle) {

View File

@ -3,12 +3,12 @@ package bin.debug;
import bin.debug.DebugRPC.DebugRPCImpl; import bin.debug.DebugRPC.DebugRPCImpl;
import macros.rpc.RPC; import macros.rpc.RPC;
import kernel.ps.ProcessHandle; import kernel.ps.ProcessHandle;
import kernel.ps.Process; import kernel.ps.IProcess;
#if debug #if debug
@:build(macros.Binstore.includeBin("Debug SRV", ["dbg-srv", "debug-srv"])) @:build(macros.Binstore.includeBin("Debug SRV", ["dbg-srv", "debug-srv"]))
#end #end
class DebugService implements Process implements DebugRPC { class DebugService implements IProcess implements DebugRPC {
private var handle:ProcessHandle; private var handle:ProcessHandle;
public function new() {} public function new() {}

View File

@ -1,14 +1,14 @@
package bin.pathfinder; package bin.pathfinder;
import lib.Pos3; import lib.Pos3;
import lib.ui.elements.UIElement; import lib.ui.elements.IUIElement;
import lib.ui.elements.TextElement; import lib.ui.elements.TextElement;
import lib.ui.elements.RootElement; import lib.ui.elements.RootElement;
import kernel.ui.WindowContext; import kernel.ui.WindowContext;
import kernel.ps.ProcessHandle; import kernel.ps.ProcessHandle;
import kernel.ps.Process; import kernel.ps.IProcess;
class PFClient implements Process { class PFClient implements IProcess {
private var handle:ProcessHandle; private var handle:ProcessHandle;
private var ctx:WindowContext; private var ctx:WindowContext;
@ -38,7 +38,7 @@ class PFClient implements Process {
var acc = kernel.gps.GPS.getAccuracy(); var acc = kernel.gps.GPS.getAccuracy();
var pos:Pos3 = kernel.gps.GPS.getPosition() ?? {x: 0, y: 0, z: 0}; var pos:Pos3 = kernel.gps.GPS.getPosition() ?? {x: 0, y: 0, z: 0};
var childre:Array<UIElement> = [ var childre:Array<IUIElement> = [
new TextElement('Acc: ${acc}'), new TextElement('Acc: ${acc}'),
new TextElement('Pos: X:${pos.x} Y:${pos.y} Z:${pos.z}'), new TextElement('Pos: X:${pos.x} Y:${pos.y} Z:${pos.z}'),
new TextElement('UPDATE', { new TextElement('UPDATE', {

View File

@ -2,9 +2,9 @@ package bin.turtle;
import kernel.turtle.TurtleMutex; import kernel.turtle.TurtleMutex;
import kernel.ps.ProcessHandle; import kernel.ps.ProcessHandle;
import kernel.ps.Process; import kernel.ps.IProcess;
class Patrol implements Process { class Patrol implements IProcess {
private var handle:ProcessHandle; private var handle:ProcessHandle;
public function new() {} public function new() {}

View File

@ -1,7 +1,7 @@
package kernel; package kernel;
import lib.Pos; import lib.Pos;
import kernel.ui.TermWriteable; import kernel.ui.ITermWriteable;
import cc.Term; import cc.Term;
import lib.Vec.Vec2; import lib.Vec.Vec2;
import lib.Color; import lib.Color;
@ -11,7 +11,7 @@ using tink.CoreApi;
/** /**
Represents the main computer screen. Represents the main computer screen.
**/ **/
class MainTerm implements TermWriteable { class MainTerm implements ITermWriteable {
/** /**
Depends on: KernelEvents, Depends on: KernelEvents,
**/ **/

View File

@ -1,12 +1,12 @@
package kernel.binstore; package kernel.binstore;
import kernel.ps.Process; import kernel.ps.IProcess;
/** /**
Represents a callable program. Represents a callable program.
**/ **/
typedef Bin = { typedef Bin = {
c:Void->Process, c:Void->IProcess,
name:String, name:String,
aliases:Array<String>, aliases:Array<String>,
} }

View File

@ -1,6 +1,6 @@
package kernel.binstore; package kernel.binstore;
import kernel.ps.Process; import kernel.ps.IProcess;
import macros.Binstore; import macros.Binstore;
class BinStore { class BinStore {
@ -13,7 +13,7 @@ class BinStore {
return bins; return bins;
} }
public static function instantiate(alias:String):Null<Process> { public static function instantiate(alias:String):Null<IProcess> {
for (bin in bins) { for (bin in bins) {
for (a in bin.aliases) { for (a in bin.aliases) {
if (a == alias) { if (a == alias) {

View File

@ -3,13 +3,13 @@ package kernel.peripherals;
import cc.Peripheral; import cc.Peripheral;
import lib.Pos; import lib.Pos;
import cc.Term.TerminalSize; import cc.Term.TerminalSize;
import kernel.ui.TermWriteable; import kernel.ui.ITermWriteable;
import lib.Vec.Vec2; import lib.Vec.Vec2;
import lib.Color; import lib.Color;
using tink.CoreApi; using tink.CoreApi;
class Screen implements TermWriteable implements IPeripheral { class Screen implements ITermWriteable implements IPeripheral {
public static inline final TYPE_NAME:String = "monitor"; public static inline final TYPE_NAME:String = "monitor";
private final nativ:cc.periphs.Monitor.Monitor; private final nativ:cc.periphs.Monitor.Monitor;

View File

@ -3,6 +3,6 @@ package kernel.ps;
/** /**
Defines an independent process that can be run by the kernel. Defines an independent process that can be run by the kernel.
**/ **/
interface Process { interface IProcess {
public function run(handle:ProcessHandle):Void; public function run(handle:ProcessHandle):Void;
} }

View File

@ -10,7 +10,7 @@ typedef PID = Int;
class ProcessManager { class ProcessManager {
private static final processList = new Map<PID, ProcessHandle>(); private static final processList = new Map<PID, ProcessHandle>();
public static function run(process:Process, config:HandleConfig):PID { public static function run(process:IProcess, config:HandleConfig):PID {
var pid = createPID(); var pid = createPID();
var handle = new ProcessHandle(config, pid); var handle = new ProcessHandle(config, pid);

View File

@ -1,6 +1,6 @@
package kernel.service; package kernel.service;
import kernel.ps.Process; import kernel.ps.IProcess;
import kernel.ps.ProcessManager; import kernel.ps.ProcessManager;
import kernel.binstore.BinStore; import kernel.binstore.BinStore;
@ -11,7 +11,7 @@ class Service {
public final name:String; public final name:String;
public final args:Array<String>; public final args:Array<String>;
public var pid:PID; public var pid:PID;
public var ps:Process; public var ps:IProcess;
@:allow(kernel.service.ServiceManager) @:allow(kernel.service.ServiceManager)
private function new(binName:String, name:String, ?args:Array<String>) { private function new(binName:String, name:String, ?args:Array<String>) {

View File

@ -3,7 +3,7 @@ package kernel.ui;
import lib.Pos; import lib.Pos;
import lib.Vec.Vec2; import lib.Vec.Vec2;
import lib.Color; import lib.Color;
import kernel.ui.TermWriteable; import kernel.ui.ITermWriteable;
using tink.CoreApi; using tink.CoreApi;
@ -11,15 +11,15 @@ using tink.CoreApi;
A term writer that can switch beetween its internal buffer and another termwriter. A term writer that can switch beetween its internal buffer and another termwriter.
The other target is most of the time a real screen The other target is most of the time a real screen
**/ **/
class BufferedVirtualTermWriter implements VirtualTermWriter extends TermBuffer { class BufferedVirtualTermWriter implements IVirtualTermWriter extends TermBuffer {
private static final defaultSize:Vec2<Int> = {x: 50, y: 50}; private static final defaultSize:Vec2<Int> = {x: 50, y: 50};
private var target:TermWriteable; private var target:ITermWriteable;
private var enabled:Bool = false; private var enabled:Bool = false;
private var onResizeLink:CallbackLink; private var onResizeLink:CallbackLink;
@:allow(kernel.ui) @:allow(kernel.ui)
private function new(?target:TermWriteable) { private function new(?target:ITermWriteable) {
setTarget(target); setTarget(target);
if (enabled) { if (enabled) {
@ -44,7 +44,7 @@ class BufferedVirtualTermWriter implements VirtualTermWriter extends TermBuffer
return enabled; return enabled;
} }
public function setTarget(newTarget:TermWriteable) { public function setTarget(newTarget:ITermWriteable) {
if (newTarget != null) { if (newTarget != null) {
super.setSize(newTarget.getSize()); super.setSize(newTarget.getSize());

View File

@ -9,7 +9,7 @@ using tink.CoreApi;
/** /**
Interface describing a terminal. E.g. the main computer screen or a external screen. Interface describing a terminal. E.g. the main computer screen or a external screen.
**/ **/
interface TermWriteable { interface ITermWriteable {
public var onResize(default, null):Signal<Vec2<Int>>; public var onResize(default, null):Signal<Vec2<Int>>;
public function write(text:String):Void; public function write(text:String):Void;

View File

@ -4,9 +4,9 @@ package kernel.ui;
A VirtualTermWriter is a TermWriteable that can be enabled or disabled. A VirtualTermWriter is a TermWriteable that can be enabled or disabled.
When disabled, it will not write to its target. When enabled, it will. When disabled, it will not write to its target. When enabled, it will.
**/ **/
interface VirtualTermWriter extends TermWriteable { interface IVirtualTermWriter extends ITermWriteable {
public function enable():Void; public function enable():Void;
public function disable():Void; public function disable():Void;
public function isEnabled():Bool; public function isEnabled():Bool;
public function setTarget(newTarget:TermWriteable):Void; public function setTarget(newTarget:ITermWriteable):Void;
} }

View File

@ -13,18 +13,18 @@ using tink.CoreApi;
The render function is only called when needed. The render function is only called when needed.
You can also request a re-render by calling `requestRender`. You can also request a re-render by calling `requestRender`.
**/ **/
class StatelessVirtualTermWriter implements VirtualTermWriter { class StatelessVirtualTermWriter implements IVirtualTermWriter {
public var onResize(default, null):Signal<Vec2<Int>>; public var onResize(default, null):Signal<Vec2<Int>>;
private var onResizeTrigger:SignalTrigger<Vec2<Int>> = Signal.trigger(); private var onResizeTrigger:SignalTrigger<Vec2<Int>> = Signal.trigger();
private var target:TermWriteable; private var target:ITermWriteable;
private var enabled:Bool = false; private var enabled:Bool = false;
private var renderFunc:Null<Void->Void> = null; private var renderFunc:Null<Void->Void> = null;
private var renderRequested:Bool = false; private var renderRequested:Bool = false;
private var onResizeLink:CallbackLink; private var onResizeLink:CallbackLink;
@:allow(kernel.ui) @:allow(kernel.ui)
private function new(?target:TermWriteable) { private function new(?target:ITermWriteable) {
onResize = onResizeTrigger.asSignal(); onResize = onResizeTrigger.asSignal();
setTarget(target); setTarget(target);
} }
@ -70,7 +70,7 @@ class StatelessVirtualTermWriter implements VirtualTermWriter {
enabled = false; enabled = false;
} }
public function setTarget(newTarget:TermWriteable) { public function setTarget(newTarget:ITermWriteable) {
if (newTarget == null) { if (newTarget == null) {
return; return;
} }

View File

@ -3,7 +3,7 @@ package kernel.ui;
import lib.Pos; import lib.Pos;
import lib.Vec.Vec2; import lib.Vec.Vec2;
import lib.Color; import lib.Color;
import kernel.ui.TermWriteable; import kernel.ui.ITermWriteable;
using tink.CoreApi; using tink.CoreApi;
@ -12,7 +12,7 @@ using tink.CoreApi;
even if its not displayed right now. When the GUI gets displayed again even if its not displayed right now. When the GUI gets displayed again
this buffer will be written to the screen. this buffer will be written to the screen.
**/ **/
class TermBuffer implements TermWriteable { class TermBuffer implements ITermWriteable {
/** /**
format [y][x]. First index is the line. Second index the char in the line. format [y][x]. First index is the line. Second index the char in the line.
**/ **/
@ -60,7 +60,7 @@ class TermBuffer implements TermWriteable {
} }
} }
private function copyBufferToTarget(target:TermWriteable) { private function copyBufferToTarget(target:ITermWriteable) {
target.setCursorPos(0, 0); target.setCursorPos(0, 0);
target.setBackgroundColor(Black); target.setBackgroundColor(Black);
target.setTextColor(White); target.setTextColor(White);

View File

@ -1,21 +1,21 @@
package kernel.ui; package kernel.ui;
import lib.ui.rendere.UIEventDelegate; import lib.ui.rendere.IUIEventDelegate;
import lib.Pos; import lib.Pos;
import lib.Color; import lib.Color;
import kernel.ButtonType; import kernel.ButtonType;
import lib.Vec.Vec2; import lib.Vec.Vec2;
import kernel.ui.TermWriteable; import kernel.ui.ITermWriteable;
using tink.CoreApi; using tink.CoreApi;
/** /**
The main object you interact with when writing anything to the screen. The main object you interact with when writing anything to the screen.
**/ **/
class WindowContext implements TermWriteable { class WindowContext implements ITermWriteable {
private final writer:VirtualTermWriter; private final writer:IVirtualTermWriter;
@:allow(kernel.ui.WindowManager) private var eventDelegate:Null<UIEventDelegate>; @:allow(kernel.ui.WindowManager) private var eventDelegate:Null<IUIEventDelegate>;
public var onClick(default, null):Signal<{button:ButtonType, pos:Pos}>; public var onClick(default, null):Signal<{button:ButtonType, pos:Pos}>;
public var onKey(default, null):Signal<{keyCode:Int, isHeld:Bool}>; public var onKey(default, null):Signal<{keyCode:Int, isHeld:Bool}>;
@ -36,7 +36,7 @@ class WindowContext implements TermWriteable {
@:allow(kernel.ui.WindowManager) private final onCharTrigger:SignalTrigger<String>; @:allow(kernel.ui.WindowManager) private final onCharTrigger:SignalTrigger<String>;
@:allow(kernel.ui.WindowManager) @:allow(kernel.ui.WindowManager)
private function new(writer:VirtualTermWriter) { private function new(writer:IVirtualTermWriter) {
this.writer = writer; this.writer = writer;
this.onResize = writer.onResize; this.onResize = writer.onResize;
@ -62,7 +62,7 @@ class WindowContext implements TermWriteable {
public var onResize(default, null):Signal<Vec2<Int>>; public var onResize(default, null):Signal<Vec2<Int>>;
@:allow(kernel.ui) @:allow(kernel.ui)
private inline function setTarget(target:TermWriteable) { private inline function setTarget(target:ITermWriteable) {
writer.setTarget(target); writer.setTarget(target);
} }
@ -145,7 +145,7 @@ class WindowContext implements TermWriteable {
Delegate events to an UIEventDelegate. Delegate events to an UIEventDelegate.
Set to null to stop delegating events. Set to null to stop delegating events.
**/ **/
public inline function delegateEvents(delegate:Null<UIEventDelegate>) { public inline function delegateEvents(delegate:Null<IUIEventDelegate>) {
this.eventDelegate = delegate; this.eventDelegate = delegate;
} }
} }

View File

@ -3,7 +3,7 @@ package kernel.ui;
import kernel.ps.ProcessManager; import kernel.ps.ProcessManager;
import kernel.ps.ProcessManager.PID; import kernel.ps.ProcessManager.PID;
import haxe.ds.ReadOnlyArray; import haxe.ds.ReadOnlyArray;
import kernel.ui.TermWriteable; import kernel.ui.ITermWriteable;
import kernel.peripherals.Peripherals.Peripheral; import kernel.peripherals.Peripherals.Peripheral;
/** /**
@ -143,7 +143,7 @@ class WindowManager {
Move context to output. If output is "main", context will be moved to main screen. Move context to output. If output is "main", context will be moved to main screen.
**/ **/
public static function focusContextToOutput(context:WindowContext, output:String) { public static function focusContextToOutput(context:WindowContext, output:String) {
var target:TermWriteable; var target:ITermWriteable;
if (output == "main") { if (output == "main") {
target = MainTerm.instance; target = MainTerm.instance;
currentMainContext = context; currentMainContext = context;

View File

@ -1,11 +1,11 @@
package lib; package lib;
import kernel.ps.Process; import kernel.ps.IProcess;
import kernel.ps.ProcessHandle; import kernel.ps.ProcessHandle;
using tink.CoreApi; using tink.CoreApi;
abstract class CLIAppBase implements Process { abstract class CLIAppBase implements IProcess {
private var handle:ProcessHandle; private var handle:ProcessHandle;
private final _subcommandsSync:Map<String, (Array<String>) -> Bool> = []; private final _subcommandsSync:Map<String, (Array<String>) -> Bool> = [];

View File

@ -4,10 +4,10 @@ import kernel.log.Log;
import kernel.binstore.BinStore; import kernel.binstore.BinStore;
import kernel.peripherals.Screen; import kernel.peripherals.Screen;
import kernel.peripherals.Peripherals.Peripheral; import kernel.peripherals.Peripherals.Peripheral;
import kernel.ps.Process; import kernel.ps.IProcess;
import kernel.ps.ProcessManager; import kernel.ps.ProcessManager;
import bin.KernelLog; import bin.KernelLog;
import lib.ui.elements.UIElement; import lib.ui.elements.IUIElement;
import lib.ui.elements.TextElement; import lib.ui.elements.TextElement;
import lib.ui.elements.RootElement; import lib.ui.elements.RootElement;
import kernel.KernelEvents; import kernel.KernelEvents;
@ -148,7 +148,7 @@ class HomeContext {
var workspaceIDs:Array<Int> = [for (k => v in workspaces) k]; var workspaceIDs:Array<Int> = [for (k => v in workspaces) k];
workspaceIDs.sort((a, b) -> a - b); workspaceIDs.sort((a, b) -> a - b);
var children:Array<UIElement> = [ var children:Array<IUIElement> = [
for (i in workspaceIDs) for (i in workspaceIDs)
new TextElement('Switch to ${i + 1}', {uiEvents: {onClick: this.handleSelectContext.bind(i)}}) new TextElement('Switch to ${i + 1}', {uiEvents: {onClick: this.handleSelectContext.bind(i)}})
]; ];

View File

@ -2,7 +2,7 @@ package lib.observable;
using tink.CoreApi; using tink.CoreApi;
class DummyObservable<T> implements Observable<T> { class DummyObservable<T> implements IObservable<T> {
private var value:T; private var value:T;
private function new(value:T) { private function new(value:T) {
@ -21,7 +21,7 @@ class DummyObservable<T> implements Observable<T> {
return null; return null;
} }
public static function dummy<T>(value:T):Observable<T> { public static function dummy<T>(value:T):IObservable<T> {
return new DummyObservable<T>(value); return new DummyObservable<T>(value);
} }
} }

View File

@ -2,7 +2,7 @@ package lib.observable;
using tink.CoreApi; using tink.CoreApi;
interface Observable<T> { interface IObservable<T> {
public function set(value:T):Void; public function set(value:T):Void;
public function get():T; public function get():T;
public function subscribe(callback:Callback<T>):CallbackLink; public function subscribe(callback:Callback<T>):CallbackLink;

View File

@ -2,7 +2,7 @@ package lib.observable;
using tink.CoreApi; using tink.CoreApi;
class ObservableValue<T> implements Observable<T> { class ObservableValue<T> implements IObservable<T> {
private var value:T; private var value:T;
private var callbacks:CallbackList<T> = new CallbackList(); private var callbacks:CallbackList<T> = new CallbackList();

View File

@ -2,9 +2,9 @@ package lib.turtle;
import kernel.turtle.TurtleMutex; import kernel.turtle.TurtleMutex;
import kernel.ps.ProcessHandle; import kernel.ps.ProcessHandle;
import kernel.ps.Process; import kernel.ps.IProcess;
abstract class TurtleAppBase implements Process { abstract class TurtleAppBase implements IProcess {
private var handle:ProcessHandle; private var handle:ProcessHandle;
private var _initFunc:Void->Void; private var _initFunc:Void->Void;

View File

@ -1,21 +1,21 @@
package lib.ui.elements; package lib.ui.elements;
import lib.ui.rendere.UIEventDelegate; import lib.ui.rendere.IUIEventDelegate;
/** /**
Find the responsable UIElement to handle the event based on position. Element can be layerd. Find the responsable UIElement to handle the event based on position. Element can be layerd.
Elements added first are lower in the layer. Elements added first are lower in the layer.
**/ **/
abstract EventMap(Array<{bound:Rect, delegate:UIEventDelegate}>) { abstract EventMap(Array<{bound:Rect, delegate:IUIEventDelegate}>) {
inline public function new(?i:Array<{bound:Rect, delegate:UIEventDelegate}>) { inline public function new(?i:Array<{bound:Rect, delegate:IUIEventDelegate}>) {
if (i == null) { if (i == null) {
this = new Array<{bound:Rect, delegate:UIEventDelegate}>(); this = new Array<{bound:Rect, delegate:IUIEventDelegate}>();
} else { } else {
this = i; this = i;
} }
} }
public function findResponseableDelegate(pos:Pos):UIEventDelegate { public function findResponseableDelegate(pos:Pos):IUIEventDelegate {
for (i in 0...this.length) { for (i in 0...this.length) {
var newi = (this.length - 1) - i; var newi = (this.length - 1) - i;
var element = this[newi]; var element = this[newi];
@ -26,7 +26,7 @@ abstract EventMap(Array<{bound:Rect, delegate:UIEventDelegate}>) {
return null; return null;
} }
public inline function addElement(element:UIEventDelegate, bound:Rect) { public inline function addElement(element:IUIEventDelegate, bound:Rect) {
this.push({bound: bound, delegate: element}); this.push({bound: bound, delegate: element});
} }
} }

View File

@ -0,0 +1,7 @@
package lib.ui.elements;
import lib.ui.rendere.IUIEventDelegate;
interface IUIElement extends IUIEventDelegate {
public function render(bounds:Pos):Canvas;
}

View File

@ -1,14 +1,14 @@
package lib.ui.elements; package lib.ui.elements;
class LayerdRootElement implements UIElement { class LayerdRootElement implements IUIElement {
private var children:Array<{element:UIElement, offset:Pos}>; private var children:Array<{element:IUIElement, offset:Pos}>;
private final eventManager:UIEventManager = new UIEventManager(); private final eventManager:UIEventManager = new UIEventManager();
public function new(?children:Array<{element:UIElement, offset:Pos}>) { public function new(?children:Array<{element:IUIElement, offset:Pos}>) {
this.children = children == null ? [] : children; this.children = children == null ? [] : children;
} }
public function setChildren(children:Array<{element:UIElement, offset:Pos}>) { public function setChildren(children:Array<{element:IUIElement, offset:Pos}>) {
this.children = children; this.children = children;
} }

View File

@ -1,11 +1,11 @@
package lib.ui.elements; package lib.ui.elements;
class RootElement implements UIElement { class RootElement implements IUIElement {
private var children:Array<UIElement>; private var children:Array<IUIElement>;
private final eventManager:UIEventManager = new UIEventManager(); private final eventManager:UIEventManager = new UIEventManager();
private var title:String = ""; private var title:String = "";
public function new(?children:Array<UIElement>) { public function new(?children:Array<IUIElement>) {
if (children == null) { if (children == null) {
children = []; children = [];
} else { } else {
@ -17,7 +17,7 @@ class RootElement implements UIElement {
return eventManager.getEventHandlers(); return eventManager.getEventHandlers();
} }
public function setChildren(children:Array<UIElement>) { public function setChildren(children:Array<IUIElement>) {
this.children = children; this.children = children;
} }

View File

@ -1,8 +1,8 @@
package lib.ui.elements; package lib.ui.elements;
import lib.ui.elements.UIElement; import lib.ui.elements.IUIElement;
class TextElement implements UIElement { class TextElement implements IUIElement {
public var text:String; public var text:String;
private final uiEvents:UIEvents; private final uiEvents:UIEvents;

View File

@ -1,7 +0,0 @@
package lib.ui.elements;
import lib.ui.rendere.UIEventDelegate;
interface UIElement extends UIEventDelegate {
public function render(bounds:Pos):Canvas;
}

View File

@ -2,9 +2,9 @@ package lib.ui.elements;
import kernel.log.Log; import kernel.log.Log;
import kernel.ButtonType; import kernel.ButtonType;
import lib.ui.rendere.UIEventDelegate; import lib.ui.rendere.IUIEventDelegate;
class UIEventManager implements UIEventDelegate { class UIEventManager implements IUIEventDelegate {
private var map:EventMap = new EventMap(); private var map:EventMap = new EventMap();
public function new() {} public function new() {}
@ -13,7 +13,7 @@ class UIEventManager implements UIEventDelegate {
this.map = new EventMap(); this.map = new EventMap();
} }
public function addMapElement(element:UIEventDelegate, bound:Rect) { public function addMapElement(element:IUIEventDelegate, bound:Rect) {
this.map.addElement(element, bound); this.map.addElement(element, bound);
} }

View File

@ -1,5 +1,5 @@
package lib.ui.rendere; package lib.ui.rendere;
interface UIEventDelegate { interface IUIEventDelegate {
public function getEventHandlers():UIEvents; public function getEventHandlers():UIEvents;
} }

View File

@ -1,6 +1,6 @@
package lib.ui.rendere; package lib.ui.rendere;
class List implements UIEventDelegate { class List implements IUIEventDelegate {
private final onElementClick:Null<Int->Void>; private final onElementClick:Null<Int->Void>;
public function new(?onElementClick:Int->Void) { public function new(?onElementClick:Int->Void) {