Skip to content

Commit

Permalink
Get rid of spacing in models
Browse files Browse the repository at this point in the history
because it should be implemented in other way
  • Loading branch information
drug007 committed Oct 17, 2024
1 parent 26d95d4 commit e87fd37
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 108 deletions.
4 changes: 2 additions & 2 deletions auxil/source/auxil/default_visitor.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion auxil/source/auxil/model/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions auxil/source/auxil/model/state.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -58,7 +57,6 @@ mixin template StateScalar()
{
import auxil.common : SizeType, Orientation;

enum Spacing = 1;
SizeType sizeYM = 0;
alias headerSizeY = sizeYM;

Expand Down
35 changes: 17 additions & 18 deletions auxil/source/auxil/test.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down
Loading

0 comments on commit e87fd37

Please sign in to comment.