diff --git a/dependencies/subprojects/animationwindow/include/internal/FontCache.h b/dependencies/subprojects/animationwindow/include/internal/FontCache.h index 761e075c60673d7861b67f8b5ae2de4b8722b048..e6a3aff4548666d4cf959def03da575662b881cb 100644 --- a/dependencies/subprojects/animationwindow/include/internal/FontCache.h +++ b/dependencies/subprojects/animationwindow/include/internal/FontCache.h @@ -47,11 +47,11 @@ namespace TDT4102::internal { std::unordered_map<Font, std::unordered_map<unsigned int, nk_font*>> loadedFonts; std::unordered_map<Font, std::unordered_map<unsigned int, nk_font_atlas*>> loadedAtlases; - std::filesystem::path findTTFInDirectory(const std::filesystem::path& directoryToSearch, const std::string& fontFileName); + std::filesystem::path findTTFInDirectory(const std::filesystem::path &directoryToSearch, const std::string &fontFileName); std::filesystem::path findTTFFile(const std::string &filename); void loadFont(nk_context *context, TDT4102::Font face, unsigned int size); public: - void initialise(); + void initialize(); void setFont(nk_context* context, TDT4102::Font face, unsigned int size); }; } diff --git a/dependencies/subprojects/animationwindow/include/widgets/DropdownList.h b/dependencies/subprojects/animationwindow/include/widgets/DropdownList.h index 6f5d09d7c4130aa62b055f27a87764a4872e82a3..56f34d25e38474a91293ba48e9381f94052e0ac8 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 getSelectedValue() 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/AnimationWindow.cpp b/dependencies/subprojects/animationwindow/src/AnimationWindow.cpp index 9ab25680b1327ae948a94f639e0d3f1926d85d1c..15385aa28a636895426e77632393ada62d750704 100644 --- a/dependencies/subprojects/animationwindow/src/AnimationWindow.cpp +++ b/dependencies/subprojects/animationwindow/src/AnimationWindow.cpp @@ -50,7 +50,7 @@ TDT4102::AnimationWindow::AnimationWindow(int x, int y, int width, int height, c std::cout << "Created an SDL renderer with name: " << rendererInfo.name << std::endl; context = nk_sdl_init(windowHandle, rendererHandle); - fontCache.initialise(); + fontCache.initialize(); fontCache.setFont(context, Font::defaultFont, 18); nk_clear(context); } diff --git a/dependencies/subprojects/animationwindow/src/internal/FontCache.cpp b/dependencies/subprojects/animationwindow/src/internal/FontCache.cpp index 7a441a85c71c165dd56c14ab554e24388948459c..1051bc0489b823242e5ec90b5fc303b6b1bed786 100644 --- a/dependencies/subprojects/animationwindow/src/internal/FontCache.cpp +++ b/dependencies/subprojects/animationwindow/src/internal/FontCache.cpp @@ -66,7 +66,7 @@ void TDT4102::internal::FontCache::setFont(nk_context *context, TDT4102::Font fa } -void TDT4102::internal::FontCache::initialise() { +void TDT4102::internal::FontCache::initialize() { for(const std::pair<const TDT4102::Font, std::vector<std::string>> &fontFaceAlternatives : TTFFilenames) { bool suitableFontFound = false; for(const std::string& fontFaceFile : fontFaceAlternatives.second) { diff --git a/dependencies/subprojects/animationwindow/src/widgets/DropdownList.cpp b/dependencies/subprojects/animationwindow/src/widgets/DropdownList.cpp index 3a836a04f1106449a64ffca2cef46cdc2b9dc8da..c22eedf2f2d7b1fd45600cb5e712b0bba589b405 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} { - if(options.size() == 0) { +TDT4102::DropdownList::DropdownList(TDT4102::Point location, unsigned int width, unsigned int height, std::vector<std::string> &initialOptions) + : TDT4102::Widget(location, width, height) { + if(initialOptions.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::getSelectedValue() 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..a0edfc996dd44a3e779f1f2cc323061de733878e 100644 --- a/dependencies/subprojects/animationwindow/src/widgets/TextInput.cpp +++ b/dependencies/subprojects/animationwindow/src/widgets/TextInput.cpp @@ -1,7 +1,7 @@ #include "widgets/TextInput.h" void TDT4102::TextInput::update(nk_context *context) { - nk_edit_string_zero_terminated(context, NK_EDIT_SELECTABLE | NK_EDIT_ALWAYS_INSERT_MODE | NK_EDIT_BOX | NK_EDIT_SIMPLE, contents.data(), internal::TEXT_INPUT_CHARACTER_LIMIT, nk_filter_ascii); + nk_edit_string_zero_terminated(context, NK_EDIT_SELECTABLE | NK_EDIT_ALWAYS_INSERT_MODE | NK_EDIT_BOX | NK_EDIT_SIMPLE, const_cast<char*>(contents.data()), internal::TEXT_INPUT_CHARACTER_LIMIT, nk_filter_ascii); // Detect whether any editing of the string has occurred // Nuklear only reports whether the text box has lost focus @@ -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());