diff --git a/src/gui/chanOsc.cpp b/src/gui/chanOsc.cpp index 57fa99dac..da82de277 100644 --- a/src/gui/chanOsc.cpp +++ b/src/gui/chanOsc.cpp @@ -143,11 +143,13 @@ void FurnaceGUI::drawChanOsc() { ImGui::Image(chanOscGradTex,gradSize); ImVec2 gradLeftAbs=ImGui::GetItemRectMin(); if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) { - chanOscGrad.points.push_back(Gradient2DPoint( - (ImGui::GetMousePos().x-gradLeftAbs.x)/gradSize.x, - (ImGui::GetMousePos().y-gradLeftAbs.y)/gradSize.y - )); - updateChanOscGradTex=true; + if (chanOscGrad.points.size()<32) { + chanOscGrad.points.push_back(Gradient2DPoint( + (ImGui::GetMousePos().x-gradLeftAbs.x)/gradSize.x, + (ImGui::GetMousePos().y-gradLeftAbs.y)/gradSize.y + )); + updateChanOscGradTex=true; + } } ImVec2 oldCurPos=ImGui::GetCursorPos(); diff --git a/src/gui/gradient.cpp b/src/gui/gradient.cpp index 510f2ad53..ac69bf866 100644 --- a/src/gui/gradient.cpp +++ b/src/gui/gradient.cpp @@ -19,6 +19,7 @@ #include "gui.h" #include "imgui.h" +#include #include ImU32 Gradient2D::get(float x, float y) { @@ -31,6 +32,19 @@ ImU32 Gradient2D::get(float x, float y) { return grad[yi*width+xi]; } +String Gradient2D::toString() { + String ret=fmt::sprintf("GRAD #%.2X%.2X%.2X%.2X",(unsigned char)(bgColor.x*255.0f),(unsigned char)(bgColor.y*255.0f),(unsigned char)(bgColor.z*255.0f),(unsigned char)(bgColor.w*255.0f)); + for (Gradient2DPoint& i: points) { + ret+=fmt::sprintf(" %f,%f:%f,%f:#%.2X%.2X%.2X%.2X",i.x,i.y,i.distance,i.spread,(unsigned char)(i.color.x*255.0f),(unsigned char)(i.color.y*255.0f),(unsigned char)(i.color.z*255.0f),(unsigned char)(i.color.w*255.0f)); + } + return ret; +} + +// TODO: this one please +bool Gradient2D::fromString(String val) { + return false; +} + void Gradient2D::render() { ImU32* g=grad.get(); ImU32 bgColorU=ImGui::ColorConvertFloat4ToU32(bgColor); diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index f3f246cd8..3de09f8e1 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -4070,6 +4070,19 @@ bool FurnaceGUI::init() { pianoView=e->getConfInt("pianoView",pianoView); pianoInputPadMode=e->getConfInt("pianoInputPadMode",pianoInputPadMode); + chanOscCols=e->getConfInt("chanOscCols",3); + chanOscColorX=e->getConfInt("chanOscColorX",GUI_OSCREF_CENTER); + chanOscColorY=e->getConfInt("chanOscColorY",GUI_OSCREF_CENTER); + chanOscWindowSize=e->getConfFloat("chanOscWindowSize",20.0f); + chanOscWaveCorr=e->getConfBool("chanOscWaveCorr",true); + chanOscOptions=e->getConfBool("chanOscOptions",false); + chanOscColor.x=e->getConfFloat("chanOscColorR",1.0f); + chanOscColor.y=e->getConfFloat("chanOscColorG",1.0f); + chanOscColor.z=e->getConfFloat("chanOscColorB",1.0f); + chanOscColor.w=e->getConfFloat("chanOscColorA",1.0f); + chanOscUseGrad=e->getConfBool("chanOscUseGrad",false); + chanOscGrad.fromString(e->getConfString("chanOscGrad","")); + syncSettings(); if (settings.dpiScale>=0.5f) { @@ -4294,6 +4307,20 @@ bool FurnaceGUI::finish() { e->setConf("pianoView",pianoView); e->setConf("pianoInputPadMode",pianoInputPadMode); + // commit per-chan osc state + e->setConf("chanOscCols",chanOscCols); + e->setConf("chanOscColorX",chanOscColorX); + e->setConf("chanOscColorY",chanOscColorY); + e->setConf("chanOscWindowSize",chanOscWindowSize); + e->setConf("chanOscWaveCorr",chanOscWaveCorr); + e->setConf("chanOscOptions",chanOscOptions); + e->setConf("chanOscColorR",chanOscColor.x); + e->setConf("chanOscColorG",chanOscColor.y); + e->setConf("chanOscColorB",chanOscColor.z); + e->setConf("chanOscColorA",chanOscColor.w); + e->setConf("chanOscUseGrad",chanOscUseGrad); + e->setConf("chanOscGrad",chanOscGrad.toString()); + for (int i=0; i grad; size_t width, height; + String toString(); + bool fromString(String val); void render(); ImU32 get(float x, float y); Gradient2D(size_t w, size_t h):