Mercurial > projects > dynamin
comparison dynamin/painting/text_layout.d @ 105:97997a544ac0
Add a couple TODOs and clean up a logging statement.
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Sat, 24 Nov 2012 10:21:50 -0600 |
parents | 73060bc3f004 |
children | acdbb30fee7e |
comparison
equal
deleted
inserted
replaced
104:5c8c1c2e12c0 | 105:97997a544ac0 |
---|---|
640 // when it is a perfectly valid string. Thankfully, cropLeft() works. | 640 // when it is a perfectly valid string. Thankfully, cropLeft() works. |
641 if(cropLeft!(char)(text[index..$]).length != text.length-index) | 641 if(cropLeft!(char)(text[index..$]).length != text.length-index) |
642 throw new Exception("index must be at a valid code point, not inside one"); | 642 throw new Exception("index must be at a valid code point, not inside one"); |
643 } | 643 } |
644 | 644 |
645 // {{{ layout() | |
645 protected void layout(Graphics g) { | 646 protected void layout(Graphics g) { |
647 if(layoutBoxes.length == 0) | |
648 throw new Exception("layoutBoxes must be set"); | |
649 // TODO: need to be able to set just one rect, not an array of layoutBoxes | |
650 | |
646 backend_preprocess(g); | 651 backend_preprocess(g); |
647 | 652 |
648 version(TextLayoutDebug) | 653 version(TextLayoutDebug) |
649 Stdout("-----layout start-----").newline; | 654 Stdout("-----layout start-----").newline; |
650 int lastRunIndex = 0; // used in case of a bug | 655 int lastRunIndex = 0; // used in case of a bug |
696 break; | 701 break; |
697 lastRunIndex = progress.runIndex; | 702 lastRunIndex = progress.runIndex; |
698 } | 703 } |
699 // if wrapping around an object, a tab should go on the other side of the object | 704 // if wrapping around an object, a tab should go on the other side of the object |
700 } | 705 } |
706 // }}} | |
701 | 707 |
702 struct LayoutProgress { | 708 struct LayoutProgress { |
703 int runIndex = 0; | 709 int runIndex = 0; |
704 int boxIndex = 0; | 710 int boxIndex = 0; |
705 double y = 0; // y is relative to the top of the layout box | 711 double y = 0; // y is relative to the top of the layout box |
1314 lastLineY = run.position.y; | 1320 lastLineY = run.position.y; |
1315 } | 1321 } |
1316 assert(startAct >= 0); | 1322 assert(startAct >= 0); |
1317 if(lengthAct == -1) | 1323 if(lengthAct == -1) |
1318 lengthAct = t.text.length - startAct; | 1324 lengthAct = t.text.length - startAct; |
1319 Stdout.format("s {0} l {1} s2 {2} l2 {3}", start, length, startAct, lengthAct).newline; | 1325 Stdout.format("test start: {0} len: {1} startAct: {2} lenAct: {3}", start, length, startAct, lengthAct).newline; |
1320 assert(start == startAct && length == lengthAct); | 1326 assert(start == startAct && length == lengthAct); |
1321 } | 1327 } |
1322 void assertLinePosition(TextLayout t, int line, float x, float y) { | 1328 void assertLinePosition(TextLayout t, int line, float x, float y) { |
1323 float lastLineY; | 1329 float lastLineY; |
1324 foreach(run; t.runs) { | 1330 foreach(run; t.runs) { |