Example #1
0
        public static UInt32 ToUInt32(this Cairo.Color color)
        {
            byte r, g, b, a;

            color.ToRGBA(out r, out g, out b, out a);
            return(RGBA_to_UInt32(r, g, b, a));
        }
Example #2
0
        Gtk.Widget GenerateButtonsForData(PaletteHeaderData data)
        {
            Gtk.Grid grid = new Gtk.Grid();

            if (data.IsResolvable)
            {
                System.Drawing.Color[][] colors = data.GetPalettes();

                int row = 0;
                int col = 0;

                int numCols = 8; // Reduce this to sort colors into separate rows

                for (int i = 0; i < data.NumPalettes; i++)
                {
                    Gtk.Box box = new Gtk.VBox();

                    for (int j = 0; j < 4; j++)
                    {
                        int paletteIndex = i;
                        int colorIndex   = j;

                        Cairo.Color     color  = CairoHelper.ConvertColor(colors[i][j]);
                        Gtk.ColorButton button = new Gtk.ColorButton(color.ToRGBA());
                        button.ColorSet += (sender, args) => {
                            data.SetColor(paletteIndex, colorIndex, button.Rgba.ToDrawingColor());
                        };
                        box.Add(button);
                    }

                    Gtk.Frame frame = new Gtk.Frame();
                    frame.Label       = (i + data.FirstPalette).ToString();
                    frame.LabelXalign = 0.5f;
                    frame.Add(box);
                    grid.Attach(frame, col, row, 1, 1);
                    col++;
                    if (col == numCols)
                    {
                        col = 0;
                        row++;
                    }
                }
            }

            Gtk.Frame outsideFrame = new Gtk.Frame();
            outsideFrame.Add(grid);
            outsideFrame.Label = data.PointerName
                                 + " [" + (data.PaletteType == PaletteType.Background ? "BG" : "OBJ") + "]";
            outsideFrame.LabelXalign = 0.5f;

            return(outsideFrame);
        }