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

Selecting a cell hides its background color/image #178

Open
jpd236 opened this issue Jan 12, 2022 · 2 comments
Open

Selecting a cell hides its background color/image #178

jpd236 opened this issue Jan 12, 2022 · 2 comments

Comments

@jpd236
Copy link
Contributor

jpd236 commented Jan 12, 2022

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
Copy link
Contributor Author

jpd236 commented Jan 24, 2022

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:

  • For background images, reorder the drawing so these are drawn above the background color, while keeping them below the outline. EDIT: I guess only works if the images are transparent, which almost certainly won't always be the case
  • For colors, if we're drawing a selected cell that already has its own background color, manually calculate a blended version of those colors and use that as the highlight instead.

@mrichards42
Copy link
Owner

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

  • There's sort of an existing convention of drawing the highlight as a thick border in some cases (rebus, diagramless black squares). That might work, but it might also make it look too much like entering a rebus :)
  • Could do something like hatching, or a fine pattern overlay (like a bayer dithering matrix). Puzzleme uses very coarse hatching if you're playing a partner crossword and the two cursors intersect (it's a bit too aggressive IMO, but that's one way someone else is solving this problem).
  • The manually calculated background sounds promising and I'd guess covers the 80% case, which is a good start.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants