1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

Added option to configure dropdown position

This commit is contained in:
Ivan Savenko
2023-11-23 17:19:49 +02:00
parent 0fd966818f
commit 1f0bcbc194
3 changed files with 10 additions and 8 deletions

View File

@@ -67,7 +67,7 @@ void ComboBox::DropDown::Item::clickReleased(const Point & cursorPosition)
dropDown.clickReleased(cursorPosition);
}
ComboBox::DropDown::DropDown(const JsonNode & config, ComboBox & _comboBox):
ComboBox::DropDown::DropDown(const JsonNode & config, ComboBox & _comboBox, Point dropDownPosition):
InterfaceObjectConfigurable(LCLICK | HOVER),
comboBox(_comboBox)
{
@@ -78,7 +78,7 @@ ComboBox::DropDown::DropDown(const JsonNode & config, ComboBox & _comboBox):
addCallback("sliderMove", std::bind(&ComboBox::DropDown::sliderMove, this, std::placeholders::_1));
pos = comboBox.pos;
pos = comboBox.pos + dropDownPosition;
build(config);
@@ -156,12 +156,12 @@ void ComboBox::DropDown::setItem(const void * item)
GH.windows().popWindows(1);
}
ComboBox::ComboBox(Point position, const AnimationPath & defName, const std::pair<std::string, std::string> & help, const JsonNode & dropDownDescriptor, EShortcut key, bool playerColoredButton):
ComboBox::ComboBox(Point position, const AnimationPath & defName, const std::pair<std::string, std::string> & help, const JsonNode & dropDownDescriptor, Point dropDownPosition, EShortcut key, bool playerColoredButton):
CButton(position, defName, help, 0, key, playerColoredButton)
{
addCallback([&, dropDownDescriptor]()
addCallback([this, dropDownDescriptor, dropDownPosition]()
{
GH.windows().createAndPushWindow<ComboBox::DropDown>(dropDownDescriptor, *this);
GH.windows().createAndPushWindow<ComboBox::DropDown>(dropDownDescriptor, *this, dropDownPosition);
});
}