Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ This enables a very quick and convenient spike per spike jump on traces.
Channel visibility can be handled with one of the roi in the probeview.

Shortcuts: many shortcuts are available, please read the **?** button in each view.
There's one secret shortcut: `ctrl+f` (or `cmd+f` on mac), for "focus mode". Try it out!

## Curation mode

Expand Down
1 change: 1 addition & 0 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ This enables a very quick and convenient spike per spike jump on traces.
Channel visibility can be handled with one of the roi in the probeview.

Shortcuts: many shortcuts are available, please read the **?** button in each view.
There's one secret shortcut: ``ctrl+f`` (or ``cmd+f`` on mac), for "focus mode". Try it out!

Curation mode
-------------
Expand Down
31 changes: 30 additions & 1 deletion spikeinterface_gui/backend_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,14 @@ def make_views(self, user_settings):


def create_main_layout(self):
from .utils_panel import KeyboardShortcut, KeyboardShortcuts

pn.extension("gridstack")

preset = self.layout_dict

layout_zone = {}
self.all_tabs = []
for zone, view_names in preset.items():
# keep only instanciated views
view_names = [view_name for view_name in view_names if view_name in self.view_layouts.keys()]
Expand All @@ -297,6 +299,7 @@ def create_main_layout(self):
# Function to update visibility
tabs = layout_zone[zone]
tabs.param.watch(self.update_visibility, "active")
self.all_tabs.append(tabs)
# Simulate an event
self.update_visibility(
param.parameterized.Event(
Expand All @@ -314,7 +317,17 @@ def create_main_layout(self):
gs = self.make_half_layout(gs, layout_zone, "left")
gs = self.make_half_layout(gs, layout_zone, "right")

self.main_layout = gs
# Initialize keyboard shortcuts
self.focus_mode = False
shortcuts = [KeyboardShortcut(name="focus", key="f", ctrlKey=True),]
shortcuts_component = KeyboardShortcuts(shortcuts=shortcuts)
shortcuts_component.on_msg(self._handle_shortcut)

self.main_layout = pn.Column(
gs,
shortcuts_component,
sizing_mode="stretch_both",
)

def make_half_layout(self, gs, layout_zone, left_or_right):
"""
Expand Down Expand Up @@ -386,6 +399,22 @@ def update_visibility(self, event):
# we also set the current view as the panel active
view.notify_active_view_updated()

def _handle_shortcut(self, event):
if event.data == "focus":
self.focus_mode = not self.focus_mode

for tabs in self.all_tabs:
if self.focus_mode:
tabs.stylesheets = [
"""
.bk-header {
display: none !important;
}
"""
]
else:
tabs.stylesheets = []
Comment on lines +402 to +416
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find a way to speed it up...Let's leave it like this for the time being :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok - it's an aspirational hidden shortcut, so that's ok



def get_local_ip():
"""
Expand Down
37 changes: 36 additions & 1 deletion spikeinterface_gui/backend_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,13 @@ class QtMainWindow(QT.QMainWindow):

def __init__(self, controller, parent=None, layout_dict=None, user_settings=None):
QT.QMainWindow.__init__(self, parent)


self.in_focus_mode = False
toggle_focus_mode = QT.QAction('Focus Mode', self)
toggle_focus_mode.setShortcut('Ctrl+F')
toggle_focus_mode.triggered.connect(self.toggle_focus_mode)
self.addAction(toggle_focus_mode)

self.controller = controller
self.verbose = controller.verbose
self.layout_dict = layout_dict
Expand Down Expand Up @@ -328,6 +334,33 @@ def closeEvent(self, event):
self.main_window_closed.emit(self)
event.accept()

def toggle_focus_mode(self, event):

if not self.in_focus_mode:

for view_name, view in self.views.items():
view.qt_widget.tb.setVisible(False)

self.setStyleSheet("QTabBar::tab { height: 0px; width: 0px; margin: 0px; padding: 0px; }")

for view_name, dock in self.docks.items():
empty_title_bar = QT.QWidget()
dock.setTitleBarWidget(empty_title_bar)

self.in_focus_mode = True

else:

for view_name, view in self.views.items():
view.qt_widget.tb.setVisible(True)

self.setStyleSheet("QTabBar::tab { }")

self.in_focus_mode = False

for view_name, dock in self.docks.items():
dock.setTitleBarWidget(None)


class ViewWidget(QT.QWidget):
def __init__(self, view_class, parent=None):
Expand Down Expand Up @@ -366,6 +399,8 @@ def __init__(self, view_class, parent=None):

add_stretch_to_qtoolbar(tb)

self.tb = tb

# TODO: make _qt method for all existing methods that don't start with _qt or _panel
# skip = ['__init__', 'set_view', 'open_settings', 'compute', 'refresh', 'open_help',
# 'on_spike_selection_changed', 'on_unit_visibility_changed',
Expand Down