Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    How to create splitted dialog window

    Cinema 4D SDK
    2
    5
    693
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • mikeudinM
      mikeudin
      last edited by

      Hello guys!
      I have to make command plugin dialog window like on this example. How to add two groups with possibility to change size of two separated zones by dragging divider. Thank you!

      ca2f21b4-eb12-4e1d-a4fc-4ca228fd994b-image.png

      Checkout my python tutorials, plugins, scripts, xpresso presets and more
      https://mikeudin.net

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        https://developers.maxon.net/docs/py/2023_2/modules/c4d.gui/GeDialog/index.html#GeDialog.GroupWeightsLoad

        I will come back with a proper reply when the SDK Team is back from holiday.
        Have a happy new year!
        Cheers,
        Maxime. 🙂

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        mikeudinM 1 Reply Last reply Reply Quote 0
        • mikeudinM
          mikeudin @m_adam
          last edited by

          @m_adam said in How to create splitted dialog window:

          happy new year!

          Thank you!

          Checkout my python tutorials, plugins, scripts, xpresso presets and more
          https://mikeudin.net

          1 Reply Last reply Reply Quote 0
          • M
            m_adam
            last edited by

            Hi @mikeudin sorry to not come back earlier I forget about it.

            Since I see it's still open I'm wondering if you have more questions about it.
            But in any case, here it's how it works.
            So you have to make a group with the flag c4d.BFV_GRIDGROUP_ALLOW_WEIGHTS then each element (gadget) of this group will have a dynamic size and can be dragged.
            Then you must define some default parameters (like how many columns the group has).
            This is done through a BaseContainer.
            Then GeDialog.GroupWeightsLoad will apply the data from the BaseContainer.

            Then to retrieve the new values defined when the user resizes something you can use GeDialog.GroupWeightsSave from the Message method by reacting to BFM_WEIGHTS_CHANGED.

            Find a complete GeDialog example bellow

            class MyDialog(c4d.gui.GeDialog):
            
                GRP_SUB = 10000
            
                def __init__(self):
                    # A BaseContainer that will store the information about weight information of the group.
                    # This is stored in a class member variable, this way if the dialog is closed and re-open 
                    # weight information will not be lost and restored as previously
                    self.groupWeights = c4d.BaseContainer()
                    
                def CreateLayout(self):
                    """
                    This method is called automatically when Cinema 4D Create the Layout (display) of the Dialog.
                    """
            
                    if self.GroupBegin(self.GRP_SUB, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 2, 0, "", c4d.BFV_GRIDGROUP_ALLOW_WEIGHTS):
                
                        self.AddStaticText(1000, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 0, 0, "1", c4d.BORDER_THIN_IN)
                        self.AddStaticText(1001, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 0, 0, "2", c4d.BORDER_THIN_IN)
                
                        self.AddStaticText(1002, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 0, 0, "3", c4d.BORDER_THIN_IN)
                        self.AddStaticText(1003, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 0, 0, "4", c4d.BORDER_THIN_IN)
                
                        self.AddStaticText(1004, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 0, 0, "5", c4d.BORDER_THIN_IN)
                        self.AddStaticText(1005, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 0, 0, "6", c4d.BORDER_THIN_IN)
                
                        self.AddEditNumberArrows(1006, c4d.BFH_SCALEFIT)
                    self.GroupEnd()
                    
                def InitValues(self):
                    """
                    This method is called automatically only the first time the instance dialog is opened after the GUI is initialized (CreateLayout).
                    """
                    
                    # Sets the columns, count has to be equal to the given layout (defined in CreateLayout, GroupBegin)
                    # Sum of all collums weight should be equal to 100.0
                    self.groupWeights.SetInt32(c4d.GROUPWEIGHTS_PERCENT_W_CNT, 2)     
                    self.groupWeights.SetFloat(c4d.GROUPWEIGHTS_PERCENT_W_VAL + 0, 25.0)  # weight for col 1
                    self.groupWeights.SetFloat(c4d.GROUPWEIGHTS_PERCENT_W_VAL + 1, 75.0)  # weight for col 2
            
                    # Sets the rows, count has to be equal to the given layout (defined in CreateLayout, GroupBegin)
                    # Sum of all rows weight should be equal to 100.0
                    self.groupWeights.SetInt32(c4d.GROUPWEIGHTS_PERCENT_H_CNT, 4)
                    self.groupWeights.SetFloat(c4d.GROUPWEIGHTS_PERCENT_H_VAL + 0, 10.0)  # weight for row 1
                    self.groupWeights.SetFloat(c4d.GROUPWEIGHTS_PERCENT_H_VAL + 1, 30.0)  # weight for row 2
                    self.groupWeights.SetFloat(c4d.GROUPWEIGHTS_PERCENT_H_VAL + 2, 60.0)  # weight for row 3
                    self.groupWeights.SetFloat(c4d.GROUPWEIGHTS_PERCENT_H_VAL + 3, 0.0)   # weight for row 4
            
                    # Defines the initial weight value of the group from the stored BaseContainer
                    self.GroupWeightsLoad(self.GRP_SUB, self.groupWeights)
                    
                    return True
                
                def Message(self, msg, result):
                    """
                    This method is called automatically when the GeDialog receives a Message.
            
                    :param msg: The message container.
                    :param result: A container to place results in.
                    """
                    # Checks if the receveid message is about a weight change
                    if msg.GetId() == c4d.BFM_WEIGHTS_CHANGED:
            
                        # Retrieves the dragged host group
                        if msg.GetInt32(c4d.BFM_WEIGHTS_CHANGED) == self.GRP_SUB:
            
                            # Stores the new weights values
                            self.groupWeights = self.GroupWeightsSave(self.GRP_SUB)
                            
                    return c4d.gui.GeDialog.Message(self, msg, result)
            

            Cheers,
            Maxime.

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

            mikeudinM 1 Reply Last reply Reply Quote 2
            • mikeudinM
              mikeudin @m_adam
              last edited by

              @m_adam said in How to create splitted dialog window:

              But in any case, here it's how it works.

              Thank you very much, Maxime! Great example!

              Checkout my python tutorials, plugins, scripts, xpresso presets and more
              https://mikeudin.net

              1 Reply Last reply Reply Quote 0
              • First post
                Last post