| 68 | } |
| 69 | |
| 70 | void UIRelativeLayout::fixChildPos( UIWidget* widget ) { |
| 71 | Vector2f pos( widget->getPosition() ); |
| 72 | |
| 73 | if ( widget->getLayoutPositionPolicy() != PositionPolicy::None && |
| 74 | widget->getParent() == widget->getLayoutPositionPolicyWidget()->getParent() ) { |
| 75 | UIWidget* of = widget->getLayoutPositionPolicyWidget(); |
| 76 | |
| 77 | switch ( widget->getLayoutPositionPolicy() ) { |
| 78 | case PositionPolicy::LeftOf: |
| 79 | pos.x = of->getPosition().x - widget->getSize().getWidth() - |
| 80 | widget->getLayoutMargin().Right - of->getLayoutMargin().Left; |
| 81 | pos.y = of->getPosition().y + widget->getLayoutMargin().Top; |
| 82 | break; |
| 83 | case PositionPolicy::RightOf: |
| 84 | pos.x = of->getPosition().x + of->getSize().getWidth() + |
| 85 | widget->getLayoutMargin().Left + of->getLayoutMargin().Right; |
| 86 | pos.y = of->getPosition().y + widget->getLayoutMargin().Top; |
| 87 | break; |
| 88 | case PositionPolicy::TopOf: |
| 89 | pos.x = of->getPosition().x + widget->getLayoutMargin().Left; |
| 90 | pos.y = of->getPosition().y - widget->getSize().getHeight() - |
| 91 | widget->getLayoutMargin().Bottom - of->getLayoutMargin().Top; |
| 92 | break; |
| 93 | case PositionPolicy::BottomOf: |
| 94 | pos.x = of->getPosition().x + widget->getLayoutMargin().Left; |
| 95 | pos.y = of->getPosition().y + of->getSize().getHeight() + |
| 96 | widget->getLayoutMargin().Top + of->getLayoutMargin().Bottom; |
| 97 | break; |
| 98 | default: |
| 99 | break; |
| 100 | } |
| 101 | } else { |
| 102 | switch ( Font::getHorizontalAlign( widget->getLayoutGravity() ) ) { |
| 103 | case UI_HALIGN_CENTER: |
| 104 | pos.x = ( getSize().getWidth() - widget->getSize().getWidth() ) / 2 + |
| 105 | widget->getLayoutMargin().Left; |
| 106 | break; |
| 107 | case UI_HALIGN_RIGHT: |
| 108 | pos.x = getSize().getWidth() - widget->getSize().getWidth() - |
| 109 | widget->getLayoutMargin().Right - mPadding.Right; |
| 110 | break; |
| 111 | case UI_HALIGN_LEFT: |
| 112 | default: |
| 113 | pos.x = widget->getLayoutMargin().Left + mPadding.Left; |
| 114 | break; |
| 115 | } |
| 116 | |
| 117 | switch ( Font::getVerticalAlign( widget->getLayoutGravity() ) ) { |
| 118 | case UI_VALIGN_CENTER: |
| 119 | pos.y = ( getSize().getHeight() - widget->getSize().getHeight() ) / 2 + |
| 120 | widget->getLayoutMargin().Top; |
| 121 | break; |
| 122 | case UI_VALIGN_BOTTOM: |
| 123 | pos.y = getSize().getHeight() - widget->getSize().getHeight() - |
| 124 | widget->getLayoutMargin().Bottom - mPadding.Bottom; |
| 125 | break; |
| 126 | case UI_VALIGN_TOP: |
| 127 | default: |
nothing calls this directly
no test coverage detected