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 |
} |
} |