Skip to content

Commit

Permalink
Instrument: Change current instrument, even if locked, when user chan…
Browse files Browse the repository at this point in the history
…ges current track with keyboard. Fix for #1412
  • Loading branch information
kjetil_matheussen committed Feb 25, 2024
1 parent 2c41b55 commit b520d2d
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Qt/Qt_MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ void handleDropEvent(QString filename, float x){
if (tracknum != -1)
setInstrumentForTrack(instrument_id, tracknum, -1, -1);

GFX_update_instrument_patch_gui(PATCH_get_from_id(instrument_id));
GFX_update_instrument_patch_gui(PATCH_get_from_id(instrument_id), true);
}

}UNDO_CLOSE();
Expand Down
13 changes: 11 additions & 2 deletions Qt/Qt_instruments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,15 @@ static bool patch_used_in_current_editor_block(struct Patch *patch){
static void GFX_PP_Update_internal(struct Patch *patch, bool is_loading, bool open_even_if_locked){
//printf("GFX_PP_Update %s\n", patch==NULL?"(null)":patch->name);

#if 0
if (open_even_if_locked){
if (isPlaying()){
printf("Gakk gakk!\n");
printf("hmm\n");
}
}
#endif

struct Patch *old_current = PATCH_get_current();

if (old_current != NULL && g_is_loading==false && open_even_if_locked==false && isCurrentInstrumentLocked())
Expand Down Expand Up @@ -965,12 +974,12 @@ void InstrumentWidget_delete(struct Patch *patch){
}
}

void GFX_update_instrument_patch_gui(struct Patch *patch){
void GFX_update_instrument_patch_gui(struct Patch *patch, bool even_if_locked){
//printf("Called GFX_update_instrument_patch_gui for patch \"%s\"\n",patch==NULL?"<>":patch->name);
if(patch!=NULL && patch->patchdata!=NULL){
R_ASSERT_RETURN_IF_FALSE(patch->instrument != NULL);
if (patch->instrument->PP_Update!=NULL)
patch->instrument->PP_Update( patch->instrument, patch, false, false );
patch->instrument->PP_Update( patch->instrument, patch, false, even_if_locked);
}
#if 0
if(wblock->wtrack->track->patch!=NULL && wblock->wtrack->track->patch->instrument->PP_Update!=NULL)
Expand Down
16 changes: 8 additions & 8 deletions api/api_navigate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ void requestCursorMove(void){

int tracknum = atoi(trackstring);
if (tracknum >= 0)
setCurrentTrack(tracknum, -2, window->l.num);
setCurrentTrack(tracknum, -2, window->l.num, true);
}

if (strlen(line) > 0) {
Expand Down Expand Up @@ -375,10 +375,10 @@ void selectPrevPlaylistBlock(void){
}

void selectTrack(int tracknum,int windownum){
setCurrentTrack(tracknum, -2, windownum);
setCurrentTrack(tracknum, -2, windownum, false);
}

void setCurrentTrack(int tracknum, int subtrack, int windownum){
void setCurrentTrack(int tracknum, int subtrack, int windownum, bool switch_instrument_even_if_locked){
struct Tracker_Windows *window=getWindowFromNum(windownum);
if(window==NULL) return;

Expand Down Expand Up @@ -445,7 +445,7 @@ void setCurrentTrack(int tracknum, int subtrack, int windownum){
}

GFX_adjust_skew_x(window, wblock, prevcurrtrack);
GFX_update_instrument_patch_gui(wtrack->track->patch);
GFX_update_instrument_patch_gui(wtrack->track->patch, switch_instrument_even_if_locked);
GFX_show_curr_track_in_statusbar(window, wblock);

window->must_redraw = true;
Expand Down Expand Up @@ -637,7 +637,7 @@ void cursorRight(int windownum){
if (!canCursorMoveToTrack(tracknum, subtracknum, -1, windownum))
return;

setCurrentTrack(tracknum, subtracknum, windownum);
setCurrentTrack(tracknum, subtracknum, windownum, true);
}

void cursorNextTrack(int windownum){
Expand Down Expand Up @@ -687,7 +687,7 @@ void cursorNextTrack(int windownum){
subtracknum = num_subtracks -1;
}

setCurrentTrack(tracknum, subtracknum, windownum);
setCurrentTrack(tracknum, subtracknum, windownum, true);
}

static int get_previous_legal_track(int tracknum, int windownum){
Expand Down Expand Up @@ -776,7 +776,7 @@ void cursorLeft(int windownum){
if (!canCursorMoveToTrack(tracknum, subtracknum, -1, windownum))
return;

setCurrentTrack(tracknum, subtracknum, windownum);
setCurrentTrack(tracknum, subtracknum, windownum, true);
}

void cursorPrevTrack(int windownum){
Expand Down Expand Up @@ -823,7 +823,7 @@ void cursorPrevTrack(int windownum){
subtracknum = num_subtracks -1;
}

setCurrentTrack(tracknum, subtracknum, windownum);
setCurrentTrack(tracknum, subtracknum, windownum, true);
}


Expand Down
2 changes: 1 addition & 1 deletion api/protos.conf
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ selectTrack | int tracknum | int windownum ? -1
# Swing: -2
# Tempo automation: -1
#
setCurrentTrack | int tracknum | int subtrack ? -2 | int windownum ? -1 # subtrack==-2 means try to use same subtrack as for the current track. Also note that the notetext subtrack is always -1. The swing subtracks numbers are always 0,1,2 (even though swing is to the left of the note).
setCurrentTrack | int tracknum | int subtrack ? -2 | int windownum ? -1 | bool switch_instrument_even_if_locked ? false # subtrack==-2 means try to use same subtrack as for the current track. Also note that the notetext subtrack is always -1. The swing subtracks numbers are always 0,1,2 (even though swing is to the left of the note).
int getCurrentTrack | int windownum ? -1
int getCurrentSubtrack | int windownum ? -1
int getNumSubtracks | int tracknum ? -1 | int blocknum ? -1 | int windownum ? -1 # returns the number of possible horizontal cursor positions.
Expand Down
2 changes: 1 addition & 1 deletion audio/Faust_plugins_template1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static float linear2db(float val){
#endif

#define MIN_LINEAR_VELOCITY 0.1
static float g_min_linear_gain = 0.001995; // = powf(10, R_SCALE(MIN_LINEAR_VELOCITY, 0.0, 1.0 ,-40, 20) / 20.0f) / 10.0f;
static constexpr float g_min_linear_gain = 0.001995; // = powf(10, R_SCALE(MIN_LINEAR_VELOCITY, 0.0, 1.0 ,-40, 20) / 20.0f) / 10.0f;

// input is between 0 and 1.
// output is between 0 and 1.
Expand Down
2 changes: 1 addition & 1 deletion common/OS_visual_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ extern LANGSPEC void OS_GFX_NumUndosHaveChanged(int num_undos, bool redos_are_av
extern LANGSPEC void OS_GFX_SetVolume(int value);
extern LANGSPEC void OS_GFX_IncVolume(int how_much);

extern LANGSPEC void GFX_update_instrument_patch_gui(struct Patch *patch);
extern LANGSPEC void GFX_update_instrument_patch_gui(struct Patch *patch, bool even_if_locked);
extern LANGSPEC void GFX_remove_patch_gui(struct Patch *patch); // Also deletes the audio object itself. (yes, it's messy)

struct SoundPlugin;
Expand Down
2 changes: 1 addition & 1 deletion common/block_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void Block_Set_num_tracks(
wblock=(struct WBlocks *)ListFindElement1(&window->wblocks->l,block->l.num);

if (wblock==window->wblock)
setCurrentTrack(num_tracks-1, -1, window->l.num);
setCurrentTrack(num_tracks-1, -1, window->l.num, false);
}
CutListAt1(&block->tracks,num_tracks);
while(window!=NULL){
Expand Down
2 changes: 1 addition & 1 deletion common/disk_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ static bool Load_CurrPos_org(struct Tracker_Windows *window, filepath_t filename
GFX_EditorWindowToFront(root->song->tracker_windows);

struct WBlocks *wblock = root->song->tracker_windows->wblock;
GFX_update_instrument_patch_gui(wblock->wtrack->track->patch);
GFX_update_instrument_patch_gui(wblock->wtrack->track->patch, false);

root->song->tracker_windows->must_redraw = true;

Expand Down
2 changes: 1 addition & 1 deletion common/threading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ priority_t THREADING_get_priority(void){
}

#if !defined(RELEASE)
enum R_thread_is_RT __thread g_t_current_thread_is_RT = R_UNINITIALIZED;
enum R_thread_is_RT __thread g_t_current_thread_is_RT = R_UNINITIALIZED; // Inefficient way store thread-local variables, but only used in DEBUG mode.
#endif


Expand Down
4 changes: 2 additions & 2 deletions common/track_insert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ void InsertTracks_CurrPos(
curr_track=wblock->block->num_tracks-1;
}

setCurrentTrack(0, -1, window->l.num);
setCurrentTrack(curr_track, -1, window->l.num);
setCurrentTrack(0, -1, window->l.num, false);
setCurrentTrack(curr_track, -1, window->l.num, false);

window->must_redraw = true;
}
Expand Down
4 changes: 2 additions & 2 deletions common/undo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,8 +868,8 @@ static void undo_internal(void){
}

if(current_patch!=NULL){
GFX_update_instrument_patch_gui(current_patch);
GFX_update_instrument_widget(current_patch);
GFX_update_instrument_patch_gui(current_patch, false);
GFX_update_instrument_widget(current_patch);
}

window->must_redraw = true; // We do this instead of calling GE_set_curr_realline. GE_set_curr_realline can also cause flickering if editor is redrawn at the same time.
Expand Down
4 changes: 2 additions & 2 deletions common/wblocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ void SelectWBlock(struct Tracker_Windows *window,struct WBlocks *wblock, bool fo
ATOMIC_WRITE(window->curr_track, newcurrtrack);

if (window->wblock==wblock)
setCurrentTrack(newcurrtrack, newcurrtracksub, window->l.num);
setCurrentTrack(newcurrtrack, newcurrtracksub, window->l.num, false);

//if (SetCursorPosConcrete(window,wblock,newcurrtrack,newcurrtracksub)==false)
// ATOMIC_WRITE(window->curr_track, 0);
Expand All @@ -527,7 +527,7 @@ void SelectWBlock(struct Tracker_Windows *window,struct WBlocks *wblock, bool fo

if(false==is_playing() && false==PlayerIsCurrentlyPlayingLoop()){
R_ASSERT_RETURN_IF_FALSE(wblock->wtrack->track != NULL);
GFX_update_instrument_patch_gui(wblock->wtrack->track->patch);
GFX_update_instrument_patch_gui(wblock->wtrack->track->patch, false);
}

//window->must_redraw = false;
Expand Down
4 changes: 2 additions & 2 deletions common/wtracks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ void MinimizeBlock_CurrPos(
wblock->skew_x = 0;

if (wblock==window->wblock)
setCurrentTrack(0, -1, window->l.num);
setCurrentTrack(0, -1, window->l.num, false);

wblock->temponodearea.width=2;
wtrack=wblock->wtracks;
Expand Down Expand Up @@ -708,7 +708,7 @@ void MinimizeBlock_CurrPos(
window->must_redraw = true;

if( ! is_playing()){
GFX_update_instrument_patch_gui(wblock->wtrack->track->patch);
GFX_update_instrument_patch_gui(wblock->wtrack->track->patch, false);
}
}

Expand Down
14 changes: 8 additions & 6 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,12 @@ then
fi

# libxcb
if [[ $RADIUM_INSTALL_LIBXCB != 0 ]]
then
cp -a packages/libxcb-1.13 "$TARGET/packages/"
cd "$TARGET/packages/libxcb-1.13/src"
rm -f ./*.o
cd "$THIS_DIR/bin"
if uname -s |grep Linux ; then
if [[ $RADIUM_INSTALL_LIBXCB != 0 ]]
then
cp -a packages/libxcb-1.13 "$TARGET/packages/"
cd "$TARGET/packages/libxcb-1.13/src"
rm -f ./*.o
cd "$THIS_DIR/bin"
fi
fi
2 changes: 1 addition & 1 deletion macosx/cocoa_Keyboard.m
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ int OS_SYSTEM_get_modifier(void *void_event){
//case 54: // Right Command (we don't use this one anymore, it's usually not available, and the "menu" key is a bit work to turn into a modifier key)
//return EVENT_EXTRA_R;
case 54: // Right Command (we don't use this one anymore, it's usually not available, and the "menu" key is a bit work to turn into a modifier key)
return EVENT_CTRL_R; // We always map left Cmd into left Ctrl since left Ctrl is not always available on mac.
return EVENT_CTRL_R; // We always map right Cmd into right Ctrl since right Ctrl is not always available on mac.
case 55: // Left Command
if (swapCtrlAndCmd())
return EVENT_CTRL_L;
Expand Down

0 comments on commit b520d2d

Please sign in to comment.