interface name consistency
This commit is contained in:
@@ -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});
|
||||
}
|
||||
}
|
||||
|
||||
7
src/lib/ui/elements/IUIElement.hx
Normal file
7
src/lib/ui/elements/IUIElement.hx
Normal file
@@ -0,0 +1,7 @@
|
||||
package lib.ui.elements;
|
||||
|
||||
import lib.ui.rendere.IUIEventDelegate;
|
||||
|
||||
interface IUIElement extends IUIEventDelegate {
|
||||
public function render(bounds:Pos):Canvas;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package lib.ui.elements;
|
||||
|
||||
class RootElement implements UIElement {
|
||||
private var children:Array<UIElement>;
|
||||
class RootElement implements IUIElement {
|
||||
private var children:Array<IUIElement>;
|
||||
private final eventManager:UIEventManager = new UIEventManager();
|
||||
private var title:String = "";
|
||||
|
||||
public function new(?children:Array<UIElement>) {
|
||||
public function new(?children:Array<IUIElement>) {
|
||||
if (children == null) {
|
||||
children = [];
|
||||
} else {
|
||||
@@ -17,7 +17,7 @@ class RootElement implements UIElement {
|
||||
return eventManager.getEventHandlers();
|
||||
}
|
||||
|
||||
public function setChildren(children:Array<UIElement>) {
|
||||
public function setChildren(children:Array<IUIElement>) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package lib.ui.elements;
|
||||
|
||||
import lib.ui.rendere.UIEventDelegate;
|
||||
|
||||
interface UIElement extends UIEventDelegate {
|
||||
public function render(bounds:Pos):Canvas;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package lib.ui.rendere;
|
||||
|
||||
interface UIEventDelegate {
|
||||
interface IUIEventDelegate {
|
||||
public function getEventHandlers():UIEvents;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package lib.ui.rendere;
|
||||
|
||||
class List implements UIEventDelegate {
|
||||
class List implements IUIEventDelegate {
|
||||
private final onElementClick:Null<Int->Void>;
|
||||
|
||||
public function new(?onElementClick:Int->Void) {
|
||||
|
||||
Reference in New Issue
Block a user