horizontal
| 65 | |
| 66 | template<> // horizontal |
| 67 | void 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 | |
| 99 | template<> // vertical |
| 100 | void Layout<false>::setSize(const uint height, const uint padding) |