1 module source.d2d.DynamicPanel;
2 
3 import d2d;
4 
5 /**
6  * A component which supports panning, zooming, and rotaion
7  * TODO: implement zoom and rotation
8  */
9 class DynamicPanel : Component {
10 
11     Texture texture; ///The texture to be drawn
12     iRectangle _location; ///The location of the panel
13     iVector panAmount; ///The distance the object is panned
14 
15     /**
16      * A property to return the panel's location
17      */
18     override @property iRectangle location() {
19         return this._location;
20     }
21 
22     /**
23      * Sets the panel's location
24      */
25     @property void location(iRectangle newLocation) {
26         this._location = newLocation;
27     }
28 
29     /**
30      * Constructs a new dynamic panel
31      */
32     this(Display container, iRectangle location, Texture texture) {
33         super(container);
34         this._location = location;
35         this.texture = texture;
36         this.panAmount = new iVector(0, 0);
37     }
38 
39     /**
40      * Changes the location of the pan 
41      */
42     void changePan(iVector change) {
43         this.panAmount += change;
44     }
45 
46     /**
47      * Sets the pan to the given amount
48      */
49     void setPan(iVector amount) {
50         this.panAmount = amount;
51     }
52 
53     override void draw() {
54         this.container.renderer.copy(this.texture, this._location, new iRectangle(this.location.initialPoint.x + 
55                 this.panAmount.x, this.location.initialPoint.y + this.panAmount.y, this.location.extent.x + 
56                 this.panAmount.x, this.location.extent.y + this.panAmount.y));
57     }
58 
59     void handleEvent(SDL_Event event) {}
60 
61 }