Mercurial > projects > doodle
annotate doodle/main/util/doodler.d @ 134:89e8b0d92f36
Ported to bob2 !!!
author | David Bryant <bagnose@gmail.com> |
---|---|
date | Thu, 02 Aug 2012 17:20:52 +0930 |
parents | doodle/main/prog/doodler.d@bc5baa585b32 |
children |
rev | line source |
---|---|
83
06b4504cbcb0
Checkpoint of trying to get a different renderer going (OpenGL)
daveb
parents:
69
diff
changeset
|
1 module main.prog.doodler; |
06b4504cbcb0
Checkpoint of trying to get a different renderer going (OpenGL)
daveb
parents:
69
diff
changeset
|
2 |
134 | 3 // XXX bob problem, needs it to be like this... |
4 import doodle.core.backtrace; | |
5 import doodle.core.logging; | |
6 import doodle.core.backtrace; | |
7 | |
8 import doodle.dia.standard_tools; | |
9 import doodle.dia.page_layer; | |
10 import doodle.dia.grid_layer; | |
11 import doodle.dia.tool_layer; | |
12 | |
13 import doodle.fig.diagram_layer; | |
14 import doodle.fig.select_tool; | |
15 | |
16 import doodle.fig.tools; | |
17 | |
18 import doodle.gtk.palette; | |
19 | |
20 import doodle.gtk.cairo_canvas; | |
21 | |
28
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
27
diff
changeset
|
22 private { |
134 | 23 /* |
44 | 24 import doodle.core.backtrace; |
38
452915ecd1f4
Basic logging functionality
David Bryant <bagnose@gmail.com>
parents:
35
diff
changeset
|
25 import doodle.core.logging; |
45 | 26 import doodle.core.backtrace; |
38
452915ecd1f4
Basic logging functionality
David Bryant <bagnose@gmail.com>
parents:
35
diff
changeset
|
27 |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
28 import doodle.dia.standard_tools; |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
29 import doodle.dia.page_layer; |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
30 import doodle.dia.grid_layer; |
63
20d6327c4a75
Event progress. Got key press/release working and panning via keyboard.
daveb
parents:
61
diff
changeset
|
31 import doodle.dia.tool_layer; |
20d6327c4a75
Event progress. Got key press/release working and panning via keyboard.
daveb
parents:
61
diff
changeset
|
32 |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
33 import doodle.fig.diagram_layer; |
63
20d6327c4a75
Event progress. Got key press/release working and panning via keyboard.
daveb
parents:
61
diff
changeset
|
34 import doodle.fig.select_tool; |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
35 |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
36 import doodle.fig.tools; |
20 | 37 |
61 | 38 import doodle.gtk.palette; |
87
c825e6db57c1
Added a flag for OpenGL/Cairo
"David Bryant <bagnose@gmail.com>"
parents:
85
diff
changeset
|
39 |
92 | 40 import doodle.gtk.cairo_canvas; |
134 | 41 */ |
27 | 42 |
20 | 43 import gtk.Main; |
44 import gtk.MainWindow; | |
27 | 45 import gtk.VBox; |
20 | 46 |
47 import std.stdio; | |
48 } | |
49 | |
132 | 50 final class TopLevel : /*private*/ IToolStackObserver { |
56 | 51 this(string[] args) { |
52 Main.init(args); | |
53 auto window = new MainWindow("Doodle"); | |
54 auto vbox = new VBox(false, 0); | |
54 | 55 |
61 | 56 auto palette = new Palette!Tool; |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
57 _palette = palette; |
60
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
58 |
56 | 59 vbox.packStart(palette, false, false, 0); |
60 | |
61 Tool[] tools; | |
62 tools ~= new PanTool; | |
63 tools ~= new ZoomTool; | |
64 tools ~= new SelectTool; | |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
65 auto toolLayer = new ToolLayer(tools, this); |
56 | 66 _toolStack = toolLayer; |
67 | |
60
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
68 auto gridLayer = new GridLayer; |
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
69 |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
70 auto diagramLayer = new DiagramLayer; |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
71 _diagram = diagramLayer; |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
72 |
56 | 73 Layer[] layers; |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
74 layers ~= new PageLayer; |
56 | 75 layers ~= gridLayer; |
92 | 76 layers ~= diagramLayer; |
56 | 77 layers ~= toolLayer; |
69 | 78 |
79 // assume the screen has PPI of 120.0 | |
80 immutable millimetersPerInch = 25.4; | |
81 immutable pixelsPerMillimetre = 120.0 / millimetersPerInch; | |
92 | 82 auto canvas = new CairoCanvas(layers, toolLayer, gridLayer, pixelsPerMillimetre); |
51 | 83 |
56 | 84 vbox.packStart(canvas, true, true, 0); |
60
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
85 |
61 | 86 Palette!Tool.Item[] items = [ |
60
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
87 { "select.svg", "Select", "Select and modify elements", new SelectTool }, |
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
88 { "rectangle.svg", "Rectangle", "Create rectangle", new CreateRectangleTool(_diagram) }, |
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
89 { "ellipse.svg", "Ellipse", "Create ellipse", new CreateRectangleTool(_diagram) }, |
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
90 { "polyline.svg", "Polyline", "Create polyline", new CreateRectangleTool(_diagram) } |
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
91 ]; |
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
92 |
61 | 93 palette.configure(items, &_toolStack.use); |
56 | 94 window.add(vbox); |
95 window.setDefaultSize(640, 580); | |
96 window.showAll(); | |
97 Main.run(); | |
98 } | |
51 | 99 |
60
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
100 void toolChanged(Tool tool) { |
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
101 message("Tool changed %s", tool.name); |
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
102 _palette.activate(tool); |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
103 } |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
104 |
56 | 105 private { |
57 | 106 IToolStack _toolStack; |
61 | 107 IPalette!Tool _palette; |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
108 IDiagram _diagram; |
56 | 109 } |
20 | 110 } |
56 | 111 |
112 void main(string[] args) { | |
113 new TopLevel(args); | |
114 } |