Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING(): Brush onMouseDown onMouseMove onMouseUp signature #9501

Closed
wants to merge 5 commits into from

Conversation

ShaMan123
Copy link
Contributor

@ShaMan123 ShaMan123 commented Nov 19, 2023

Motivation

continues #9175

Description

#9175 forgot about brush API
onMouseDown and onMouseMove use a scene point named pointer.
In order to fix this name conflict I decided to break the signature taking the opportunity to provide a better API while needing to break so the dev is aware of the change.

Changes

  • Brush API signature changes
    • onMouseDown(pointer, { e, pointer }) => onMouseDown({ e, scenePoint, viewportPoint })
    • onMouseMove(pointer, { e, pointer }) => onMouseMove({ e, scenePoint, viewportPoint })
    • onMouseUp({ e, pointer }) => onMouseUp({ e, scenePoint, viewportPoint })
  • rm onMouse(Down|Move|Up)InDrawingMode => move the bits of logic to BaseBrush:
    • onMouseDownInDrawingMode => expose enterDrawingMode to discard active object
    • onMouseMoveInDrawingMode => set cursor under onMouseMove
  • dep freeDrawingCursor in favor of BaseBrush#cursor, still respecting freeDrawingCursor

Gist

In Action

@ShaMan123 ShaMan123 requested a review from asturur November 19, 2023 13:51
Copy link
Contributor

github-actions bot commented Nov 19, 2023

Build Stats

file / KB (diff) bundled minified
fabric 904.267 (-0.241) 304.103 (+0.113)

ShaMan123 and others added 2 commits November 19, 2023 16:04
dep freeDrawingCursor in favor od BaseBrush#cursor
expose `enterDrawingMode`
Update freedraw.js
Copy link
Contributor Author

@ShaMan123 ShaMan123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks stable

Copy link
Contributor

Coverage after merging brush-pointer into master will be

82.74%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
index.node.ts7.69%100%0%14.29%17, 20, 23, 35, 38, 41
src
   ClassRegistry.ts100%100%100%100%
   Collection.ts94.85%94.83%87.10%97.14%109, 112, 215–216, 241–242
   CommonMethods.ts96.55%87.50%100%100%9
   Intersection.ts100%100%100%100%
   Observable.ts87.76%85.29%87.50%89.58%134–135, 160–161, 32–33, 41, 50, 78, 89
   Point.ts100%100%100%100%
   Shadow.ts98.36%95.65%100%100%178
   cache.ts97.06%90%100%100%57
   config.ts75%66.67%66.67%82.76%130, 138, 138, 138, 138, 138–140, 151–153
   constants.ts100%100%100%100%
src/Pattern
   Pattern.ts92.31%91.89%90%93.55%119, 130, 139, 32, 95
src/brushes
   BaseBrush.ts88.24%83.33%88.89%90.24%81–82, 82, 82–84, 93
   CircleBrush.ts0%0%0%0%105, 105, 105, 107, 109, 111–113, 115–118, 125–126, 13, 133, 135, 23–24, 32–36, 40–44, 47–51, 59–63, 65, 69–70, 70, 70–71, 71, 74, 77, 79, 79, 79–82, 84, 89–90, 92, 94–96
   PatternBrush.ts97.06%87.50%100%100%21
   PencilBrush.ts91.11%82.35%100%93.86%122–123, 152, 152–154, 176, 176, 276, 280, 285–286, 65–66, 79–80
   SprayBrush.ts0%0%0%0%100, 100, 100–101, 101, 104, 107–109, 113–114, 116, 118–122, 131, 135–136, 136, 144, 144, 144–147, 149–152, 156–157, 159, 161–164, 167, 17, 174–175, 177, 179, 18, 180, 182, 189–190, 192–193, 196, 196, 20, 203, 203, 207, 21–22, 22, 22–24, 28, 32, 39, 46, 53, 60, 67, 84–86, 89–92, 94–95, 99
src/canvas
   Canvas.ts79.86%76.83%85.96%81.19%1000–1002, 1002, 1002–1003, 1005–1006, 1009–1010, 1014–1015, 1138–1139, 1139, 1139, 1139, 1139, 1139, 1139, 1142–1143, 1146–1147, 1220, 1333, 1455, 172, 197, 24–26, 297, 297–302, 307, 330–331, 336–341, 361, 361, 361–362, 362, 362–363, 371, 376–377, 377, 377–378, 380, 389, 395–396, 396, 396, 439, 447, 451, 451, 451–452, 454, 535–536, 536, 536–537, 543, 543, 543–545, 56, 565, 567, 567, 567–568, 568, 568, 571, 571, 571–572, 575, 584–585, 587–588, 590, 590–591, 593–594, 60, 606–607, 607, 607–608, 610–615, 621, 628, 665, 665, 665, 667, 669–674, 680, 686, 686, 686–687, 689, 692, 697, 710, 738, 790–791, 791, 791, 791, 791, 791, 794–795, 798, 798–799, 799, 799, 802–803, 806–807, 889, 896, 896, 896, 909, 941, 962–963, 999, 999
   CanvasOptions.ts100%100%100%100%
   SelectableCanvas.ts93.21%91.60%94.44%94.22%1016, 1024, 1143, 1145, 1147–1148, 305, 475–476, 478–479, 479, 479, 528–529, 590–591, 604, 644–646, 678, 683–684, 711–712, 772–773, 778–782, 784, 943, 943–944, 947, 967, 967
   StaticCanvas.ts96.78%93.09%100%98.53%1019, 1029, 1081–1082, 1085, 1120–1121, 1197, 1206, 1206, 1210, 1210, 1257–1258, 178–179, 195, 559, 571–572, 902–903, 903, 903–904
   StaticCanvasOptions.ts100%100%100%100%
   TextEditingManager.ts89.58%83.33%91.67%91.67%16–17, 17, 17
src/canvas/DOMManagers
   CanvasDOMManager.ts95.52%70%100%100%21–22, 29
   StaticCanvasDOMManager.ts97.50%88.89%100%100%33
   util.ts86.67%80.56%83.33%93.94%14, 26, 63–64, 67, 67, 74, 93–94
src/color
   Color.ts94.96%91.67%96.30%96.05%233, 258–259, 267–268, 48
   color_map.ts100%100%100%100%
   constants.ts100%100%100%100%
   util.ts85.71%76.92%100%89.74%55–56, 56, 58, 58, 58–59, 61–62, 89
src/controls
   Control.ts94.44%93.10%91.67%96.77%183, 249, 354
   changeWidth.ts100%100%100%100%
   commonControls.ts100%100%100%100%
   controlRendering.ts81.63%78%100%84.78%106, 111, 121, 121, 45, 50, 61, 61, 65–72, 81–82
   drag.ts100%100%100%100%
   fireEvent.ts88.89%75%100%100%13
   polyControl.ts7.25%0%0%13.51%103, 108, 120, 120, 120, 120, 120, 122–125, 125, 128, 135, 17, 25–29, 29, 29, 29, 29, 29, 29, 29, 50–56, 56, 56, 56, 56, 58, 63–64, 66, 76, 82–84, 84, 86, 89–90, 90, 90, 90, 90, 92, 97
   rotate.ts19.57%12.50%50%21.43%41, 45, 51, 51, 51–52, 55–57, 59, 59, 59, 59, 59–61, 61, 61–63, 65, 65, 65–67, 67, 67–68, 73, 73, 73–74, 76, 78, 80–81
   scale.ts93.57%92.94%100%93.67%129–130, 132–134, 148–149, 181–183, 42
   scaleSkew.ts78.79%64.29%100%85.71%27, 29, 29, 29, 31, 33, 35
   skew.ts91.03%79.31%100%97.67%131–132, 163–164, 171, 177, 179
   util.ts100%100%100%100%
   wrapWithFireEvent.ts100%100%100%100%</

@ShaMan123 ShaMan123 closed this May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant