updated GUI classes

This commit is contained in:
devZoGok
2026-08-03 15:45:18 +03:00
parent 9b2a5e7502
commit 6edc143013
5 changed files with 26 additions and 26 deletions
+6 -6
View File
@@ -1,7 +1,3 @@
#include <locale>
#include <codecvt>
#include <glfw3.h>
#include "root.h"
#include "quad.h"
#include "node.h"
@@ -11,6 +7,10 @@
#include "util.h"
#include "button.h"
#include <locale>
#include <codecvt>
#include <glfw3.h>
using namespace std;
using namespace vb01;
@@ -28,7 +28,7 @@ namespace vb01Gui{
guiNode = root->getGuiNode();
rect = new Quad(Vector3(size.x, size.y, 0), false);
rectNode = new Node(pos);
Material *mat = new Material(root->getLibPath() + "gui");
Material *mat = new Material(root->getGuiShader());
if(imagePath == ""){
mat->addBoolUniform(texUni, false);
@@ -54,7 +54,7 @@ namespace vb01Gui{
textNode = new Node(pos + textOffset, Quaternion::QUAT_W, Vector3(sc, sc, 1));
textNode->addText(text);
Material *textMat = new Material(root->getLibPath() + "text");
Material *textMat = new Material(root->getGuiShader());
textMat->addBoolUniform(texUni, false);
textMat->addVec4Uniform(diffColUni, Vector4::VEC_IJKL);
text->setMaterial(textMat);
+6 -6
View File
@@ -1,5 +1,3 @@
#include <glfw3.h>
#include "listbox.h"
#include "util.h"
#include "node.h"
@@ -8,6 +6,8 @@
#include "root.h"
#include "material.h"
#include <glfw3.h>
using namespace vb01;
using namespace std;
@@ -46,7 +46,7 @@ namespace vb01Gui{
guiNode = Root::getSingleton()->getGuiNode();
string texUni = "texturingEnabled", diffColUni = "diffuseColor";
textMat = new Material(root->getLibPath() + "text");
textMat = new Material(root->getGuiShader());
textMat->addBoolUniform(texUni, false);
textMat->addVec4Uniform(diffColUni, Vector4::VEC_IJKL);
@@ -65,7 +65,7 @@ namespace vb01Gui{
Quad *selRect = new Quad(Vector3(size.x, size.y, 0), false);
selRectNode = new Node(Vector3(size.x, size.y, -.05));
Material *mat = new Material(root->getLibPath() + "gui");
Material *mat = new Material(root->getGuiShader());
mat->addBoolUniform(texUni, false);
mat->addVec4Uniform(diffColUni, Vector4(.6, .35, .05, 1));
selRect->setMaterial(mat);
@@ -203,14 +203,14 @@ namespace vb01Gui{
}
void Listbox::changeLine(int id, wstring change){
lines[id]->setText(change);
lines[id]->setEntry(change);
}
std::vector<wstring> Listbox::getContents(){
std::vector<wstring> lines;
for(Text *t : this->lines)
lines.push_back(t->getText());
lines.push_back(t->getEntry());
return lines;
}
+4 -5
View File
@@ -1,12 +1,11 @@
#include <glfw3.h>
#include <sstream>
#include <algorithm>
#include "slider.h"
#include "root.h"
#include "util.h"
#include <glfw3.h>
#include <sstream>
#include <algorithm>
using namespace std;
using namespace vb01;
+9 -8
View File
@@ -27,9 +27,10 @@ namespace vb01Gui{
textboxButton = new TextboxButton(this, pos, size, "TextboxButton");
string libPath = Root::getSingleton()->getLibPath();
guiNode = Root::getSingleton()->getGuiNode();
Root *root = Root::getSingleton();
guiNode = root->getGuiNode();
text = new Text(fontPath, entry);
Material *textMat = new Material(libPath + "text");
Material *textMat = new Material(root->getGuiShader());
textMat->addBoolUniform("texturingEnabled", false);
textMat->addVec4Uniform("diffuseColor", Vector4(1, 1, 1, 1));
text->setMaterial(textMat);
@@ -42,7 +43,7 @@ namespace vb01Gui{
cursorPosOffset = entry.length();
cursorRect = new Quad(Vector3(cursorWidth, size.y, 0), false);
cursorNode = new Node(Vector3(pos.x + text->getLength(), pos.y, pos.z + cursorZCoord));
Material *mat = new Material(libPath + "gui");
Material *mat = new Material(root->getGuiShader());
mat->addBoolUniform("texturingEnabled", false);
mat->addVec4Uniform("diffuseColor", Vector4(1, 1, 1, 1));
cursorRect->setMaterial(mat);
@@ -73,8 +74,8 @@ namespace vb01Gui{
void Textbox::type(u32 c, bool capitalLetters){
entry += c;
text->setText(entry);
moveCursor(false, text->getGlyph(c)->size.x);
text->setEntry(entry);
moveCursor(false, text->getFont()->getGlyph(c).size.x);
}
void Textbox::moveCursor(bool left, float charWidth){
@@ -94,8 +95,8 @@ namespace vb01Gui{
if(entry.length() > 0 && canDeleteChar()){
char c = entry.c_str()[entry.length() - 1];
entry = entry.substr(0, entry.length() - 1);
text->setText(entry);
moveCursor(true, text->getGlyph(c)->size.x);
text->setEntry(entry);
moveCursor(true, text->getFont()->getGlyph(c).size.x);
lastDeleteTime = getTime();
}
}
@@ -124,7 +125,7 @@ namespace vb01Gui{
void Textbox::setEntry(wstring entry){
this->entry = entry;
text->setText(entry);
text->setEntry(entry);
cursorNode->setPosition(Vector3(pos.x + text->getLength(), pos.y, cursorZCoord));
cursorPosOffset = entry.length();
}
+1 -1
View File
@@ -27,7 +27,7 @@ namespace vb01Gui{
void remove();
inline void setSlider(Slider *s){this->slider = s;}
inline bool isEnabled(){return enabled;}
inline std::wstring getText(){return text->getText();}
inline std::wstring getText(){return text->getEntry();}
inline void setDeleteCharacters(bool del){this->deleteCharacters = del;}
inline bool isDeleteCharacters(){return deleteCharacters;}
private: