Skip to content
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
20 changes: 20 additions & 0 deletions Pinta.Core/Effects/BaseEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using System.ComponentModel;
using System.Threading.Tasks;
using Cairo;
using Mono.Addins.Localization;

namespace Pinta.Core;

Expand Down Expand Up @@ -188,6 +189,25 @@ public virtual BaseEffect Clone ()
}
}

/// <summary>
/// Base class for configurable effects whose dialog is the standard <c>SimpleEffectDialog<c/>
/// built from their <see cref="EffectData"/>
/// </summary>
public abstract class ConfigurableEffect : BaseEffect
{
private readonly IAddinLocalizer? localizer;

protected ConfigurableEffect (IAddinLocalizer? localizer = null)
{
this.localizer = localizer;
}

public sealed override bool IsConfigurable => true;

public override Task<bool> LaunchConfiguration (ILivePreviewSession session)
=> session.LaunchSimpleEffectDialog (localizer);
}

/// <summary>
/// Holds the user configurable data used by this effect.
/// </summary>
Expand Down
9 changes: 1 addition & 8 deletions Pinta.Effects/Adjustments/BrightnessContrastEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
/////////////////////////////////////////////////////////////////////////////////

using System;
using System.Threading.Tasks;
using Cairo;
using Pinta.Core;

namespace Pinta.Effects;

public sealed class BrightnessContrastEffect : BaseEffect
public sealed class BrightnessContrastEffect : ConfigurableEffect
{
const int DEFAULT_BRIGHTNESS = 0;
const int DEFAULT_CONTRAST = 0;
Expand All @@ -39,9 +38,6 @@ public override string Icon
public override string Name
=> Translations.GetString ("Brightness / Contrast");

public override bool IsConfigurable
=> true;

public override string AdjustmentMenuKey
=> "B";

Expand All @@ -53,9 +49,6 @@ public BrightnessContrastEffect (IServiceProvider _)
EffectData = new BrightnessContrastData ();
}

public override Task<bool> LaunchConfiguration (ILivePreviewSession session)
=> session.LaunchSimpleEffectDialog ();

private readonly record struct BrightnessContrastSettings (BrightnessContrastPixelOp PreRender, Size CanvasSize);
private static BrightnessContrastSettings CreateSettings (ImageSurface destination, BrightnessContrastPixelOp pixelOp)
=> new (
Expand Down
Loading