Hey Graeme,
As with all new (and complex) things, there may still be bugs with the
new layout code, so I would appreciate if we can work through all your
issues (and fix whatever needs to be fixed).
2012/8/4 Graeme Gill <[email protected]>:
> You're right - setting a vertical size with resize() makes it work
> better in the layout. Other similar widgets don't have this problem
> though (ie. WTree, WTreeTable), and the overlayed behaviour would seem
> to be a bug in WTreeView, since the layout it is in should not let this
> happen.
True. That would be indeed be a bug, but we haven't been able to
reproduce it. Could you check whether you hit a JavaScript error ?
Find attached a test case which works for me, could you adapt it to break it ?
You will notice that the treeview does not shrink properly in this
test case, this is something that I've fixed now in latest git.
> Using resize() creates a different problem:
> The only effective way of specifying a height seems to be in pixels,
> percentage simply doesn't work. Yet in these days of devices with
> wildly different screen sizes and pixel density, it's considered
> bad GUI practice to specify layouts in pixels. What alternatives are there ?
There should not be a need for resize() if you use layout managers (!).
> I've checked that it's got a full set of Wt's CSS files and that they
> are being used.
My second theory is then a JavaScript problem which should show in the
Chrome or Firefox developer consoles.
> I'm afraid my impression is quite the contrary - lots of things
> that seemed to work in 3.2.0, don't seem to work anymore. At first blush:
> the stretch factors don't seem to work anymore - container
> sizes that were stretched proportionally to the factors now
> seem to do something unconnected with the stretch factors.
The behavior has changed in the sense that now the stretch factor only
applies to "excess space" to be redistributed to each widget, on top
of the preferred size of each widget.
> The alignment flags seem to do things other than what they
> specify i.e. AlignTop seemed to stop the new unwanted default vertical
> justification of my buttons, but positioned them centrally
> rather than at the top. I didn't investigate further than that since
> it is unclear whether these are bugs, or what has fundamentally changed
> here, but if these things are not bugs then the layout controls seem
> even more puzzling and inscrutable than they were.
What you describe sounds like a bug then (and ASFAIK, there are no
known ones in that area).
AlignTop really has no other meaning but to align a widget at the top
instead of stretching it in the available space.
AlignTop used to have the meaning of not taking into account the
widget size for the complete layout, but this was a major source of
annoyances and bugs.
>> That is because in non-Ajax mode, there is now active layout management.
>
> I guess I don't understand that. Doesn't Ajax use layout management ?
That was meant to be read: "because in
contents-determines-container-size, there is
now active layout management".
>> With the new implementation of layout management in 3.2.2-p1, you
>> should be able to get the same behaviour by putting a maximum height
>> on the treeview, which will have the effect of resizing itself up to
>> that maximum size given what its contents needs.
>
> That sounds a bit strange. I would have though "maximum hight" would
> be the maximum height available to it, whereas "auto" would be the
> minimum height it needs to display without using scroll bars.
Our meaning of maximum height follows the CSS meaning of maximum
height (and is no different): this the maximum height that the widget
will be given irrespective of what it needs. The actual height will
always be smaller or equal to the maximum height.
Wt's special attention to maximum height is to interpret it as a hint
that you actually want the container contents to be as large as it
requires (based on total preferred size of the contents), and growing
if necessary, rather than fitting the contents in the current
container size.
> Is there some way of retrieving the actual height of things.
> so that some intelligent layout can be performed (ie.,
> not pixel based) ?
Yes, you can make a widget layout-size-aware and react to actual sizes
(see setLayoutSizeAware() and layoutSizeChanged())
Regards,
koen
#include <Wt/WApplication>
#include <Wt/WStandardItemModel>
#include <Wt/WStandardItem>
#include <Wt/WContainerWidget>
#include <Wt/WText>
#include <Wt/WVBoxLayout>
#include <Wt/WTreeView>
using namespace Wt;
int cols = 2;
class TestApp : public WApplication
{
public:
void createRow(std::vector<WStandardItem *>& row, int size,
const std::string& s) {
row.clear();
for (int i = 0; i < size; ++i) {
WStandardItem *t
= new WStandardItem(s + " c" + boost::lexical_cast<std::string>(i));
row.push_back(t);
}
}
WStandardItemModel *createModel() {
WStandardItemModel *model_ = new WStandardItemModel(0, cols, this);
for (int i = 0; i < cols; ++i)
model_->setHeaderData(i, Horizontal,
"col " + boost::lexical_cast<std::string>(i));
std::vector<WStandardItem *> row;
for (unsigned i = 0; i < 3; ++i) {
createRow(row, cols, "Item "+ boost::lexical_cast<std::string>(i));
model_->appendRow(row);
WStandardItem *level0 = row[0];
for (unsigned k = 0; k < 3; ++k) {
char l = 'a' + k;
std::string s;
s += l;
createRow(row, cols, level0->text().toUTF8() + s);
level0->appendRow(row);
WStandardItem *level1 = row[0];
for (unsigned j = 0; j < 100; ++j) {
createRow(row, cols, level1->text().toUTF8() + " "
+ boost::lexical_cast<std::string>(j));
level1->appendRow(row);
}
}
}
return model_;
}
TestApp(const WEnvironment& env) : WApplication(env)
{
WContainerWidget *w = new WContainerWidget(root());
w->decorationStyle().setBackgroundColor(yellow);
w->setPadding(5);
WVBoxLayout *layout = new WVBoxLayout(w);
WTreeView *tv = new WTreeView(w);
tv->setModel(createModel());
layout->addWidget(tv);
layout->addWidget(new WText("Under treeview"));
}
void foo() {
}
private:
};
WApplication *createApplication(const WEnvironment& env)
{
TestApp *app = new TestApp(env);
return app;
}
int main(int argc, char *argv[])
{
return WRun(argc, argv, &createApplication);
}
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest