Sidebar & Activation¶
Structure Sidebar¶
The structure sidebar (codemol/structure_sidebar.py) appears automatically when 2+ structures are loaded. It provides a visual list of loaded structures with click-to-activate behavior.
┌──────────────────────────────┐
│ Structures │
│ ┌──────────────────────────┐ │
│ │ ● 1AKE (active) │ │
│ │ 4AKE │ │
│ │ 3HTB │ │
│ └──────────────────────────┘ │
└──────────────────────────────┘
Auto-Open Behavior¶
The sidebar is managed by StructureManager:
- First structure loaded → sidebar stays hidden
- Second structure loaded → sidebar slides open (animated)
- All structures cleared → sidebar slides closed
# In StructureManager
def _check_sidebar_visibility(self):
if self._ctx.session.has_multiple():
_animate_sidebar(self._sidebar, 0, 200) # open
else:
_animate_sidebar(self._sidebar, 200, 0) # close
Activation Flow¶
When the user clicks a structure in the sidebar:
sequenceDiagram
participant Sidebar
participant StructureManager
participant Session as StructureSession
participant Engine
participant Window
Sidebar->>StructureManager: clicked("4AKE")
StructureManager->>Session: activate("4AKE", cmd)
Session->>Engine: save scene for "1AKE"
Session->>Engine: disable "1AKE" + objects
Session->>Engine: enable "4AKE" + objects
Session->>Engine: recall scene for "4AKE"
StructureManager->>Window: update scope to "4AKE"
Window->>Window: update title bar
Sidebar->>Sidebar: highlight "4AKE" row
Scoping After Activation¶
After activation, the window's scope changes. All subsequent commands are automatically scoped to the active structure:
# User activates "4AKE" via sidebar
# Then types:
/rep cartoon protein
# Executes as: cmd.show("cartoon", "model 4AKE and (polymer.protein)")
Keyboard Shortcuts¶
| Shortcut | Action |
|---|---|
| Click structure name | Activate that structure |
| Double-click | Activate + zoom to fit |
Visual State Per Structure¶
Each structure maintains independent:
- Representations (cartoon, sticks, surface)
- Colors
- Measurements
- Camera position (via scene save/restore)
- Visibility of associated objects