kapstok / NHL-DePa2 (public) (License: Unspecified) (since 2018-11-09) (hash sha1)
Design Patterns school project; a GUI using multiple Design Patterns.
List of commits:
Subject Hash Author Date (UTC)
Allow multiple Ornaments to be aligned at the same Entity. b01673996a5b4a589b8e6c6d9dee0dc9b3c1cc60 Jan Allersma 2018-11-09 21:46:01
Allow multiple Ornaments to be added to an Entity. db1ce677fbcbba757c18ea645b76bb1688594d04 Jan Allersma 2018-11-09 17:23:02
Change Entity.group as variable into a property. bbda7fe1dd4528b9396bff03fcb669e4c6ff2ad5 Jan Allersma 2018-11-08 16:37:41
Load nested Entities with Ornaments properly. 8da015e6fd4f43cc873a5ae330caefab73b8f5fc Jan Allersma 2018-11-08 13:56:36
Save nested Entities with Ornaments properly. 645cf4ae287fd2511b4c1404d0d9559372e5e10b Jan Allersma 2018-11-08 12:04:40
Fix bug: activate group after movement with cloning. 482c53ecab43cdee03590949669c22227d104475 Jan Allersma 2018-11-08 10:35:27
Include Groups in Commands, removing dp.groups.groups. 699f767ac316edd481630a943f7a1884c5bc16f2 Jan Allersma 2018-11-07 11:27:15
Fix ability to nest in Groups. fd546a42ef54bdf5d2966eb7facbbf21a6b72e1b Jan Allersma 2018-11-06 17:49:11
Fix file I/O for single entities. 093b7d31a215067212927b1d92bdbbee306ea345 Jan Allersma 2018-11-06 16:49:55
Fix file I/O issue. 25c0b40db223c806eb3ea8bd28238dedc38ca8b5 Jan Allersma 2018-11-02 16:22:59
Cleanup commenting. 445aea4a5115c9110a097bfc7ac9f7d5ad48a9e7 Jan Allersma 2018-11-02 14:33:08
Show Ornaments on Canvas. d8456f15d69550c4cb0aa615cccb96b45a77f6a6 Jan Allersma 2018-11-02 14:08:47
Support Entities for Create & Destruct commands. cc900579eedf9c6288ce1c1883122856794e05a0 Jan Allersma 2018-11-02 13:25:43
Use entities instead of shapes when constructing ornaments. 13f08847624489f60a37db55c2aedbba6b021f98 Jan Allersma 2018-11-01 17:02:47
Remove obsolete 'calcBounds' function. 475ec330736b5800d12d091415480b163dd244e2 Jan Allersma 2018-11-01 14:28:29
Setup for decorator pattern. 762914dec31b1fb1d4cf6bb0cef2e148010652a4 Jan Allersma 2018-11-01 14:12:51
Revert commit '5678eb6'. 6225242719b2cfc5ee0de9f8d05edbc7a69007a7 Jan Allersma 2018-11-01 14:10:27
Make groups movable and resizable. 1ca7c18ab103a8d1055b27f63192038fd75aef3e Jan Allersma 2018-10-17 14:51:32
Use translations instead of positions for moving shapes. 9551c7d2608f01c3950743fd97bd217aab8f5766 Jan Allersma 2018-10-16 16:11:03
Implement Visitor pattern for Groups. bd30477ce616362d3f58cef072d1ebc78077fa85 Jan Allersma 2018-10-16 13:28:37
Commit b01673996a5b4a589b8e6c6d9dee0dc9b3c1cc60 - Allow multiple Ornaments to be aligned at the same Entity.
* Deprecate and remove EntityOrnament.setOrnament().
* Implement accept/visit for EntityOrnament with Visitors.
* Update readme.
Author: Jan Allersma
Author date (UTC): 2018-11-09 21:46
Committer name: Jan Allersma
Committer date (UTC): 2018-11-09 21:51
Parent(s): db1ce677fbcbba757c18ea645b76bb1688594d04
Signing key:
Tree: bd1e493e56f6f8aea93eec63c54600f0d1616636
File Lines added Lines deleted
README.md 7 13
source/entities/decorator/entornament.d 0 5
source/entities/ornament.d 16 5
source/file.d 2 2
source/frontend/ornamentDialog.d 3 3
source/vistors/moveVisitor.d 4 0
source/vistors/resizeVisitor.d 4 0
source/vistors/saveVisitor.d 12 0
source/vistors/visitor.d 2 0
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/decorator/entornament.d changed (mode: 100644) (index bcd204c..eafbc5d)
... ... class EntityOrnament : Decorator {
40 40 foreach(o; ornaments) foreach(o; ornaments)
41 41 o.render(); o.render();
42 42 } }
43
44 public void setOrnament(Ornament ornament) {
45 ornaments.length++;
46 ornaments[ornaments.length - 1] = ornament;
47 }
48 43 } }
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/resizeVisitor.d changed (mode: 100644) (index 2f8db00..c76850c)
... ... public class ResizeVisitor : Visitor {
9 9 this.amount = amount; this.amount = amount;
10 10 } }
11 11
12 public override void visit(EntityOrnament eo) {
13 eo.accept(new ResizeVisitor(amount));
14 }
15
12 16 public override void visit(Shape s) { public override void visit(Shape s) {
13 17 double[2] newPos; double[2] newPos;
14 18
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);
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/kapstok/NHL-DePa2

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/kapstok/NHL-DePa2

Clone this repository using git:
git clone git://git.rocketgit.com/user/kapstok/NHL-DePa2

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main