diff --git a/src/bin/ID.hx b/src/bin/ID.hx index a0bcefd..635fd26 100644 --- a/src/bin/ID.hx +++ b/src/bin/ID.hx @@ -1,10 +1,10 @@ package bin; import kernel.ps.ProcessHandle; -import kernel.ps.Process; +import kernel.ps.IProcess; @:build(macros.Binstore.includeBin("ID", ["id"])) -class ID implements Process { +class ID implements IProcess { public function new() {} public function run(handle:ProcessHandle) { diff --git a/src/bin/KernelLog.hx b/src/bin/KernelLog.hx index 9c4a5c4..7f66e62 100644 --- a/src/bin/KernelLog.hx +++ b/src/bin/KernelLog.hx @@ -1,7 +1,7 @@ package bin; import kernel.ps.ProcessHandle; -import kernel.ps.Process; +import kernel.ps.IProcess; import lib.Color; import lib.MathI; import kernel.log.Log; @@ -11,7 +11,7 @@ import lib.ui.UIApp; using tink.CoreApi; @:build(macros.Binstore.includeBin("Log", ["log"])) -class KernelLog implements Process { +class KernelLog implements IProcess { private var handle:ProcessHandle; private var ctx:WindowContext; diff --git a/src/bin/LSPS.hx b/src/bin/LSPS.hx index fb62bea..d4c9bfa 100644 --- a/src/bin/LSPS.hx +++ b/src/bin/LSPS.hx @@ -2,10 +2,10 @@ package bin; import kernel.ps.ProcessManager; import kernel.ps.ProcessHandle; -import kernel.ps.Process; +import kernel.ps.IProcess; @:build(macros.Binstore.includeBin("LSPS", ["lsps"])) -class LSPS implements Process { +class LSPS implements IProcess { public function new() {} public function run(handle:ProcessHandle) { diff --git a/src/bin/Terminal.hx b/src/bin/Terminal.hx index 9da60ab..6d00df8 100644 --- a/src/bin/Terminal.hx +++ b/src/bin/Terminal.hx @@ -4,7 +4,7 @@ import kernel.EndOfLoop; import lua.NativeStringTools; import kernel.binstore.BinStore; import kernel.ps.ProcessHandle; -import kernel.ps.Process; +import kernel.ps.IProcess; import kernel.ps.ProcessManager; import lib.Color; import kernel.ui.WindowContext; @@ -12,7 +12,7 @@ import kernel.ui.WindowContext; using tink.CoreApi; @:build(macros.Binstore.includeBin("Terminal", ["terminal"])) -class Terminal implements Process { +class Terminal implements IProcess { private static inline final MAX_BACKLOG:Int = 100; private var handle:ProcessHandle; diff --git a/src/bin/debug/Debug.hx b/src/bin/debug/Debug.hx index e14d559..f61e8b2 100644 --- a/src/bin/debug/Debug.hx +++ b/src/bin/debug/Debug.hx @@ -3,7 +3,7 @@ package bin.debug; import kernel.log.Log; import lib.turtle.InvManager; 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. @@ -12,7 +12,7 @@ import kernel.ps.Process; #if debug @:build(macros.Binstore.includeBin("Debug", ["dbg", "debug"])) #end -class Debug implements Process { +class Debug implements IProcess { public function new() {} public function run(handle:ProcessHandle) { diff --git a/src/bin/debug/DebugService.hx b/src/bin/debug/DebugService.hx index b2bdddf..8399b2a 100644 --- a/src/bin/debug/DebugService.hx +++ b/src/bin/debug/DebugService.hx @@ -3,12 +3,12 @@ package bin.debug; import bin.debug.DebugRPC.DebugRPCImpl; import macros.rpc.RPC; import kernel.ps.ProcessHandle; -import kernel.ps.Process; +import kernel.ps.IProcess; #if debug @:build(macros.Binstore.includeBin("Debug SRV", ["dbg-srv", "debug-srv"])) #end -class DebugService implements Process implements DebugRPC { +class DebugService implements IProcess implements DebugRPC { private var handle:ProcessHandle; public function new() {} diff --git a/src/bin/pathfinder/PFClient.hx b/src/bin/pathfinder/PFClient.hx index 7637764..3f8cf1a 100644 --- a/src/bin/pathfinder/PFClient.hx +++ b/src/bin/pathfinder/PFClient.hx @@ -1,14 +1,14 @@ package bin.pathfinder; import lib.Pos3; -import lib.ui.elements.UIElement; +import lib.ui.elements.IUIElement; import lib.ui.elements.TextElement; import lib.ui.elements.RootElement; import kernel.ui.WindowContext; 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 ctx:WindowContext; @@ -38,7 +38,7 @@ class PFClient implements Process { var acc = kernel.gps.GPS.getAccuracy(); var pos:Pos3 = kernel.gps.GPS.getPosition() ?? {x: 0, y: 0, z: 0}; - var childre:Array = [ + var childre:Array = [ new TextElement('Acc: ${acc}'), new TextElement('Pos: X:${pos.x} Y:${pos.y} Z:${pos.z}'), new TextElement('UPDATE', { diff --git a/src/bin/turtle/Patrol.hx b/src/bin/turtle/Patrol.hx index 7b9cbd0..d1c8205 100644 --- a/src/bin/turtle/Patrol.hx +++ b/src/bin/turtle/Patrol.hx @@ -2,9 +2,9 @@ package bin.turtle; import kernel.turtle.TurtleMutex; import kernel.ps.ProcessHandle; -import kernel.ps.Process; +import kernel.ps.IProcess; -class Patrol implements Process { +class Patrol implements IProcess { private var handle:ProcessHandle; public function new() {} diff --git a/src/kernel/MainTerm.hx b/src/kernel/MainTerm.hx index d9cac2f..51bcef6 100644 --- a/src/kernel/MainTerm.hx +++ b/src/kernel/MainTerm.hx @@ -1,7 +1,7 @@ package kernel; import lib.Pos; -import kernel.ui.TermWriteable; +import kernel.ui.ITermWriteable; import cc.Term; import lib.Vec.Vec2; import lib.Color; @@ -11,7 +11,7 @@ using tink.CoreApi; /** Represents the main computer screen. **/ -class MainTerm implements TermWriteable { +class MainTerm implements ITermWriteable { /** Depends on: KernelEvents, **/ diff --git a/src/kernel/binstore/Bin.hx b/src/kernel/binstore/Bin.hx index 201807d..b7f06b2 100644 --- a/src/kernel/binstore/Bin.hx +++ b/src/kernel/binstore/Bin.hx @@ -1,12 +1,12 @@ package kernel.binstore; -import kernel.ps.Process; +import kernel.ps.IProcess; /** Represents a callable program. **/ typedef Bin = { - c:Void->Process, + c:Void->IProcess, name:String, aliases:Array, } diff --git a/src/kernel/binstore/BinStore.hx b/src/kernel/binstore/BinStore.hx index ad43c6f..3dade76 100644 --- a/src/kernel/binstore/BinStore.hx +++ b/src/kernel/binstore/BinStore.hx @@ -1,6 +1,6 @@ package kernel.binstore; -import kernel.ps.Process; +import kernel.ps.IProcess; import macros.Binstore; class BinStore { @@ -13,7 +13,7 @@ class BinStore { return bins; } - public static function instantiate(alias:String):Null { + public static function instantiate(alias:String):Null { for (bin in bins) { for (a in bin.aliases) { if (a == alias) { diff --git a/src/kernel/peripherals/Screen.hx b/src/kernel/peripherals/Screen.hx index e50840c..7d2f5b5 100644 --- a/src/kernel/peripherals/Screen.hx +++ b/src/kernel/peripherals/Screen.hx @@ -3,13 +3,13 @@ package kernel.peripherals; import cc.Peripheral; import lib.Pos; import cc.Term.TerminalSize; -import kernel.ui.TermWriteable; +import kernel.ui.ITermWriteable; import lib.Vec.Vec2; import lib.Color; using tink.CoreApi; -class Screen implements TermWriteable implements IPeripheral { +class Screen implements ITermWriteable implements IPeripheral { public static inline final TYPE_NAME:String = "monitor"; private final nativ:cc.periphs.Monitor.Monitor; diff --git a/src/kernel/ps/Process.hx b/src/kernel/ps/IProcess.hx similarity index 87% rename from src/kernel/ps/Process.hx rename to src/kernel/ps/IProcess.hx index f61d095..f8ba6bf 100644 --- a/src/kernel/ps/Process.hx +++ b/src/kernel/ps/IProcess.hx @@ -3,6 +3,6 @@ package kernel.ps; /** Defines an independent process that can be run by the kernel. **/ -interface Process { +interface IProcess { public function run(handle:ProcessHandle):Void; } diff --git a/src/kernel/ps/ProcessManager.hx b/src/kernel/ps/ProcessManager.hx index e7bf30d..3872562 100644 --- a/src/kernel/ps/ProcessManager.hx +++ b/src/kernel/ps/ProcessManager.hx @@ -10,7 +10,7 @@ typedef PID = Int; class ProcessManager { private static final processList = new Map(); - public static function run(process:Process, config:HandleConfig):PID { + public static function run(process:IProcess, config:HandleConfig):PID { var pid = createPID(); var handle = new ProcessHandle(config, pid); diff --git a/src/kernel/service/Service.hx b/src/kernel/service/Service.hx index 3e88158..ac8e933 100644 --- a/src/kernel/service/Service.hx +++ b/src/kernel/service/Service.hx @@ -1,6 +1,6 @@ package kernel.service; -import kernel.ps.Process; +import kernel.ps.IProcess; import kernel.ps.ProcessManager; import kernel.binstore.BinStore; @@ -11,7 +11,7 @@ class Service { public final name:String; public final args:Array; public var pid:PID; - public var ps:Process; + public var ps:IProcess; @:allow(kernel.service.ServiceManager) private function new(binName:String, name:String, ?args:Array) { diff --git a/src/kernel/ui/BufferedVirtualTermWriter.hx b/src/kernel/ui/BufferedVirtualTermWriter.hx index 84bde3e..bc48127 100644 --- a/src/kernel/ui/BufferedVirtualTermWriter.hx +++ b/src/kernel/ui/BufferedVirtualTermWriter.hx @@ -3,7 +3,7 @@ package kernel.ui; import lib.Pos; import lib.Vec.Vec2; import lib.Color; -import kernel.ui.TermWriteable; +import kernel.ui.ITermWriteable; using tink.CoreApi; @@ -11,15 +11,15 @@ using tink.CoreApi; A term writer that can switch beetween its internal buffer and another termwriter. 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 = {x: 50, y: 50}; - private var target:TermWriteable; + private var target:ITermWriteable; private var enabled:Bool = false; private var onResizeLink:CallbackLink; @:allow(kernel.ui) - private function new(?target:TermWriteable) { + private function new(?target:ITermWriteable) { setTarget(target); if (enabled) { @@ -44,7 +44,7 @@ class BufferedVirtualTermWriter implements VirtualTermWriter extends TermBuffer return enabled; } - public function setTarget(newTarget:TermWriteable) { + public function setTarget(newTarget:ITermWriteable) { if (newTarget != null) { super.setSize(newTarget.getSize()); diff --git a/src/kernel/ui/TermWriteable.hx b/src/kernel/ui/ITermWriteable.hx similarity index 97% rename from src/kernel/ui/TermWriteable.hx rename to src/kernel/ui/ITermWriteable.hx index 4c79f5f..e307097 100644 --- a/src/kernel/ui/TermWriteable.hx +++ b/src/kernel/ui/ITermWriteable.hx @@ -9,7 +9,7 @@ using tink.CoreApi; /** Interface describing a terminal. E.g. the main computer screen or a external screen. **/ -interface TermWriteable { +interface ITermWriteable { public var onResize(default, null):Signal>; public function write(text:String):Void; diff --git a/src/kernel/ui/VirtualTermWriter.hx b/src/kernel/ui/IVirtualTermWriter.hx similarity index 70% rename from src/kernel/ui/VirtualTermWriter.hx rename to src/kernel/ui/IVirtualTermWriter.hx index ed4387f..cfd3bdb 100644 --- a/src/kernel/ui/VirtualTermWriter.hx +++ b/src/kernel/ui/IVirtualTermWriter.hx @@ -4,9 +4,9 @@ package kernel.ui; A VirtualTermWriter is a TermWriteable that can be enabled or disabled. 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 disable():Void; public function isEnabled():Bool; - public function setTarget(newTarget:TermWriteable):Void; + public function setTarget(newTarget:ITermWriteable):Void; } diff --git a/src/kernel/ui/StatelessVirtualTermWriter.hx b/src/kernel/ui/StatelessVirtualTermWriter.hx index daf0c88..adafac7 100644 --- a/src/kernel/ui/StatelessVirtualTermWriter.hx +++ b/src/kernel/ui/StatelessVirtualTermWriter.hx @@ -13,18 +13,18 @@ using tink.CoreApi; The render function is only called when needed. You can also request a re-render by calling `requestRender`. **/ -class StatelessVirtualTermWriter implements VirtualTermWriter { +class StatelessVirtualTermWriter implements IVirtualTermWriter { public var onResize(default, null):Signal>; private var onResizeTrigger:SignalTrigger> = Signal.trigger(); - private var target:TermWriteable; + private var target:ITermWriteable; private var enabled:Bool = false; private var renderFunc:NullVoid> = null; private var renderRequested:Bool = false; private var onResizeLink:CallbackLink; @:allow(kernel.ui) - private function new(?target:TermWriteable) { + private function new(?target:ITermWriteable) { onResize = onResizeTrigger.asSignal(); setTarget(target); } @@ -70,7 +70,7 @@ class StatelessVirtualTermWriter implements VirtualTermWriter { enabled = false; } - public function setTarget(newTarget:TermWriteable) { + public function setTarget(newTarget:ITermWriteable) { if (newTarget == null) { return; } diff --git a/src/kernel/ui/TermBuffer.hx b/src/kernel/ui/TermBuffer.hx index d9e4775..8327c49 100644 --- a/src/kernel/ui/TermBuffer.hx +++ b/src/kernel/ui/TermBuffer.hx @@ -3,7 +3,7 @@ package kernel.ui; import lib.Pos; import lib.Vec.Vec2; import lib.Color; -import kernel.ui.TermWriteable; +import kernel.ui.ITermWriteable; using tink.CoreApi; @@ -12,7 +12,7 @@ using tink.CoreApi; even if its not displayed right now. When the GUI gets displayed again 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. **/ @@ -60,7 +60,7 @@ class TermBuffer implements TermWriteable { } } - private function copyBufferToTarget(target:TermWriteable) { + private function copyBufferToTarget(target:ITermWriteable) { target.setCursorPos(0, 0); target.setBackgroundColor(Black); target.setTextColor(White); diff --git a/src/kernel/ui/WindowContext.hx b/src/kernel/ui/WindowContext.hx index 0ebb67c..237f08d 100644 --- a/src/kernel/ui/WindowContext.hx +++ b/src/kernel/ui/WindowContext.hx @@ -1,21 +1,21 @@ package kernel.ui; -import lib.ui.rendere.UIEventDelegate; +import lib.ui.rendere.IUIEventDelegate; import lib.Pos; import lib.Color; import kernel.ButtonType; import lib.Vec.Vec2; -import kernel.ui.TermWriteable; +import kernel.ui.ITermWriteable; using tink.CoreApi; /** The main object you interact with when writing anything to the screen. **/ -class WindowContext implements TermWriteable { - private final writer:VirtualTermWriter; +class WindowContext implements ITermWriteable { + private final writer:IVirtualTermWriter; - @:allow(kernel.ui.WindowManager) private var eventDelegate:Null; + @:allow(kernel.ui.WindowManager) private var eventDelegate:Null; public var onClick(default, null):Signal<{button:ButtonType, pos:Pos}>; 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; @:allow(kernel.ui.WindowManager) - private function new(writer:VirtualTermWriter) { + private function new(writer:IVirtualTermWriter) { this.writer = writer; this.onResize = writer.onResize; @@ -62,7 +62,7 @@ class WindowContext implements TermWriteable { public var onResize(default, null):Signal>; @:allow(kernel.ui) - private inline function setTarget(target:TermWriteable) { + private inline function setTarget(target:ITermWriteable) { writer.setTarget(target); } @@ -145,7 +145,7 @@ class WindowContext implements TermWriteable { Delegate events to an UIEventDelegate. Set to null to stop delegating events. **/ - public inline function delegateEvents(delegate:Null) { + public inline function delegateEvents(delegate:Null) { this.eventDelegate = delegate; } } diff --git a/src/kernel/ui/WindowManager.hx b/src/kernel/ui/WindowManager.hx index c6702c9..6f7de25 100644 --- a/src/kernel/ui/WindowManager.hx +++ b/src/kernel/ui/WindowManager.hx @@ -3,7 +3,7 @@ package kernel.ui; import kernel.ps.ProcessManager; import kernel.ps.ProcessManager.PID; import haxe.ds.ReadOnlyArray; -import kernel.ui.TermWriteable; +import kernel.ui.ITermWriteable; 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. **/ public static function focusContextToOutput(context:WindowContext, output:String) { - var target:TermWriteable; + var target:ITermWriteable; if (output == "main") { target = MainTerm.instance; currentMainContext = context; diff --git a/src/lib/CLIAppBase.hx b/src/lib/CLIAppBase.hx index 500cf4f..f5afd32 100644 --- a/src/lib/CLIAppBase.hx +++ b/src/lib/CLIAppBase.hx @@ -1,11 +1,11 @@ package lib; -import kernel.ps.Process; +import kernel.ps.IProcess; import kernel.ps.ProcessHandle; using tink.CoreApi; -abstract class CLIAppBase implements Process { +abstract class CLIAppBase implements IProcess { private var handle:ProcessHandle; private final _subcommandsSync:Map) -> Bool> = []; diff --git a/src/lib/HomeContext.hx b/src/lib/HomeContext.hx index fec460f..70ef26a 100644 --- a/src/lib/HomeContext.hx +++ b/src/lib/HomeContext.hx @@ -4,10 +4,10 @@ import kernel.log.Log; import kernel.binstore.BinStore; import kernel.peripherals.Screen; import kernel.peripherals.Peripherals.Peripheral; -import kernel.ps.Process; +import kernel.ps.IProcess; import kernel.ps.ProcessManager; import bin.KernelLog; -import lib.ui.elements.UIElement; +import lib.ui.elements.IUIElement; import lib.ui.elements.TextElement; import lib.ui.elements.RootElement; import kernel.KernelEvents; @@ -148,7 +148,7 @@ class HomeContext { var workspaceIDs:Array = [for (k => v in workspaces) k]; workspaceIDs.sort((a, b) -> a - b); - var children:Array = [ + var children:Array = [ for (i in workspaceIDs) new TextElement('Switch to ${i + 1}', {uiEvents: {onClick: this.handleSelectContext.bind(i)}}) ]; diff --git a/src/lib/observable/DummyObservable.hx b/src/lib/observable/DummyObservable.hx index 4c6db51..f2d4edc 100644 --- a/src/lib/observable/DummyObservable.hx +++ b/src/lib/observable/DummyObservable.hx @@ -2,7 +2,7 @@ package lib.observable; using tink.CoreApi; -class DummyObservable implements Observable { +class DummyObservable implements IObservable { private var value:T; private function new(value:T) { @@ -21,7 +21,7 @@ class DummyObservable implements Observable { return null; } - public static function dummy(value:T):Observable { + public static function dummy(value:T):IObservable { return new DummyObservable(value); } } diff --git a/src/lib/observable/Observable.hx b/src/lib/observable/IObservable.hx similarity index 86% rename from src/lib/observable/Observable.hx rename to src/lib/observable/IObservable.hx index ff01dce..475cc15 100644 --- a/src/lib/observable/Observable.hx +++ b/src/lib/observable/IObservable.hx @@ -2,7 +2,7 @@ package lib.observable; using tink.CoreApi; -interface Observable { +interface IObservable { public function set(value:T):Void; public function get():T; public function subscribe(callback:Callback):CallbackLink; diff --git a/src/lib/observable/ObservableValue.hx b/src/lib/observable/ObservableValue.hx index 32bcd24..2932a39 100644 --- a/src/lib/observable/ObservableValue.hx +++ b/src/lib/observable/ObservableValue.hx @@ -2,7 +2,7 @@ package lib.observable; using tink.CoreApi; -class ObservableValue implements Observable { +class ObservableValue implements IObservable { private var value:T; private var callbacks:CallbackList = new CallbackList(); diff --git a/src/lib/turtle/TurtleAppBase.hx b/src/lib/turtle/TurtleAppBase.hx index 3a3a5c7..5a8bbb5 100644 --- a/src/lib/turtle/TurtleAppBase.hx +++ b/src/lib/turtle/TurtleAppBase.hx @@ -2,9 +2,9 @@ package lib.turtle; import kernel.turtle.TurtleMutex; 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 _initFunc:Void->Void; diff --git a/src/lib/ui/elements/EventMap.hx b/src/lib/ui/elements/EventMap.hx index d0e2d4f..005b301 100644 --- a/src/lib/ui/elements/EventMap.hx +++ b/src/lib/ui/elements/EventMap.hx @@ -1,21 +1,21 @@ 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. Elements added first are lower in the layer. **/ -abstract EventMap(Array<{bound:Rect, delegate:UIEventDelegate}>) { - inline public function new(?i:Array<{bound:Rect, delegate:UIEventDelegate}>) { +abstract EventMap(Array<{bound:Rect, delegate:IUIEventDelegate}>) { + inline public function new(?i:Array<{bound:Rect, delegate:IUIEventDelegate}>) { if (i == null) { - this = new Array<{bound:Rect, delegate:UIEventDelegate}>(); + this = new Array<{bound:Rect, delegate:IUIEventDelegate}>(); } else { this = i; } } - public function findResponseableDelegate(pos:Pos):UIEventDelegate { + public function findResponseableDelegate(pos:Pos):IUIEventDelegate { for (i in 0...this.length) { var newi = (this.length - 1) - i; var element = this[newi]; @@ -26,7 +26,7 @@ abstract EventMap(Array<{bound:Rect, delegate:UIEventDelegate}>) { return null; } - public inline function addElement(element:UIEventDelegate, bound:Rect) { + public inline function addElement(element:IUIEventDelegate, bound:Rect) { this.push({bound: bound, delegate: element}); } } diff --git a/src/lib/ui/elements/IUIElement.hx b/src/lib/ui/elements/IUIElement.hx new file mode 100644 index 0000000..deda016 --- /dev/null +++ b/src/lib/ui/elements/IUIElement.hx @@ -0,0 +1,7 @@ +package lib.ui.elements; + +import lib.ui.rendere.IUIEventDelegate; + +interface IUIElement extends IUIEventDelegate { + public function render(bounds:Pos):Canvas; +} diff --git a/src/lib/ui/elements/LayerdRootElement.hx b/src/lib/ui/elements/LayerdRootElement.hx index 0cb8db5..1143f3a 100644 --- a/src/lib/ui/elements/LayerdRootElement.hx +++ b/src/lib/ui/elements/LayerdRootElement.hx @@ -1,14 +1,14 @@ package lib.ui.elements; -class LayerdRootElement implements UIElement { - private var children:Array<{element:UIElement, offset:Pos}>; +class LayerdRootElement implements IUIElement { + private var children:Array<{element:IUIElement, offset:Pos}>; 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; } - public function setChildren(children:Array<{element:UIElement, offset:Pos}>) { + public function setChildren(children:Array<{element:IUIElement, offset:Pos}>) { this.children = children; } diff --git a/src/lib/ui/elements/RootElement.hx b/src/lib/ui/elements/RootElement.hx index 3ad9048..8e3f255 100644 --- a/src/lib/ui/elements/RootElement.hx +++ b/src/lib/ui/elements/RootElement.hx @@ -1,11 +1,11 @@ package lib.ui.elements; -class RootElement implements UIElement { - private var children:Array; +class RootElement implements IUIElement { + private var children:Array; private final eventManager:UIEventManager = new UIEventManager(); private var title:String = ""; - public function new(?children:Array) { + public function new(?children:Array) { if (children == null) { children = []; } else { @@ -17,7 +17,7 @@ class RootElement implements UIElement { return eventManager.getEventHandlers(); } - public function setChildren(children:Array) { + public function setChildren(children:Array) { this.children = children; } diff --git a/src/lib/ui/elements/TextElement.hx b/src/lib/ui/elements/TextElement.hx index 8aafdf0..dfa78c4 100644 --- a/src/lib/ui/elements/TextElement.hx +++ b/src/lib/ui/elements/TextElement.hx @@ -1,8 +1,8 @@ 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; private final uiEvents:UIEvents; diff --git a/src/lib/ui/elements/UIElement.hx b/src/lib/ui/elements/UIElement.hx deleted file mode 100644 index 5b1ffe3..0000000 --- a/src/lib/ui/elements/UIElement.hx +++ /dev/null @@ -1,7 +0,0 @@ -package lib.ui.elements; - -import lib.ui.rendere.UIEventDelegate; - -interface UIElement extends UIEventDelegate { - public function render(bounds:Pos):Canvas; -} diff --git a/src/lib/ui/elements/UIEventManager.hx b/src/lib/ui/elements/UIEventManager.hx index 69747bc..44745a4 100644 --- a/src/lib/ui/elements/UIEventManager.hx +++ b/src/lib/ui/elements/UIEventManager.hx @@ -2,9 +2,9 @@ package lib.ui.elements; import kernel.log.Log; 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(); public function new() {} @@ -13,7 +13,7 @@ class UIEventManager implements UIEventDelegate { this.map = new EventMap(); } - public function addMapElement(element:UIEventDelegate, bound:Rect) { + public function addMapElement(element:IUIEventDelegate, bound:Rect) { this.map.addElement(element, bound); } diff --git a/src/lib/ui/rendere/UIEventDelegate.hx b/src/lib/ui/rendere/IUIEventDelegate.hx similarity index 71% rename from src/lib/ui/rendere/UIEventDelegate.hx rename to src/lib/ui/rendere/IUIEventDelegate.hx index d286b1f..725e614 100644 --- a/src/lib/ui/rendere/UIEventDelegate.hx +++ b/src/lib/ui/rendere/IUIEventDelegate.hx @@ -1,5 +1,5 @@ package lib.ui.rendere; -interface UIEventDelegate { +interface IUIEventDelegate { public function getEventHandlers():UIEvents; } diff --git a/src/lib/ui/rendere/List.hx b/src/lib/ui/rendere/List.hx index df2b960..d78c452 100644 --- a/src/lib/ui/rendere/List.hx +++ b/src/lib/ui/rendere/List.hx @@ -1,6 +1,6 @@ package lib.ui.rendere; -class List implements UIEventDelegate { +class List implements IUIEventDelegate { private final onElementClick:NullVoid>; public function new(?onElementClick:Int->Void) {