diff --git a/src/ui/GLPanel.cpp b/src/ui/GLPanel.cpp index b3839b6..3f0f094 100644 --- a/src/ui/GLPanel.cpp +++ b/src/ui/GLPanel.cpp @@ -264,8 +264,8 @@ void GLPanel::draw(CubicVR::mat4 transform_in, GLPanel *parent) { std::cout << umin << " :: " << ucenter << " :: " << pdim << " :: " << pvec << std::endl; if (marginPx.left || marginPx.right || marginPx.top || marginPx.bottom) { - localTransform *= mat4::translate(marginPx.left*pvec.x, marginPx.top*pvec.y, 0) * - mat4::scale(1.0-(marginPx.left+marginPx.right)*pvec.x, 1.0-(marginPx.top+marginPx.bottom)*pvec.y, 0); + localTransform *= mat4::translate(marginPx.left*pvec.x/size[0], marginPx.top*pvec.y/size[1], 0) * + mat4::scale(1.0-(marginPx.left+marginPx.right)*pvec.x/size[0], 1.0-(marginPx.top+marginPx.bottom)*pvec.y/size[1], 0); transform = transform_in * localTransform; } diff --git a/src/ui/UITestContext.cpp b/src/ui/UITestContext.cpp index 8c43e10..b06cdb0 100644 --- a/src/ui/UITestContext.cpp +++ b/src/ui/UITestContext.cpp @@ -12,19 +12,19 @@ PrimaryGLContext(canvas, sharedContext) { testPanel.setFillColor(RGB(0.0,0.0,1.0), RGB(0.0,1.0,0.0)); testChildPanel.setPosition(0.0, 0.0); - testChildPanel.setMarginPx(10); - testChildPanel.setSize(1.0, 0.3); + testChildPanel.setMarginPx(10,10,10,5); + testChildPanel.setSize(1.0, 0.5); testChildPanel.setFill(GLPanel::GLPANEL_FILL_GRAD_BAR_X); testChildPanel.setFillColor(RGB(0.0,0.0,1.0), RGB(0.0,1.0,0.0)); testChildPanel.setBorderPx(1); - testChildPanel2.setPosition(0.0, 0.3); - testChildPanel2.setSize(1.0, 0.3); - testChildPanel2.setMarginPx(10); + testChildPanel2.setPosition(0.0, 0.5); + testChildPanel2.setSize(1.0, 0.5); + testChildPanel2.setMarginPx(10,10,5,10); testChildPanel2.setFill(GLPanel::GLPANEL_FILL_GRAD_X); testChildPanel2.setFillColor(RGB(0.0,0.0,1.0), RGB(0.0,1.0,0.0)); testChildPanel2.setBorderColor(RGB(1.0,0.0,0.0)); - testChildPanel2.setBorderPx(2,4,6,8); + testChildPanel2.setBorderPx(1); testPanel.addChild(&testChildPanel); testPanel.addChild(&testChildPanel2);