Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialization of object properties is made in initialization block #320

Merged
merged 2 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Pinta.Core/Actions/ImageActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,10 @@ static void CropImageToRectangle (Document doc, RectangleI rect, Path? selection
if (rect.Width <= 0 || rect.Height <= 0)
return;

ResizeHistoryItem hist = new ResizeHistoryItem (doc.ImageSize);

hist.Icon = Resources.Icons.ImageCrop;
hist.Text = Translations.GetString ("Crop to Selection");
ResizeHistoryItem hist = new ResizeHistoryItem (doc.ImageSize) {
Icon = Resources.Icons.ImageCrop,
Text = Translations.GetString ("Crop to Selection")
};
hist.StartSnapshotOfImage ();
hist.RestoreSelection = doc.Selection.Clone ();

Expand Down
12 changes: 6 additions & 6 deletions Pinta.Core/Classes/AsyncEffectRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ void StartRender ()
HandleRenderCompletion ();
return false; // don't call the timer again
});
});

master.Priority = settings.ThreadPriority;
}) {
Priority = settings.ThreadPriority
};
master.Start ();

// Start timer used to periodically fire update events on the UI thread.
Expand All @@ -214,9 +214,9 @@ Thread StartSlaveThread (int renderId, int threadId)
{
var slave = new Thread (() => {
Render (renderId, threadId);
});

slave.Priority = settings.ThreadPriority;
}) {
Priority = settings.ThreadPriority
};
slave.Start ();

return slave;
Expand Down
7 changes: 4 additions & 3 deletions Pinta.Core/Classes/Document.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,10 @@ public void ResizeCanvas (int width, int height, Anchor anchor, CompoundHistoryI

PintaCore.Tools.Commit ();

ResizeHistoryItem hist = new ResizeHistoryItem (ImageSize);
hist.Icon = Resources.Icons.ImageResizeCanvas;
hist.Text = Translations.GetString ("Resize Canvas");
ResizeHistoryItem hist = new ResizeHistoryItem (ImageSize) {
Icon = Resources.Icons.ImageResizeCanvas,
Text = Translations.GetString ("Resize Canvas")
};
hist.StartSnapshotOfImage ();

scale = Workspace.Scale;
Expand Down
34 changes: 18 additions & 16 deletions Pinta.Core/Effects/ColorBgra.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ public readonly ColorBgra NewAlpha (byte newA)
/// </summary>
public static ColorBgra FromBgra (byte b, byte g, byte r, byte a)
{
ColorBgra color = new ColorBgra ();
color.Bgra = BgraToUInt32 (b, g, r, a);
ColorBgra color = new ColorBgra {
Bgra = BgraToUInt32 (b, g, r, a)
};
return color;
}

Expand Down Expand Up @@ -259,8 +260,9 @@ public static ColorBgra FromBgr (byte b, byte g, byte r)
/// </summary>
public static ColorBgra FromUInt32 (UInt32 bgra)
{
ColorBgra color = new ColorBgra ();
color.Bgra = bgra;
ColorBgra color = new ColorBgra {
Bgra = bgra
};
return color;
}

Expand Down Expand Up @@ -313,12 +315,12 @@ public static ColorBgra Blend (ColorBgra ca, ColorBgra cb, byte cbAlpha)
/// </remarks>
public static ColorBgra Lerp (ColorBgra from, ColorBgra to, float frac)
{
ColorBgra ret = new ColorBgra ();

ret.B = (byte) ClampToByte (Lerp (from.B, to.B, frac));
ret.G = (byte) ClampToByte (Lerp (from.G, to.G, frac));
ret.R = (byte) ClampToByte (Lerp (from.R, to.R, frac));
ret.A = (byte) ClampToByte (Lerp (from.A, to.A, frac));
ColorBgra ret = new ColorBgra {
B = (byte) ClampToByte (Lerp (from.B, to.B, frac)),
G = (byte) ClampToByte (Lerp (from.G, to.G, frac)),
R = (byte) ClampToByte (Lerp (from.R, to.R, frac)),
A = (byte) ClampToByte (Lerp (from.A, to.A, frac))
};

return ret;
}
Expand All @@ -343,12 +345,12 @@ public static double Lerp (double from, double to, double frac)
/// </remarks>
public static ColorBgra Lerp (ColorBgra from, ColorBgra to, double frac)
{
ColorBgra ret = new ColorBgra ();

ret.B = (byte) ClampToByte (Lerp (from.B, to.B, frac));
ret.G = (byte) ClampToByte (Lerp (from.G, to.G, frac));
ret.R = (byte) ClampToByte (Lerp (from.R, to.R, frac));
ret.A = (byte) ClampToByte (Lerp (from.A, to.A, frac));
ColorBgra ret = new ColorBgra {
B = (byte) ClampToByte (Lerp (from.B, to.B, frac)),
G = (byte) ClampToByte (Lerp (from.G, to.G, frac)),
R = (byte) ClampToByte (Lerp (from.R, to.R, frac)),
A = (byte) ClampToByte (Lerp (from.A, to.A, frac))
};

return ret;
}
Expand Down
10 changes: 5 additions & 5 deletions Pinta.Core/Effects/UnaryPixelOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -686,11 +686,11 @@ public void UnApply (ColorBgra after, float[] beforeOut, float[] slopesOut)

public object Clone ()
{
Level copy = new Level (color_in_low, color_in_high, (float[]) gamma.Clone (), color_out_low, color_out_high);

copy.CurveB = (byte[]) this.CurveB.Clone ();
copy.CurveG = (byte[]) this.CurveG.Clone ();
copy.CurveR = (byte[]) this.CurveR.Clone ();
Level copy = new Level (color_in_low, color_in_high, (float[]) gamma.Clone (), color_out_low, color_out_high) {
CurveB = (byte[]) this.CurveB.Clone (),
CurveG = (byte[]) this.CurveG.Clone (),
CurveR = (byte[]) this.CurveR.Clone ()
};

return copy;
}
Expand Down
10 changes: 6 additions & 4 deletions Pinta.Core/ImageFormats/OraFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ private static Size GetThumbDimensions (int width, int height)
private byte[] GetLayerXmlData (IReadOnlyList<UserLayer> layers)
{
MemoryStream ms = new MemoryStream ();
XmlTextWriter writer = new XmlTextWriter (ms, System.Text.Encoding.UTF8);
writer.Formatting = Formatting.Indented;
XmlTextWriter writer = new XmlTextWriter (ms, System.Text.Encoding.UTF8) {
Formatting = Formatting.Indented
};

writer.WriteStartElement ("image");
writer.WriteAttributeString ("w", layers[0].Surface.Width.ToString ());
Expand Down Expand Up @@ -183,8 +184,9 @@ public void Export (Document document, Gio.File file, Gtk.Window parent)
using var stream = new ZipOutputStream (file_stream) {
UseZip64 = UseZip64.Off // For backwards compatibility with older versions.
};
ZipEntry mimetype = new ZipEntry ("mimetype");
mimetype.CompressionMethod = CompressionMethod.Stored;
ZipEntry mimetype = new ZipEntry ("mimetype") {
CompressionMethod = CompressionMethod.Stored
};
stream.PutNextEntry (mimetype);

byte[] databytes = System.Text.Encoding.ASCII.GetBytes ("image/openraster");
Expand Down
28 changes: 14 additions & 14 deletions Pinta.Core/ImageFormats/TgaExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,20 @@ public void Export (Document document, Gio.File file, Gtk.Window parent)
using var file_stream = new GioStream (file.Replace ());
using var writer = new BinaryWriter (file_stream);

TgaHeader header = new TgaHeader ();

header.idLength = (byte) (ImageIdField.Length + 1);
header.cmapType = 0;
header.imageType = 2; // uncompressed RGB
header.cmapIndex = 0;
header.cmapLength = 0;
header.cmapEntrySize = 0;
header.xOrigin = 0;
header.yOrigin = 0;
header.imageWidth = (ushort) surf.Width;
header.imageHeight = (ushort) surf.Height;
header.pixelDepth = 32;
header.imageDesc = 8; // 32-bit, lower-left origin, which is weird but hey...
TgaHeader header = new TgaHeader {
idLength = (byte) (ImageIdField.Length + 1),
cmapType = 0,
imageType = 2, // uncompressed RGB
cmapIndex = 0,
cmapLength = 0,
cmapEntrySize = 0,
xOrigin = 0,
yOrigin = 0,
imageWidth = (ushort) surf.Width,
imageHeight = (ushort) surf.Height,
pixelDepth = 32,
imageDesc = 8 // 32-bit, lower-left origin, which is weird but hey...
};
header.WriteTo (writer);

writer.Write (ImageIdField);
Expand Down
15 changes: 9 additions & 6 deletions Pinta.Effects/Dialogs/Effects.PosterizeDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,21 @@ private void Build ()
content_area.SetAllMargins (6);
content_area.Spacing = 6;

red_spinbox = new HScaleSpinButtonWidget ();
red_spinbox.Label = Translations.GetString ("Red");
red_spinbox = new HScaleSpinButtonWidget {
Label = Translations.GetString ("Red")
};
InitSpinBox (red_spinbox);
content_area.Append (red_spinbox);

green_spinbox = new HScaleSpinButtonWidget ();
green_spinbox.Label = Translations.GetString ("Green");
green_spinbox = new HScaleSpinButtonWidget {
Label = Translations.GetString ("Green")
};
InitSpinBox (green_spinbox);
content_area.Append (green_spinbox);

blue_spinbox = new HScaleSpinButtonWidget ();
blue_spinbox.Label = Translations.GetString ("Blue");
blue_spinbox = new HScaleSpinButtonWidget {
Label = Translations.GetString ("Blue")
};
InitSpinBox (blue_spinbox);
content_area.Append (blue_spinbox);

Expand Down
7 changes: 4 additions & 3 deletions Pinta.Gui.Widgets/Widgets/AnglePickerWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ private void Build ()
var hbox2 = new Box () { Spacing = spacing };
hbox2.SetOrientation (Orientation.Horizontal);

anglepickergraphic1 = new AnglePickerGraphic ();
anglepickergraphic1.Hexpand = true;
anglepickergraphic1.Halign = Align.Center;
anglepickergraphic1 = new AnglePickerGraphic {
Hexpand = true,
Halign = Align.Center
};
hbox2.Append (anglepickergraphic1);

spin = SpinButton.NewWithRange (0, 360, 1);
Expand Down
7 changes: 4 additions & 3 deletions Pinta.Gui.Widgets/Widgets/PointPickerWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,10 @@ private void Build ()
var hbox2 = new Box () { Spacing = spacing };
hbox2.SetOrientation (Orientation.Horizontal);

pointpickergraphic1 = new PointPickerGraphic ();
pointpickergraphic1.Hexpand = true;
pointpickergraphic1.Halign = Align.Center;
pointpickergraphic1 = new PointPickerGraphic {
Hexpand = true,
Halign = Align.Center
};
hbox2.Append (pointpickergraphic1);

// X spinner
Expand Down
12 changes: 6 additions & 6 deletions Pinta.Tools/Editable/Shapes/Arrow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public class Arrow
/// <returns>A clone of the Arrow.</returns>
public Arrow Clone ()
{
Arrow clonedA = new Arrow ();

clonedA.Show = Show;
clonedA.ArrowSize = ArrowSize;
clonedA.AngleOffset = AngleOffset;
clonedA.LengthOffset = LengthOffset;
Arrow clonedA = new Arrow {
Show = Show,
ArrowSize = ArrowSize,
AngleOffset = AngleOffset,
LengthOffset = LengthOffset
};

return clonedA;
}
Expand Down
5 changes: 3 additions & 2 deletions Pinta.Tools/Tools/EraserTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ private static ImageSurface CopySurfacePart (ImageSurface surf, RectangleI dest_
{
var tmp_surface = CairoExtensions.CreateImageSurface (Format.Argb32, dest_rect.Width, dest_rect.Height);

var g = new Context (tmp_surface);
g.Operator = Operator.Source;
var g = new Context (tmp_surface) {
Operator = Operator.Source
};
g.SetSourceSurface (surf, -dest_rect.Left, -dest_rect.Top);
g.Rectangle (new RectangleD (0, 0, dest_rect.Width, dest_rect.Height));
g.Fill ();
Expand Down
5 changes: 3 additions & 2 deletions Pinta.Tools/Tools/LassoSelectTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ protected override void OnMouseMove (Document document, ToolMouseEventArgs e)

var surf = document.Layers.SelectionLayer.Surface;

var g = new Context (surf);
g.Antialias = Antialias.Subpixel;
var g = new Context (surf) {
Antialias = Antialias.Subpixel
};

if (path != null) {
g.AppendPath (path);
Expand Down
5 changes: 3 additions & 2 deletions Pinta.Tools/Tools/PaintBucketTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ protected override void OnFillRegionComputed (Document document, BitMask stencil
{
var surf = document.Layers.ToolLayer.Surface;

var g = new Context (surf);
g.Operator = Operator.Source;
var g = new Context (surf) {
Operator = Operator.Source
};
g.SetSourceSurface (document.Layers.CurrentUserLayer.Surface, 0, 0);
g.Paint ();

Expand Down
Loading