mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-05 12:25:05 +00:00
GUI: save per-chan osc state
This commit is contained in:
parent
abbd6e7274
commit
1b5396e814
4 changed files with 50 additions and 5 deletions
|
@ -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();
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "gui.h"
|
||||
#include "imgui.h"
|
||||
#include <fmt/printf.h>
|
||||
#include <math.h>
|
||||
|
||||
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);
|
||||
|
|
|
@ -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<DIV_MAX_CHANS; i++) {
|
||||
delete oldPat[i];
|
||||
}
|
||||
|
|
|
@ -804,6 +804,8 @@ struct Gradient2D {
|
|||
std::unique_ptr<ImU32[]> 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):
|
||||
|
|
Loading…
Reference in a new issue