Skip to content

Commit

Permalink
feat: setSize triggers WindowResizeEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
floryst committed Oct 26, 2023
1 parent fae07e4 commit 1435f51
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
15 changes: 9 additions & 6 deletions Sources/Rendering/OpenGL/RenderWindow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,15 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
model.activeFramebuffer = newActiveFramebuffer;
};

const superSetSize = publicAPI.setSize;
publicAPI.setSize = (width, height) => {
const modified = superSetSize(width, height);
if (modified) {
publicAPI.invokeWindowResizeEvent({ width, height });
}
return modified;
};

publicAPI.getGraphicsResourceForObject = (vtkObj) => {
if (!vtkObj) {
return null;
Expand Down Expand Up @@ -1360,12 +1369,6 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
glRen?.releaseGraphicsResources();
});
};

model._onSizeChanged = (_publicAPI, _model, newValue) =>
publicAPI.invokeWindowResizeEvent({
width: newValue[0],
height: newValue[1],
});
}

// ----------------------------------------------------------------------------
Expand Down
14 changes: 9 additions & 5 deletions Sources/Rendering/WebGPU/RenderWindow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,12 +543,16 @@ function vtkWebGPURenderWindow(publicAPI, model) {
return ret;
};

const superSetSize = publicAPI.setSize;
publicAPI.setSize = (width, height) => {
const modified = superSetSize(width, height);
if (modified) {
publicAPI.invokeWindowResizeEvent({ width, height });
}
return modified;
};

publicAPI.delete = macro.chain(publicAPI.delete, publicAPI.setViewStream);
model._onSizeChanged = (_publicAPI, _model, newValue) =>
publicAPI.invokeWindowResizeEvent({
width: newValue[0],
height: newValue[1],
});
}

// ----------------------------------------------------------------------------
Expand Down

0 comments on commit 1435f51

Please sign in to comment.