/*
    Copyright (c) 2026 Christian Schoenebeck

    This file is part of "gigedit" and released under the terms of the
    GNU General Public License version 2.
*/

#ifndef GIGEDIT_PARAMSTR_H
#define GIGEDIT_PARAMSTR_H

#include "global.h"
#include <sstream>

// Like their names suggest, these functions should return a short string
// presentation of the sound parameter passed, as they are displayed on an UI
// area with only very little space to show them. These are displayed on
// dimension zones of the dimension region chooser, when hovering the mouse over
// a sound parameter control.

template<typename T> static
std::string geShortStr(T type) {
    std::ostringstream oss;
    oss << type;
    return oss.str();
}

template<>
std::string geShortStr(bool b) {
    return b ? "✓" : "off";
}

template<>
std::string geShortStr(uint8_t value) {
    return geShortStr<unsigned int>(value);
}

template<>
std::string geShortStr(int8_t value) {
    return geShortStr<int>(value);
}

template<>
std::string geShortStr(gig::loop_type_t type) {
    switch (type) {
        case gig::loop_type_normal: return "norm";
        case gig::loop_type_bidirectional: return "bi";
        case gig::loop_type_backward: return "back";
    }
    return "";
}

template<>
std::string geShortStr(gig::curve_type_t type) {
    switch (type) {
        case gig::curve_type_nonlinear: return "nonlin";
        case gig::curve_type_linear: return "lin";
        case gig::curve_type_special: return "spec";
        case gig::curve_type_unknown: return "unkn";
    }
    return "";
}

template<>
std::string geShortStr(gig::lfo_wave_t wave) {
    switch (wave) {
        case gig::lfo_wave_sine: return "sine";
        case gig::lfo_wave_triangle: return "triang";
        case gig::lfo_wave_saw: return "saw";
        case gig::lfo_wave_square: return "square";
    }
    return "";
}

template<>
std::string geShortStr(gig::lfo3_ctrl_t ctrl) {
    switch (ctrl) {
        case gig::lfo3_ctrl_internal: return "int";
        case gig::lfo3_ctrl_modwheel: return "modwh";
        case gig::lfo3_ctrl_aftertouch: return "aftch";
        case gig::lfo3_ctrl_internal_modwheel: return "int&modwh";
        case gig::lfo3_ctrl_internal_aftertouch: return "int&aftch";
    }
    return "";
}

template<>
std::string geShortStr(gig::lfo2_ctrl_t ctrl) {
    switch (ctrl) {
        case gig::lfo2_ctrl_internal: return "int";
        case gig::lfo2_ctrl_modwheel: return "modwh";
        case gig::lfo2_ctrl_foot: return "foot";
        case gig::lfo2_ctrl_internal_modwheel: return "int&modwh";
        case gig::lfo2_ctrl_internal_foot: return "int&foot";
    }
    return "";
}

template<>
std::string geShortStr(gig::lfo1_ctrl_t ctrl) {
    switch (ctrl) {
        case gig::lfo1_ctrl_internal: return "int";
        case gig::lfo1_ctrl_modwheel: return "modwh";
        case gig::lfo1_ctrl_breath: return "breath";
        case gig::lfo1_ctrl_internal_modwheel: return "int&modwh";
        case gig::lfo1_ctrl_internal_breath: return "int&breath";
    }
    return "";
}

template<>
std::string geShortStr(gig::vcf_cutoff_ctrl_t ctrl) {
    switch (ctrl) {
        case gig::vcf_cutoff_ctrl_none: return "none";
        case gig::vcf_cutoff_ctrl_none2: return "none";
        case gig::vcf_cutoff_ctrl_modwheel: return "modwh";
        case gig::vcf_cutoff_ctrl_effect1: return "eff1";
        case gig::vcf_cutoff_ctrl_effect2: return "eff2";
        case gig::vcf_cutoff_ctrl_breath: return "breath";
        case gig::vcf_cutoff_ctrl_foot: return "foot";
        case gig::vcf_cutoff_ctrl_sustainpedal: return "sust";
        case gig::vcf_cutoff_ctrl_softpedal: return "soft";
        case gig::vcf_cutoff_ctrl_genpurpose7: return "genp7";
        case gig::vcf_cutoff_ctrl_genpurpose8: return "genp8";
        case gig::vcf_cutoff_ctrl_aftertouch: return "aftch";
    }
    return "";
}

template<>
std::string geShortStr(gig::vcf_res_ctrl_t ctrl) {
    switch (ctrl) {
        case gig::vcf_res_ctrl_none: return "none";
        case gig::vcf_res_ctrl_genpurpose3: return "genp3";
        case gig::vcf_res_ctrl_genpurpose4: return "genp4";
        case gig::vcf_res_ctrl_genpurpose5: return "genp5";
        case gig::vcf_res_ctrl_genpurpose6: return "genp6";
    }
    return "";
}

template<>
std::string geShortStr(gig::leverage_ctrl_t ctrl) {
    switch (ctrl.type) {
        case gig::leverage_ctrl_t::type_none: return "none";
        case gig::leverage_ctrl_t::type_channelaftertouch: return "aftch";
        case gig::leverage_ctrl_t::type_velocity: return "velo";
        case gig::leverage_ctrl_t::type_controlchange:
            return "cc" + std::to_string(ctrl.controller_number);
    }
    return "";
}

template<>
std::string geShortStr(gig::sust_rel_trg_t type) {
    switch (type) {
        case gig::sust_rel_trg_none: return "off";
        case gig::sust_rel_trg_maxvelocity: return "maxvel";
        case gig::sust_rel_trg_keyvelocity: return "keyvel";
    }
    return "";
}

template<>
std::string geShortStr(gig::dim_bypass_ctrl_t ctrl) {
    switch (ctrl) {
        case gig::dim_bypass_ctrl_none: return "off";
        case gig::dim_bypass_ctrl_94: return "cc94";
        case gig::dim_bypass_ctrl_95: return "cc95";
    }
    return "";
}

template<>
std::string geShortStr(gig::vcf_type_t type) {
    switch (type) {
        case gig::vcf_type_lowpass: return "lp";
        case gig::vcf_type_lowpassturbo: return "lpturbo";
        case gig::vcf_type_bandpass: return "bp";
        case gig::vcf_type_highpass: return "hp";
        case gig::vcf_type_bandreject: return "brej";
        case gig::vcf_type_lowpass_1p: return "lp1p";
        case gig::vcf_type_lowpass_2p: return "lp2p";
        case gig::vcf_type_lowpass_4p: return "lp4p";
        case gig::vcf_type_lowpass_6p: return "lp6p";
        case gig::vcf_type_highpass_1p: return "hp1p";
        case gig::vcf_type_highpass_2p: return "hp2p";
        case gig::vcf_type_highpass_4p: return "hp4p";
        case gig::vcf_type_highpass_6p: return "hp6p";
        case gig::vcf_type_bandpass_2p: return "bp2p";
        case gig::vcf_type_bandreject_2p: return "brej2p";
    }
    return "";
}

#endif // GIGEDIT_PARAMSTR_H
