mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 08:14:58 +01:00
canvas: actually follow CSS conventions for 1/2/3/4 arguments in padding
This commit is contained in:
parent
5eee8bf1a3
commit
c952c57a99
1 changed files with 28 additions and 10 deletions
|
|
@ -222,19 +222,37 @@ struct FourDimensions {
|
||||||
|
|
||||||
FourDimensions (Distance u, Distance r = -1., Distance d = -1., Distance l = -1.) {
|
FourDimensions (Distance u, Distance r = -1., Distance d = -1., Distance l = -1.) {
|
||||||
|
|
||||||
/* CSS style defaults: if only 1 value is givem, set all 4 to
|
/* CSS style defaults: see https://developer.mozilla.org/en-US/docs/Web/CSS/Shorthand_properties
|
||||||
* that value; if 2 values are supplied, up uses the first,
|
|
||||||
* other 3 use the second; if 3 values are supplied, up uses
|
|
||||||
* the first, right uses the second, other 2 use the
|
|
||||||
* third. etc.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Distance last = u;
|
std::vector<Distance> args;
|
||||||
|
|
||||||
up = u;
|
args.push_back (u);
|
||||||
if (r >= 0) { last = r; } right = last;
|
|
||||||
if (d >= 0) { last = d; } down = last;
|
if (r >= 0) { args.push_back (r); }
|
||||||
if (l >= 0) { last = l; } left = last;
|
if (d >= 0) { args.push_back (d); }
|
||||||
|
if (l >= 0) { args.push_back (l); }
|
||||||
|
|
||||||
|
switch (args.size()) {
|
||||||
|
case 1:
|
||||||
|
up = right = down = left = args[0];
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
up = down = args[0];
|
||||||
|
left = right = args[1];
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
up = args[0];
|
||||||
|
left = right = args[1];
|
||||||
|
down = args[2];
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
up = args[0];
|
||||||
|
right = args[1];
|
||||||
|
down = args[2];
|
||||||
|
left = args[3];
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue