Skip to content
Snippets Groups Projects

added colors to textinput

Merged Joakim Borge Hunskår requested to merge add-color-to-textinput into main
2 files
+ 25
0
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -2,6 +2,7 @@
@@ -2,6 +2,7 @@
#include "Widget.h"
#include "Widget.h"
#include "Point.h"
#include "Point.h"
 
#include "Color.h"
#include <string>
#include <string>
namespace TDT4102 {
namespace TDT4102 {
@@ -13,11 +14,21 @@ namespace TDT4102 {
@@ -13,11 +14,21 @@ namespace TDT4102 {
private:
private:
std::string contents;
std::string contents;
std::string previousContents;
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:
protected:
void update(nk_context* context) override;
void update(nk_context* context) override;
public:
public:
explicit TextInput(TDT4102::Point location, unsigned int width, unsigned int height, std::string initialText = "");
explicit TextInput(TDT4102::Point location, unsigned int width, unsigned int height, std::string initialText = "");
std::string getText() const;
std::string getText() const;
void setText(std::string text);
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
Loading