mirror of
https://github.com/tildearrow/furnace.git
synced 2025-01-03 14:11:11 +00:00
GUI: introduce power-saving mode
This commit is contained in:
parent
dd8df45519
commit
ef6e63239c
5 changed files with 41 additions and 2 deletions
|
@ -2038,7 +2038,15 @@ bool FurnaceGUI::loop() {
|
|||
|
||||
while (!quit) {
|
||||
SDL_Event ev;
|
||||
if (e->isPlaying()) {
|
||||
WAKE_UP;
|
||||
}
|
||||
if (--drawHalt<=0) {
|
||||
drawHalt=0;
|
||||
if (settings.powerSave) SDL_WaitEventTimeout(NULL,500);
|
||||
}
|
||||
while (SDL_PollEvent(&ev)) {
|
||||
WAKE_UP;
|
||||
ImGui_ImplSDL2_ProcessEvent(&ev);
|
||||
switch (ev.type) {
|
||||
case SDL_MOUSEMOTION: {
|
||||
|
@ -3425,6 +3433,7 @@ FurnaceGUI::FurnaceGUI():
|
|||
wantCaptureKeyboard(false),
|
||||
displayNew(false),
|
||||
vgmExportVersion(0x171),
|
||||
drawHalt(10),
|
||||
curFileDialog(GUI_FILE_OPEN),
|
||||
warnAction(GUI_WARN_OPEN),
|
||||
postWarnAction(GUI_WARN_GENERIC),
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#define unimportant(x) if (x) {handleUnimportant}
|
||||
|
||||
#define MARK_MODIFIED modified=true;
|
||||
#define WAKE_UP drawHalt=16;
|
||||
|
||||
#define TOGGLE_COLOR(x) ((x)?uiColors[GUI_COLOR_TOGGLE_ON]:uiColors[GUI_COLOR_TOGGLE_OFF])
|
||||
|
||||
|
@ -715,6 +716,7 @@ class FurnaceGUI {
|
|||
bool displayNew;
|
||||
bool willExport[32];
|
||||
int vgmExportVersion;
|
||||
int drawHalt;
|
||||
|
||||
FurnaceGUIFileDialogs curFileDialog;
|
||||
FurnaceGUIWarnings warnAction;
|
||||
|
@ -820,6 +822,7 @@ class FurnaceGUI {
|
|||
int cursorMoveNoScroll;
|
||||
int lowLatency;
|
||||
int notePreviewBehavior;
|
||||
int powerSave;
|
||||
unsigned int maxUndoSteps;
|
||||
String mainFontPath;
|
||||
String patFontPath;
|
||||
|
@ -893,6 +896,7 @@ class FurnaceGUI {
|
|||
cursorMoveNoScroll(0),
|
||||
lowLatency(0),
|
||||
notePreviewBehavior(1),
|
||||
powerSave(1),
|
||||
maxUndoSteps(100),
|
||||
mainFontPath(""),
|
||||
patFontPath(""),
|
||||
|
|
|
@ -49,12 +49,19 @@ void FurnaceGUI::readOsc() {
|
|||
for (int i=0; i<512; i++) {
|
||||
int pos=(readPos+(i*total/512))&0x7fff;
|
||||
oscValues[i]=(e->oscBuf[0][pos]+e->oscBuf[1][pos])*0.5f;
|
||||
if (oscValues[i]>0.001f || oscValues[i]<-0.001f) {
|
||||
WAKE_UP;
|
||||
}
|
||||
}
|
||||
|
||||
float peakDecay=0.05f*60.0f*ImGui::GetIO().DeltaTime;
|
||||
for (int i=0; i<2; i++) {
|
||||
peak[i]*=1.0-peakDecay;
|
||||
if (peak[i]<0.0001) peak[i]=0.0;
|
||||
if (peak[i]<0.0001) {
|
||||
peak[i]=0.0;
|
||||
} else {
|
||||
WAKE_UP;
|
||||
}
|
||||
float newPeak=peak[i];
|
||||
for (int j=0; j<total; j++) {
|
||||
int pos=(readPos+j)&0x7fff;
|
||||
|
|
|
@ -890,6 +890,7 @@ void FurnaceGUI::drawPattern() {
|
|||
|
||||
// particle simulation
|
||||
ImDrawList* fdl=ImGui::GetForegroundDrawList();
|
||||
if (!particles.empty()) WAKE_UP;
|
||||
for (size_t i=0; i<particles.size(); i++) {
|
||||
Particle& part=particles[i];
|
||||
if (part.update(frameTime)) {
|
||||
|
|
|
@ -31,6 +31,13 @@
|
|||
|
||||
#define DEFAULT_NOTE_KEYS "5:7;6:4;7:3;8:16;10:6;11:8;12:24;13:10;16:11;17:9;18:26;19:28;20:12;21:17;22:1;23:19;24:23;25:5;26:14;27:2;28:21;29:0;30:100;31:13;32:15;34:18;35:20;36:22;38:25;39:27;43:100;46:101;47:29;48:31;53:102;"
|
||||
|
||||
#if defined(_WIN32) || defined(__APPLE__)
|
||||
#define POWER_SAVE_DEFAULT 1
|
||||
#else
|
||||
// currently off on Linux/other due to Mesa catch-up behavior.
|
||||
#define POWER_SAVE_DEFAULT 0
|
||||
#endif
|
||||
|
||||
const char* mainFonts[]={
|
||||
"IBM Plex Sans",
|
||||
"Liberation Sans",
|
||||
|
@ -301,7 +308,15 @@ void FurnaceGUI::drawSettings() {
|
|||
settings.sysFileDialog=sysFileDialogB;
|
||||
}
|
||||
|
||||
ImGui::Text("Note preview behavioe:");
|
||||
bool powerSaveB=settings.powerSave;
|
||||
if (ImGui::Checkbox("Power-saving mode",&powerSaveB)) {
|
||||
settings.powerSave=powerSaveB;
|
||||
}
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::SetTooltip("saves power by lowering the frame rate to 2fps when idle.\nmay cause issues under Mesa drivers!");
|
||||
}
|
||||
|
||||
ImGui::Text("Note preview behavior:");
|
||||
if (ImGui::RadioButton("Never##npb0",settings.notePreviewBehavior==0)) {
|
||||
settings.notePreviewBehavior=0;
|
||||
}
|
||||
|
@ -1624,6 +1639,7 @@ void FurnaceGUI::syncSettings() {
|
|||
settings.cursorMoveNoScroll=e->getConfInt("cursorMoveNoScroll",0);
|
||||
settings.lowLatency=e->getConfInt("lowLatency",0);
|
||||
settings.notePreviewBehavior=e->getConfInt("notePreviewBehavior",1);
|
||||
settings.powerSave=e->getConfInt("powerSave",POWER_SAVE_DEFAULT);
|
||||
|
||||
clampSetting(settings.mainFontSize,2,96);
|
||||
clampSetting(settings.patFontSize,2,96);
|
||||
|
@ -1686,6 +1702,7 @@ void FurnaceGUI::syncSettings() {
|
|||
clampSetting(settings.cursorMoveNoScroll,0,1);
|
||||
clampSetting(settings.lowLatency,0,1);
|
||||
clampSetting(settings.notePreviewBehavior,0,3);
|
||||
clampSetting(settings.powerSave,0,1);
|
||||
|
||||
// keybinds
|
||||
for (int i=0; i<GUI_ACTION_MAX; i++) {
|
||||
|
@ -1775,6 +1792,7 @@ void FurnaceGUI::commitSettings() {
|
|||
e->setConf("cursorMoveNoScroll",settings.cursorMoveNoScroll);
|
||||
e->setConf("lowLatency",settings.lowLatency);
|
||||
e->setConf("notePreviewBehavior",settings.notePreviewBehavior);
|
||||
e->setConf("powerSave",settings.powerSave);
|
||||
|
||||
// colors
|
||||
for (int i=0; i<GUI_COLOR_MAX; i++) {
|
||||
|
|
Loading…
Reference in a new issue