Skip to content

Commit

Permalink
Merge pull request #15 from pd-robgee/bugfix/room-for-name
Browse files Browse the repository at this point in the history
Component: Fixed bug where the height of the name was not taken into account.
  • Loading branch information
ogheorghies authored Jan 17, 2020
2 parents 04e56a9 + 96276fd commit a68e9ae
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/metauml_component.mp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ _metauml_component_mp:=1;
% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times,
% but this macro makes sure that MetaPost won't try to load the file and display a message for that.
def inputonce text libraryFile=
if not known scantokens ("_" & str libraryFile & "_mp"):
%includeonce% show "Loading " & str libraryFile;
scantokens ("input " & str libraryFile);
else:
%includeonce% show str libraryFile & " already loaded.";
fi;
if not known scantokens ("_" & str libraryFile & "_mp"):
%includeonce% show "Loading " & str libraryFile;
scantokens ("input " & str libraryFile);
else:
%includeonce% show str libraryFile & " already loaded.";
fi;
enddef;

inputonce metauml_defaults;
Expand Down Expand Up @@ -113,14 +113,14 @@ vardef Component_layout@#=
else:
@#contentWidth = lmax(@#nameStack.width, @#subItems.width);
fi;

@#width = @#contentWidth + @#info.left + @#info.right + 15;

if @#nSubItems = 0:
@#height = @#info.top + @#info.bottom + @#subItems.height + 15;
@#height = @#info.top + @#info.bottom + @#nameStack.height + @#subItems.height;
@#nameStack.n = @#n - (0, 7);
else:
@#height = @#info.top + @#info.bottom + @#subItems.height + 30;
@#height = @#info.top + @#info.bottom + @#nameStack.height + @#subItems.height + 15;
@#nameStack.n = @#n + (0, @#info.top) - (0, 5);
fi;

Expand All @@ -143,20 +143,19 @@ vardef Component_draw@#=

fill @#border withcolor @#info.foreColor;
draw @#border withcolor @#info.borderColor;

drawComponentVisualStereotype(@#ne);

drawObject(@#nameStack);
drawObject(@#subItems);

enddef;

vardef drawComponentVisualStereotype(text ne)=
% lud = left-up-down of the top-right rectangle; luu = left-up-up of the top-right rectangle etc.
pair lud, luu, ru, rd, ldd, ldu, lmd, lmu;
% urectld = upper rectangle left-down, lrectru = lower rectangle right-up
pair urectld, urectlu, urectru, urectrd, lrectld, lrectlu, lrectru, lrectrd;
lud = ne - (14, 5 );
lud = ne - (14, 5 );
luu = lud + (0, 2 );
ru = luu + (8, 0 );
rd = ru - (0, 14);
Expand Down

0 comments on commit a68e9ae

Please sign in to comment.