MCPcopy Create free account
hub / github.com/SolarLune/masterplan / Update

Method Update

gui.go:2830–2901  ·  view source on GitHub ↗

Update takes the Y position to set the row to update and draw

(yPos float32)

Source from the content-addressed store, hash-verified

2828
2829// Update takes the Y position to set the row to update and draw
2830func (row *ContainerRow) Update(yPos float32) float32 {
2831
2832 x := row.Container.Rect.X
2833 y := row.Container.Rect.Y + float32(yPos)
2834
2835 row.rect.X = x - 32 + row.HorizontalMargin
2836 row.rect.Y = y
2837
2838 usedWidth := float32(0)
2839 maxWidth := row.Container.Rect.W - (row.HorizontalMargin * 2)
2840 yHeight := float32(0)
2841
2842 if row.ForcedSize.Y != 0 {
2843 usedWidth = row.ForcedSize.X
2844 yHeight = row.ForcedSize.Y
2845 } else {
2846
2847 for _, element := range row.Elements {
2848
2849 rect := element.Rectangle()
2850 usedWidth += rect.W + row.HorizontalSpacing
2851 if yHeight < rect.H {
2852 yHeight = rect.H
2853 }
2854 }
2855
2856 }
2857
2858 diff := (maxWidth - usedWidth)
2859 if diff < 0 {
2860 diff = 0
2861 }
2862 if row.Alignment == AlignCenter {
2863 x += diff / 2
2864 } else if row.Alignment == AlignRight {
2865 x += diff
2866 }
2867
2868 for _, element := range row.ElementOrder {
2869 if !row.ExpandElementSet.Contains(element) {
2870 maxWidth -= element.Rectangle().W
2871 }
2872 }
2873
2874 totalElementSize := float32(len(row.ElementOrder))
2875
2876 if row.ExpandElementSet.On {
2877 totalElementSize = float32(len(row.ExpandElementSet.Elements))
2878 }
2879
2880 for _, element := range row.ElementOrder {
2881 rect := element.Rectangle()
2882
2883 rect.X = x
2884 rect.Y = y
2885
2886 if row.ExpandElementSet.On && row.ExpandElementSet.Contains(element) {
2887 rect.W = maxWidth / totalElementSize

Callers

nothing calls this directly

Calls 4

RectangleMethod · 0.65
SetRectangleMethod · 0.65
UpdateMethod · 0.65
ContainsMethod · 0.45

Tested by

no test coverage detected