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)
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
Implement Visitor pattern for Shapes. e52412c3059c1ee5fa9abdf4a32db0f47981eee1 Jan Allersma 2018-10-16 12:43:17
Setup 'Decorator' and 'Ornament' class. 5678eb6257bcf88502078d08395a394a1c24568b Jan Allersma 2018-10-09 09:29:50
Use different strats instead of seperate Shapes. a56e1e665a0292d15139eddfd8ebdeb8c95251b4 Jan Allersma 2018-10-01 11:37:45
Make ornament interface compatible with Entities. 21383d5f200a338f8255d7d33b6989937c19fed6 Jan Allersma 2018-10-08 20:36:23
Fix bug in Rect from commit 6c91140 in other Shapes as well. 4165a5da98dd9a548a222c6160390e4e54026d48 Jan Allersma 2018-09-28 14:53:40
Build interface for ornament creation. adcf22a4e878edc45ac0775a5e15ebf0bb1a937d Jan Allersma 2018-10-08 13:53:52
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
Commit d8456f15d69550c4cb0aa615cccb96b45a77f6a6 - Show Ornaments on Canvas.
Author: Jan Allersma
Author date (UTC): 2018-11-02 14:08
Committer name: Jan Allersma
Committer date (UTC): 2018-11-02 14:08
Parent(s): cc900579eedf9c6288ce1c1883122856794e05a0
Signing key:
Tree: 38178492520a7a463968ffd8b7cc1858fde72f0c
File Lines added Lines deleted
source/entities/ornament.d 28 15
source/entities/shape/decorator.d 0 13
source/frontend/ornamentDialog.d 5 5
File source/entities/ornament.d changed (mode: 100644) (index 00deab9..2fd109b)
1 1 module dp.ent.ornament; module dp.ent.ornament;
2 2
3 3 import dp.ent.entity; import dp.ent.entity;
4 import cairo.Context;
4 5
5 6 class Ornament : Entity { class Ornament : Entity {
6 7 Entity entity; Entity entity;
7 string position;
8 Context context;
9 string alignment;
8 10 string value; string value;
9 11
10 this(Entity entity, string position, string value) {
12 this(Entity entity, string alignment, string value, Context context) {
11 13 this.entity = entity; this.entity = entity;
12 this.position = position;
14 this.alignment = alignment;
13 15 this.value = value; this.value = value;
16 this.context = context;
17
18 context.setSourceRgba(0.5,0.5,0.5,1);
19 context.selectFontFace("Purisa", CairoFontSlant.NORMAL, CairoFontWeight.BOLD);
20 context.setFontSize(13);
14 21 } }
15 22
16 23 @property @property
 
... ... class Ornament : Entity {
35 42
36 43 @property @property
37 44 public override string to_string() { public override string to_string() {
38 return type ~ " " ~ position ~ " " ~ value;
45 return type ~ " " ~ alignment ~ " " ~ value;
39 46 } }
40 47
41 48 public override void accept(Visitor v) { public override void accept(Visitor v) {
 
... ... class Ornament : Entity {
45 52 public override void checkBounds(int x, int y) {} public override void checkBounds(int x, int y) {}
46 53
47 54 public override void render() { public override void render() {
48 // render text.
55 if(!active)
56 return;
57
58 double[2] pos = position;
59 context.moveTo(pos[0], pos[1]);
60 context.showText(value);
49 61 } }
50 62
51 private void calcBounds() {
63 @property
64 private double[2] position() {
52 65 double[2][2] bounds = entity.bounds; double[2][2] bounds = entity.bounds;
53 66
54 final switch(position) {
67 final switch(alignment) {
55 68 case "Top": case "Top":
56 bounds[0][1] -= 30 + size;
57 bounds[1][1] -= 30 + size;
69 bounds[0][1] -= size / 4;
58 70 break; break;
59 71 case "Bottom": case "Bottom":
60 bounds[0][1] += 30 + size;
61 bounds[1][1] += 30 + size;
72 bounds[0][1] = 30 + bounds[1][1];
62 73 break; break;
63 74 case "Left": case "Left":
64 bounds[0][0] -= 30 + size;
65 bounds[0][1] -= 30 + size;
75 bounds[0][0] -= 30 + size / 2;
76 bounds[0][1] += size / 2;
66 77 break; break;
67 78 case "Right": case "Right":
68 bounds[0][0] += 30 + size;
69 bounds[0][1] += 30 + size;
79 bounds[0][0] = 30 + bounds[1][0];
80 bounds[0][1] += size / 2;
70 81 break; break;
71 82 } }
83
84 return [bounds[0][0], bounds[0][1]];
72 85 } }
73 86 } }
File source/entities/shape/decorator.d changed (mode: 100644) (index 670c9ce..71beec4)
... ... abstract class Decorator : Entity {
10 10 e = entity; e = entity;
11 11 } }
12 12
13 // public bool active = true;
14 // public Group group = null;
15 /+
16 @property
17 public override Group group() {
18 return e.group;
19 }
20
21 @property
22 public override bool active() {
23 return e.active;
24 }+/
25
26 13 @property @property
27 14 public override double size() { public override double size() {
28 15 return e.size; return e.size;
File source/frontend/ornamentDialog.d changed (mode: 100644) (index f5ab652..ded2560)
... ... import gtk.Box;
11 11 import dp.ent.entity; import dp.ent.entity;
12 12 import dp.ent.ornament; import dp.ent.ornament;
13 13 import dp.dec.entornament; import dp.dec.entornament;
14 //import dp.command.create;
14 import dp.command.create;
15 15
16 16 import Global = dp.global; import Global = dp.global;
17 17
 
... ... class OrnamentDialog : Dialog {
80 80 this.close(); this.close();
81 81
82 82 if(input != "") { if(input != "") {
83 //Ornament o = new Ornament(e, position, input);
84 //Global.History.addCommand(new CreateCmd(o));
85 eo.setOrnament(new Ornament(e, position, input));
86 //e = eo;
83 Ornament o = new Ornament(e, position, input, Global.canvas.newContext);
84 Global.History.addCommand(new CreateCmd(o));
85 eo.setOrnament(o);
86 Global.canvas.repaint();
87 87 this.close(); this.close();
88 88 } }
89 89 else { else {
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