ScrollGroupBegin() is not work in GeUserArea()

I have custom user area for showing multiple images ( like content browser layout in c4d )
And i want to scroll the user area, so i use ScrollGroupBegin() in CreateLayout() but its not work

Here is example code:

class MyUa(gui.GeUserArea):

    def DrawMsg(self, x1, y1, x2, y2, msg):
        self.OffScreenOn()
        self.SetClippingRegion(x1, y1, x2, y2)
        self.DrawSetPen(c4d.COLOR_BG)
        self.DrawRectangle(x1, y1, x2, y2)
        ...

    def GetMinSize(self):
        return self.GetWidth(), self.GetHeight()
    
class MyDialog(gui.GeDialog):
    UA = MyUa() # UserArea
    
    def CreateLayout(self):
        self.ScrollGroupBegin(5555, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 
                              c4d.SCROLLGROUP_VERT)
        self.AddUserArea(6666, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT)
        self.AttachUserArea(self.UA, 6666)
        self.GroupEnd()
        return True

I'm trying to change GetMinSize like this;

def GetMinSize(self):
    return 800, 500

it does create the scrollbar, but the vertical range of the scrollbar is limited to the values in GetMinSize, the contents in UserArea are not fully displayed, I'm not quite sure how do I set GetMinSize?
Help me please!

Hello?is anyone here?😄

Hello @gheyret,

thank you for reaching out to us. Please note that we do state in our forum guidelines under Support Procedures:

Support requests will be discussed by us internally and then be assigned to a team member. Because of that new topics will take at least one day to be answered. This procedure is in place so that each support request can benefit from the combined knowledge of the SDK team, and subsequently give the development community the best support possible.

About your question: The minimum size of an element has to be determined by you and depends on the subject of your UserArea. If you would implement for example a multiline textbox, then a sensible minimum height could be the number of pixels that that element requires to display a single line of characters and the minimum width would be an arbitrary value, you could say for example it should be at least n pixels wide, so that it can at least render m characters.

There are also some problems with how you have setup the draw method of your user area. See the example snippet at the end for details.

I hope this helps and cheers,
Ferdinand

The result:
red_box.gif
The code:

"""Example for drawing inside an UserArea.

If I do understand your question correctly, the problem of yours has little 
to do with the scroll group, but more with how to draw something inside an 
UserArea. See MyUserArea for details.

This example can be run in the script manger, and will create a dialog with
an UserArea in it that contains a scrollable red box.

As discussed in:
    plugincafe.maxon.net/topic/13575/
"""

import c4d

class MyUserArea(c4d.gui.GeUserArea):
    """Renders a little red box on the canvas.
    """

    def DrawMsg(self, x1, y1, x2, y2, msg):
        """Called to draw the user area.
        """
        # Ensure we only draw within the visible area.
        self.SetClippingRegion(x1, y1, x2, y2)
        # The UserArea is being cached, so we first have to fill the area
        # with a solid color.
        self.DrawSetPen(c4d.COLOR_BG)
        self.DrawRectangle(x1, y1, x2, y2)

        # Now we are going to draw something, so that we can see some
        # scrolling. Just a little red box that goes over the full width of
        # the user area, but only from the height 200 to 400.
        self.DrawSetPen(c4d.Vector(1, 0, 0))
        self.DrawRectangle(x1, 200, x2, 400)

    def GetMinSize(self):
        """Signalizes the minimum size to a hosting element.

        The min size reflects the size below which a parent dialog cannot
        shrink its content area. In this case the height has to be at least
        400 pixels, because that is where our red box does end.
        """
        return (0, 400)

class MyDialog(c4d.gui.GeDialog):
    """Presents an instance of our MyUserArea.
    """
    _userArea = MyUserArea()

    def CreateLayout(self):
        """Creates the elements of the dialog after it has been initialized.
        """
        self.ScrollGroupBegin(1000, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT,
                              c4d.SCROLLGROUP_VERT)
        self.AddUserArea(1002, c4d.BFH_SCALEFIT|c4d.BFH_SCALEFIT)
        self.AttachUserArea(MyDialog._userArea, 1002)
        self.GroupEnd()
        return True


if __name__ == "__main__":
    # Little hack to handle an async dialog in the script manager, please do
    # not use this in a production environment.
    global dlg
    dlg = MyDialog()
    dlg.Open(c4d.DLG_TYPE_ASYNC)

@ferdinand Mmmm...I still don't get it... there have a GIF to my problem;
p.gif

I set the minimum value of height to 400 in the GetMinSize() like this:

def GetMinSize(self):
    return 0, 400

It does create the scrollbar, but the vertical range of the scrollbar is limited to 400,this prevents me from using the scroll bar to scroll down to see my all sunjects in the UserArea.
So how do I set the GetMinSize() so that the scrollbar exactly matches UserArea?

Hello @gheyret,

please read the answer I did give above; it is all explained there. Four hundred was the value one must set it to in my example, because that was the height of the content in the example. Only you can answer what that minimum height is in your case, it will be the sum of the heights of all your images in your user area plus the margins between them. If you set the minimum height to a lower value, the wrapping scroll group will squish your user area to that size and therefore make it impossible for you to scroll there, since the lower parts are never being rendered.

Cheers,
Ferdinand

@ferdinand I will handle it.
Thanks for your help!
Cheers~