|
1 | | -# User Interface (UI) Module |
| 1 | +# 🎨 User Interface (UI) Module |
2 | 2 |
|
3 | | -This directory contains the **View layer** of the application's MVC architecture. It is responsible solely for the graphical presentation and user interaction components. |
| 3 | +This directory contains the **View layer** of the application's MVC architecture. It is responsible solely for graphical presentation and user interaction. |
4 | 4 |
|
5 | | -**Note:** No business logic or data manipulation is performed here. All user interactions (clicks, edits) are emitted as Qt Signals to be handled by the `controllers` module. |
| 5 | +**Note:** No business logic or data manipulation is performed here. All user interactions (clicks, edits, playback controls) are emitted as **Qt Signals** to be handled by the `controllers` module. |
6 | 6 |
|
7 | 7 | ## 📂 Directory Structure |
8 | 8 |
|
9 | | -The UI is organized by functional domain rather than spatial position: |
| 9 | +The UI is organized by functional domain, with a robust **Common** library supporting four distinct annotation modes: |
10 | 10 |
|
11 | 11 | ```text |
12 | 12 | ui/ |
13 | | -├── common/ # Reusable widgets and dialogs shared across different tasks |
14 | | -│ ├── dialogs.py |
15 | | -│ └── project_controls.py |
16 | | -├── classification/ # UI components specific to the Classification task |
17 | | -└── localization/ # UI components specific to the Localization task |
| 13 | +├── common/ # Shared architecture (Main Window, Workspace Skeleton, Dialogs) |
| 14 | +│ ├── main_window.py # Top-level Stacked Layout orchestrator |
| 15 | +│ ├── workspace.py # Unified 3-column layout skeleton |
| 16 | +│ ├── video_surface.py # Shared video rendering widget |
| 17 | +│ └── ... |
| 18 | +│ |
| 19 | +├── classification/ # [Mode 1] Whole-Video Classification |
| 20 | +├── localization/ # [Mode 2] Action Spotting (Timestamps) |
| 21 | +├── description/ # [Mode 3] Global Description (Captions) |
| 22 | +└── dense_description/ # [Mode 4] Dense Description (Timestamped Text) |
18 | 23 |
|
19 | 24 | ``` |
20 | 25 |
|
|
24 | 29 |
|
25 | 30 | ### 1. Common (`ui/common/`) |
26 | 31 |
|
27 | | -Contains widgets and windows that are standardized and used across multiple modes to ensure a consistent user experience. |
| 32 | +The backbone of the application, ensuring a consistent user experience across all modes. |
28 | 33 |
|
29 | | -* **`dialogs.py`**: Contains modal dialog windows used throughout the application lifecycle: |
30 | | -* `ProjectTypeDialog`: Forces the user to choose between Classification and Localization modes. |
31 | | -* `CreateProjectDialog`: A wizard for setting up new tasks and defining the initial Label Schema. |
32 | | -* `FolderPickerDialog`: A custom file tree that allows selecting multiple folders without holding the Ctrl key. |
| 34 | +* **`main_window.py`**: The application entry point. It manages a `QStackedLayout` to switch between the **Welcome Screen** and the four **Workspaces** without destroying state. |
| 35 | +* **`workspace.py`**: Defines the `UnifiedTaskPanel`. This is the generic 3-column skeleton (Left Tree | Center Player | Right Editor) used by **every** mode to maintain layout consistency. |
| 36 | +* **`video_surface.py`**: A pure rendering widget wrapping `QMediaPlayer` and `QVideoWidget`. It handles video output while leaving playback logic to the controllers. |
| 37 | +* **`clip_explorer.py`**: The **Left Sidebar**. Refactored to use **Qt Model/View** (`QTreeView`) for high performance. It handles file navigation and filtering (e.g., "Show Labelled Only"). |
| 38 | +* **`dialogs.py`**: |
| 39 | +* `ProjectTypeDialog`: Updated wizard allowing selection of **Classification**, **Localization**, **Description**, or **Dense Description**. |
| 40 | +* `FolderPickerDialog`: A custom file tree allowing multi-folder selection. |
33 | 41 |
|
34 | 42 |
|
35 | | -* **`project_controls.py`**: |
36 | | -* Defines the **Unified 3x2 Control Grid** (New, Load, Add Data, Close, Save, Export). |
37 | | -* Contains the **Unified Clip Explorer**, providing a consistent video list and filter interface for both modes. |
38 | 43 |
|
| 44 | +### 2. Classification (`ui/classification/`) |
39 | 45 |
|
| 46 | +Implements the interface for **Whole-Video Classification** (assigning categories to an entire clip). |
40 | 47 |
|
41 | | -### 2. Classification (`ui/classification/`) |
| 48 | +* **`media_player/`**: Standard player with basic seek controls. |
| 49 | +* **`event_editor/`**: Dynamic form generation (Radio buttons/Checkboxes) based on the project Schema. |
42 | 50 |
|
43 | | -Implements the interface for **Whole-Video Classification** (assigning global labels to an entire video clip). |
| 51 | +### 3. Localization (`ui/localization/`) |
44 | 52 |
|
45 | | -* **`panels.py`**: Defines the high-level layout: |
46 | | -* `LeftPanel`: Navigation tree and Project Controls. |
47 | | -* `CenterPanel`: Video player and basic navigation controls. |
48 | | -* `RightPanel`: Dynamic form generation based on the project Schema. |
| 53 | +Implements the interface for **Action Spotting** (identifying specific timestamps). |
49 | 54 |
|
| 55 | +* **`media_player/`**: |
| 56 | +* Features the **Zoomable Timeline**, visual event markers, and frame-stepping tools. |
50 | 57 |
|
51 | | -* **`widgets.py`**: Contains specialized input widgets: |
52 | | -* `DynamicSingleLabelGroup`: Generates Radio Buttons for single-choice categories. |
53 | | -* `DynamicMultiLabelGroup`: Generates Checkboxes for multi-choice categories. |
54 | | -* `VideoViewAndControl`: A wrapper for the video player and slider. |
55 | 58 |
|
| 59 | +* **`event_editor/`**: |
| 60 | +* **Spotting Tabs:** Rapid-fire buttons for defining event categories. |
| 61 | +* **Annotation Table:** A spreadsheet view for editing timestamps and labels. |
56 | 62 |
|
57 | 63 |
|
58 | | -### 3. Localization (`ui/localization/`) |
59 | 64 |
|
60 | | -Implements the interface for **Action Spotting** (identifying specific timestamps within a video). |
| 65 | +### 4. Description (`ui/description/`) [NEW] |
61 | 66 |
|
62 | | -* **`panels.py`**: The layout container that assembles the following functional widgets. |
63 | | -* **`clip_explorer.py`**: |
64 | | -* Displays the list of video clips (Sequences) using the shared explorer logic. |
65 | | -* Handles filtering (Done/Not Done) and visual status indicators. |
| 67 | +Implements the interface for **Global Captioning** (one text description per video). |
66 | 68 |
|
| 69 | +* **`media_player/`**: |
| 70 | +* **Composite Player:** Combines the video surface with a specialized navigation toolbar. |
| 71 | +* **Behavior:** Defaults to **Infinite Loop** to allow repeated viewing while typing. |
67 | 72 |
|
68 | | -* **`media_player.py`**: |
69 | | -* Contains the `MediaPreviewWidget`. |
70 | | -* Features a custom, zoomable **Timeline** with visual event markers. |
71 | | -* Includes frame-stepping and speed control playback tools. |
72 | 73 |
|
| 74 | +* **`event_editor/`**: |
| 75 | +* **Text Input:** A large `QTextEdit` for free-form text. |
| 76 | +* **Actions:** Simple "Confirm" and "Clear" workflow. |
73 | 77 |
|
74 | | -* **`event_editor.py`**: |
75 | | -* `Spotting Tabs`: A multi-tab interface for defining different event categories (Heads). |
76 | | -* `Annotation Table`: A spreadsheet-like view for editing event timestamps and labels. |
77 | 78 |
|
78 | 79 |
|
| 80 | +### 5. Dense Description (`ui/dense_description/`) [NEW] |
79 | 81 |
|
80 | | ---- |
| 82 | +Implements the interface for **Dense Captioning** (text descriptions anchored to specific timestamps). |
81 | 83 |
|
82 | | -## 🎨 Design Principles |
| 84 | +* **`event_editor/`**: |
| 85 | +* **Input Widget:** A specialized panel showing the current video time alongside a text input area. |
| 86 | +* **Dense Table:** A subclass of the Localization table. It replaces the "Label" column with a "Description" column and auto-sizes to a **2:1:4 ratio** (Time : Lang : Text). |
83 | 87 |
|
84 | | -1. **Passive View**: These classes do not modify the `model` directly. They only display data provided by the controller and emit signals when the user acts. |
85 | | -2. **Dynamic Generation**: The annotation forms (buttons/checkboxes) are not hardcoded; they are generated dynamically based on the loaded JSON schema. |
86 | | -3. **Functional Naming**: Files are named after what they *do* (e.g., `media_player.py`), not where they are located (e.g., `center_widgets.py`), allowing for flexible layout changes in the future. |
87 | 88 |
|
| 89 | +* **Reuse:** This mode reuses the **Localization Center Panel** (Timeline + Player) to allow precise navigation between text events. |
88 | 90 |
|
89 | | -``` |
| 91 | +--- |
| 92 | + |
| 93 | +## 🎨 Design Principles |
| 94 | + |
| 95 | +1. **Passive View:** These classes do not modify data directly. They display data provided by the controller and emit signals (e.g., `confirm_clicked`, `request_remove_item`) when the user acts. |
| 96 | +2. **Unified Skeleton:** All modes inherit the same `UnifiedTaskPanel` structure. This ensures that the Sidebar and Media Player always appear in the same relative locations, reducing cognitive load for the user. |
| 97 | +3. **Composite Design:** Complex widgets (like the Description Player) are built by composing smaller, single-purpose widgets (VideoSurface + Controls + Slider) rather than monolithic classes. |
| 98 | +4. **Dynamic Generation:** Where possible, forms and tables adjust their content dynamically based on the loaded JSON schema or data model. |
0 commit comments