Skip to content

Commit

Permalink
Merge pull request #2341 from AllenInstitute/bugfix/2341-better-listb…
Browse files Browse the repository at this point in the history
…ox-modes

Prefer Listbox modes with more natural shortcuts
  • Loading branch information
t-b authored Feb 13, 2025
2 parents fdad71e + 631a97c commit d95d80e
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 64 deletions.
27 changes: 13 additions & 14 deletions Packages/MIES/MIES_AnalysisBrowser.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1353,8 +1353,8 @@ static Function/WAVE AB_ReturnAndClearGUISelBits()

WAVE expBrowserSel = GetExperimentBrowserGUISel()

Make/FREE/N=(DimSize(expBrowserSel, ROWS)) selBits = expBrowserSel[p][0] & LISTBOX_SELECTED
expBrowserSel[][0] = expBrowserSel[p][0] & ~LISTBOX_SELECTED
Make/FREE/N=(DimSize(expBrowserSel, ROWS)) selBits = expBrowserSel[p][0] & LISTBOX_SELECT_OR_SHIFT_SELECTION
expBrowserSel[][0] = expBrowserSel[p][0] & ~LISTBOX_SELECT_OR_SHIFT_SELECTION

return selBits
End
Expand Down Expand Up @@ -1469,11 +1469,11 @@ End
/// @returns valid indizes wave on success
static Function/WAVE AB_GetExpandedIndices()

variable i, row, numEntries
variable i, row

WAVE expBrowserSel = GetExperimentBrowserGUISel()
// Our mode for the listbox stores the selection bit only in the first column
WAVE/Z wv = FindIndizes(expBrowserSel, var = 1, prop = PROP_MATCHES_VAR_BIT_MASK)
WAVE/Z wv = FindIndizes(expBrowserSel, col = 0, var = LISTBOX_SELECT_OR_SHIFT_SELECTION, prop = PROP_MATCHES_VAR_BIT_MASK)
if(!WaveExists(wv))
Make/FREE/N=0 wv
return wv
Expand All @@ -1482,18 +1482,17 @@ static Function/WAVE AB_GetExpandedIndices()
// expand all selected treeviews
// as indizes might change during the loop run we have to determine the
// dimension size in the loop condition
numEntries = DimSize(wv, ROWS)
for(i = 0; i < numEntries; i += 1)
for(i = 0; i < DimSize(wv, ROWS); i += 1) // NOLINT
row = wv[i]

// we have to refetch the selected entries
if(!AB_ExpandIfCollapsed(row, EXPERIMENT_TREEVIEW_COLUMN))
WAVE wv = FindIndizes(expBrowserSel, var = 1, prop = PROP_MATCHES_VAR_BIT_MASK)
WAVE wv = FindIndizes(expBrowserSel, col = 0, var = LISTBOX_SELECT_OR_SHIFT_SELECTION, prop = PROP_MATCHES_VAR_BIT_MASK)
i = 0
endif

if(!AB_ExpandIfCollapsed(row, DEVICE_TREEVIEW_COLUMN))
WAVE wv = FindIndizes(expBrowserSel, var = 1, prop = PROP_MATCHES_VAR_BIT_MASK)
WAVE wv = FindIndizes(expBrowserSel, col = 0, var = LISTBOX_SELECT_OR_SHIFT_SELECTION, prop = PROP_MATCHES_VAR_BIT_MASK)
i = 0
endif
endfor
Expand Down Expand Up @@ -2750,7 +2749,7 @@ Function AB_ButtonProc_Refresh(STRUCT WMButtonAction &ba) : ButtonControl

WAVE/T folderList = GetAnalysisBrowserGUIFolderList()
WAVE folderSelection = GetAnalysisBrowserGUIFolderSelection()
WAVE/Z indices = FindIndizes(folderSelection, col = 0, var = 0x1, prop = PROP_MATCHES_VAR_BIT_MASK)
WAVE/Z indices = FindIndizes(folderSelection, col = 0, var = LISTBOX_SELECT_OR_SHIFT_SELECTION, prop = PROP_MATCHES_VAR_BIT_MASK)
if(!WaveExists(indices))
size = DimSize(folderList, ROWS)
Make/FREE/N=(size) indices
Expand Down Expand Up @@ -2985,7 +2984,7 @@ Function AB_ButtonProc_SelectStimSets(STRUCT WMButtonAction &ba) : ButtonControl
WAVE/T expBrowserList = GetExperimentBrowserGUIList()
WAVE expBrowserSel = GetExperimentBrowserGUISel()

WAVE/Z indizes = FindIndizes(expBrowserSel, var = 1)
WAVE/Z indizes = FindIndizes(expBrowserSel, col = 0, var = LISTBOX_SELECT_OR_SHIFT_SELECTION, prop = PROP_MATCHES_VAR_BIT_MASK)

if(!WaveExists(indizes) || DimSize(indizes, ROWS) != 1)
print "Please select exactly one row to use this feature"
Expand All @@ -3001,12 +3000,12 @@ Function AB_ButtonProc_SelectStimSets(STRUCT WMButtonAction &ba) : ButtonControl
break
endif

WAVE indizes = FindIndizes(expBrowserList, colLabel = "stim sets", str = selectedStimSet)
expBrowserSel[][] = expBrowserSel[p][q] & ~LISTBOX_SELECTED
WAVE indizes = FindIndizes(expBrowserList, col = 0, colLabel = "stim sets", str = selectedStimSet)
expBrowserSel[][] = expBrowserSel[p][q] & ~(LISTBOX_SELECT_OR_SHIFT_SELECTION)

numEntries = DimSize(indizes, ROWS)
for(i = 0; i < numEntries; i += 1)
expBrowserSel[indizes[i]][] = expBrowserSel[p][q] | LISTBOX_SELECTED
expBrowserSel[indizes[i]][] = expBrowserSel[p][q] | LISTBOX_SELECT_OR_SHIFT_SELECTION
endfor

break
Expand Down Expand Up @@ -3108,7 +3107,7 @@ Function AB_ButtonProc_OpenCommentNB(STRUCT WMButtonAction &ba) : ButtonControl
WAVE expBrowserSel = GetExperimentBrowserGUISel()
WAVE/T map = GetAnalysisBrowserMap()

WAVE/Z indizes = FindIndizes(expBrowserSel, var = 1)
WAVE/Z indizes = FindIndizes(expBrowserSel, col = 0, var = LISTBOX_SELECT_OR_SHIFT_SELECTION, prop = PROP_MATCHES_VAR_BIT_MASK)

if(!WaveExists(indizes) || DimSize(indizes, ROWS) != 1)
print "Please select a sweep belonging to a device to use this feature"
Expand Down
4 changes: 2 additions & 2 deletions Packages/MIES/MIES_AnalysisBrowser_Macro.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Window AnalysisBrowser() : Panel
ListBox list_experiment_contents, userdata(ResizeControlsInfo)=A"!!,FS!!#A%!!#E8J,htSz!!#](Aon\"Qzzzzzzzzzzzzzz!!#o2B4uAezz"
ListBox list_experiment_contents, userdata(ResizeControlsInfo)+=A"zzzzzzzzzzzz!!#u:Du]k<zzzzzzzzzzz"
ListBox list_experiment_contents, userdata(ResizeControlsInfo)+=A"zzz!!#?(FEDG<zzzzzzzzzzzzzz!!!"
ListBox list_experiment_contents, mode=4
ListBox list_experiment_contents, mode=9
ListBox list_experiment_contents, widths={40, 322, 65, 21, 94, 57, 50, 77, 159, 63, 42, 42}
ListBox list_experiment_contents, userColumnResize=1
Button button_select_same_stim_sets, pos={6.00, 151.00}, size={100.00, 30.00}, proc=AB_ButtonProc_SelectStimSets
Expand Down Expand Up @@ -78,7 +78,7 @@ Window AnalysisBrowser() : Panel
ListBox listbox_AB_Folders, userdata(ResizeControlsInfo)=A"!!,FS!!#97!!#E85QF.Xz!!#](Aon\"Qzzzzzzzzzzzzzz!!#o2B4uAezz"
ListBox listbox_AB_Folders, userdata(ResizeControlsInfo)+=A"zzzzzzzzzzzz!!#u:Du]k<zzzzzzzzzzz"
ListBox listbox_AB_Folders, userdata(ResizeControlsInfo)+=A"zzz!!#u:Du]k<zzzzzzzzzzzzzz!!!"
ListBox listbox_AB_Folders, labelBack=(65535, 65535, 65535), mode=4
ListBox listbox_AB_Folders, labelBack=(65535, 65535, 65535), mode=9
Button button_AB_AddFolder, pos={7.00, 5.00}, size={100.00, 25.00}, proc=AB_ButtonProc_AddFolder
Button button_AB_AddFolder, title="Add folder"
Button button_AB_AddFolder, help={"Add a new folder to the list"}
Expand Down
12 changes: 9 additions & 3 deletions Packages/MIES/MIES_AnalysisBrowser_SweepBrowser.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -630,10 +630,16 @@ Function SB_PopupMenuSelectSweep(STRUCT WMPopupAction &pa) : PopupMenuControl

PGC_SetAndActivateControl(bsPanel, "check_BrowserSettings_DS", val = CHECKBOX_UNSELECTED)

WAVE sweeps = SB_GetPlainSweepList(win)
newIndex = pa.popNum - 1
newSweep = sweeps[newIndex]
SetSetVariable(win, "setvar_SweepControl_SweepNo", newSweep)

if(BSP_IsDataBrowser(win))
WAVE sweeps = SB_GetPlainSweepList(win)
newSweep = sweeps[newIndex]

SetSetVariable(win, "setvar_SweepControl_SweepNo", newSweep)
else
SetSetVariable(win, "setvar_SweepControl_SweepNo", newIndex)
endif

if(OVS_IsActive(win))
OVS_ChangeSweepSelectionState(win, CHECKBOX_SELECTED, index = newIndex)
Expand Down
49 changes: 16 additions & 33 deletions Packages/MIES/MIES_BrowserSettingsPanel.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -876,8 +876,7 @@ End
static Function BSP_UpdateSweepControls(string win, string ctrl, variable firstSweepOrIndex, variable lastSweepOrIndex)

string graph, scPanel
variable currentSweep, newSweep, step, direction, ret
variable firstSweep, lastSweep, firstIndex, lastIndex, currentIndex, newIndex
variable currentSweepOrIndex, newSweepOrIndex, step, direction

graph = GetMainWindow(win)
scPanel = BSP_GetSweepControlsPanel(graph)
Expand All @@ -895,38 +894,17 @@ static Function BSP_UpdateSweepControls(string win, string ctrl, variable firstS
ASSERT(0, "unhandled control name")
endif

if(BSP_IsDataBrowser(graph))
firstSweep = firstSweepOrIndex
lastSweep = lastSweepOrIndex
currentSweepOrIndex = GetSetVariable(scPanel, "setvar_SweepControl_SweepNo")
newSweepOrIndex = currentSweepOrIndex + direction * step
newSweepOrIndex = limit(newSweepOrIndex, firstSweepOrIndex, lastSweepOrIndex)

currentSweep = GetSetVariable(scPanel, "setvar_SweepControl_SweepNo")
newSweep = currentSweep + direction * step
newSweep = limit(newSweep, firstSweep, lastSweep)
SetPopupMenuIndex(scPanel, "popup_SweepControl_Selector", newSweepOrIndex)

ret = newSweep
else
WAVE sweeps = SB_GetPlainSweepList(win)
firstIndex = 0
lastIndex = DimSize(sweeps, ROWS) - 1

currentIndex = GetPopupMenuIndex(scPanel, "popup_SweepControl_Selector")
newIndex = currentIndex + direction * step
newIndex = limit(newIndex, firstIndex, lastIndex)

newSweep = sweeps[newIndex]
firstSweep = sweeps[firstIndex]
lastSweep = sweeps[lastIndex]

SetPopupMenuIndex(scPanel, "popup_SweepControl_Selector", newIndex)

ret = newIndex
endif

SetSetVariable(scPanel, "setvar_SweepControl_SweepNo", newSweep)
SetSetVariableLimits(scPanel, "setvar_SweepControl_SweepNo", firstSweep, lastSweep, step)
SetValDisplay(scPanel, "valdisp_SweepControl_LastSweep", var = lastSweep)
SetSetVariable(scPanel, "setvar_SweepControl_SweepNo", newSweepOrIndex)
SetSetVariableLimits(scPanel, "setvar_SweepControl_SweepNo", firstSweepOrIndex, lastSweepOrIndex, step)
SetValDisplay(scPanel, "valdisp_SweepControl_LastSweep", var = lastSweepOrIndex)

return ret
return newSweepOrIndex
End

/// @brief check if the specified setting is activated
Expand Down Expand Up @@ -1378,7 +1356,8 @@ Function/WAVE BSP_FetchSelectedChannels(string graph, [variable index, variable
return channelSel
End

/// @brief Return the last and first sweep numbers
/// @brief Return the last and first sweep numbers for the databrowser or the
/// indizes for the sweepbrowser
Function [variable first, variable last] BSP_FirstAndLastSweepAcquired(string win)

string list
Expand All @@ -1389,7 +1368,11 @@ Function [variable first, variable last] BSP_FirstAndLastSweepAcquired(string wi
return [NaN, NaN]
endif

return [sweeps[0], sweeps[DimSize(sweeps, ROWS) - 1]]
if(BSP_IsDataBrowser(win))
return [sweeps[0], sweeps[DimSize(sweeps, ROWS) - 1]]
endif

return [0, DimSize(sweeps, ROWS) - 1]
End

Function BSP_ButtonProc_ChangeSweep(STRUCT WMButtonAction &ba) : ButtonControl
Expand Down
21 changes: 11 additions & 10 deletions Packages/MIES/MIES_Constants.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ Constant DAQ_CONFIG_WAVE_VERSION = 3

/// Used to upgrade the GuiStateWave as well as the DA Ephys panel
Constant DA_EPHYS_PANEL_VERSION = 64
Constant DATA_SWEEP_BROWSER_PANEL_VERSION = 51
Constant DATA_SWEEP_BROWSER_PANEL_VERSION = 52
Constant WAVEBUILDER_PANEL_VERSION = 14
Constant ANALYSISBROWSER_PANEL_VERSION = 5
Constant ANALYSISBROWSER_PANEL_VERSION = 6
Constant PSX_PLOT_PANEL_VERSION = 1

/// Version of the stimset wave note
Expand Down Expand Up @@ -348,14 +348,15 @@ Constant CHANNEL_INDEX_ALL_I_ZERO = -4
/// of a ListBox
/// @anchor ListBoxSelectionWaveFlags
///@{
Constant LISTBOX_SELECTED = 0x01
Constant LISTBOX_CELL_EDITABLE = 0x02
Constant LISTBOX_CELL_DOUBLECLICK_EDIT = 0x04
Constant LISTBOX_SHIFT_SELECTION = 0x08
Constant LISTBOX_CHECKBOX_SELECTED = 0x10
Constant LISTBOX_CHECKBOX = 0x20
Constant LISTBOX_TREEVIEW_EXPANDED = 0x10 ///< Convenience definition, equal to #LISTBOX_CHECKBOX_SELECTED
Constant LISTBOX_TREEVIEW = 0x40
Constant LISTBOX_SELECTED = 0x01
Constant LISTBOX_CELL_EDITABLE = 0x02
Constant LISTBOX_CELL_DOUBLECLICK_EDIT = 0x04
Constant LISTBOX_SHIFT_SELECTION = 0x08
Constant LISTBOX_CHECKBOX_SELECTED = 0x10
Constant LISTBOX_CHECKBOX = 0x20
Constant LISTBOX_TREEVIEW_EXPANDED = 0x10 ///< Convenience definition, equal to #LISTBOX_CHECKBOX_SELECTED
Constant LISTBOX_SELECT_OR_SHIFT_SELECTION = 0x09 ///< Convenience definition: LISTBOX_SELECTED | LISTBOX_SHIFT_SELECTION
Constant LISTBOX_TREEVIEW = 0x40
///@}

Constant INITIAL_KEY_WAVE_COL_COUNT = 5
Expand Down
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_DataBrowser_Macro.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ Window DataBrowser() : Graph
ListBox list_dashboard, userdata(ResizeControlsInfo)+=A"zzzzzzzzzzzz!!#u:Du]k<zzzzzzzzzzz"
ListBox list_dashboard, userdata(ResizeControlsInfo)+=A"zzz!!#?(FEDG<zzzzzzzzzzzzzz!!!"
ListBox list_dashboard, userdata(Config_DontRestore)="1"
ListBox list_dashboard, userdata(Config_DontSave)="1", fSize=12, mode=4
ListBox list_dashboard, userdata(Config_DontSave)="1", fSize=12, mode=9
ListBox list_dashboard, widths={141, 109, 77}, userColumnResize=1
CheckBox check_BrowserSettings_DS, pos={186.00, 47.00}, size={51.00, 15.00}, disable=1, proc=AD_CheckProc_Toggle
CheckBox check_BrowserSettings_DS, title="enable"
Expand Down
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_WaveBuilderPanel.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1829,7 +1829,7 @@ static Function WBP_ToggleAnalysisParamGUI()
ListBox list_params, listWave=listWave
ListBox list_params, selWave=selWave
ListBox list_params, helpWave=helpWave
ListBox list_params, mode=4, widths={180, 60, 120, 60, 600}, userColumnResize=1
ListBox list_params, mode=9, widths={180, 60, 120, 60, 600}, userColumnResize=1
ListBox list_params, userdata(ResizeControlsInfo)=A"!!,I!J,hkh!!#D1!!#B1z!!#N3Bk1ct<C]MV0`V1Rzzzzzzzzzzzz!!#o2B4uAezz"
ListBox list_params, userdata(ResizeControlsInfo)+=A"zzzzzzzzzzzz!!#u:Duafnzzzzzzzzzzz"
ListBox list_params, userdata(ResizeControlsInfo)+=A"zzz!!#?(FEDG<zzzzzzzzzzzzzz!!!"
Expand Down

0 comments on commit d95d80e

Please sign in to comment.