GUI: add pattern label customization settings

This commit is contained in:
tildearrow 2022-08-13 18:00:29 -05:00
parent ee16d20047
commit bb5cee4a66
8 changed files with 106 additions and 35 deletions

View File

@ -24,7 +24,7 @@
#include "actionUtil.h"
const char* noteNameNormal(short note, short octave) {
const char* FurnaceGUI::noteNameNormal(short note, short octave) {
if (note==100) { // note cut
return "OFF";
} else if (note==101) { // note off and envelope release

View File

@ -593,11 +593,11 @@ void FurnaceGUI::drawFindReplace() {
i.note=0;
}
if (i.note==130) {
snprintf(tempID,1024,"REL");
snprintf(tempID,1024,"%s##MREL",macroRelLabel);
} else if (i.note==129) {
snprintf(tempID,1024,"===");
snprintf(tempID,1024,"%s##NREL",noteRelLabel);
} else if (i.note==128) {
snprintf(tempID,1024,"OFF");
snprintf(tempID,1024,"%s##NOFF",noteOffLabel);
} else if (i.note>=-60 && i.note<120) {
snprintf(tempID,1024,"%s",noteNames[i.note+60]);
} else {
@ -613,13 +613,13 @@ void FurnaceGUI::drawFindReplace() {
}
}
if (i.noteMode!=GUI_QUERY_RANGE && i.noteMode!=GUI_QUERY_RANGE_NOT) {
if (ImGui::Selectable("OFF",i.note==128)) {
if (ImGui::Selectable(noteOffLabel,i.note==128)) {
i.note=128;
}
if (ImGui::Selectable("===",i.note==129)) {
if (ImGui::Selectable(noteRelLabel,i.note==129)) {
i.note=129;
}
if (ImGui::Selectable("REL",i.note==130)) {
if (ImGui::Selectable(macroRelLabel,i.note==130)) {
i.note=130;
}
}
@ -916,11 +916,11 @@ void FurnaceGUI::drawFindReplace() {
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
if (queryReplaceNoteMode==GUI_QUERY_REPLACE_SET) {
if (queryReplaceNote==130) {
snprintf(tempID,1024,"REL");
snprintf(tempID,1024,"%s##MREL",macroRelLabel);
} else if (queryReplaceNote==129) {
snprintf(tempID,1024,"===");
snprintf(tempID,1024,"%s##NREL",noteRelLabel);
} else if (queryReplaceNote==128) {
snprintf(tempID,1024,"OFF");
snprintf(tempID,1024,"%s##NOFF",noteOffLabel);
} else if (queryReplaceNote>=-60 && queryReplaceNote<120) {
snprintf(tempID,1024,"%s",noteNames[queryReplaceNote+60]);
} else {
@ -934,13 +934,13 @@ void FurnaceGUI::drawFindReplace() {
queryReplaceNote=j-60;
}
}
if (ImGui::Selectable("OFF",queryReplaceNote==128)) {
if (ImGui::Selectable(noteOffLabel,queryReplaceNote==128)) {
queryReplaceNote=128;
}
if (ImGui::Selectable("===",queryReplaceNote==129)) {
if (ImGui::Selectable(noteRelLabel,queryReplaceNote==129)) {
queryReplaceNote=129;
}
if (ImGui::Selectable("REL",queryReplaceNote==130)) {
if (ImGui::Selectable(macroRelLabel,queryReplaceNote==130)) {
queryReplaceNote=130;
}
ImGui::EndCombo();

View File

@ -84,13 +84,13 @@ void FurnaceGUI::bindEngine(DivEngine* eng) {
const char* FurnaceGUI::noteName(short note, short octave) {
if (note==100) {
return "OFF";
return noteOffLabel;
} else if (note==101) { // note off and envelope release
return "===";
return noteRelLabel;
} else if (note==102) { // envelope release only
return "REL";
return macroRelLabel;
} else if (octave==0 && note==0) {
return "...";
return emptyLabel;
} else if (note==0 && octave!=0) {
return "BUG";
}
@ -5067,4 +5067,16 @@ FurnaceGUI::FurnaceGUI():
memset(queryReplaceEffectValDo,0,sizeof(bool)*8);
chanOscGrad.bgColor=ImVec4(0.0f,0.0f,0.0f,1.0f);
memset(noteOffLabel,0,32);
memset(noteRelLabel,0,32);
memset(macroRelLabel,0,32);
memset(emptyLabel,0,32);
memset(emptyLabel2,0,32);
strncat(noteOffLabel,"OFF",32);
strncat(noteRelLabel,"===",32);
strncat(macroRelLabel,"REL",32);
strncat(emptyLabel,"...",32);
strncat(emptyLabel2,"..",32);
}

View File

@ -1017,6 +1017,12 @@ class FurnaceGUI {
ImU32 sysCmd1Grad[256];
ImU32 sysCmd2Grad[256];
char noteOffLabel[32];
char noteRelLabel[32];
char macroRelLabel[32];
char emptyLabel[32];
char emptyLabel2[32];
struct Settings {
int mainFontSize, patFontSize, iconSize;
int audioEngine;
@ -1119,6 +1125,11 @@ class FurnaceGUI {
String midiOutDevice;
String c163Name;
String initialSysName;
String noteOffLabel;
String noteRelLabel;
String macroRelLabel;
String emptyLabel;
String emptyLabel2;
std::vector<int> initialSys;
Settings():
@ -1224,7 +1235,12 @@ class FurnaceGUI {
midiInDevice(""),
midiOutDevice(""),
c163Name(""),
initialSysName("Sega Genesis/Mega Drive") {}
initialSysName("Sega Genesis/Mega Drive"),
noteOffLabel("OFF"),
noteRelLabel("==="),
macroRelLabel("REL"),
emptyLabel("..."),
emptyLabel2("..") {}
} settings;
char finalLayoutPath[4096];
@ -1657,6 +1673,7 @@ class FurnaceGUI {
public:
void showWarning(String what, FurnaceGUIWarnings type);
void showError(String what);
const char* noteNameNormal(short note, short octave);
const char* noteName(short note, short octave);
bool decodeNote(const char* what, short& note, short& octave);
void bindEngine(DivEngine* eng);

View File

@ -56,7 +56,7 @@ void FurnaceGUI::popPartBlend() {
// draw a pattern row
inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int chans, int ord, const DivPattern** patCache, bool inhibitSel) {
static char id[32];
static char id[64];
bool selectedRow=(i>=sel1.y && i<=sel2.y && !inhibitSel);
ImGui::TableNextRow(0,lineHeight);
ImGui::TableNextColumn();
@ -114,9 +114,9 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int
ImGui::PushStyleColor(ImGuiCol_Text,rowIndexColor);
if (settings.patRowsBase==1) {
snprintf(id,31," %.2X ##PR_%d",i,i);
snprintf(id,63," %.2X ##PR_%d",i,i);
} else {
snprintf(id,31,"%3d ##PR_%d",i,i);
snprintf(id,63,"%3d ##PR_%d",i,i);
}
ImGui::Selectable(id,false,ImGuiSelectableFlags_NoPadWithHalfSpacing,fourChars);
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) {
@ -151,7 +151,7 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int
bool cursorVol=(cursor.y==i && cursor.xCoarse==j && cursor.xFine==2 && curWindowLast==GUI_WINDOW_PATTERN);
// note
sprintf(id,"%s##PN_%d_%d",noteName(pat->data[i][0],pat->data[i][1]),i,j);
snprintf(id,63,"%.31s##PN_%d_%d",noteName(pat->data[i][0],pat->data[i][1]),i,j);
if (pat->data[i][0]==0 && pat->data[i][1]==0) {
ImGui::PushStyleColor(ImGuiCol_Text,inactiveColor);
} else {
@ -182,7 +182,7 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int
// instrument
if (pat->data[i][2]==-1) {
ImGui::PushStyleColor(ImGuiCol_Text,inactiveColor);
sprintf(id,"..##PI_%d_%d",i,j);
snprintf(id,63,"%.31s##PI_%d_%d",emptyLabel2,i,j);
} else {
if (pat->data[i][2]<0 || pat->data[i][2]>=e->song.insLen) {
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_INS_ERROR]);
@ -194,7 +194,7 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_INS]);
}
}
sprintf(id,"%.2X##PI_%d_%d",pat->data[i][2],i,j);
snprintf(id,63,"%.2X##PI_%d_%d",pat->data[i][2],i,j);
}
ImGui::SameLine(0.0f,0.0f);
if (cursorIns) {
@ -221,13 +221,13 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int
if (e->curSubSong->chanCollapse[j]<2) {
// volume
if (pat->data[i][3]==-1) {
sprintf(id,"..##PV_%d_%d",i,j);
snprintf(id,63,"%.31s##PV_%d_%d",emptyLabel2,i,j);
ImGui::PushStyleColor(ImGuiCol_Text,inactiveColor);
} else {
int volColor=(pat->data[i][3]*127)/chanVolMax;
if (volColor>127) volColor=127;
if (volColor<0) volColor=0;
sprintf(id,"%.2X##PV_%d_%d",pat->data[i][3],i,j);
snprintf(id,63,"%.2X##PV_%d_%d",pat->data[i][3],i,j);
ImGui::PushStyleColor(ImGuiCol_Text,volColors[volColor]);
}
ImGui::SameLine(0.0f,0.0f);
@ -263,15 +263,15 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int
// effect
if (pat->data[i][index]==-1) {
sprintf(id,"..##PE%d_%d_%d",k,i,j);
snprintf(id,63,"%.31s##PE%d_%d_%d",emptyLabel2,k,i,j);
ImGui::PushStyleColor(ImGuiCol_Text,inactiveColor);
} else {
if (pat->data[i][index]>0xff) {
sprintf(id,"??##PE%d_%d_%d",k,i,j);
snprintf(id,63,"??##PE%d_%d_%d",k,i,j);
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_EFFECT_INVALID]);
} else {
const unsigned char data=pat->data[i][index];
sprintf(id,"%.2X##PE%d_%d_%d",data,k,i,j);
snprintf(id,63,"%.2X##PE%d_%d_%d",data,k,i,j);
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[fxColors[data]]);
}
}
@ -297,9 +297,9 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int
// effect value
if (pat->data[i][index+1]==-1) {
sprintf(id,"..##PF%d_%d_%d",k,i,j);
snprintf(id,63,"%.31s##PF%d_%d_%d",emptyLabel2,k,i,j);
} else {
sprintf(id,"%.2X##PF%d_%d_%d",pat->data[i][index+1],k,i,j);
snprintf(id,63,"%.2X##PF%d_%d_%d",pat->data[i][index+1],k,i,j);
}
ImGui::SameLine(0.0f,0.0f);
if (cursorEffectVal) {

View File

@ -21,6 +21,7 @@
#include "fonts.h"
#include "../ta-log.h"
#include "../fileutils.h"
#include "../utfutils.h"
#include "util.h"
#include "guiConst.h"
#include "intConst.h"
@ -1081,6 +1082,15 @@ void FurnaceGUI::drawSettings() {
ImGui::Separator();
ImGui::Text("Pattern view labels:");
ImGui::InputTextWithHint("Note off (3-char)","OFF",&settings.noteOffLabel);
ImGui::InputTextWithHint("Note release (3-char)","===",&settings.noteRelLabel);
ImGui::InputTextWithHint("Macro release (3-char)","REL",&settings.macroRelLabel);
ImGui::InputTextWithHint("Empty field (3-char)","...",&settings.emptyLabel);
ImGui::InputTextWithHint("Empty field (2-char)","..",&settings.emptyLabel2);
ImGui::Separator();
ImGui::Text("Orders row number format:");
if (ImGui::RadioButton("Decimal##orbD",settings.orderRowsBase==0)) {
settings.orderRowsBase=0;
@ -2118,6 +2128,11 @@ void FurnaceGUI::syncSettings() {
settings.noThreadedInput=e->getConfInt("noThreadedInput",0);
settings.initialSysName=e->getConfString("initialSysName","");
settings.clampSamples=e->getConfInt("clampSamples",0);
settings.noteOffLabel=e->getConfString("noteOffLabel","OFF");
settings.noteRelLabel=e->getConfString("noteRelLabel","===");
settings.macroRelLabel=e->getConfString("macroRelLabel","REL");
settings.emptyLabel=e->getConfString("emptyLabel","...");
settings.emptyLabel2=e->getConfString("emptyLabel2","..");
clampSetting(settings.mainFontSize,2,96);
clampSetting(settings.patFontSize,2,96);
@ -2345,6 +2360,11 @@ void FurnaceGUI::commitSettings() {
e->setConf("unsignedDetune",settings.unsignedDetune);
e->setConf("noThreadedInput",settings.noThreadedInput);
e->setConf("clampSamples",settings.clampSamples);
e->setConf("noteOffLabel",settings.noteOffLabel);
e->setConf("noteRelLabel",settings.noteRelLabel);
e->setConf("macroRelLabel",settings.macroRelLabel);
e->setConf("emptyLabel",settings.emptyLabel);
e->setConf("emptyLabel2",settings.emptyLabel2);
// colors
for (int i=0; i<GUI_COLOR_MAX; i++) {
@ -2757,6 +2777,20 @@ void FurnaceGUI::popAccentColors() {
#define SYSTEM_PAT_FONT_PATH_3 "/usr/share/fonts/ubuntu/UbuntuMono-R.ttf"
#endif
void setupLabel(const char* lStr, char* label, int len) {
memset(label,0,32);
for (int i=0, p=0; i<len; i++) {
signed char cl;
if (lStr[p]!=0) {
strncat(label," ",32);
} else {
decodeUTF8((const unsigned char*)&lStr[p],cl);
memcpy(label+p,lStr+p,cl);
p+=cl;
}
}
}
void FurnaceGUI::applyUISettings(bool updateFonts) {
ImGuiStyle sty;
if (settings.guiColorsBase) {
@ -2765,6 +2799,12 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
ImGui::StyleColorsDark(&sty);
}
setupLabel(settings.noteOffLabel.c_str(),noteOffLabel,3);
setupLabel(settings.noteRelLabel.c_str(),noteRelLabel,3);
setupLabel(settings.macroRelLabel.c_str(),macroRelLabel,3);
setupLabel(settings.emptyLabel.c_str(),emptyLabel,3);
setupLabel(settings.emptyLabel2.c_str(),emptyLabel2,2);
if (settings.dpiScale>=0.5f) dpiScale=settings.dpiScale;
// colors

View File

@ -19,7 +19,7 @@
#include "utfutils.h"
int decodeUTF8(const unsigned char* data, char& len) {
int decodeUTF8(const unsigned char* data, signed char& len) {
int ret=0xfffd;
if (data[0]<0x80) {
ret=data[0];
@ -66,7 +66,7 @@ int decodeUTF8(const unsigned char* data, char& len) {
size_t utf8len(const char* s) {
size_t p=0;
size_t r=0;
char cl;
signed char cl;
while (s[p]!=0) {
r++;
decodeUTF8((const unsigned char*)&s[p],cl);
@ -76,7 +76,7 @@ size_t utf8len(const char* s) {
}
char utf8csize(const unsigned char* c) {
char ret;
signed char ret;
decodeUTF8(c,ret);
return ret;
}
@ -84,7 +84,7 @@ char utf8csize(const unsigned char* c) {
WString utf8To16(const char* s) {
WString ret;
int ch, p;
char chs;
signed char chs;
p=0;
while (s[p]!=0) {
ch=decodeUTF8((const unsigned char*)&s[p],chs);

View File

@ -21,6 +21,8 @@
#define _UTFUTILS_H
#include "ta-utils.h"
int decodeUTF8(const unsigned char* data, signed char& len);
size_t utf8len(const char* s);
size_t utf8clen(const char* s);
size_t utf8pos(const char* s, size_t inpos);