Hey Mike,
2010/6/23 Mike Teehan <[email protected]>:
> Greetings all,
>
> It the course of all my hacking today, I've managed to assemble a test case
> that shows some sort of layout rendering bug. Clicking on the "preview"
> column in the test case should hide the "editor" and show a second preview
> column, suitable for printing. The editor hide()s properly, and the second
> preview show()s up, but instead of being on the left side of the browser, they
> are on the right. Firebug leads me to believe that the editor is hiding its
> content, but still somehow taking up space.
The main gotcha here is that a layout manager does not consider the
visibility of a widget (hidden or shown) when doing the layout. Thus,
although the editor is being hidden, it is still configured in the
layout manager as taking up all excess space (ltr->addWidget(_editor,
1)).
I would be curious to what Qt does in this case. I would assume that
the right thing to do is to ignore a hidden widget entirely in the
layout (as if it was not inserted at all -- thus also ignoring any
padding that is associated with it). If that is the case, we'll need a
feature/bug request for this.
The modified test case below removes and re-inserts the _editor in the
layout, instead of just hiding and showing it. Is that the behaviour
you are looking for?
Regards,
koen
#include <Wt/WApplication>
#include <Wt/WContainerWidget>
#include <Wt/WBoxLayout>
#include <Wt/WText>
using namespace Wt;
using std::vector;
using std::string;
class testApp : public WApplication
{
public:
testApp(const WEnvironment& env);
private slots:
void viewClicked();
private:
WContainerWidget* makeEditor();
WContainerWidget* makeViewerWidget();
WContainerWidget* makeViewer();
WContainerWidget* makeSpacer();
WContainerWidget* _editor;
WContainerWidget* _spacer;
WContainerWidget* _view2;
WBoxLayout *ltr_;
};
WApplication *createApplication(const WEnvironment& env)
{
return new testApp(env);
}
int main(int argc, char **argv)
{
return WRun(argc, argv, &createApplication);
}
testApp::testApp(const WEnvironment& env) : WApplication(env)
{
setTitle("WTestCase of Layout Funkiness(tm)");
_editor = makeEditor();
WContainerWidget* view1 = makeViewer();
_spacer = makeSpacer();
_view2 = makeViewer();
ltr_ = new WBoxLayout(Wt::WBoxLayout::LeftToRight);
// ltr_->addWidget(_editor, 1);
ltr_->addWidget(makeViewerWidget());
root()->setLayout(ltr_);
_editor->hide();
viewClicked();
}
WContainerWidget* testApp::makeEditor()
{
WContainerWidget* w = new WContainerWidget();
w->decorationStyle().setBorder(WBorder(WBorder::Solid, WBorder::Thin));
new WText("The editor stuff goes here", w);
return w;
}
WContainerWidget* testApp::makeViewerWidget()
{
WContainerWidget* w = new WContainerWidget();
w->decorationStyle().setBorder(WBorder(WBorder::Solid, WBorder::Thin));
WBoxLayout* ltr = new WBoxLayout(WBoxLayout::LeftToRight);
ltr->addWidget(makeViewer());
ltr->addWidget(_spacer = makeSpacer());
ltr->addWidget(_view2 = makeViewer());
w->setLayout(ltr);
w->clicked().connect(SLOT(this, testApp::viewClicked));
return w;
}
void testApp::viewClicked()
{
if(_editor->isHidden()) {
ltr_->insertWidget(0, _editor, 1);
_editor->show();
_spacer->hide();
_view2->hide();
} else {
ltr_->removeWidget(_editor);
_editor->hide();
_spacer->show();
_view2->show();
}
}
WContainerWidget* testApp::makeViewer()
{
WContainerWidget* w = new WContainerWidget();
w->decorationStyle().setBorder(WBorder(WBorder::Solid, WBorder::Thin));
w->setMinimumSize(WLength(4, WLength::Inch), WLength(10.5, WLength::Inch));
w->setMaximumSize(WLength(4, WLength::Inch), WLength(10.5, WLength::Inch));
w->setToolTip("Click to toggle editor and multi-column view");
new WText("Preview of data from editor goes here", w);
return w;
}
WContainerWidget* testApp::makeSpacer()
{
WContainerWidget* w = new WContainerWidget();
w->decorationStyle().setBorder(WBorder(WBorder::Solid, WBorder::Thin));
w->setMinimumSize(WLength(.2, WLength::Inch), WLength());
w->setMaximumSize(WLength(.2, WLength::Inch), WLength());
return w;
}
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest