[Bugfix] Grid cell callbacks, child clicks, and cell hover all dead since #252 GridView unification #355
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
#357 [Bugfix] mcrfpy.find()/findAll() never search entities inside grids (UIGRID gate dead since #252)
john/McRogueFace
#358 [Bugfix] ImGui scene explorer shows no children/entities for grids (UIGRIDVIEW hits default: break)
john/McRogueFace
Reference
john/McRogueFace#355
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Symptom
grid.on_cell_click,grid.on_cell_enter,grid.on_cell_exitnever fire, andgrid.hovered_cellstaysNone, on any grid created viamcrfpy.Grid(...). Plaingrid.on_clickDOES fire, which confirms the event pipeline itself is fine.Scope is wider than originally filed. Everything below is dead for a
mcrfpy.Grid:on_cell_clickon_cell_enter/on_cell_exit/hovered_cellon_enter/on_exit/on_move)grid->childrennever reached)Related same-root-cause bugs split out: #357 (
find()/findAll()never search grid entities), #358 (ImGui scene explorer won't expand grids).Existing test
tests/unit/test_grid_cell_events.pymasks all of this: it prints"PARTIAL (events may require interactive mode)"and exits 0 when zero events fire (lines 82-86, 112-116). That string is why this shipped broken.Root cause
Since #252,
mcrfpy.Grid(...)constructs a UIGridView (derived_type() == UIGRIDVIEW), but every dispatch site is gated onderived_type() == UIGRID. Scene children are always UIGridViews; the internalUIGrid(mcrfpy._GridData) is never itself a scene-graph member. All six gates are dead code.UIGridView::click_at(src/UIGridView.cpp:369-373) is a 4-line stub — bounds-check,return this. It never descends into children or entities, and never records a cell.The part that makes "just add a UIGRIDVIEW branch" wrong
The cell-callback family is split across the seam in the worst possible way:
on_cell_*_callable,hovered_cell,last_clicked_cell,cell_callback_cache) lives on GridData (src/GridData.h:125-138).fireCellClick/Enter/Exit,updateCellHover,refreshCellCallbackCache) lives on UIGrid (src/UIGrid.cpp:1084-1345) — per the comment at GridData.h:140, "because they need access to UIDrawable::serial_number/is_python_subclass".UIGrid::screenToCellreads UIGrid's owncenter_x/center_y/zoom— legacy fields that are no longer the camera the user sees. Even with the UIGRID branch re-enabled, it would report wrong cells for any panned or zoomed grid.UIGridView::screenToCell(src/UIGridView.cpp:88-109) is the only correct implementation, and it currently has no callers.Worse:
UIGridView::init_with_data(src/UIGridView.cpp:566-613) builds a_GridDataPython object, steals itsGridDatasub-object via an aliasingshared_ptr, andPy_DECREFs the wrapper. SoUIGrid::fireCellClick'sPythonObjectCache::lookup(this->serial_number)resolves the serial of a discarded wrapper — aclass MyGrid(mcrfpy.Grid)subclass instance is a GridView, and itson_cell_clickmethod could never be found even if dispatch reached it. AndrefreshCellCallbackCachewalks the type hierarchy up to sentinel&PyUIGridType(UIGrid.cpp:1113), which a Grid subclass never passes through.The ownership has to move. It cannot be fixed by adding a branch.
Fix
Input becomes purely a GridView concern — the view owns the camera, so it is the only thing that can map screen to cell, and it is the object the user's Python subclass actually is.
Move
hovered_cell,last_clicked_cell,cell_callback_cache, the threeon_cell_*callables, andfireCell*/updateCellHover/refreshCellCallbackCachefrom GridData/UIGrid onto UIGridView. Delete them from UIGrid rather than leaving two copies.hovered_cellmust be per-view: two views over one GridData (#359) would otherwise ping-pong exit/enter through a shared field on every hover pass.grid.on_cell_clickkeeps working unchanged, becausemcrfpy.Gridis the view.view.grid(a_GridData) loses cell callbacks — correct: a data grid has no screen mapping.Implement
UIGridView::click_atproperly: children hit-test (reverse z) -> entity hit-test -> record cell via the existingscreenToCell-> returnthis. Port fromUIGrid::click_at(src/UIGrid.cpp:525-617) and delete that.Kill the enum gates rather than adding to them. Instead of a second
derived_type()==UIGRIDVIEWarm at each of six sites, add virtuals onUIDrawable:virtual bool dispatchCellClick(button, action)— defaultfalse; GridView overrides.virtual void updateHover(sf::Vector2f)— default no-op; Frame and GridView override to recurse into children.virtual GridData* asGridData()— defaultnullptr; unblocks #357 and #358.This is what stops the family from re-rotting the next time a type is unified.
Tighten
tests/unit/test_grid_cell_events.pyfrom "PARTIAL" prints into hard asserts. Add regression coverage for child-click, entity-click, and child-hover inside a grid.Repro (headless)
Not in scope
_GridDatasheddingUIDrawableentirely — the remaining half of #252 — is #361, and it is sequenced after this issue. After this lands, UIGrid has no input responsibilities left, which makes #361 a much smaller surgery.Found while rewriting the site's systems/input.md docs page (signatures in stubs/API reference are correct; the events just never dispatch).
[Bugfix] Grid cell callbacks (on_cell_click/on_cell_enter/on_cell_exit, hovered_cell) never fire since #252 GridView unificationto [Bugfix] Grid cell callbacks, child clicks, and cell hover all dead since #252 GridView unification