Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0b03c73
Created new mapItem instance for rendering the tool brush on mapview.…
UltraDagon Jun 16, 2026
6760a51
Fixed tool brush mapitem to no longer cause errors when the map is un…
UltraDagon Jun 19, 2026
f530985
mapview.qml updates upon old editor tool usage
UltraDagon Jun 19, 2026
0005b76
Added sizeChanged and tileSizeChanged notify signals to editablemap
UltraDagon Jun 20, 2026
451055f
Changed libtiledquick/mapitem::repaintRegion to only update the affec…
UltraDagon Jun 20, 2026
d703b13
Updated new ToolBrush to work with mouse movement and fill tool
UltraDagon Jun 23, 2026
85dcc28
Moved quick brush changes to onQuickBrushChanged and set up emits in …
UltraDagon Jun 24, 2026
833bbf0
Don't link to the tiledquickplugin
bjorn Jun 24, 2026
b07fc43
Changed editablemap's size signals to be sent properly; MapItem now r…
UltraDagon Jun 24, 2026
9ca0d81
Added disconnects for libtiledquick/mapitem's setmap connections
UltraDagon Jun 24, 2026
40055c8
Small fixes for review comments
UltraDagon Jun 24, 2026
2e3f22b
Renamed quickBrushChanged signal to brushMapChanged; Javascript owner…
UltraDagon Jun 25, 2026
8632491
Partially implemented requested brushItem->map() and toolBrushMap cha…
UltraDagon Jun 26, 2026
e096b8d
Moved brushChanged logic to a Q_PROPERTY and quickMouseCoordsChanged …
UltraDagon Jun 27, 2026
8c3e48f
Fixed ifdefs for TILEDQUICK_LIB
UltraDagon Jun 27, 2026
4cbb046
Created template classes and setup for regionOverlay
UltraDagon Jun 28, 2026
e6ac0b9
Fixed crash that happened upon QML's garbage collection for tileEditP…
UltraDagon Jun 29, 2026
5775da4
Fixed small typo in mapview.qml
UltraDagon Jun 29, 2026
26b461f
Fixed memory leak with setTileEditPreview; brushMapChanged now takes …
UltraDagon Jun 30, 2026
fc5b3ec
Removed AbstractTileTool::toolBrush(); Fixed crash caused by closing …
UltraDagon Jun 30, 2026
b8afceb
Added RegionOverlay for selected tiles to mapview.qml
UltraDagon Jul 1, 2026
163e803
Linked quick mouse onPress and onRelease events to selectedTool
UltraDagon Jul 2, 2026
40b1776
Moved tileEditRegionChanged code from brushItem to abstractTileTool &…
UltraDagon Jul 3, 2026
5d21d77
Changed brushRegionOverlay to indicate if brush is in or out of map b…
UltraDagon Jul 5, 2026
d4a3f4a
Added selectedRegionOverlay; RegionOverlay tweaks
UltraDagon Jul 7, 2026
a75bf94
Added EditableMap constructor for using SharedMaps
UltraDagon Jul 7, 2026
4dfaad9
Added safeguard for new EditableMap constructor usage; Small RegionOv…
UltraDagon Jul 7, 2026
eee95ff
Fixed crash by only forwarding Quick mouse events to an active tool
bjorn Jul 8, 2026
8dd9411
Added requested changes
UltraDagon Jul 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/libtiledquick/mapitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ void MapItem::setMap(Tiled::EditableMap *editableMap)

mEditableMap = editableMap;
mMap = editableMap ? editableMap->map() : nullptr;

if (editableMap)
{
Tiled::MapDocument *mapDocument = editableMap->mapDocument();
connect(mapDocument, &Tiled::MapDocument::regionChanged, this, &MapItem::repaintRegion);
Comment thread
bjorn marked this conversation as resolved.
}

refresh();
emit mapChanged();
}
Expand Down Expand Up @@ -170,3 +177,9 @@ void MapItem::refresh()
const QRect rect = mRenderer->mapBoundingRect();
setImplicitSize(rect.width(), rect.height());
}

void MapItem::repaintRegion(const QRegion &region, Tiled::TileLayer *tileLayer)
{
// TODO: update only the region edited
refresh();
}
2 changes: 2 additions & 0 deletions src/libtiledquick/mapitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class TILEDQUICK_SHARED_EXPORT MapItem : public QQuickItem
private:
void refresh();

void repaintRegion(const QRegion &region, Tiled::TileLayer *tileLayer);

Tiled::Map *mMap;
Tiled::EditableMap *mEditableMap;
QRectF mVisibleArea;
Expand Down
4 changes: 4 additions & 0 deletions src/tiled/editablemap.cpp
Comment thread
UltraDagon marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ void EditableMap::setSize(int width, int height)
map()->setWidth(width);
map()->setHeight(height);
}
emit sizeChanged();
}

void EditableMap::setTileWidth(int value)
Expand All @@ -505,6 +506,7 @@ void EditableMap::setTileWidth(int value)
push(new ChangeMapTileSize(doc, QSize(value, tileHeight())));
else if (!checkReadOnly())
map()->setTileWidth(value);
emit tileSizeChanged();
}

void EditableMap::setTileHeight(int value)
Expand All @@ -513,6 +515,7 @@ void EditableMap::setTileHeight(int value)
push(new ChangeMapTileSize(doc, QSize(tileWidth(), value)));
else if (!checkReadOnly())
map()->setTileHeight(value);
emit tileSizeChanged();
}

void EditableMap::setTileSize(int width, int height)
Expand All @@ -529,6 +532,7 @@ void EditableMap::setTileSize(int width, int height)
} else {
map()->setTileWidth(width);
map()->setTileHeight(height);
emit tileSizeChanged();
}
}

Expand Down
12 changes: 7 additions & 5 deletions src/tiled/editablemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ class TILED_EDITOR_EXPORT EditableMap final : public EditableAsset
{
Q_OBJECT

Q_PROPERTY(int width READ width WRITE setWidth)
Q_PROPERTY(int height READ height WRITE setHeight)
Q_PROPERTY(QSize size READ size)
Q_PROPERTY(int tileWidth READ tileWidth WRITE setTileWidth)
Q_PROPERTY(int tileHeight READ tileHeight WRITE setTileHeight)
Q_PROPERTY(int width READ width WRITE setWidth NOTIFY sizeChanged)
Q_PROPERTY(int height READ height WRITE setHeight NOTIFY sizeChanged)
Q_PROPERTY(QSize size READ size NOTIFY sizeChanged)
Q_PROPERTY(int tileWidth READ tileWidth WRITE setTileWidth NOTIFY tileSizeChanged)
Q_PROPERTY(int tileHeight READ tileHeight WRITE setTileHeight NOTIFY tileSizeChanged)
Q_PROPERTY(bool infinite READ infinite WRITE setInfinite)
Q_PROPERTY(int hexSideLength READ hexSideLength WRITE setHexSideLength)
Q_PROPERTY(StaggerAxis staggerAxis READ staggerAxis WRITE setStaggerAxis)
Expand Down Expand Up @@ -218,6 +218,8 @@ class TILED_EDITOR_EXPORT EditableMap final : public EditableAsset
QSharedPointer<Document> createDocument() override;

signals:
void sizeChanged();
void tileSizeChanged();
void currentLayerChanged();
void selectedLayersChanged();
void selectedObjectsChanged();
Expand Down
16 changes: 15 additions & 1 deletion src/tiled/mapeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ void MapEditor::addDocument(Document *document)
EditableMap *editableMap = qobject_cast<Tiled::EditableMap*>(mapDocument->editable());

engine->rootContext()->setContextProperty(QStringLiteral("mapItemMap"), editableMap);
engine->rootContext()->setContextProperty(QStringLiteral("toolBrushMap"), nullptr);
quickWidget->setSource(QUrl(QStringLiteral("qrc:/qml/mapview.qml")));
quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
#endif
Expand Down Expand Up @@ -825,6 +826,16 @@ void MapEditor::setStamp(const TileStamp &stamp)

mTilesetDock->selectTilesInStamp(stamp);

#ifdef TILEDQUICK_LIB
if (Preferences::instance()->useNewHardwareRenderer())
{
QQuickWidget* activeWidget = mViewForMap.value(mCurrentMapDocument)->quickWidget();
QQmlContext* rootContext = activeWidget->engine()->rootContext();

rootContext->setContextProperty(QStringLiteral("toolBrushMap"), currentBrush());
}
#endif

emit currentBrushChanged();
}

Expand Down Expand Up @@ -1106,7 +1117,10 @@ EditableMap *MapEditor::currentBrush() const

auto map = stamp.variations().first().map->clone();
auto editableMap = new EditableMap(std::move(map));
QQmlEngine::setObjectOwnership(editableMap, QQmlEngine::JavaScriptOwnership);

// Disable JavaScriptOwnership for QtQuick rendering
if (!Preferences::instance()->useNewHardwareRenderer())
QQmlEngine::setObjectOwnership(editableMap, QQmlEngine::JavaScriptOwnership);
Comment thread
bjorn marked this conversation as resolved.
Outdated
return editableMap;
}

Expand Down
30 changes: 29 additions & 1 deletion src/tiled/resources/qml/mapview.qml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,35 @@ Rectangle {
}

Tiled.MapGridItem {
id: mapGriditem
id: mapGridItem
anchors.fill: mapItem

tileSize: Qt.point(mapItem.map.tileWidth, mapItem.map.tileHeight);
scale: mapContainer.scale;

color: "black"
}

Tiled.MapItem { // Tool Brush
id: toolBrush
anchors.left: mapItem.left
anchors.top: mapItem.top
anchors.leftMargin: (Math.floor(cursorTileCoords().x) - Math.floor(this.map ? this.map.width/2 : 0)) * mapGridItem.tileSize.x
anchors.topMargin: (Math.floor(cursorTileCoords().y) - Math.floor(this.map ? this.map.height/2 : 0)) * mapGridItem.tileSize.y

map: toolBrushMap;

visibleArea: {
var scale = mapContainer.scale
Comment thread
bjorn marked this conversation as resolved.
Outdated
if (this.map)
Qt.rect(0,
0,
this.map.width * this.map.tileWidth,
this.map.height * this.map.tileHeight);
else
Qt.rect(0, 0, 0, 0);
}
}
}
}

Expand Down Expand Up @@ -130,4 +151,11 @@ Rectangle {
mapContainer.y = (mapView.height / 2) - ((mapItem.height * scale) / 2)
}
}

function cursorTileCoords() {
var mapRelativeCoords = singleFingerPanArea.mapToItem(mapItem, singleFingerPanArea.mouseX, singleFingerPanArea.mouseY);
var tileCoords = mapItem.screenToTileCoords(mapRelativeCoords.x, mapRelativeCoords.y);

return tileCoords;
}
}
Loading