Fix issue with default-initialization of fonts as garbage data in JUI.
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <J3ML/LinearAlgebra.hpp>
|
||||
#include <Color4.hpp>
|
||||
#include <JGL/JGL.h>
|
||||
#include <JGL/types/Font.h>
|
||||
|
||||
using J3ML::LinearAlgebra::Vector2;
|
||||
@@ -120,7 +121,7 @@ namespace JUI
|
||||
TextAlign::H h_align = TextAlign::H::Left;
|
||||
TextAlign::V v_align = TextAlign::V::Top;
|
||||
TextOverflowMode overflow_mode;
|
||||
JGL::Font set_font = JGL::Font("assets/fonts/Jupiteroid.ttf");
|
||||
JGL::Font set_font = JGL::Fonts::Jupiteroid;
|
||||
u32 text_size = 12;
|
||||
|
||||
};
|
||||
|
@@ -45,6 +45,9 @@ namespace JUI
|
||||
public:
|
||||
UtilityBar() : Rect()
|
||||
{
|
||||
// TODO: Make a note that all JGL::Font members on widgets need to be initialized to JGL::Fonts::Jupiteroid inside the constructor.
|
||||
font = JGL::Fonts::Jupiteroid;
|
||||
|
||||
this->Size({0, 20, 1, 0});
|
||||
this->Position({0,0,0,0});
|
||||
this->BGColor(Colors::White);
|
||||
|
18
main.cpp
18
main.cpp
@@ -25,7 +25,6 @@
|
||||
#include <JUI/Widgets/Checkbox.hpp>
|
||||
#include <rewindow/types/window.h>
|
||||
|
||||
JGL::Font Jupiteroid;
|
||||
JUI::Scene* scene;
|
||||
JGL::Texture* sample_texture;
|
||||
|
||||
@@ -36,14 +35,12 @@ JUI::Scene* CreateScene() {
|
||||
|
||||
auto* topbar = new UtilityBar(root);
|
||||
topbar->ZIndex(3);
|
||||
topbar->SetFont(Jupiteroid);
|
||||
auto* file = topbar->AddButton("File");
|
||||
file->SetTooltip("This Dick Nigga", 0.5f);
|
||||
|
||||
file->OnClickEvent += [&, root, file] (Vector2 pos, JUI::MouseButton btn)
|
||||
{
|
||||
auto* ctx_menu = new ContextMenu(root);
|
||||
ctx_menu->SetFont(Jupiteroid);
|
||||
ctx_menu->Position(UDim2(0,20,0,0));
|
||||
ctx_menu->AddItem("A");
|
||||
ctx_menu->AddItem("B");
|
||||
@@ -78,7 +75,6 @@ JUI::Scene* CreateScene() {
|
||||
auto* button = new TextButton(s1_vert);
|
||||
//button->Position({5, 105, 0, 0});
|
||||
button->Size({0, 35, 1, 0});
|
||||
button->SetFont(Jupiteroid);
|
||||
button->SetTextColor(Colors::Black);
|
||||
button->SetContent("Button");
|
||||
button->AlignLeft();
|
||||
@@ -87,7 +83,6 @@ JUI::Scene* CreateScene() {
|
||||
auto* button2 = new TextButton(s1_vert);
|
||||
//button2->Position({5, 105, 0, 0});
|
||||
button2->Size({0, 35, 1, 0});
|
||||
button2->SetFont(Jupiteroid);
|
||||
button2->SetTextColor(Colors::Black);
|
||||
button2->SetContent("Button");
|
||||
button2->AlignCenterHorizontally();
|
||||
@@ -95,7 +90,6 @@ JUI::Scene* CreateScene() {
|
||||
auto* button3 = new TextButton(s1_vert);
|
||||
//button2->Position({5, 105, 0, 0});
|
||||
button3->Size({0, 35, 1, 0});
|
||||
button3->SetFont(Jupiteroid);
|
||||
button3->SetTextColor(Colors::Black);
|
||||
button3->SetContent("Button");
|
||||
button3->AlignRight();
|
||||
@@ -222,7 +216,6 @@ JUI::Scene* CreateScene() {
|
||||
*/
|
||||
// Window //
|
||||
auto* win_element = new JUI::Window(root);
|
||||
win_element->SetTitleFont(Jupiteroid);
|
||||
win_element->CornerRounding(5);
|
||||
win_element->Size({50_percent, 50_percent});
|
||||
win_element->SetTitle("Window Widget");
|
||||
@@ -240,7 +233,6 @@ JUI::Scene* CreateScene() {
|
||||
|
||||
TextRect* a = new TextRect(list);
|
||||
a->SetTextSize(16);
|
||||
a->SetFont(Jupiteroid);
|
||||
a->Size({0, 20, 1, 0});
|
||||
//a->FitText(true);
|
||||
a->Center();
|
||||
@@ -253,7 +245,6 @@ JUI::Scene* CreateScene() {
|
||||
//b->FitText(true);
|
||||
b->Size({0, 20, 1, 0});
|
||||
b->Center();
|
||||
b->SetFont(Jupiteroid);
|
||||
|
||||
root->SetViewportSize({800, 600});
|
||||
|
||||
@@ -264,10 +255,8 @@ class JUIDevelopmentTestWindow : public ReWindow::RWindow {
|
||||
public:
|
||||
|
||||
void initGL() {
|
||||
gladLoadGL();
|
||||
JGL::Init(GetSize(), 0.f, 0.f);
|
||||
bool result = JGL::Init(GetSize(), 0.f, 0.f);
|
||||
JGL::Update(GetSize());
|
||||
//JGL::InitTextEngine();
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
|
||||
// TODO: Delete when we update to the next release of JGL
|
||||
@@ -334,7 +323,6 @@ public:
|
||||
int main()
|
||||
{
|
||||
|
||||
|
||||
using namespace ReWindow;
|
||||
// TODO: Find out new jlog api for silencing specific loggers.
|
||||
|
||||
@@ -350,14 +338,10 @@ int main()
|
||||
|
||||
JGL::Update({800, 600});
|
||||
|
||||
Jupiteroid = JGL::Font("assets/fonts/Jupiteroid.ttf");
|
||||
sample_texture = new JGL::Texture("assets/ld.png");
|
||||
scene = CreateScene();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
window->OnResizeRequestEvent += [&] (ReWindow::WindowResizeRequestEvent e){
|
||||
Vector2 size = e.Size;//window->getLastKnownResize();
|
||||
scene->SetViewportSize(size);
|
||||
|
@@ -109,7 +109,9 @@ namespace JUI {
|
||||
set_font = font;
|
||||
}
|
||||
|
||||
TextBase::TextBase() {}
|
||||
TextBase::TextBase() {
|
||||
SetFont(JGL::Fonts::Jupiteroid);
|
||||
}
|
||||
|
||||
void TextBase::SetTextSize(u32 size) {
|
||||
text_size = size;
|
||||
|
Reference in New Issue
Block a user