Clicking Group Children Causes Bitmap to Redraw Incorrectly



  • Hello,
    I have a bitmap in a main GeDialog group. When I click on either the child of another group within the main group or the bitmap itself, the bitmap redraws several times vertically incorrectly. It can be reset by resizing the window. You can see a quick screencast of the faulty behavior here. Can someone please help me fix this? Thank you very much!

    Before.jpg
    Error.jpg

    Here is the random image, "random_img.jpg", that I used: random_img.jpg
    This script looks for it on the Desktop.

    import  c4d,os
    from c4d import gui, plugins, bitmaps
    
    class BitmapUserArea(c4d.gui.GeUserArea) :
        def __init__(self,x,y,imageName) :
            self.x = x
            self.y = y
            fn = c4d.storage.GeGetC4DPath(c4d.C4D_PATH_DESKTOP)
            image = "random_img.jpg"
            path = os.path.join(fn,image)
            self.bmp = c4d.bitmaps.BaseBitmap()
            if self.bmp.InitWith(path)[0] != c4d.IMAGERESULT_OK:
                c4d.gui.MessageDialog("Cannot load image "" + path + "".")
                return
    
        def DrawMsg(self, x1, y1, x2, y2, msg) :
            self.OffScreenOn()
            self.DrawSetPen(c4d.COLOR_BG)
            self.DrawRectangle(x1, y1, x2, y2)
            self.SetClippingRegion(x1, y1, x2, y2)
            self.width, self.height = self.bmp.GetSize()
            self.DrawBitmap(self.bmp, x1 + self.x, y1 + self.y, self.width,
                            self.height, 0, 0, self.width, self.height,
                            c4d.BMP_NORMAL | c4d.BMP_ALLOWALPHA)
    
        def GetMinSize(self):
            self.width, self.height = self.bmp.GetSize()
            return self.width, self.height
    
    class MyDialog(c4d.gui.GeDialog) :
        ID_MAIN_GRP = 20000
        ID_BMP_USERAREA = 20002
        ID_TXT1 = 20004
        ID_TXT2 = 20006
    
        def __init__(self):
            self.randomImage = BitmapUserArea(0, 0, "random_img.jpg")
    
        def CreateLayout(self) : 
            self.SetTitle("MyDialog")
            if self.GroupBegin(self.ID_MAIN_GRP, c4d.BFH_SCALEFIT | c4d.BFV_TOP, cols=3,
                                rows=1, title=""):
                self.GroupBorderSpace(5, 5, 5, 5)
                self.GroupBorderNoTitle(c4d.BORDER_BLACK)
                self.AddUserArea(self.ID_BMP_USERAREA, c4d.BFH_CENTER | c4d.BFH_SCALE | c4d.BFV_CENTER |c4d.BFV_SCALE, initw=142, inith=52)
                self.AttachUserArea(self.randomImage, self.ID_BMP_USERAREA)
                self.AddStaticText(self.ID_TXT1, c4d.BFH_CENTER | c4d.BFH_SCALE | c4d.BFV_CENTER |c4d.BFV_SCALE, 0, 0, "TEXT 1", borderstyle=c4d.BORDER_BLACK)
                self.AddStaticText(self.ID_TXT2, c4d.BFH_CENTER | c4d.BFH_SCALE | c4d.BFV_CENTER |c4d.BFV_SCALE, 0, 0, "TEXT 2", borderstyle=c4d.BORDER_BLACK)
            return True
    
    def main() :
        global dialog
        dialog = MyDialog()
        dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, xpos=-2, ypos=-2, defaultw=350, defaulth=500)
    
    if __name__=='__main__':
        main()
    


  • Hi @blastframe, Thanks for reporting the issue.
    Actually it's very similar to R21 GeUserArea in docked GeDialog behaves differently but as stated to the other topic, I don't have any news on that, I will bump development team again.

    So not the safest but as a workaround ignore the x,y, x2, y2 passed and draw with the data you defined in GetMinSize.
    Of course, this has the limitation that scroll groups are not anymore supported, but its the only workaround I see for the moment.

    Cheers,
    Maxime.



  • Hi @blastframe, Thanks for reporting the issue.
    Actually it's very similar to R21 GeUserArea in docked GeDialog behaves differently but as stated to the other topic, I don't have any news on that, I will bump development team again.

    So not the safest but as a workaround ignore the x,y, x2, y2 passed and draw with the data you defined in GetMinSize.
    Of course, this has the limitation that scroll groups are not anymore supported, but its the only workaround I see for the moment.

    Cheers,
    Maxime.



  • @m_adam Thanks, Maxime, for the temporary workaround and for bumping it to the development team. I hope this is fixed soon!