Working on some fixes for widget resize issues. This is hacky as fuck and the branch is only meant to serve as a way to share the hacky fixes between developers. Some fixes are outside of ReJUI and will not be committed since they need to be properly addressed in ReWindow. GLHF

This commit is contained in:
2024-07-16 09:00:12 -04:00
parent 6d2177dcba
commit be628e5d88
3 changed files with 24 additions and 1 deletions

View File

@@ -14,6 +14,7 @@
#include <JUI/Rect.hpp>
#include <JUI/Scene.hpp>
#include <rewindow/types/window.h>
#include <jlog/jlog.hpp>
class JUIDevelopmentTestWindow : public ReWindow::RWindow {
@@ -45,6 +46,7 @@ JUI::Scene* CreateScene() {
Scene* root = new Scene();
Rect* element = new Rect(root);
element->SetName("jimbob");
element->SetBGColor({0,255,0});
auto size = UDim2(64, 64, 0, 0);
element->SetSize({0, 0, 1.f, 1.f});
@@ -56,6 +58,8 @@ int main()
auto* scene = CreateScene();
JUI::Rect element = scene->FindFirstChild("jimbob");
auto* window = new JUIDevelopmentTestWindow("Test Window", 600, 480);
window->setRenderer(RenderingAPI::OPENGL);
window->Open();
@@ -69,6 +73,20 @@ int main()
window->pollEvents();
window->refresh();
scene->SetViewportSize(window->getWidth(), window->getHeight());
Vector2 winsz = window->getSize();
int wwidth = window->getWidth();
int wheight = window->getHeight();
//element.SetSize({wwidth, wheight, winsz.x, winsz.y});
//element.SetSize({0,0, winsz.x, winsz.y});
//element.SetSize({wwidth, wheight, (float)wwidth, (float)wheight});
//scene->SetViewportSize(window->getWidth(), window->getHeight());
DEBUG(std::format("Window sz x: {} y: {}", wwidth, wheight));
DEBUG(std::format("Window sz2 x: {} y: {}", winsz.x, winsz.y));
JUI::UDim2 esz = element.GetSize();
Vector2 escale = esz.GetScale();
Vector2 epix = esz.GetPixels();
DEBUG(std::format("Element scale x: {} y: {}", escale.x, escale.y));
DEBUG(std::format("Element pix x: {} y: {}", epix.x, epix.y));
scene->Update(0.f);
scene->Draw();
window->glSwapBuffers();

View File

@@ -25,7 +25,9 @@ namespace JUI {
//J2D::FillRoundedRect(bg_color, abs_pos, abs_size, corner_rounding_radius);
J2D::Begin();
J2D::FillRect(bg_color, abs_pos, abs_size);
//J2D::FillRect(bg_color, abs_pos, abs_size);
//J2D::FillRect(bg_color, abs_pos, root_size);
J2D::FillRect(bg_color, abs_size/2, abs_size);
// Outline rect
if (corner_rounding_radius >= 0)
J2D::OutlineRect(border_color, abs_pos, abs_size);

View File

@@ -1,4 +1,5 @@
#include <JUI/Scene.hpp>
#include <jlog/jlog.hpp>
namespace JUI {
Scene::Scene(): Widget() {}
@@ -8,10 +9,12 @@ namespace JUI {
Vector2 Scene::GetAbsoluteSize() const { return {(float)viewport_w,(float)viewport_h};}
void Scene::Draw() {
DEBUG("Drawing widget")
Widget::Draw();
}
void Scene::SetViewportSize(int w, int h) {
DEBUG(std::format("Setting scene viewport size to x: {} y: {}", w, h));
viewport_w = w;
viewport_h = h;
}