Hi,
I am trying to use UserArea to draw a simple 4x4 grid in a dialog, and docking it with the Timeline.
The issue is when I click around the UserArea and the Timeline(which is built-in UserArea??), top and bottom edges of the UserArea behave strangely.
And when I tweak the size of the dialog to redraw the UserArea, it returns to normal.
video:
https://drive.google.com/file/d/1arqRD-4y52WJfyI3QnlgN3oBpsuvfxcj/view?usp=sharing
.pyp:
import c4d
import os
PLUGIN_ID = 9366042 # Random Number
ID_UA = 1000
class TestUserArea(c4d.gui.GeUserArea):
def DrawMsg(self, x1, y1, x2, y2, msg):
self.OffScreenOn()
self.SetClippingRegion(x1, y1, x2, y2)
# Draw Background
black = c4d.Vector(0)
self.DrawSetPen(black)
self.DrawRectangle(x1, y1, x2, y2)
# Draw Grid
white = c4d.Vector(1)
self.DrawSetPen(white)
w = self.GetWidth()
h = self.GetHeight()
for i in range(5):
xpos = int(i*0.25*w)
self.DrawLine(xpos, y1, xpos, y2)
ypos = int(i*0.25*h)
self.DrawLine(x1, ypos, x2, ypos)
class TestDialog(c4d.gui.GeDialog):
def CreateLayout(self):
self.ua = TestUserArea()
self.AddUserArea(ID_UA, c4d.BFH_SCALEFIT|c4d.BFV_SCALEFIT)
self.AttachUserArea(self.ua, ID_UA)
return True
class TestData(c4d.plugins.CommandData):
dialog = None
def Execute(self, doc):
if self.dialog is None:
self.dialog = TestDialog()
return self.dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=PLUGIN_ID)
def RestoreLayout(self, sec_ref):
if self.dialog is None:
self.dialog = TestDialog()
return self.dialog.Restore(pluginid=PLUGIN_ID, secret=sec_ref)
if __name__ == "__main__":
path, file = os.path.split(__file__)
bmp = c4d.bitmaps.BaseBitmap()
bmp.InitWith(os.path.join(path, "res", "icon.tif"))
c4d.plugins.RegisterCommandPlugin(id=PLUGIN_ID, str="TestUserArea", info=0,
help="", dat=TestData(), icon=bmp)
The same issue can be seen with the official plugin sample Py-MemoryViewer.
In this one, Redraw() is called frequently, so it returns to normal display immediately.
https://drive.google.com/file/d/1vGgoPJ3ierUFBNdD92hUl7UuaKjkcE--/view?usp=sharing
I know that this issue is not that critical, but is there any solution? Thank you.