Skip to content

Commit

Permalink
CloseBehavior of ChildWindow couldn't be set in Gui Builder
Browse files Browse the repository at this point in the history
  • Loading branch information
texus committed Oct 8, 2024
1 parent d4a65b8 commit aa89121
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion gui-builder/include/WidgetProperties/ChildWindowProperties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ struct ChildWindowProperties : WidgetProperties
void updateProperty(const tgui::Widget::Ptr& widget, const tgui::String& property, const tgui::String& value) const override
{
auto childWindow = widget->cast<tgui::ChildWindow>();
if (property == "TitleAlignment")
if (property == "CloseBehavior")
childWindow->setCloseBehavior(deserializeCloseBehavior(value));
else if (property == "TitleAlignment")
childWindow->setTitleAlignment(deserializeHorizontalAlignment(value));
else if (property == "TitleButtons")
childWindow->setTitleButtons(deserializeTitleButtons(value));
Expand Down Expand Up @@ -61,6 +63,7 @@ struct ChildWindowProperties : WidgetProperties
{
auto pair = WidgetProperties::initProperties(widget);
auto childWindow = widget->cast<tgui::ChildWindow>();
pair.first["CloseBehavior"] = {"Enum{None,Hide,Remove}", serializeCloseBehavior(childWindow->getCloseBehavior())};
pair.first["TitleAlignment"] = {"Enum{Left,Center,Right}", serializeHorizontalAlignment(childWindow->getTitleAlignment())};
pair.first["TitleButtons"] = {"ChildWindowTitleButtons", serializeTitleButtons(childWindow->getTitleButtons())};
pair.first["Title"] = {"String", childWindow->getTitle()};
Expand Down Expand Up @@ -128,6 +131,27 @@ struct ChildWindowProperties : WidgetProperties

return serializedTitleButtons;
}

TGUI_NODISCARD static tgui::ChildWindow::CloseBehavior deserializeCloseBehavior(tgui::String value)
{
value = value.trim().toLower();
if (value == "none")
return tgui::ChildWindow::CloseBehavior::None;
else if (value == "hide")
return tgui::ChildWindow::CloseBehavior::Hide;
else
return tgui::ChildWindow::CloseBehavior::Remove;
}

TGUI_NODISCARD static tgui::String serializeCloseBehavior(tgui::ChildWindow::CloseBehavior behavior)
{
if (behavior == tgui::ChildWindow::CloseBehavior::None)
return "None";
else if (behavior == tgui::ChildWindow::CloseBehavior::Hide)
return "Hide";
else
return "Remove";
}
};

#endif // TGUI_GUI_BUILDER_CHILD_WINDOW_PROPERTIES_HPP

0 comments on commit aa89121

Please sign in to comment.