GUI: prevent user from sliding macros out of view
This commit is contained in:
parent
036bec2b56
commit
1dec8bff40
|
@ -1782,13 +1782,19 @@ void FurnaceGUI::drawMacros(std::vector<FurnaceGUIMacroDesc>& macros, FurnaceGUI
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
float availableWidth=ImGui::GetContentRegionAvail().x-reservedSpace;
|
float availableWidth=ImGui::GetContentRegionAvail().x-reservedSpace;
|
||||||
int totalFit=MIN(255,availableWidth/MAX(1,macroPointSize*dpiScale));
|
int totalFit=MIN(255,availableWidth/MAX(1,macroPointSize*dpiScale));
|
||||||
if (macroDragScroll>255-totalFit) {
|
int scrollMax=0;
|
||||||
macroDragScroll=255-totalFit;
|
for (FurnaceGUIMacroDesc& i: macros) {
|
||||||
|
if (i.macro->len>scrollMax) scrollMax=i.macro->len;
|
||||||
|
}
|
||||||
|
scrollMax-=totalFit;
|
||||||
|
if (scrollMax<0) scrollMax=0;
|
||||||
|
if (macroDragScroll>scrollMax) {
|
||||||
|
macroDragScroll=scrollMax;
|
||||||
}
|
}
|
||||||
ImGui::SetNextItemWidth(availableWidth);
|
ImGui::SetNextItemWidth(availableWidth);
|
||||||
if (CWSliderInt("##MacroScroll",¯oDragScroll,0,255-totalFit,"")) {
|
if (CWSliderInt("##MacroScroll",¯oDragScroll,0,scrollMax,"")) {
|
||||||
if (macroDragScroll<0) macroDragScroll=0;
|
if (macroDragScroll<0) macroDragScroll=0;
|
||||||
if (macroDragScroll>255-totalFit) macroDragScroll=255-totalFit;
|
if (macroDragScroll>scrollMax) macroDragScroll=scrollMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw macros
|
// draw macros
|
||||||
|
@ -1839,9 +1845,9 @@ void FurnaceGUI::drawMacros(std::vector<FurnaceGUIMacroDesc>& macros, FurnaceGUI
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::SetNextItemWidth(availableWidth);
|
ImGui::SetNextItemWidth(availableWidth);
|
||||||
if (CWSliderInt("##MacroScroll",¯oDragScroll,0,255-totalFit,"")) {
|
if (CWSliderInt("##MacroScroll",¯oDragScroll,0,scrollMax,"")) {
|
||||||
if (macroDragScroll<0) macroDragScroll=0;
|
if (macroDragScroll<0) macroDragScroll=0;
|
||||||
if (macroDragScroll>255-totalFit) macroDragScroll=255-totalFit;
|
if (macroDragScroll>scrollMax) macroDragScroll=scrollMax;
|
||||||
}
|
}
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue