ドロップダウンメニュー

dropdown.png
typedef enum { SUMMER, FALL, WINTER, SPRING } Seasons;
    Seasons season = WINTER;
 
    TwEnumVal seasonsEV[] = { {SUMMER, "Summer"}, {FALL, "Fall"}, {WINTER, "Winter"}, {SPRING, "Spring"} };
    TwType seasonType;
 
    seasonType = TwDefineEnum("SeasonType", seasonsEV, 4);
    TwAddVarRW(bar, "Season", seasonType, &season, NULL);

ドロップダウンメニューにコールバック関数を登録する

TwAddVarCBでいけそう。

    Seasons season = WINTER;
    TwEnumVal seasonsEV[] = { {SUMMER, "Summer"}, {FALL, "Fall"}, {WINTER, "Winter"}, {SPRING, "Spring"} };
    TwType seasonType;
    seasonType = TwDefineEnum("SeasonType", seasonsEV, 4);
    TwAddVarCB(bar, "drop down callback", seasonType, SetCB, GetCB, &season,  " label='drop down'");

コールバック関数

void __stdcall SetCB(const void *value, void *clientData)
{
 
    *((Seasons*)clientData) = *(Seasons *)value; // copy value to g_AutoRotate
    cout<<"SetCB"<< *((Seasons*)clientData)<<endl;
 
}
void __stdcall GetCB(void *value, void *clientData)
{
    (void)clientData; // unused
    //int i=0;
    *(Seasons *)value =  *((Seasons*)clientData); // copy g_AutoRotate to value
    cout<<"GetCB"<<*((Seasons*)clientData)<<endl;
}
サポートサイト Wikidot.com