Project

General

Profile

Actions

Bug #11875

open

WBoxLayout incorrectly calculates the size of scrollable widgets

Added by Andreas Frolov 9 months ago. Updated 6 months ago.

Status:
InProgress
Priority:
Normal
Target version:
Start date:
08/15/2023
Due date:
% Done:

0%

Estimated time:

Description

I expect in my example that the widgets with the same scale factor get the same size. Unfortunately it isn't. The large content view gets more space than a short content view.

But if I set the preferred layout implementation globally to JavaScript and the preferred layout implementation of concrete layout to Flex then it works as expected. This surprised me because the BoxLayout has Flex implementation by default.

That would be a workaround but in one case it doesn't work. If the view with short content (v1 in my example) has a scale factor greater than 0 and the other has none, then the view v1 will not be displayed.

void showLayout()
{
  auto m1 = std::make_shared<Wt::WStandardItemModel>(1, 1);
  auto m2 = std::make_shared<Wt::WStandardItemModel>(10, 1); // The content takes up more than half of the space provided

  auto layout = std::make_unique<Wt::WVBoxLayout>();
  //layout->setPreferredImplementation(Wt::LayoutImplementation::Flex);

  auto v1 = layout->addWidget(std::make_unique<Wt::WTreeView>()/*, 1*/);
  v1->setModel(m1);
  auto v2 = layout->addWidget(std::make_unique<Wt::WTreeView>()/*, 1*/);
  v2->setModel(m2);

  auto c = Wt::WApplication::instance()->root()->addWidget(std::make_unique<Wt::WContainerWidget>());
  c->setLayout(std::move(layout));
  c->resize(200, 200);
}

class Application : public Wt::WApplication
{
public:
  Application(const Wt::WEnvironment& env);
};

Application::Application(const Wt::WEnvironment& env)
  : Wt::WApplication(env)
{
    showLayout();
}

int main(int argc, char **argv)
{
  //Wt::WLayout::setDefaultImplementation(Wt::LayoutImplementation::JavaScript);

  return Wt::WRun(argc, argv, [](const Wt::WEnvironment& env) {
    return std::make_unique<Application>(env);
  });
}
Actions #1

Updated by Matthias Van Ceulebroeck 8 months ago

  • Target version set to 4.10.2
Actions #2

Updated by Matthias Van Ceulebroeck 8 months ago

  • Status changed from New to InProgress
  • Assignee set to Matthias Van Ceulebroeck
Actions #3

Updated by Matthias Van Ceulebroeck 6 months ago

  • Target version changed from 4.10.2 to 4.10.3
Actions

Also available in: Atom PDF