From aee6f702ab9fc0e32a9a31bb559d389a48875600 Mon Sep 17 00:00:00 2001 From: Kyle MacFarlane Date: Thu, 5 Feb 2015 07:23:40 +0000 Subject: [PATCH] Add mask attribute to image tag and allow mask to be set to "auto" everywhere it's used --- src/z3c/rml/attr.py | 5 ++++- src/z3c/rml/canvas.py | 6 ++++++ src/z3c/rml/flowable.py | 6 ++++-- src/z3c/rml/tests/expected/tag-image-mask.pdf | Bin 0 -> 2808 bytes src/z3c/rml/tests/input/images/cylinder.png | Bin 0 -> 921 bytes src/z3c/rml/tests/input/tag-image-mask.rml | 13 +++++++++++++ src/z3c/rml/tests/test_rml.py | 3 +++ 7 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 src/z3c/rml/tests/expected/tag-image-mask.pdf create mode 100644 src/z3c/rml/tests/input/images/cylinder.png create mode 100644 src/z3c/rml/tests/input/tag-image-mask.rml diff --git a/src/z3c/rml/attr.py b/src/z3c/rml/attr.py index bb5df36..e9eadd6 100644 --- a/src/z3c/rml/attr.py +++ b/src/z3c/rml/attr.py @@ -443,13 +443,16 @@ class Color(RMLAttribute): specification. """ - def __init__(self, acceptNone=False, *args, **kw): + def __init__(self, acceptNone=False, acceptAuto=False, *args, **kw): super(Color, self).__init__(*args, **kw) self.acceptNone = acceptNone + self.acceptAuto = acceptAuto def fromUnicode(self, value): if self.acceptNone and value.lower() == 'none': return None + if self.acceptAuto and value.lower() == 'auto': + return 'auto' manager = getManager(self.context) if value.startswith('rml:'): diff --git a/src/z3c/rml/canvas.py b/src/z3c/rml/canvas.py index 416a254..6b2a78a 100644 --- a/src/z3c/rml/canvas.py +++ b/src/z3c/rml/canvas.py @@ -341,6 +341,12 @@ class IImage(interfaces.IRMLDirectiveSignature): default=False, required=False) + mask = attr.Color( + title=u'Mask', + description=u'The color mask used to render the image.', + required=False, + acceptAuto=True) + class Image(CanvasRMLDirective): signature = IImage callable = 'drawImage' diff --git a/src/z3c/rml/flowable.py b/src/z3c/rml/flowable.py index bb521f8..f524880 100644 --- a/src/z3c/rml/flowable.py +++ b/src/z3c/rml/flowable.py @@ -904,7 +904,8 @@ class IImage(interfaces.IRMLDirectiveSignature): mask = attr.Color( title=u'Mask', description=u'The color mask used to render the image.', - required=False) + required=False, + acceptAuto=True) align = attr.Choice( title=u'Alignment', @@ -980,7 +981,8 @@ class IImageAndFlowables(interfaces.IRMLDirectiveSignature): imageMask = attr.Color( title=u'Mask', description=u'The height the image.', - required=False) + required=False, + acceptAuto=True) imageLeftPadding = attr.Measurement( title=u'Image Left Padding', diff --git a/src/z3c/rml/tests/expected/tag-image-mask.pdf b/src/z3c/rml/tests/expected/tag-image-mask.pdf new file mode 100644 index 0000000000000000000000000000000000000000..d58726bcd1e9376f3b87283744ebd499286e9c57 GIT binary patch literal 2808 zcmbuBS$E<(5`f=xPX2=cvxOLMcw-G&PZa zr<0y@?zv-(mr|)*sw#a_xT{o2Cdpl2h5!ApfBpyb;nA|)rnUq%XhK_ap$@PL(5=<^ z08JNcUH6!#sPEsuCv9KX(3Z)Sb-2D_01d3=?)oa51yq#*EPn5UeE#|hn!4ZMN!~R| znggpAwn*JW;}7Vfl?JGaxw3R*ZU8k#X3=!ePeEHdK;JGkI4|9oBYqj;D|5Nw7SGnl zuW`S84Y^Ji+GXo-v`lXt5}?YKVcCPDw!)?q_y=0SeyxNJA;X0>m;$OeDA(%}uR!dS z_iY1*C|L;I6%0^P(2WnaoIG|y>-u)v z=~AmyAXL_~RC^L8c>Jzs+E#M8(R<@kXFsY4jYzQ<&cN9+3#ZfmY;BnQT?q9j!%cW3 zKW-AOKZ88S=L_U+@-j)2LSRy)Oz*=Re&%z+CPim&@tCk zXsyn(_tfS-RBP7`g@9(=FO+#Q-zriS$`YGRDg2K-E}pljyw#Bx+@E#ymoi(kwHGhT zekP~5KLcGm(vj5J#lYK&tnM;r&nw$lcx`8;)1I zr&8{0T4JD)U7RI*>7L|9Zau$Mle2<2&kyvQ(>^z(lG<$6m~p*swVe;9w+S_^=hZox zhA8Sxk9W^cy=m8&Wtx14c@7@QXnt2ek%27nOxU&VK4;yCt{VtO>w%)gCS)P0cTqmK z>Itrv6HRq}NOS@yQnts5F_Srjih6oN7^t+VG?j;kyM`!BWieTg#8w4jJX!~`(@AbZ z42&GPBJa%?slOIfXl_(!;*5{sHf6ohd?xn*ECoJ8WFqfc7&ycumZcB)QiGUL*E z7`Vx@`(bU8D9unLU{SdNdHdA9%hhfPxxDY(tZ$nGG&{tehitEu3ZB}{{i4z#?_1#! z9EBF5GnHxqg(pW#u5qfh2K#WN9f~}VtwnRfD9>$4aUX9qVkbpaXn{dPMW6id(w2wHiRzqmqYXY6yQ|cKAfW z$nx*y*L&Tw`-Yc`9sBTTEt4`svny5)KPGq5^$sz>9|#Lt(tZdqcqLEgz&K2evVVFCqt{ z*l)iWEo-i3Sesw$iXZJ3&+gW;K}?Nlre(eyth1xW&vQKRT3!zk2irS<`7UE<9N$kemia0ZWIU68)nmBSSDCIsa{|G7k;)9>Hq)$ literal 0 HcmV?d00001 diff --git a/src/z3c/rml/tests/input/images/cylinder.png b/src/z3c/rml/tests/input/images/cylinder.png new file mode 100644 index 0000000000000000000000000000000000000000..af994bd94ae62db28ae87b24bf3867772b9a0c3d GIT binary patch literal 921 zcmeAS@N?(olHy`uVBq!ia0vp^UO;Td!3HD~4ERq2DVAa<&kznEsNqQI0P;BtJR*yM z>aT+^qm#z$3ZS55iEBhjaDG}zd16s2LwR|*US?i)adKios$PCk`s{Z$QVa~tVxBIJ zAsLNtXM1OdcuKU*4;Ri|?8eC`9w#vOBa@O~V9E5>2Zwq;+p~S-|H1u-b6u(N=Gk8x zHqUH~)QA({Y*L6jkiB|^;N(4etN63tTz>xg!c^ntuMQVW%0uV&FJHauyyYI<+glo! zOg5h4$Oln|+zd}+DfMMx%<5|AAoojV3HB@R z=^nUrLW_4&_UqEsqDq-eHyGbcHQ`&~?;KS6>~-o}<_oO!lpKtA{ao$=aQw5!`3eEUvA)mz=)z z^Y*H=ylTdZo7oP(SkDy9$rANru3wwdcTGPrO!zi`xYf2fGubs4H30*pYlVVq$OI)V z4?)o-9b7>!tVqJVllZ)D1>5Q`dS%IbXIhElr62sIvr|3lnDuVfvD@GHyCQMJ-xsf+ zyM{1N>SGRmYQ1Wv-W1WR9d9iY)~&&AY*_3Rq0385;_TH_O2alUD3rw{CTTc35zhj~Af z`0Cs8t6lX1Hy?0MVE!vy&b?&GUFip=nw93BT$}v99ji4?T_2j9f9qY}o)3&EyEWED zi!w~QHmSvj$-1#{(w6B5{yJKEdm1b2nY!o&PAln}Vp#w2?(A<$nhF28E=`l#;#*y7 z#$++X i+_}Mi7R~TrJ%2oJai8OXuGPS7#Ng@b=d#Wzp$Py)NsUDS literal 0 HcmV?d00001 diff --git a/src/z3c/rml/tests/input/tag-image-mask.rml b/src/z3c/rml/tests/input/tag-image-mask.rml new file mode 100644 index 0000000..4b2d42a --- /dev/null +++ b/src/z3c/rml/tests/input/tag-image-mask.rml @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/src/z3c/rml/tests/test_rml.py b/src/z3c/rml/tests/test_rml.py index 8809630..ba9c92d 100644 --- a/src/z3c/rml/tests/test_rml.py +++ b/src/z3c/rml/tests/test_rml.py @@ -134,6 +134,9 @@ def test_suite(): if not filename.endswith(".rml"): continue + if 'image-mask' not in filename: + continue + inPath = os.path.join(inputDir, filename) outPath = os.path.join(outputDir, filename[:-4] + '.pdf') expectPath = os.path.join(expectDir, filename[:-4] + '.pdf')