GeUserArea::DrawText() in R21 behaves different from previous releases?
-
Hello,
in R21, we have a strange issue when drawing text into a GeUserArea:
We first draw the background including the blue highlight rectangle under the third thumbnail. Then, in a loop, we draw all the thumbnails and the label texts. The text background seems to draw over the highlight rectangle, partly blocking it.
Setting the text drawing color is done like this:
DrawSetTextCol(COLOR_TEXT, COLOR_TRANS);
Then we draw the text like this:
DrawText(labelStr, labelPosX, labelPosY, DRAWTEXT_HALIGN_CENTER);
Questions:
- Why is the text background drawn even though COLOR_TRANS is used as background color?
- Why is the text background so much wider than the actual text? There are no leading or trailing spaces in labelStr.
- Why is the label text of the third thumbnail not blocking the highlight rectangle, even though it's drawn with the exact same code?
This works perfectly in all previous C4D releases.
Thanks in advance for advice,
greetings,
Frank -
Here I'm not able to reproduce the issue, could you share your code, please.
Since I'm pretty sure it's not language dependant I have made a quick test in python, but no success:import c4d GADGET_ID_GEUSERAREA = 10000 class ExampleGeUserArea(c4d.gui.GeUserArea): def DrawBackGround(self, pictId, bmp, selected=True): if selected: self.DrawSetPen(c4d.Vector(1, 0, 0)) self.DrawRectangle(pictId * 150, 5, (pictId + 1) * 150, 170) print pictId, pictId * 150 + 5, (pictId + 1) * 150 - 5 self.DrawBitmap(bmp, pictId * 150 + 5, 5, 145, 145, 0, 0, bmp.GetBw(), bmp.GetBh(), c4d.BMP_NORMALSCALED | c4d.BMP_ALLOWALPHA) def DrawTxt(self, pictId): self.DrawSetTextCol(c4d.COLOR_TEXT, c4d.COLOR_TRANS) self.DrawText("String for {}".format(pictId), (pictId + 1) * 150 - 75, 150, c4d.DRAWTEXT_HALIGN_CENTER) def DrawMsg(self, x1, y1, x2, y2, msg): self.DrawRectangle(x1, y1, x2, y2) obj = c4d.BaseObject(c4d.Ocube) bmp = obj.GetIconEx().GetGuiScalePart() for i in xrange(4): selected = True if i > 2 else False self.DrawBackGround(i, bmp, selected) self.DrawTxt(i) class ExampleDialog(c4d.gui.GeDialog): geUserArea = ExampleGeUserArea() def CreateLayout(self): self.AddUserArea(GADGET_ID_GEUSERAREA, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 100, 100) # Attaches the stored GeUserArea to the Gadget previously created self.AttachUserArea(self.geUserArea, GADGET_ID_GEUSERAREA) return True def main(): global dlg # Creates a new instance of the GeDialog dlg = ExampleDialog() # Opens the GeDialog, since it's open it as Modal, it block Cinema 4D dlg.Open(c4d.DLG_TYPE_ASYNC, defaultw=300, defaulth=50) if __name__ == "__main__": main()
If not possible to do it publicly, you can send us an email to [email protected]
Cheers,
Maxime. -
Hi Maxime,
thanks for trying! I'm also sure it's not specific to C++. I'll send you some code as soon as I find the time to strip it down.
Cheers,
Frank