cogentcore / core

A free and open source framework for building powerful, fast, and elegant 2D and 3D apps that run on macOS, Windows, Linux, iOS, Android, and the Web with a single pure Go codebase, allowing you to Code Once, Run Everywhere.
http://cogentcore.org/core
BSD 3-Clause "New" or "Revised" License
1.31k stars 71 forks source link

Major redesign of widget and value configuration structure #971

Closed kkoreilly closed 3 weeks ago

kkoreilly commented 3 weeks ago

This PR constitutes one of the largest structural redesigns of Cogent Core ever. Based on discussions in #961 and #962, in addition to experience with other major issues in the codebase, this PR accomplishes the following primary changes:

  1. It replaces the previous deeply flawed tree.Config paradigm in a GUI context with the newly created Plan paradigm built on Maker and Updater. This allows for significantly better configuration of dynamic widgets in a way much more aligned with the standard declarative paradigms of modern GUI frameworks.
  2. It completely redesigns the previous bloated and poorly designed views.Value into a new lightweight interface-based approach centered around core.Value that drastically reduces the complexity and boilerplate of widget value binding.
  3. It removes the unnecessary use of parts on various widgets, making the codebase more consistent and simple.
  4. It reduces dependence on unsafe and repetitive name referencing in contexts like OnWidgetAdded.
  5. It removes support for embedded field setters in typegen, removing a major source of complexity and unpredictable errors and making the codebase more clear and consistent.

This list is far from exhaustive of all of the changes made in this PR, which are almost guaranteed to break any existing codebases. If anyone else is using Cogent Core at this time and needs help migrating to the new breaking changes, please file an issue.

The restructuring and rewriting of the codebase in accordance with these new principles is not over yet, and there are still various bugs and un-updated sections of code marked with TODO(config). We will continue to work on updating these over the coming weeks, but at this point, the functionality of the codebase should be almost entirely equivalent to that before this rewrite. As such, we made the decision to merge this PR now to better facilitate further updating and refactors. If we waited for this rewrite to be perfect before merging it, we may never end up merging it.