Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

box renderer: Allow for shapes with radius bigger than box width (or height) #415

Open
peter-ha opened this issue Jul 21, 2024 · 1 comment
Assignees
Labels
Scenegraph Code related to the Qt/QSG classes
Milestone

Comments

@peter-ha
Copy link
Collaborator

Problem: I have a box with relative radius 100%:

Screenshot from 2024-07-21 16-50-48

Now when the width of the box gets smaller, I want the radius still be of the same size, but it gets squeezed:

Screenshot from 2024-07-21 16-49-43

We have this use case for the new Material sliders (#413).

I wonder if there is a way to introduce a mode where the radius stays the same, even if it exceeds the width (or height) of the box. I haven't looked at the box renderer code yet whether this is feasible...

@peter-ha
Copy link
Collaborator Author

This is how I reproduced it:

#include "QskBox.h"
#include "QskBoxShapeMetrics.h"
#include "QskLinearBox.h"
#include "QskWindow.h"

#include <SkinnyShortcut.h>
#include <SkinnyNamespace.h>

#include <QDebug>
#include <QGuiApplication>
#include <QTimer>
#include <qnamespace.h>

int main( int argc, char* argv[] )
{
    QGuiApplication app( argc, argv );

    SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );

    QskWindow window;

    auto* l = new QskLinearBox(window.contentItem());

    auto* box = new QskBox(l);
    box->setPanel(true);
    box->setGradientHint(QskBox::Panel, Qt::magenta);
    box->setFixedSize(150,50);
    box->setBoxShapeHint(QskBox::Panel, {25, 25, 25, 25});

    auto* t = new QTimer(&app);
    QObject::connect(t, &QTimer::timeout, box, [box]()
    {
        static qreal w = 150;
        static bool shrink = true;
        if((w<=0 && shrink) || (w>=150 && !shrink))
        {
            shrink = !shrink;
        }

        w = shrink ? w-5 : w+5;
        box->setFixedWidth(w);
    });
    t->start(50);

    window.resize( 150, 50 );
    window.show();

    return app.exec();
}

@uwerat uwerat added the Scenegraph Code related to the Qt/QSG classes label Sep 19, 2024
@uwerat uwerat self-assigned this Oct 25, 2024
@uwerat uwerat added this to the Qskinny 0.0.x milestone Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scenegraph Code related to the Qt/QSG classes
Projects
None yet
Development

No branches or pull requests

2 participants