diff --git a/src/discussions/ui/gui.py b/src/discussions/ui/gui.py index 3e1f616..6878376 100644 --- a/src/discussions/ui/gui.py +++ b/src/discussions/ui/gui.py @@ -413,9 +413,6 @@ class DiscussionGUI: """Handle mouse down on dictate button - start timing for mode detection.""" import time - # Hide tooltip when button is clicked - self._hide_dictate_tooltip() - current_time = time.time() # Check for double-click (two clicks within 300ms) @@ -484,111 +481,6 @@ class DiscussionGUI: if self._continuous_recorder is None: self._start_dictation() - def _show_dictate_tooltip(self): - """Show the custom dictate button tooltip.""" - if dpg.does_item_exist("dictate_tooltip_window"): - return # Already visible - - # Get mouse position for tooltip placement (show near cursor) - mouse_pos = dpg.get_mouse_pos(local=False) - tooltip_x = mouse_pos[0] + 15 - tooltip_y = mouse_pos[1] + 15 - - self._tooltip_visible = True - self._tooltip_fading = False - self._tooltip_alpha = 1.0 - self._tooltip_last_mouse_pos = mouse_pos - - # Create tooltip as a non-modal, non-focusable window - with dpg.window( - tag="dictate_tooltip_window", - no_title_bar=True, - no_resize=True, - no_move=True, - no_scrollbar=True, - no_collapse=True, - no_background=False, - no_focus_on_appearing=True, - no_bring_to_front_on_focus=True, - pos=[tooltip_x, tooltip_y], - autosize=True - ): - dpg.add_text("Voice Dictation", color=(200, 200, 255)) - dpg.add_separator() - dpg.add_text("Double-click: Continuous mode") - dpg.add_text(" Transcribed text appends to end.", color=(150, 150, 150)) - dpg.add_text(" Click again to stop.", color=(150, 150, 150)) - dpg.add_spacer(height=5) - dpg.add_text("Click & hold: Walkie-talkie mode") - dpg.add_text(" Inserts at last edited position.", color=(150, 150, 150)) - dpg.add_text(" Release to stop.", color=(150, 150, 150)) - dpg.add_spacer(height=5) - dpg.add_text("Tip: Type at insertion point first", color=(255, 200, 100)) - dpg.add_text("to set cursor position.", color=(255, 200, 100)) - - def _hide_dictate_tooltip(self): - """Hide the custom dictate button tooltip immediately.""" - if dpg.does_item_exist("dictate_tooltip_window"): - dpg.delete_item("dictate_tooltip_window") - self._tooltip_visible = False - self._tooltip_fading = False - - def _start_tooltip_fade(self): - """Start fading out the tooltip.""" - import time - if self._tooltip_visible and not self._tooltip_fading: - self._tooltip_fading = True - self._tooltip_fade_start_time = time.time() - - def _update_tooltip(self): - """Update tooltip visibility and fade animation. Call this from frame callback.""" - import time - - # Check if dictate button exists and mouse is over it - if dpg.does_item_exist("dictate_btn"): - # Check if button is hovered using item state - state = dpg.get_item_state("dictate_btn") - is_hovered = state.get("hovered", False) if state else False - - if is_hovered and not self._tooltip_visible: - # Mouse entered button - show tooltip - self._show_dictate_tooltip() - elif not is_hovered and self._tooltip_visible and not self._tooltip_fading: - # Mouse left button - start fade - self._start_tooltip_fade() - - if not self._tooltip_visible: - return - - current_mouse = dpg.get_mouse_pos(local=False) - - # Check if mouse moved significantly while tooltip is visible - dx = abs(current_mouse[0] - self._tooltip_last_mouse_pos[0]) - dy = abs(current_mouse[1] - self._tooltip_last_mouse_pos[1]) - - if dx > 5 or dy > 5: # Mouse moved - if not self._tooltip_fading: - self._start_tooltip_fade() - self._tooltip_last_mouse_pos = current_mouse - - # Handle fade animation - if self._tooltip_fading: - elapsed = time.time() - self._tooltip_fade_start_time - fade_duration = 2.0 # 2 seconds to fade - - if elapsed >= fade_duration: - self._hide_dictate_tooltip() - else: - # Calculate alpha (1.0 to 0.0 over fade_duration) - self._tooltip_alpha = 1.0 - (elapsed / fade_duration) - # DearPyGui doesn't have direct alpha control, so we hide at threshold - if self._tooltip_alpha < 0.1: - self._hide_dictate_tooltip() - - def _on_dictate_hover(self, sender, app_data): - """Handle mouse hovering over dictate button (backup, main check is in _update_tooltip).""" - self._show_dictate_tooltip() - def _start_dictation(self): """Start continuous recording with chunked transcription.""" # Create recorder with callbacks @@ -804,13 +696,6 @@ class DiscussionGUI: self._last_text_value = "" self._approx_cursor_pos = 0 # Approximate cursor position for insertion - # Custom tooltip state for sticky fade behavior - self._tooltip_visible = False - self._tooltip_last_mouse_pos = (0, 0) - self._tooltip_fade_start_time = 0.0 - self._tooltip_fading = False - self._tooltip_alpha = 1.0 - # Initialize Dear PyGui dpg.create_context() dpg.create_viewport(title="Orchestrated Discussions", width=1400, height=900) @@ -2175,8 +2060,6 @@ class DiscussionGUI: dpg.delete_item(window_tag) if dpg.does_item_exist("dictate_btn_handlers"): dpg.delete_item("dictate_btn_handlers") - # Clean up any existing tooltip - self._hide_dictate_tooltip() # Reset dictation state when dialog opens self._dictation_mode = "idle" self._last_dictate_click_time = 0.0 @@ -2195,13 +2078,25 @@ class DiscussionGUI: tag="dictate_btn", width=100 ) + # Add tooltip with usage instructions + with dpg.tooltip("dictate_btn"): + dpg.add_text("Voice Dictation", color=(200, 200, 255)) + dpg.add_separator() + dpg.add_text("Double-click: Continuous mode") + dpg.add_text(" Transcribed text appends to end.", color=(150, 150, 150)) + dpg.add_text(" Click again to stop.", color=(150, 150, 150)) + dpg.add_spacer(height=5) + dpg.add_text("Click & hold: Walkie-talkie mode") + dpg.add_text(" Inserts at last edited position.", color=(150, 150, 150)) + dpg.add_text(" Release to stop.", color=(150, 150, 150)) + dpg.add_spacer(height=5) + dpg.add_text("Tip: Type at insertion point first", color=(255, 200, 100)) + dpg.add_text("to set cursor position.", color=(255, 200, 100)) # Add item handlers for press-and-hold vs double-click detection - # Also includes hover handler for custom sticky tooltip with dpg.item_handler_registry(tag="dictate_btn_handlers"): dpg.add_item_activated_handler(callback=self._on_dictate_activated) dpg.add_item_deactivated_handler(callback=self._on_dictate_deactivated) dpg.add_item_active_handler(callback=self._on_dictate_active) - dpg.add_item_hover_handler(callback=self._on_dictate_hover) dpg.bind_item_handler_registry("dictate_btn", "dictate_btn_handlers") dpg.add_button( label="Add Artifact", @@ -4249,9 +4144,6 @@ final = json.dumps(parsed)''', # Poll for updates from background threads (output, turn completion) self._poll_background_tasks() - # Update tooltip visibility and fade animation - self._update_tooltip() - # Render frame dpg.render_dearpygui_frame()