GUI: dynamic wave list buttons
This commit is contained in:
parent
cf4a2fa902
commit
b5cb1d626c
|
@ -786,6 +786,22 @@ void FurnaceGUI::drawWaveList(bool asChild) {
|
||||||
began=ImGui::Begin("Wavetables",&waveListOpen,globalWinFlags,_("Wavetables"));
|
began=ImGui::Begin("Wavetables",&waveListOpen,globalWinFlags,_("Wavetables"));
|
||||||
}
|
}
|
||||||
if (began) {
|
if (began) {
|
||||||
|
// hide buttons if there isn't enough space
|
||||||
|
// buttons and their space requirements:
|
||||||
|
// - new: 2
|
||||||
|
// - duplicate: 6
|
||||||
|
// - open: 3
|
||||||
|
// - save: 5
|
||||||
|
// - folder view: 7
|
||||||
|
// - move up: 8
|
||||||
|
// - move down: 8
|
||||||
|
// - delete: 4
|
||||||
|
float buttonSize=ImGui::GetStyle().FramePadding.x*2.0f+settings.iconSize*dpiScale+ImGui::GetStyle().ItemSpacing.x;
|
||||||
|
float buttonSpace=ImGui::GetContentRegionAvail().x/MAX(1.0f,buttonSize);
|
||||||
|
bool mustOpenNewFolder=false;
|
||||||
|
|
||||||
|
if (buttonSpace>=2.0f) {
|
||||||
|
// add
|
||||||
if (ImGui::Button(ICON_FA_PLUS "##WaveAdd")) {
|
if (ImGui::Button(ICON_FA_PLUS "##WaveAdd")) {
|
||||||
doAction(GUI_ACTION_WAVE_LIST_ADD);
|
doAction(GUI_ACTION_WAVE_LIST_ADD);
|
||||||
}
|
}
|
||||||
|
@ -793,6 +809,10 @@ void FurnaceGUI::drawWaveList(bool asChild) {
|
||||||
ImGui::SetTooltip(_("Add"));
|
ImGui::SetTooltip(_("Add"));
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buttonSpace>=6.0f) {
|
||||||
|
// duplicate
|
||||||
if (ImGui::Button(ICON_FA_FILES_O "##WaveClone")) {
|
if (ImGui::Button(ICON_FA_FILES_O "##WaveClone")) {
|
||||||
doAction(GUI_ACTION_WAVE_LIST_DUPLICATE);
|
doAction(GUI_ACTION_WAVE_LIST_DUPLICATE);
|
||||||
}
|
}
|
||||||
|
@ -800,6 +820,10 @@ void FurnaceGUI::drawWaveList(bool asChild) {
|
||||||
ImGui::SetTooltip(_("Duplicate"));
|
ImGui::SetTooltip(_("Duplicate"));
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buttonSpace>=3.0f) {
|
||||||
|
// open
|
||||||
if (ImGui::Button(ICON_FA_FOLDER_OPEN "##WaveLoad")) {
|
if (ImGui::Button(ICON_FA_FOLDER_OPEN "##WaveLoad")) {
|
||||||
doAction(GUI_ACTION_WAVE_LIST_OPEN);
|
doAction(GUI_ACTION_WAVE_LIST_OPEN);
|
||||||
}
|
}
|
||||||
|
@ -813,6 +837,10 @@ void FurnaceGUI::drawWaveList(bool asChild) {
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buttonSpace>=5.0f) {
|
||||||
|
// save
|
||||||
if (ImGui::Button(ICON_FA_FLOPPY_O "##WaveSave")) {
|
if (ImGui::Button(ICON_FA_FLOPPY_O "##WaveSave")) {
|
||||||
doAction(GUI_ACTION_WAVE_LIST_SAVE);
|
doAction(GUI_ACTION_WAVE_LIST_SAVE);
|
||||||
}
|
}
|
||||||
|
@ -834,6 +862,10 @@ void FurnaceGUI::drawWaveList(bool asChild) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buttonSpace>=7.0f) {
|
||||||
|
// dir mode
|
||||||
pushToggleColors(waveListDir);
|
pushToggleColors(waveListDir);
|
||||||
if (ImGui::Button(ICON_FA_SITEMAP "##WaveDirMode")) {
|
if (ImGui::Button(ICON_FA_SITEMAP "##WaveDirMode")) {
|
||||||
doAction(GUI_ACTION_WAVE_LIST_DIR_VIEW);
|
doAction(GUI_ACTION_WAVE_LIST_DIR_VIEW);
|
||||||
|
@ -842,8 +874,12 @@ void FurnaceGUI::drawWaveList(bool asChild) {
|
||||||
if (ImGui::IsItemHovered()) {
|
if (ImGui::IsItemHovered()) {
|
||||||
ImGui::SetTooltip(_("Toggle folders/standard view"));
|
ImGui::SetTooltip(_("Toggle folders/standard view"));
|
||||||
}
|
}
|
||||||
if (!waveListDir) {
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buttonSpace>=(waveListDir?7.0f:8.0f)) {
|
||||||
|
// move up/down
|
||||||
|
if (!waveListDir) {
|
||||||
if (ImGui::Button(ICON_FA_ARROW_UP "##WaveUp")) {
|
if (ImGui::Button(ICON_FA_ARROW_UP "##WaveUp")) {
|
||||||
doAction(GUI_ACTION_WAVE_LIST_MOVE_UP);
|
doAction(GUI_ACTION_WAVE_LIST_MOVE_UP);
|
||||||
}
|
}
|
||||||
|
@ -858,11 +894,93 @@ void FurnaceGUI::drawWaveList(bool asChild) {
|
||||||
ImGui::SetTooltip(_("Move down"));
|
ImGui::SetTooltip(_("Move down"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ImGui::SameLine();
|
|
||||||
if (ImGui::Button(ICON_FA_FOLDER "##WaveFolder")) {
|
if (ImGui::Button(ICON_FA_FOLDER "##WaveFolder")) {
|
||||||
folderString="";
|
mustOpenNewFolder=true;
|
||||||
}
|
}
|
||||||
if (ImGui::BeginPopupContextItem("NewWaveFolder",ImGuiMouseButton_Left)) {
|
if (ImGui::IsItemHovered()) {
|
||||||
|
ImGui::SetTooltip(_("New folder"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buttonSpace>=4.0f) {
|
||||||
|
// delete
|
||||||
|
pushDestColor();
|
||||||
|
if (ImGui::Button(ICON_FA_TIMES "##WaveDelete")) {
|
||||||
|
doAction(GUI_ACTION_WAVE_LIST_DELETE);
|
||||||
|
}
|
||||||
|
popDestColor();
|
||||||
|
if (ImGui::IsItemHovered()) {
|
||||||
|
ImGui::SetTooltip(_("Delete"));
|
||||||
|
}
|
||||||
|
if (buttonSpace<8.0f) {
|
||||||
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buttonSpace<(waveListDir?7.0f:8.0f)) {
|
||||||
|
if (ImGui::Button(ICON_FA_ELLIPSIS_H "##WaveMore")) {
|
||||||
|
}
|
||||||
|
if (ImGui::BeginPopupContextItem("WaveListMore",ImGuiMouseButton_Left)) {
|
||||||
|
if (buttonSpace<2.0f) if (ImGui::MenuItem("add")) {
|
||||||
|
doAction(GUI_ACTION_WAVE_LIST_ADD);
|
||||||
|
}
|
||||||
|
if (buttonSpace<6.0f) if (ImGui::MenuItem("duplicate")) {
|
||||||
|
doAction(GUI_ACTION_WAVE_LIST_DUPLICATE);
|
||||||
|
}
|
||||||
|
if (buttonSpace<3.0f) {
|
||||||
|
if (ImGui::MenuItem("open...")) {
|
||||||
|
doAction(GUI_ACTION_WAVE_LIST_OPEN);
|
||||||
|
}
|
||||||
|
if (ImGui::MenuItem("replace...")) {
|
||||||
|
doAction((curWave>=0 && curWave<(int)e->song.wave.size())?GUI_ACTION_WAVE_LIST_OPEN_REPLACE:GUI_ACTION_WAVE_LIST_OPEN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (buttonSpace<5.0f) {
|
||||||
|
if (ImGui::MenuItem("save...")) {
|
||||||
|
doAction(GUI_ACTION_WAVE_LIST_SAVE);
|
||||||
|
}
|
||||||
|
if (ImGui::MenuItem(_("save as .dmw..."))) {
|
||||||
|
doAction(GUI_ACTION_WAVE_LIST_SAVE_DMW);
|
||||||
|
}
|
||||||
|
if (ImGui::MenuItem(_("save raw..."))) {
|
||||||
|
doAction(GUI_ACTION_WAVE_LIST_SAVE_RAW);
|
||||||
|
}
|
||||||
|
if (ImGui::MenuItem(_("save all..."))) {
|
||||||
|
doAction(GUI_ACTION_WAVE_LIST_SAVE_ALL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (buttonSpace<7.0f) if (ImGui::MenuItem("folder view",NULL,waveListDir)) {
|
||||||
|
doAction(GUI_ACTION_WAVE_LIST_DIR_VIEW);
|
||||||
|
}
|
||||||
|
if (buttonSpace<(waveListDir?7.0f:8.0f)) {
|
||||||
|
if (!waveListDir) {
|
||||||
|
if (ImGui::MenuItem("move up")) {
|
||||||
|
doAction(GUI_ACTION_WAVE_LIST_MOVE_UP);
|
||||||
|
}
|
||||||
|
if (ImGui::MenuItem("move down")) {
|
||||||
|
doAction(GUI_ACTION_WAVE_LIST_MOVE_DOWN);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (ImGui::MenuItem("new folder")) {
|
||||||
|
mustOpenNewFolder=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (buttonSpace<4.0f) if (ImGui::MenuItem("delete")) {
|
||||||
|
doAction(GUI_ACTION_WAVE_LIST_DELETE);
|
||||||
|
}
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mustOpenNewFolder) {
|
||||||
|
folderString="";
|
||||||
|
ImGui::OpenPopup("NewWaveFolder");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::BeginPopup("NewWaveFolder",ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings)) {
|
||||||
ImGui::InputText("##FolderName",&folderString);
|
ImGui::InputText("##FolderName",&folderString);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::BeginDisabled(folderString.empty());
|
ImGui::BeginDisabled(folderString.empty());
|
||||||
|
@ -875,19 +993,7 @@ void FurnaceGUI::drawWaveList(bool asChild) {
|
||||||
ImGui::EndDisabled();
|
ImGui::EndDisabled();
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
if (ImGui::IsItemHovered()) {
|
|
||||||
ImGui::SetTooltip(_("New folder"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ImGui::SameLine();
|
|
||||||
pushDestColor();
|
|
||||||
if (ImGui::Button(ICON_FA_TIMES "##WaveDelete")) {
|
|
||||||
doAction(GUI_ACTION_WAVE_LIST_DELETE);
|
|
||||||
}
|
|
||||||
popDestColor();
|
|
||||||
if (ImGui::IsItemHovered()) {
|
|
||||||
ImGui::SetTooltip(_("Delete"));
|
|
||||||
}
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
if (ImGui::BeginTable("WaveListScroll",1,ImGuiTableFlags_ScrollY)) {
|
if (ImGui::BeginTable("WaveListScroll",1,ImGuiTableFlags_ScrollY)) {
|
||||||
actualWaveList();
|
actualWaveList();
|
||||||
|
|
Loading…
Reference in a new issue