1 /** 2 * Copyright: Copyright (C) 2018 Gabriel Gheorghe, All Rights Reserved 3 * Authors: $(Gabriel Gheorghe) 4 * License: $(LINK2 https://www.gnu.org/licenses/gpl-3.0.txt, GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007) 5 * Source 6 * Documentation: 7 * Coverage: 8 */ 9 module liberty.core.scenegraph.canvas; 10 version (none): 11 import liberty.core.scenegraph.services : ListenerServices; 12 import liberty.core.scenegraph.node : NodeObject; 13 import liberty.core.scenegraph.scene : Scene; 14 import liberty.math.vector : Vector3F, Vector4F; 15 import liberty.core.geometry.shapes; 16 import liberty.core.config : CoreEngineException; 17 /// 18 abstract class Canvas : Widget { // TODO: Not abstract, not final. 19 protected { 20 bool _canListen = false; 21 Vector4F _fillColor; 22 Shape _shape; 23 // TODO: CollisionShape _collisionShape; 24 } 25 /// 26 this(string id, Node parent) { 27 super(id, parent); 28 _shape = scene.spawn!RectangleShape("shape"); // TODO. Algorithm for a new id. Maybe count instances with static? 29 } 30 /// 31 this(string id, ShapeForm shape_form, Node parent) { 32 super(id, parent); 33 switch (shape_form) with (ShapeForm) { 34 case Rectangle: 35 _shape = scene.spawn!RectangleShape("shape"); // TODO. Algorithm for a new id. 36 break; 37 //case Circe: 38 //_shape = scene.spawn!CircleShape("shape"); // TODO. Algorithm for a new id. 39 //break; 40 default: 41 throw new CoreEngineException("Unsupported ShapeForm for Canvas element!"); 42 } 43 } 44 /// 45 bool canListen() pure nothrow const { 46 return _canListen; 47 } 48 /// 49 void __canListen(bool __) { // TODO: remove. 50 _canListen = __; 51 } 52 /// 53 void stopListening() {} 54 /// 55 //override void render() { 56 // _shape.draw(); 57 //} 58 /// 59 Shape shape() { 60 return _shape; 61 } 62 }