mrichards42 / xword

Cross-platform crossword solving
https://mrichards42.github.io/xword/
GNU General Public License v3.0
42 stars 13 forks source link

Selecting a cell hides its background color/image #178

Open jpd236 opened 2 years ago

jpd236 commented 2 years ago

When a cell with a background color or image is selected, the selection color takes full precedent over the background, hiding it completely. This can make it more challenging to solve these puzzles, especially in cases where the background is thematic rather than just for contrast.

Maybe it would work better to draw the selection color with some amount of transparency so background images still appear and so shaded squares are tinted differently and stand out a bit more.

jpd236 commented 2 years ago

Unfortunately, this looks like it might be a bit tricky. The obvious solution (to me at least) is to draw the highlight color with some transparency. This requires enabling XWORD_USE_GC and using wxGraphicsContext since the regular DC doesn't support transparency here. But this context seems significantly slower, at least on my machine + w/ alpha transparency, and lags behind my keyboard input somewhat. It's also tricky to get the colors to line up - for example, we want to draw the text with the same background color as the cell, but now that color is alpha blended, which means doing so will apply alpha a second time and won't match exactly. Maybe you could erase the rectangle from the selection first before drawing the text... but it gets messy.

I wonder if it might be feasible to do something like:

mrichards42 commented 2 years ago

Hmm, yeah that would be nice to fix. A number of thoughts come to mind as alternatives to transparency:

Maybe some combination where either a manually blended or simple pattern overlay is used for colored cells, and something else for images? Potentially even using GCDC to alpha blend images since there are probably fewer of those in a row?