Skip to content

Commit

Permalink
Merge pull request #299 from Lehonti/improvement1
Browse files Browse the repository at this point in the history
Modernized remaining getters/setters
  • Loading branch information
cameronwhite authored Aug 9, 2023
2 parents e0fddde + 40a1160 commit c65cefa
Show file tree
Hide file tree
Showing 23 changed files with 52 additions and 82 deletions.
4 changes: 2 additions & 2 deletions Pinta.Core/Actions/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void Activate ()
public string? IconName { get; }
public string FullName => $"app.{Name}";
public bool IsImportant { get; set; } = false;
public bool Sensitive { get { return Action.Enabled; } set { Action.Enabled = value; } }
public bool Sensitive { get => Action.Enabled; set => Action.Enabled = value; }

public Command (string name, string label, string? tooltip, string? icon_name, GLib.Variant? state = null)
{
Expand Down Expand Up @@ -85,7 +85,7 @@ public ToggleCommand (string name, string label, string? tooltip, string? stock_
}

public bool Value {
get { return GetBoolValue (Action.GetState ()); }
get => GetBoolValue (Action.GetState ());
set {
if (value != Value) {
Toggled?.Invoke (value);
Expand Down
2 changes: 1 addition & 1 deletion Pinta.Core/Actions/ViewActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class ViewActions
private bool zoom_to_window_activated = false;

public bool ZoomToWindowActivated {
get { return zoom_to_window_activated; }
get => zoom_to_window_activated;
set {
zoom_to_window_activated = value;
old_zoom_text = ZoomComboBox.ComboBox.GetActiveText ()!;
Expand Down
4 changes: 2 additions & 2 deletions Pinta.Core/Classes/Document.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class Document

private DocumentSelection selection = null!; // NRT - Set by constructor via Selection property
public DocumentSelection Selection {
get { return selection; }
get => selection;
set {
selection = value;

Expand Down Expand Up @@ -118,7 +118,7 @@ public Gio.File? File {
public Core.Size ImageSize { get; set; }

public bool IsDirty {
get { return is_dirty; }
get => is_dirty;
set {
if (is_dirty != value) {
is_dirty = value;
Expand Down
2 changes: 1 addition & 1 deletion Pinta.Core/Classes/DocumentSelection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class DocumentSelection

private bool _visible = true;
public bool Visible {
get { return _visible; }
get => _visible;
set {
_visible = value;

Expand Down
4 changes: 2 additions & 2 deletions Pinta.Core/Classes/DocumentWorkspace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public bool ImageViewFitsInWindow {
/// Size of the zoomed image.
/// </summary>
public Size ViewSize {
get { return view_size; }
get => view_size;
set {
if (view_size.Width != value.Width || view_size.Height != value.Height) {
view_size = value;
Expand Down Expand Up @@ -108,7 +108,7 @@ public bool ImageFitsInWindow {
/// Scale factor for the zoomed image.
/// </summary>
public double Scale {
get { return (double) ViewSize.Width / (double) document.ImageSize.Width; }
get => (double) ViewSize.Width / (double) document.ImageSize.Width;
set {
if (value != (double) ViewSize.Width / (double) document.ImageSize.Width || value != (double) ViewSize.Height / (double) document.ImageSize.Height) {
if (document.ImageSize.Width == 0) {
Expand Down
8 changes: 4 additions & 4 deletions Pinta.Core/Classes/Layer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,22 @@ public Layer (ImageSurface surface, bool hidden, double opacity, string name)
public static readonly string BlendModeProperty = "BlendMode";

public double Opacity {
get { return opacity; }
get => opacity;
set { if (opacity != value) SetValue (OpacityProperty, ref opacity, value); }
}

public bool Hidden {
get { return hidden; }
get => hidden;
set { if (hidden != value) SetValue (HiddenProperty, ref hidden, value); }
}

public string Name {
get { return name; }
get => name;
set { if (name != value) SetValue (NameProperty, ref name, value); }
}

public BlendMode BlendMode {
get { return blend_mode; }
get => blend_mode;
set { if (blend_mode != value) SetValue (BlendModeProperty, ref blend_mode, value); }
}

Expand Down
4 changes: 1 addition & 3 deletions Pinta.Core/Classes/Palette.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ private void OnPaletteChanged ()
public int Count => colors.Count;

public Color this[int index] {
get {
return colors[index];
}
get => colors[index];

set {
colors[index] = value;
Expand Down
4 changes: 1 addition & 3 deletions Pinta.Core/Classes/Re-editable/ReEditableLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ public Layer Layer {
return actualLayer!; // NRT - Set in SetupLayer
}

set {
actualLayer = value;
}
set => actualLayer = value;
}

public bool IsLayerSetup => isLayerSetup;
Expand Down
2 changes: 1 addition & 1 deletion Pinta.Core/Classes/Re-editable/Text/TextLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class TextLayout
private TextEngine engine = null!; // NRT - Not sure how this is set, but all callers assume it is not-null

public TextEngine Engine {
get { return engine; }
get => engine;
set {
if (engine != null)
engine.Modified -= OnEngineModified;
Expand Down
8 changes: 4 additions & 4 deletions Pinta.Core/Classes/Re-editable/Text/TextPosition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public TextPosition (int line, int offset)
}

public int Line {
readonly get { return line; }
set { line = Math.Max (value, 0); }
readonly get => line;
set => line = Math.Max (value, 0);
}

public int Offset {
readonly get { return offset; }
set { offset = Math.Max (value, 0); }
readonly get => offset;
set => offset = Math.Max (value, 0);
}

#region Operators
Expand Down
4 changes: 1 addition & 3 deletions Pinta.Core/Effects/Histogram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ public abstract class Histogram
{
protected long[][] histogram;
public long[][] HistogramValues {
get {
return this.histogram;
}
get => this.histogram;

set {
if (value.Length == this.histogram.Length && value[0].Length == this.histogram[0].Length) {
Expand Down
16 changes: 4 additions & 12 deletions Pinta.Core/Effects/UnaryPixelOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,7 @@ public class Level
{
private ColorBgra color_in_low;
public ColorBgra ColorInLow {
get {
return color_in_low;
}
get => color_in_low;

set {
if (value.R == 255) {
Expand Down Expand Up @@ -463,9 +461,7 @@ public ColorBgra ColorInLow {

private ColorBgra color_in_high;
public ColorBgra ColorInHigh {
get {
return color_in_high;
}
get => color_in_high;

set {
if (value.R == 0) {
Expand Down Expand Up @@ -499,9 +495,7 @@ public ColorBgra ColorInHigh {

private ColorBgra color_out_low;
public ColorBgra ColorOutLow {
get {
return color_out_low;
}
get => color_out_low;

set {
if (value.R == 255) {
Expand Down Expand Up @@ -535,9 +529,7 @@ public ColorBgra ColorOutLow {

private ColorBgra color_out_high;
public ColorBgra ColorOutHigh {
get {
return color_out_high;
}
get => color_out_high;

set {
if (value.R == 0) {
Expand Down
4 changes: 1 addition & 3 deletions Pinta.Core/Extensions/GioStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ public override long Position {
throw new ObjectDisposedException ("The stream is closed");
return ((Gio.Seekable) stream).Tell ();
}
set {
Seek (value, System.IO.SeekOrigin.Begin);
}
set => Seek (value, System.IO.SeekOrigin.Begin);
}

public override void Flush ()
Expand Down
4 changes: 2 additions & 2 deletions Pinta.Core/Managers/ChromeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public ChromeManager ()

#region Public Properties
public PointI LastCanvasCursorPoint {
get { return last_canvas_cursor_point; }
get => last_canvas_cursor_point;
set {
if (last_canvas_cursor_point != value) {
last_canvas_cursor_point = value;
Expand All @@ -70,7 +70,7 @@ public PointI LastCanvasCursorPoint {
}

public bool MainWindowBusy {
get { return main_window_busy; }
get => main_window_busy;
set {
main_window_busy = value;

Expand Down
2 changes: 1 addition & 1 deletion Pinta.Core/Managers/RecentFileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public RecentFileManager ()
}

public Gio.File? LastDialogDirectory {
get { return last_dialog_directory; }
get => last_dialog_directory;
set {
// The file chooser dialog may return null for the current folder in certain cases,
// such as the Recently Used pane in the Gnome file chooser.
Expand Down
4 changes: 2 additions & 2 deletions Pinta.Effects/Adjustments/BrightnessContrastEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public class BrightnessContrastData : EffectData

[Caption ("Brightness")]
public int Brightness {
get { return brightness; }
get => brightness;
set {
if (value != brightness) {
brightness = value;
Expand All @@ -150,7 +150,7 @@ public int Brightness {

[Caption ("Contrast")]
public int Contrast {
get { return contrast; }
get => contrast;
set {
if (value != contrast) {
contrast = value;
Expand Down
4 changes: 1 addition & 3 deletions Pinta.Effects/Dialogs/Effects.CurvesDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ private class ControlPointDrawingInfo
private SortedList<int, int>[] rgb_cps = null!;

public SortedList<int, int>[] ControlPoints {
get {
return (Mode == ColorTransferMode.Luminosity) ? luminosity_cps : rgb_cps;
}
get => (Mode == ColorTransferMode.Luminosity) ? luminosity_cps : rgb_cps;
set {
if (Mode == ColorTransferMode.Luminosity)
luminosity_cps = value;
Expand Down
8 changes: 2 additions & 6 deletions Pinta.Gui.Widgets/Widgets/PointPickerWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,10 @@ public PointI Point {
}

public PointD DefaultOffset {
get {
return new PointD ((DefaultPoint.X * 2.0 / PintaCore.Workspace.ImageSize.Width) - 1.0,
get => new PointD ((DefaultPoint.X * 2.0 / PintaCore.Workspace.ImageSize.Width) - 1.0,
(DefaultPoint.Y * 2.0 / PintaCore.Workspace.ImageSize.Height) - 1.0);
}
set {
DefaultPoint = new PointI ((int) ((value.X + 1.0) * PintaCore.Workspace.ImageSize.Width / 2.0),
set => DefaultPoint = new PointI ((int) ((value.X + 1.0) * PintaCore.Workspace.ImageSize.Width / 2.0),
(int) ((value.Y + 1.0) * PintaCore.Workspace.ImageSize.Height / 2.0));
}
}

public PointD Offset
Expand Down
8 changes: 4 additions & 4 deletions Pinta.Tools/Editable/EditEngines/BaseEditEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ public enum ShapeTypes
protected PointD current_point;

public static Color OutlineColor {
get { return PintaCore.Palette.PrimaryColor; }
set { PintaCore.Palette.PrimaryColor = value; }
get => PintaCore.Palette.PrimaryColor;
set => PintaCore.Palette.PrimaryColor = value;
}

public static Color FillColor {
get { return PintaCore.Palette.SecondaryColor; }
set { PintaCore.Palette.SecondaryColor = value; }
get => PintaCore.Palette.SecondaryColor;
set => PintaCore.Palette.SecondaryColor = value;
}

// NRT - Created by HandleBuildToolBar
Expand Down
4 changes: 1 addition & 3 deletions Pinta.Tools/Tools/TextTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ public class TextTool : BaseTool
private readonly Pinta.Core.TextLayout layout;

private RectangleI CurrentTextBounds {
get {
return PintaCore.Workspace.ActiveDocument.Layers.CurrentUserLayer.textBounds;
}
get => PintaCore.Workspace.ActiveDocument.Layers.CurrentUserLayer.textBounds;

set {
PintaCore.Workspace.ActiveDocument.Layers.CurrentUserLayer.previousTextBounds = PintaCore.Workspace.ActiveDocument.Layers.CurrentUserLayer.textBounds;
Expand Down
8 changes: 2 additions & 6 deletions Pinta/Actions/File/DBus/ScreenshotPortal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,9 @@ class ScreenshotProperties
{
private uint _version = default (uint);
public uint Version {
get {
return _version;
}
get => _version;

set {
_version = (value);
}
set => _version = (value);
}
}

Expand Down
8 changes: 4 additions & 4 deletions Pinta/Dialogs/ProgressDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ public ProgressDialog ()
}

public string Text {
get { return label.GetText (); }
set { label.SetText (value); }
get => label.GetText ();
set => label.SetText (value);
}

public double Progress {
get { return progress_bar.Fraction; }
set { progress_bar.Fraction = value; }
get => progress_bar.Fraction;
set => progress_bar.Fraction = value;
}

public event EventHandler<EventArgs>? Canceled;
Expand Down
18 changes: 8 additions & 10 deletions Pinta/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ internal OptionValueCollection (OptionContext c)
void IList.Remove (object value) { (values as IList).Remove (value); }
void IList.RemoveAt (int index) { (values as IList).RemoveAt (index); }
bool IList.IsFixedSize => false;
object IList.this[int index] { get { return this[index]; } set { (values as IList)[index] = value; } }
object IList.this[int index] { get => this[index]; set => (values as IList)[index] = value; }
#endregion

#region IList<T>
Expand All @@ -220,9 +220,7 @@ public string this[int index] {
AssertValid (index);
return index >= values.Count ? null : values[index];
}
set {
values[index] = value;
}
set => values[index] = value;
}
#endregion

Expand Down Expand Up @@ -257,18 +255,18 @@ public OptionContext (OptionSet set)
}

public Option Option {
get { return option; }
set { option = value; }
get => option;
set => option = value;
}

public string OptionName {
get { return name; }
set { name = value; }
get => name;
set => name = value;
}

public int OptionIndex {
get { return index; }
set { index = value; }
get => index;
set => index = value;
}

public OptionSet OptionSet => set;
Expand Down

0 comments on commit c65cefa

Please sign in to comment.