https://touchgfx.zendesk.com/hc/en-us/articles/207282555
1--srreen1建立一个BOX 颜色全黑 铺满
2--切换到custom容器 改名字为 MenuElement--width (W) 390 height (H) to 70.
3--一次性加入文本图片
4--加入ICOC TXT
5--回到左边 可以加入自定义的控件了
6--暂时不要自定义控件 增加一个滚动
X = 208, Y = 45 and H = 390 and change the name to "scrollWheel"
其中的模板选择自定义控件
7--加入2个图 半展示效果 此时结束开始code
感觉他就是框架已经完成了 你只是去填鸭!
你在MenuElement.hpp里面写的函数
offset
setY
你不知道在哪里用的
而setNumber你知道重写了
1#MenuElement.hpp
#include "BitmapDatabase.hpp"
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;
}
}
2#Screen1View.hpp
virtual void scrollWheelUpdateItem(MenuElement& item, int16_t itemIndex)
{
item.setNumber(itemIndex);
}
这个函数其实类似__WEAK 被我重写了
原来是:
class Screen1ViewBase : public touchgfx::View<Screen1Presenter>
{
public:
virtual void scrollWheelUpdateItem(MenuElement& item, int16_t itemIndex)
{
// Override and implement this function in Screen1
}
void Screen1ViewBase::updateItemCallbackHandler(DrawableListItemsInterface* items, int16_t containerIndex, int16_t itemIndex)
{
if (items == &scrollWheelListItems)
{
Drawable* d = items->getDrawable(containerIndex);
MenuElement* cc = (MenuElement*)d;
scrollWheelUpdateItem(*cc, itemIndex);
}
}
3#MenuElement.hpp
#include <math.h>
void offset(int16_t x)
{
icon.moveTo(30 + x, icon.getY());
text.moveTo(80 + x, text.getY());
}
virtual void setY(int16_t y)
{
MenuElementBase::setY(y);
const int circleRadius = 250;
y = y + getHeight() / 2 - 390 / 2;
float x_f = circleRadius - sqrtf((float)((circleRadius* circleRadius) - (y*y)));
int16_t x = (int16_t)(x_f + 0.5f);
offset(x);
}
void setNumber(int no)