GUI: add ability to select entire row

when clicking on row number
This commit is contained in:
tildearrow 2022-05-14 01:46:06 -05:00
parent 297ab01d4c
commit 1ba5ac6766
5 changed files with 54 additions and 22 deletions

View file

@ -16,7 +16,6 @@
- try to find out why does VSlider not accept keyboard input
- finish lock layout
- if macros have release, note off should release them
- add ability to select entire row when clicking on row number
- store edit/followOrders/followPattern state in config
- add ability to select a column by double clicking
- add ability to move selection by dragging

View file

@ -21,28 +21,48 @@
#include "actionUtil.h"
void FurnaceGUI::startSelection(int xCoarse, int xFine, int y) {
void FurnaceGUI::startSelection(int xCoarse, int xFine, int y, bool fullRow) {
DETERMINE_FIRST_LAST;
if (xCoarse!=selStart.xCoarse || xFine!=selStart.xFine || y!=selStart.y) {
curNibble=false;
}
cursor.xCoarse=xCoarse;
cursor.xFine=xFine;
cursor.y=y;
selStart.xCoarse=xCoarse;
selStart.xFine=xFine;
selStart.y=y;
selEnd.xCoarse=xCoarse;
selEnd.xFine=xFine;
selEnd.y=y;
if (fullRow) {
selStart.xCoarse=firstChannel;
selStart.xFine=0;
selEnd.xCoarse=lastChannel-1;
selEnd.xFine=2+e->song.pat[selEnd.xCoarse].effectCols*2;
selStart.y=y;
selEnd.y=y;
} else {
cursor.xCoarse=xCoarse;
cursor.xFine=xFine;
cursor.y=y;
selStart.xCoarse=xCoarse;
selStart.xFine=xFine;
selStart.y=y;
selEnd.xCoarse=xCoarse;
selEnd.xFine=xFine;
selEnd.y=y;
}
selecting=true;
selectingFull=fullRow;
e->setMidiBaseChan(cursor.xCoarse);
}
void FurnaceGUI::updateSelection(int xCoarse, int xFine, int y) {
void FurnaceGUI::updateSelection(int xCoarse, int xFine, int y, bool fullRow) {
if (!selecting) return;
selEnd.xCoarse=xCoarse;
selEnd.xFine=xFine;
selEnd.y=y;
if (selectingFull) {
DETERMINE_LAST;
selEnd.xCoarse=lastChannel-1;
selEnd.xFine=2+e->song.pat[selEnd.xCoarse].effectCols*2;
selEnd.y=y;
} else {
selEnd.xCoarse=xCoarse;
selEnd.xFine=xFine;
selEnd.y=y;
}
}
void FurnaceGUI::finishSelection() {
@ -66,6 +86,7 @@ void FurnaceGUI::finishSelection() {
selEnd.xFine^=selStart.xFine;
}
selecting=false;
selectingFull=false;
// boundary check
int chanCount=e->getTotalChannelCount();

View file

@ -2350,7 +2350,7 @@ bool FurnaceGUI::loop() {
}
sampleDragActive=false;
if (selecting) {
cursor=selEnd;
if (!selectingFull) cursor=selEnd;
finishSelection();
demandScrollX=true;
if (cursor.xCoarse==selStart.xCoarse && cursor.xFine==selStart.xFine && cursor.y==selStart.y &&
@ -3975,6 +3975,7 @@ FurnaceGUI::FurnaceGUI():
chanOscDocked(false),
*/
selecting(false),
selectingFull(false),
curNibble(false),
orderNibble(false),
followOrders(true),

View file

@ -1016,7 +1016,7 @@ class FurnaceGUI {
*/
SelectionPoint selStart, selEnd, cursor;
bool selecting, curNibble, orderNibble, followOrders, followPattern, changeAllOrders, mobileUI;
bool selecting, selectingFull, curNibble, orderNibble, followOrders, followPattern, changeAllOrders, mobileUI;
bool collapseWindow, demandScrollX, fancyPattern, wantPatName, firstFrame, tempoView, waveHex, lockLayout, editOptsVisible, latchNibble, nonLatchNibble;
FurnaceGUIWindows curWindow, nextWindow, curWindowLast;
float peak[2];
@ -1121,7 +1121,7 @@ class FurnaceGUI {
ImVec2 patWindowPos, patWindowSize;
// pattern view specific
ImVec2 threeChars, twoChars;
ImVec2 fourChars, threeChars, twoChars;
SelectionPoint sel1, sel2;
int dummyRows, demandX;
int transposeAmount, randomizeMin, randomizeMax, fadeMin, fadeMax;
@ -1262,8 +1262,8 @@ class FurnaceGUI {
void commitSettings();
void processDrags(int dragX, int dragY);
void startSelection(int xCoarse, int xFine, int y);
void updateSelection(int xCoarse, int xFine, int y);
void startSelection(int xCoarse, int xFine, int y, bool fullRow=false);
void updateSelection(int xCoarse, int xFine, int y, bool fullRow=false);
void finishSelection();
void moveCursor(int x, int y, bool select);

View file

@ -88,11 +88,21 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int
}
}
// row number
ImGui::PushStyleColor(ImGuiCol_Text,rowIndexColor);
if (settings.patRowsBase==1) {
ImGui::TextColored(rowIndexColor," %.2X ",i);
snprintf(id,31," %.2X ##PR_%d",i,i);
} else {
ImGui::TextColored(rowIndexColor,"%3d ",i);
snprintf(id,31,"%3d ##PR_%d",i,i);
}
ImGui::Selectable(id,false,ImGuiSelectableFlags_NoPadWithHalfSpacing,fourChars);
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) {
updateSelection(0,0,i,true);
}
if (ImGui::IsItemClicked()) {
startSelection(0,0,i,true);
}
ImGui::PopStyleColor();
// for each column
for (int j=0; j<chans; j++) {
// check if channel is not hidden
@ -535,6 +545,7 @@ void FurnaceGUI::drawPattern() {
ImGui::TextColored(uiColors[GUI_COLOR_EE_VALUE]," %.2X",e->getExtValue());
}
float oneCharSize=ImGui::CalcTextSize("A").x;
fourChars=ImVec2(oneCharSize*4.0f,lineHeight);
threeChars=ImVec2(oneCharSize*3.0f,lineHeight);
twoChars=ImVec2(oneCharSize*2.0f,lineHeight);
//ImVec2 oneChar=ImVec2(oneCharSize,lineHeight);