You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.6 KiB

#include <GL/glew.h>
#include <string>
#include "BoxComponent.h"
#include "TextComponent.h"
#include "../../tools/TextBlock.h"
#include "../../tools/Scheduler.h"
class Window;
class InputComponent : public BoxComponent {
//: BoxComponent(rawX, rawY, rawWidth, rawHeight, passedWindowWidth, passedWindowHeight) { }
InputComponent(const float rawX, const float rawY, const float rawWidth, const float rawHeight, const int passedWindowWidth, const int passedWindowHeight);
// or
//using BoxComponent::BoxComponent;
void resize(const int passedWindowWidth, const int passedWindowHeight);
void render();
std::string getValue();
void setValue(std::string newValue);
// FIXME: change to using std::string
void addChar(char c);
void backSpace();
void updateCursor(int x, int y);
void updateText();
TextComponent *userInputText = nullptr;
BoxComponent *cursorBox = nullptr;
std::function<void(std::string value)> onEnter = nullptr;
// needed for our shader's resizing
int lastRenderedWindowHeight;
bool focused = false;
bool showCursor = true;
std::shared_ptr<timer_handle> cursorTimer = nullptr;
// store for cursor
int textScrollX = 0;
int textScrollY = 0;
int textCropX = 0;
int textCropY = 0;
int cursorLastX = 0;
int cursorLastY = 0;
int cursorCharX = 0;
int cursorCharY = 0;
TextBlock text;
TagNode *node = nullptr;
bool multiLine = false; // textarea control
//std::string value="";