Qt TAS row selection in work.

This commit is contained in:
mjbudd77 2021-11-06 09:47:03 -04:00
parent 4acf8ab61b
commit b2244b3a0b
2 changed files with 46 additions and 40 deletions

View File

@ -425,20 +425,8 @@ void SELECTION::noteThatItemRangeChanged(int startItem, int endItem, int newValu
} }
void SELECTION::noteThatItemChanged(int item, int newValue ) void SELECTION::noteThatItemChanged(int item, int newValue )
{ {
int oldValue = 0; bool ON = newValue;
std::map <int, int>::iterator it; bool OFF = !newValue;
if ( selList.size() > 0 )
{
it = selList.find(item);
if ( it != selList.end() )
{
oldValue = it->second;
}
}
bool ON = !oldValue && newValue;
bool OFF = oldValue && !newValue;
//if the item is -1, apply the change to all items //if the item is -1, apply the change to all items
if (item == -1) if (item == -1)
@ -579,8 +567,11 @@ void SELECTION::clearSingleRowSelection(int index)
if ( it != selList.end() ) if ( it != selList.end() )
{ {
noteThatItemChanged(index, 1); if ( it->second )
it->second = 0; {
noteThatItemChanged(index, 0);
}
selList.erase(it);
} }
} }
void SELECTION::clearRegionOfRowsSelection(int start, int end) void SELECTION::clearRegionOfRowsSelection(int start, int end)
@ -596,6 +587,7 @@ void SELECTION::clearRegionOfRowsSelection(int start, int end)
{ {
selList[i] = 0; selList[i] = 0;
} }
noteThatItemRangeChanged(start, end, 0);
} }
void SELECTION::selectAllRows(void) void SELECTION::selectAllRows(void)
@ -610,10 +602,24 @@ void SELECTION::selectAllRows(void)
} }
void SELECTION::setRowSelection(int index) void SELECTION::setRowSelection(int index)
{ {
noteThatItemChanged(index, 1); std::map <int, int>::iterator it;
selList[index] = 1;
it = selList.find(index);
if ( it != selList.end() )
{
if ( !it->second )
{
noteThatItemChanged(index, 1);
it->second = 1;
}
}
else
{
noteThatItemChanged(index, 1);
selList[index] = 1;
}
//ListView_SetItemState(pianoRoll.hwndList, index, LVIS_SELECTED, LVIS_SELECTED); //ListView_SetItemState(pianoRoll.hwndList, index, LVIS_SELECTED, LVIS_SELECTED);
printf("Set Row Selection:%i\n", index);
} }
void SELECTION::setRegionOfRowsSelection(int start, int end) void SELECTION::setRegionOfRowsSelection(int start, int end)
{ {

View File

@ -11,18 +11,18 @@ typedef std::set<int> RowsSelection;
class SELECTION class SELECTION
{ {
public: public:
SELECTION(); SELECTION(void);
void init(); void init(void);
void free(); void free(void);
void reset(); void reset(void);
void reset_vars(); void reset_vars(void);
void update(); void update(void);
void updateSelectionSize(); void updateSelectionSize(void);
void updateHistoryLogSize(); void updateHistoryLogSize(void);
void redrawMarkerData(); void redrawMarkerData(void);
void save(EMUFILE *os, bool really_save = true); void save(EMUFILE *os, bool really_save = true);
bool load(EMUFILE *is, unsigned int offset); bool load(EMUFILE *is, unsigned int offset);
@ -33,26 +33,26 @@ public:
void noteThatItemRangeChanged(int startItem, int endItem, int newValue); void noteThatItemRangeChanged(int startItem, int endItem, int newValue);
void noteThatItemChanged(int itemIndex, int value); void noteThatItemChanged(int itemIndex, int value);
void addNewSelectionToHistory(); void addNewSelectionToHistory(void);
void addCurrentSelectionToHistory(); void addCurrentSelectionToHistory(void);
void undo(); void undo(void);
void redo(); void redo(void);
bool isRowSelected(int index); bool isRowSelected(int index);
void clearAllRowsSelection(); void clearAllRowsSelection(void);
void clearSingleRowSelection(int index); void clearSingleRowSelection(int index);
void clearRegionOfRowsSelection(int start, int end); void clearRegionOfRowsSelection(int start, int end);
void selectAllRows(); void selectAllRows(void);
void setRowSelection(int index); void setRowSelection(int index);
void setRegionOfRowsSelection(int start, int end); void setRegionOfRowsSelection(int start, int end);
void setRegionOfRowsSelectionUsingPattern(int start, int end); void setRegionOfRowsSelectionUsingPattern(int start, int end);
void selectAllRowsBetweenMarkers(); void selectAllRowsBetweenMarkers(void);
void reselectClipboard(); void reselectClipboard(void);
void transposeVertically(int shift); void transposeVertically(int shift);
@ -62,10 +62,10 @@ public:
void jumpToFrame(int frame); void jumpToFrame(int frame);
// getters // getters
int getCurrentRowsSelectionSize(); int getCurrentRowsSelectionSize(void);
int getCurrentRowsSelectionBeginning(); int getCurrentRowsSelectionBeginning(void);
int getCurrentRowsSelectionEnd(); int getCurrentRowsSelectionEnd(void);
RowsSelection* getCopyOfCurrentRowsSelection(); RowsSelection* getCopyOfCurrentRowsSelection(void);
bool mustFindCurrentMarker; bool mustFindCurrentMarker;
int displayedMarkerNumber; int displayedMarkerNumber;