jupytercad / JupyterCAD

A JupyterLab extension for collaborative 3D geometry modeling
https://jupytercad.github.io/JupyterCAD
BSD 3-Clause "New" or "Revised" License
139 stars 18 forks source link

Fix handling of theme change #505

Closed arjxn-py closed 1 month ago

arjxn-py commented 1 month ago

https://github.com/user-attachments/assets/d24c193a-874e-4d65-8d63-5adf7e30e738

Shall close #480

github-actions[bot] commented 1 month ago

Preview PR at appsharing.space

github-actions[bot] commented 1 month ago

Integration tests repot: appsharing.space

SylvainCorlay commented 1 month ago

A full resize event would trigger a complete reflow of the page. Maybe just doing it on the view would be more economical.

Also, is the resize the only thing that triggers a redraw of the view?

arjxn-py commented 1 month ago

Also, is the resize the only thing that triggers a redraw of the view?

That sounds good, thanks @SylvainCorlay. I at the moment can't think of any other way but I'm happy to discuss and iterate over it.

SylvainCorlay commented 1 month ago

Just calling update() on the Lumino panel of the 3-D view should do it. People more familiar with Lumino on the team will know the proper way to do.

trungleduc commented 1 month ago

you can use MessageLoop.sendMessage to send the Widget.ResizeMessage message to the 3D view widget.

https://github.com/jupytercad/JupyterCAD/blob/7e6b49b8be3948b9b0dd24aa2db6fc4414ea7f0c/packages/base/src/panelview/formbuilder.tsx#L37

arjxn-py commented 1 month ago

you can use MessageLoop.sendMessage to send the Widget.ResizeMessage message to the 3D view widget.

https://github.com/jupytercad/JupyterCAD/blob/7e6b49b8be3948b9b0dd24aa2db6fc4414ea7f0c/packages/base/src/panelview/formbuilder.tsx#L37

@trungleduc When i try MessageLoop.sendMessage in model.ts it says

Property 'sendMessage' does not exist on type 
'typeof import("/Users/arjunverma/Desktop/Arjun/JupyterCAD/node_modules/@lumino/messaging/types/index")'

but the same works in formbuilder.tsx

martinRenou commented 1 month ago

My 2 cents, we used to depend on the lightTheme attribute in the React component state to change the background color according to it: https://github.com/jupytercad/JupyterCAD/blob/main/packages/base/src/3dview/mainview.tsx#L1444

This seems to not be used anymore! So we should probably remove lightTheme from the state, but we should probably modify this _handleThemeChange method there to force a this.update() of the react component to trigger a re-render, instead of setting that old unused state attribute.