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