mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2025-01-11 15:45:38 +00:00
commit
c7657fcab4
|
@ -30,7 +30,6 @@ namespace GtkDemo
|
||||||
vbox.PackStart (frame, true, true, 0);
|
vbox.PackStart (frame, true, true, 0);
|
||||||
|
|
||||||
drawingArea = new DrawingArea ();
|
drawingArea = new DrawingArea ();
|
||||||
drawingArea.Drawn += new DrawnHandler (DrawnCallback);
|
|
||||||
// set a minimum size
|
// set a minimum size
|
||||||
drawingArea.SetSizeRequest (200,200);
|
drawingArea.SetSizeRequest (200,200);
|
||||||
// set the color
|
// set the color
|
||||||
|
@ -56,18 +55,6 @@ namespace GtkDemo
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drawn callback for the drawing area
|
|
||||||
private void DrawnCallback (object o, DrawnArgs args)
|
|
||||||
{
|
|
||||||
Cairo.Context cr = args.Cr;
|
|
||||||
|
|
||||||
Gdk.RGBA rgba = StyleContext.GetBackgroundColor (StateFlags.Normal);
|
|
||||||
cr.SetSourceRGBA (rgba.Red, rgba.Green, rgba.Blue, rgba.Alpha);
|
|
||||||
cr.Paint ();
|
|
||||||
|
|
||||||
args.RetVal = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ChangeColorCallback (object o, EventArgs args)
|
private void ChangeColorCallback (object o, EventArgs args)
|
||||||
{
|
{
|
||||||
using (ColorSelectionDialog colorSelectionDialog = new ColorSelectionDialog ("Changing color")) {
|
using (ColorSelectionDialog colorSelectionDialog = new ColorSelectionDialog ("Changing color")) {
|
||||||
|
@ -77,8 +64,8 @@ namespace GtkDemo
|
||||||
colorSelectionDialog.ColorSelection.HasPalette = true;
|
colorSelectionDialog.ColorSelection.HasPalette = true;
|
||||||
|
|
||||||
if (colorSelectionDialog.Run () == (int) ResponseType.Ok) {
|
if (colorSelectionDialog.Run () == (int) ResponseType.Ok) {
|
||||||
Gdk.RGBA selected = colorSelectionDialog.ColorSelection.CurrentRgba;
|
color = colorSelectionDialog.ColorSelection.CurrentRgba;
|
||||||
drawingArea.OverrideBackgroundColor (StateFlags.Normal, selected);
|
drawingArea.OverrideBackgroundColor (StateFlags.Normal, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
colorSelectionDialog.Hide ();
|
colorSelectionDialog.Hide ();
|
||||||
|
|
|
@ -112,6 +112,7 @@ namespace GtkDemo
|
||||||
cr.SetSourceRGB (1, 1, 1);
|
cr.SetSourceRGB (1, 1, 1);
|
||||||
// If we're outside the clip, this will do nothing.
|
// If we're outside the clip, this will do nothing.
|
||||||
cr.Rectangle (i, j, CheckSize, CheckSize);
|
cr.Rectangle (i, j, CheckSize, CheckSize);
|
||||||
|
cr.Fill ();
|
||||||
|
|
||||||
j += CheckSize + Spacing;
|
j += CheckSize + Spacing;
|
||||||
++ycount;
|
++ycount;
|
||||||
|
@ -146,6 +147,7 @@ namespace GtkDemo
|
||||||
surface = widget.Window.CreateSimilarSurface (Cairo.Content.Color, allocation.Width, allocation.Height);
|
surface = widget.Window.CreateSimilarSurface (Cairo.Content.Color, allocation.Width, allocation.Height);
|
||||||
var cr = new Cairo.Context (surface);
|
var cr = new Cairo.Context (surface);
|
||||||
|
|
||||||
|
cr.SetSourceRGB (1, 1, 1);
|
||||||
cr.Paint ();
|
cr.Paint ();
|
||||||
((IDisposable)cr).Dispose ();
|
((IDisposable)cr).Dispose ();
|
||||||
|
|
||||||
|
@ -186,8 +188,8 @@ namespace GtkDemo
|
||||||
var update_rect = new Gdk.Rectangle ((int)x - 3, (int)y - 3, 6, 6);
|
var update_rect = new Gdk.Rectangle ((int)x - 3, (int)y - 3, 6, 6);
|
||||||
var cr = new Cairo.Context (surface);
|
var cr = new Cairo.Context (surface);
|
||||||
|
|
||||||
cr.Fill ();
|
|
||||||
Gdk.CairoHelper.Rectangle (cr, update_rect);
|
Gdk.CairoHelper.Rectangle (cr, update_rect);
|
||||||
|
cr.Fill ();
|
||||||
|
|
||||||
((IDisposable)cr).Dispose ();
|
((IDisposable)cr).Dispose ();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue