vertical text

todo: mixer tooltips
This commit is contained in:
Eknous-P 2025-10-08 11:30:34 +04:00
parent 22f0b3f4e6
commit fe0f4d82e6
4 changed files with 51 additions and 7 deletions

View file

@ -400,6 +400,13 @@ void FurnaceGUI::drawDebug() {
ImGui::ScrollText(ImGui::GetID("scrolltest4"),"quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla pariatur?",ImGui::GetCursorPos(),ImVec2(0,0),true);
ImGui::TreePop();
}
if (ImGui::TreeNode("Vertical Text Test")) {
VerticalText("Test");
VerticalText("Test 2");
ImGui::SameLine();
VerticalText("Test 3");
ImGui::TreePop();
}
if (ImGui::TreeNode("Pitch Table Calculator")) {
ImGui::InputDouble("Clock",&ptcClock);
ImGui::InputDouble("Divider/FreqBase",&ptcDivider);

View file

@ -439,6 +439,22 @@ bool FurnaceGUI::isCtrlWheelModifierHeld() const {
}
}
void FurnaceGUI::VerticalText(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
ImVec2 pos=ImGui::GetCursorScreenPos();
ImDrawList* dl=ImGui::GetWindowDrawList();
int vtxBegin, vtxEnd;
vtxBegin=dl->_VtxCurrentIdx;
char text[4096];
vsnprintf(text, 4096, fmt, args);
ImVec2 size=ImGui::CalcTextSize(text);
dl->AddText(pos, ImGui::GetColorU32(ImGuiCol_Text), text);
vtxEnd=dl->_VtxCurrentIdx;
ImGui::ShadeVertsTransformPos(dl, vtxBegin, vtxEnd, pos+ImVec2(size.x,0), 0, -1, pos);
ImGui::Dummy(ImVec2(size.y,size.x));
}
bool FurnaceGUI::CWSliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags) {
flags^=ImGuiSliderFlags_AlwaysClamp;
if (ImGui::SliderScalar(label,data_type,p_data,p_min,p_max,format,flags)) {

View file

@ -2859,6 +2859,8 @@ class FurnaceGUI {
void renderFMPreviewOPZ(const DivInstrumentFM& params, int pos=0);
void renderFMPreviewESFM(const DivInstrumentFM& params, const DivInstrumentESFM& esfmParams, int pos=0);
void VerticalText(const char* fmt, ...);
// combo with locale
static bool LocalizedComboGetter(void* data, int idx, const char** out_text);

View file

@ -411,15 +411,36 @@ bool FurnaceGUI::chipMixer(int which, ImVec2 size) {
ImGui::BeginGroup();
float textHeight=ImGui::GetFontSize();
float volSliderHeight=size.y-ImGui::GetStyle().FramePadding.y*8-textHeight*3;
float vol=abs(e->song.systemVol[which]);
bool vInvert=e->song.systemVol[which]<0;
if (ImGui::Checkbox("##ChipInvert", &vInvert)) {
e->song.systemVol[which]=vInvert?-vol:vol;
ret=true;
}
// hack to get the same line from here
ImGui::SameLine();
ImVec2 curPos=ImGui::GetCursorPos();
ImGui::NewLine();
VerticalText("%s",e->getSystemName(e->song.system[which]));
ImGui::SameLine();
float volSliderHeight=size.y-ImGui::GetStyle().FramePadding.y*7-textHeight*2;
float vTextWidth=textHeight+2*ImGui::GetStyle().FramePadding.x;
// TODO: per-chip per-out peak
float vol[2];
ImVec2 pos=ImGui::GetWindowPos()+ImGui::GetCursorPos();
drawVolMeterInternal(ImGui::GetWindowDrawList(),ImRect(pos,pos+ImVec2(size.x,volSliderHeight)),vol,2);
float volMeter[2];
ImGui::SetCursorPos(curPos);
ImVec2 pos=ImGui::GetCursorScreenPos();
drawVolMeterInternal(ImGui::GetWindowDrawList(),ImRect(pos,pos+ImVec2(size.x-vTextWidth,volSliderHeight)),volMeter,2);
ImGui::PushStyleColor(ImGuiCol_FrameBg,0);
ImGui::PushStyleColor(ImGuiCol_FrameBgActive,0);
if (ImGui::VSliderFloat("##ChipVol", ImVec2(size.x,volSliderHeight), &e->song.systemVol[which], 0.0f, 2.0f)) ret=true;
if (ImGui::VSliderFloat("##ChipVol", ImVec2(size.x-vTextWidth,volSliderHeight), &vol, 0.0f, 2.0f)) {
e->song.systemVol[which]=vInvert?-vol:vol;
ret=true;
}
ImGui::PopStyleColor(2);
ImGui::SetNextItemWidth(size.x);
@ -427,8 +448,6 @@ bool FurnaceGUI::chipMixer(int which, ImVec2 size) {
ImGui::SetNextItemWidth(size.x);
if (ImGui::SliderFloat("##ChipPanFR", &e->song.systemPanFR[which], -1.0f, 1.0f)) ret=true;
ImGui::ScrollText(ImGui::GetID(which),fmt::sprintf("%d. %s",which+1,getSystemName(e->song.system[which])).c_str(),ImGui::GetCursorPos(),ImVec2(size.x,textHeight));
ImGui::Dummy(ImVec2(size.x,textHeight));
ImGui::EndGroup();
ImGui::PopID();
return ret;