File source/canvas.d changed (mode: 100644) (index b7e5700..da3cd65) |
... |
... |
public class Canvas : DrawingArea { |
79 |
79 |
else if(Global.Brush.shape !is null) { |
else if(Global.Brush.shape !is null) { |
80 |
80 |
final switch (Global.Brush.shape) { |
final switch (Global.Brush.shape) { |
81 |
81 |
case "rectangle": |
case "rectangle": |
82 |
|
writeln("Canvas instantiating rect.."); |
|
83 |
82 |
Global.History.addCommand(new CreateCmd(new Shape(mouseX, mouseY, newContext, rect))); |
Global.History.addCommand(new CreateCmd(new Shape(mouseX, mouseY, newContext, rect))); |
84 |
83 |
break; |
break; |
85 |
84 |
case "circle": |
case "circle": |
File source/entities/shape.d changed (mode: 100644) (index cd6c655..e6d4060) |
... |
... |
import dp.ent.entity; |
4 |
4 |
import dp.strat.strat; |
import dp.strat.strat; |
5 |
5 |
import cairo.Context; |
import cairo.Context; |
6 |
6 |
import std.conv; |
import std.conv; |
7 |
|
import std.stdio; // Debug |
|
8 |
7 |
|
|
9 |
8 |
import Global = dp.global; |
import Global = dp.global; |
10 |
9 |
|
|
|
... |
... |
class Shape : Entity { |
22 |
21 |
private Strategy strat; |
private Strategy strat; |
23 |
22 |
|
|
24 |
23 |
this(int x, int y, Context context, Strategy strategy, double size = 0) { |
this(int x, int y, Context context, Strategy strategy, double size = 0) { |
25 |
|
writeln("Entered constructor of shape."); |
|
26 |
24 |
c = context; |
c = context; |
27 |
25 |
active = true; |
active = true; |
28 |
26 |
this.strat = strategy; |
this.strat = strategy; |
29 |
27 |
this.size = size != 0 ? size : strat.initialSize; |
this.size = size != 0 ? size : strat.initialSize; |
30 |
28 |
this.bounds = calcBounds(x,y); |
this.bounds = calcBounds(x,y); |
31 |
|
writeln("Done! " ~ to!string(getBounds) ~ to!string(getSize)); |
|
32 |
29 |
} |
} |
33 |
30 |
|
|
34 |
31 |
@property |
@property |
|
... |
... |
class Shape : Entity { |
89 |
86 |
Global.Brush.red, Global.Brush.green, |
Global.Brush.red, Global.Brush.green, |
90 |
87 |
Global.Brush.blue, Global.Brush.alpha |
Global.Brush.blue, Global.Brush.alpha |
91 |
88 |
); |
); |
92 |
|
writeln("Rendering.."); |
|
93 |
89 |
strat.draw(this); |
strat.draw(this); |
94 |
90 |
c.fill(); |
c.fill(); |
95 |
|
writeln("Done!"); |
|
96 |
91 |
} |
} |
97 |
92 |
} |
} |
98 |
93 |
|
|
File source/frontend/ornamentDialog.d added (mode: 100644) (index 0000000..5b5a173) |
|
1 |
|
module dp.win.ornament; |
|
2 |
|
|
|
3 |
|
import gtk.Dialog; |
|
4 |
|
import gtk.MessageDialog; |
|
5 |
|
import gtk.Label; |
|
6 |
|
import gtk.Button; |
|
7 |
|
import gtk.Entry; |
|
8 |
|
import gtk.RadioButton, gtk.ToggleButton; |
|
9 |
|
import gtk.Box; |
|
10 |
|
|
|
11 |
|
import dp.ent.shape; |
|
12 |
|
|
|
13 |
|
import Global = dp.global; |
|
14 |
|
|
|
15 |
|
class OrnamentDialog : Dialog { |
|
16 |
|
Shape shape; |
|
17 |
|
Entry factorEntry; |
|
18 |
|
RadioButton topRd, bottomRd, leftRd, rightRd; |
|
19 |
|
string position = "Top"; // Default value since 'topRd' is mnemonic. |
|
20 |
|
|
|
21 |
|
this(Shape shape) { |
|
22 |
|
super(); |
|
23 |
|
setTitle("Attach ornament"); |
|
24 |
|
this.shape = shape; |
|
25 |
|
|
|
26 |
|
Box box = new Box(Orientation.VERTICAL, 50); |
|
27 |
|
|
|
28 |
|
Box rdBox = new Box(Orientation.HORIZONTAL, 30); |
|
29 |
|
Box rdBox1 = new Box(Orientation.VERTICAL, 15); |
|
30 |
|
Box rdBox2 = new Box(Orientation.VERTICAL, 15); |
|
31 |
|
topRd = new RadioButton("Top"); |
|
32 |
|
bottomRd = new RadioButton(topRd, "Bottom", false); |
|
33 |
|
leftRd = new RadioButton(topRd, "Left", false); |
|
34 |
|
rightRd = new RadioButton(topRd, "Right", false); |
|
35 |
|
|
|
36 |
|
topRd.addOnToggled(&toggledRd); |
|
37 |
|
bottomRd.addOnToggled(&toggledRd); |
|
38 |
|
leftRd.addOnToggled(&toggledRd); |
|
39 |
|
rightRd.addOnToggled(&toggledRd); |
|
40 |
|
|
|
41 |
|
rdBox1.add(topRd); |
|
42 |
|
rdBox1.add(leftRd); |
|
43 |
|
rdBox2.add(bottomRd); |
|
44 |
|
rdBox2.add(rightRd); |
|
45 |
|
rdBox.add(rdBox1); |
|
46 |
|
rdBox.add(rdBox2); |
|
47 |
|
|
|
48 |
|
factorEntry = new Entry(); |
|
49 |
|
factorEntry.setPlaceholderText("Enter ornament text here"); |
|
50 |
|
|
|
51 |
|
Box btnBox = new Box(Orientation.HORIZONTAL, 30); |
|
52 |
|
Button shapeBtn = new Button("Add ornament to shape", &clickCallback); |
|
53 |
|
Button groupBtn = new Button("Add ornament to group", &clickCallback); |
|
54 |
|
|
|
55 |
|
btnBox.add(shapeBtn); |
|
56 |
|
btnBox.add(groupBtn); |
|
57 |
|
|
|
58 |
|
// Content area, containing non-interactable GTK objects. |
|
59 |
|
getContentArea().add(new Label("Position of ornament relative to shape/group:")); |
|
60 |
|
getContentArea().setBorderWidth(20); |
|
61 |
|
|
|
62 |
|
// Action area, containing interactable GTK objects. |
|
63 |
|
box.add(rdBox); |
|
64 |
|
box.add(factorEntry); |
|
65 |
|
box.add(btnBox); |
|
66 |
|
getActionArea().add(box); |
|
67 |
|
getActionArea().setBorderWidth(30); |
|
68 |
|
|
|
69 |
|
showAll(); |
|
70 |
|
} |
|
71 |
|
|
|
72 |
|
private void clickCallback (Button button) { |
|
73 |
|
string input = factorEntry.getText(); |
|
74 |
|
|
|
75 |
|
if(input != "") { |
|
76 |
|
final switch(position) { |
|
77 |
|
case "Top": |
|
78 |
|
break; |
|
79 |
|
case "Bottom": |
|
80 |
|
break; |
|
81 |
|
case "Left": |
|
82 |
|
break; |
|
83 |
|
case "Right": |
|
84 |
|
break; |
|
85 |
|
} |
|
86 |
|
this.close(); |
|
87 |
|
} |
|
88 |
|
else { |
|
89 |
|
MessageDialog msgd = new MessageDialog ( |
|
90 |
|
this, DialogFlags.MODAL, MessageType.ERROR, ButtonsType.OK, |
|
91 |
|
"Please enter a value.", |
|
92 |
|
null |
|
93 |
|
); |
|
94 |
|
scope(exit) msgd.destroy(); |
|
95 |
|
msgd.run(); |
|
96 |
|
} |
|
97 |
|
} |
|
98 |
|
|
|
99 |
|
private void toggledRd(ToggleButton rd) { |
|
100 |
|
if(rd.getActive) |
|
101 |
|
position = rd.getLabel(); |
|
102 |
|
} |
|
103 |
|
} |
File source/frontend/shapeOptions.d changed (mode: 100644) (index 4cc0932..d0e98b5) |
... |
... |
import gdk.Event; |
6 |
6 |
|
|
7 |
7 |
import dp.ent.shape; |
import dp.ent.shape; |
8 |
8 |
import dp.command.destruct; |
import dp.command.destruct; |
9 |
|
import dp.win.resize; |
|
|
9 |
|
import dp.win.resize, dp.win.ornament; |
10 |
10 |
import Global = dp.global; |
import Global = dp.global; |
11 |
11 |
|
|
12 |
12 |
import std.stdio; // For debugging. |
import std.stdio; // For debugging. |
13 |
13 |
|
|
14 |
14 |
protected Shape s; |
protected Shape s; |
15 |
15 |
protected ResizeDialog rd; |
protected ResizeDialog rd; |
|
16 |
|
protected OrnamentDialog od; |
16 |
17 |
|
|
17 |
18 |
public class ShapeOptions : Menu { |
public class ShapeOptions : Menu { |
18 |
19 |
this() { |
this() { |
|
... |
... |
public class ShapeOptions : Menu { |
20 |
21 |
this.append(new DeleteShape()); |
this.append(new DeleteShape()); |
21 |
22 |
this.append(new MoveShape()); |
this.append(new MoveShape()); |
22 |
23 |
this.append(new ResizeShape()); |
this.append(new ResizeShape()); |
|
24 |
|
this.append(new AddOrnament()); |
23 |
25 |
} |
} |
24 |
26 |
|
|
25 |
27 |
public void selectShape (Shape shape) { // Shows options of param shape. |
public void selectShape (Shape shape) { // Shows options of param shape. |
|
... |
... |
protected class ResizeShape : MenuItem { |
67 |
69 |
return false; // Hide ShapeOptions when button is released. |
return false; // Hide ShapeOptions when button is released. |
68 |
70 |
} |
} |
69 |
71 |
} |
} |
|
72 |
|
|
|
73 |
|
protected class AddOrnament : MenuItem { |
|
74 |
|
this() { |
|
75 |
|
super("Attach ornament"); |
|
76 |
|
addOnButtonRelease(&relCallback); |
|
77 |
|
} |
|
78 |
|
|
|
79 |
|
private bool relCallback (Event event, Widget widget) { |
|
80 |
|
od = new OrnamentDialog(s); |
|
81 |
|
return false; // Hide ShapeOptions when button is released. |
|
82 |
|
} |
|
83 |
|
} |
File source/strategies/rect.d changed (mode: 100644) (index d84c9b0..a301072) |
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 |
|
|
8 |
7 |
public static RectDrawer rect() { |
public static RectDrawer rect() { |
9 |
|
if(_rect is null) { |
|
10 |
|
synchronized if(_rect is null) { |
|
|
8 |
|
if(_rect is null) |
11 |
9 |
_rect = new RectDrawer(); |
_rect = new RectDrawer(); |
12 |
|
} |
|
13 |
|
} |
|
|
10 |
|
|
14 |
11 |
return _rect; |
return _rect; |
15 |
12 |
} |
} |
16 |
13 |
|
|
|
... |
... |
private static class RectDrawer : Strategy { |
36 |
33 |
} |
} |
37 |
34 |
|
|
38 |
35 |
public override void draw(Shape shape) { |
public override void draw(Shape shape) { |
39 |
|
writeln("Drawing.."); |
|
40 |
36 |
shape.c.rectangle ( |
shape.c.rectangle ( |
41 |
37 |
shape.getBounds[0][0], |
shape.getBounds[0][0], |
42 |
38 |
shape.getBounds[0][1], |
shape.getBounds[0][1], |