mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-28 04:54:13 +02:00
85dc638a42
On a dark palette the folio stayed a white sheet with black ink, and the white/gray toggle only darkened the sheet while the ink stayed black. DiagramView now renders each repaint into an image and inverts its lightness before blitting it: white becomes the palette's Base, black becomes its Text, and colored conductors and elements keep their hue. The document, printing and export are untouched; only the screen rendering changes, and only while the palette is dark. QET::Palette::invertLightness does the inversion in one integer pass (adding 255 - max - min to the three channels inverts the HSL lightness and keeps hue and saturation), then stretches the result between the sheet and ink colors through three lookup tables. A 4K viewport costs about 9 ms in a release build. QGraphicsView::render() skips the selection rubber band, so the view draws it again after the inversion. Tests in tst_qetpalette: invertLightnessMapsSheetAndInk, invertedViewReadsOnDarkSheet, invertLightnessSpeed.