Project

General

Profile

Curious behaviour of WGridLayout

Added by Benjamin Kloster almost 11 years ago

Hi everyone,

I'm playing around with WGridLayout and have some trouble with it. Consider the following program:

#include <Wt/WApplication>
#include <Wt/WColor>
#include <Wt/WContainerWidget>
#include <Wt/WGridLayout>
#include <Wt/WText>

static Wt::WText*
getText(
    const Wt::WString& text,
    const char* colorName
) {
    Wt::WColor color(colorName);
    Wt::WText* widget = new Wt::WText(text);
    Wt::WCssDecorationStyle decoration;
    decoration.setBackgroundColor(color);
    widget->setDecorationStyle(decoration);
    return widget;
}


class GridDemoApplication : public Wt::WApplication
{
public:

    GridDemoApplication(
        const Wt::WEnvironment& env
    ) : Wt::WApplication(env) {
        this->root()->setOverflow(Wt::WContainerWidget::OverflowAuto);
        Wt::WGridLayout* layout = new Wt::WGridLayout(this->root());
        // A
        Wt::WText* a = getText("A", "red");
        layout->addWidget(a, 0, 0, 1, 1);
        // B
        Wt::WText* b = getText("B", "blue");
        layout->addWidget(b, 1, 0, 1, 1);
    }

private:
};


Wt::WApplication 
*createApplication(
    const Wt::WEnvironment& env
) {
    return new GridDemoApplication(env);
}

int 
main(
    int argc, 
    char **argv
) {
    return Wt::WRun(argc, argv, &createApplication);
}

I'm linking against wt and wthttp and running the server with

 grid_demo --docroot . --http-address 0.0.0.0 --http-port 9090 

the environment is an Ubuntu 64 bit, gcc 4.7.3 and Wt 3.3.1.

This will render a simple webpage with a red rectangle (A) above a blue rectangle (B). Now change the row span of the blue text field to 2. I would expect the page to be one third red, two thirds blue after that. Instead, it's all red and inspection of the page source shows that the "B" field has a height of 0 px. Even stranger is the behaviour when changing the row span of the red text field to 2. It will receive a zero height, just as the blue field, but said blue text field disappears completely. I can reproduce this in both Firefox and Chromium.

Am I doing something wrong, or is this a bug?


Replies (2)

RE: Curious behaviour of WGridLayout - Added by Koen Deforche almost 11 years ago

Hey,

I tried your test case and get the same behaviour, even with latest git. This is clearly a bug. I know we made some short-cuts in supporting rowspan and colspan, especially (or perhaps only) when they also have no functional behavior in the sense that they make one item combine cells which sibling columns/rows have as separate.

Rowspan/colspan does not have an effect on stretch and excess space redistribution: so the correct behavior should be that rowspan simply has no effect in your example.

Regards,

koen

RE: Curious behaviour of WGridLayout - Added by Benjamin Kloster almost 11 years ago

Thanks for confirming that I'm not the only one with this problem. I've created an issue for this.

    (1-2/2)