Project

General

Profile

stretch = 0 has no effect in the WBoxLayout::addWidget() method

Added by Ali Ali 23 days ago

As stated in this document:

https://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1WBoxLayout.html#a2e3e6bcd3a059fd9780ac2b584a9e07b

when stretch = 0, the widget size is not changed by the layout manager, but in reality this is not the case and the flex property value of the added widget is equal to 1 1 auto when it should be equal to 0 0 auto.


Replies (1)

RE: stretch = 0 has no effect in the WBoxLayout::addWidget() method - Added by Matthias Van Ceulebroeck about 24 hours ago

Hello Ali,

I do believe that this renders out correctly?

E.g. (taken from your flex example code)

auto topBox = root()->addNew<Wt::WContainerWidget>();                                                                                                                                                                                                    
auto topLayout = topBox->setLayout<Wt::WVBoxLayout>(std::make_unique<Wt::WVBoxLayout>());

// widget should have "flex: 0 0 auto"
topLayout->addWidget(std::make_unique<Wt::WContainerWidget>(), 0, Wt::AlignmentFlag::Top);

Which renders out to:

<!-- ROOT -->
<div id="o4" style="height:100.0%;">
  <!-- topBox -->
  <div id="ot" style="padding:9px 9px 9px 9px;display:flex;flex-flow:column;-moz-flex-flow:column;">
    <!-- topLayout -->
    <div id="wow" flg="0" style="display: flex; flex: 1 1 auto; flex-flow: column; justify-content: flex-start; overflow: hidden;">
      <!-- widget with "flex: 0 0 auto" -->
      <div id="ow" style="flex:0 0 auto;-moz-flex:0 0 auto;">
      </div>
    </div>
  </div>
</div>

that seems to be right to me.

If you have a counterexample, please let me know!

Best,
Matthias

    (1-1/1)