centered vertical text
someone pleeeeeease fix the clipping i give up
This commit is contained in:
parent
9a2705e169
commit
76b29fa31c
4 changed files with 24 additions and 55 deletions
|
|
@ -455,7 +455,7 @@ void FurnaceGUI::VerticalText(const char* fmt, ...) {
|
|||
ImGui::Dummy(ImVec2(size.y,size.x));
|
||||
}
|
||||
|
||||
void FurnaceGUI::VerticalText(float maxSize, const char* fmt, ...) {
|
||||
void FurnaceGUI::VerticalText(float maxSize, bool centered, const char* fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
ImVec2 pos=ImGui::GetCursorScreenPos();
|
||||
|
|
@ -464,11 +464,13 @@ void FurnaceGUI::VerticalText(float maxSize, const char* fmt, ...) {
|
|||
vtxBegin=dl->_VtxCurrentIdx;
|
||||
char text[4096];
|
||||
vsnprintf(text, 4096, fmt, args);
|
||||
const char* textEol=ImGui::FindRenderedTextEnd(text);
|
||||
ImVec2 size=ImGui::CalcTextSize(text);
|
||||
ImGui::RenderTextEllipsis(dl,pos,pos+ImVec2(maxSize,ImGui::GetFontSize()),maxSize,text,ImGui::FindRenderedTextEnd(text),&size);
|
||||
ImGui::RenderTextEllipsis(dl,pos,pos+ImVec2(maxSize,ImGui::GetFontSize()),maxSize,text,textEol,&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));
|
||||
float ySize=(size.x>maxSize)?maxSize:size.x;
|
||||
ImGui::ShadeVertsTransformPos(dl, vtxBegin, vtxEnd, pos, 0, -1, pos+ImVec2(0,ySize+(centered?(maxSize-size.x)/2.0f:0)));
|
||||
ImGui::Dummy(ImVec2(size.y,centered?maxSize:ySize));
|
||||
}
|
||||
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -2860,7 +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, ...);
|
||||
void VerticalText(float maxSize, bool centered, const char* fmt, ...);
|
||||
|
||||
// combo with locale
|
||||
static bool LocalizedComboGetter(void* data, int idx, const char** out_text);
|
||||
|
|
@ -2991,7 +2991,7 @@ class FurnaceGUI {
|
|||
|
||||
float drawSystemChannelInfo(const DivSysDef* whichDef, int keyHitOffset=-1, float width=-1.0f);
|
||||
void drawSystemChannelInfoText(const DivSysDef* whichDef);
|
||||
void drawVolMeterInternal(ImDrawList* dl, ImRect rect, float* data, int chans);
|
||||
void drawVolMeterInternal(ImDrawList* dl, ImRect rect, float* data, int chans, bool aspectRatio);
|
||||
|
||||
void assignActionMap(std::map<int,int>& actionMap, int first, int last);
|
||||
void drawKeybindSettingsTableRow(FurnaceGUIActions actionIdx);
|
||||
|
|
|
|||
|
|
@ -226,16 +226,19 @@ void FurnaceGUI::drawMixer() {
|
|||
if (ImGui::Begin("Mixer",&mixerOpen,globalWinFlags|(settings.allowEditDocking?0:ImGuiWindowFlags_NoDocking),_("Mixer"))) {
|
||||
if (ImGui::BeginTabBar("MixerView")) {
|
||||
if (ImGui::BeginTabItem(_("Mixer"))) {
|
||||
if (ImGui::VSliderFloat("##mixerMaster",ImVec2(40*dpiScale,ImGui::GetContentRegionAvail().y),&e->song.masterVol,0,3,"%.2fx")) {
|
||||
float maxY=ImGui::GetContentRegionAvail().y;
|
||||
VerticalText(maxY, true,_("Master Volume"));
|
||||
ImGui::SameLine();
|
||||
if (ImGui::VSliderFloat("##mixerMaster",ImVec2(40*dpiScale,maxY),&e->song.masterVol,0,3,"%.2fx")) {
|
||||
if (e->song.masterVol<0) e->song.masterVol=0;
|
||||
if (e->song.masterVol>3) e->song.masterVol=3;
|
||||
MARK_MODIFIED;
|
||||
} rightClickable //_("Master Volume")
|
||||
} rightClickable
|
||||
ImGui::SameLine();
|
||||
if (ImGui::BeginChild("##mixerPerChipContainer",ImGui::GetContentRegionAvail())) {
|
||||
if (ImGui::BeginChild("##mixerPerChipContainer")) {
|
||||
const float childWidth=60*dpiScale;
|
||||
for (int i=0; i<e->song.systemLen; i++) {
|
||||
if (chipMixer(i, ImVec2(childWidth, ImGui::GetContentRegionAvail().y))) MARK_MODIFIED;
|
||||
if (chipMixer(i, ImVec2(childWidth,maxY))) MARK_MODIFIED;
|
||||
ImGui::SameLine();
|
||||
}
|
||||
}
|
||||
|
|
@ -428,21 +431,22 @@ bool FurnaceGUI::chipMixer(int which, ImVec2 size) {
|
|||
|
||||
float volSliderHeight=size.y-ImGui::GetStyle().FramePadding.y*7-textHeight*2;
|
||||
|
||||
VerticalText(volSliderHeight-(ImGui::GetCursorPosY()-curPos.y),"%s",e->getSystemName(e->song.system[which]));
|
||||
VerticalText(volSliderHeight-(ImGui::GetCursorPosY()-curPos.y), true,"%s",e->getSystemName(e->song.system[which]));
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
float vTextWidth=textHeight+2*ImGui::GetStyle().FramePadding.x;
|
||||
// TODO: per-chip per-out peak
|
||||
float volMeter[2];
|
||||
volMeter[0]=0;
|
||||
volMeter[1]=0;
|
||||
volMeter[0]=0.5;
|
||||
volMeter[1]=0.5;
|
||||
ImGui::SetCursorPos(curPos);
|
||||
ImVec2 pos=ImGui::GetCursorScreenPos();
|
||||
drawVolMeterInternal(ImGui::GetWindowDrawList(),ImRect(pos,pos+ImVec2(size.x-vTextWidth,volSliderHeight)),volMeter,2);
|
||||
drawVolMeterInternal(ImGui::GetWindowDrawList(),ImRect(pos,pos+ImVec2(size.x-vTextWidth,volSliderHeight)),volMeter,2,false);
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBg,0);
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgActive,0);
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered,127<<IM_COL32_A_SHIFT);
|
||||
if (ImGui::VSliderFloat("##ChipVol", ImVec2(size.x-vTextWidth,volSliderHeight), &vol, 0.0f, 2.0f)) {
|
||||
if (doInvert) {
|
||||
if (vol<0.0001) vol=0.0001;
|
||||
|
|
@ -455,7 +459,7 @@ bool FurnaceGUI::chipMixer(int which, ImVec2 size) {
|
|||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayShort)) {
|
||||
ImGui::SetTooltip(_("Volume"));
|
||||
}
|
||||
ImGui::PopStyleColor(2);
|
||||
ImGui::PopStyleColor(3);
|
||||
|
||||
ImGui::SetNextItemWidth(size.x+1.5f*ImGui::GetStyle().FramePadding.x);
|
||||
if (ImGui::SliderFloat("##ChipPan", &e->song.systemPan[which], -1.0f, 1.0f)) {
|
||||
|
|
|
|||
|
|
@ -48,47 +48,11 @@ void FurnaceGUI::drawVolMeter() {
|
|||
ImRect rect=ImRect(minArea,maxArea);
|
||||
ImGuiStyle& style=ImGui::GetStyle();
|
||||
ImGui::ItemSize(ImVec2(4.0f,4.0f),style.FramePadding.y);
|
||||
ImU32 lowColor=ImGui::GetColorU32(uiColors[GUI_COLOR_VOLMETER_LOW]);
|
||||
// ImU32 lowColor=ImGui::GetColorU32(uiColors[GUI_COLOR_VOLMETER_LOW]);
|
||||
if (ImGui::ItemAdd(rect,ImGui::GetID("volMeter"))) {
|
||||
ImGui::RenderFrame(rect.Min,rect.Max,ImGui::GetColorU32(ImGuiCol_FrameBg),true,style.FrameRounding);
|
||||
int outChans=e->getAudioDescGot().outChans;
|
||||
for (int i=0; i<outChans; i++) {
|
||||
float logPeak=(20*log10(peak[i])/36.0);
|
||||
if (logPeak==NAN) logPeak=0.0;
|
||||
if (logPeak<-1.0) logPeak=-1.0;
|
||||
if (logPeak>0.0) {
|
||||
isClipping=8;
|
||||
logPeak=0.0;
|
||||
}
|
||||
logPeak+=1.0;
|
||||
ImU32 highColor=ImGui::GetColorU32(
|
||||
ImLerp(uiColors[GUI_COLOR_VOLMETER_LOW],uiColors[GUI_COLOR_VOLMETER_HIGH],logPeak)
|
||||
);
|
||||
ImRect s;
|
||||
if (aspectRatio) {
|
||||
s=ImRect(
|
||||
ImLerp(rect.Min,rect.Max,ImVec2(0,float(i)/outChans)),
|
||||
ImLerp(rect.Min,rect.Max,ImVec2(logPeak,float(i+1)/outChans))
|
||||
);
|
||||
if (i!=(outChans-1)) s.Max.y-=dpiScale;
|
||||
if (isClipping) {
|
||||
dl->AddRectFilled(s.Min,s.Max,ImGui::GetColorU32(uiColors[GUI_COLOR_VOLMETER_PEAK]));
|
||||
} else {
|
||||
dl->AddRectFilledMultiColor(s.Min,s.Max,lowColor,highColor,highColor,lowColor);
|
||||
}
|
||||
} else {
|
||||
s=ImRect(
|
||||
ImLerp(rect.Min,rect.Max,ImVec2(float(i)/outChans,1.0-logPeak)),
|
||||
ImLerp(rect.Min,rect.Max,ImVec2(float(i+1)/outChans,1.0))
|
||||
);
|
||||
if (i!=(outChans-1)) s.Max.x-=dpiScale;
|
||||
if (isClipping) {
|
||||
dl->AddRectFilled(s.Min,s.Max,ImGui::GetColorU32(uiColors[GUI_COLOR_VOLMETER_PEAK]));
|
||||
} else {
|
||||
dl->AddRectFilledMultiColor(s.Min,s.Max,highColor,highColor,lowColor,lowColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
drawVolMeterInternal(dl, rect, peak, outChans, aspectRatio);
|
||||
if (ImGui::IsItemHovered()) {
|
||||
if (aspectRatio) {
|
||||
ImGui::SetTooltip("%.1fdB",36*((ImGui::GetMousePos().x-ImGui::GetItemRectMin().x)/(rect.Max.x-rect.Min.x)-1.0));
|
||||
|
|
@ -103,8 +67,7 @@ void FurnaceGUI::drawVolMeter() {
|
|||
ImGui::End();
|
||||
}
|
||||
|
||||
void FurnaceGUI::drawVolMeterInternal(ImDrawList* dl, ImRect rect, float* data, int chans) {
|
||||
bool aspectRatio=(ImGui::GetWindowSize().x/ImGui::GetWindowSize().y)>1.0;
|
||||
void FurnaceGUI::drawVolMeterInternal(ImDrawList* dl, ImRect rect, float* data, int chans, bool aspectRatio) {
|
||||
ImU32 lowColor=ImGui::GetColorU32(uiColors[GUI_COLOR_VOLMETER_LOW]);
|
||||
ImGuiStyle& style=ImGui::GetStyle();
|
||||
ImGui::RenderFrame(rect.Min,rect.Max,ImGui::GetColorU32(ImGuiCol_FrameBg),true,style.FrameRounding);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue