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

feat(ui): filter/select-object do not exit on save-as #7238

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,22 @@ export abstract class CanvasEntityAdapterBase<
}
this.log.trace(isVisible ? 'Showing' : 'Hiding');
this.konva.layer.visible(isVisible);
if (isVisible) {
/**
* When a layer is created and initially not visible, its compositing rect won't be set up properly. Then, when
* we show it in this method, it the layer will not render as it should.
*
* For example, if an inpaint mask is created via select-object while the isolated layer preview feature is
* enabled, it will be hidden on its first render, and the compositing rect will not be sized/positioned/filled.
* When next show the layer, the its underlying objects will be rendered directly, without the compositing rect
* providing the correct fill.
*
* The simplest way to ensure this doesn't happen is to always update the compositing rect when showing the layer.
*/
this.renderer.updateCompositingRectSize();
this.renderer.updateCompositingRectPosition();
this.renderer.updateCompositingRectFill();
}
this.renderer.syncKonvaCache();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,6 @@ export class CanvasEntityFilterer extends CanvasModuleBase {
default:
assert<Equals<typeof type, never>>(false);
}

// Final cleanup and teardown, returning user to main canvas UI
this.resetEphemeralState();
this.teardown();
};

resetEphemeralState = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,14 @@ export class CanvasEntityObjectRenderer extends CanvasModuleBase {
return;
}

this.log.trace('Updating compositing rect fill');
if (
!this.konva.compositing ||
(this.parent.state.type !== 'inpaint_mask' && this.parent.state.type !== 'regional_guidance')
) {
return;
}

assert(this.konva.compositing, 'Missing compositing rect');
assert(this.parent.state.type === 'inpaint_mask' || this.parent.state.type === 'regional_guidance');
this.log.trace('Updating compositing rect fill');

const fill = this.parent.state.fill;

Expand All @@ -252,9 +256,14 @@ export class CanvasEntityObjectRenderer extends CanvasModuleBase {
return;
}

this.log.trace('Updating compositing rect size');
if (
!this.konva.compositing ||
(this.parent.state.type !== 'inpaint_mask' && this.parent.state.type !== 'regional_guidance')
) {
return;
}

assert(this.konva.compositing, 'Missing compositing rect');
this.log.trace('Updating compositing rect size');

const scale = this.manager.stage.unscale(1);

Expand All @@ -274,9 +283,14 @@ export class CanvasEntityObjectRenderer extends CanvasModuleBase {
return;
}

this.log.trace('Updating compositing rect position');
if (
!this.konva.compositing ||
(this.parent.state.type !== 'inpaint_mask' && this.parent.state.type !== 'regional_guidance')
) {
return;
}

assert(this.konva.compositing, 'Missing compositing rect');
this.log.trace('Updating compositing rect position');

this.konva.compositing.rect.setAttrs({
...this.manager.stage.getScaledStageRect(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,10 +740,6 @@ export class CanvasSegmentAnythingModule extends CanvasModuleBase {
default:
assert<Equals<typeof type, never>>(false);
}

// Final cleanup and teardown, returning user to main canvas UI
this.resetEphemeralState();
this.teardown();
};

/**
Expand Down
Loading