Commit 667d309
authored
Fix overwriting of alpha values in Viewer colorpicker (#2404)
Currently, if an user uses the MaterialXView colorpicker for a `Color4` field, the alpha component is automatically overwritten and transformed to a value of 1, regardless of original value. Although it is shown unmodified in the UI, if written out to file, the alpha component is always "1". e.g.
```
<input name="bias" type="color4" value="0.0908109, 0.0908109, 0.0908109, 1" />
```
This is because the Nanogui `ColorWheel` class does not handle color values with 4 components, yet the Nanogui `ColorPicker` class refers to its color wheel member to set the new picked color ([code ref](https://github.com/mitsuba-renderer/nanogui/blob/6452dd6944d2ba5c0c9bc0042a1894f703ce1ace/src/colorpicker.cpp#L58-L65)).
To prevent this from happening, I modified the current `class EditorColorPicker : public ng::ColorPicker`, and created custom callbacks for `m_color_wheel` and `m_pick_button`. The logic essentially is -- since we have additional color widget members in our color picker, we instead refer to their values when setting the color value. Then, the alpha component can only be changed via the color widgets, so interacting with the color wheel does not change / overwrite the original alpha component.1 parent 656a7f6 commit 667d309
1 file changed
Lines changed: 28 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
52 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
53 | 77 | | |
54 | 78 | | |
55 | 79 | | |
56 | 80 | | |
57 | 81 | | |
| 82 | + | |
58 | 83 | | |
59 | 84 | | |
60 | 85 | | |
| |||
374 | 399 | | |
375 | 400 | | |
376 | 401 | | |
377 | | - | |
| 402 | + | |
378 | 403 | | |
379 | 404 | | |
380 | 405 | | |
| |||
0 commit comments