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)
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
Add resize option. 961e464090918d83690ff66838f2fc96c6ad213a Jan Allersma 2018-09-13 18:29:44
Make `MoveCmd` Command-oriented. 2970a8d862285752551be2464422375ca958357f Jan Allersma 2018-09-12 15:33:17
Change of strategy: Make project command-oriented. ce40dffb1675661922411eeb07f148f61a176c22 Jan Allersma 2018-09-12 11:35:45
Initial commit. 38c8818349679937ae25dde38949202ec45ea7b2 Jan Allersma 2018-09-11 20:21:57
Commit 888b8ea647c0f25cfbeefcd97ee7ebb59e7f0751 - WIP: Restore 'shapeOptions.d'.
Author: Jan Allersma
Author date (UTC): 2018-09-18 15:46
Committer name: Jan Allersma
Committer date (UTC): 2018-09-21 13:50
Parent(s): df0f2f82a86581ba9fa3a169d63a950229341a9f
Signing key:
Tree: e77a39187f9d7d6dcf2b854d9924e97ade5ab673
File Lines added Lines deleted
source/canvas.d 1 1
source/commands/create.d 2 0
source/commands/move.d 35 0
source/shapeOptions.d 68 0
source/shapes/shape.d 14 0
File source/canvas.d changed (mode: 100644) (index 55df17d..bcd29aa)
... ... public class Canvas : DrawingArea {
41 41 getPointer(mouseX, mouseY); getPointer(mouseX, mouseY);
42 42
43 43 if(event.button.button == 3) { // if right click... if(event.button.button == 3) { // if right click...
44
44 Global.History.CheckBounds(mouseX, mouseY);
45 45 } }
46 46 else { else {
47 47 final switch (Global.Brush.shape) { final switch (Global.Brush.shape) {
File source/commands/create.d changed (mode: 100644) (index 6e82cc8..0383ac4)
... ... public class CreateCmd : Command {
10 10
11 11 this(Shape shape) { this(Shape shape) {
12 12 s = shape; s = shape;
13 execute(); // Obsolete, but remained for consistency between 'Command' classes.
13 14 } }
14 15
15 16 public override void execute() { public override void execute() {
 
... ... public class CreateCmd : Command {
25 26 } }
26 27
27 28 public override void check(int x, int y) { public override void check(int x, int y) {
29 s.checkBounds(x,y);
28 30 } }
29 31 } }
File source/commands/move.d added (mode: 100644) (index 0000000..010192f)
1 module dp.command.move;
2
3 import dp.command.cmd;
4 import dp.shape.shape;
5
6 import Global = dp.global;
7
8 public class MoveCmd : Command {
9 private Shape s;
10 private int[2] oldPos;
11 private int[2] newPos;
12
13 this(Shape shape, int[2] newPosition) {
14 s = shape;
15 oldPos = shape.position;
16 newPos = newPosition;
17 execute();
18 }
19
20 public override void execute() {
21 s.move(newPos[0], newPos[1]);
22 }
23
24 public override void undo() {
25 s.move(oldPos[0], oldPos[1]);
26 }
27
28 public override void render() {
29 s.render();
30 }
31
32 public override void check(int x, int y) {
33 s.checkBounds(x,y);
34 }
35 }
File source/shapeOptions.d added (mode: 100644) (index 0000000..a85f0ff)
1 module dp.shapeOptions;
2
3 import gtk.Menu, gtk.MenuItem;
4 import gtk.Widget;
5 import gdk.Event;
6
7 import dp.shape.shape;
8 //import dp.win.resize;
9 //import Global = dp.globals;
10
11 import std.stdio; // For debugging.
12
13 protected Shape s;
14 //protected ResizeDialog rd;
15
16 public class ShapeOptions : Menu {
17 this() {
18 super();
19 //this.append(new DeleteShape());
20 this.append(new MoveShape());
21 //this.append(new ResizeShape());
22 }
23
24 // Will look like: sOptions.OfShape(s); Should be differently named.
25 public void OfShape (Shape shape) { // Shows options of param shape.
26 s = shape;
27 this.showAll();
28 this.popup(0, 0);
29 }
30 }
31
32 protected class DeleteShape : MenuItem {
33 this() {
34 super("Delete");
35 addOnButtonRelease(&relCallback);
36 }
37
38 // Omgekeerde CreateCmd misschien?
39 private bool relCallback (Event event, Widget widget) {
40 //s.remove();
41 //Global.canvas.repaint();
42 return false; // Hide ShapeOptions when button is released.
43 }
44 }
45
46 protected class MoveShape : MenuItem {
47 this() {
48 super("Move shape");
49 addOnButtonRelease(&relCallback);
50 }
51
52 private bool relCallback (Event event, Widget widget) {
53 // Create ghost shape.
54 return false; // Hide ShapeOptions when button is released.
55 }
56 }
57
58 protected class ResizeShape : MenuItem {
59 this() {
60 super("Resize shape");
61 addOnButtonRelease(&relCallback);
62 }
63
64 private bool relCallback (Event event, Widget widget) {
65 //rd = new ResizeDialog(s);
66 return false; // Hide ShapeOptions when button is released.
67 }
68 }
File source/shapes/shape.d changed (mode: 100644) (index 5ee84d0..657f81c)
1 1 module dp.shape.shape; module dp.shape.shape;
2 2
3 3 import cairo.Context; import cairo.Context;
4 import std.conv;
4 5
5 6 class Shape { class Shape {
6 7 /+ /+
 
... ... class Shape {
26 27 @property @property
27 28 public abstract string type(); public abstract string type();
28 29
30 @property
31 public int[2] position() {
32 return [to!int(bounds[0][0]), to!int(bounds[0][1])];
33 }
34
29 35 /+ /+
30 36 public string toString() { public string toString() {
31 37 return text(type, " ", position[0], " ", position[1], " ", size); return text(type, " ", position[0], " ", position[1], " ", size);
 
... ... class Shape {
36 42 protected abstract void initSize(double size); protected abstract void initSize(double size);
37 43 protected abstract void draw(); protected abstract void draw();
38 44
45 public void move(int x, int y) {
46 this.bounds = calcBounds(x,y);
47 }
48
49 public void checkBounds(int x, int y) {
50
51 }
52
39 53 public void render() { public void render() {
40 54 if(active) { if(active) {
41 55 draw(); draw();
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