Commit Graph

47 Commits

Author SHA1 Message Date
Felix Zedén Yverås
67851dad8f fix: reduce jitter by disabling pointer events on line 2024-07-17 22:22:52 +02:00
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
Felix Zedén Yverås
cdecf7c633 feat: add basic touchscreen support
This is basically a migration from mouse events to
[pointer events](
  https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events
).

The `PointerEvent` interface inherits all of the `MouseEvent`
properties, meaning that existing code can essentially be left
as-is. The only major change is making sure we only respond to the
"primary" pointer.

Known issues include:
* stylus hover is not detected
* touchscreens do not have a concept of hover, making it difficult
  to e.g. resize areas
* no touch gesture support, e.g. "pinch-to-zoom"
2024-07-14 15:36:54 +02:00
1ilit
9b606114df Rename TablesContext to DiagramContext 2024-07-04 23:18:20 +03:00
1ilit
1d1dde27e7 Crop long types 2024-06-15 22:46:19 +03:00
1ilit
9c820664dc Fix label for cannot connect toast 2024-05-31 17:18:03 +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
1ilit
fc904fb740 Edit relationship on double click (#68) 2024-05-08 04:03:04 +03:00
haecheonlee
c0437b5433 Open note in tab after clicking edit button 2024-04-14 17:28:18 -04:00
1ilit
9efee285c8 Fix subject area title overflow 2024-04-14 10:28:08 +03:00
1ilit
e3f3f9d5bd Fix note title overflow 2024-04-14 10:26:31 +03:00
1ilit
598f41fed2 Remove inline styling 2024-04-14 10:23:02 +03:00
1ilit
f4f55faf2b Merge commit 'refs/pull/47/head' of https://github.com/drawdb-io/drawdb 2024-04-14 10:13:23 +03:00
1ilit
527f335f68 Merge commit 'refs/pull/46/head' of https://github.com/drawdb-io/drawdb 2024-04-14 10:05:34 +03:00
1ilit
2ac0f047a1 Merge commit 'refs/pull/35/head' of https://github.com/drawdb-io/drawdb 2024-04-14 09:59:25 +03:00
haecheonlee
cc32ffdd80 Fix rendering area in safari 2024-04-13 20:30:56 -04:00
haecheonlee
5b6c34d9aa Fix button in note rendering in safari 2024-04-13 19:31:29 -04:00
santilapi13
0797a3fd7a fix: set field comment width instead of popover width 2024-04-11 23:30:40 -03:00
Santiago N. Lapiana
6580a40017
Merge branch 'drawdb-io:main' into popovers_comments 2024-04-11 22:46:47 -03:00
1ilit
9faf99d9d7 Remove magic numbers in table height calculations 2024-04-12 04:24:19 +03:00
ClaPalo
99cee1c104 Reintroduced opacity using RGBA 2024-04-11 20:08:05 -05:00
haecheonlee
eadcff091a Fix class name evaluated by short circuit 2024-04-11 20:11:33 -04:00
ClaPalo
3509286426 Fixed field circle icons not moving in Safari 2024-04-11 19:09:19 -05:00
santilapi13
dd57df8bc2 fix: comment visualization in table and fields popovers 2024-04-11 19:15:28 -03:00
1ilit
2740aeeb9f
Merge pull request #29 from HaecheonLee/bug/fix-remaining-popover-after-deleting-table
Fix to close remainig popover after deleting table
2024-04-11 07:30:17 +03:00
haecheonlee
b788fd86dc Fix to close remainig popover after deleting table 2024-04-10 19:56:19 -04:00
Gautam krishna R
7023b2e611
added double click to open editor 2024-04-10 09:15:48 +00:00
1ilit
895c1da2b0 Add a setting to resize table width (#21) 2024-04-10 06:47:06 +03:00
1ilit
6ab13a70d2 Fix form label color in sidesheet for editing a table 2024-04-10 05:22:10 +03:00
1ilit
21ed333f7d Fix panning when the sidesheet for editing a table is open 2024-04-10 05:12:39 +03:00
1ilit
155810d7e6 Fix typo 2024-04-06 10:27:18 +03:00
1ilit
1efd72dfe3 Use ColorPallete in area popover 2024-04-06 09:56:20 +03:00
1ilit
234d4fc04b Remove duplicate logic to edit table 2024-04-06 09:51:38 +03:00
1ilit
40800f8f28 Clean up tabs 2024-04-06 04:58:42 +03:00
1ilit
afa8fca00c Fix import 2024-04-05 06:32:35 +03:00
1ilit
8cf95a9a06 Fix imports for hooks 2024-04-05 05:12:50 +03:00
1ilit
10e0e279cc Remove coords from relationship objects 2024-04-05 03:05:09 +03:00
1ilit
ee44cd2b7c Fix table names taking half of the table width when not hovered 2024-04-02 16:05:07 +03:00
1ilit
4d7f18c26e Removed isHovered from Table 2024-04-02 03:38:58 +03:00
1ilit
6fda5356b0 Add primary key icon to fields 2024-04-02 00:22:07 +03:00
1ilit
d9fa03ae01 Fix table name overflow 2024-04-01 20:57:13 +03:00
1ilit
19ca8a55c2 Fix field name overflow 2024-04-01 20:31:24 +03:00
1ilit
9df9527950 Reorganize files 2024-04-01 19:44:50 +03:00