Enable creation of custom linear colormaps in layer controls - #7600
Conversation
|
At a glance, pretty cool! Similar to thoughts I had here: |
|
Thanks for the issue links! Good to know! |
|
@Czaki Your issue relates to labels, while I think this is more similar to the feature of passing hex codes to generate colormaps that was added more recently (0.4.19?). |
|
Whops. I mean to link #1779. That is bigger than this because it also suggests adding of save between sessions. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7600 +/- ##
==========================================
- Coverage 92.87% 92.84% -0.04%
==========================================
Files 629 629
Lines 58900 58973 +73
==========================================
+ Hits 54705 54752 +47
- Misses 4195 4221 +26 ☔ View full report in Codecov by Sentry. |
|
The more important bigger scope from #1779 is the proposal of a custom segmented colormap creation, which I still oppose. However, reading through the comments, we were quite positive about linear colormaps, which this PR implements. And quite minimally, too! 🥳 The only thing I would add to this PR is naming the colormap from the hex value of the picked colour, see e.g. #1779 (comment). |
|
Oh and btw, long time no see @lukasz-migas!!! 👋😊 |
Czaki
left a comment
There was a problem hiding this comment.
I would like to see some test here.
|
This is cool! I have no comment on if it's appropriate for napari but I like it. A few things:
Also wondering how this would interact with #7555 where using QColormapComboBox opens up some possibilities |
|
I made that recording on MacOS and the |
|
While I personally prefer to have native widgets, I think it's probably better to have the same ones across the app.
For reference, here is the cmap catalog of colormaps: |
This already works for me? @lukasz-migas Edit: I don't see any effect of changing alpha (unlike for Points for example), so lets remove that to prevent confusion. |
It at least works for me now! I think this morning I may have been just trying to put it in without '#' first, but cleverly(?) it prevents any input not starting with '#'
What I was thinking about was the editable width of the cmap in the combobox display. I think it would be awkard to try to use |
I disagree here — let's use the native widgets. It's not just a preference, it also works better: I can't use "pick screen color" with the non-native widget: it only allows me to pick from the widget window, not from the full desktop. I've granted screen permission to the app — if I go to d6764cc, I can pick from the screen no problem. |
|
@jni I too prefer the native ones! What about the Points/Shapes? my thought was we do a followup to switch to native widgets everywhere? |
yes, let's do this in follow-ups, not here. @lukasz-migas could you revert 8f01d08? Then hopefully the tests will be green and we can merge! |
This reverts commit 8f01d08.
|
@jni @psobolewskiPhD Done, thanks for the feedback. |
willingc
left a comment
There was a problem hiding this comment.
Hi @lukasz-migas 👋🏼 To be a bit more explicit and add context for future devs, I've suggested some docstring additions. Thanks!
| self.layout().addRow(self.button_grid) | ||
|
|
||
| def _on_make_colormap(self): | ||
| """Make new colormap.""" |
There was a problem hiding this comment.
| """Make new colormap.""" | |
| """Make new colormap when receiving this event.""" |
|
|
||
|
|
||
| class ColorMode(StringEnum): | ||
| """Looping mode for animating an axis. |
There was a problem hiding this comment.
| """Looping mode for animating an axis. | |
| """Represents a color mode, useful for looping mode when animating an axis. |
| color: str | np.ndarray | QColor | None = None, | ||
| mode: ColorMode = ColorMode.HEX, | ||
| ) -> np.ndarray | None: | ||
| """Get color.""" |
There was a problem hiding this comment.
| """Get color.""" | |
| """Get color. Returns a new color when a color and color mode are passed.""" |
|
Thanks @willingc! I tend to forget to do docstrings (and then forget what the function does...) |
willingc
left a comment
There was a problem hiding this comment.
Looks great @lukasz-migas. Thanks for adding context 😄
This fixes a minor layout issue for the image/surface layer controls (which use. the colormapComboBox. I noticed that if the width of the layer controls is changed, the 'colormap' combobox doesn't get resized (because there was a stretch after the control). I should have noticed in #7600 but clearly missed it. before  after  # References and relevant issues # Description
|
This pull request has been mentioned on Image.sc Forum. There might be relevant details there: |


Description
This PR replaces the 'colormap' label (which displays the current colormap) with a push button (which also displays the colormap as before).
When the button is pressed, it will ask the user to select a color using color picker.
If a color was selected, then it creates a new colormap, otherwise nothing happens.
REC-20250212145409.mp4