Skip to content

Refactoring - splitting up VirtualTrees.pas #1041

Closed
@vincentparrett

Description

@vincentparrett

So now that most of the reliance on friend access has been remove, we can attempt to split things up to make the code base easier to work on.

Proposed split units (and where I am up to)

  • VirtualTrees.Types
  • VirtualTrees.Options
  • VirtualTrees.Columns
  • VirtualTrees.Header
  • VirtualTrees.DragnDrop
  • VirtualTrees.DragImage
  • VirtualTrees.DataObject
  • VirtualTrees.EditLink
  • VirtualTrees.Colors

There will likely be a few more as I work through this.

Now a lot of the types are used in published props and event signatures, so what I am doing is adding aliases at the top of VirtualTrees.pas for those types - that will hopefully avoid breaking anyone's code (although the worst that would happen is they need to add to their uses clause).

There will be some (minor) breaking interface changes with this. For example TVTHeader exposes a TreeView property of type TBaseVirtualTree - that was only possible due to them being in the same unit.. with the split this becomes an issue of circular references. I changed this to TCustomControl and cast where needed in the code. There are a few more cases like this that couldn't be helped. I also needed to change the scope of some methods to public, I will try to avoid that using a cracker class where possible.

I'll update this issue with any breaking changes as I come across them. In the work I have done so far, VirtualTrees.pas shrunk from 38K to 27K lines - still way to large for lots of tooling (like github) but more manageable - and there is still more to split out.

Hopefully I should have a PR ready for review in a day or so.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking ChangeOpen for DiscussionThere are several possibilites to address the issue and anyone is invited for comments.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions