Phase 4.2: Add GridView UIDrawable type (addresses #252)

GridView is a new UIDrawable that renders a GridData object independently.
Multiple GridViews can reference the same Grid for split-screen, minimap,
or different camera/zoom perspectives on shared grid state.

- New files: UIGridView.h/cpp with full rendering pipeline (copied from
  UIGrid::render, adapted to use grid_data pointer)
- Add UIGRIDVIEW to PyObjectsEnum
- Add UIGRIDVIEW cases to all switch(derived_type()) sites:
  Animation.cpp, UICollection.cpp, UIDrawable.cpp, McRFPy_API.cpp,
  ImGuiSceneExplorer.cpp
- Python type: mcrfpy.GridView(grid=, pos=, size=, zoom=, fill_color=)
- Properties: grid, center, zoom, fill_color, texture
- Register type with metaclass for callback support

All 258 existing tests pass. New GridView test suite added.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
John McCardle 2026-03-16 08:41:44 -04:00
commit 4b13e5f5db
10 changed files with 824 additions and 2 deletions

View file

@ -4,6 +4,7 @@
#include "UICaption.h"
#include "UISprite.h"
#include "UIGrid.h"
#include "UIGridView.h"
#include "UILine.h"
#include "UICircle.h"
#include "UIArc.h"
@ -78,6 +79,17 @@ static PyObject* convertDrawableToPython(std::shared_ptr<UIDrawable> drawable) {
obj = (PyObject*)pyObj;
break;
}
case PyObjectsEnum::UIGRIDVIEW:
{
type = &PyUIGridViewType;
auto pyObj = (PyUIGridViewObject*)type->tp_alloc(type, 0);
if (pyObj) {
pyObj->data = std::static_pointer_cast<UIGridView>(drawable);
pyObj->weakreflist = NULL;
}
obj = (PyObject*)pyObj;
break;
}
case PyObjectsEnum::UILINE:
{
type = &PyUILineType;
@ -152,6 +164,8 @@ static std::shared_ptr<UIDrawable> extractDrawable(PyObject* o) {
return ((PyUISpriteObject*)o)->data;
if (PyObject_IsInstance(o, (PyObject*)&PyUIGridType))
return ((PyUIGridObject*)o)->data;
if (PyObject_IsInstance(o, (PyObject*)&PyUIGridViewType))
return ((PyUIGridViewObject*)o)->data;
if (PyObject_IsInstance(o, (PyObject*)&PyUILineType))
return ((PyUILineObject*)o)->data;
if (PyObject_IsInstance(o, (PyObject*)&PyUICircleType))
@ -1034,6 +1048,7 @@ PyObject* UICollection::repr(PyUICollectionObject* self)
case PyObjectsEnum::UICAPTION: caption_count++; break;
case PyObjectsEnum::UISPRITE: sprite_count++; break;
case PyObjectsEnum::UIGRID: grid_count++; break;
case PyObjectsEnum::UIGRIDVIEW: other_count++; break;
default: other_count++; break;
}
}