Okay, I am testing with this code...
#include "Leadwerks.h"
using namespace UltraEngine;
class CustomWidget : public Panel {
protected:
virtual bool Initialize(const int x, const int y, const int width, const int height, shared_ptr<Widget> parent) {
blocks.resize(2);
return Widget::Initialize(text, x, y, width, height, parent, style);
}
void Draw(const int x, const int y, const int width, const int height) {
blocks[0].color = Vec4(0, 0, 1, 1);
blocks[0].wireframe = false;
blocks[0].position = 0;
blocks[0].size = this->size;
blocks[0].hidden = false;
blocks[1].hidden = false;
blocks[1].position = 0;
blocks[1].size = this->size;
blocks[1].SetText(text);
blocks[1].textalignment = TEXT_LEFT | TEXT_MIDDLE;
}
public:
static shared_ptr<CustomWidget> create(const int x, const int y, const int width, const int height, shared_ptr<Widget> parent) {
struct Struct : public CustomWidget {
};
auto instance = std::make_shared<Struct>();
instance->Initialize(x, y, width, height, parent);
return instance;
}
};
shared_ptr<Window> window;
shared_ptr<Framebuffer> framebuffer;
shared_ptr<World> menuWold;
shared_ptr<Interface> ui;
shared_ptr<Camera> uiCamera;
shared_ptr<CustomWidget> customWidget;
void initGui() {
uiCamera = CreateCamera(menuWold, PROJECTION_ORTHOGRAPHIC);
uiCamera->SetPosition((float)framebuffer->GetSize().x * 0.5f, (float)framebuffer->GetSize().y * 0.5f, 0);
uiCamera->SetRenderLayers(2);
uiCamera->SetClearMode(CLEAR_DEPTH);
auto default_font = LoadFont("Fonts\\arial.ttf");
ui = CreateInterface(uiCamera, default_font, framebuffer->GetSize());
ui->SetRenderLayers(2);
float scale = 1.0f;
customWidget = CustomWidget::create(10, 10, 800, 14 * scale, ui->root);
customWidget->SetText("ESCpppp123");
customWidget->SetFontScale(scale);
}
int main(int argc, const char* argv[]) {
auto displays = GetDisplays();
window = CreateWindow("Ultra Engine", 0, 0, 800, 250, displays[0], WINDOW_DEFAULT);
menuWold = CreateWorld();
framebuffer = CreateFramebuffer(window);
initGui();
while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) {
menuWold->Update();
menuWold->Render(framebuffer);
}
return 0;
}