Skip to content

Commit cbc7c3a

Browse files
authored
Merge branch 'beta' into chart-nps-graph
2 parents 553f41c + e2ced99 commit cbc7c3a

File tree

11 files changed

+97
-2
lines changed

11 files changed

+97
-2
lines changed

bin/settings/shortcuts.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ SELECT_QUANT_48 =
3838
SELECT_QUANT_64 =
3939
SELECT_QUANT_192 =
4040

41+
SELECT_DENSITY_1 =
42+
SELECT_DENSITY_2 =
43+
SELECT_DENSITY_3 =
44+
SELECT_DENSITY_4 =
45+
SELECT_DENSITY_5 =
46+
SELECT_DENSITY_6 =
47+
SELECT_DENSITY_7 =
48+
SELECT_DENSITY_8 =
49+
SELECT_DENSITY_9 =
50+
SELECT_DENSITY_10 =
51+
4152
SELECT_TEMPO_BPM =
4253
SELECT_TEMPO_STOP =
4354
SELECT_TEMPO_DELAY =

src/Editor/Action.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,10 @@ void Action::perform(Type action) {
408408
if (action >= FILE_OPEN_RECENT_BEGIN && action < FILE_OPEN_RECENT_END) {
409409
gEditor->openSimfile(action - FILE_OPEN_RECENT_BEGIN);
410410
}
411+
if (action >= SELECT_DENSITY_BEGIN && action < SELECT_DENSITY_END) {
412+
gSelection->selectNotes(SelectModifier::SELECT_SET,
413+
action - SELECT_DENSITY_BEGIN + 1);
414+
}
411415
if (action >= SET_NOTESKIN_BEGIN && action < SET_NOTESKIN_END) {
412416
gNoteskin->setType(action - SET_NOTESKIN_BEGIN);
413417
}

src/Editor/Action.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <Core/Core.h>
4+
#include <Editor/Common.h>
45

56
namespace Vortex {
67

@@ -82,6 +83,9 @@ enum Type {
8283
SELECT_QUANT_64,
8384
SELECT_QUANT_192,
8485

86+
SELECT_DENSITY_BEGIN,
87+
SELECT_DENSITY_END = SELECT_DENSITY_BEGIN + SIM_MAX_COLUMNS,
88+
8589
SELECT_TEMPO_BPM,
8690
SELECT_TEMPO_STOP,
8791
SELECT_TEMPO_DELAY,

src/Editor/Menubar.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ struct MenuBarImpl : public Menubar {
3838

3939
Item* myFileMenu;
4040
Item* myVisualSyncMenu;
41+
Item* myNotesSelectMenu;
4142
Item* myViewMenu;
4243
Item* myBeatlineMenu;
4344
Item* myPreviewMenu;
@@ -159,8 +160,9 @@ struct MenuBarImpl : public Menubar {
159160
add(hSelectQuant, SELECT_QUANT_192, "192nd");
160161

161162
// Notes > Select menu.
162-
Item* hSelection = newMenu();
163+
Item* hSelection = myNotesSelectMenu = newMenu();
163164
sub(hSelection, hSelectQuant, "Quantization");
165+
add(hSelection, 0 /*dummy*/, "Density");
164166
sep(hSelection);
165167
add(hSelection, SELECT_ALL_STEPS, "Steps");
166168
add(hSelection, SELECT_ALL_MINES, "Mines");
@@ -499,6 +501,18 @@ struct MenuBarImpl : public Menubar {
499501
MENU->myViewMenu->setChecked(TOGGLE_CHART_PREVIEW,
500502
gView->hasChartPreview());
501503
};
504+
myUpdateFunctions[SELECT_DENSITY] = [] {
505+
Item* density = newMenu();
506+
int numCol = gStyle->getNumCols();
507+
if (numCol > 0) {
508+
for (int i = 0; i < numCol; ++i) {
509+
add(density, static_cast<Type>(SELECT_DENSITY_BEGIN + i),
510+
Str::val(i + 1).c_str());
511+
}
512+
}
513+
MENU->myNotesSelectMenu->replaceSubmenu(1, density, "Density",
514+
(numCol == 0));
515+
};
502516
myUpdateFunctions[VIEW_MODE] = [] {
503517
MENU->myViewMenu->setChecked(USE_ROW_BASED_VIEW,
504518
!gView->isTimeBased());

src/Editor/Menubar.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ struct Menubar {
2929

3030
VISUAL_SYNC_ANCHOR,
3131

32+
SELECT_DENSITY,
33+
3234
BEATLINE_ENABLED,
3335
BEATLINE_SNAP,
3436
BEATLINE_COLOR,

src/Editor/Selection.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,13 @@ struct SelectionImpl : public Selection {
293293
return numSelected;
294294
}
295295

296+
int selectNotes(SelectModifier mod, int density,
297+
bool ignoreRegion) override {
298+
int numSelected = gNotes->selectDensity(mod, density, ignoreRegion);
299+
showSelectionResult(mod, numSelected);
300+
return numSelected;
301+
}
302+
296303
int selectNotes(SelectModifier mod, RowCol begin, RowCol end,
297304
bool ignoreRegion) override {
298305
int numSelected = gNotes->selectRows(mod, begin.col, end.col, begin.row,

src/Editor/Selection.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ struct Selection : public InputHandler {
3434
virtual int selectNotes(NotesMan::Filter filter,
3535
bool ignoreRegion = false) = 0;
3636
virtual int selectNotes(RowType rowType, bool ignoreRegion = false) = 0;
37+
virtual int selectNotes(SelectModifier t, int density,
38+
bool ignoreRegion = false) = 0;
3739
virtual int selectNotes(SelectModifier t, RowCol begin, RowCol end,
3840
bool ignoreRegion = false) = 0;
3941
virtual int selectNotes(SelectModifier t, const Vector<RowCol>& indices,

src/Editor/Shortcuts.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,27 @@ static ActionEntry actionMap[] = {
368368
E(SHOW_SHORTCUTS),
369369
E(SHOW_MESSAGE_LOG),
370370
E(SHOW_DEBUG_LOG),
371-
E(SHOW_ABOUT)
371+
E(SHOW_ABOUT),
372372

373373
#undef E
374374

375+
#define E_DENSITY(n) \
376+
{"SELECT_DENSITY_" #n, \
377+
static_cast<Action::Type>(SELECT_DENSITY_BEGIN + (n - 1))}
378+
379+
E_DENSITY(1),
380+
E_DENSITY(2),
381+
E_DENSITY(3),
382+
E_DENSITY(4),
383+
E_DENSITY(5),
384+
E_DENSITY(6),
385+
E_DENSITY(7),
386+
E_DENSITY(8),
387+
E_DENSITY(9),
388+
E_DENSITY(10)
389+
390+
#undef E_DENSITY
391+
375392
};
376393

377394
static const int NUM_MAPPED_ACTIONS = sizeof(actionMap) / sizeof(actionMap[0]);

src/Managers/NoteMan.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,35 @@ struct NotesManImpl : public NotesMan {
528528
return numSelected;
529529
}
530530

531+
int selectDensity(SelectModifier mod, int density,
532+
bool ignoreRegion) override {
533+
auto first = myNotes.begin();
534+
auto last = myNotes.end() - 1;
535+
536+
return performSelection(
537+
mod, ignoreRegion, [&](const ExpandedNote* note) {
538+
if (note->isMine) {
539+
return false;
540+
}
541+
542+
int count = 1;
543+
for (const ExpandedNote* it = note - 1;
544+
it >= first && it->row == note->row; --it) {
545+
if (!it->isMine) {
546+
count++;
547+
}
548+
}
549+
for (const ExpandedNote* it = note + 1;
550+
it <= last && it->row == note->row; ++it) {
551+
if (!it->isMine) {
552+
count++;
553+
}
554+
}
555+
556+
return count == density;
557+
});
558+
}
559+
531560
int selectRows(SelectModifier mod, int firstCol, int lastCol, int firstRow,
532561
int lastRow, bool ignoreRegion) override {
533562
auto region = gSelection->getSelectedRegion();

src/Managers/NoteMan.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ struct NotesMan {
4242
virtual void deselectAll() = 0;
4343
virtual int selectAll() = 0;
4444
virtual int selectQuant(int rowType, bool ignoreRegion) = 0;
45+
virtual int selectDensity(SelectModifier mod, int rowType,
46+
bool ignoreRegion) = 0;
4547
virtual int selectRows(SelectModifier mod, int beginCol, int endCol,
4648
int beginRow, int endRow, bool ignoreRegion) = 0;
4749
virtual int selectTime(SelectModifier mod, int beginCol, int endCol,

0 commit comments

Comments
 (0)