Skip to content

PME2: GPU-rendered description tooltip for Pie Menu #100

@Pluglug

Description

@Pluglug

Summary

Add GPU-rendered description tooltips for Pie Menu items - a long-requested PME1 feature finally coming to PME2.

Background

Users have requested the ability to show descriptive text for pie menu items on hover. This is a signature PME2 feature that will enhance usability.


Phase 1: Pie Menu Tooltip (This Issue)

Goal

  • GPU-rendered tooltip showing pmi.description on hover
  • Pie Menu only (PMENU mode)
  • Simple text display near the hovered item

Technical Approach

Architecture:

┌─────────────────────────────────────────────────┐
│ Blender Standard UI                              │
│   wm.popup_menu_pie() → _draw_pm()              │
│   (UILayout-based, existing behavior)            │
└─────────────────────────────────────────────────┘
                    ▼
┌─────────────────────────────────────────────────┐
│ GPU Overlay (NEW)                                │
│   POST_PIXEL draw_handler                        │
│   - Detect hovered item                          │
│   - Render description tooltip                   │
└─────────────────────────────────────────────────┘

Key Components:

  1. Mouse tracking: Get cursor position during pie menu display
  2. Hit test: Calculate which slot (0-9) is hovered based on angle/distance
  3. Tooltip rendering: gpu (rect) + blf (text) modules
  4. Positioning: Near cursor or item, avoiding screen edge

Key Files:

  • operators/__init__.py:1137 - WM_OT_pme_user_pie_menu_call
  • operators/__init__.py:1372 - _draw_pm() method
  • infra/overlay.py - Existing overlay infrastructure

Future Phases (Out of Scope)

Phase 2: Always-Visible Hover UI

  • Mini Qt-like widget system
  • Persistent panels that don't auto-close
  • GPU widget framework (pme.gfx package)

Phase 3: Full Widget Editor

  • Visual pie menu editor
  • Drag & drop slot arrangement
  • Live preview

Implementation Considerations

GPU/BLF Constraints (from analysis)

  1. Drawing target: Existing Area/Region only (SpaceView3D, etc.)
  2. Input handling: All via modal operator
  3. Theme/scaling: Manual calculation required (HiDPI, pixel_size)
  4. API stability: GPU/BLF signatures change between versions - need adapter layer

Blender API Notes

  • blf.size() changed in 4.0 (dpi argument removed)
  • gpu.shader.from_builtin() may change
  • Recommend isolating GPU calls in pme.gfx or infra/gpu_utils.py

Recommended Architecture

# infra/gpu_utils.py - Adapter layer for Blender version compatibility
def draw_text(x, y, text, size, color): ...
def draw_rect(x, y, w, h, color): ...

# ui/tooltip.py - Tooltip logic
class PieTooltipRenderer:
    def __init__(self, pm): ...
    def draw(self, context): ...
    def get_hovered_slot(self, mouse_x, mouse_y): ...

Related Resources

Internal Documents

  • _docs/design/user_pie_menu_call_analysis.md - Full operator analysis
  • _docs/design/PME2_FEATURE_REQUESTS.md - User feature requests

Design Decision: Operator Decomposition

Benefits of decomposing WM_OT_pme_user_pie_menu_call:

Feature Request Current Problem After Decomposition
Custom styling (#3) 200-line _draw_item, changes hard to trace ui/item_style.py isolates style logic
Modal operator enhancement (#8) 524-line state machine operators/modal/state_machine.py
Context-aware menus (#5) poll/draw tightly coupled core/context_rules.py

Recommendation: Consider _draw_item separation (Phase WM-1) before or alongside tooltip implementation.


JSON Schema v2 Integration

{
  "items": [
    {
      "text": "Add Cube",
      "description": "Add a cube primitive to the scene",
      "description_expr": "'Objects: ' + str(len(C.scene.objects))"
    }
  ]
}
  • description: Static text (i18n-translatable)
  • description_expr: Python expression for dynamic text

See: #81 (description/description_expr implementation)


🎉 Milestone Issue #100 - A signature feature for PME2!

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestui/uxUser interface and experience

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions