Ejemplo n.º 1
0
 public ImageScrollButton(string name, int xpos, int ypos, int width, int height, float minVal, float maxVal)
 {
     sliderButton = new ImageButton(name + "_slider", true, xpos, ypos, height, height);
     sliderButton.SetDragAndDrop(true);
     sliderButton.SetDragBoundingBox(xpos, ypos, xpos + width - height, ypos);
     sliderTrack = new ImageButton(name + "_slider_track", false, xpos, ypos, width, height);
     this.initXpos = xpos;
     this.initYpos = ypos;
     this.width = width;
     this.height = height;
     this.maxVal = maxVal;
     this.minVal = minVal;
     sliderTrack.SetBackgroundColor(new Color4(0.2f, 0.2f, 0.2f, 1.0f));
     sliderButton.SetSelectedColor(new Color4(0.5f, 0.5f, 0.5f, 0.5f));
     sliderButton.SetBackgroundColor(new Color4(1.0f, 1.0f, 1.0f, 0.5f));
     labelButton = new ImageTextButton(new Message(name, (int)(height * 0.6f)), false, xpos, ypos, width, height);
     valueButton = new ImageTextButton(new Message("", (int)(height * 0.6f)), false, xpos + width, ypos, width, height);
     labelButton.message.SetColor(new Color4(1.0f, 1.0f, 1.0f, 0.7f));
     sliderButton.AddObserver(this);
     labelButton.update();
     UpdateText();
 }
Ejemplo n.º 2
0
 public bool ProcessMouseButton(bool mouseDown)
 {
     if (Visible)
     {
         lock (this)
         {
             if (mouseDown)
             {
                 if (current != null)
                 {
                     current.SetSelected(true);
                     selected = current;
                     xOffset = xOld - current.xpos;
                     yOffset = yOld - current.ypos;
                     return true;
                 }
             }
             else
             {
                 if (selected != null)
                 {
                     selected.SetSelected(false);
                     selected = null;
                     return true;
                 }
             }
         }
     }
     return false;
 }
Ejemplo n.º 3
0
        public bool ProcessMouseMove(int xpos, int ypos)
        {
            if (Visible)
            {
                xpos = (int)Math.Round(xpos * scaleX);
                ypos = (int)Math.Round(ypos * scaleY);
                lock (this)
                {
                    bool found = false;
                    for (int i = Buttons.Count - 1; i >= 0; i--)
                    {
                        ImageButton button = Buttons[i];
                        if (button.MouseOver(xpos, ypos))
                        {
                            if (current != null)
                            {
                                current.SetRollover(false);
                            }
                            current = button;
                            current.SetRollover(true);
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {

                        if (current != null)
                        {
                            current.SetRollover(false);
                        }
                        current = null;
                    }
                    if (glw != null)
                    {
                        if (current != null)
                        {
                            glw.GLCtrl.Cursor = System.Windows.Forms.Cursors.Hand;
                        }
                        else
                        {
                            glw.GLCtrl.Cursor = System.Windows.Forms.Cursors.Arrow;
                        }
                    }
                    if (selected != null && selected.isDragEnabled())
                    {
                        int2 clamped = selected.ClampPosition(xpos - xOffset, ypos - yOffset);
                        xpos = ypos - clamped.x;
                        ypos = ypos - clamped.y;
                        selected.xpos = clamped.x;
                        selected.ypos = clamped.y;
                    }
                    xOld = xpos;
                    yOld = ypos;
                    return (current != null);
                }
            }
            else
            {
                glw.GLCtrl.Cursor = System.Windows.Forms.Cursors.Arrow;
            }
            xOld = xpos;
            yOld = ypos;
            return false;
        }
Ejemplo n.º 4
0
 public void OnMouseOver(ImageButton button)
 {
 }
Ejemplo n.º 5
0
 public void OnMouseClick(ImageButton button)
 {
     for (int i = 0; i < NUM_CONTROL_PTS; i++)
     {
         if (controlPoints[i] == button)
         {
             colorIndex = i;
             float4 hsv = RGBtoHSV(controlPoints[i].GetForegroundColor());
             hueScroll.SetValue(hsv.x);
             saturationScroll.SetValue(hsv.y);
             valueScroll.SetValue(hsv.z);
             hueScroll.UpdateText();
             saturationScroll.UpdateText();
             valueScroll.UpdateText();
             return;
         }
     }
 }
Ejemplo n.º 6
0
        public ImageColorMixer(int xpos, int ypos, int width, int height)
        {
            this.xpos = xpos;
            this.ypos = ypos;
            this.width = width;
            this.height = height;
            this.scrollWidth = width / 2 - 40;

            this.controlXpos = xpos + scrollWidth + 40;
            hueScroll = new ImageScrollButton("Hue", xpos, ypos, scrollWidth, 20, 0, 1.0f);

            saturationScroll = new ImageScrollButton("Saturation", xpos, ypos + 30, scrollWidth, 20, 0, 1.0f);
            valueScroll = new ImageScrollButton("Brightness", xpos, ypos + 60, scrollWidth, 20, 0, 1.0f);
            hueImage = new CLCalc.Program.Image2D(hueBuffer = new float[scrollWidth * 4], scrollWidth, 1);
            saturationImage = new CLCalc.Program.Image2D(saturationBuffer = new float[scrollWidth * 4], scrollWidth, 1);
            valueImage = new CLCalc.Program.Image2D(valueBuffer = new float[scrollWidth * 4], scrollWidth, 1);
            mixedImage = new CLCalc.Program.Image2D(mixedBuffer = new float[scrollWidth * 4], scrollWidth, 1);
            controlColors = CLCalc.Program.Variable.Create(new ComputeBuffer<float>(CLCalc.Program.Context, ComputeMemoryFlags.ReadWrite, controlColorsBuffer = new float[4 * NUM_CONTROL_PTS]));
            controlAmps = CLCalc.Program.Variable.Create(new ComputeBuffer<float>(CLCalc.Program.Context, ComputeMemoryFlags.ReadWrite, controlAmpsBuffer = new float[NUM_CONTROL_PTS]));
            hueScroll.sliderTrack.SetDynamicImage(hueImage);
            saturationScroll.sliderTrack.SetDynamicImage(saturationImage);
            valueScroll.sliderTrack.SetDynamicImage(valueImage);
            mixedColor = new ImageButton("Mixture", false, controlXpos, ypos + 90, scrollWidth, 20);
            chosenColor = new ImageButton("Chosen", false, xpos, ypos + 90, scrollWidth, 20);
            mixedColor.SetDynamicImage(mixedImage);

            controlPoints = new ImageButton[NUM_CONTROL_PTS];
            stems = new ImageButton[NUM_CONTROL_PTS];
            controlPointsBorder = new ImageButton[NUM_CONTROL_PTS];
            Bitmap bitmap = new Bitmap(20, 20);
            using (Graphics gfx = Graphics.FromImage(bitmap))
            {
                gfx.Clear(Color.FromArgb(0, 0, 0, 0));
                gfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                gfx.FillEllipse(new SolidBrush(Color.White), 1, 1, 17, 17);
            }

            hueScroll.SetValue(0.1f);
            valueScroll.SetValue(0.5f);
            saturationScroll.SetValue(0.5f);
            float4 currentColor = HSVtoRGB(new float4(hueScroll.GetValue(), saturationScroll.GetValue(), valueScroll.GetValue(), 1.0f));
            colorIndex = NUM_CONTROL_PTS / 2;
            for (int i = 0; i < NUM_CONTROL_PTS; i++)
            {
                controlPoints[i] = new ImageButton("control_" + i, bitmap, true, (int)(controlXpos + (i + 0.5f) * (scrollWidth) / (float)NUM_CONTROL_PTS), ypos + ((i == colorIndex) ? 50 : 70), 20, 20);
                controlPointsBorder[i] = new ImageButton("control_" + i, new Bitmap(20, 20), false, (int)(controlXpos + i * (scrollWidth) / (float)NUM_CONTROL_PTS), ypos + 70, 20, 20);
                controlPoints[i].SetDragAndDrop(true);
                controlPoints[i].SetDragBoundingBox(controlXpos - 10, ypos, controlXpos + scrollWidth - 10, ypos + 70);
                stems[i] = new ImageButton("stem_" + i, false, (int)(controlXpos + i * (scrollWidth) / (float)NUM_CONTROL_PTS), 90, 2, 20);
                stems[i].SetBackgroundColor(Color4.White);
                controlPoints[i].SetForegroundColor(HSVtoRGB(new float4(i / (float)(NUM_CONTROL_PTS), saturationScroll.GetValue(), valueScroll.GetValue(), 1.0f)));
                UpdateControlPoint(i);
                controlPoints[i].AddObserver(this);
            }
        }
Ejemplo n.º 7
0
 public void OnMouseClick(ImageButton button)
 {
 }