Skip to content

Allow Highlighter to restore previous colors for any style, not just select #755

@MarcinKoziuk

Description

@MarcinKoziuk

Description 📝

As you can see in the video, I use a cyan highlight style as a preview for what’s being selected. That works great, as long as the model uses original colors.

However, if a model is already colored with OBF.Highlighter (e.g. to color items by level or type), then the previously applied custom color will be lost. From what I can see, restorePreviousColors only runs for the "select" style, so any other style defined doesn't get restored.

This seems like a noticeable limitation in OBF.Highlighter. Are there ideas on how best to solve it? We'd be happy to help out with the changes (e.g. a pull request), if that's something accepted. Or is there another/better pattern for doing temporary previews like this that we're missing?

Multi-Highlight.mp4

Suggested solution 💡

Generalize the style restoration so it works for any style. Probably this means some extra bookkeeping on the order styles were applied.

Alternative ⛕

Thoughts on better ways of using styles

  • Perhaps the styles should be applied more in a declarative instead of imperative way
  • Give each style a priority value so that when multiple styles apply to the same item, the highest-priority one wins

Current workaround

  • Manually reapplying the previous styles after clearing the preview
    • this does mean that wrong colors are shown briefly

Additional context ☝️

This issue came up while building box-selection in an IFC widget for the low-code app platform https://wistor.nl

You can find a working repo of it here:
https://github.com/MarcinKoziuk/ThatOpen-demos

Validations ✅

  • Read the docs.
  • Check that there isn't already an issue that requests the same feature to avoid creating a duplicate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureSomething new that we could do

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions