MCPcopy Create free account
hub / github.com/DISTRHO/DPF / setSize

Method setSize

dgl/src/Layout.cpp:67–97  ·  view source on GitHub ↗

horizontal

Source from the content-addressed store, hash-verified

65
66template<> // horizontal
67void Layout<true>::setSize(const uint width, const uint padding)
68{
69 uint maxHeight = 0;
70 uint nonFixedWidth = width - padding * 2;
71 uint numDynamiclySizedWidgets = 0;
72
73 for (SubWidgetWithSizeHintIterator it = widgets.begin(), end = widgets.end(); it != end; ++it)
74 {
75 SubWidgetWithSizeHint& s(*it);
76 maxHeight = std::max(maxHeight, s.widget->getHeight());
77
78 if (s.sizeHint == Fixed)
79 nonFixedWidth -= s.widget->getWidth();
80 else
81 ++numDynamiclySizedWidgets;
82 }
83
84 if (const size_t numWidgets = widgets.size())
85 nonFixedWidth -= padding * static_cast<uint>(numWidgets - 1);
86
87 const uint widthPerWidget = numDynamiclySizedWidgets != 0 ? nonFixedWidth / numDynamiclySizedWidgets : 0;
88
89 for (SubWidgetWithSizeHintIterator it=widgets.begin(), end=widgets.end(); it != end; ++it)
90 {
91 SubWidgetWithSizeHint& s(*it);
92 if (s.sizeHint != Fixed)
93 s.widget->setSize(widthPerWidget, maxHeight);
94 else
95 s.widget->setHeight(maxHeight);
96 }
97}
98
99template<> // vertical
100void Layout<false>::setSize(const uint height, const uint padding)

Callers 1

adjustSizeMethod · 0.45

Calls 5

sizeMethod · 0.80
getHeightMethod · 0.45
getWidthMethod · 0.45
setHeightMethod · 0.45
setWidthMethod · 0.45

Tested by

no test coverage detected