diff --git a/dependencies/subprojects/animationwindow/include/widgets/TextInput.h b/dependencies/subprojects/animationwindow/include/widgets/TextInput.h index 23867627ae92e4a6e82e6e29d935eb9e73b71d02..41edb7dfc613c6161fe317e6b0ee08e58978ff95 100644 --- a/dependencies/subprojects/animationwindow/include/widgets/TextInput.h +++ b/dependencies/subprojects/animationwindow/include/widgets/TextInput.h @@ -2,6 +2,7 @@ #include "Widget.h" #include "Point.h" +#include "Color.h" #include <string> namespace TDT4102 { @@ -13,11 +14,21 @@ namespace TDT4102 { private: std::string contents; std::string previousContents; + nk_color textColor = nk_rgba(175, 175, 175, 255); + nk_color boxColor = nk_rgba(50 , 50, 50, 255); + nk_color boxColorHover = nk_rgba(50 , 50, 50, 255); + nk_color boxColorActive = nk_rgba(50 , 50, 50, 255); + nk_color borderColor = nk_rgba(50, 50, 50, 255); protected: void update(nk_context* context) override; public: explicit TextInput(TDT4102::Point location, unsigned int width, unsigned int height, std::string initialText = ""); std::string getText() const; void setText(std::string text); + void setTextColor(TDT4102::Color newColor) {textColor = nk_color{(nk_byte)newColor.redChannel, (nk_byte)newColor.greenChannel, (nk_byte)newColor.blueChannel, (nk_byte)newColor.alphaChannel};} + void setBoxColor(TDT4102::Color newColor) {boxColor = nk_color{(nk_byte)newColor.redChannel, (nk_byte)newColor.greenChannel, (nk_byte)newColor.blueChannel, (nk_byte)newColor.alphaChannel};} + void setBoxColorHover(Color newColor) {boxColorHover = nk_color{(nk_byte)newColor.redChannel, (nk_byte)newColor.greenChannel, (nk_byte)newColor.blueChannel, (nk_byte)newColor.alphaChannel};} + void setBoxColorActive(Color newColor) {boxColorActive = nk_color{(nk_byte)newColor.redChannel, (nk_byte)newColor.greenChannel, (nk_byte)newColor.blueChannel, (nk_byte)newColor.alphaChannel};} + void setBorderColor(TDT4102::Color newColor) {borderColor = nk_color{(nk_byte)newColor.redChannel, (nk_byte)newColor.greenChannel, (nk_byte)newColor.blueChannel, (nk_byte)newColor.alphaChannel};} }; } \ 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 a0edfc996dd44a3e779f1f2cc323061de733878e..8fe1efab23adebef08c925fdf5ea774a5b4f8ff9 100644 --- a/dependencies/subprojects/animationwindow/src/widgets/TextInput.cpp +++ b/dependencies/subprojects/animationwindow/src/widgets/TextInput.cpp @@ -1,6 +1,13 @@ #include "widgets/TextInput.h" void TDT4102::TextInput::update(nk_context *context) { + struct nk_style* s = &context->style; + nk_style_push_color(context, &s->edit.text_normal, textColor); + nk_style_push_color(context, &s->edit.text_hover, textColor); + nk_style_push_color(context, &s->edit.text_active, textColor); + nk_style_push_style_item(context, &s->edit.normal, nk_style_item_color(boxColor)); + nk_style_push_style_item(context, &s->edit.hover, nk_style_item_color(boxColorHover)); + nk_style_push_style_item(context, &s->edit.active, nk_style_item_color(boxColorActive)); 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 @@ -9,6 +16,13 @@ void TDT4102::TextInput::update(nk_context *context) { fire(); } previousContents = contents; + + nk_style_pop_color(context); + nk_style_pop_color(context); + nk_style_pop_color(context); + nk_style_pop_style_item(context); + nk_style_pop_style_item(context); + nk_style_pop_style_item(context); } TDT4102::TextInput::TextInput(TDT4102::Point location, unsigned int width, unsigned int height, std::string initialText)