Hello,
I'm trying to resize a GeUserArea within a ScrollGroup with a gui Slider. The GeUserArea's border is not being redrawn properly in my script as I don't think I'm calling the Redraw()
/ LayoutChanged()
in the correct way: it's drawing unwanted lines as I drag the slider and scrollbar.
I just want one solid border. The extra borders go away upon release of the Slider handle but are persistent with the scrollbar. Where would be the right place to call Redraw (or is something else causing the problem)? Thank you!
import c4d
from c4d import gui
class ExampleUserArea(c4d.gui.GeUserArea):
def __init__(self, x, y, width, height):
super(ExampleUserArea, self).__init__()
self.x = x
self.y = y
self.width = width
self.height = height
self.Redraw()
def DrawMsg(self, x1, y1, x2, y2, msg) :
self.OffScreenOn()
self.SetClippingRegion(x1, y1, x2, y2)
self.DrawRectangle(x1, y1, x2, y2)
self.DrawBorder(c4d.BORDER_IN, x1, y1, x2, y2)
def GetMinSize(self):
return self.width, self.height
def InputEvent(self, msg) :
self.Redraw()
return True
class ExampleDialog(c4d.gui.GeDialog):
ID_SLIDER = 10000
ID_UA = 10001
ID_SCROLLGRP = 10002
def __init__(self):
pass
def Command(self, id, data):
if id == self.ID_SLIDER:
self.ua.height = int(self.GetFloat(self.ID_SLIDER))
print(self.ua.width,self.ua.height)
self.ua.LayoutChanged()
return True
def CreateLayout(self):
self.SetTitle("Scrolling UserArea Example")
self.AddSlider(self.ID_SLIDER, c4d.BFH_SCALEFIT | c4d.BFV_BOTTOM, 10)
self.SetFloat(self.ID_SLIDER, 200, 1, 1000, 1)
if self.ScrollGroupBegin(self.ID_SCROLLGRP, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, scrollflags=c4d.SCROLLGROUP_VERT):
self.ua = ExampleUserArea(0,0,200,200)
self.AddUserArea(self.ID_UA, c4d.BFH_LEFT | c4d.BFV_TOP)
self.AttachUserArea(self.ua, self.ID_UA)
self.GroupEnd()
self.ua.Redraw()
return True
def main():
dlg = ExampleDialog()
dlg.Open(c4d.DLG_TYPE_MODAL_RESIZEABLE, xpos=-2, ypos=-2, defaultw=400, defaulth=400)
if __name__=='__main__':
main()