GUI: allow setting macro release points

This commit is contained in:
tildearrow 2022-02-08 21:59:30 -05:00
parent 27333dc812
commit c8b149b4c8
2 changed files with 23 additions and 6 deletions

View File

@ -1402,6 +1402,12 @@ String macroHover(int id, float val) {
return fmt::sprintf("%d: %d",id,val);
}
String macroHoverLoop(int id, float val) {
if (val>1) return "Release";
if (val>0) return "Loop";
return "";
}
#define P(x) if (x) { \
modified=true; \
e->notifyInsChange(curIns); \
@ -1438,7 +1444,7 @@ String macroHover(int id, float val) {
if (j+macroDragScroll>=macroLen) { \
loopIndicator[j]=0; \
} else { \
loopIndicator[j]=(macroLoop!=-1 && (j+macroDragScroll)>=macroLoop); \
loopIndicator[j]=(macroLoop!=-1 && (j+macroDragScroll)>=macroLoop)|((macroRel!=-1 && (j+macroDragScroll)==macroRel)<<1); \
} \
} \
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,ImVec2(0.0f,0.0f)); \
@ -1468,17 +1474,25 @@ String macroHover(int id, float val) {
ImGui::SameLine(); \
ImGui::VSliderInt("##IArpMacroPos",ImVec2(20.0f*dpiScale,displayHeight*dpiScale),sliderVal,sliderLow,70); \
} \
PlotCustom("##IMacroLoop_" macroName,loopIndicator,totalFit,macroDragScroll,NULL,0,1,ImVec2(availableWidth,8.0f*dpiScale),sizeof(float),macroColor,macroLen-macroDragScroll); \
PlotCustom("##IMacroLoop_" macroName,loopIndicator,totalFit,macroDragScroll,NULL,0,2,ImVec2(availableWidth,16.0f*dpiScale),sizeof(float),macroColor,macroLen-macroDragScroll,&macroHoverLoop); \
if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) { \
macroLoopDragStart=ImGui::GetItemRectMin(); \
macroLoopDragAreaSize=ImVec2(availableWidth,8.0f*dpiScale); \
macroLoopDragAreaSize=ImVec2(availableWidth,16.0f*dpiScale); \
macroLoopDragLen=totalFit; \
macroLoopDragTarget=&macroLoop; \
if (ImGui::IsKeyDown(ImGuiKey_LeftShift) || ImGui::IsKeyDown(ImGuiKey_RightShift)) { \
macroLoopDragTarget=&macroRel; \
} else { \
macroLoopDragTarget=&macroLoop; \
} \
macroLoopDragActive=true; \
processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y); \
} \
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) { \
macroLoop=-1; \
if (ImGui::IsKeyDown(ImGuiKey_LeftShift) || ImGui::IsKeyDown(ImGuiKey_RightShift)) { \
macroRel=-1; \
} else { \
macroLoop=-1; \
} \
} \
ImGui::SetNextItemWidth(availableWidth); \
if (ImGui::InputText("##IMacroMML_" macroName,&mmlStr)) { \

View File

@ -332,7 +332,10 @@ int PlotCustomEx(ImGuiPlotType plot_type, const char* label, float (*values_gett
const float v0 = values_getter(data, (v_idx) % values_count);
const float v1 = values_getter(data, (v_idx + 1) % values_count);
if (hoverFunc) {
ImGui::SetTooltip("%s",hoverFunc(v_idx+values_display_offset,v0).c_str());
std::string hoverText=hoverFunc(v_idx+values_display_offset,v0);
if (!hoverText.empty()) {
ImGui::SetTooltip("%s",hoverText.c_str());
}
} else {
if (plot_type == ImGuiPlotType_Lines)
ImGui::SetTooltip("%d: %8.4g\n%d: %8.4g", v_idx, v0, v_idx + 1, v1);