MCPcopy Create free account
hub / github.com/BlueAndi/Pixelix / alignWidget

Method alignWidget

lib/YAWidgets/src/BitmapWidget.cpp:206–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204 *****************************************************************************/
205
206void BitmapWidget::alignWidget()
207{
208 uint16_t imageWidth = 0U;
209 uint16_t imageHeight = 0U;
210
211 switch (m_imgType)
212 {
213 case IMG_TYPE_NO_IMAGE:
214 break;
215
216 case IMG_TYPE_BMP:
217 imageWidth = m_bitmap.getWidth();
218 imageHeight = m_bitmap.getHeight();
219 break;
220
221 case IMG_TYPE_GIF:
222 imageWidth = m_gifPlayer.getWidth();
223 imageHeight = m_gifPlayer.getHeight();
224 break;
225
226 default:
227 break;
228 }
229
230 switch (m_hAlign)
231 {
232 case Alignment::Horizontal::HORIZONTAL_LEFT:
233 m_hAlignPosX = 0;
234 break;
235
236 case Alignment::Horizontal::HORIZONTAL_CENTER:
237 m_hAlignPosX = (m_canvas.getWidth() - imageWidth) / 2;
238 break;
239
240 case Alignment::Horizontal::HORIZONTAL_RIGHT:
241 m_hAlignPosX = m_canvas.getWidth() - imageWidth;
242 break;
243
244 default:
245 break;
246 }
247
248 switch (m_vAlign)
249 {
250 case Alignment::Vertical::VERTICAL_TOP:
251 m_vAlignPosY = 0;
252 break;
253
254 case Alignment::Vertical::VERTICAL_CENTER:
255 m_vAlignPosY = (m_canvas.getHeight() - imageHeight) / 2;
256 break;
257
258 case Alignment::Vertical::VERTICAL_BOTTOM:
259 m_vAlignPosY = m_canvas.getHeight() - imageHeight;
260 break;
261
262 default:
263 break;

Callers

nothing calls this directly

Calls 2

getWidthMethod · 0.45
getHeightMethod · 0.45

Tested by

no test coverage detected