diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index ab8d4ff9d..933636b9f 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -455,6 +455,22 @@ void FurnaceGUI::VerticalText(const char* fmt, ...) { ImGui::Dummy(ImVec2(size.y,size.x)); } +void FurnaceGUI::VerticalText(float maxSize, 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); + ImGui::RenderTextEllipsis(dl,pos,pos+ImVec2(maxSize,ImGui::GetFontSize()),maxSize,text,ImGui::FindRenderedTextEnd(text),&size); + vtxEnd=dl->_VtxCurrentIdx; + ImGui::ShadeVertsTransformPos(dl, vtxBegin, vtxEnd, pos+ImVec2(size.x>maxSize?maxSize:size.x,0), 0, -1, pos); + ImGui::Dummy(ImVec2(size.y,size.x>maxSize?maxSize: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)) { diff --git a/src/gui/gui.h b/src/gui/gui.h index 5a8531928..4af1f5794 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -2860,6 +2860,7 @@ class FurnaceGUI { void renderFMPreviewESFM(const DivInstrumentFM& params, const DivInstrumentESFM& esfmParams, int pos=0); void VerticalText(const char* fmt, ...); + void VerticalText(float maxSize, const char* fmt, ...); // combo with locale static bool LocalizedComboGetter(void* data, int idx, const char** out_text); diff --git a/src/gui/mixer.cpp b/src/gui/mixer.cpp index a9f87bad1..1cf6382f7 100644 --- a/src/gui/mixer.cpp +++ b/src/gui/mixer.cpp @@ -239,6 +239,7 @@ void FurnaceGUI::drawMixer() { ImGui::SameLine(); } } + ImGui::EndChild(); ImGui::EndTabItem(); } if (ImGui::BeginTabItem(_("Patchbay"))) { @@ -411,26 +412,31 @@ bool FurnaceGUI::chipMixer(int which, ImVec2 size) { ImGui::BeginGroup(); float textHeight=ImGui::GetFontSize(); - 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; + float vol=fabs(e->song.systemVol[which]); + bool doInvert=e->song.systemVol[which]<0; + if (ImGui::Checkbox("##ChipInvert", &doInvert)) { + e->song.systemVol[which]=doInvert?-vol:vol; ret=true; } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip(_("Invert")); + } // hack to get the same line from here ImGui::SameLine(); ImVec2 curPos=ImGui::GetCursorPos(); ImGui::NewLine(); + float volSliderHeight=size.y-ImGui::GetStyle().FramePadding.y*7-textHeight*2; - VerticalText("%s",e->getSystemName(e->song.system[which])); + VerticalText(volSliderHeight-(ImGui::GetCursorPosY()-curPos.y),"%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 volMeter[2]; + volMeter[0]=0; + volMeter[1]=0; ImGui::SetCursorPos(curPos); ImVec2 pos=ImGui::GetCursorScreenPos(); drawVolMeterInternal(ImGui::GetWindowDrawList(),ImRect(pos,pos+ImVec2(size.x-vTextWidth,volSliderHeight)),volMeter,2); @@ -438,15 +444,38 @@ bool FurnaceGUI::chipMixer(int which, ImVec2 size) { ImGui::PushStyleColor(ImGuiCol_FrameBg,0); ImGui::PushStyleColor(ImGuiCol_FrameBgActive,0); if (ImGui::VSliderFloat("##ChipVol", ImVec2(size.x-vTextWidth,volSliderHeight), &vol, 0.0f, 2.0f)) { - e->song.systemVol[which]=vInvert?-vol:vol; + if (doInvert) { + if (vol<0.0001) vol=0.0001; + } + if (vol<0) vol=0; + if (vol>10) vol=10; + e->song.systemVol[which]=doInvert?-vol:vol; ret=true; + } rightClickable + if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayShort)) { + ImGui::SetTooltip(_("Volume")); } ImGui::PopStyleColor(2); - ImGui::SetNextItemWidth(size.x); - if (ImGui::SliderFloat("##ChipPan", &e->song.systemPan[which], -1.0f, 1.0f)) ret=true; - ImGui::SetNextItemWidth(size.x); - if (ImGui::SliderFloat("##ChipPanFR", &e->song.systemPanFR[which], -1.0f, 1.0f)) ret=true; + ImGui::SetNextItemWidth(size.x+1.5f*ImGui::GetStyle().FramePadding.x); + if (ImGui::SliderFloat("##ChipPan", &e->song.systemPan[which], -1.0f, 1.0f)) { + if (e->song.systemPan[which]<-1.0f) e->song.systemPan[which]=-1.0f; + if (e->song.systemPan[which]>1.0f) e->song.systemPan[which]=1.0f; + ret=true; + } rightClickable + if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayShort)) { + ImGui::SetTooltip(_("Panning")); + } + + ImGui::SetNextItemWidth(size.x+1.5f*ImGui::GetStyle().FramePadding.x); + if (ImGui::SliderFloat("##ChipPanFR", &e->song.systemPanFR[which], -1.0f, 1.0f)) { + if (e->song.systemPanFR[which]<-1.0f) e->song.systemPanFR[which]=-1.0f; + if (e->song.systemPanFR[which]>1.0f) e->song.systemPanFR[which]=1.0f; + ret=true; + } rightClickable + if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayShort)) { + ImGui::SetTooltip(_("Front/Rear")); + } ImGui::EndGroup(); ImGui::PopID();