Skip to content

SimpleEffectDialog Reference

Cameron White edited this page Jun 22, 2013 · 11 revisions

The SimpleEffectDialog class will automatically generate a dialog for your effect based on the properties in the effect's EffectData.

Default Values and Common Attributes

All of the widgets will automatically use the current value of their associated property as the default value.

When creating the dialog, Pinta will automatically generate a label for each property based on its name. For example, a property named MyValue will have a label of "My Value". You can use the Caption attribute to specify a different name, and you can also use the Hint attribute to provide a helpful description that appears below the widget.

Integer/Double Slider

For int or double properties, a slider widget will be created. You can use the MinimumValue and MaximumValue attributes to control the range of the slider, and the IncrementValue attribute to specify the step size of the slider. For double, you can also use the DigitsValue attribute to control the number of decimal places.

public class MyEffectData : EffectData
{
    [MinimumValue(1), MaximumValue(5)]
    public int IntegerValue = 2;

    [DigitsValue(3), IncrementValue(0.1)]
    public double DoubleValue = 1.0;
};

Sliders

Random Seed

If an int property is named "Seed", it will create a "Reseed" button instead of a slider. Use this if your effect requires a random value.

public class MyEffectData : EffectData
{
    public int Seed;
};

Reseed Button

Angle Picker

If a double property is named "Angle" or "Rotation", an angle picker will be created instead of a slider.

public class MyEffectData : EffectData
{
    public double Angle;
    public double Rotation;
};

Angle Picker Widget

Checkbox

For bool properties, a checkbox will be created.

public class MyEffectData : EffectData
{
    public bool Invert;
};

Checkbox Widget

Point Picker

For Gdk.Point properties, a widget will be created that allows the user to specify the coordinates of a point on the canvas.

public class MyEffectData : EffectData
{
    public Gdk.Point Point;
};

Point Picker Widget

Offset Picker

For Cairo.PointD properties, a widget will be created that allows the user to specify an offset from the center of the canvas. The coordinates will be normalized, so that (-1, -1) is the top left corner and (1, 1) is the bottom right corner.

public class MyEffectData : EffectData
{
    public Cairo.PointD Offset;
};

Offset Picker Widget

Combo Box

There are two ways to create a combobox. For a string property with the StaticList attribute, a combobox will be be created using the keys of the dictionary specified in the attribute.

public class MyEffectData : EffectData
{
    public static Dictionary<string, object> TheOptions = new Dictionary<string, object> () {
        {"Option 1", 1}, {"Option 2", 2}, {"Option 3", 3}
    };
    [StaticList ("TheOptions")]
    public string Options = "Option 1";
};

For an enum property, a combobox will be automatically created using the enum values.

public class MyEffectData : EffectData
{
    public enum MyEnum
    {
        Option1,
        Option2,
        Option3
    }

    public MyEnum Enum;
};