Skip to content

Commit

Permalink
Merge branch 'feature/xrcfiltertypes'
Browse files Browse the repository at this point in the history
Add XRC filter types to properly convert string like properties which
used the wrong type Text because nothing else was available.
  • Loading branch information
sodevel committed Feb 19, 2024
2 parents 2d39f8c + 2dade96 commit 14024c6
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 83 deletions.
46 changes: 22 additions & 24 deletions plugins/additional/additional.cpp
Expand Up @@ -617,7 +617,7 @@ class ToggleButtonComponent : public ComponentBase, public wxEvtHandler
filter.AddProperty(XrcFilter::Type::Bitmap, "current");
}
if (!obj->IsPropertyNull("position")) {
filter.AddProperty(XrcFilter::Type::Text, "position", "bitmapposition");
filter.AddProperty(XrcFilter::Type::Option, "position", "bitmapposition");
}
if (!obj->IsPropertyNull("margins")) {
filter.AddProperty(XrcFilter::Type::Size, "margins");
Expand All @@ -637,7 +637,7 @@ class ToggleButtonComponent : public ComponentBase, public wxEvtHandler
filter.AddProperty(XrcFilter::Type::Bitmap, "pressed");
filter.AddProperty(XrcFilter::Type::Bitmap, "focus");
filter.AddProperty(XrcFilter::Type::Bitmap, "current");
filter.AddProperty(XrcFilter::Type::Text, "bitmapposition", "position");
filter.AddProperty(XrcFilter::Type::Option, "bitmapposition", "position");
filter.AddProperty(XrcFilter::Type::Size, "margins");
filter.AddProperty(XrcFilter::Type::Bool, "checked", "value");
return xfb;
Expand Down Expand Up @@ -719,7 +719,7 @@ class BitmapToggleButtonComponent : public ComponentBase, public wxEvtHandler
filter.AddProperty(XrcFilter::Type::Bitmap, "current");
}
if (!obj->IsPropertyNull("position")) {
filter.AddProperty(XrcFilter::Type::Text, "position", "bitmapposition");
filter.AddProperty(XrcFilter::Type::Option, "position", "bitmapposition");
}
if (!obj->IsPropertyNull("margins")) {
filter.AddProperty(XrcFilter::Type::Size, "margins");
Expand All @@ -737,7 +737,7 @@ class BitmapToggleButtonComponent : public ComponentBase, public wxEvtHandler
filter.AddProperty(XrcFilter::Type::Bitmap, "pressed");
filter.AddProperty(XrcFilter::Type::Bitmap, "focus");
filter.AddProperty(XrcFilter::Type::Bitmap, "current");
filter.AddProperty(XrcFilter::Type::Text, "bitmapposition", "position");
filter.AddProperty(XrcFilter::Type::Option, "bitmapposition", "position");
filter.AddProperty(XrcFilter::Type::Size, "margins");
filter.AddProperty(XrcFilter::Type::Bool, "checked", "value");
return xfb;
Expand Down Expand Up @@ -864,7 +864,7 @@ class SpinCtrlComponent : public ComponentBase, public wxEvtHandler
{
ObjectToXrcFilter filter(xrc, GetLibrary(), obj);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Text, "initial", "value");
filter.AddProperty(XrcFilter::Type::Integer, "initial", "value");
filter.AddProperty(XrcFilter::Type::Integer, "min");
filter.AddProperty(XrcFilter::Type::Integer, "max");
return xrc;
Expand All @@ -874,9 +874,9 @@ class SpinCtrlComponent : public ComponentBase, public wxEvtHandler
{
XrcToXfbFilter filter(xfb, GetLibrary(), xrc);
filter.AddWindowProperties();
// FIXME: Why is value filtered twice? What effect does this have?
filter.AddProperty(XrcFilter::Type::Text, "value");
filter.AddProperty(XrcFilter::Type::Text, "value", "initial");
// TODO: XRC only supports the integral initial value, filter it twice to initialize the string initial value as well
filter.AddProperty(XrcFilter::Type::String, "value");
filter.AddProperty(XrcFilter::Type::Integer, "value", "initial");
filter.AddProperty(XrcFilter::Type::Integer, "min");
filter.AddProperty(XrcFilter::Type::Integer, "max");
return xfb;
Expand Down Expand Up @@ -927,7 +927,7 @@ class SpinCtrlDoubleComponent : public ComponentBase, public wxEvtHandler
{
ObjectToXrcFilter filter(xrc, GetLibrary(), obj);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Text, "initial", "value");
filter.AddProperty(XrcFilter::Type::Float, "initial", "value");
filter.AddProperty(XrcFilter::Type::Float, "min");
filter.AddProperty(XrcFilter::Type::Float, "max");
filter.AddProperty(XrcFilter::Type::Float, "inc");
Expand All @@ -939,9 +939,9 @@ class SpinCtrlDoubleComponent : public ComponentBase, public wxEvtHandler
{
XrcToXfbFilter filter(xfb, GetLibrary(), xrc);
filter.AddWindowProperties();
// FIXME: Why is value filtered twice? What effect does this have?
filter.AddProperty(XrcFilter::Type::Text, "value");
filter.AddProperty(XrcFilter::Type::Text, "value", "initial");
// TODO: XRC only supports the float initial value, filter it twice to initialize the string initial value as well
filter.AddProperty(XrcFilter::Type::String, "value");
filter.AddProperty(XrcFilter::Type::Float, "value", "initial");
filter.AddProperty(XrcFilter::Type::Float, "min");
filter.AddProperty(XrcFilter::Type::Float, "max");
filter.AddProperty(XrcFilter::Type::Float, "inc");
Expand Down Expand Up @@ -992,15 +992,15 @@ class CheckListBoxComponent : public ComponentBase
{
ObjectToXrcFilter filter(xrc, GetLibrary(), obj);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::StringList, "choices", "content");
filter.AddProperty(XrcFilter::Type::TextList, "choices", "content");
return xrc;
}

tinyxml2::XMLElement* ImportFromXrc(tinyxml2::XMLElement* xfb, const tinyxml2::XMLElement* xrc) override
{
XrcToXfbFilter filter(xfb, GetLibrary(), xrc);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::StringList, "content", "choices");
filter.AddProperty(XrcFilter::Type::TextList, "content", "choices");
return xfb;
}
};
Expand Down Expand Up @@ -1287,7 +1287,7 @@ class FilePickerComponent : public PickerComponentBase
{
ObjectToXrcFilter filter(xrc, GetLibrary(), obj);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Text, "value");
filter.AddProperty(XrcFilter::Type::String, "value");
filter.AddProperty(XrcFilter::Type::Text, "message");
filter.AddProperty(XrcFilter::Type::Text, "wildcard");
return xrc;
Expand All @@ -1297,7 +1297,7 @@ class FilePickerComponent : public PickerComponentBase
{
XrcToXfbFilter filter(xfb, GetLibrary(), xrc);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Text, "value");
filter.AddProperty(XrcFilter::Type::String, "value");
filter.AddProperty(XrcFilter::Type::Text, "message");
filter.AddProperty(XrcFilter::Type::Text, "wildcard");
return xfb;
Expand Down Expand Up @@ -1330,7 +1330,7 @@ class DirPickerComponent : public PickerComponentBase
{
ObjectToXrcFilter filter(xrc, GetLibrary(), obj);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Text, "value");
filter.AddProperty(XrcFilter::Type::String, "value");
filter.AddProperty(XrcFilter::Type::Text, "message");
return xrc;
}
Expand All @@ -1339,7 +1339,7 @@ class DirPickerComponent : public PickerComponentBase
{
XrcToXfbFilter filter(xfb, GetLibrary(), xrc);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Text, "value");
filter.AddProperty(XrcFilter::Type::String, "value");
filter.AddProperty(XrcFilter::Type::Text, "message");
return xfb;
}
Expand Down Expand Up @@ -1373,7 +1373,7 @@ class HyperlinkComponent : public ComponentBase
ObjectToXrcFilter filter(xrc, GetLibrary(), obj);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Text, "label");
filter.AddPropertyValue("url", obj->GetPropertyAsString("url"));
filter.AddProperty(XrcFilter::Type::String, "url");
return xrc;
}

Expand All @@ -1382,9 +1382,7 @@ class HyperlinkComponent : public ComponentBase
XrcToXfbFilter filter(xfb, GetLibrary(), xrc);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Text, "label");
if (const auto* urlElement = xrc->FirstChildElement("url")) {
filter.AddPropertyValue("url", XMLUtils::GetText(urlElement));
}
filter.AddProperty(XrcFilter::Type::String, "url");
return xfb;
}
};
Expand Down Expand Up @@ -1417,7 +1415,7 @@ class GenericDirCtrlComponent : public ComponentBase
{
ObjectToXrcFilter filter(xrc, GetLibrary(), obj);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Text, "defaultfolder");
filter.AddProperty(XrcFilter::Type::String, "defaultfolder");
filter.AddProperty(XrcFilter::Type::Text, "filter");
filter.AddProperty(XrcFilter::Type::Integer, "defaultfilter");
return xrc;
Expand All @@ -1427,7 +1425,7 @@ class GenericDirCtrlComponent : public ComponentBase
{
XrcToXfbFilter filter(xfb, GetLibrary(), xrc);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Text, "defaultfolder");
filter.AddProperty(XrcFilter::Type::String, "defaultfolder");
filter.AddProperty(XrcFilter::Type::Text, "filter");
filter.AddProperty(XrcFilter::Type::Integer, "defaultfilter");
return xfb;
Expand Down
40 changes: 20 additions & 20 deletions plugins/common/common.cpp
Expand Up @@ -420,7 +420,7 @@ class ButtonComponent : public ComponentBase
filter.AddProperty(XrcFilter::Type::Bitmap, "current");
}
if (!obj->IsPropertyNull("position")) {
filter.AddProperty(XrcFilter::Type::Text, "position", "bitmapposition");
filter.AddProperty(XrcFilter::Type::Option, "position", "bitmapposition");
}
if (!obj->IsPropertyNull("margins")) {
filter.AddProperty(XrcFilter::Type::Size, "margins");
Expand All @@ -441,7 +441,7 @@ class ButtonComponent : public ComponentBase
filter.AddProperty(XrcFilter::Type::Bitmap, "pressed");
filter.AddProperty(XrcFilter::Type::Bitmap, "focus");
filter.AddProperty(XrcFilter::Type::Bitmap, "current");
filter.AddProperty(XrcFilter::Type::Text, "bitmapposition", "position");
filter.AddProperty(XrcFilter::Type::Option, "bitmapposition", "position");
filter.AddProperty(XrcFilter::Type::Size, "margins");
return xfb;
}
Expand Down Expand Up @@ -517,7 +517,7 @@ class BitmapButtonComponent : public ComponentBase
filter.AddProperty(XrcFilter::Type::Bitmap, "current");
}
if (!obj->IsPropertyNull("position")) {
filter.AddProperty(XrcFilter::Type::Text, "position", "bitmapposition");
filter.AddProperty(XrcFilter::Type::Option, "position", "bitmapposition");
}
if (!obj->IsPropertyNull("margins")) {
filter.AddProperty(XrcFilter::Type::Size, "margins");
Expand All @@ -536,7 +536,7 @@ class BitmapButtonComponent : public ComponentBase
filter.AddProperty(XrcFilter::Type::Bitmap, "pressed");
filter.AddProperty(XrcFilter::Type::Bitmap, "focus");
filter.AddProperty(XrcFilter::Type::Bitmap, "current");
filter.AddProperty(XrcFilter::Type::Text, "bitmapposition", "position");
filter.AddProperty(XrcFilter::Type::Option, "bitmapposition", "position");
filter.AddProperty(XrcFilter::Type::Size, "margins");
return xfb;
}
Expand Down Expand Up @@ -664,7 +664,7 @@ class ComboBoxComponent : public ComponentBase
ObjectToXrcFilter filter(xrc, GetLibrary(), obj);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Text, "value");
filter.AddProperty(XrcFilter::Type::StringList, "choices", "content");
filter.AddProperty(XrcFilter::Type::TextList, "choices", "content");
return xrc;
}

Expand All @@ -673,7 +673,7 @@ class ComboBoxComponent : public ComponentBase
XrcToXfbFilter filter(xfb, GetLibrary(), xrc);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Text, "value");
filter.AddProperty(XrcFilter::Type::StringList, "content", "choices");
filter.AddProperty(XrcFilter::Type::TextList, "content", "choices");
return xfb;
}
};
Expand Down Expand Up @@ -717,7 +717,7 @@ class BitmapComboBoxComponent : public ComponentBase
ObjectToXrcFilter filter(xrc, GetLibrary(), obj);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Text, "value");
filter.AddProperty(XrcFilter::Type::StringList, "choices", "content");
filter.AddProperty(XrcFilter::Type::TextList, "choices", "content");
return xrc;
}

Expand All @@ -726,7 +726,7 @@ class BitmapComboBoxComponent : public ComponentBase
XrcToXfbFilter filter(xfb, GetLibrary(), xrc);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Text, "value");
filter.AddProperty(XrcFilter::Type::StringList, "content", "choices");
filter.AddProperty(XrcFilter::Type::TextList, "content", "choices");
return xfb;
}
};
Expand Down Expand Up @@ -900,15 +900,15 @@ class ListBoxComponent : public ComponentBase
{
ObjectToXrcFilter filter(xrc, GetLibrary(), obj);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::StringList, "choices", "content");
filter.AddProperty(XrcFilter::Type::TextList, "choices", "content");
return xrc;
}

tinyxml2::XMLElement* ImportFromXrc(tinyxml2::XMLElement* xfb, const tinyxml2::XMLElement* xrc) override
{
XrcToXfbFilter filter(xfb, GetLibrary(), xrc);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::StringList, "content", "choices");
filter.AddProperty(XrcFilter::Type::TextList, "content", "choices");
return xfb;
}
};
Expand Down Expand Up @@ -976,7 +976,7 @@ class RadioBoxComponent : public ComponentBase, public wxEvtHandler
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Text, "label");
filter.AddProperty(XrcFilter::Type::Integer, "selection");
filter.AddProperty(XrcFilter::Type::StringList, "choices", "content");
filter.AddProperty(XrcFilter::Type::TextList, "choices", "content");
filter.AddProperty(XrcFilter::Type::Integer, "majorDimension", "dimension");
return xrc;
}
Expand All @@ -987,7 +987,7 @@ class RadioBoxComponent : public ComponentBase, public wxEvtHandler
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Text, "label");
filter.AddProperty(XrcFilter::Type::Integer, "selection");
filter.AddProperty(XrcFilter::Type::StringList, "content", "choices");
filter.AddProperty(XrcFilter::Type::TextList, "content", "choices");
filter.AddProperty(XrcFilter::Type::Integer, "dimension", "majorDimension");
return xfb;
}
Expand Down Expand Up @@ -1463,7 +1463,7 @@ class ChoiceComponent : public ComponentBase
ObjectToXrcFilter filter(xrc, GetLibrary(), obj);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Integer, "selection");
filter.AddProperty(XrcFilter::Type::StringList, "choices", "content");
filter.AddProperty(XrcFilter::Type::TextList, "choices", "content");
return xrc;
}

Expand All @@ -1472,7 +1472,7 @@ class ChoiceComponent : public ComponentBase
XrcToXfbFilter filter(xfb, GetLibrary(), xrc);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Integer, "selection");
filter.AddProperty(XrcFilter::Type::StringList, "content", "choices");
filter.AddProperty(XrcFilter::Type::TextList, "content", "choices");
return xfb;
}
};
Expand Down Expand Up @@ -1587,15 +1587,15 @@ class AnimCtrlComponent : public ComponentBase
{
ObjectToXrcFilter filter(xrc, GetLibrary(), obj);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Text, "animation");
filter.AddProperty(XrcFilter::Type::String, "animation");
return xrc;
}

tinyxml2::XMLElement* ImportFromXrc(tinyxml2::XMLElement* xfb, const tinyxml2::XMLElement* xrc) override
{
XrcToXfbFilter filter(xfb, GetLibrary(), xrc);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Text, "animation");
filter.AddProperty(XrcFilter::Type::String, "animation");
return xfb;
}
};
Expand Down Expand Up @@ -1630,8 +1630,8 @@ class InfoBarComponent : public ComponentBase
{
ObjectToXrcFilter filter(xrc, GetLibrary(), obj);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Text, "show_effect", "showeffect");
filter.AddProperty(XrcFilter::Type::Text, "hide_effect", "hideeffect");
filter.AddProperty(XrcFilter::Type::Option, "show_effect", "showeffect");
filter.AddProperty(XrcFilter::Type::Option, "hide_effect", "hideeffect");
filter.AddProperty(XrcFilter::Type::Integer, "duration", "effectduration");
// FIXME: button is currently not part of the data model
return xrc;
Expand All @@ -1641,8 +1641,8 @@ class InfoBarComponent : public ComponentBase
{
XrcToXfbFilter filter(xfb, GetLibrary(), xrc);
filter.AddWindowProperties();
filter.AddProperty(XrcFilter::Type::Text, "showeffect", "show_effect");
filter.AddProperty(XrcFilter::Type::Text, "hideeffect", "hide_effect");
filter.AddProperty(XrcFilter::Type::Option, "showeffect", "show_effect");
filter.AddProperty(XrcFilter::Type::Option, "hideeffect", "hide_effect");
filter.AddProperty(XrcFilter::Type::Integer, "effectduration", "duration");
// FIXME: button is currently not part of the data model
return xfb;
Expand Down

0 comments on commit 14024c6

Please sign in to comment.