-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New Hardware Renderer: Add tool brush to mapview.qml #4547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
UltraDagon
wants to merge
29
commits into
mapeditor:new-hardware-renderer
Choose a base branch
from
UltraDagon:nhr/tool-brush
base: new-hardware-renderer
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 23 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 6760a51
Fixed tool brush mapitem to no longer cause errors when the map is un…
UltraDagon f530985
mapview.qml updates upon old editor tool usage
UltraDagon 0005b76
Added sizeChanged and tileSizeChanged notify signals to editablemap
UltraDagon 451055f
Changed libtiledquick/mapitem::repaintRegion to only update the affec…
UltraDagon d703b13
Updated new ToolBrush to work with mouse movement and fill tool
UltraDagon 85dcc28
Moved quick brush changes to onQuickBrushChanged and set up emits in …
UltraDagon 833bbf0
Don't link to the tiledquickplugin
bjorn b07fc43
Changed editablemap's size signals to be sent properly; MapItem now r…
UltraDagon 9ca0d81
Added disconnects for libtiledquick/mapitem's setmap connections
UltraDagon 40055c8
Small fixes for review comments
UltraDagon 2e3f22b
Renamed quickBrushChanged signal to brushMapChanged; Javascript owner…
UltraDagon 8632491
Partially implemented requested brushItem->map() and toolBrushMap cha…
UltraDagon e096b8d
Moved brushChanged logic to a Q_PROPERTY and quickMouseCoordsChanged …
UltraDagon 8c3e48f
Fixed ifdefs for TILEDQUICK_LIB
UltraDagon 4cbb046
Created template classes and setup for regionOverlay
UltraDagon e6ac0b9
Fixed crash that happened upon QML's garbage collection for tileEditP…
UltraDagon 5775da4
Fixed small typo in mapview.qml
UltraDagon 26b461f
Fixed memory leak with setTileEditPreview; brushMapChanged now takes …
UltraDagon fc5b3ec
Removed AbstractTileTool::toolBrush(); Fixed crash caused by closing …
UltraDagon b8afceb
Added RegionOverlay for selected tiles to mapview.qml
UltraDagon 163e803
Linked quick mouse onPress and onRelease events to selectedTool
UltraDagon 40b1776
Moved tileEditRegionChanged code from brushItem to abstractTileTool &…
UltraDagon 5d21d77
Changed brushRegionOverlay to indicate if brush is in or out of map b…
UltraDagon d4a3f4a
Added selectedRegionOverlay; RegionOverlay tweaks
UltraDagon a75bf94
Added EditableMap constructor for using SharedMaps
UltraDagon 4dfaad9
Added safeguard for new EditableMap constructor usage; Small RegionOv…
UltraDagon eee95ff
Fixed crash by only forwarding Quick mouse events to an active tool
bjorn 8dd9411
Added requested changes
UltraDagon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| /* | ||
| * regionoverlay.cpp | ||
| * Copyright 2026, UltraDagon | ||
| * | ||
| * This file is part of Tiled Quick. | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU General Public License as published by the Free | ||
| * Software Foundation; either version 2 of the License, or (at your option) | ||
| * any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| * more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License along with | ||
| * this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #include "regionoverlay.h" | ||
|
|
||
| #include <QPainterPath> | ||
| #include <QApplication> | ||
| #include <QPalette> | ||
|
|
||
| using namespace TiledQuick; | ||
|
|
||
| RegionOverlay::RegionOverlay(QQuickItem *parent) | ||
| : QQuickItem(parent) | ||
| , mTileSize(0, 0) | ||
| , mRegion(QRegion()) | ||
| , mColor(QApplication::palette().highlight().color()) | ||
| { | ||
| } | ||
|
|
||
| RegionOverlay::~RegionOverlay() = default; | ||
|
|
||
| QList<QPolygonF> RegionOverlay::polygons() const | ||
| { | ||
| QPainterPath path; | ||
|
|
||
| for (const QRect &r : mRegion.rects()) | ||
| path.addRect(r); | ||
|
|
||
| QList<QPolygonF> polygons = path.simplified().toFillPolygons(); | ||
|
|
||
| QTransform transform; | ||
| transform.scale(mTileSize.x(), mTileSize.y()); | ||
|
|
||
| for (QPolygonF &polygon : polygons) | ||
| polygon = polygon * transform; | ||
|
|
||
| return polygons; | ||
| } | ||
|
|
||
| QColor RegionOverlay::strokeColor() const | ||
| { | ||
| return mColor; | ||
| } | ||
|
|
||
| QColor RegionOverlay::fillColor() const | ||
| { | ||
| QColor fillColor = mColor; | ||
| fillColor.setAlpha(64); | ||
| return fillColor; | ||
| } | ||
|
|
||
| QPointF RegionOverlay::tileSize() const | ||
| { | ||
| return mTileSize; | ||
| } | ||
|
|
||
| void RegionOverlay::setTileSize(const QPointF &tileSize) | ||
| { | ||
| if (mTileSize == tileSize) | ||
| return; | ||
|
|
||
| mTileSize = tileSize; | ||
| emit tileSizeChanged(); | ||
| } | ||
|
|
||
| QRegion RegionOverlay::region() const | ||
| { | ||
| return mRegion; | ||
| } | ||
|
|
||
| void RegionOverlay::setRegion(const QRegion ®ion) | ||
| { | ||
| if (mRegion == region) | ||
| return; | ||
|
|
||
| mRegion = region; | ||
| emit regionChanged(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| * regionoverlay.h | ||
| * Copyright 2026, UltraDagon | ||
| * | ||
| * This file is part of Tiled Quick. | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU General Public License as published by the Free | ||
| * Software Foundation; either version 2 of the License, or (at your option) | ||
| * any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| * more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License along with | ||
| * this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <QQuickItem> | ||
|
|
||
| #include "tiledquick_global.h" | ||
|
|
||
| namespace TiledQuick { | ||
|
|
||
| class TILEDQUICK_SHARED_EXPORT RegionOverlay : public QQuickItem | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| Q_PROPERTY(QPointF tileSize READ tileSize WRITE setTileSize NOTIFY tileSizeChanged) | ||
| Q_PROPERTY(QRegion region READ region WRITE setRegion NOTIFY regionChanged) | ||
|
|
||
| public: | ||
| explicit RegionOverlay(QQuickItem *parent = nullptr); | ||
| ~RegionOverlay() override; | ||
|
|
||
| Q_INVOKABLE QList<QPolygonF> polygons() const; | ||
| Q_INVOKABLE QColor strokeColor() const; | ||
| Q_INVOKABLE QColor fillColor() const; | ||
|
|
||
| QPointF tileSize() const; | ||
| void setTileSize(const QPointF &tileSize); | ||
|
|
||
| QRegion region() const; | ||
| void setRegion(const QRegion ®ion); | ||
|
|
||
| signals: | ||
| void tileSizeChanged(); | ||
| void regionChanged(); | ||
|
|
||
| private: | ||
| QPointF mTileSize; | ||
| QRegion mRegion; | ||
| QColor mColor; | ||
| }; | ||
|
|
||
| } // namespace TiledQuick |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,8 +136,6 @@ void TileLayerItem::syncWithTileLayer() | |
| setSize(boundingRect.size()); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| QSGNode *TileLayerItem::updatePaintNode(QSGNode *node, | ||
| QQuickItem::UpdatePaintNodeData *) | ||
| { | ||
|
|
@@ -201,6 +199,10 @@ QSGNode *TileLayerItem::updatePaintNode(QSGNode *node, | |
| return node; | ||
| } | ||
|
|
||
| Tiled::TileLayer *TileLayerItem::layer() { | ||
| return mLayer; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A good candidate for inlining. :-) |
||
| } | ||
|
|
||
| void TileLayerItem::updateVisibleTiles() | ||
| { | ||
| const MapItem *mapItem = static_cast<MapItem*>(parentItem()); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this added here? I think that should be already covered by this line above:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that, Qt Creator auto adds it whenever I add new files and I must have forgot to remove it.