| 139 | } |
| 140 | |
| 141 | void CTouchControls::CTouchButton::UpdateBackgroundCorners() |
| 142 | { |
| 143 | if(m_Shape != EButtonShape::RECT) |
| 144 | { |
| 145 | m_BackgroundCorners = IGraphics::CORNER_NONE; |
| 146 | return; |
| 147 | } |
| 148 | |
| 149 | // Determine rounded corners based on button layout |
| 150 | m_BackgroundCorners = IGraphics::CORNER_ALL; |
| 151 | |
| 152 | if(m_UnitRect.m_X == 0) |
| 153 | { |
| 154 | m_BackgroundCorners &= ~IGraphics::CORNER_L; |
| 155 | } |
| 156 | if(m_UnitRect.m_X + m_UnitRect.m_W == BUTTON_SIZE_SCALE) |
| 157 | { |
| 158 | m_BackgroundCorners &= ~IGraphics::CORNER_R; |
| 159 | } |
| 160 | if(m_UnitRect.m_Y == 0) |
| 161 | { |
| 162 | m_BackgroundCorners &= ~IGraphics::CORNER_T; |
| 163 | } |
| 164 | if(m_UnitRect.m_Y + m_UnitRect.m_H == BUTTON_SIZE_SCALE) |
| 165 | { |
| 166 | m_BackgroundCorners &= ~IGraphics::CORNER_B; |
| 167 | } |
| 168 | |
| 169 | const auto &&PointInOrOnRect = [](ivec2 Point, CUnitRect Rect) { |
| 170 | return Point.x >= Rect.m_X && Point.x <= Rect.m_X + Rect.m_W && Point.y >= Rect.m_Y && Point.y <= Rect.m_Y + Rect.m_H; |
| 171 | }; |
| 172 | for(const CTouchButton &OtherButton : m_pTouchControls->m_vTouchButtons) |
| 173 | { |
| 174 | if(&OtherButton == this || OtherButton.m_Shape != EButtonShape::RECT || !OtherButton.IsVisible()) |
| 175 | continue; |
| 176 | |
| 177 | if((m_BackgroundCorners & IGraphics::CORNER_TL) && PointInOrOnRect(ivec2(m_UnitRect.m_X, m_UnitRect.m_Y), OtherButton.m_UnitRect)) |
| 178 | { |
| 179 | m_BackgroundCorners &= ~IGraphics::CORNER_TL; |
| 180 | } |
| 181 | if((m_BackgroundCorners & IGraphics::CORNER_TR) && PointInOrOnRect(ivec2(m_UnitRect.m_X + m_UnitRect.m_W, m_UnitRect.m_Y), OtherButton.m_UnitRect)) |
| 182 | { |
| 183 | m_BackgroundCorners &= ~IGraphics::CORNER_TR; |
| 184 | } |
| 185 | if((m_BackgroundCorners & IGraphics::CORNER_BL) && PointInOrOnRect(ivec2(m_UnitRect.m_X, m_UnitRect.m_Y + m_UnitRect.m_H), OtherButton.m_UnitRect)) |
| 186 | { |
| 187 | m_BackgroundCorners &= ~IGraphics::CORNER_BL; |
| 188 | } |
| 189 | if((m_BackgroundCorners & IGraphics::CORNER_BR) && PointInOrOnRect(ivec2(m_UnitRect.m_X + m_UnitRect.m_W, m_UnitRect.m_Y + m_UnitRect.m_H), OtherButton.m_UnitRect)) |
| 190 | { |
| 191 | m_BackgroundCorners &= ~IGraphics::CORNER_BR; |
| 192 | } |
| 193 | if(m_BackgroundCorners == IGraphics::CORNER_NONE) |
| 194 | { |
| 195 | break; |
| 196 | } |
| 197 | } |
| 198 | } |
no test coverage detected