Repository navigation
refactor(erd): ErdViewport and ErdCanvas out of _ErdViewState, saved-view rules into the controller (#1690) - #1724
Merged
Merged
Conversation
…; viewport and controller tests (#1690)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Refs #1690 (second PR: the canvas)
erd_view.dart: 1482 -> 1285 lines (1844 before #1723). Behaviour and look unchanged.ErdViewport(erd_viewport.dart): zoom and pan with theTransformationController, the viewport box key, the zoom floor, and the maths:zoomToabout a point,zoomBy,fit(returns whether the floor moved),centreOn,centre,toCanvas/toScreen. It replaces_scale,_viewportSize,_setScale,_viewCentreand the matrix code in the view.ErdCanvas(widgets/erd_canvas.dart): the shortcuts and focus, theInteractiveViewerover the sheet, and the layers in order (hover layer, group frames, edges, cards, notes), then the edge label, the search panel and the zoom controls in screen space. The view builds the layers and hands them in.snapshot,capture,toStore,stateOfViewandaddViewFromCurrenthold the rules of saving and switching views (which layout goes to the active view or to All tables, which tables a view keeps, that a new view from All tables leaves it showing every table); the view only supplies positions and viewport.Tests:
erd_viewport_test.dart(zoom about a point keeps it still, clamping to the floor and maximum, conversions, fit without enlarging, fit of a diagram bigger than the floor, centring), six more controller tests for saving and views. The 140 existing ERD tests pass unchanged, and so do workspace, core/erd and e2e (663 locally). Bench: erd_open_200 build p90 19.1 ms, erd_hover 0.1 ms, erd_drag 0.2 ms.Where the issue's ~900 lines stands: not reached. What is left in
_ErdViewStateis the glue that needs the layout, the schema and the viewport together (loading, routing and card drag, group and note drag, the export source forErdExporter, the dialogs). Splitting it further would mean one more object that owns the layout and the routes; I'd rather leave that decision to you than move it for the number. The issue stays open for that.