From e87fd37b9f64058930f3b642820e74a14775aa48 Mon Sep 17 00:00:00 2001 From: drug007 Date: Thu, 17 Oct 2024 16:59:48 +0300 Subject: [PATCH] Get rid of spacing in models because it should be implemented in other way --- auxil/source/auxil/default_visitor.d | 4 +- auxil/source/auxil/model/package.d | 2 +- auxil/source/auxil/model/state.d | 2 - auxil/source/auxil/test.d | 35 +++--- auxil/source/auxil/test2d.d | 157 ++++++++++++--------------- 5 files changed, 92 insertions(+), 108 deletions(-) diff --git a/auxil/source/auxil/default_visitor.d b/auxil/source/auxil/default_visitor.d index a66dc92..d04a699 100644 --- a/auxil/source/auxil/default_visitor.d +++ b/auxil/source/auxil/default_visitor.d @@ -392,7 +392,7 @@ struct MeasuringVisitor const currentOrientation = model.orientation; else const currentOrientation = orientation; - model.sizeYM = model.headerSizeY = size[currentOrientation] + model.Spacing; + model.sizeYM = model.headerSizeY = size[currentOrientation]; return false; } @@ -417,7 +417,7 @@ struct MeasuringVisitor if (parent.orientation != childOrientation) { // if orientations mismatch use parent orientation - parent.sizeYM += size[parent.orientation] + parent.Spacing; + parent.sizeYM += size[parent.orientation]; return; } } diff --git a/auxil/source/auxil/model/package.d b/auxil/source/auxil/model/package.d index a27159c..6ebf958 100644 --- a/auxil/source/auxil/model/package.d +++ b/auxil/source/auxil/model/package.d @@ -825,7 +825,7 @@ unittest auto data = [0, 1, 2, 3]; auto model = makeModel(data); - auto visitor = MeasuringVisitor(0, 9); + auto visitor = MeasuringVisitor(0, 10); model.collapsed = false; model.traversalForward(data, visitor); diff --git a/auxil/source/auxil/model/state.d b/auxil/source/auxil/model/state.d index 2b994c5..eadec4a 100644 --- a/auxil/source/auxil/model/state.d +++ b/auxil/source/auxil/model/state.d @@ -4,7 +4,6 @@ mixin template State() { import auxil.common : SizeType, Orientation; - enum Spacing = 1; SizeType sizeYM = 0, headerSizeY = 0; int _placeholder = 1 << Field.Collapsed | 1 << Field.Enabled; @@ -58,7 +57,6 @@ mixin template StateScalar() { import auxil.common : SizeType, Orientation; - enum Spacing = 1; SizeType sizeYM = 0; alias headerSizeY = sizeYM; diff --git a/auxil/source/auxil/test.d b/auxil/source/auxil/test.d index 860bb3d..9edf94e 100644 --- a/auxil/source/auxil/test.d +++ b/auxil/source/auxil/test.d @@ -110,7 +110,7 @@ unittest m.makeDefaultMeasuring(d, width, height); m.traversalForward(d, visitor); - m.sizeYM.should.be == 10; + m.sizeYM.should.be == 9; d.d = 0; d.l = 1; d.t.f = 2; @@ -741,49 +741,49 @@ unittest model.collapsed.should.be == true; model.sizeYM.should.be ~ visitor.sizeY; - model.sizeYM.should.be ~ 18.0; + model.sizeYM.should.be ~ 17.0; visitor.posY.should.be ~ 0.0; setPropertyByTreePath!"collapsed"(data, model, [], false); model.makeDefaultMeasuring(data, width, height); model.traversalForward(data, visitor); model.sizeYM.should.be ~ visitor.sizeY*7; - model.sizeYM.should.be ~ 18.0*7; - visitor.posY.should.be ~ 6*18.0; + model.sizeYM.should.be ~ 17.0*7; + visitor.posY.should.be ~ 6*17.0; setPropertyByTreePath!"collapsed"(data, model, [3], false); model.makeDefaultMeasuring(data, width, height); model.traversalForward(data, visitor); model.sizeYM.should.be ~ visitor.sizeY*9; - model.sizeYM.should.be ~ 18.0*9; - visitor.posY.should.be ~ (6+2)*18.0; + model.sizeYM.should.be ~ 17.0*9; + visitor.posY.should.be ~ (6+2)*17.0; setPropertyByTreePath!"collapsed"(data, model, [4], false); model.makeDefaultMeasuring(data, width, height); model.traversalForward(data, visitor); model.sizeYM.should.be ~ visitor.sizeY*12; - model.sizeYM.should.be ~ 18.0*12; - visitor.posY.should.be ~ (6+2+3)*18.0; + model.sizeYM.should.be ~ 17.0*12; + visitor.posY.should.be ~ (6+2+3)*17.0; setPropertyByTreePath!"collapsed"(data, model, [5], false); model.makeDefaultMeasuring(data, width, height); model.traversalForward(data, visitor); model.sizeYM.should.be ~ visitor.sizeY*15; - model.sizeYM.should.be ~ 18.0*15; - visitor.posY.should.be ~ (6+2+3+3)*18.0; + model.sizeYM.should.be ~ 17.0*15; + visitor.posY.should.be ~ (6+2+3+3)*17.0; visitor.destY = visitor.destY.nan; model.makeDefaultMeasuring(data, width, height); model.traversalForward(data, visitor); - model.sizeYM.should.be == 270; - visitor.posY.should.be == 252; + model.sizeYM.should.be == 255; + visitor.posY.should.be == 238; visitor.posY = 0; visitor.destY = 100; model.makeDefaultMeasuring(data, width, height); model.traversalForward(data, visitor); - model.sizeYM.should.be == 270; - visitor.posY.should.be == 90; + model.sizeYM.should.be == 255; + visitor.posY.should.be == 85; } struct RelativeMeasurer @@ -1180,7 +1180,7 @@ unittest model.collapsed = false; { - auto mv = MeasuringVisitor(0, 9); + auto mv = MeasuringVisitor(0, 10); model.traversalForward(data, mv); } visitor.posY = 0; @@ -1255,13 +1255,12 @@ unittest model.collapsed = false; model.collapsed.should.be == false; { - auto mv = MeasuringVisitor(0, 9); + auto mv = MeasuringVisitor(0, 10); model.traversalForward(data, mv); } visitor.posX = 0; visitor.posY = 0; -import std.stdio; -debug writeln("---"); + model.traversalForward(data, visitor); visitor.output.should.be == [ TreePosition([], 0), diff --git a/auxil/source/auxil/test2d.d b/auxil/source/auxil/test2d.d index 819200f..d00fa90 100644 --- a/auxil/source/auxil/test2d.d +++ b/auxil/source/auxil/test2d.d @@ -169,10 +169,8 @@ unittest model[2].orientation = Orientation.Vertical; model[2].collapsed = false; - const spacing = 1; const width = 99; - const height = 9; - const sizeY = height + spacing; + const height = 10; // measure size { auto mv = MeasuringVisitor(width, height); @@ -213,70 +211,70 @@ unittest rm.output[i].x.should.be == 0; rm.output[i].y.should.be == 0; rm.output[i].w.should.be == width; - rm.output[i].h.should.be == sizeY; + rm.output[i].h.should.be == height; i++; rm.output[i].path[].should.be == [0]; rm.output[i].x.should.be == 15; rm.output[i].y.should.be == 10; rm.output[i].w.should.be == width - rm.output[i].x; - rm.output[i].h.should.be == sizeY; + rm.output[i].h.should.be == height; i++; rm.output[i].path[].should.be == [0, 0]; rm.output[i].x.should.be == 30; rm.output[i].y.should.be == 20; rm.output[i].w.should.be == width - rm.output[i].x; - rm.output[i].h.should.be == sizeY; + rm.output[i].h.should.be == height; i++; rm.output[i].path[].should.be == [0, 1]; rm.output[i].x.should.be == 30; rm.output[i].y.should.be == 30; rm.output[i].w.should.be == width - rm.output[i].x; - rm.output[i].h.should.be == sizeY; + rm.output[i].h.should.be == height; i++; rm.output[i].path[].should.be == [1]; rm.output[i].x.should.be == 15; rm.output[i].y.should.be == 40; rm.output[i].w.should.be == width - rm.output[i].x; - rm.output[i].h.should.be == sizeY; + rm.output[i].h.should.be == height; i++; rm.output[i].path[].should.be == [1, 0]; rm.output[i].x.should.be == 30; rm.output[i].y.should.be == 50; rm.output[i].w.should.be == width - rm.output[i].x; - rm.output[i].h.should.be == sizeY; + rm.output[i].h.should.be == height; i++; rm.output[i].path[].should.be == [1, 1]; rm.output[i].x.should.be == 30; rm.output[i].y.should.be == 60; rm.output[i].w.should.be == width - rm.output[i].x; - rm.output[i].h.should.be == sizeY; + rm.output[i].h.should.be == height; i++; rm.output[i].path[].should.be == [2]; rm.output[i].x.should.be == 15; rm.output[i].y.should.be == 70; rm.output[i].w.should.be == width - rm.output[i].x; - rm.output[i].h.should.be == sizeY; + rm.output[i].h.should.be == height; i++; rm.output[i].path[].should.be == [2, 0]; rm.output[i].x.should.be == 30; rm.output[i].y.should.be == 80; rm.output[i].w.should.be == width - rm.output[i].x; - rm.output[i].h.should.be == sizeY; + rm.output[i].h.should.be == height; i++; rm.output[i].path[].should.be == [2, 1]; rm.output[i].x.should.be == 30; rm.output[i].y.should.be == 90; rm.output[i].w.should.be == width - rm.output[i].x; - rm.output[i].h.should.be == sizeY; + rm.output[i].h.should.be == height; i++; } (); } @@ -302,10 +300,8 @@ unittest model.orientation = Orientation.Horizontal; - const width = 100; - const height = 9; - const spacing = 1; - const sizeX = width + spacing; + const width = 101; + const height = 10; // measure size { @@ -313,10 +309,10 @@ unittest model.traversalForward(data, mv); } - model.header_size.should.be == sizeX; - model.i.size.should.be == sizeX; - model.f.size.should.be == sizeX; - model.size.should.be == 3*sizeX; + model.header_size.should.be == width; + model.i.size.should.be == width; + model.f.size.should.be == width; + model.size.should.be == 3*width; model.header_size.should.be == 101; model.size.should.be == 303; @@ -328,7 +324,6 @@ unittest rm.posY = 0; rm.destX = 1000; rm.destY = 1000; - enum spacing = 1; model.traversalForward(data, rm); printLogToSvg("horizontal.TrivialAggregate", 1, rm.output); @@ -337,21 +332,21 @@ unittest rm.output[i].path[].length.should.be == 0; rm.output[i].x.should.be == 0; rm.output[i].y.should.be == 0; - rm.output[i].w.should.be == sizeX; + rm.output[i].w.should.be == width; rm.output[i].h.should.be == height; i++; rm.output[i].path[].should.be == [0]; - rm.output[i].x.should.be == sizeX; + rm.output[i].x.should.be == width; rm.output[i].y.should.be == 0; - rm.output[i].w.should.be == sizeX; + rm.output[i].w.should.be == width; rm.output[i].h.should.be == height; i++; rm.output[i].path[].should.be == [1]; - rm.output[i].x.should.be == 2*sizeX; + rm.output[i].x.should.be == 2*width; rm.output[i].y.should.be == 0; - rm.output[i].w.should.be == sizeX; + rm.output[i].w.should.be == width; rm.output[i].h.should.be == height; rm.output.length.should.be == 3; @@ -383,10 +378,8 @@ unittest model[0].collapsed = false; model[0].orientation = Orientation.Horizontal; - const width = 100; - const height = 9; - const spacing = 1; - const sizeX = width + spacing; + const width = 101; + const height = 10; // measure size { @@ -394,14 +387,14 @@ unittest model.traversalForward(data, mv); } - model.header_size.should.be == sizeX; + model.header_size.should.be == width; model.header_size.should.be == 101; model.size.should.be == 404; - model[0].header_size.should.be == sizeX; - model[0].i.size.should.be == sizeX; - model[0].f.size.should.be == sizeX; - model[0].size.should.be == 3*sizeX; + model[0].header_size.should.be == width; + model[0].i.size.should.be == width; + model[0].f.size.should.be == width; + model[0].size.should.be == 3*width; { auto rm = RelativeMeasurer(width, height); @@ -415,10 +408,10 @@ unittest printLogToSvg("horizontal.ArrayOfTrivialAggregates.1", 1, rm.output); auto expectedData = [ - TreePosition(0*sizeX, 0, sizeX, height, []), - TreePosition(1*sizeX, 0, sizeX, height, [0]), - TreePosition(2*sizeX, 0, sizeX, height, [0, 0]), - TreePosition(3*sizeX, 0, sizeX, height, [0, 1]), + TreePosition(0*width, 0, width, height, []), + TreePosition(1*width, 0, width, height, [0]), + TreePosition(2*width, 0, width, height, [0, 0]), + TreePosition(3*width, 0, width, height, [0, 1]), ]; rm.output.length.should.be == expectedData.length; @@ -456,9 +449,6 @@ unittest const width = 100; const height = 9; - const spacing = 1; - const sizeX = width + spacing; - const sizeY = height + spacing; // measure size { @@ -466,14 +456,14 @@ unittest model.traversalForward(data, mv); } - model.header_size.should.be == sizeY; - model.header_size.should.be == 10; - model.size.should.be == 20; + model.header_size.should.be == height; + model.header_size.should.be == 9; + model.size.should.be == 18; - model[0].header_size.should.be == sizeX; - model[0].i.size.should.be == sizeX; - model[0].f.size.should.be == sizeX; - model[0].size.should.be == 3*sizeX; + model[0].header_size.should.be == width; + model[0].i.size.should.be == width; + model[0].f.size.should.be == width; + model[0].size.should.be == 3*width; { auto rm = RelativeMeasurer(width, height); @@ -487,10 +477,10 @@ unittest printLogToSvg("horizontal.ArrayOfTrivialAggregates.2", 1, rm.output); auto expectedData = [ - TreePosition( 0 + 0*sizeX, 0, width, sizeY, []), // TODO instead of width should be sizeX - TreePosition(15 + 0*sizeX, sizeY, sizeX, sizeY, [0]), - TreePosition(15 + 1*sizeX, sizeY, sizeX, sizeY, [0, 0]), - TreePosition(15 + 2*sizeX, sizeY, sizeX, sizeY, [0, 1]), + TreePosition( 0 + 0*width, 0, width, height, []), // TODO instead of width should be width + TreePosition(15 + 0*width, height, width, height, [0]), + TreePosition(15 + 1*width, height, width, height, [0, 0]), + TreePosition(15 + 2*width, height, width, height, [0, 1]), ]; rm.output.length.should.be == expectedData.length; @@ -531,10 +521,7 @@ unittest model[2].collapsed = false; const width = 100; - const height = 9; - const spacing = 1; - const sizeX = width + spacing; - const sizeY = height + spacing; + const height = 10; // measure size { @@ -542,20 +529,20 @@ unittest model.traversalForward(data, mv); } - model[0].header_size.should.be == sizeY; - model[0].i.size.should.be == sizeY; - model[0].f.size.should.be == sizeY; - model[0].size.should.be == 3*sizeY; + model[0].header_size.should.be == height; + model[0].i.size.should.be == height; + model[0].f.size.should.be == height; + model[0].size.should.be == 3*height; - model[1].header_size.should.be == sizeX; - model[1].i.size.should.be == sizeX; - model[1].f.size.should.be == sizeX; - model[1].size.should.be == 3*sizeX; + model[1].header_size.should.be == width; + model[1].i.size.should.be == width; + model[1].f.size.should.be == width; + model[1].size.should.be == 3*width; - model[2].header_size.should.be == sizeY; - model[2].i.size.should.be == sizeY; - model[2].f.size.should.be == sizeY; - model[2].size.should.be == 3*sizeY; + model[2].header_size.should.be == height; + model[2].i.size.should.be == height; + model[2].f.size.should.be == height; + model[2].size.should.be == 3*height; model.header_size.should.be == 10; model.size.should.be == 80; @@ -576,70 +563,70 @@ unittest rm.output[i].x.should.be == 0; rm.output[i].y.should.be == 0; rm.output[i].w.should.be == width; - rm.output[i].h.should.be == sizeY; + rm.output[i].h.should.be == height; i++; rm.output[i].path[].should.be == [0]; rm.output[i].x.should.be == 15; rm.output[i].y.should.be == 10; rm.output[i].w.should.be == width - rm.output[i].x; - rm.output[i].h.should.be == sizeY; + rm.output[i].h.should.be == height; i++; rm.output[i].path[].should.be == [0, 0]; rm.output[i].x.should.be == 30; rm.output[i].y.should.be == 20; rm.output[i].w.should.be == width - rm.output[i].x; - rm.output[i].h.should.be == sizeY; + rm.output[i].h.should.be == height; i++; rm.output[i].path[].should.be == [0, 1]; rm.output[i].x.should.be == 30; rm.output[i].y.should.be == 30; rm.output[i].w.should.be == width - rm.output[i].x; - rm.output[i].h.should.be == sizeY; + rm.output[i].h.should.be == height; i++; rm.output[i].path[].should.be == [1]; rm.output[i].x.should.be == 15; rm.output[i].y.should.be == 40; - rm.output[i].w.should.be == sizeX; - rm.output[i].h.should.be == sizeY; + rm.output[i].w.should.be == width; + rm.output[i].h.should.be == height; i++; rm.output[i].path[].should.be == [1, 0]; - rm.output[i].x.should.be == 15 + sizeX; + rm.output[i].x.should.be == 15 + width; rm.output[i].y.should.be == 40; - rm.output[i].w.should.be == sizeX; - rm.output[i].h.should.be == sizeY; + rm.output[i].w.should.be == width; + rm.output[i].h.should.be == height; i++; rm.output[i].path[].should.be == [1, 1]; - rm.output[i].x.should.be == 15 + 2*sizeX; // размер первого элемента плюс размер второго + rm.output[i].x.should.be == 15 + 2*width; // размер первого элемента плюс размер второго rm.output[i].y.should.be == 40; - rm.output[i].w.should.be == sizeX; - rm.output[i].h.should.be == sizeY; + rm.output[i].w.should.be == width; + rm.output[i].h.should.be == height; i++; rm.output[i].path[].should.be == [2]; rm.output[i].x.should.be == 15; rm.output[i].y.should.be == 50; rm.output[i].w.should.be == width - rm.output[i].x; - rm.output[i].h.should.be == sizeY; + rm.output[i].h.should.be == height; i++; rm.output[i].path[].should.be == [2, 0]; rm.output[i].x.should.be == 30; rm.output[i].y.should.be == 60; rm.output[i].w.should.be == width - rm.output[i].x; - rm.output[i].h.should.be == sizeY; + rm.output[i].h.should.be == height; i++; rm.output[i].path[].should.be == [2, 1]; rm.output[i].x.should.be == 30; rm.output[i].y.should.be == 70; rm.output[i].w.should.be == width - rm.output[i].x; - rm.output[i].h.should.be == sizeY; + rm.output[i].h.should.be == height; i++; } (); }