diff --git a/dependencies/subprojects/animationwindow/include/widgets/DropdownList.h b/dependencies/subprojects/animationwindow/include/widgets/DropdownList.h index 6f5d09d7c4130aa62b055f27a87764a4872e82a3..87fac22108d2cdfeede453deca1ba0eea93ed802 100644 --- a/dependencies/subprojects/animationwindow/include/widgets/DropdownList.h +++ b/dependencies/subprojects/animationwindow/include/widgets/DropdownList.h @@ -12,8 +12,8 @@ namespace TDT4102 { protected: void update(nk_context* context) override; public: - explicit DropdownList(TDT4102::Point location, int width, int height, std::vector<std::string> &options); - std::string getValue(); - void setOptions(std::vector<std::string>& updatedOptionsList); + explicit DropdownList(TDT4102::Point location, unsigned int width, unsigned int height, std::vector<std::string> &initialOptions); + std::string getValue() const; + void setOptions(std::vector<std::string> &updatedOptionsList); }; } \ No newline at end of file diff --git a/dependencies/subprojects/animationwindow/include/widgets/TextInput.h b/dependencies/subprojects/animationwindow/include/widgets/TextInput.h index fbdfa31141fb9ac23aa3aa2f4a18fa14027074b6..23867627ae92e4a6e82e6e29d935eb9e73b71d02 100644 --- a/dependencies/subprojects/animationwindow/include/widgets/TextInput.h +++ b/dependencies/subprojects/animationwindow/include/widgets/TextInput.h @@ -17,7 +17,7 @@ namespace TDT4102 { void update(nk_context* context) override; public: explicit TextInput(TDT4102::Point location, unsigned int width, unsigned int height, std::string initialText = ""); - std::string getText(); + std::string getText() const; void setText(std::string text); }; } \ No newline at end of file diff --git a/dependencies/subprojects/animationwindow/src/widgets/DropdownList.cpp b/dependencies/subprojects/animationwindow/src/widgets/DropdownList.cpp index 3a836a04f1106449a64ffca2cef46cdc2b9dc8da..ebc80eae4defd45f77b7ab6897f08a6aea81defa 100644 --- a/dependencies/subprojects/animationwindow/src/widgets/DropdownList.cpp +++ b/dependencies/subprojects/animationwindow/src/widgets/DropdownList.cpp @@ -1,14 +1,16 @@ #include "widgets/DropdownList.h" #include <stdexcept> -TDT4102::DropdownList::DropdownList(TDT4102::Point location, int width, int height, std::vector<std::string> &options) - : TDT4102::Widget(location, width, height), options{options} { +TDT4102::DropdownList::DropdownList(TDT4102::Point location, unsigned int width, unsigned int height, std::vector<std::string> &initialOptions) + : TDT4102::Widget(location, width, height) { if(options.size() == 0) { throw std::runtime_error("The list of options must contain at least one option to choose from!"); } + options = initialOptions; + } -std::string TDT4102::DropdownList::getValue() { +std::string TDT4102::DropdownList::getValue() const { return options.at(selectedIndex); } @@ -26,6 +28,6 @@ void TDT4102::DropdownList::update(nk_context *context) { } } -void TDT4102::DropdownList::setOptions(std::vector<std::string>& updatedOptionsList) { +void TDT4102::DropdownList::setOptions(std::vector<std::string> &updatedOptionsList) { options = updatedOptionsList; } \ No newline at end of file diff --git a/dependencies/subprojects/animationwindow/src/widgets/TextInput.cpp b/dependencies/subprojects/animationwindow/src/widgets/TextInput.cpp index 36be762da164c50f336a2e3eb351ac805dd512c7..6cf3971de69afa5644a1579e638e333ca5bb8121 100644 --- a/dependencies/subprojects/animationwindow/src/widgets/TextInput.cpp +++ b/dependencies/subprojects/animationwindow/src/widgets/TextInput.cpp @@ -20,7 +20,7 @@ TDT4102::TextInput::TextInput(TDT4102::Point location, unsigned int width, unsig previousContents.resize(internal::TEXT_INPUT_CHARACTER_LIMIT); } -std::string TDT4102::TextInput::getText() { +std::string TDT4102::TextInput::getText() const { // The editing string contains a large number of zeroes at the end // This chops those off return std::string(contents.data());