From aeeaa9ca1d516dd87322c624b52143dd8d09f95f Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 22 Jun 2023 19:49:45 -0500 Subject: [PATCH] GUI: change color of destructive actions --- src/gui/dataList.cpp | 6 ++++++ src/gui/gui.cpp | 1 + src/gui/gui.h | 7 ++++++- src/gui/guiConst.cpp | 2 +- src/gui/settings.cpp | 29 +++++++++++++++++++++++++++++ src/gui/subSongs.cpp | 2 ++ 6 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/gui/dataList.cpp b/src/gui/dataList.cpp index 2ccbca943..77084e06f 100644 --- a/src/gui/dataList.cpp +++ b/src/gui/dataList.cpp @@ -693,6 +693,7 @@ void FurnaceGUI::drawInsList(bool asChild) { } } ImGui::SameLine(); + pushDestColor(); if (ImGui::Button(ICON_FA_TIMES "##InsDelete")) { if (settings.unifiedDataView) { switch (lastAssetType) { @@ -710,6 +711,7 @@ void FurnaceGUI::drawInsList(bool asChild) { doAction(GUI_ACTION_INS_LIST_DELETE); } } + popDestColor(); if (ImGui::IsItemHovered()) { ImGui::SetTooltip("Delete"); } @@ -930,9 +932,11 @@ void FurnaceGUI::drawWaveList(bool asChild) { } } ImGui::SameLine(); + pushDestColor(); if (ImGui::Button(ICON_FA_TIMES "##WaveDelete")) { doAction(GUI_ACTION_WAVE_LIST_DELETE); } + popDestColor(); if (ImGui::IsItemHovered()) { ImGui::SetTooltip("Delete"); } @@ -1070,9 +1074,11 @@ void FurnaceGUI::drawSampleList(bool asChild) { } } ImGui::SameLine(); + pushDestColor(); if (ImGui::Button(ICON_FA_TIMES "##SampleDelete")) { doAction(GUI_ACTION_SAMPLE_LIST_DELETE); } + popDestColor(); if (ImGui::IsItemHovered()) { ImGui::SetTooltip("Delete"); } diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index a51f9ab89..4edaeab23 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -6575,6 +6575,7 @@ FurnaceGUI::FurnaceGUI(): portrait(false), injectBackUp(false), mobileMenuOpen(false), + warnColorPushed(false), wantCaptureKeyboard(false), oldWantCaptureKeyboard(false), displayMacroMenu(false), diff --git a/src/gui/gui.h b/src/gui/gui.h index b6e77306c..77199a6cb 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -1299,7 +1299,7 @@ class FurnaceGUI { bool quit, warnQuit, willCommit, edit, modified, displayError, displayExporting, vgmExportLoop, zsmExportLoop, vgmExportPatternHints; bool vgmExportDirectStream, displayInsTypeList; - bool portrait, injectBackUp, mobileMenuOpen; + bool portrait, injectBackUp, mobileMenuOpen, warnColorPushed; bool wantCaptureKeyboard, oldWantCaptureKeyboard, displayMacroMenu; bool displayNew, fullScreen, preserveChanPos, wantScrollList, noteInputPoly; bool displayPendingIns, pendingInsSingle, displayPendingRawSample, snesFilterHex, modTableHex, displayEditString; @@ -2084,6 +2084,11 @@ class FurnaceGUI { void pushAccentColors(const ImVec4& one, const ImVec4& two, const ImVec4& border, const ImVec4& borderShadow); void popAccentColors(); + void pushDestColor(); + void popDestColor(); + void pushWarningColor(bool warnCond, bool errorCond=false); + void popWarningColor(); + float calcBPM(const DivGroovePattern& speeds, float hz, int vN, int vD); void patternRow(int i, bool isPlaying, float lineHeight, int chans, int ord, const DivPattern** patCache, bool inhibitSel); diff --git a/src/gui/guiConst.cpp b/src/gui/guiConst.cpp index 40f987081..25364d2d9 100644 --- a/src/gui/guiConst.cpp +++ b/src/gui/guiConst.cpp @@ -742,7 +742,7 @@ const FurnaceGUIColorDef guiColors[GUI_COLOR_MAX]={ D(GUI_COLOR_TOGGLE_ON,"",ImVec4(0.2f,0.6f,0.2f,1.0f)), D(GUI_COLOR_EDITING,"",ImVec4(0.2f,0.1f,0.1f,1.0f)), D(GUI_COLOR_SONG_LOOP,"",ImVec4(0.3f,0.5f,0.8f,0.4f)), - D(GUI_COLOR_DESTRUCTIVE,"",ImVec4(0.8f,0.3f,0.3f,1.0f)), + D(GUI_COLOR_DESTRUCTIVE,"",ImVec4(1.0f,0.2f,0.2f,1.0f)), D(GUI_COLOR_WARNING,"",ImVec4(0.98f,0.98f,0.06f,1.0f)), D(GUI_COLOR_ERROR,"",ImVec4(0.98f,0.06f,0.11f,1.0f)), diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index 9551d6669..33a6c5c6e 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -3495,6 +3495,35 @@ void FurnaceGUI::popAccentColors() { ImGui::PopStyleColor(24); } +void FurnaceGUI::pushDestColor() { + pushAccentColors(uiColors[GUI_COLOR_DESTRUCTIVE],uiColors[GUI_COLOR_DESTRUCTIVE],uiColors[GUI_COLOR_DESTRUCTIVE],ImVec4(0.0f,0.0f,0.0f,0.0f)); +} + +void FurnaceGUI::popDestColor() { + popAccentColors(); +} + +void FurnaceGUI::pushWarningColor(bool warnCond, bool errorCond) { + if (warnColorPushed) { + logE("warnColorPushed"); + abort(); + } + if (errorCond) { + pushAccentColors(uiColors[GUI_COLOR_ERROR],uiColors[GUI_COLOR_ERROR],uiColors[GUI_COLOR_ERROR],ImVec4(0.0f,0.0f,0.0f,0.0f)); + warnColorPushed=true; + } else if (warnCond) { + pushAccentColors(uiColors[GUI_COLOR_WARNING],uiColors[GUI_COLOR_WARNING],uiColors[GUI_COLOR_WARNING],ImVec4(0.0f,0.0f,0.0f,0.0f)); + warnColorPushed=true; + } +} + +void FurnaceGUI::popWarningColor() { + if (warnColorPushed) { + popAccentColors(); + warnColorPushed=false; + } +} + #define IGFD_FileStyleByExtension IGFD_FileStyleByExtention #ifdef _WIN32 diff --git a/src/gui/subSongs.cpp b/src/gui/subSongs.cpp index c0056b723..86fb2cb3c 100644 --- a/src/gui/subSongs.cpp +++ b/src/gui/subSongs.cpp @@ -92,6 +92,7 @@ void FurnaceGUI::drawSubSongs(bool asChild) { ImGui::SetTooltip("Add"); } ImGui::SameLine(); + pushDestColor(); if (ImGui::Button(ICON_FA_MINUS "##SubSongDel")) { if (e->song.subsong.size()<=1) { showError("this is the only subsong!"); @@ -99,6 +100,7 @@ void FurnaceGUI::drawSubSongs(bool asChild) { showWarning("are you sure you want to remove this subsong?",GUI_WARN_SUBSONG_DEL); } } + popDestColor(); if (ImGui::IsItemHovered()) { ImGui::SetTooltip("Remove"); }