GUI: sample/macro zoom with ctrl-wheel

This commit is contained in:
tildearrow 2022-04-29 05:39:18 -05:00
parent aeea8a4912
commit 635bd72904
4 changed files with 19 additions and 1 deletions

View file

@ -3788,6 +3788,7 @@ FurnaceGUI::FurnaceGUI():
preserveChanPos(false), preserveChanPos(false),
vgmExportVersion(0x171), vgmExportVersion(0x171),
drawHalt(10), drawHalt(10),
macroPointSize(16),
curFileDialog(GUI_FILE_OPEN), curFileDialog(GUI_FILE_OPEN),
warnAction(GUI_WARN_OPEN), warnAction(GUI_WARN_OPEN),
postWarnAction(GUI_WARN_GENERIC), postWarnAction(GUI_WARN_GENERIC),

View file

@ -739,6 +739,7 @@ class FurnaceGUI {
bool willExport[32]; bool willExport[32];
int vgmExportVersion; int vgmExportVersion;
int drawHalt; int drawHalt;
int macroPointSize;
FurnaceGUIFileDialogs curFileDialog; FurnaceGUIFileDialogs curFileDialog;
FurnaceGUIWarnings warnAction; FurnaceGUIWarnings warnAction;

View file

@ -1128,6 +1128,11 @@ void FurnaceGUI::drawGBEnv(unsigned char vol, unsigned char len, unsigned char s
processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y); \ processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y); \
} \ } \
if (displayLoop) { \ if (displayLoop) { \
if (ImGui::IsItemHovered() && ctrlWheeling) { \
macroPointSize+=wheelY; \
if (macroPointSize<1) macroPointSize=1; \
if (macroPointSize>256) macroPointSize=256; \
} \
if (drawSlider) { \ if (drawSlider) { \
ImGui::SameLine(); \ ImGui::SameLine(); \
CWVSliderInt("##IMacroPos_" macroName,ImVec2(20.0f*dpiScale,displayHeight*dpiScale),sliderVal,sliderLow,sliderHigh); \ CWVSliderInt("##IMacroPos_" macroName,ImVec2(20.0f*dpiScale,displayHeight*dpiScale),sliderVal,sliderLow,sliderHigh); \
@ -1262,7 +1267,7 @@ if (ImGui::BeginTable("MacroSpace",2)) { \
ImGui::Dummy(ImVec2(120.0f*dpiScale,dpiScale)); \ ImGui::Dummy(ImVec2(120.0f*dpiScale,dpiScale)); \
ImGui::TableNextColumn(); \ ImGui::TableNextColumn(); \
float availableWidth=ImGui::GetContentRegionAvail().x-reservedSpace; \ float availableWidth=ImGui::GetContentRegionAvail().x-reservedSpace; \
int totalFit=MIN(127,availableWidth/(16*dpiScale)); \ int totalFit=MIN(127,availableWidth/MAX(1,macroPointSize*dpiScale)); \
if (macroDragScroll>127-totalFit) { \ if (macroDragScroll>127-totalFit) { \
macroDragScroll=127-totalFit; \ macroDragScroll=127-totalFit; \
} \ } \

View file

@ -1268,6 +1268,17 @@ void FurnaceGUI::drawSampleEdit() {
} }
if (ImGui::IsItemHovered()) { if (ImGui::IsItemHovered()) {
if (ctrlWheeling) {
double zoomPercent=100.0/sampleZoom;
zoomPercent+=wheelY*10.0;
if (zoomPercent>10000.0) zoomPercent=10000.0;
if (zoomPercent<1.0) zoomPercent=1.0;
sampleZoom=100.0/zoomPercent;
if (sampleZoom<0.01) sampleZoom=0.01;
sampleZoomAuto=false;
updateSampleTex=true;
}
int posX=-1; int posX=-1;
int posY=0; int posY=0;
ImVec2 pos=ImGui::GetMousePos(); ImVec2 pos=ImGui::GetMousePos();