mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Added option to configure dropdown position
This commit is contained in:
parent
0fd966818f
commit
1f0bcbc194
@ -560,9 +560,11 @@ std::shared_ptr<ComboBox> InterfaceObjectConfigurable::buildComboBox(const JsonN
|
||||
{
|
||||
logGlobal->debug("Building widget ComboBox");
|
||||
auto position = readPosition(config["position"]);
|
||||
auto dropDownPosition = readPosition(config["dropDownPosition"]);
|
||||
auto image = AnimationPath::fromJson(config["image"]);
|
||||
auto help = readHintText(config["help"]);
|
||||
auto result = std::make_shared<ComboBox>(position, image, help, config["dropDown"]);
|
||||
auto result = std::make_shared<ComboBox>(position, image, help, config["dropDown"], dropDownPosition);
|
||||
|
||||
if(!config["items"].isNull())
|
||||
{
|
||||
for(const auto & item : config["items"].Vector())
|
||||
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ class ComboBox : public CButton
|
||||
friend struct Item;
|
||||
|
||||
public:
|
||||
DropDown(const JsonNode &, ComboBox &);
|
||||
DropDown(const JsonNode &, ComboBox &, Point dropDownPosition);
|
||||
|
||||
bool receiveEvent(const Point & position, int eventType) const override;
|
||||
void clickPressed(const Point & cursorPosition) override;
|
||||
@ -54,7 +54,7 @@ class ComboBox : public CButton
|
||||
void setItem(const void *);
|
||||
|
||||
public:
|
||||
ComboBox(Point position, const AnimationPath & defName, const std::pair<std::string, std::string> & help, const JsonNode & dropDownDescriptor, EShortcut key = {}, bool playerColoredButton = false);
|
||||
ComboBox(Point position, const AnimationPath & defName, const std::pair<std::string, std::string> & help, const JsonNode & dropDownDescriptor, Point dropDownPosition, EShortcut key = {}, bool playerColoredButton = false);
|
||||
|
||||
//define this callback to fill input vector with data for the combo box
|
||||
std::function<void(std::vector<const void *> &)> onConstructItems;
|
||||
|
Loading…
Reference in New Issue
Block a user