-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
feat(V6
): Group Rewrite + Nested Selection
#7669
Conversation
Code Coverage Summary
|
moved to object_origin mixin
Code Coverage Summary
|
Code Coverage Summary
|
This reverts commit 77caa46.
Code Coverage Summary
|
I have dropped old group's caching checks so the issue with caching probably lies there. |
* Remove objects | ||
* @param {...fabric.Object} objects | ||
*/ | ||
remove: function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add relativeRemove
or some name for a function that removes objects without removing the group's transform
if (object.group === this) { | ||
throw new Error('fabric.Group: duplicate objects are not supported inside group'); | ||
} | ||
object.group.remove(object); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I think it makes sense to preserve the old group's transform if removeParentTransform
is true
Alright, |
@asturur I now understand your incline not to have fill/stroke for group. I was not aware of |
Take a look at THIS!The blue circles are rendered by a textbox and because of the rewrite with a few lines of code I got this working This is EXTREMELY exciting because it means that anyone could create custom objects subclassing whatever object they need and have nested selection work out of the box! All you need is to reference the parent object as the Custom classes will become much easier to build |
* force intial layout * minor: refactor layout logic * Update group.class.js
* Update object_geometry.mixin.js * fix(): selection controls connecting lines * Update object.class.js * Update object_geometry.mixin.js * fix(): flipX control * tests * lint * Update control_rendering.js * Update active_selection.class.js * flipX * tests(): flipX * Revert "tests(): flipX" This reverts commit 58e2cd5. * Revert "flipX" This reverts commit 5e129d1.
apart from |
Group Rewrite
This PR has been broken down into #7858 #7859 #7860 and will be left open for tracking only.
This description is updated continuously with relevant information
You don't need to scroll and read endless comments (unless you are a maintainer :))
Motivation
#7473 #7316 #6776 #7136 #7299 #7130 #7142 #7449 and anything with a
group
tagcloses #6499, closes #3012, closes #3000, closes #7130, closes #7142, closes #7598
Nested selection is a MUST.
Group wasn't easy to use and was very limiting (e.g. doesn't support resizing logic, customize rendering - bg) and confusing (relative coordinate system and transform).
Current State
Fixed logic across fabric for nested objects to be selectable.
Selection logic needs refactoring to support some cases of nested selection (multiselect), for now use
canvas.setActiveObject
.Group has been completely rewritten and Layer has been introduced. As part of the rewrite group is now a layout engine, you can use it to customize layout of objects.
Group now respects
originX
originY
(still buggy)BREAKING
addWithUpdate
are removedWorking Examples
POC
Tryouts (out of scope, and stale, here to light the way):
Alpha testing
npm i --save fabricjs/fabric.js#v6! && cd ./node_modules/fabric && npm run build
To Do
dblClick
to select nested objects? create mechanism for dev to customize selection)fabric.js/src/canvas.class.js
Line 422 in 109efe5
preserveObjectStacking
in favor of a drag image/ghostgetLocalPointer
8bf7f92)shouldCache
method.removeAll
insteadgetObjectsBoundingBox
- needs work to exactly fit when group is rotatedoriginX/Y
407023c andangle
groupSVGElements
_renderObjects
- nested active object will fail withperPixelTargetFind
because it will not get rendered by group (add logic tocanvas.isTargetTransparent
)Look
Video is running in original speed
Cutting Edge
The blue circles are rendered by a textbox and because of the rewrite with a few lines of code I got this working
Pay no attention to caching of course
This is EXTREMELY exciting because it means that anyone could create custom objects subclassing whatever object they need and have nested selection work out of the box!