示例#1
0
        unsafe void CopyState(swig.GradientHDRState dst, Data.Value.Gradient.State src)
        {
            dst.SetColorCount(src.ColorMarkers.Length);
            for (int i = 0; i < src.ColorMarkers.Length; i++)
            {
                var color = new swig.ColorF();
                color.R = src.ColorMarkers[i].ColorR;
                color.G = src.ColorMarkers[i].ColorG;
                color.B = src.ColorMarkers[i].ColorB;

                dst.SetColorMarkerPosition(i, src.ColorMarkers[i].Position);
                dst.SetColorMarkerColor(i, color);
                dst.SetColorMarkerIntensity(i, src.ColorMarkers[i].Intensity);
            }

            dst.SetAlphaCount(src.AlphaMarkers.Length);
            for (int i = 0; i < src.AlphaMarkers.Length; i++)
            {
                dst.SetAlphaMarkerPosition(i, src.AlphaMarkers[i].Position);
                dst.SetAlphaMarkerAlpha(i, src.AlphaMarkers[i].Alpha);
            }
        }
示例#2
0
        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;
            }
        }