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 62 commits into
base: master
Choose a base branch
from

Commits on Oct 24, 2024

  1. Started a rewrite of the property editor

    The new property editor will be based on a widget hierarchy instead of a
    QTreeView. This will allow better customization and direct widget
    interaction.
    
    This first step implements various property edit widgets which are
    instantiated based on the type of QVariant values.
    
    * DoubleSpinBox, with precision logic from existing property editor
    * Custom spin boxes and combo boxes which shrink horizontally
    * Property names elide when there isn't enough space
    * QPointF and QColor editor factories
    * Includes a test with all built-in map properties
    * Supports headers (not collapsible for now)
    * Supports separators
    * EnumEditorFactory, with support for non-consecutive enums
    * Name and editor widgets are stretched by a fixed 2:3 ratio and ignore
      their size hint
    * Includes some start on possible API for setting/getting the value
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    2d2a3f1 View commit details
    Browse the repository at this point in the history
  2. Introduced a responsive editor for QSize

    It adjusts the layout based on its width.
    
    Also made a few other visual tweaks.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    5179a8e View commit details
    Browse the repository at this point in the history
  3. First fully functional "Map Orientation" property

    Introduced Property class and changed from using editor factories to
    having the property itself create its widget.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    1637962 View commit details
    Browse the repository at this point in the history
  4. Implemented "Map Size" and "Tile Size" properties

    * Map size is read-only but features a "Resize Map" button that triggers
      the resize dialog.
    
    * Both map size and tile size are implemented based on the new
      "ValueTypeEditorFactory" which selects an editor based on the value
      type. This functionality is moved out of the VariantEditor.
    
    * Introduced AbstractProperty, ValueProperty and QObjectProperty in an
      attempt to provide some convenience on top of the Property interface.
    
    I'm not entirely convinced it was a good idea to put the "createEditor"
    function on the Property. It makes it easy to do custom widgets for a
    property, but annoying to have it use a type-based editor.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    8113c2b View commit details
    Browse the repository at this point in the history
  5. Implemented "Infinite" and "Hex Side Length" properties

    * Introduced MapProperties class to make it easier to emit valueChanged
      for all the map's properties, as well to move their creation out of
      PropertiesWidget::currentObjectChanged.
    
    * Added GetSetProperty that makes it easier to define a property in
      terms of a given getter and setter function, since it avoids the need
      for a specific Property subclass.
    
    * Finished implementation of the BoolEditorFactory (signals connected).
    
    * Moved property edit widgets to their own file.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    e40c924 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    21259d3 View commit details
    Browse the repository at this point in the history
  7. Implemented remaining Map properties

    * Introduced a few helper functions to reduce code duplication, like
      MapProperties::push.
    
    * Disabled properties when they are irrelevant.
    
    * Finished connecting the signals for the remaining editor factories:
      StringEditorFactory, IntEditorFactory, FloatEditorFactory,
      PointEditorFactory, PointFEditorFactory, RectFEditorFactory and
      ColorEditorFactory.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    0ee9d10 View commit details
    Browse the repository at this point in the history
  8. Implemented custom widget for Class property

    This property uses an editable combo box with the valid classes set up for
    the given object type.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    5e9cb22 View commit details
    Browse the repository at this point in the history
  9. Made most Tileset properties functional

    Still needs special handling for:
    
    * Color (requires handling invalid/unset values)
    * Widget for editing allowed transformations
    * Widget for showing tileset parameters (and trigger edit dialog)
    * Specifying 1 as minimum value for column count
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    ad0a4dd View commit details
    Browse the repository at this point in the history
  10. Implemented Layer properties

    Some details remain to be done:
    
    * Changes made to layer properties should apply to all selected layers
    * Opacity should probably be a slider now and have appropriate limits
    * Step size for opacity and parallax factor is too big
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    754fd17 View commit details
    Browse the repository at this point in the history
  11. Added Image Layer and Group Layer properties

    Added support for editing QUrl values using UrlEditorFactory that
    creates a FileEdit.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    ba5c31d View commit details
    Browse the repository at this point in the history
  12. Added properties for map objects

    Also in this change:
    
    * Made SpinBox and DoubleSpinBox don't respond to changing from
      keyboard typing immediately.
    
    * Share a single implementation of wrapping label/widget pairs for
      SizeEdit, SizeFEdit, PointEdit, PointFEdit and RectFEdit.
    
    * Added widget factories for QFont, QSizeF and Qt::Alignment.
    
    * Allow setting suffix on custom FloatEditorFactory, used for adding
      degree symbol to rotation values.
    
    A few things remain to be done:
    
    * Custom widget for editing tile object flipping flags
    * Try reducing size of font editor with style toggle buttons
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    2f0e76a View commit details
    Browse the repository at this point in the history
  13. Implemented Tile, WangSet and WangColor properties

    Now all built-in properties are present, apart from some loose ends.
    
    * Added RectEdit / RectEditorFactory (QRect values)
    * Added Property::toolTip (set on label and editor, but currently not
      functional on label due to the eliding tool tip logic)
    * Added change events to fix updating of WangSet and WangColor properties
      (was already broken with old framework)
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    7a6de73 View commit details
    Browse the repository at this point in the history
  14. Refactor that gets rid of most editor factories

    Instead there are now typed Property subclasses similar to the generic
    GetSetProperty.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    d89f757 View commit details
    Browse the repository at this point in the history
  15. Renamed ValueTypeEditorFactory to PropertyFactory

    This name is more appropriate for what it actually does. It also no
    longer derives from EditorFactory.
    
    PropertyFactory::createQObjectProperty should be functional again. It
    now returns an appropriate property, and the QObjectProperty class is
    gone. This approach is still not used, however.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    ddbf1d6 View commit details
    Browse the repository at this point in the history
  16. Simplifying or over-complicating things

    * Removed EditorFactory, EnumEditorFactory, AbstractProperty,
      ValueProperty and GetSetProperty.
    
    * EnumProperty now derives from IntProperty and retrieves the enum
      meta-data based on its template argument.
    
    * Use the typed properties to avoid QVariant when synchronizing between
      the created editor.
    
    For the built-in properties, this definitely simplifies things. But it
    remains to be seen how custom properties are best handled.
    
    Also due to the lack of registering editor factories, QObjectProperty
    is now broken for enums (but it's unused).
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    3211a46 View commit details
    Browse the repository at this point in the history
  17. Addressed various property todo items

    * Apply various minimum and maximum values
    * Set custom step size where needed
    * Set file filters where appropriate
    * Support constraint on RectProperty
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    dc083df View commit details
    Browse the repository at this point in the history
  18. Use tool buttons for text styling in FontProperty

    Makes font property widget take up less vertical space.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    c52c920 View commit details
    Browse the repository at this point in the history
  19. Progress on various property editor features

    * Added support for editing top-level custom properties (excluding support
      for classes and enums for now).
    
    * Added support for collapsing the property groups, based on a new
      GroupProperty which creates nested VariantEditor instances.
    
    * Removed QVariant based getter/setter from Property, since it doesn't
      appear to be useful.
    
    * Added Property::DisplayMode, which is used to tell apart group
      properties and separators from regular properties.
    
    * VariantEditor is no longer a scroll area itself, to enable nesting.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    2cb3d25 View commit details
    Browse the repository at this point in the history
  20. Made a special case for the image layer repeat setting

    Also made some other small tweaks.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    09f16a6 View commit details
    Browse the repository at this point in the history
  21. Added support for "no label" properties, used for bool values

    Also fixed indentatation of property labels to match the header widget.
    
    And fixed the margins on the side for groups of properties without
    separator (affected Custom Properties).
    
    Not entirely sure moving the label of boolean properties is the right
    thing to do.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    e1416bd View commit details
    Browse the repository at this point in the history
  22. Used Slider for opacity property, replacing the one in Layers view

    Opacity is now implemented as IntProperty that goes from 0 to 100.
    
    Now the Properties view needs to be open to change the layer opacity. If
    that's a problem for some we can consider reintroducing the opacity
    slider in the Layers view.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    6bbae7f View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    3daeedc View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    057edb4 View commit details
    Browse the repository at this point in the history
  25. Fixed an issue with VariantEditor::clear

    Not everything was deleted from the layout because the deletion was
    lacking support for handling nested layouts.
    
    Also removed the only remaining case where a nested layout was used at
    the top-level.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    0bc17ed View commit details
    Browse the repository at this point in the history
  26. Added suffixes, support for custom enums and other progress

    * Added "px" suffixes to various pixel values.
    
    * Added support for custom enum properties (top-level only so far,
      because there is no support for class properties yet). It's amazing
      how trivial this was with the new approach (though, it does not
      support enums with values as flags yet).
    
    * Enabled editing of tileset image parameters through a button and made
      some progress towards allowing a GroupProperty to appear like a normal
      property (currently it can, but then it no longer shows its children).
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    82da15c View commit details
    Browse the repository at this point in the history
  27. Added support for custom enum types that are used as flags

    It creates a checkbox for each flag. They will need to be able to
    collapse in case there are lots of flags, but this works for now.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    fed14c8 View commit details
    Browse the repository at this point in the history
  28. Allow expanding the child properties for any GroupProperty

    Also when it isn't displayed as a header. Also introduced a "level"
    member of VariantEditor which is passed on to the PropertyLabel, which
    is used to indent expanded child properties.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    d40ab86 View commit details
    Browse the repository at this point in the history
  29. Added support for custom class properties

    Including changing of nested values. However, several things remain to be
    done, including:
    
    * When the custom properties are refreshed, all properties (and their
      widgets) are re-created. There should be a way to update their value
      instead.
    
    * There is no way to see yet whether a property is set, nor can its value
      be reset.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    ba50ef9 View commit details
    Browse the repository at this point in the history
  30. Show inherited class name as placeholder text

    For map objects, which can inherit their class from their tile or their
    template.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    382e4fe View commit details
    Browse the repository at this point in the history
  31. Implemented Remove and Reset buttons for custom properties

    * Top-level custom properties can now be removed.
    * Class members can be reset.
    
    A "modified" state was added to Property, which is updated as necessary
    and indicated by using bold font for the name.
    
    Further tweaks to the spacing between property widgets and draw line to
    separate property group headers.
    
    A generic VariantMapProperty was split off from the CustomProperties
    class, since the former can also be a base for editing class members.
    
    The ColorButton widget now replaces its icon with "Unset" text when an
    invalid color is set.
    
    When changing the "Class" it now affects all selected objects.
    
    Fixed layout flicker when collapsing nested class members.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    74666e1 View commit details
    Browse the repository at this point in the history
  32. Added ability to add (override) an inherited property

    In the previous property editor, overriding happened automatically as
    soon as you changed a value. Now that the edit widgets are always
    visible, I've instead opted to show a disabled widget for inherited
    properties along with a '+' button for adding (overriding) that
    property.
    
    I think this helps unintensionally setting a value, and the disabled
    state.
    
    Currently the VariantMapProperty does not yet handle a possible change
    of property type when a removed property has a different type than the
    inherited property.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    c99a1e7 View commit details
    Browse the repository at this point in the history
  33. Optimized updating of the list of custom properties

    * Now properties that have the same name and type are re-used, avoiding
      re-creation of editors for most property changes. This also avoids
      collapsing of nested properties in those cases.
    
    * Properties that change type, are re-created.
    
    We can still optimise the case where the current object changes further,
    because in this case all property widgets are still re-created because
    the CustomProperties object is re-added to the top-level VariantEditor
    instance.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    75e24c3 View commit details
    Browse the repository at this point in the history
  34. Optimized PropertyLabel to not need a QLineEdit instance

    It was only used for calculating the size hint, which is now done with
    some code copied and adjusted from QLineEdit::sizeHint.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    02eda6e View commit details
    Browse the repository at this point in the history
  35. Don't display label on checkbox for boolean properties

    For now it still does this for some common built-in properties, but no
    longer for custom properties.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    deb0a09 View commit details
    Browse the repository at this point in the history
  36. Create child property widgets on-demand as they are expanded

    Might be necessary for performance reasons, because the amount of
    widgets created could quickly get out of hand.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    b301505 View commit details
    Browse the repository at this point in the history
  37. Handle changes in the custom property types

    Now any properties using custom types are re-created when any change is
    made to the custom types.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    82ab2cb View commit details
    Browse the repository at this point in the history
  38. Collect property values from all selected objects

    In order to allow them to be easily added, when they are not set on the
    current object.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    8cc0374 View commit details
    Browse the repository at this point in the history
  39. Made layer properties apply to all selected layers

    Same for the more specific object layer and image layer properties.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    629b53c View commit details
    Browse the repository at this point in the history
  40. Added a custom widget for the object flipping property

    Using two toggle buttons rather than checkboxes, similar to the "Allowed
    Transformations" tileset property.
    
    Also changed the stretch factor of the property labels column to be the
    same as the property editor column. It looks more balanced overall and
    helps to keep the labels readable when propeties are nested a few
    levels.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    9e0c001 View commit details
    Browse the repository at this point in the history
  41. Apply changes to map objects to all selected objects

    Also made the changes to layer offset and object flipping more specific,
    only changing the actually changing axis for all selected layers or
    objects respectively.
    
    The same still needs to be done for changing object position or size.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    ed94a00 View commit details
    Browse the repository at this point in the history
  42. Show the type of custom properties in their tool tip

    Also fixed some issues in left-to-right mode.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    da05ecf View commit details
    Browse the repository at this point in the history
  43. Configuration menu
    Copy the full SHA
    58d7a35 View commit details
    Browse the repository at this point in the history
  44. Remember the expanded state of custom class properties

    The expanded state is now remembered for each "path", meaning you can
    select different objects, and when they happen to have the same
    properties the expanded state applies to all of them.
    
    For now the state is lost when Tiled is closed. It might be nice to
    store the list of expanded property paths in the session.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    bd54309 View commit details
    Browse the repository at this point in the history
  45. Added context menu to custom properties

    Currently providing access to the existing Add, Remove and Reset actions
    as well as "Expand All" and "Collapse All" for custom classes.
    
    This also adds the fallback icons to the existing action buttons.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    c982c20 View commit details
    Browse the repository at this point in the history
  46. Configuration menu
    Copy the full SHA
    35a7ca1 View commit details
    Browse the repository at this point in the history
  47. Configuration menu
    Copy the full SHA
    fae849c View commit details
    Browse the repository at this point in the history
  48. Spin boxes and combo boxes ignore wheel events when not focused

    Otherwise it is too easy to accidentally trigger them while scrolling
    through the Properties view.
    bjorn committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    56b4deb View commit details
    Browse the repository at this point in the history

Commits on Oct 25, 2024

  1. Fixed changing the compression level property

    It was affecting the background color instead, due to a wrong
    constructor overload getting chosen.
    bjorn committed Oct 25, 2024
    Configuration menu
    Copy the full SHA
    6fc6c5d View commit details
    Browse the repository at this point in the history

Commits on Oct 29, 2024

  1. Addressed a few usability issues

    * Cursor no longer jumps to the end when editing string properties.
    
    * Global undo/redo shortcuts are no longer overridden by those local to
      property edit widgets.
    
    * Since global undo/redo is now relied upon, the keyboard tracking is
      enabled again for spin boxes.
    bjorn committed Oct 29, 2024
    Configuration menu
    Copy the full SHA
    dd0784a View commit details
    Browse the repository at this point in the history
  2. Made consecutive edits to map properties merge together

    Like already happens for the properties of most other data types.
    
    The new properties view made it extra noticeable that each change became
    its own undo command.
    bjorn committed Oct 29, 2024
    Configuration menu
    Copy the full SHA
    2177fac View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    82d7b49 View commit details
    Browse the repository at this point in the history

Commits on Oct 31, 2024

  1. Remember the expanded state for built-in property groups

    It remembers the expanded state by their index, because this seems like
    the most desirable behavior.
    
    The built-in property groups are now children of a top-level
    GroupProperty with a new "ChildrenOnly" display mode. This mode
    suppresses the display of a collapsible header.
    bjorn committed Oct 31, 2024
    Configuration menu
    Copy the full SHA
    2cabfad View commit details
    Browse the repository at this point in the history

Commits on Nov 5, 2024

  1. Fixed initialization of SizeProperty::m_minimum

    This was causing the map size display to sometimes display way too large
    values.
    bjorn committed Nov 5, 2024
    Configuration menu
    Copy the full SHA
    13fe21e View commit details
    Browse the repository at this point in the history

Commits on Nov 6, 2024

  1. Fixed flickering when rewrapping widget pairs

    Rather than rearranging widgets in a QGridLayout in the resize event, we
    now use a custom layout, which can propertly implement heightForWidth to
    ensure a smooth layout update.
    bjorn committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    921bce2 View commit details
    Browse the repository at this point in the history
  2. Fixed opacity slider to also ignore wheel events when not focused

    Since handling wheel events interferes with scrolling through the
    properties.
    bjorn committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    9711234 View commit details
    Browse the repository at this point in the history
  3. Group object "Position" and "Size" properties as "Geometry"

    This is mostly to improve the layout since the W is often wider than the
    X and Y.
    
    The minimum size hint for the DoubleSpinBox was increased a bit so it
    wraps a bit earlier.
    
    This change also makes it so that changing any of these values changes
    only that particular value for all selected objects.
    bjorn committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    023ba4c View commit details
    Browse the repository at this point in the history

Commits on Nov 8, 2024

  1. Used the new properties widget in the Custom Types Editor

    * Moved VariantMapProperty to its own file, because it is now also used
      by the PropertyTypesEditor.
    
    * Introduced VariantEditorView to share a bit of code.
    bjorn committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    a7777eb View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2b710d4 View commit details
    Browse the repository at this point in the history
  3. Used the new properties framework in the Project Properties dialog

    A bit of a hacky solution to hiding the "Custom Properties" header in
    this context, because it is now inside a group box with that title.
    bjorn committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    8bf312e View commit details
    Browse the repository at this point in the history
  4. Removed now unused VariantEditorFactory and VariantPropertyManager

    These have been replaced by the new property framework.
    bjorn committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    4e1a9cf View commit details
    Browse the repository at this point in the history
  5. Removed the QtPropertyBrowser solution

    The QtPropertyBrowser solution has served us well for over 10 years. Now
    it has been replaced by a new widget-based solution with a more
    convenient API.
    bjorn committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    3ef1916 View commit details
    Browse the repository at this point in the history