GUI: chip manager redesign, part 1

This commit is contained in:
tildearrow 2025-09-15 21:02:19 -05:00
parent f29d72c45c
commit 0f408310f1
4 changed files with 37 additions and 16 deletions

View file

@ -5005,7 +5005,7 @@ bool FurnaceGUI::loop() {
} }
for (int i=0; i<e->getTotalChannelCount(); i++) { for (int i=0; i<e->getTotalChannelCount(); i++) {
keyHit1[i]-=0.2f; keyHit1[i]-=0.08f;
if (keyHit1[i]<0.0f) keyHit1[i]=0.0f; if (keyHit1[i]<0.0f) keyHit1[i]=0.0f;
} }

View file

@ -2974,7 +2974,7 @@ class FurnaceGUI {
void drawTutorial(); void drawTutorial();
void drawXYOsc(); void drawXYOsc();
void drawUserPresets(); void drawUserPresets();
void drawSystemChannelInfo(const DivSysDef* whichDef); void drawSystemChannelInfo(const DivSysDef* whichDef, int keyHitOffset=-1);
void drawSystemChannelInfoText(const DivSysDef* whichDef); void drawSystemChannelInfoText(const DivSysDef* whichDef);
void assignActionMap(std::map<int,int>& actionMap, int first, int last); void assignActionMap(std::map<int,int>& actionMap, int first, int last);

View file

@ -45,6 +45,7 @@ void FurnaceGUI::drawSysManager() {
ImGui::SameLine(); ImGui::SameLine();
ImGui::Checkbox(_("Clone at end"),&sysDupEnd); ImGui::Checkbox(_("Clone at end"),&sysDupEnd);
int dispatchOff=0;
for (int i=0; i<e->song.systemLen; i++) { for (int i=0; i<e->song.systemLen; i++) {
String rackID=fmt::sprintf("SysEntry%d",i); String rackID=fmt::sprintf("SysEntry%d",i);
String rackNameID=fmt::sprintf("SysName%d",i); String rackNameID=fmt::sprintf("SysName%d",i);
@ -76,12 +77,13 @@ void FurnaceGUI::drawSysManager() {
ImGui::EndDragDropTarget(); ImGui::EndDragDropTarget();
} }
ImGui::SameLine(); 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::AlignTextToFramePadding();
ImGui::ScrollText(ImGui::GetID(rackNameID.c_str()),sysDef->name,ImVec2(0.0f,0.0f),ImVec2(ImGui::GetContentRegionAvail().x-sideButtonSize,0)); 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::Dummy(ImVec2(ImGui::GetContentRegionAvail().x-sideButtonSize,1.0f));
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(_("Clone##SysDup"))) { if (ImGui::Button(ICON_FA_CLONE "##SysDup")) {
if (!e->duplicateSystem(i,sysDupCloneChannels,sysDupEnd)) { if (!e->duplicateSystem(i,sysDupCloneChannels,sysDupEnd)) {
showError(fmt::sprintf(_("cannot clone chip! (%s)"),e->getLastError())); showError(fmt::sprintf(_("cannot clone chip! (%s)"),e->getLastError()));
} else { } else {
@ -92,9 +94,11 @@ void FurnaceGUI::drawSysManager() {
updateROMExportAvail(); updateROMExportAvail();
MARK_MODIFIED; MARK_MODIFIED;
} }
}if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(_("Clone"));
} }
ImGui::SameLine(); ImGui::SameLine();
ImGui::Button(_("Change##SysChange")); ImGui::Button(ICON_FA_EJECT "##SysChange");
if (ImGui::BeginPopupContextItem("SysPickerC",ImGuiPopupFlags_MouseButtonLeft)) { if (ImGui::BeginPopupContextItem("SysPickerC",ImGuiPopupFlags_MouseButtonLeft)) {
DivSystem picked=systemPicker(false); DivSystem picked=systemPicker(false);
if (picked!=DIV_SYSTEM_NULL) { if (picked!=DIV_SYSTEM_NULL) {
@ -115,6 +119,9 @@ void FurnaceGUI::drawSysManager() {
} }
ImGui::EndPopup(); ImGui::EndPopup();
} }
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(_("Change"));
}
ImGui::SameLine(); ImGui::SameLine();
ImGui::BeginDisabled(e->song.systemLen<=1); ImGui::BeginDisabled(e->song.systemLen<=1);
pushDestColor(); pushDestColor();
@ -128,14 +135,16 @@ void FurnaceGUI::drawSysManager() {
} }
ImGui::EndDisabled(); ImGui::EndDisabled();
drawSystemChannelInfo(sysDef); drawSystemChannelInfo(sysDef,dispatchOff);
ImGui::Indent(); /*ImGui::Indent();
drawSysConf(i,i,e->song.system[i],e->song.systemFlags[i],true); drawSysConf(i,i,e->song.system[i],e->song.systemFlags[i],true);
ImGui::Unindent(); ImGui::Unindent();*/
} }
ImGui::EndChild(); ImGui::EndChild();
ImGui::PopID(); ImGui::PopID();
dispatchOff+=sysDef->channels;
} }
/* /*

View file

@ -21,6 +21,7 @@
#include "guiConst.h" #include "guiConst.h"
#include "misc/cpp/imgui_stdlib.h" #include "misc/cpp/imgui_stdlib.h"
#include <fmt/printf.h> #include <fmt/printf.h>
#include <imgui.h>
const char* FurnaceGUI::getSystemPartNumber(DivSystem sys, DivConfig& flags) { const char* FurnaceGUI::getSystemPartNumber(DivSystem sys, DivConfig& flags) {
switch (sys) { 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(); ImDrawList* dl=ImGui::GetWindowDrawList();
const ImVec2 p=ImGui::GetCursorScreenPos(); 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 x=p.x, y=p.y;
float tooltipWidth=MIN(scrW*dpiScale,400.0f*dpiScale); float tooltipWidth=ImGui::GetContentRegionAvail().x;
for (int i=0; i<whichDef->channels; i++) { for (int i=0; i<whichDef->channels; 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); if (x>tooltipWidth+p.x) {
x+=2.0f*scaler;
if ((x+1.5f*scaler)>tooltipWidth+p.x) {
x=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);
} }
ImGui::Dummy(ImVec2(0,(y-p.y)+1.5f*scaler)); 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)+ledSize.y));
} }
void FurnaceGUI::drawSystemChannelInfoText(const DivSysDef* whichDef) { void FurnaceGUI::drawSystemChannelInfoText(const DivSysDef* whichDef) {