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)
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
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 bbe699f41e5dacbfdadfaa879452ac2f4501f5a1 - Implement shapeOptions without undo/redo.
Author: Jan Allersma
Author date (UTC): 2018-09-18 19:44
Committer name: Jan Allersma
Committer date (UTC): 2018-09-21 13:50
Parent(s): 888b8ea647c0f25cfbeefcd97ee7ebb59e7f0751
Signing key:
Tree: c5ce5eff75119308d5e067283e8c6ca0ef803245
File Lines added Lines deleted
source/brush.d 3 0
source/canvas.d 9 5
source/globals.d 4 0
source/shapeOptions.d 4 3
source/shapes/shape.d 11 0
File source/brush.d changed (mode: 100644) (index a66c80b..783a7b1)
1 1 module dp.brush; module dp.brush;
2 2
3 import dp.shape.shape;
4
5 static Shape clone;
3 6 static string shape; static string shape;
4 7 static double red; static double red;
5 8 static double green; static double green;
File source/canvas.d changed (mode: 100644) (index bcd29aa..52df95f)
... ... import cairo.Context;
6 6 import cairo.ImageSurface; import cairo.ImageSurface;
7 7
8 8 import dp.shape.shape, dp.shape.rect; import dp.shape.shape, dp.shape.rect;
9 import dp.command.create;
9 import dp.command.create, dp.command.move;
10 10
11 11 import std.stdio; // For debug import std.stdio; // For debug
12 12
 
... ... public class Canvas : DrawingArea {
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); Global.History.CheckBounds(mouseX, mouseY);
45 45 } }
46 else {
46 else if(Global.Brush.clone !is null) {
47 Global.Brush.clone.active = true;
48 Global.History.addCommand(new MoveCmd(Global.Brush.clone, [mouseX, mouseY]));
49 Global.Brush.clone = null;
50 repaint();
51 }
52 else if(Global.Brush.shape !is null) {
47 53 final switch (Global.Brush.shape) { final switch (Global.Brush.shape) {
48 54 case "rectangle": case "rectangle":
49 55 Global.History.addCommand(new CreateCmd(new Rectangle(mouseX, mouseY, Context.create(surface)))); Global.History.addCommand(new CreateCmd(new Rectangle(mouseX, mouseY, Context.create(surface))));
50 56 break; break;
51 case null:
52 break;
53 57 } }
54 repaint();
55 58 Global.Brush.shape = null; Global.Brush.shape = null;
59 repaint();
56 60 } }
57 61
58 62 return true; return true;
File source/globals.d changed (mode: 100644) (index 0ea1b31..ccd5fa9)
1 1 module dp.global; module dp.global;
2 2
3 3 import dp.canvas; import dp.canvas;
4 import dp.shapeOptions;
4 5
5 6 public import dp.history; public import dp.history;
6 7 public import Brush = dp.brush; public import Brush = dp.brush;
7 8
8 9 public static Canvas canvas; public static Canvas canvas;
10 public static ShapeOptions shapeOptn;
9 11
10 12 public static void init() { public static void init() {
11 13 canvas = new Canvas(500,500); canvas = new Canvas(500,500);
14 shapeOptn = new ShapeOptions();
15 Brush.clone = null;
12 16 Brush.shape = null; Brush.shape = null;
13 17 Brush.red = 0.5; Brush.red = 0.5;
14 18 Brush.green = 0.9; Brush.green = 0.9;
File source/shapeOptions.d changed (mode: 100644) (index a85f0ff..00dba09)
... ... import gdk.Event;
6 6
7 7 import dp.shape.shape; import dp.shape.shape;
8 8 //import dp.win.resize; //import dp.win.resize;
9 //import Global = dp.globals;
9 import Global = dp.global;
10 10
11 11 import std.stdio; // For debugging. import std.stdio; // For debugging.
12 12
 
... ... public class ShapeOptions : Menu {
21 21 //this.append(new ResizeShape()); //this.append(new ResizeShape());
22 22 } }
23 23
24 // Will look like: sOptions.OfShape(s); Should be differently named.
25 public void OfShape (Shape shape) { // Shows options of param shape.
24 public void selectShape (Shape shape) { // Shows options of param shape.
26 25 s = shape; s = shape;
27 26 this.showAll(); this.showAll();
28 27 this.popup(0, 0); this.popup(0, 0);
 
... ... protected class MoveShape : MenuItem {
50 49 } }
51 50
52 51 private bool relCallback (Event event, Widget widget) { private bool relCallback (Event event, Widget widget) {
52 Global.Brush.clone = s;
53 s.active = false; // In de tussentijd niet gaan drawen totdat het verplaatsen gelukt is!!!
53 54 // Create ghost shape. // Create ghost shape.
54 55 return false; // Hide ShapeOptions when button is released. return false; // Hide ShapeOptions when button is released.
55 56 } }
File source/shapes/shape.d changed (mode: 100644) (index 657f81c..4bb4f9a)
... ... module dp.shape.shape;
3 3 import cairo.Context; import cairo.Context;
4 4 import std.conv; import std.conv;
5 5
6 import Global = dp.global;
7
6 8 class Shape { class Shape {
7 9 /+ /+
8 10 bounds[0][0] = minX bounds[0][0] = minX
 
... ... class Shape {
47 49 } }
48 50
49 51 public void checkBounds(int x, int y) { public void checkBounds(int x, int y) {
52 double[2] p = [to!double(x), to!double(y)];
50 53
54 if (
55 p[0] > bounds[0][0] &&
56 p[0] < bounds[1][0] &&
57 p[1] > bounds[0][1] &&
58 p[1] < bounds[1][1]
59 ) {
60 Global.shapeOptn.selectShape(this);
61 }
51 62 } }
52 63
53 64 public void render() { public void render() {
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