Example #1
0
void SetValuesWidth(TwBar* bar, int32 width, bool32 fit)
{
    if(fit)
        TwCall(TwSetParam(bar, nullptr, "valueswidth", TW_PARAM_CSTRING, 1, "fit"));
    else
        TwCall(TwSetParam(bar, nullptr, "valueswidth", TW_PARAM_INT32, 1, &width));
}
Example #2
0
void SetAxisMapping(TwBar* bar, const char* varName, Axis xAxis, Axis yAxis, Axis zAxis)
{
    static const char* AxisStrings[] = { "x", "-x", "y", "-y", "z", "-z" };
    TwCall(TwSetParam(bar, varName, "axisx", TW_PARAM_CSTRING, 1, AxisStrings[uint64(xAxis)]));
    TwCall(TwSetParam(bar, varName, "axisy", TW_PARAM_CSTRING, 1, AxisStrings[uint64(yAxis)]));
    TwCall(TwSetParam(bar, varName, "axisz", TW_PARAM_CSTRING, 1, AxisStrings[uint64(zAxis)]));
}
Example #3
0
void SetUseArrowMode(TwBar* bar, const char* varName, bool32 useArrowMode, Float3 initialDirection)
{
    if(useArrowMode)
    {
        std::string dirString = "'" + ToAnsiString(initialDirection.x) + " " + ToAnsiString(initialDirection.y)
                                + " " + ToAnsiString(initialDirection.z) + "'";
        TwCall(TwSetParam(bar, varName, "arrow", TW_PARAM_CSTRING, 1, dirString.c_str()));
    }
    else
        TwCall(TwSetParam(bar, varName, "arrow", TW_PARAM_CSTRING, 1, "0"));
}
Example #4
0
void SetColor(TwBar* bar, Float3 color)
{
    int32 rgb[3] = { int32(Saturate(color.x) * 255.0f),
                     int32(Saturate(color.y) * 255.0f),
                     int32(Saturate(color.z) * 255.0f) };
    TwCall(TwSetParam(bar, nullptr, "color", TW_PARAM_INT32, 3, rgb));
}
Example #5
0
void SetArrowColor(TwBar* bar, const char* varName, Float3 color)
{
    int32 rgb[3] = { int32(Saturate(color.x) * 255.0f),
                     int32(Saturate(color.y) * 255.0f),
                     int32(Saturate(color.z) * 255.0f) };
    TwCall(TwSetParam(bar, varName, "arrowcolor", TW_PARAM_INT32, 3, rgb));
}
Example #6
0
void Setting::Initialize(TwBar* tweakBar_, SettingType type_, void* data_, const char* name_,
                         const char* group_, const char* label_, const char* helpText_,
                         ETwType twType_)
{
    tweakBar = tweakBar_;
    type = type_;
    data = data_;
    name = name_;
    group = group_;
    label = label_;
    helpText = helpText_;
    changed = false;

    static const ETwType twTypes[] =
    {
        TW_TYPE_FLOAT,
        TW_TYPE_INT32,
        TW_TYPE_BOOL32,
        TW_TYPE_UINT32,     // not used
        TW_TYPE_DIR3F,
        TW_TYPE_QUAT4F,
        TW_TYPE_COLOR3F,
    };

    StaticAssert_(_countof(twTypes) == uint64(SettingType::NumTypes));

    const ETwType twType = twType_ == TW_TYPE_UNDEF ? twTypes[uint64(type)] : twType_;
    TwCall(TwAddVarRW(tweakBar, name.c_str(), twType, data, nullptr));
    TwHelper::SetLabel(tweakBar, name.c_str(), label.c_str());
    TwHelper::SetHelpText(tweakBar, name.c_str(), helpText.c_str());
    TwHelper::SetGroup(tweakBar, name.c_str(), group.c_str());
}
Example #7
0
void Button::Initialize(TwBar* tweakBar_, const char* name_, const char* group_,
                        const char* label_, const char* helpText_)
{
    tweakBar = tweakBar_;
    type = SettingType::Button;
    name = name_;
    group = group_;
    label = label_;
    helpText = helpText_;
    changed = false;

    TwCall(TwAddButton(tweakBar, name_, Button::Callback, this, ""));

    TwHelper::SetLabel(tweakBar, name.c_str(), label.c_str());
    TwHelper::SetHelpText(tweakBar, name.c_str(), helpText.c_str());
    TwHelper::SetGroup(tweakBar, name.c_str(), group.c_str());
}
Example #8
0
void EnumSetting::Initialize(TwBar* tweakBar_, const char* name_,
                             const char* group_, const char* label_,
                             const char* helpText_, uint32 initialVal,
                             uint32 numValues_, const char* const* valueLabels)
{
    val = std::min(initialVal, numValues - 1);
    numValues = numValues_;

    // Register an enum type
    std::vector<TwEnumVal> enumValues(numValues);
    for(uint32 i = 0; i < numValues; ++i)
    {
        enumValues[i].Value = i;
        enumValues[i].Label = valueLabels[i];
    }
    TwType twType = TwDefineEnum(name_, enumValues.data(), numValues);
    TwCall(twType);

    Setting::Initialize(tweakBar_, SettingType::Enum, &val, name_, group_, label_, helpText_, twType);
}
Example #9
0
void SetStep(TwBar* bar, const char* varName, float step)
{
    TwCall(TwSetParam(bar, varName, "step", TW_PARAM_FLOAT, 1, &step));
}
Example #10
0
void SetMinMax(TwBar* bar, const char* varName, int32 min, int32 max)
{
    TwCall(TwSetParam(bar, varName, "min", TW_PARAM_INT32, 1, &min));
    TwCall(TwSetParam(bar, varName, "max", TW_PARAM_INT32, 1, &max));
}
Example #11
0
void SetMinMax(TwBar* bar, const char* varName, float min, float max)
{
    TwCall(TwSetParam(bar, varName, "min", TW_PARAM_FLOAT, 1, &min));
    TwCall(TwSetParam(bar, varName, "max", TW_PARAM_FLOAT, 1, &max));
}
Example #12
0
void SetIconPosition(IconPosition position)
{
    static const char* IconPositionStrings[] = { "topleft", "topright", "bottomleft", "bottomright" };
    TwCall(TwSetParam(nullptr, nullptr, "iconpos", TW_PARAM_CSTRING, 1, IconPositionStrings[uint64(position)]));
}
Example #13
0
void SetUseAlphaChannel(TwBar* bar, const char* varName, bool32 useAlpha)
{
    TwCall(TwSetParam(bar, varName, "coloralpha", TW_PARAM_INT32, 1, &useAlpha));
}
Example #14
0
void SetFontScaling(float scale)
{
    TwCall(TwSetParam(nullptr, nullptr, "fontscaling", TW_PARAM_FLOAT, 1, &scale));
}
Example #15
0
void SetShortcutKeyDecrement(TwBar* bar, const char* varName, const char* shortcutKey)
{
    TwCall(TwSetParam(bar, varName, "keydecr", TW_PARAM_CSTRING, 1, shortcutKey));
}
Example #16
0
void SetFontStyle(FontStyle style)
{
    static const char* FontStyleStrings[] = { "default", "fixed" };
    TwCall(TwSetParam(nullptr, nullptr, "fontstyle", TW_PARAM_CSTRING, 1, FontStyleStrings[uint64(style)]));
}
Example #17
0
void SetFontResizable(bool32 resizable)
{
    TwCall(TwSetParam(nullptr, nullptr, "fontresizable", TW_PARAM_INT32, 1, &resizable));
}
Example #18
0
void SetFontSize(FontSize size)
{
    int32 fontSize[1] = { int32(size) };
    TwCall(TwSetParam(nullptr, nullptr, "fontsize", TW_PARAM_INT32, 1, fontSize));
}
Example #19
0
void SetIconMargin(int32 marginX, int32 marginY)
{
    int32 margins[2] = { marginX, marginY };
    TwCall(TwSetParam(nullptr, nullptr, "iconmargin", TW_PARAM_INT32, 2, margins));
}
Example #20
0
void SetIconAlignment(IconAlignment alignment)
{
    static const char* IconAlignmentStrings[] = { "vertical", "horizontal" };
    TwCall(TwSetParam(nullptr, nullptr, "iconalign", TW_PARAM_CSTRING, 1, IconAlignmentStrings[uint64(alignment)]));
}
Example #21
0
void SetPrecision(TwBar* bar, const char* varName, int32 precision)
{
    TwCall(TwSetParam(bar, varName, "precision", TW_PARAM_INT32, 1, &precision));
}
Example #22
0
// Group parameters
void SetOpened(TwBar* bar, const char* groupName, bool32 opened)
{
    TwCall(TwSetParam(bar, groupName, "opened", TW_PARAM_INT32, 1, &opened));
}
Example #23
0
void SetHexidecimal(TwBar* bar, const char* varName, bool32 hex)
{
    TwCall(TwSetParam(bar, varName, "hexa", TW_PARAM_INT32, 1, &hex));
}
Example #24
0
void SetDrawOverlappedBars(bool32 drawOverlapped)
{
    TwCall(TwSetParam(nullptr, nullptr, "overlap", TW_PARAM_INT32, 1, &drawOverlapped));
}
Example #25
0
void SetBoolLabels(TwBar* bar, const char* varName, const char* falseLabel, const char* trueLabel)
{
    TwCall(TwSetParam(bar, varName, "false", TW_PARAM_CSTRING, 1, falseLabel));
    TwCall(TwSetParam(bar, varName, "true", TW_PARAM_CSTRING, 1, trueLabel));
}
Example #26
0
void SetVisible(TwBar* bar, const char* varName, bool32 visible)
{
    TwCall(TwSetParam(bar, varName, "visible", TW_PARAM_INT32, 1, &visible));
}
Example #27
0
void SetColorOrder(TwBar* bar, const char* varName, ColorOrder order)
{
    static const char* ColorOrderStrings[] = { "rgba", "bgra" };
    TwCall(TwSetParam(bar, varName, "colororder", TW_PARAM_CSTRING, 1, ColorOrderStrings[uint64(order)]));
}
Example #28
0
void SetReadOnly(TwBar* bar, const char* varName, bool32 readOnly)
{
    TwCall(TwSetParam(bar, varName, "readonly", TW_PARAM_INT32, 1, &readOnly));
}
Example #29
0
void SetGroup(TwBar* bar, const char* varName, const char* group)
{
    TwCall(TwSetParam(bar, varName, "group", TW_PARAM_CSTRING, 1, group));
}
Example #30
0
void SetHelpText(TwBar* bar, const char* varName, const char* helpText)
{
    TwCall(TwSetParam(bar, varName, "help", TW_PARAM_CSTRING, 1, helpText));
}