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)
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
Implement Visitor pattern for Shapes. e52412c3059c1ee5fa9abdf4a32db0f47981eee1 Jan Allersma 2018-10-16 12:43:17
Use different strats instead of seperate Shapes. a56e1e665a0292d15139eddfd8ebdeb8c95251b4 Jan Allersma 2018-10-01 11:37:45
Fix bug in Rect from commit 6c91140 in other Shapes as well. 4165a5da98dd9a548a222c6160390e4e54026d48 Jan Allersma 2018-09-28 14:53:40
Fully implement File I/O. 45cbb48489a24857cfc76144b38b12ccebfd9e61 Jan Allersma 2018-09-27 16:03:40
Fix GroupMenu bug. be41e51819be1a23e7761ea0662eb188ac641aca Jan Allersma 2018-09-27 14:55:20
Fix TODO's from previous commit. 89d8172b77336a6c18f30521147eb81287961f11 Jan Allersma 2018-09-27 14:06:30
Add groups as preparation for step 3. a91368128e7444f69b3a30ee4d17f9063c8846b8 Jan Allersma 2018-09-26 18:31:49
Fix minor bug. Small cleanup 'ellipse' code. 6c911405eb8e48ffe2d63aaff5255adbd4aec889 Jan Allersma 2018-09-21 18:10:01
Implement file I/O. 6219eca932d454a7dab5fe8679f07865ce3cf49d Jan Allersma 2018-09-21 15:52:45
Add shape 'ellipse'. 99d8b029c769bc291af73df3fd445da3cbf5bef4 Jan Allersma 2018-09-21 10:44:36
Add shape 'circle'. 092cb3c3f788b461192a6e164955c53acaf58720 Jan Allersma 2018-09-21 09:35:27
Add resize option (again). 08c95e97268cf9d74bcb963503eec512e528edfe Jan Allersma 2018-09-20 18:09:03
Fix undo bug. 6ab126be633075923cdcce53044e2468f967db41 Jan Allersma 2018-09-20 10:46:50
Implement 'delete shape' feature. 16d42472d44a9dae988c4745c90c791a8770541b Jan Allersma 2018-09-19 09:04:40
Fix undo/redo for 'MoveCmd'. be51bea021bfe5ff79e16a92d350677aed736ddd Jan Allersma 2018-09-19 08:49:55
Implement shapeOptions without undo/redo. bbe699f41e5dacbfdadfaa879452ac2f4501f5a1 Jan Allersma 2018-09-18 19:44:44
WIP: Restore 'shapeOptions.d'. 888b8ea647c0f25cfbeefcd97ee7ebb59e7f0751 Jan Allersma 2018-09-18 15:46:05
Rebuild project from scratch. df0f2f82a86581ba9fa3a169d63a950229341a9f Jan Allersma 2018-09-18 15:04:32
Commit 9551c7d2608f01c3950743fd97bd217aab8f5766 - Use translations instead of positions for moving shapes.
Remove some unnecessary verbosity with `writeln()`.
Author: Jan Allersma
Author date (UTC): 2018-10-16 16:11
Committer name: Jan Allersma
Committer date (UTC): 2018-10-16 16:11
Parent(s): bd30477ce616362d3f58cef072d1ebc78077fa85
Signing key:
Tree: 60749dd1151ffd49595ce7d0b00ee987a87bf37b
File Lines added Lines deleted
source/commands/move.d 12 8
source/entities/shape.d 0 2
source/strategies/rect.d 0 2
source/vistors/moveVisitor.d 9 6
File source/commands/move.d changed (mode: 100644) (index 6f9a3ae..afa4b6c)
... ... import Global = dp.global;
8 8
9 9 public class MoveCmd : Command { public class MoveCmd : Command {
10 10 private Shape s; private Shape s;
11 private int[2] oldPos;
12 private int[2] newPos;
11 private int[2] translation;
13 12
14 13 this(Shape shape, int[2] newPosition) { this(Shape shape, int[2] newPosition) {
15 14 s = shape; s = shape;
16 oldPos = shape.position;
17 newPos = newPosition;
15
16 translation = [
17 newPosition[0] - s.position[0],
18 newPosition[1] - s.position[1]
19 ];
20
18 21 execute(); execute();
19 22 } }
20 23
21 24 public override void execute() { public override void execute() {
22 //s.move(newPos[0], newPos[1]);
23 s.accept(new MoveVisitor(newPos));
25 s.accept(new MoveVisitor(translation));
24 26 } }
25 27
26 28 public override void undo() { public override void undo() {
27 //move(oldPos[0], oldPos[1]);
28 s.accept(new MoveVisitor(oldPos));
29 s.accept(new MoveVisitor([
30 -translation[0],
31 -translation[1]
32 ]));
29 33 } }
30 34
31 35 public override void render() { public override void render() {
File source/entities/shape.d changed (mode: 100644) (index 9e80031..fa7e7a6)
... ... class Shape : Entity {
83 83 Global.Brush.red, Global.Brush.green, Global.Brush.red, Global.Brush.green,
84 84 Global.Brush.blue, Global.Brush.alpha Global.Brush.blue, Global.Brush.alpha
85 85 ); );
86 writeln("Rendering..");
87 86 strat.draw(this); strat.draw(this);
88 87 c.fill(); c.fill();
89 writeln("Done!");
90 88 } }
91 89 } }
92 90
File source/strategies/rect.d changed (mode: 100644) (index 37d2d5d..7174c5e)
1 1 module dp.strat.rect; module dp.strat.rect;
2 2
3 3 import dp.strat.strat; import dp.strat.strat;
4 import std.stdio; // Debug
5 4
6 5 private static RectDrawer _rect; private static RectDrawer _rect;
7 6
 
... ... private static class RectDrawer : Strategy {
36 35 } }
37 36
38 37 public override void draw(Shape shape) { public override void draw(Shape shape) {
39 writeln("Drawing..");
40 38 shape.c.rectangle ( shape.c.rectangle (
41 39 shape.bounds[0][0], shape.bounds[0][0],
42 40 shape.bounds[0][1], shape.bounds[0][1],
File source/vistors/moveVisitor.d changed (mode: 100644) (index 38aadc3..79bc248)
... ... module dp.visitor.move;
3 3 import dp.visitor.visitor; import dp.visitor.visitor;
4 4
5 5 public class MoveVisitor : Visitor { public class MoveVisitor : Visitor {
6 int[2] position;
6 int[2] translation;
7 7
8 8 this(int x, int y) { this(int x, int y) {
9 position = [x,y];
9 translation = [x,y];
10 10 } }
11 11
12 this(int[2] position) {
13 this.position = position;
12 this(int[2] translation) {
13 this.translation = translation;
14 14 } }
15 15
16 16 public override void visit(Shape s) { public override void visit(Shape s) {
17 s.bounds = s.calcBounds(position[0], position[1]);
17 s.bounds = s.calcBounds(
18 this.translation[0] + s.position[0],
19 this.translation[1] + s.position[1]
20 );
18 21 } }
19 22
20 23 public override void visit(Group g) { public override void visit(Group g) {
21 24 for(size_t i = 0; i < g.length; i++) for(size_t i = 0; i < g.length; i++)
22 g.get(i).accept(new MoveVisitor(position));
25 g.get(i).accept(new MoveVisitor(translation));
23 26 } }
24 27 } }
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