Skip to content

Commit

Permalink
GUI: channel pair hints, part 3
Browse files Browse the repository at this point in the history
to-do:
- flooring
  • Loading branch information
tildearrow committed Oct 8, 2023
1 parent 7fc7347 commit 8422e5d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 21 deletions.
2 changes: 2 additions & 0 deletions src/gui/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ enum FurnaceGUIColors {
GUI_COLOR_PATTERN_STATUS_REL_ON,
GUI_COLOR_PATTERN_STATUS_ON,

GUI_COLOR_PATTERN_PAIR,

GUI_COLOR_SAMPLE_BG,
GUI_COLOR_SAMPLE_FG,
GUI_COLOR_SAMPLE_LOOP,
Expand Down
2 changes: 2 additions & 0 deletions src/gui/guiConst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,8 @@ const FurnaceGUIColorDef guiColors[GUI_COLOR_MAX]={
D(GUI_COLOR_PATTERN_STATUS_REL_ON,"",ImVec4(1.0f,0.8f,0.1f,1.0f)),
D(GUI_COLOR_PATTERN_STATUS_ON,"",ImVec4(0.3f,1.0f,0.1f,1.0f)),

D(GUI_COLOR_PATTERN_PAIR,"",ImVec4(0.6f,0.8f,1.0f,1.0f)),

D(GUI_COLOR_SAMPLE_BG,"",ImVec4(0.04f,0.13f,0.2f,1.0f)),
D(GUI_COLOR_SAMPLE_FG,"",ImVec4(0.7f,0.7f,0.7f,1.0f)),
D(GUI_COLOR_SAMPLE_LOOP,"",ImVec4(0.1f,0.22f,0.35f,1.0f)),
Expand Down
54 changes: 33 additions & 21 deletions src/gui/pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ void FurnaceGUI::drawPattern() {
nextScroll=-1.0f;
nextAddScroll=0.0f;
}
ImDrawList* tdl=NULL;
if (ImGui::BeginTable("PatternView",displayChans+2,ImGuiTableFlags_BordersInnerV|ImGuiTableFlags_ScrollX|ImGuiTableFlags_ScrollY|ImGuiTableFlags_NoPadInnerX|ImGuiTableFlags_NoBordersInFrozenArea|((settings.cursorFollowsWheel || wheelCalmDown)?ImGuiTableFlags_NoScrollWithMouse:0))) {
ImGui::TableSetupColumn("pos",ImGuiTableColumnFlags_WidthFixed);
char chanID[2048];
Expand Down Expand Up @@ -1134,11 +1135,13 @@ void FurnaceGUI::drawPattern() {
}
}
}
// HACK: rendering here would cause the pairs to be drawn behind the pattern for some reason...
tdl=ImGui::GetWindowDrawList();
ImGui::EndTable();
}

if (patChannelPairs && e->isRunning()) { // pair hints
ImDrawList* dl=ImGui::GetWindowDrawList();
ImGui::PushFont(mainFont);
if (patChannelPairs && e->isRunning() && tdl!=NULL) { // pair hints
float pos=0.0f;
float posCenter=0.0f;
float posMin=FLT_MAX;
Expand Down Expand Up @@ -1177,11 +1180,11 @@ void FurnaceGUI::drawPattern() {
} else {
textSize=ImGui::CalcTextSize(pairs.label);
}
dl->AddLine(
tdl->AddLine(
ImVec2(pos,posY),
ImVec2(pos,posY+textSize.y),
0xffffffff,
dpiScale
ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_PAIR]),
2.0f*dpiScale
);

for (int j=0; j<8; j++) {
Expand All @@ -1196,45 +1199,54 @@ void FurnaceGUI::drawPattern() {
numPairs++;
if (pos<posMin) posMin=pos;
if (pos>posMax) posMax=pos;
dl->AddLine(
tdl->AddLine(
ImVec2(pos,posY),
ImVec2(pos,posY+textSize.y),
0xffffffff,
dpiScale
ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_PAIR]),
2.0f*dpiScale
);
}

posCenter/=numPairs;

if (pairs.label==NULL) {
dl->AddLine(
tdl->AddLine(
ImVec2(posMin,posY+textSize.y),
ImVec2(posMax,posY+textSize.y),
0xffffffff,
dpiScale
ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_PAIR]),
2.0f*dpiScale
);
} else {
dl->AddLine(
tdl->AddLine(
ImVec2(posMin,posY+textSize.y),
ImVec2(posCenter-textSize.x*0.5,posY+textSize.y),
0xffffffff,
dpiScale
ImVec2(posCenter-textSize.x*0.5-6.0f*dpiScale,posY+textSize.y),
ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_PAIR]),
2.0f*dpiScale
);
dl->AddLine(
ImVec2(posCenter+textSize.x*0.5,posY+textSize.y),
tdl->AddLine(
ImVec2(posCenter+textSize.x*0.5+6.0f*dpiScale,posY+textSize.y),
ImVec2(posMax,posY+textSize.y),
0xffffffff,
dpiScale
ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_PAIR]),
2.0f*dpiScale
);

ImGui::RenderFrame(
ImVec2(posCenter-textSize.x*0.5-6.0f*dpiScale,posY+textSize.y*0.5-3.0f*dpiScale),
ImVec2(posCenter+textSize.x*0.5+6.0f*dpiScale,posY+textSize.y*1.5+3.0f*dpiScale),
ImGui::GetColorU32(ImGuiCol_FrameBg),
true,
ImGui::GetStyle().FrameRounding
);

dl->AddText(
tdl->AddText(
ImVec2(posCenter-textSize.x*0.5,posY+textSize.y*0.5),
0xffffffff,
ImGui::GetColorU32(ImGuiCol_Text),
pairs.label
);
}
}
}
ImGui::PopFont();

if (fancyPattern) { // visualizer
e->getCommandStream(cmdStream);
Expand Down

0 comments on commit 8422e5d

Please sign in to comment.