Also save/load ExpandDirection from ComboBox to text file

0.8
Bruno Van de Velde 2017-09-23 15:24:02 +02:00
parent 635517e1c3
commit 4d51472523
3 changed files with 14 additions and 0 deletions

View File

@ -486,6 +486,16 @@ namespace tgui
if (node->propertyValuePairs["maximumitems"]) if (node->propertyValuePairs["maximumitems"])
comboBox->setMaximumItems(tgui::stoi(node->propertyValuePairs["maximumitems"]->value)); comboBox->setMaximumItems(tgui::stoi(node->propertyValuePairs["maximumitems"]->value));
if (node->propertyValuePairs["expanddirection"])
{
if (toLower(node->propertyValuePairs["expanddirection"]->value) == "up")
comboBox->setExpandDirection(ComboBox::ExpandDirection::Up);
else if (toLower(node->propertyValuePairs["expanddirection"]->value) == "down")
comboBox->setExpandDirection(ComboBox::ExpandDirection::Down);
else
throw Exception{"Failed to parse ExpandDirection property. Only the values Up and Down are correct."};
}
return comboBox; return comboBox;
} }

View File

@ -378,6 +378,9 @@ namespace tgui
SET_PROPERTY("TextSize", to_string(comboBox->getTextSize())); SET_PROPERTY("TextSize", to_string(comboBox->getTextSize()));
SET_PROPERTY("MaximumItems", to_string(comboBox->getMaximumItems())); SET_PROPERTY("MaximumItems", to_string(comboBox->getMaximumItems()));
if (comboBox->getExpandDirection() != ComboBox::ExpandDirection::Down)
SET_PROPERTY("ExpandDirection", "Up");
return node; return node;
} }

View File

@ -362,6 +362,7 @@ TEST_CASE("[ComboBox]")
comboBox->addItem("Item 3", "3"); comboBox->addItem("Item 3", "3");
comboBox->setItemsToDisplay(3); comboBox->setItemsToDisplay(3);
comboBox->setMaximumItems(5); comboBox->setMaximumItems(5);
comboBox->setExpandDirection(tgui::ComboBox::ExpandDirection::Up);
testSavingWidget("ComboBox", comboBox); testSavingWidget("ComboBox", comboBox);
} }