Mercurial > projects > doodle
annotate doodle/main/prog/doodler.d @ 85:98980cee8c5b
More work trying to support OpenGL as a renderer
author | daveb |
---|---|
date | Mon, 16 Aug 2010 17:59:42 +0930 |
parents | 06b4504cbcb0 |
children | c825e6db57c1 |
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; |
85 | 19 //import doodle.gtk.cairo_canvas; |
20 import doodle.gtk.opengl_canvas; | |
21 import glgdk.GLdInit; | |
27 | 22 |
20 | 23 import gtk.Main; |
24 import gtk.MainWindow; | |
27 | 25 import gtk.VBox; |
20 | 26 |
27 import std.stdio; | |
28 } | |
29 | |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
30 final class TopLevel : private IToolStackObserver { |
56 | 31 this(string[] args) { |
32 Main.init(args); | |
85 | 33 GLdInit.init(args); |
56 | 34 auto window = new MainWindow("Doodle"); |
35 auto vbox = new VBox(false, 0); | |
54 | 36 |
61 | 37 auto palette = new Palette!Tool; |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
38 _palette = palette; |
60
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
39 |
56 | 40 vbox.packStart(palette, false, false, 0); |
41 | |
42 Tool[] tools; | |
43 tools ~= new PanTool; | |
44 tools ~= new ZoomTool; | |
45 tools ~= new SelectTool; | |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
46 auto toolLayer = new ToolLayer(tools, this); |
56 | 47 _toolStack = toolLayer; |
48 | |
60
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
49 auto gridLayer = new GridLayer; |
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
50 |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
51 auto diagramLayer = new DiagramLayer; |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
52 _diagram = diagramLayer; |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
53 |
56 | 54 Layer[] layers; |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
55 layers ~= new PageLayer; |
56 | 56 layers ~= gridLayer; |
57 layers ~= toolLayer; | |
69 | 58 |
59 // assume the screen has PPI of 120.0 | |
60 immutable millimetersPerInch = 25.4; | |
61 immutable pixelsPerMillimetre = 120.0 / millimetersPerInch; | |
85 | 62 //auto canvas = new CairoCanvas(layers, toolLayer, gridLayer, pixelsPerMillimetre); |
63 auto canvas = new OpenGLCanvas(layers, toolLayer, gridLayer, pixelsPerMillimetre); | |
51 | 64 |
56 | 65 vbox.packStart(canvas, true, true, 0); |
60
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
66 |
61 | 67 Palette!Tool.Item[] items = [ |
60
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
68 { "select.svg", "Select", "Select and modify elements", new SelectTool }, |
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
69 { "rectangle.svg", "Rectangle", "Create rectangle", new CreateRectangleTool(_diagram) }, |
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
70 { "ellipse.svg", "Ellipse", "Create ellipse", new CreateRectangleTool(_diagram) }, |
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
71 { "polyline.svg", "Polyline", "Create polyline", new CreateRectangleTool(_diagram) } |
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
72 ]; |
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
73 |
61 | 74 palette.configure(items, &_toolStack.use); |
56 | 75 window.add(vbox); |
76 window.setDefaultSize(640, 580); | |
77 window.showAll(); | |
78 Main.run(); | |
79 } | |
51 | 80 |
60
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
81 void toolChanged(Tool tool) { |
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
82 message("Tool changed %s", tool.name); |
e64baac3efb2
Attempt at a templatised palette
David Bryant <bagnose@gmail.com>
parents:
58
diff
changeset
|
83 _palette.activate(tool); |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
84 } |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
85 |
56 | 86 private { |
57 | 87 IToolStack _toolStack; |
61 | 88 IPalette!Tool _palette; |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
57
diff
changeset
|
89 IDiagram _diagram; |
56 | 90 } |
20 | 91 } |
56 | 92 |
93 void main(string[] args) { | |
94 new TopLevel(args); | |
95 } |