File source/entities/ornament.d changed (mode: 100644) (index 00deab9..2fd109b) |
1 |
1 |
module dp.ent.ornament; |
module dp.ent.ornament; |
2 |
2 |
|
|
3 |
3 |
import dp.ent.entity; |
import dp.ent.entity; |
|
4 |
|
import cairo.Context; |
4 |
5 |
|
|
5 |
6 |
class Ornament : Entity { |
class Ornament : Entity { |
6 |
7 |
Entity entity; |
Entity entity; |
7 |
|
string position; |
|
|
8 |
|
Context context; |
|
9 |
|
string alignment; |
8 |
10 |
string value; |
string value; |
9 |
11 |
|
|
10 |
|
this(Entity entity, string position, string value) { |
|
|
12 |
|
this(Entity entity, string alignment, string value, Context context) { |
11 |
13 |
this.entity = entity; |
this.entity = entity; |
12 |
|
this.position = position; |
|
|
14 |
|
this.alignment = alignment; |
13 |
15 |
this.value = value; |
this.value = value; |
|
16 |
|
this.context = context; |
|
17 |
|
|
|
18 |
|
context.setSourceRgba(0.5,0.5,0.5,1); |
|
19 |
|
context.selectFontFace("Purisa", CairoFontSlant.NORMAL, CairoFontWeight.BOLD); |
|
20 |
|
context.setFontSize(13); |
14 |
21 |
} |
} |
15 |
22 |
|
|
16 |
23 |
@property |
@property |
|
... |
... |
class Ornament : Entity { |
35 |
42 |
|
|
36 |
43 |
@property |
@property |
37 |
44 |
public override string to_string() { |
public override string to_string() { |
38 |
|
return type ~ " " ~ position ~ " " ~ value; |
|
|
45 |
|
return type ~ " " ~ alignment ~ " " ~ value; |
39 |
46 |
} |
} |
40 |
47 |
|
|
41 |
48 |
public override void accept(Visitor v) { |
public override void accept(Visitor v) { |
|
... |
... |
class Ornament : Entity { |
45 |
52 |
public override void checkBounds(int x, int y) {} |
public override void checkBounds(int x, int y) {} |
46 |
53 |
|
|
47 |
54 |
public override void render() { |
public override void render() { |
48 |
|
// render text. |
|
|
55 |
|
if(!active) |
|
56 |
|
return; |
|
57 |
|
|
|
58 |
|
double[2] pos = position; |
|
59 |
|
context.moveTo(pos[0], pos[1]); |
|
60 |
|
context.showText(value); |
49 |
61 |
} |
} |
50 |
62 |
|
|
51 |
|
private void calcBounds() { |
|
|
63 |
|
@property |
|
64 |
|
private double[2] position() { |
52 |
65 |
double[2][2] bounds = entity.bounds; |
double[2][2] bounds = entity.bounds; |
53 |
66 |
|
|
54 |
|
final switch(position) { |
|
|
67 |
|
final switch(alignment) { |
55 |
68 |
case "Top": |
case "Top": |
56 |
|
bounds[0][1] -= 30 + size; |
|
57 |
|
bounds[1][1] -= 30 + size; |
|
|
69 |
|
bounds[0][1] -= size / 4; |
58 |
70 |
break; |
break; |
59 |
71 |
case "Bottom": |
case "Bottom": |
60 |
|
bounds[0][1] += 30 + size; |
|
61 |
|
bounds[1][1] += 30 + size; |
|
|
72 |
|
bounds[0][1] = 30 + bounds[1][1]; |
62 |
73 |
break; |
break; |
63 |
74 |
case "Left": |
case "Left": |
64 |
|
bounds[0][0] -= 30 + size; |
|
65 |
|
bounds[0][1] -= 30 + size; |
|
|
75 |
|
bounds[0][0] -= 30 + size / 2; |
|
76 |
|
bounds[0][1] += size / 2; |
66 |
77 |
break; |
break; |
67 |
78 |
case "Right": |
case "Right": |
68 |
|
bounds[0][0] += 30 + size; |
|
69 |
|
bounds[0][1] += 30 + size; |
|
|
79 |
|
bounds[0][0] = 30 + bounds[1][0]; |
|
80 |
|
bounds[0][1] += size / 2; |
70 |
81 |
break; |
break; |
71 |
82 |
} |
} |
|
83 |
|
|
|
84 |
|
return [bounds[0][0], bounds[0][1]]; |
72 |
85 |
} |
} |
73 |
86 |
} |
} |
File source/frontend/ornamentDialog.d changed (mode: 100644) (index f5ab652..ded2560) |
... |
... |
import gtk.Box; |
11 |
11 |
import dp.ent.entity; |
import dp.ent.entity; |
12 |
12 |
import dp.ent.ornament; |
import dp.ent.ornament; |
13 |
13 |
import dp.dec.entornament; |
import dp.dec.entornament; |
14 |
|
//import dp.command.create; |
|
|
14 |
|
import dp.command.create; |
15 |
15 |
|
|
16 |
16 |
import Global = dp.global; |
import Global = dp.global; |
17 |
17 |
|
|
|
... |
... |
class OrnamentDialog : Dialog { |
80 |
80 |
this.close(); |
this.close(); |
81 |
81 |
|
|
82 |
82 |
if(input != "") { |
if(input != "") { |
83 |
|
//Ornament o = new Ornament(e, position, input); |
|
84 |
|
//Global.History.addCommand(new CreateCmd(o)); |
|
85 |
|
eo.setOrnament(new Ornament(e, position, input)); |
|
86 |
|
//e = eo; |
|
|
83 |
|
Ornament o = new Ornament(e, position, input, Global.canvas.newContext); |
|
84 |
|
Global.History.addCommand(new CreateCmd(o)); |
|
85 |
|
eo.setOrnament(o); |
|
86 |
|
Global.canvas.repaint(); |
87 |
87 |
this.close(); |
this.close(); |
88 |
88 |
} |
} |
89 |
89 |
else { |
else { |