Jump to content

In custom widget cornerradius does not make cornes rounded


Dreikblack
 Share

Recommended Posts

I don't know if it was changed intentionally somehow but several months ago blocks[0].radius used to make corners rounded

image.png.67b10002bc963bd2202def7514fc2b22.png

#include "UltraEngine.h"

using namespace UltraEngine;

class CustomWidget : public Panel
{
    CustomWidget::CustomWidget()
    {
        cornerradius = 8;
        blocks.resize(1);
    }

protected:

    virtual bool Initialize(const int x, const int y, const int width, const int height, shared_ptr<Widget> parent)
    {
        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 = color[WIDGETCOLOR_BACKGROUND];
	    blocks[0].wireframe = false;
	    blocks[0].position = iVec2(0);
	    blocks[0].size = size;
	    blocks[0].hidden = false;
        blocks[0].radius = cornerradius;
    }

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);
        instance->SetColor(0.5, 0.5, 0.5, 1, WIDGETCOLOR_BACKGROUND);
        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()
{
    auto default_font = LoadFont("Fonts\\arial.ttf");
    ui = CreateInterface(menuWold, default_font, framebuffer->GetSize());
    ui->SetRenderLayers(2);
    ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f);
    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);
    customWidget = CustomWidget::create(10, 50, 200, 50, ui->root);
}


int main(int argc, const char* argv[])
{
    //Get the displays
    auto displays = GetDisplays();

    //Create a window
    window = CreateWindow("Ultra Engine", 0, 0, 300, 300, displays[0], WINDOW_DEFAULT);

    //Create a world
    menuWold = CreateWorld();

    //Create a framebuffer
    framebuffer = CreateFramebuffer(window);

    //Create camera
    auto camera = CreateCamera(menuWold);
    camera->SetClearColor(0.125);
    camera->SetPosition(0, 0, -3);
    camera->SetFov(70);

    initGui();

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {       
        menuWold->Update();
        menuWold->Render(framebuffer);
    }
    return 0;
}

 

Link to comment
Share on other sites

Yeah, I was using vertices for the rounding and I think that is not good, so I disabled it. I think I want to do some CPU rasterization to generate images for rounded blocks, and for blocks with a gradient.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...