File README.md changed (mode: 100644) (index 3d9bf4e..f54b858) |
... |
... |
use 'dub' to compile and run the code. |
6 |
6 |
|
|
7 |
7 |
# Entities |
# Entities |
8 |
8 |
|
|
9 |
|
`Shapes` are stored in a `Command`. Each `Command` is saved in `History`. |
|
10 |
|
|
|
11 |
|
`Groups` are stored in `Global.groups`. |
|
|
9 |
|
`Entities` are stored in a `Command`. Each `Command` is saved in `History`. |
12 |
10 |
|
|
13 |
11 |
The rendering of `Entities` is done through `History`. First are |
The rendering of `Entities` is done through `History`. First are |
14 |
|
all `Commands` rendered with a `foreach`-loop. Then all `Groups` |
|
15 |
|
in `Global.groups` are rendered with a `foreach`-loop. |
|
|
12 |
|
all `Commands` rendered with a `foreach`-loop. |
16 |
13 |
|
|
17 |
|
If a `Shape` is added to a `Group`, The `Shape` is unable to save itself |
|
|
14 |
|
If an `Entity` is added to a `Group`, The `Entity` is unable to save itself |
18 |
15 |
anymore. From that point, `Group` has the task to save itself, including |
anymore. From that point, `Group` has the task to save itself, including |
19 |
|
all it's members. The ability to save is determined by the `saveable` |
|
20 |
|
variable. |
|
|
16 |
|
all it's members. |
21 |
17 |
|
|
22 |
18 |
# Roadmap |
# Roadmap |
23 |
19 |
|
|
24 |
|
- Delete group? Hoe? |
|
25 |
|
|
|
26 |
20 |
- Grafische indicatie van een groep. De groepen worden wel goed weergegeven, |
- Grafische indicatie van een groep. De groepen worden wel goed weergegeven, |
27 |
21 |
maar subgroepen niet. |
maar subgroepen niet. |
28 |
22 |
|
|
29 |
|
- Een `SaveVisitor` voor `Ornament` kan controleren `if(o.ornament !is null)`. |
|
30 |
|
Zo ja, move `o.ornament` een beetje? |
|
31 |
|
|
|
32 |
23 |
- Kan een `Global.Brush.clone` niet gewoon een Entity zijn? Dan hoef je |
- Kan een `Global.Brush.clone` niet gewoon een Entity zijn? Dan hoef je |
33 |
24 |
denk ik niet `Global.Brush.cloneGroup` te gebruiken. |
denk ik niet `Global.Brush.cloneGroup` te gebruiken. |
|
25 |
|
|
|
26 |
|
- `OrnamentDialog` voegt `Ornaments` aan de `Entity` toe. Dat moet nog aan |
|
27 |
|
`EntityOrnament` gekoppeld worden (zie `clickCallback()`). |
File source/entities/ornament.d changed (mode: 100644) (index 29ee340..8241ef9) |
... |
... |
class Ornament : Entity { |
8 |
8 |
Context context; |
Context context; |
9 |
9 |
string alignment; |
string alignment; |
10 |
10 |
string value; |
string value; |
|
11 |
|
double offset; |
11 |
12 |
|
|
12 |
13 |
this(Entity entity, string alignment, string value, Context context) { |
this(Entity entity, string alignment, string value, Context context) { |
13 |
14 |
this.entity = entity; |
this.entity = entity; |
14 |
15 |
this.alignment = alignment; |
this.alignment = alignment; |
15 |
16 |
this.value = value; |
this.value = value; |
16 |
17 |
this.context = context; |
this.context = context; |
|
18 |
|
this.offset = 0; |
17 |
19 |
|
|
18 |
20 |
entity.ornaments.length++; |
entity.ornaments.length++; |
19 |
21 |
entity.ornaments[entity.ornaments.length - 1] = this; |
entity.ornaments[entity.ornaments.length - 1] = this; |
20 |
22 |
|
|
|
23 |
|
foreach(o; entity.ornaments) { |
|
24 |
|
if(o.alignment == alignment) { |
|
25 |
|
if(alignment == "Top") |
|
26 |
|
offset -= 30; |
|
27 |
|
else |
|
28 |
|
offset += 30; |
|
29 |
|
} |
|
30 |
|
} |
|
31 |
|
|
21 |
32 |
context.setSourceRgba(0.5,0.5,0.5,1); |
context.setSourceRgba(0.5,0.5,0.5,1); |
22 |
33 |
context.selectFontFace("Purisa", CairoFontSlant.NORMAL, CairoFontWeight.BOLD); |
context.selectFontFace("Purisa", CairoFontSlant.NORMAL, CairoFontWeight.BOLD); |
23 |
34 |
context.setFontSize(13); |
context.setFontSize(13); |
|
... |
... |
class Ornament : Entity { |
79 |
90 |
|
|
80 |
91 |
final switch(alignment) { |
final switch(alignment) { |
81 |
92 |
case "Top": |
case "Top": |
82 |
|
bounds[0][1] -= size / 4; |
|
|
93 |
|
bounds[0][1] -= size / 4 - 30; |
83 |
94 |
break; |
break; |
84 |
95 |
case "Bottom": |
case "Bottom": |
85 |
|
bounds[0][1] = 30 + bounds[1][1]; |
|
|
96 |
|
bounds[0][1] = bounds[1][1]; |
86 |
97 |
break; |
break; |
87 |
98 |
case "Left": |
case "Left": |
88 |
99 |
bounds[0][0] -= 30 + size / 2; |
bounds[0][0] -= 30 + size / 2; |
89 |
|
bounds[0][1] += size / 2; |
|
|
100 |
|
bounds[0][1] += size / 2 - 30; |
90 |
101 |
break; |
break; |
91 |
102 |
case "Right": |
case "Right": |
92 |
103 |
bounds[0][0] = 30 + bounds[1][0]; |
bounds[0][0] = 30 + bounds[1][0]; |
93 |
|
bounds[0][1] += size / 2; |
|
|
104 |
|
bounds[0][1] += size / 2 - 30; |
94 |
105 |
break; |
break; |
95 |
106 |
} |
} |
96 |
107 |
|
|
97 |
|
return [bounds[0][0], bounds[0][1]]; |
|
|
108 |
|
return [bounds[0][0], bounds[0][1] + offset]; |
98 |
109 |
} |
} |
99 |
110 |
} |
} |
File source/file.d changed (mode: 100644) (index 30fdda9..3116029) |
... |
... |
public class Savefile { |
116 |
116 |
entities[entities.length - 1] = eo; |
entities[entities.length - 1] = eo; |
117 |
117 |
|
|
118 |
118 |
foreach(wrds; o_words) |
foreach(wrds; o_words) |
119 |
|
eo.setOrnament(new Ornament(eo, wrds[0], wrds[1], Global.canvas.newContext)); |
|
|
119 |
|
new Ornament(eo, wrds[0], wrds[1], Global.canvas.newContext); |
120 |
120 |
|
|
121 |
121 |
o_words.length = 0; |
o_words.length = 0; |
122 |
122 |
|
|
|
... |
... |
public class Savefile { |
129 |
129 |
entities[entities.length - 1] = eo; |
entities[entities.length - 1] = eo; |
130 |
130 |
|
|
131 |
131 |
foreach(wrds; o_words) |
foreach(wrds; o_words) |
132 |
|
eo.setOrnament(new Ornament(eo, wrds[0], wrds[1], Global.canvas.newContext)); |
|
|
132 |
|
new Ornament(eo, wrds[0], wrds[1], Global.canvas.newContext); |
133 |
133 |
|
|
134 |
134 |
o_words.length = 0; |
o_words.length = 0; |
135 |
135 |
|
|
File source/frontend/ornamentDialog.d changed (mode: 100644) (index fcebbd3..ff3f552) |
... |
... |
class OrnamentDialog : Dialog { |
81 |
81 |
this.close(); |
this.close(); |
82 |
82 |
|
|
83 |
83 |
EntityOrnament eo = new EntityOrnament(e); |
EntityOrnament eo = new EntityOrnament(e); |
84 |
|
write("O: ");write(&e);write(", ");writeln(e.ornaments.length); |
|
|
84 |
|
write("O: ");write(&eo);write(", ");writeln(eo.ornaments.length); |
85 |
85 |
|
|
86 |
86 |
if(input != "") { |
if(input != "") { |
87 |
|
Ornament o = new Ornament(e, position, input, Global.canvas.newContext); |
|
|
87 |
|
Ornament o = new Ornament(e, position, input, Global.canvas.newContext); // Should become eo instead of e. |
|
88 |
|
write("O: ");write(&eo);write(", ");writeln(eo.ornaments.length); |
88 |
89 |
Global.History.addCommand(new CreateCmd(o)); |
Global.History.addCommand(new CreateCmd(o)); |
89 |
|
eo.setOrnament(o); |
|
90 |
90 |
Global.canvas.repaint(); |
Global.canvas.repaint(); |
91 |
91 |
this.close(); |
this.close(); |
92 |
92 |
} |
} |
File source/vistors/moveVisitor.d changed (mode: 100644) (index c0ebc45..39d0c35) |
... |
... |
public class MoveVisitor : Visitor { |
13 |
13 |
this.translation = translation; |
this.translation = translation; |
14 |
14 |
} |
} |
15 |
15 |
|
|
|
16 |
|
public override void visit(EntityOrnament eo) { |
|
17 |
|
eo.accept(new MoveVisitor(translation)); |
|
18 |
|
} |
|
19 |
|
|
16 |
20 |
public override void visit(Shape s) { |
public override void visit(Shape s) { |
17 |
21 |
s.bounds = [ |
s.bounds = [ |
18 |
22 |
this.translation[0] + s.position[0], |
this.translation[0] + s.position[0], |
File source/vistors/saveVisitor.d changed (mode: 100644) (index 1df58e0..05fca56) |
... |
... |
module dp.visitor.save; |
3 |
3 |
import dp.visitor.visitor; |
import dp.visitor.visitor; |
4 |
4 |
import dp.file; |
import dp.file; |
5 |
5 |
|
|
|
6 |
|
import std.stdio; // Debug |
|
7 |
|
|
6 |
8 |
public class SaveVisitor : Visitor { |
public class SaveVisitor : Visitor { |
7 |
9 |
Savefile f; |
Savefile f; |
8 |
10 |
|
|
|
... |
... |
public class SaveVisitor : Visitor { |
10 |
12 |
f = file; |
f = file; |
11 |
13 |
} |
} |
12 |
14 |
|
|
|
15 |
|
public override void visit(EntityOrnament eo) { |
|
16 |
|
eo.accept(new SaveVisitor(f)); |
|
17 |
|
|
|
18 |
|
foreach(ornament; eo.ornaments) |
|
19 |
|
ornament.accept(new SaveVisitor(f)); |
|
20 |
|
} |
|
21 |
|
|
13 |
22 |
public override void visit(Shape s) { |
public override void visit(Shape s) { |
|
23 |
|
writeln("S: shape"); |
14 |
24 |
foreach(ornament; s.ornaments) |
foreach(ornament; s.ornaments) |
15 |
25 |
ornament.accept(new SaveVisitor(f)); |
ornament.accept(new SaveVisitor(f)); |
16 |
26 |
|
|
|
... |
... |
public class SaveVisitor : Visitor { |
18 |
28 |
} |
} |
19 |
29 |
|
|
20 |
30 |
public override void visit(Group g) { |
public override void visit(Group g) { |
|
31 |
|
writeln("S: group"); |
21 |
32 |
foreach(ornament; g.ornaments) |
foreach(ornament; g.ornaments) |
22 |
33 |
ornament.accept(new SaveVisitor(f)); |
ornament.accept(new SaveVisitor(f)); |
23 |
34 |
|
|
|
... |
... |
public class SaveVisitor : Visitor { |
32 |
43 |
} |
} |
33 |
44 |
|
|
34 |
45 |
public override void visit(Ornament o) { |
public override void visit(Ornament o) { |
|
46 |
|
writeln("S: ornament"); |
35 |
47 |
f.toFile(o); |
f.toFile(o); |
36 |
48 |
} |
} |
37 |
49 |
} |
} |
File source/vistors/visitor.d changed (mode: 100644) (index 36f51d4..8ffa573) |
... |
... |
module dp.visitor.visitor; |
3 |
3 |
public import dp.ent.shape; |
public import dp.ent.shape; |
4 |
4 |
public import dp.ent.group; |
public import dp.ent.group; |
5 |
5 |
public import dp.ent.ornament; |
public import dp.ent.ornament; |
|
6 |
|
public import dp.dec.entornament; |
6 |
7 |
|
|
7 |
8 |
abstract class Visitor { |
abstract class Visitor { |
|
9 |
|
public abstract void visit(EntityOrnament eo); |
8 |
10 |
public abstract void visit(Shape s); |
public abstract void visit(Shape s); |
9 |
11 |
public abstract void visit(Group g); |
public abstract void visit(Group g); |
10 |
12 |
public abstract void visit(Ornament o); |
public abstract void visit(Ornament o); |