Project

General

Profile

WPopupWidget and Layouts

Added by Aaron Wright about 7 years ago

I have a popup widget nested inside of several containers and layout managers. When the popup is shown, the layout manager expands the container to the size of the popup.

I tried to write a minimal example, but I couldn't reproduce it in a minimal case. I was just curious if there some special sauce I need to be aware of when nesting a popup inside a composite widget implemented by a container widget that is itself inside of a composite widget implemented by a container?

I'll keep trying to get to the minimal example.


Replies (5)

RE: WPopupWidget and Layouts - Added by Aaron Wright about 7 years ago

OK. I have an example that is somewhat minimal, and that demonstrates the problem. It has something to do with the stacked widget and the table view. If I change those up the problem goes away.

Please help!

#include <Wt/WApplication>
#include <Wt/WCompositeWidget>
#include <Wt/WContainerWidget>
#include <Wt/WEnvironment>
#include <Wt/WHBoxLayout>
#include <Wt/WPopupWidget>
#include <Wt/WPushButton>
#include <Wt/WServer>
#include <Wt/WStackedWidget>
#include <Wt/WStandardItem>
#include <Wt/WStandardItemModel>
#include <Wt/WTableView>

struct Three : Wt::WCompositeWidget
{
   Three(Wt::WContainerWidget* parent = NULL) : Wt::WCompositeWidget(parent)
   {
      Wt::WPushButton* impl = new Wt::WPushButton("Push");
      setImplementation(impl);

      Wt::WContainerWidget* popup_contents = new Wt::WContainerWidget();
      Wt::WPopupWidget* popup = new Wt::WPopupWidget(popup_contents, this);
      popup->setAnchorWidget(impl);
      popup->setTransient(true);

      impl->clicked().connect(popup, &Wt::WPopupWidget::show);

      m_model.invisibleRootItem()->setColumnCount(1);
      m_model.setHeaderData(0, std::string("Numbers"));

      m_model.appendRow(new Wt::WStandardItem("five"));
      m_model.appendRow(new Wt::WStandardItem("six"));
      m_model.appendRow(new Wt::WStandardItem("seven"));
      m_model.appendRow(new Wt::WStandardItem("eight"));
      m_model.appendRow(new Wt::WStandardItem("nine"));
      m_model.appendRow(new Wt::WStandardItem("ten"));

      Wt::WTableView* four = new Wt::WTableView(popup_contents);
      four->setModel(&m_model);
   }

private:

   Wt::WStandardItemModel m_model;
};

struct Two : Wt::WCompositeWidget
{
   Two(Wt::WContainerWidget* parent = NULL) : Wt::WCompositeWidget(parent)
   {
      Wt::WContainerWidget* impl = new Wt::WContainerWidget();
      setImplementation(impl);

      Wt::WHBoxLayout* layout = new Wt::WHBoxLayout(impl);

      Wt::WStackedWidget* stack = new Wt::WStackedWidget();
      layout->addWidget(stack);

      Wt::WContainerWidget* container = new Wt::WContainerWidget(stack);

      Wt::WHBoxLayout* layout2 = new Wt::WHBoxLayout(container);

      Three* three = new Three();
      layout2->addWidget(three);
   }
};

struct One : Wt::WCompositeWidget
{
   One(Wt::WContainerWidget* parent = NULL) : Wt::WCompositeWidget(parent)
   {
      Wt::WContainerWidget* impl = new Wt::WContainerWidget();
      setImplementation(impl);

      Two* two = new Two(impl);
   }
};

struct Application : Wt::WApplication
{
   Application(Wt::WEnvironment const& env) : Wt::WApplication(env)
   {
      One* one = new One(root());
      Two* two = new Two(root());
      Three* three = new Three(root());
   }
};

Wt::WApplication* session_handler(Wt::WEnvironment const& env)
{
   return new Application(env);
}

int main(int argc, char** argv)
{
   return Wt::WRun(argc, argv, boost::bind(&session_handler, _1));
}

RE: WPopupWidget and Layouts - Added by Roel Standaert about 7 years ago

That was indeed a regression, see: http://redmine.webtoolkit.eu/issues/5554

Regards,

Roel

RE: WPopupWidget and Layouts - Added by Aaron Wright about 7 years ago

Is this headed to github? Or do you have a patch?

RE: WPopupWidget and Layouts - Added by Roel Standaert about 7 years ago

I just pushed the fix to GitHub.

    (1-5/5)