Skip to content
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

New properties framework #4045

Draft
wants to merge 78 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
2d2a3f1
Started a rewrite of the property editor
bjorn Aug 15, 2024
5179a8e
Introduced a responsive editor for QSize
bjorn Aug 21, 2024
1637962
First fully functional "Map Orientation" property
bjorn Aug 26, 2024
8113c2b
Implemented "Map Size" and "Tile Size" properties
bjorn Aug 30, 2024
e40c924
Implemented "Infinite" and "Hex Side Length" properties
bjorn Sep 2, 2024
21259d3
Implemented "Stagger Axis/Index" properties
bjorn Sep 2, 2024
0ee9d10
Implemented remaining Map properties
bjorn Sep 3, 2024
5e9cb22
Implemented custom widget for Class property
bjorn Sep 4, 2024
ad0a4dd
Made most Tileset properties functional
bjorn Sep 4, 2024
754fd17
Implemented Layer properties
bjorn Sep 4, 2024
ba5c31d
Added Image Layer and Group Layer properties
bjorn Sep 4, 2024
2f0e76a
Added properties for map objects
bjorn Sep 5, 2024
7a6de73
Implemented Tile, WangSet and WangColor properties
bjorn Sep 6, 2024
d89f757
Refactor that gets rid of most editor factories
bjorn Sep 6, 2024
ddbf1d6
Renamed ValueTypeEditorFactory to PropertyFactory
bjorn Sep 6, 2024
3211a46
Simplifying or over-complicating things
bjorn Sep 9, 2024
dc083df
Addressed various property todo items
bjorn Sep 9, 2024
c52c920
Use tool buttons for text styling in FontProperty
bjorn Sep 9, 2024
2cb3d25
Progress on various property editor features
bjorn Sep 12, 2024
09f16a6
Made a special case for the image layer repeat setting
bjorn Sep 16, 2024
e1416bd
Added support for "no label" properties, used for bool values
bjorn Sep 16, 2024
6bbae7f
Used Slider for opacity property, replacing the one in Layers view
bjorn Sep 16, 2024
3daeedc
Made the property label indentation shrink when there is very little …
bjorn Sep 16, 2024
057edb4
Implemented custom widget for allowed transformations
bjorn Sep 17, 2024
0bc17ed
Fixed an issue with VariantEditor::clear
bjorn Sep 17, 2024
82da15c
Added suffixes, support for custom enums and other progress
bjorn Sep 17, 2024
fed14c8
Added support for custom enum types that are used as flags
bjorn Sep 18, 2024
d40ab86
Allow expanding the child properties for any GroupProperty
bjorn Sep 18, 2024
ba50ef9
Added support for custom class properties
bjorn Sep 24, 2024
382e4fe
Show inherited class name as placeholder text
bjorn Sep 26, 2024
74666e1
Implemented Remove and Reset buttons for custom properties
bjorn Sep 27, 2024
c99a1e7
Added ability to add (override) an inherited property
bjorn Oct 1, 2024
75e24c3
Optimized updating of the list of custom properties
bjorn Oct 10, 2024
02eda6e
Optimized PropertyLabel to not need a QLineEdit instance
bjorn Oct 10, 2024
deb0a09
Don't display label on checkbox for boolean properties
bjorn Oct 11, 2024
b301505
Create child property widgets on-demand as they are expanded
bjorn Oct 11, 2024
82ab2cb
Handle changes in the custom property types
bjorn Oct 11, 2024
8cc0374
Collect property values from all selected objects
bjorn Oct 11, 2024
629b53c
Made layer properties apply to all selected layers
bjorn Oct 11, 2024
9e0c001
Added a custom widget for the object flipping property
bjorn Oct 11, 2024
ed94a00
Apply changes to map objects to all selected objects
bjorn Oct 11, 2024
da05ecf
Show the type of custom properties in their tool tip
bjorn Oct 14, 2024
58d7a35
Fixed the visibility of custom properties on the project
bjorn Oct 15, 2024
bd54309
Remember the expanded state of custom class properties
bjorn Oct 17, 2024
c982c20
Added context menu to custom properties
bjorn Oct 17, 2024
35a7ca1
Moved CSV layer data format up for consistency with New Map dialog
bjorn Oct 24, 2024
fae849c
Added rename action to property context menu
bjorn Oct 24, 2024
56b4deb
Spin boxes and combo boxes ignore wheel events when not focused
bjorn Oct 24, 2024
6fc6c5d
Fixed changing the compression level property
bjorn Oct 25, 2024
dd0784a
Addressed a few usability issues
bjorn Oct 25, 2024
2177fac
Made consecutive edits to map properties merge together
bjorn Oct 29, 2024
82d7b49
Used ChangeMapProperty template to reduce code duplication
bjorn Oct 29, 2024
2cabfad
Remember the expanded state for built-in property groups
bjorn Oct 31, 2024
13fe21e
Fixed initialization of SizeProperty::m_minimum
bjorn Nov 5, 2024
921bce2
Fixed flickering when rewrapping widget pairs
bjorn Nov 6, 2024
9711234
Fixed opacity slider to also ignore wheel events when not focused
bjorn Nov 6, 2024
023ba4c
Group object "Position" and "Size" properties as "Geometry"
bjorn Nov 6, 2024
a7777eb
Used the new properties widget in the Custom Types Editor
bjorn Nov 8, 2024
2b710d4
Removed now unused PropertyBrowser and CustomPropertiesHelper
bjorn Nov 8, 2024
d294ece
Used the new properties framework in the Project Properties dialog
bjorn Nov 8, 2024
e500940
Removed now unused VariantEditorFactory and VariantPropertyManager
bjorn Nov 8, 2024
d0d1ff5
Removed the QtPropertyBrowser solution
bjorn Nov 8, 2024
66ec4aa
Allow using Tab to change focus in the Properties view
bjorn Nov 11, 2024
8c767d0
Fixed some issues when changing map properties
bjorn Nov 11, 2024
ccf704d
Focus new custom properties or class members when adding them
bjorn Nov 11, 2024
5fefeba
Made Add Property action use inline widgets
bjorn Nov 13, 2024
b6e7510
Fixed updating of layer names in Properties view
bjorn Nov 15, 2024
9380587
Added clear button to the editor for color properties
bjorn Nov 15, 2024
d1ddc01
Use VariantEditor directly for ChildrenOnly properties
bjorn Nov 21, 2024
9b00402
Disable custom property editing for tileset objects in map editor
bjorn Nov 21, 2024
eb3eb10
Made custom properties selectable
bjorn Nov 21, 2024
681d4ea
Renamed varianteditor.{h,cpp} to propertiesview.{h,cpp}
bjorn Nov 29, 2024
edc9dac
Fixed color widget and reset button alignment
bjorn Dec 2, 2024
b7c230a
Don't copy an empty array when no properties are selected
bjorn Dec 3, 2024
8a36db5
Select pasted custom properties and expand the group
bjorn Dec 4, 2024
73e6373
Add custom property when pressing Enter with type combo focused
bjorn Dec 5, 2024
8eb447e
Moved the context menu implementation back to PropertiesWidget
bjorn Dec 11, 2024
754b2a5
Make sure the checkbox label remains readable when selected
bjorn Dec 11, 2024
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
6 changes: 6 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@ Icons from the Elementary icon theme (GPLv3)
* src/tiled/images/32/dialog-error.png
* src/tiled/images/32/dialog-warning.png

Icons from the GNOME project (CC0 1.0 Universal)
* src/tiled/resources/images/scalable/text-bold-symbolic.svg
* src/tiled/resources/images/scalable/text-italic-symbolic.svg
* src/tiled/resources/images/scalable/text-underline-symbolic.svg
* src/tiled/resources/images/scalable/text-strikethrough-symbolic.svg


Tilesets:

Expand Down
3 changes: 1 addition & 2 deletions src/libtiled/imagelayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ ImageLayer *ImageLayer::initializeClone(ImageLayer *clone) const
clone->mImageSource = mImageSource;
clone->mTransparentColor = mTransparentColor;
clone->mImage = mImage;
clone->mRepeatX = mRepeatX;
clone->mRepeatY = mRepeatY;
clone->mRepetition = mRepetition;

return clone;
}
43 changes: 23 additions & 20 deletions src/libtiled/imagelayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ namespace Tiled {
class TILEDSHARED_EXPORT ImageLayer : public Layer
{
public:
enum Repetition {
/**
* Makes the image repeat along the X axis.
*/
RepeatX = 0x1,

/**
* Makes the image repeat along the Y axis.
*/
RepeatY = 0x2,
};
Q_DECLARE_FLAGS(RepetitionFlags, Repetition)

ImageLayer(const QString &name, int x, int y);
~ImageLayer() override;

Expand Down Expand Up @@ -114,25 +127,13 @@ class TILEDSHARED_EXPORT ImageLayer : public Layer
*/
bool isEmpty() const override;

/**
* Returns true if the image of this layer repeats along the X axis.
*/
bool repeatX() const { return mRepeatX; }

/**
* Returns true if the image of this layer repeats along the Y axis.
*/
bool repeatY() const { return mRepeatY; }

/**
* Sets whether the image of this layer repeats along the X axis.
*/
void setRepeatX(bool repeatX) { mRepeatX = repeatX; }
bool repeatX() const { return mRepetition & RepeatX; }
bool repeatY() const { return mRepetition & RepeatY; }
RepetitionFlags repetition() const { return mRepetition; }

/**
* Sets whether the image of this layer repeats along the Y axis.
*/
void setRepeatY(bool repeatY) { mRepeatY = repeatY; }
void setRepeatX(bool repeatX) { mRepetition.setFlag(RepeatX, repeatX); }
void setRepeatY(bool repeatY) { mRepetition.setFlag(RepeatY, repeatY); }
void setRepetition(RepetitionFlags repetition) { mRepetition = repetition; }

ImageLayer *clone() const override;

Expand All @@ -143,8 +144,10 @@ class TILEDSHARED_EXPORT ImageLayer : public Layer
QUrl mImageSource;
QColor mTransparentColor;
QPixmap mImage;
bool mRepeatX = false;
bool mRepeatY = false;
RepetitionFlags mRepetition;
};

} // namespace Tiled

Q_DECLARE_METATYPE(Tiled::ImageLayer::RepetitionFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(Tiled::ImageLayer::RepetitionFlags)
12 changes: 10 additions & 2 deletions src/libtiled/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ class TILEDSHARED_EXPORT Map : public Object
QString exportFormat;

enum Property {
TileWidthProperty,
TileHeightProperty,
TileSizeProperty,
InfiniteProperty,
HexSideLengthProperty,
StaggerAxisProperty,
Expand Down Expand Up @@ -212,6 +211,7 @@ class TILEDSHARED_EXPORT Map : public Object
void setTileHeight(int height);

QSize tileSize() const;
void setTileSize(QSize size);

bool infinite() const;
void setInfinite(bool infinite);
Expand Down Expand Up @@ -455,6 +455,12 @@ inline QSize Map::tileSize() const
return QSize(mParameters.tileWidth, mParameters.tileHeight);
}

inline void Map::setTileSize(QSize size)
{
mParameters.tileWidth = size.width();
mParameters.tileHeight = size.height();
}

inline bool Map::infinite() const
{
return mParameters.infinite;
Expand Down Expand Up @@ -791,3 +797,5 @@ Q_DECLARE_METATYPE(Tiled::Map*)
Q_DECLARE_METATYPE(Tiled::Map::Orientation)
Q_DECLARE_METATYPE(Tiled::Map::LayerDataFormat)
Q_DECLARE_METATYPE(Tiled::Map::RenderOrder)
Q_DECLARE_METATYPE(Tiled::Map::StaggerAxis)
Q_DECLARE_METATYPE(Tiled::Map::StaggerIndex)
41 changes: 28 additions & 13 deletions src/libtiled/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ Object::~Object()
delete mEditable;
}

const ClassPropertyType *Object::classType() const
{
QString objectClassName = className();
if (objectClassName.isEmpty() && typeId() == Object::MapObjectType) {
auto mapObject = static_cast<const MapObject*>(this);
objectClassName = mapObject->effectiveClassName();
}

return propertyTypes().findClassFor(objectClassName, *this);
}

/**
* Returns the value of the property \a name, taking into account that it may
* be inherited from another object or from the class.
Expand Down Expand Up @@ -78,32 +89,36 @@ QVariant Object::resolvedProperty(const QString &name) const
QVariantMap Object::resolvedProperties() const
{
QVariantMap allProperties;
Tiled::mergeProperties(allProperties, inheritedProperties());
return allProperties;
}

/**
* Computes the inherited properties for this object. This excludes the
* properties that are directly set on the object.
*/
QVariantMap Object::inheritedProperties() const
{
QVariantMap inheritedProperties;

// Insert properties into allProperties in the reverse order that
// Object::resolvedProperty searches them, to make sure that the
// same precedence is maintained.

QString objectClassName = className();
if (objectClassName.isEmpty() && typeId() == Object::MapObjectType) {
auto mapObject = static_cast<const MapObject*>(this);
objectClassName = mapObject->effectiveClassName();
}

if (auto type = propertyTypes().findClassFor(objectClassName, *this))
Tiled::mergeProperties(allProperties, type->members);
if (auto type = classType())
Tiled::mergeProperties(inheritedProperties, type->members);

if (typeId() == Object::MapObjectType) {
auto mapObject = static_cast<const MapObject*>(this);

if (const Tile *tile = mapObject->cell().tile())
Tiled::mergeProperties(allProperties, tile->properties());
Tiled::mergeProperties(inheritedProperties, tile->properties());

if (const MapObject *templateObject = mapObject->templateObject())
Tiled::mergeProperties(allProperties, templateObject->properties());
Tiled::mergeProperties(inheritedProperties, templateObject->properties());
}

Tiled::mergeProperties(allProperties, properties());

return allProperties;
return inheritedProperties;
}

bool Object::setProperty(const QStringList &path, const QVariant &value)
Expand Down
3 changes: 3 additions & 0 deletions src/libtiled/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class TILEDSHARED_EXPORT Object
const QString &className() const;
void setClassName(const QString &className);

const ClassPropertyType *classType() const;

/**
* Returns the properties of this object.
*/
Expand Down Expand Up @@ -111,6 +113,7 @@ class TILEDSHARED_EXPORT Object

QVariant resolvedProperty(const QString &name) const;
QVariantMap resolvedProperties() const;
QVariantMap inheritedProperties() const;

/**
* Returns the value of the object's \a name property, as a string.
Expand Down
1 change: 1 addition & 0 deletions src/libtiled/objectgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,4 @@ TILEDSHARED_EXPORT ObjectGroup::DrawOrder drawOrderFromString(const QString &);
} // namespace Tiled

Q_DECLARE_METATYPE(Tiled::ObjectGroup*)
Q_DECLARE_METATYPE(Tiled::ObjectGroup::DrawOrder)
4 changes: 4 additions & 0 deletions src/libtiled/tileset.h
Original file line number Diff line number Diff line change
Expand Up @@ -739,5 +739,9 @@ inline void Tileset::setTransformationFlags(TransformationFlags flags)

Q_DECLARE_METATYPE(Tiled::Tileset*)
Q_DECLARE_METATYPE(Tiled::SharedTileset)
Q_DECLARE_METATYPE(Tiled::Tileset::Orientation)
Q_DECLARE_METATYPE(Tiled::Tileset::TileRenderSize)
Q_DECLARE_METATYPE(Tiled::Tileset::FillMode)
Q_DECLARE_METATYPE(Tiled::Tileset::TransformationFlags)

Q_DECLARE_OPERATORS_FOR_FLAGS(Tiled::Tileset::TransformationFlags)
3 changes: 2 additions & 1 deletion src/libtiled/wangset.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,5 +424,6 @@ TILEDSHARED_EXPORT WangSet::Type wangSetTypeFromString(const QString &);

} // namespace Tiled

Q_DECLARE_METATYPE(Tiled::WangSet*)
Q_DECLARE_METATYPE(Tiled::WangId)
Q_DECLARE_METATYPE(Tiled::WangSet*)
Q_DECLARE_METATYPE(Tiled::WangSet::Type)
93 changes: 0 additions & 93 deletions src/qtpropertybrowser/README.TXT

This file was deleted.

5 changes: 0 additions & 5 deletions src/qtpropertybrowser/common.pri

This file was deleted.

46 changes: 0 additions & 46 deletions src/qtpropertybrowser/qtpropertybrowser.qbs

This file was deleted.

1 change: 0 additions & 1 deletion src/qtpropertybrowser/src/QtAbstractEditorFactoryBase

This file was deleted.

1 change: 0 additions & 1 deletion src/qtpropertybrowser/src/QtAbstractPropertyBrowser

This file was deleted.

1 change: 0 additions & 1 deletion src/qtpropertybrowser/src/QtAbstractPropertyManager

This file was deleted.

1 change: 0 additions & 1 deletion src/qtpropertybrowser/src/QtBoolPropertyManager

This file was deleted.

1 change: 0 additions & 1 deletion src/qtpropertybrowser/src/QtBrowserItem

This file was deleted.

1 change: 0 additions & 1 deletion src/qtpropertybrowser/src/QtButtonPropertyBrowser

This file was deleted.

1 change: 0 additions & 1 deletion src/qtpropertybrowser/src/QtCharEditorFactory

This file was deleted.

1 change: 0 additions & 1 deletion src/qtpropertybrowser/src/QtCharPropertyManager

This file was deleted.

1 change: 0 additions & 1 deletion src/qtpropertybrowser/src/QtCheckBoxFactory

This file was deleted.

1 change: 0 additions & 1 deletion src/qtpropertybrowser/src/QtColorEditorFactory

This file was deleted.

Loading
Loading