Commit Graph

33 Commits

Author SHA1 Message Date
Felix Zedén Yverås e4e22dee20 fix: rewrite coordinate management
After some initial smaller fixes, it turned out that I had broken
the red line used when linking fields. Fixing this was not trivial
as I found myself battling a lot of small bugs relating to scale
and translation in the existing code. This was made extra difficult
as a lot of coordinates were calculated when necessary in
Canvas.jsx.

This commit attempts to simplify the coordinate management in a few
different ways:
* There are now two distinct coordinate systems in use, typically
  referred to as "spaces". Screen space and diagram space.
* Diagram space is no longer measured in pixels (though the
  dimension-less measure used instead still maps to pixels at 100%
  zoom).
* The canvas now exposes helper methods for transforming between
  spaces.
* Zoom and translation is now managed via the svg viewBox property.
  * This makes moving items in diagram space much easier as the
    coordinates remain constant regardless of zoom level.
* The canvas now wraps the current mouse position in a context
  object, making mouse movement much easier to work with.
* The transform.pan property now refers to the center of the screen.

A new feature in this commit is that scroll wheel zoom is now based
on the current cursor location, making the diagram more convenient
to move around in.

I have tried to focus on Canvas.jsx and avoid changes that might be
desctructive on existing save files. I also believe more refactors
and abstractions could be introduced based on these changes to make
the diagram even easier to work with. However, I deem that out of
scope for now.
2024-07-17 22:22:52 +02:00
Felix Zedén Yverås 32c82168fe feat: add debug coordinate overlay
Makes debugging issues in conversion from screen space
to diagram space easier.

Only adding english translations as I do not speak the
other languages.
2024-07-14 15:36:54 +02:00
Felix Zedén Yverås 354ea47529 fix: validate transform data before storage
During testing I accidentally managed to submit `NaN` as a pan
coordinate. This had the unfortunate side effect of bricking the
editor.

Given the serverity of an accidental `NaN` and that `NaN`s are not
impossible considering the amount of math involved in mouse move
operations, this commit introduces a simple validation step.

The new validation step should additionally be able to unstuck
anyone who have happened into this state by accident already.
2024-07-14 15:36:54 +02:00
1ilit c005020048 Add option to declare an array 2024-07-05 22:28:44 +03:00
1ilit 9b606114df Rename TablesContext to DiagramContext 2024-07-04 23:18:20 +03:00
1ilit 7c1eecd7a0 Undo and redo enum editing 2024-07-03 21:21:44 +03:00
1ilit 810afe4bc0 Add enums tab 2024-06-30 13:19:21 +03:00
1ilit 9e2684e7a9 Swap INTEGER for INT in generic diagrams to maintain backward compatibility 2024-06-25 02:07:57 +03:00
1ilit 0a108fc33a Import from mysql 2024-06-16 00:23:48 +03:00
1ilit be6ecb066c Load types for selected db 2024-06-06 20:24:05 +03:00
1ilit 3988b8d990 Recover relationships after undoing table delete 2024-05-31 20:17:21 +03:00
1ilit 679f6b05e5 Recover relationships after undoing 'field_delete' 2024-05-31 19:19:58 +03:00
lilit 0371606829 Merge branch 'main' into i18n 2024-05-16 07:01:55 +03:00
1ilit 2b4b01c358 Configure i18n and add simplified chinese (#99) 2024-05-16 06:45:47 +03:00
liao文禧 a33b68bfd0 place optional parameters of functions at the end(#104) 2024-05-14 11:22:13 +08:00
haecheonlee b788fd86dc Fix to close remainig popover after deleting table 2024-04-10 19:56:19 -04:00
1ilit 895c1da2b0 Add a setting to resize table width (#21) 2024-04-10 06:47:06 +03:00
1ilit 40800f8f28 Clean up tabs 2024-04-06 04:58:42 +03:00
1ilit 10e0e279cc Remove coords from relationship objects 2024-04-05 03:05:09 +03:00
1ilit 3ec93f42c6 Make variable naming consistent 2024-03-15 16:37:22 +02:00
1ilit 1132edbbb3 Abstract save state from editor 2024-03-15 16:00:23 +02:00
1ilit 697291fe66 Fix setSelectedElement in contexts 2024-03-14 00:27:09 +02:00
1ilit 34f8d9491b Abstract tasks to a context 2024-03-13 21:09:29 +02:00
1ilit 40ef1b057e Remove tab context 2024-03-13 20:39:16 +02:00
1ilit 24eecdc39b Abstract types from editor 2024-03-13 01:27:42 +02:00
1ilit 54c043204a Abstract notes out of editor 2024-03-12 23:38:13 +02:00
1ilit 9e32c49306 Abstract areas 2024-03-11 23:59:04 +02:00
1ilit 680d349380 Abstract controls on fullscreen 2024-03-11 01:50:34 +02:00
1ilit dc8bbc0f9c Abstract tables, undo/redo, selected element 2024-03-10 23:55:23 +02:00
1ilit 23bc6278a2 Abstract TransformContext 2024-03-10 19:25:22 +02:00
1ilit 6c0ebcf7bc Abstract SettingsContext out 2024-03-09 22:39:46 +02:00
1ilit f3eb6d7c04 Separate zoom and pan from settings 2024-03-09 20:35:04 +02:00
1ilit 610e2fa5c5 Abstract LayoutContext 2024-03-09 19:42:09 +02:00