GUI: find and replace, part 9
This commit is contained in:
		
							parent
							
								
									fa9fb6f8f5
								
							
						
					
					
						commit
						7354b1221c
					
				| 
						 | 
					@ -4,6 +4,7 @@
 | 
				
			||||||
#include "misc/cpp/imgui_stdlib.h"
 | 
					#include "misc/cpp/imgui_stdlib.h"
 | 
				
			||||||
#include "guiConst.h"
 | 
					#include "guiConst.h"
 | 
				
			||||||
#include "intConst.h"
 | 
					#include "intConst.h"
 | 
				
			||||||
 | 
					#include "../ta-log.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char* queryModes[GUI_QUERY_MAX]={
 | 
					const char* queryModes[GUI_QUERY_MAX]={
 | 
				
			||||||
  "ignore",
 | 
					  "ignore",
 | 
				
			||||||
| 
						 | 
					@ -140,13 +141,12 @@ void FurnaceGUI::doFind() {
 | 
				
			||||||
          matched=true;
 | 
					          matched=true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (matched) {
 | 
					        if (matched) {
 | 
				
			||||||
          curQueryResults.push_back(FurnaceGUIQueryResult(e->getCurrentSubSong(),i,j,k));
 | 
					          curQueryResults.push_back(FurnaceGUIQueryResult(e->getCurrentSubSong(),i,k,j));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  queryViewingResults=true;
 | 
				
			||||||
  printf("%d %d %d %d\n",firstOrder,lastOrder,firstRow,lastRow);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define FIRST_VISIBLE(x) (x==GUI_QUERY_MATCH || x==GUI_QUERY_MATCH_NOT || x==GUI_QUERY_RANGE || x==GUI_QUERY_RANGE_NOT)
 | 
					#define FIRST_VISIBLE(x) (x==GUI_QUERY_MATCH || x==GUI_QUERY_MATCH_NOT || x==GUI_QUERY_RANGE || x==GUI_QUERY_RANGE_NOT)
 | 
				
			||||||
| 
						 | 
					@ -167,13 +167,85 @@ void FurnaceGUI::drawFindReplace() {
 | 
				
			||||||
    int index=0;
 | 
					    int index=0;
 | 
				
			||||||
    int eraseIndex=-1;
 | 
					    int eraseIndex=-1;
 | 
				
			||||||
    char tempID[1024];
 | 
					    char tempID[1024];
 | 
				
			||||||
 | 
					    if (ImGui::BeginTabBar("FindOrReplace")) {
 | 
				
			||||||
 | 
					      if (ImGui::BeginTabItem("Find")) {
 | 
				
			||||||
 | 
					        if (queryViewingResults) {
 | 
				
			||||||
 | 
					          if (!curQueryResults.empty()) {
 | 
				
			||||||
 | 
					            ImVec2 avail=ImGui::GetContentRegionAvail();
 | 
				
			||||||
 | 
					            avail.y-=ImGui::GetFrameHeightWithSpacing();
 | 
				
			||||||
 | 
					            if (ImGui::BeginTable("FindResults",4,ImGuiTableFlags_Borders|ImGuiTableFlags_ScrollY,avail)) {
 | 
				
			||||||
 | 
					              ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed,ImGui::CalcTextSize("order").x);
 | 
				
			||||||
 | 
					              ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthFixed,ImGui::CalcTextSize("row").x);
 | 
				
			||||||
 | 
					              ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch);
 | 
				
			||||||
 | 
					              ImGui::TableSetupColumn("c3",ImGuiTableColumnFlags_WidthFixed);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					              ImGui::TableSetupScrollFreeze(0,1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					              ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
 | 
				
			||||||
 | 
					              ImGui::TableNextColumn();
 | 
				
			||||||
 | 
					              ImGui::Text("order");
 | 
				
			||||||
 | 
					              ImGui::TableNextColumn();
 | 
				
			||||||
 | 
					              ImGui::Text("row");
 | 
				
			||||||
 | 
					              ImGui::TableNextColumn();
 | 
				
			||||||
 | 
					              ImGui::Text("channel");
 | 
				
			||||||
 | 
					              ImGui::TableNextColumn();
 | 
				
			||||||
 | 
					              ImGui::Text("go");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					              int index=0;
 | 
				
			||||||
 | 
					              for (FurnaceGUIQueryResult& i: curQueryResults) {
 | 
				
			||||||
 | 
					                ImGui::TableNextRow();
 | 
				
			||||||
 | 
					                ImGui::TableNextColumn();
 | 
				
			||||||
 | 
					                if (settings.orderRowsBase==1) {
 | 
				
			||||||
 | 
					                  ImGui::Text("%.2X",i.order);
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                  ImGui::Text("%d",i.order);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                ImGui::TableNextColumn();
 | 
				
			||||||
 | 
					                if (settings.patRowsBase==1) {
 | 
				
			||||||
 | 
					                  ImGui::Text("%.2X",i.y);
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                  ImGui::Text("%d",i.y);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                ImGui::TableNextColumn();
 | 
				
			||||||
 | 
					                ImGui::Text("%d (%s)",i.x+1,e->getChannelName(i.x));
 | 
				
			||||||
 | 
					                if (ImGui::TableNextColumn()) {
 | 
				
			||||||
 | 
					                  snprintf(tempID,1024,ICON_FA_CHEVRON_RIGHT "##_FR%d",index);
 | 
				
			||||||
 | 
					                  if (ImGui::Selectable(tempID)) {
 | 
				
			||||||
 | 
					                    e->changeSongP(i.subsong);
 | 
				
			||||||
 | 
					                    if (e->isPlaying()) {
 | 
				
			||||||
 | 
					                      followPattern=false;
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                      e->setOrder(i.order);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    curOrder=i.order;
 | 
				
			||||||
 | 
					                    cursor.xCoarse=i.x;
 | 
				
			||||||
 | 
					                    cursor.xFine=0;
 | 
				
			||||||
 | 
					                    cursor.y=i.y;
 | 
				
			||||||
 | 
					                    selStart=cursor;
 | 
				
			||||||
 | 
					                    selEnd=cursor;
 | 
				
			||||||
 | 
					                    demandScrollX=true;
 | 
				
			||||||
 | 
					                    updateScroll(cursor.y);
 | 
				
			||||||
 | 
					                    nextWindow=GUI_WINDOW_PATTERN;
 | 
				
			||||||
 | 
					                  }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                index++;
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					              ImGui::EndTable();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          } else {
 | 
				
			||||||
 | 
					            ImGui::Text("no matches found!");
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					          if (ImGui::Button("Back")) {
 | 
				
			||||||
 | 
					            queryViewingResults=false;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
          for (FurnaceGUIFindQuery& i: curQuery) {
 | 
					          for (FurnaceGUIFindQuery& i: curQuery) {
 | 
				
			||||||
 | 
					            ImGui::PushID(index+0x100);
 | 
				
			||||||
            if (ImGui::BeginTable("FindRep",4,ImGuiTableFlags_BordersOuter)) {
 | 
					            if (ImGui::BeginTable("FindRep",4,ImGuiTableFlags_BordersOuter)) {
 | 
				
			||||||
              ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed);
 | 
					              ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed);
 | 
				
			||||||
              ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.5);
 | 
					              ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.5);
 | 
				
			||||||
              ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch,0.25);
 | 
					              ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch,0.25);
 | 
				
			||||||
              ImGui::TableSetupColumn("c3",ImGuiTableColumnFlags_WidthStretch,0.25);
 | 
					              ImGui::TableSetupColumn("c3",ImGuiTableColumnFlags_WidthStretch,0.25);
 | 
				
			||||||
        ImGui::PushID(index);
 | 
					 | 
				
			||||||
              ImGui::TableNextRow();
 | 
					              ImGui::TableNextRow();
 | 
				
			||||||
              ImGui::TableNextColumn();
 | 
					              ImGui::TableNextColumn();
 | 
				
			||||||
              ImGui::Text("Note");
 | 
					              ImGui::Text("Note");
 | 
				
			||||||
| 
						 | 
					@ -402,15 +474,11 @@ void FurnaceGUI::drawFindReplace() {
 | 
				
			||||||
                  i.effectCount--;
 | 
					                  i.effectCount--;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
        ImGui::PopID();
 | 
					 | 
				
			||||||
              ImGui::EndTable();
 | 
					              ImGui::EndTable();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            ImGui::PopID();
 | 
				
			||||||
            index++;
 | 
					            index++;
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
    if (ImGui::Button("Find")) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    ImGui::SameLine();
 | 
					 | 
				
			||||||
          if (eraseIndex>=0) {
 | 
					          if (eraseIndex>=0) {
 | 
				
			||||||
            curQuery.erase(curQuery.begin()+eraseIndex);
 | 
					            curQuery.erase(curQuery.begin()+eraseIndex);
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
| 
						 | 
					@ -487,14 +555,16 @@ void FurnaceGUI::drawFindReplace() {
 | 
				
			||||||
              ImGui::SetTooltip("match effects only if they appear exactly as specified.");
 | 
					              ImGui::SetTooltip("match effects only if they appear exactly as specified.");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      ImGui::TableNextRow();
 | 
					 | 
				
			||||||
      ImGui::TableNextColumn();
 | 
					 | 
				
			||||||
      ImGui::Checkbox("Backwards",&curQueryBackwards);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            ImGui::EndTable();
 | 
					            ImGui::EndTable();
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (ImGui::TreeNode("Replace")) {
 | 
					          if (ImGui::Button("Find")) {
 | 
				
			||||||
 | 
					            doFind();
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        ImGui::EndTabItem();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      if (ImGui::BeginTabItem("Replace")) {
 | 
				
			||||||
        if (ImGui::BeginTable("QueryReplace",3,ImGuiTableFlags_BordersOuter)) {
 | 
					        if (ImGui::BeginTable("QueryReplace",3,ImGuiTableFlags_BordersOuter)) {
 | 
				
			||||||
          ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed);
 | 
					          ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed);
 | 
				
			||||||
          ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.5);
 | 
					          ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.5);
 | 
				
			||||||
| 
						 | 
					@ -675,7 +745,9 @@ void FurnaceGUI::drawFindReplace() {
 | 
				
			||||||
        if (ImGui::Button("Replace##QueryReplace")) {
 | 
					        if (ImGui::Button("Replace##QueryReplace")) {
 | 
				
			||||||
          // TODO
 | 
					          // TODO
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      ImGui::TreePop();
 | 
					        ImGui::EndTabItem();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      ImGui::EndTabBar();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_FIND;
 | 
					  if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_FIND;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4450,6 +4450,7 @@ FurnaceGUI::FurnaceGUI():
 | 
				
			||||||
  queryReplaceNoteDo(false),
 | 
					  queryReplaceNoteDo(false),
 | 
				
			||||||
  queryReplaceInsDo(false),
 | 
					  queryReplaceInsDo(false),
 | 
				
			||||||
  queryReplaceVolDo(false),
 | 
					  queryReplaceVolDo(false),
 | 
				
			||||||
 | 
					  queryViewingResults(false),
 | 
				
			||||||
  wavePreviewOn(false),
 | 
					  wavePreviewOn(false),
 | 
				
			||||||
  wavePreviewKey((SDL_Scancode)0),
 | 
					  wavePreviewKey((SDL_Scancode)0),
 | 
				
			||||||
  wavePreviewNote(0),
 | 
					  wavePreviewNote(0),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1208,6 +1208,7 @@ class FurnaceGUI {
 | 
				
			||||||
  bool queryReplaceVolDo;
 | 
					  bool queryReplaceVolDo;
 | 
				
			||||||
  bool queryReplaceEffectDo[8];
 | 
					  bool queryReplaceEffectDo[8];
 | 
				
			||||||
  bool queryReplaceEffectValDo[8];
 | 
					  bool queryReplaceEffectValDo[8];
 | 
				
			||||||
 | 
					  bool queryViewingResults;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  struct ActiveNote {
 | 
					  struct ActiveNote {
 | 
				
			||||||
    int chan;
 | 
					    int chan;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue