Browse Source

link to node for value passing, win guard, unroll loop, need node value up to date

master
Odilitime 5 years ago
parent
commit
d1ed073719
  1. 23
      src/graphics/components/InputComponent.cpp
  2. 1
      src/graphics/components/InputComponent.h

23
src/graphics/components/InputComponent.cpp

@ -63,9 +63,9 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r @@ -63,9 +63,9 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r
initialWindowWidth = windowWidth;
initialWindowHeight = windowHeight;
for (int i = 0; i < 3; i++) {
data[0][0][i] = 0xf0; // set RGB color
}
data[0][0][0] = 0xf0; // set R color
data[0][0][1] = 0xf0; // set G color
data[0][0][2] = 0xf0; // set B color
data[0][0][3] = 0xff; // set alpha
float vx = rawX;
@ -139,6 +139,7 @@ void InputComponent::render() { @@ -139,6 +139,7 @@ void InputComponent::render() {
}
verticesDirty = false;
}
glBindVertexArray(vertexArrayObject);
glErr=glGetError();
if(glErr != GL_NO_ERROR) {
@ -190,7 +191,9 @@ void InputComponent::render() { @@ -190,7 +191,9 @@ void InputComponent::render() {
cursorTimer = scheduler->setInterval([this]() {
this->showCursor = !this->showCursor;
//std::cout << "showCursor " << this->showCursor << std::endl;
this->win->renderDirty = true;
if (this->win) {
this->win->renderDirty = true;
}
}, 500);
// render it if we need to
@ -237,7 +240,7 @@ void InputComponent::resize(const int passedWindowWidth, const int passedWindowH @@ -237,7 +240,7 @@ void InputComponent::resize(const int passedWindowWidth, const int passedWindowH
float vx = x;
float vy = y;
if (boundToPage) {
if (this->boundToPage) {
vy = this->windowHeight + y - height;
//std::cout << "InputComponent::resize - Adjust y to " << vy << " from " << y << " h: " << (int)height << std::endl;
}
@ -301,6 +304,16 @@ void InputComponent::updateCursor() { @@ -301,6 +304,16 @@ void InputComponent::updateCursor() {
void InputComponent::updateText() {
//std::cout << "InputComponent::updateText - input value is now: " << value << std::endl;
if (this->node) {
std::map<std::string, std::string>::iterator it = this->node->properties.find("value");
if (it == this->node->properties.end()) {
this->node->properties.insert(std::make_pair("value", this->value));
} else {
it->second = this->value;
}
}
// maybe tie the fontsize to height
if (userInputText) {
delete userInputText;

1
src/graphics/components/InputComponent.h

@ -32,6 +32,7 @@ public: @@ -32,6 +32,7 @@ public:
std::shared_ptr<timer_handle> cursorTimer = nullptr;
// store for cursor
int estWidth;
TagNode *node = nullptr;
};
#endif

Loading…
Cancel
Save