From 0f408310f1bf42b35684fd332a49367585e9f34b Mon Sep 17 00:00:00 2001 From: tildearrow Date: Mon, 15 Sep 2025 21:02:19 -0500 Subject: [PATCH] GUI: chip manager redesign, part 1 --- src/gui/gui.cpp | 2 +- src/gui/gui.h | 2 +- src/gui/sysManager.cpp | 21 +++++++++++++++------ src/gui/sysMiscInfo.cpp | 28 ++++++++++++++++++++-------- 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 28066772f..7b613bfb0 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -5005,7 +5005,7 @@ bool FurnaceGUI::loop() { } for (int i=0; igetTotalChannelCount(); i++) { - keyHit1[i]-=0.2f; + keyHit1[i]-=0.08f; if (keyHit1[i]<0.0f) keyHit1[i]=0.0f; } diff --git a/src/gui/gui.h b/src/gui/gui.h index a037090cb..d7b5a28ee 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -2974,7 +2974,7 @@ class FurnaceGUI { void drawTutorial(); void drawXYOsc(); void drawUserPresets(); - void drawSystemChannelInfo(const DivSysDef* whichDef); + void drawSystemChannelInfo(const DivSysDef* whichDef, int keyHitOffset=-1); void drawSystemChannelInfoText(const DivSysDef* whichDef); void assignActionMap(std::map& actionMap, int first, int last); diff --git a/src/gui/sysManager.cpp b/src/gui/sysManager.cpp index cd304efc7..1a5be0334 100644 --- a/src/gui/sysManager.cpp +++ b/src/gui/sysManager.cpp @@ -45,6 +45,7 @@ void FurnaceGUI::drawSysManager() { ImGui::SameLine(); ImGui::Checkbox(_("Clone at end"),&sysDupEnd); + int dispatchOff=0; for (int i=0; isong.systemLen; i++) { String rackID=fmt::sprintf("SysEntry%d",i); String rackNameID=fmt::sprintf("SysName%d",i); @@ -76,12 +77,13 @@ void FurnaceGUI::drawSysManager() { ImGui::EndDragDropTarget(); } ImGui::SameLine(); - float sideButtonSize=200.0f*dpiScale; + float buttonInnerSize=ImGui::CalcTextSize(ICON_FA_CLONE ICON_FA_EJECT ICON_FA_TIMES).x; + float sideButtonSize=ImGui::GetStyle().ItemSpacing.x*3.0f+buttonInnerSize+ImGui::GetStyle().ItemInnerSpacing.x*6; ImGui::AlignTextToFramePadding(); ImGui::ScrollText(ImGui::GetID(rackNameID.c_str()),sysDef->name,ImVec2(0.0f,0.0f),ImVec2(ImGui::GetContentRegionAvail().x-sideButtonSize,0)); ImGui::Dummy(ImVec2(ImGui::GetContentRegionAvail().x-sideButtonSize,1.0f)); ImGui::SameLine(); - if (ImGui::Button(_("Clone##SysDup"))) { + if (ImGui::Button(ICON_FA_CLONE "##SysDup")) { if (!e->duplicateSystem(i,sysDupCloneChannels,sysDupEnd)) { showError(fmt::sprintf(_("cannot clone chip! (%s)"),e->getLastError())); } else { @@ -92,9 +94,11 @@ void FurnaceGUI::drawSysManager() { updateROMExportAvail(); MARK_MODIFIED; } + }if (ImGui::IsItemHovered()) { + ImGui::SetTooltip(_("Clone")); } ImGui::SameLine(); - ImGui::Button(_("Change##SysChange")); + ImGui::Button(ICON_FA_EJECT "##SysChange"); if (ImGui::BeginPopupContextItem("SysPickerC",ImGuiPopupFlags_MouseButtonLeft)) { DivSystem picked=systemPicker(false); if (picked!=DIV_SYSTEM_NULL) { @@ -115,6 +119,9 @@ void FurnaceGUI::drawSysManager() { } ImGui::EndPopup(); } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip(_("Change")); + } ImGui::SameLine(); ImGui::BeginDisabled(e->song.systemLen<=1); pushDestColor(); @@ -128,14 +135,16 @@ void FurnaceGUI::drawSysManager() { } ImGui::EndDisabled(); - drawSystemChannelInfo(sysDef); + drawSystemChannelInfo(sysDef,dispatchOff); - ImGui::Indent(); + /*ImGui::Indent(); drawSysConf(i,i,e->song.system[i],e->song.systemFlags[i],true); - ImGui::Unindent(); + ImGui::Unindent();*/ } ImGui::EndChild(); ImGui::PopID(); + + dispatchOff+=sysDef->channels; } /* diff --git a/src/gui/sysMiscInfo.cpp b/src/gui/sysMiscInfo.cpp index 2c7ccbe8e..442249467 100644 --- a/src/gui/sysMiscInfo.cpp +++ b/src/gui/sysMiscInfo.cpp @@ -21,6 +21,7 @@ #include "guiConst.h" #include "misc/cpp/imgui_stdlib.h" #include +#include const char* FurnaceGUI::getSystemPartNumber(DivSystem sys, DivConfig& flags) { switch (sys) { @@ -295,21 +296,32 @@ const char* FurnaceGUI::getSystemPartNumber(DivSystem sys, DivConfig& flags) { } } -void FurnaceGUI::drawSystemChannelInfo(const DivSysDef* whichDef) { +void FurnaceGUI::drawSystemChannelInfo(const DivSysDef* whichDef, int keyHitOffset) { ImDrawList* dl=ImGui::GetWindowDrawList(); const ImVec2 p=ImGui::GetCursorScreenPos(); - float scaler=5.0f*dpiScale; + ImVec2 sep=ImGui::GetStyle().ItemSpacing; + ImVec2 ledSize=ImVec2( + (ImGui::GetContentRegionAvail().x-sep.x*(whichDef->channels-1))/(float)whichDef->channels, + 8.0f*dpiScale + ); + if (ledSize.x<7.5f*dpiScale) ledSize.x=7.5f*dpiScale; float x=p.x, y=p.y; - float tooltipWidth=MIN(scrW*dpiScale,400.0f*dpiScale); + float tooltipWidth=ImGui::GetContentRegionAvail().x; for (int i=0; ichannels; i++) { - dl->AddRectFilled(ImVec2(x,y),ImVec2(x+1.5f*scaler,y+1.0f*scaler),ImGui::GetColorU32(uiColors[whichDef->chanTypes[i]+GUI_COLOR_CHANNEL_FM]),scaler); - x+=2.0f*scaler; - if ((x+1.5f*scaler)>tooltipWidth+p.x) { + if (x>tooltipWidth+p.x) { x=p.x; - y+=1.5f*scaler; + y+=ledSize.y+sep.y; } + ImVec4 color=uiColors[whichDef->chanTypes[i]+GUI_COLOR_CHANNEL_FM]; + if (keyHitOffset>=0) { + color.x*=MIN(1.0f,0.125f+keyHit1[keyHitOffset+i]*0.875f); + color.y*=MIN(1.0f,0.125f+keyHit1[keyHitOffset+i]*0.875f); + color.z*=MIN(1.0f,0.125f+keyHit1[keyHitOffset+i]*0.875f); + } + dl->AddRectFilled(ImVec2(x,y),ImVec2(x+ledSize.x,y+ledSize.y),ImGui::GetColorU32(color),ledSize.y); + x+=ledSize.x+sep.x; } - ImGui::Dummy(ImVec2(0,(y-p.y)+1.5f*scaler)); + ImGui::Dummy(ImVec2(0,(y-p.y)+ledSize.y)); } void FurnaceGUI::drawSystemChannelInfoText(const DivSysDef* whichDef) {