Problem with custom attributes , parameters are not properly rendered

Hi all,
I have mad a custom component starting from an example file by @DavidRutten , everything worked fine for me and I am almost done with the new UI, . There are only couple of issues which I would rather post one by one.
First , the output parameter do not render properly as you can see in the screen shot.
Any help is appreciated.

protected override void Layout()
            {
                // draw basic layout
                base.Layout();
                GHCustomComponent owner = Owner as GHCustomComponent;
                if (owner.CustomControls.Values.Count == 0)
                    return;
                // we add the custom constrols to the buttom of each other in the same order they have been added to the dictionary 
                // the value buttom records the buttom postion of the controls as they are being added
                float buttom = Bounds.Bottom;
                
                // to find the overal widht of the component we find the maximum width of the customcontrols
                float maxWidth = Bounds.Width;
                foreach (IGHCustomControl item in owner.CustomControls.Values)
                {
                    float w = item.GetWidth();
                    if (maxWidth < w)
                        maxWidth = w;
                }
                foreach (IGHCustomControl item in owner.CustomControls.Values)
                {
                    
                    float h = item.GetHeight();
                    // set the item bounds , we expand the bounds by 2 units from each side 
                    item.Bounds = new RectangleF(Bounds.X, buttom, maxWidth, h);
                    buttom += h+_offset; // update the buttom value
                 
                }
                if (maxWidth > Bounds.Width)
                {
                    // update the output parameter layout  layout  
                    int paramWidth = Owner.Params.Output.Max(
                        p => GH_FontServer.StringWidth(
                            (CentralSettings.CanvasFullNames) ? p.Name : p.NickName
                            , GH_FontServer.Standard
                            )
                        );
                    LayoutOutputParams(Owner, new RectangleF(Bounds.X, Bounds.Y, maxWidth - paramWidth, Bounds.Height));
                }
                var corner = new PointF(Bounds.X - _offset, Bounds.Y - _offset);
                Bounds = new RectangleF(corner, new SizeF( maxWidth+2*_offset,Bounds.Height+ buttom- Bounds.Bottom+2*_offset));
            }

When you call base.Layout() way at the beginning the output parameter attributes are sized and positioned according to the original layout logic. If you then later grow the bounds of the component, it will not change the input/ output parameter bounds.

The easiest solution may be to just iterate over all outputs, get their attributes and move the bound rectangles.

1 Like

Thanks David, I thought I am doing that by calling LayoutOutputParams() , but apparently that’s not the right way ! I will now try to iterate over the outputs and see what I can do with that.
BTW, when I measure a string using the GH_FontServer to align my texts , I get different results in different screen resolution , why is that?