File source/entities/entity.d changed (mode: 100644) (index a93d0dc..e317789) |
... |
... |
class Entity { |
13 |
13 |
public bool active = true; |
public bool active = true; |
14 |
14 |
public Group group = null; |
public Group group = null; |
15 |
15 |
|
|
|
16 |
|
@property |
|
17 |
|
public abstract double size(); |
|
18 |
|
|
|
19 |
|
@property |
|
20 |
|
public abstract double size(double s); |
|
21 |
|
|
|
22 |
|
@property |
|
23 |
|
public abstract double[2][2] bounds(); |
|
24 |
|
|
16 |
25 |
@property |
@property |
17 |
26 |
public abstract string type(); |
public abstract string type(); |
18 |
27 |
|
|
File source/entities/group.d changed (mode: 100644) (index bd71c97..a7746b7) |
... |
... |
import Global = dp.global; |
13 |
13 |
class Group : Entity { |
class Group : Entity { |
14 |
14 |
public double[3] colour; // R, G, B |
public double[3] colour; // R, G, B |
15 |
15 |
private Entity[] entities; |
private Entity[] entities; |
|
16 |
|
private double s; |
16 |
17 |
|
|
17 |
18 |
this() { |
this() { |
18 |
19 |
auto random = rndGen(); |
auto random = rndGen(); |
|
20 |
|
s = 1; |
19 |
21 |
entities = []; |
entities = []; |
20 |
22 |
active = true; |
active = true; |
21 |
23 |
colour = [ |
colour = [ |
|
... |
... |
class Group : Entity { |
27 |
29 |
writeln(colour); |
writeln(colour); |
28 |
30 |
} |
} |
29 |
31 |
|
|
|
32 |
|
@property |
|
33 |
|
public override double size() { |
|
34 |
|
return s; |
|
35 |
|
} |
|
36 |
|
|
|
37 |
|
@property |
|
38 |
|
public override double size(double s) { |
|
39 |
|
return this.s = s; |
|
40 |
|
} |
|
41 |
|
|
|
42 |
|
@property |
|
43 |
|
public override double[2][2] bounds() { |
|
44 |
|
double[2][2] result = [ |
|
45 |
|
[double.infinity,double.infinity], |
|
46 |
|
[0.0,0.0] |
|
47 |
|
]; |
|
48 |
|
|
|
49 |
|
foreach(e; entities) { |
|
50 |
|
double[2][2] bnds = e.bounds; |
|
51 |
|
|
|
52 |
|
if(bnds[0][0] < result[0][0]) |
|
53 |
|
result[0][0] = bnds[0][0]; |
|
54 |
|
if(bnds[0][1] < result[0][1]) |
|
55 |
|
result[0][1] = bnds[0][1]; |
|
56 |
|
if(bnds[1][0] > result[1][0]) |
|
57 |
|
result[1][0] = bnds[1][0]; |
|
58 |
|
if(bnds[1][1] > result[1][1]) |
|
59 |
|
result[1][1] = bnds[1][1]; |
|
60 |
|
} |
|
61 |
|
|
|
62 |
|
return result; |
|
63 |
|
} |
|
64 |
|
|
30 |
65 |
@property |
@property |
31 |
66 |
public size_t length() { |
public size_t length() { |
32 |
67 |
return entities.length; |
return entities.length; |
File source/entities/ornament.d changed (mode: 100644) (index 040c90b..00deab9) |
1 |
1 |
module dp.ent.ornament; |
module dp.ent.ornament; |
2 |
2 |
|
|
3 |
|
import dp.ent.shape; |
|
4 |
3 |
import dp.ent.entity; |
import dp.ent.entity; |
5 |
4 |
|
|
6 |
5 |
class Ornament : Entity { |
class Ornament : Entity { |
7 |
|
Shape shape; |
|
|
6 |
|
Entity entity; |
8 |
7 |
string position; |
string position; |
9 |
8 |
string value; |
string value; |
10 |
9 |
|
|
11 |
|
this(Shape shape, string position, string value) { |
|
12 |
|
this.shape = shape; |
|
|
10 |
|
this(Entity entity, string position, string value) { |
|
11 |
|
this.entity = entity; |
13 |
12 |
this.position = position; |
this.position = position; |
14 |
13 |
this.value = value; |
this.value = value; |
15 |
14 |
} |
} |
16 |
15 |
|
|
|
16 |
|
@property |
|
17 |
|
public override double size() { |
|
18 |
|
return entity.size; |
|
19 |
|
} |
|
20 |
|
|
|
21 |
|
@property |
|
22 |
|
public override double size(double s) { |
|
23 |
|
return entity.size = s; |
|
24 |
|
} |
|
25 |
|
|
|
26 |
|
@property |
|
27 |
|
public override double[2][2] bounds() { |
|
28 |
|
return entity.bounds; |
|
29 |
|
} |
|
30 |
|
|
17 |
31 |
@property |
@property |
18 |
32 |
public override string type() { |
public override string type() { |
19 |
33 |
return "ornament"; |
return "ornament"; |
|
... |
... |
class Ornament : Entity { |
24 |
38 |
return type ~ " " ~ position ~ " " ~ value; |
return type ~ " " ~ position ~ " " ~ value; |
25 |
39 |
} |
} |
26 |
40 |
|
|
|
41 |
|
public override void accept(Visitor v) { |
|
42 |
|
v.visit(this); |
|
43 |
|
} |
|
44 |
|
|
27 |
45 |
public override void checkBounds(int x, int y) {} |
public override void checkBounds(int x, int y) {} |
28 |
46 |
|
|
29 |
47 |
public override void render() { |
public override void render() { |
|
... |
... |
class Ornament : Entity { |
31 |
49 |
} |
} |
32 |
50 |
|
|
33 |
51 |
private void calcBounds() { |
private void calcBounds() { |
34 |
|
double[2][2] bounds = shape.bounds; |
|
|
52 |
|
double[2][2] bounds = entity.bounds; |
35 |
53 |
|
|
36 |
54 |
final switch(position) { |
final switch(position) { |
37 |
55 |
case "Top": |
case "Top": |
38 |
|
bounds[0][1] -= 30 + shape.size; |
|
39 |
|
bounds[1][1] -= 30 + shape.size; |
|
|
56 |
|
bounds[0][1] -= 30 + size; |
|
57 |
|
bounds[1][1] -= 30 + size; |
40 |
58 |
break; |
break; |
41 |
59 |
case "Bottom": |
case "Bottom": |
42 |
|
bounds[0][1] += 30 + shape.size; |
|
43 |
|
bounds[1][1] += 30 + shape.size; |
|
|
60 |
|
bounds[0][1] += 30 + size; |
|
61 |
|
bounds[1][1] += 30 + size; |
44 |
62 |
break; |
break; |
45 |
63 |
case "Left": |
case "Left": |
46 |
|
bounds[0][0] -= 30 + shape.size; |
|
47 |
|
bounds[0][1] -= 30 + shape.size; |
|
|
64 |
|
bounds[0][0] -= 30 + size; |
|
65 |
|
bounds[0][1] -= 30 + size; |
48 |
66 |
break; |
break; |
49 |
67 |
case "Right": |
case "Right": |
50 |
|
bounds[0][0] += 30 + shape.size; |
|
51 |
|
bounds[0][1] += 30 + shape.size; |
|
|
68 |
|
bounds[0][0] += 30 + size; |
|
69 |
|
bounds[0][1] += 30 + size; |
52 |
70 |
break; |
break; |
53 |
71 |
} |
} |
54 |
72 |
} |
} |
File source/entities/shape/decorator.d changed (mode: 100644) (index b813a0d..670c9ce) |
1 |
|
module dp.dec.shape; |
|
|
1 |
|
module dp.dec.entity; |
2 |
2 |
|
|
3 |
|
import dp.ent.shape; |
|
|
3 |
|
import dp.ent.entity; |
4 |
4 |
import dp.visitor.visitor; |
import dp.visitor.visitor; |
5 |
|
import cairo.Context; |
|
6 |
5 |
|
|
7 |
|
abstract class Decorator : Shape { |
|
8 |
|
protected Shape s; |
|
|
6 |
|
abstract class Decorator : Entity { |
|
7 |
|
protected Entity e; |
9 |
8 |
|
|
10 |
|
this(Shape shape) { |
|
11 |
|
super(0,0,null,null); // Superclass will not be used. |
|
12 |
|
s = shape; |
|
|
9 |
|
this(Entity entity) { |
|
10 |
|
e = entity; |
13 |
11 |
} |
} |
14 |
12 |
|
|
|
13 |
|
// public bool active = true; |
|
14 |
|
// public Group group = null; |
|
15 |
|
/+ |
15 |
16 |
@property |
@property |
16 |
|
public override string type() { |
|
17 |
|
return s.type; |
|
18 |
|
} |
|
19 |
|
|
|
20 |
|
@property |
|
21 |
|
public override string to_string() { |
|
22 |
|
return s.to_string; |
|
23 |
|
} |
|
24 |
|
|
|
25 |
|
@property |
|
26 |
|
public override int[2] position() { |
|
27 |
|
return s.position; |
|
28 |
|
} |
|
29 |
|
|
|
30 |
|
@property |
|
31 |
|
public override double sizeX() { |
|
32 |
|
return s.sizeX; |
|
|
17 |
|
public override Group group() { |
|
18 |
|
return e.group; |
33 |
19 |
} |
} |
34 |
20 |
|
|
35 |
21 |
@property |
@property |
36 |
|
public override double sizeY() { |
|
37 |
|
return s.sizeY; |
|
38 |
|
} |
|
39 |
|
|
|
40 |
|
@property |
|
41 |
|
public override Context context() { |
|
42 |
|
return s.context; |
|
43 |
|
} |
|
44 |
|
|
|
45 |
|
@property |
|
46 |
|
public override Context context(Context c) { |
|
47 |
|
return s.context = c; |
|
48 |
|
} |
|
|
22 |
|
public override bool active() { |
|
23 |
|
return e.active; |
|
24 |
|
}+/ |
49 |
25 |
|
|
50 |
26 |
@property |
@property |
51 |
27 |
public override double size() { |
public override double size() { |
52 |
|
return s.size; |
|
|
28 |
|
return e.size; |
53 |
29 |
} |
} |
54 |
30 |
|
|
55 |
31 |
@property |
@property |
56 |
32 |
public override double size(double s) { |
public override double size(double s) { |
57 |
|
return this.s.size = s; |
|
|
33 |
|
return e.size = s; |
58 |
34 |
} |
} |
59 |
35 |
|
|
60 |
36 |
@property |
@property |
61 |
37 |
public override double[2][2] bounds() { |
public override double[2][2] bounds() { |
62 |
|
return s.bounds; |
|
|
38 |
|
return e.bounds; |
63 |
39 |
} |
} |
64 |
40 |
|
|
65 |
41 |
@property |
@property |
66 |
|
public override double[2][2] bounds(double[2] pos) { |
|
67 |
|
return s.bounds = pos; |
|
|
42 |
|
public override string type() { |
|
43 |
|
return e.type; |
|
44 |
|
} |
|
45 |
|
|
|
46 |
|
@property |
|
47 |
|
public override string to_string() { |
|
48 |
|
return e.to_string(); |
68 |
49 |
} |
} |
69 |
50 |
|
|
70 |
51 |
public override void accept(Visitor v) { |
public override void accept(Visitor v) { |
71 |
|
s.accept(v); |
|
|
52 |
|
e.accept(v); |
72 |
53 |
} |
} |
73 |
54 |
|
|
74 |
55 |
public override void checkBounds(int x, int y) { |
public override void checkBounds(int x, int y) { |
75 |
|
s.checkBounds(x,y); |
|
|
56 |
|
e.checkBounds(x,y); |
76 |
57 |
} |
} |
77 |
58 |
|
|
78 |
59 |
public override void render() { |
public override void render() { |
79 |
|
s.render(); |
|
|
60 |
|
e.render(); |
80 |
61 |
} |
} |
81 |
62 |
} |
} |
File source/entities/shape/entornament.d renamed from source/entities/shape/shapeornament.d (similarity 67%) (mode: 100644) (index 93e4b8f..caeddf1) |
1 |
|
module dp.dec.shapeornament; |
|
|
1 |
|
module dp.dec.entornament; |
2 |
2 |
|
|
3 |
|
import dp.dec.shape; |
|
4 |
|
import dp.ent.shape; |
|
|
3 |
|
import dp.dec.entity; |
|
4 |
|
import dp.ent.entity; |
5 |
5 |
import dp.ent.ornament; |
import dp.ent.ornament; |
6 |
6 |
|
|
7 |
|
class ShapeOrnament : Decorator { |
|
|
7 |
|
class EntityOrnament : Decorator { |
8 |
8 |
Ornament o; |
Ornament o; |
9 |
9 |
|
|
10 |
|
this(Shape shape) { |
|
11 |
|
super(shape); |
|
|
10 |
|
this(Entity entity) { |
|
11 |
|
super(entity); |
12 |
12 |
o = null; |
o = null; |
13 |
13 |
} |
} |
14 |
14 |
|
|
15 |
15 |
@property |
@property |
16 |
16 |
public override string type() { |
public override string type() { |
17 |
|
string result = s.type; |
|
|
17 |
|
string result = e.type; |
18 |
18 |
|
|
19 |
19 |
if(o !is null) |
if(o !is null) |
20 |
20 |
result ~= "\n" ~ o.type; |
result ~= "\n" ~ o.type; |
|
... |
... |
class ShapeOrnament : Decorator { |
24 |
24 |
|
|
25 |
25 |
@property |
@property |
26 |
26 |
public override string to_string() { |
public override string to_string() { |
27 |
|
string result = s.to_string; |
|
|
27 |
|
string result = e.to_string; |
28 |
28 |
|
|
29 |
29 |
if(o !is null) |
if(o !is null) |
30 |
30 |
result ~= "\n" ~ o.to_string; |
result ~= "\n" ~ o.to_string; |
|
... |
... |
class ShapeOrnament : Decorator { |
33 |
33 |
} |
} |
34 |
34 |
|
|
35 |
35 |
public override void render() { |
public override void render() { |
36 |
|
s.render(); |
|
|
36 |
|
e.render(); |
37 |
37 |
if(o !is null) |
if(o !is null) |
38 |
38 |
o.render(); |
o.render(); |
39 |
39 |
} |
} |
File source/frontend/ornamentDialog.d changed (mode: 100644) (index 205f18f..44a440d) |
... |
... |
import gtk.RadioButton, gtk.ToggleButton; |
9 |
9 |
import gtk.Box; |
import gtk.Box; |
10 |
10 |
|
|
11 |
11 |
import dp.ent.entity; |
import dp.ent.entity; |
|
12 |
|
import dp.ent.ornament; |
|
13 |
|
import dp.dec.entornament; |
12 |
14 |
|
|
13 |
15 |
import Global = dp.global; |
import Global = dp.global; |
14 |
16 |
|
|
|
... |
... |
class OrnamentDialog : Dialog { |
71 |
73 |
|
|
72 |
74 |
private void clickCallback(Button button) { |
private void clickCallback(Button button) { |
73 |
75 |
string input = factorEntry.getText(); |
string input = factorEntry.getText(); |
|
76 |
|
EntityOrnament eo = new EntityOrnament(e); |
74 |
77 |
|
|
75 |
78 |
if(e is null) |
if(e is null) |
76 |
79 |
this.close(); |
this.close(); |
77 |
80 |
|
|
78 |
81 |
if(input != "") { |
if(input != "") { |
79 |
|
final switch(position) { |
|
80 |
|
case "Top": |
|
81 |
|
break; |
|
82 |
|
case "Bottom": |
|
83 |
|
break; |
|
84 |
|
case "Left": |
|
85 |
|
break; |
|
86 |
|
case "Right": |
|
87 |
|
break; |
|
88 |
|
} |
|
|
82 |
|
eo.setOrnament(new Ornament(e, position, input)); |
|
83 |
|
//e = eo; |
89 |
84 |
this.close(); |
this.close(); |
90 |
85 |
} |
} |
91 |
86 |
else { |
else { |
File source/vistors/resizeVisitor.d changed (mode: 100644) (index 27270f6..2f8db00) |
... |
... |
public class ResizeVisitor : Visitor { |
35 |
35 |
public override void visit(Group g) { |
public override void visit(Group g) { |
36 |
36 |
for(size_t i = 0; i < g.length; i++) |
for(size_t i = 0; i < g.length; i++) |
37 |
37 |
g.get(i).accept(new ResizeVisitor(amount)); |
g.get(i).accept(new ResizeVisitor(amount)); |
|
38 |
|
|
|
39 |
|
g.size = g.size + amount; |
38 |
40 |
} |
} |
|
41 |
|
|
|
42 |
|
public override void visit(Ornament o) {} |
39 |
43 |
} |
} |
File source/vistors/visitor.d changed (mode: 100644) (index 8c878d4..36f51d4) |
... |
... |
module dp.visitor.visitor; |
2 |
2 |
|
|
3 |
3 |
public import dp.ent.shape; |
public import dp.ent.shape; |
4 |
4 |
public import dp.ent.group; |
public import dp.ent.group; |
|
5 |
|
public import dp.ent.ornament; |
5 |
6 |
|
|
6 |
7 |
abstract class Visitor { |
abstract class Visitor { |
7 |
8 |
public abstract void visit(Shape s); |
public abstract void visit(Shape s); |
8 |
9 |
public abstract void visit(Group g); |
public abstract void visit(Group g); |
|
10 |
|
public abstract void visit(Ornament o); |
9 |
11 |
} |
} |