unsafe void CopyState(Data.Value.Gradient.State dst, swig.GradientHDRState src) { dst.ColorMarkers = new Data.Value.Gradient.ColorMarker[src.GetColorCount()]; dst.AlphaMarkers = new Data.Value.Gradient.AlphaMarker[src.GetAlphaCount()]; for (int i = 0; i < src.GetColorCount(); i++) { var color = src.GetColorMarkerColor(i); dst.ColorMarkers[i].ColorR = color.R; dst.ColorMarkers[i].ColorG = color.G; dst.ColorMarkers[i].ColorB = color.B; dst.ColorMarkers[i].Position = src.GetColorMarkerPosition(i); dst.ColorMarkers[i].Intensity = src.GetColorMarkerIntensity(i); } for (int i = 0; i < src.GetAlphaCount(); i++) { dst.AlphaMarkers[i].Alpha = src.GetAlphaMarkerAlpha(i); dst.AlphaMarkers[i].Position = src.GetAlphaMarkerPosition(i); } }
void Popup() { if (isPopupShown) { return; } if (Manager.NativeManager.BeginPopup(id_c, swig.WindowFlags.AlwaysAutoResize)) { Manager.NativeManager.Dummy(new swig.Vector2I(200, 1)); if (Manager.NativeManager.GradientHDR(id_popup, internalState, guiPopupState)) { StoreValue(); } var selectedIndex = guiPopupState.GetSelectedIndex(); if (selectedIndex >= 0) { if (guiPopupState.GetSelectedMarkerType() == swig.GradientHDRMarkerType.Color) { var color = internalState.GetColorMarkerColor(selectedIndex); var intensity = internalState.GetColorMarkerIntensity(selectedIndex); var colors = new float[] { color.R, color.G, color.B, 1.0f }; if (Manager.NativeManager.ColorEdit4("Color" + id_color, colors, swig.ColorEditFlags.NoAlpha)) { color.R = colors[0]; color.G = colors[1]; color.B = colors[2]; internalState.SetColorMarkerColor(selectedIndex, color); StoreValue(); } var intensityArray = new float[1]; intensityArray[0] = intensity; if (Manager.NativeManager.DragFloat("Intensity" + id_intensity, intensityArray, 0.1f, 0.0f, float.MaxValue)) { intensity = intensityArray[0]; internalState.SetColorMarkerIntensity(selectedIndex, intensity); StoreValue(); } } else if (guiPopupState.GetSelectedMarkerType() == swig.GradientHDRMarkerType.Alpha) { var alpha = internalState.GetAlphaMarkerAlpha(selectedIndex); var alphaArray = new float[1]; alphaArray[0] = alpha; if (Manager.NativeManager.DragFloat("Alpha" + id_alpha, alphaArray, 0.1f, 0.0f, 1.0f)) { alpha = alphaArray[0]; internalState.SetAlphaMarkerAlpha(selectedIndex, alpha); StoreValue(); } } if (Manager.NativeManager.Button("Delete")) { var selectedType = guiPopupState.GetSelectedMarkerType(); if (selectedType == swig.GradientHDRMarkerType.Color) { if (internalState.RemoveColorMarker(selectedIndex)) { StoreValue(); } } else if (selectedType == swig.GradientHDRMarkerType.Alpha) { if (internalState.RemoveAlphaMarker(selectedIndex)) { StoreValue(); } } } } Manager.NativeManager.EndPopup(); isPopupShown = true; } }