-
Notifications
You must be signed in to change notification settings - Fork 155
Property Enum file format (*.pef)
Defining property sets is a very similar with defining GUI elements. In most cases it's just hierarchy of objects with attributes. Now many GUI frameworks allow define GUI stuff using declarative language (like QML in Qt or XAML in .NET) in contrast of imperative C++ code.
So PEF format was introduced to help users to define properties in declarative way.
Let's consider the following example. Here is a simple property set with three sub properties.
#include "Core/PropertyCore.h"
...
auto textAttr = new QtnPropertySet(nullptr);
textAttr.setName("TextAttributes");
auto wrapping = new QtnPropertyBool(textAttr);
wrapping->setName("WordWrap");
wrapping->setDescription("Text word wrapping");
wrapping->setValue(true);
auto height = new QtnPropertyInt(textAttr);
height->setName("Height");
height->setDescription("Text height");
height->setMaxValue(100);
height->setMinValue(1);
height->setStepValue(1);
height->setValue(16);
auto textColor = new QtnPropertyQColor(textAttr);
textColor->setName("Color");
textColor->setDescription("Foreground text color");
textColor->setValue(QColor(0, 0, 0));
This code has a lot of redundancy and can be represented in more compact and elegant way using PEF (TextAttribues.pef):
#include "Core/PropertyCore.h"
property_set TextAttributes
{
Bool WordWrap
{
description = "Text word wrapping";
value = true;
}
Int Height
{
description = "Text height";
value = 16;
minValue = 1;
maxValue = 100;
stepValue = 1;
}
QColor Color
{
description = "Foreground text color";
value = QColor(0, 0, 0);
}
}
QtnPEG (Property/Enum Generator) executable converts *.pef file info C++ code. For example
QtnPEG.exe TextAttrubutes.pef
will produce TextAttributes.pef.h and TextAttributes.pef.cpp files where QtnPropertySetTextAttributes class is declared and implemented.