Skip to content

Add PrimitivePropertyType with visual color indicators#4421

Open
kanishka0411 wants to merge 3 commits intomapeditor:masterfrom
kanishka0411:feature/property-visualization
Open

Add PrimitivePropertyType with visual color indicators#4421
kanishka0411 wants to merge 3 commits intomapeditor:masterfrom
kanishka0411:feature/property-visualization

Conversation

@kanishka0411
Copy link
Copy Markdown
Contributor

@kanishka0411 kanishka0411 commented Mar 12, 2026

Fixes #4169

Summary

Implements the initial version of property visualization as discussed . Introduces a new PrimitivePropertyTypethat can be assigned a visual color, which is then displayed as a colored circle overlay on tiles in the tileset view.

What this PR does

  • New property type: PrimitivePropertyTypewith configurable storage type (bool, int, float, string, color) and an optional visual color
  • Editor UI: "Add Primitive" button in the Custom Types Editor with a color picker and storage type selector
  • Tileset visualization: Colored circle indicators drawn in the top-left corner of tiles that have properties of a primitive type with a visual color set
  • Scripting support: Primitive property type exposed to the JavaScript API
  • Auto-refresh: Tileset view updates when property type colors change
  • Tests: JSON round-trip, default values, and export/import tests

How to test

  1. Open a project → View → Custom Types Editor
  2. Click "Add Primitive", name it (e.g., Interactable), pick a color
  3. Assign the primitive-typed property to a tile
  4. A colored circle appears on the tile in the tileset view

@saurabh-zz007
Copy link
Copy Markdown

saurabh-zz007 commented Mar 20, 2026

Hey @kanishka0411 , I was looking through the Linux build failure in your pr. It looks like it might be a header issue, I noticed QAction (and possibly std::make_unique) are being used, but their headers (#include <QAction> and #include <memory>) might be missing. Also, did you make sure to add the new source files to the CMakeLists.txt? Sometimes Linux is way more strict than windows in these things.

Hope this helps!

Copy link
Copy Markdown
Member

@bjorn bjorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good start, thanks @kanishka0411! There are a number of issues in the details though, so I've left some comments.

It's good that this PR focuses on the basics rather than adding any more involved visualizations. It does leave an interesting challenge for whoever is going to look into enabling that. :-)

@saurabh-zz007 I'm not sure what missing header you're referring to. I only see a build failure for the snap, which appears to have been due to a network error:

Cannot process request (Service Unavailable: 503): https://github.com/mapeditor/qaseprite/releases/download/1.0.3/qaseprite-1.0.3-source.tar.gz


// Draw property visual indicators
{
const auto &propertyTypes = *ProjectManager::instance()->project().propertyTypes();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use Object::propertyTypes() to get the currently active property types.

@kanishka0411
Copy link
Copy Markdown
Contributor Author

Hey @bjorn, thanks for the review! i have made the changes based on your suggestions.

  • The main change is swapping out the StorageType enum for a QVariant defaultValue like you suggested
  • The "Add Primitive" button now pops up a menu to pick the type, and I got rid of the storage type combo from the details panel since it's no longer needed.
  • Also simplified the tileset view to use propertyValue.type() directly and hooked up the document signals so indicators update in real time.

Let me know if there's anything else you'd like me to change :-)

Copy link
Copy Markdown
Member

@bjorn bjorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more comments. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow custom properties to be assigned a unique color to show inside of tileview/mapview/tileset preview windows

3 participants