TouchGFX/gui/include/gui/containers/MenuElement.hpp #ifndef MENUELEMENT_HPP #define MENUELEMENT_HPP #include #include class MenuElement : public MenuElementBase { public: MenuElement(); virtual ~MenuElement() {} virtual void initialize(); void setNumber(int no) { Unicode::itoa(no, textBuffer, TEXT_SIZE, 10); switch (no % 7) { case 0: icon.setBitmap(Bitmap(BITMAP_ICON00_ID)); break; case 1: icon.setBitmap(Bitmap(BITMAP_ICON01_ID)); break; case 2: icon.setBitmap(Bitmap(BITMAP_ICON02_ID)); break; case 3: icon.setBitmap(Bitmap(BITMAP_ICON03_ID)); break; case 4: icon.setBitmap(Bitmap(BITMAP_ICON04_ID)); break; case 5: icon.setBitmap(Bitmap(BITMAP_ICON05_ID)); break; case 6: icon.setBitmap(Bitmap(BITMAP_ICON06_ID)); break; } } protected: }; #endif // MENUELEMENT_HPP Screen1View.hpp #ifndef SCREEN1VIEW_HPP #define SCREEN1VIEW_HPP #include #include class Screen1View : public Screen1ViewBase { public: Screen1View(); virtual ~Screen1View() {} virtual void setupScreen(); virtual void tearDownScreen(); virtual void scrollWheelUpdateItem(MenuElement& item, int16_t itemIndex) { item.setNumber(itemIndex); } protected: }; #endif // SCREEN1VIEW_HPP MenuElement.hpp #ifndef MENUELEMENT_HPP #define MENUELEMENT_HPP #include #include #include class MenuElement : public MenuElementBase { public: MenuElement(); virtual ~MenuElement() {} virtual void initialize(); //Adjusts the position of the text and the icon, based in the calculated offset(x) void offset(int16_t x) { icon.setX(30 + x); text.setX(80 + x); } //The new declaration and implementation of the setY() function virtual void setY(int16_t y) { //set Y as normal MenuElementBase::setY(y); const int circleRadius = 250; //center around middle of background y = y + getHeight() / 2 - 390 /2; //calculate x float x_f = circleRadius - sqrtf((float)((circleRadius * circleRadius) - (y * y))); int16_t x = (int16_t)(x_f + 0.5f); offset(x); } ...