Mercurial > projects > doodle
annotate doodle/fig/diagram_elements.d @ 73:6f2525e170f2
Cairo/OpenGL checkpoint
author | "David Bryant <bagnose@gmail.com>" |
---|---|
date | Sun, 15 Aug 2010 01:02:15 +0930 |
parents | 31d10176415d |
children | b759414d2b72 |
rev | line source |
---|---|
54 | 1 module doodle.fig.diagram_elements; |
27 | 2 |
44 | 3 private { |
4 import doodle.tk.geometry; | |
73 | 5 import doodle.tk.cairo; |
44 | 6 } |
7 | |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
8 interface IDiagram { |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
9 void add(DiagramElement element); |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
10 } |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
11 |
54 | 12 abstract class DiagramElement { |
44 | 13 Rectangle bounds() const; |
14 | |
15 void draw(in Rectangle damage, scope Context cr) const; | |
16 | |
17 private { | |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
18 //GraphElement _container; // FIXME use an interface to the container |
54 | 19 } |
20 } | |
21 | |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
22 /* |
66 | 23 abstract class SemanticModelBridge { |
24 }; | |
54 | 25 |
66 | 26 abstract class GraphElement : DiagramElement { |
27 // Link to model via bridge goes here | |
28 private { | |
29 SemanticModelBridge _modelBridge; | |
30 GraphConnector[] _anchorages; | |
31 } | |
44 | 32 } |
27 | 33 |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
34 class GraphConnector { |
44 | 35 } |
27 | 36 |
67 | 37 final class GraphNode : GraphElement { |
44 | 38 } |
27 | 39 |
67 | 40 final class GraphEdge : GraphElement { |
66 | 41 private { |
42 GraphConnector[2] _anchors; | |
44 | 43 } |
66 | 44 } |
45 */ | |
44 | 46 |
54 | 47 abstract class LeafElement : DiagramElement { |
48 } | |
49 | |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
50 /* |
66 | 51 class TextElement : LeafElement { |
52 } | |
53 */ | |
54 | 54 |
55 abstract class GraphicPrimitive : LeafElement { | |
44 | 56 } |
54 | 57 |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
58 /* |
66 | 59 class PolylinePrimitive : GraphicPrimitive { |
60 private { | |
61 Point[] _waypoints; | |
62 } | |
63 } | |
64 */ | |
54 | 65 |
67 | 66 final class RectanglePrimitive : GraphicPrimitive { |
54 | 67 override void draw(in Rectangle damage, scope Context cr) const { |
68 rectangle(cr, bounds); | |
69 } | |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
70 |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
71 override Rectangle bounds() const { return _bounds; } |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
72 |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
73 private { |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
74 Rectangle _bounds; |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
75 } |
54 | 76 } |