View Full Version : [CLOSED] [2.0M2] Layout issue on hide button bar
takayser
21 May 2009, 11:09 AM
I have 2 issues if I try to hide the button bar:
1) the button bar does not completely hide, there is still a small bar, at least the container does not expand fully.
2) the button bar only hides (or appears), if I resize the window, even if I call layout() manually. This also happens if I try to show/hide a toolbar set with setBottomComponent().
Im not sure if the second point is really a bug or I am doing anything wrong.
Here the code to reproduce this two issues:
public void onModuleLoad() {
final ContentPanel panel = new ContentPanel();
ToolBar toolbar = new ToolBar();
toolbar.add(new Button("show / hide ButtonBar", new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
if (panel.getButtonBar().isVisible())
panel.getButtonBar().setVisible(false);
else
panel.getButtonBar().setVisible(true);
}
}));
panel.addButton(new Button("TestButton"));
panel.add(toolbar);
Viewport v = new Viewport();
v.setLayout(new FitLayout());
v.add(panel);
RootPanel.get().add(v);
}
john.nichol
28 May 2009, 7:57 AM
takayser - I am seeing the same problem with GXT 1.2.4. If I change the toolbars visibility then I either have to resize the browser or navigate away to a different tab and then back to the original to see the buttons appear/dissapear.
I have worked around the problem for now by calling setSize() on the ContentPanel to fool GXT into redrawing. E.g.
setSize(getWidth(), getHeight());
this is helping for the particular case I am trying at the moment, don't know if it will help you.
GXT cant listen to all events that may get fired. You need to call layout after removing the toolbar. In GXT 2 you may become aware of sizecaching, there you need to call to syncSize()
I am going to close this issue.
john.nichol
28 May 2009, 8:57 AM
Sven - I do call layout after showing/hiding the toolbar, it doesn't help. Also takayser said in his post that calling layout() manually does not help.
I believe that there is a bug here - think you should consider reopening.
Excerpt from my code is
private void showButtons(final boolean showButtons) {
getButtonBar().setVisible(showButtons);
layout();
// Uncomment this to work around the problem
// setSize(getWidth(), getHeight());
}
You need to call layout on the parent of use setSize of this component do redo the sizing of this component.
takayser
29 May 2009, 12:00 AM
john.nichol, thx for your reply.
@sven, why did you close this bug report? There is still issue nr. 1 (the button bar does not completely hide, there is still a small bar, at least the container does not expand fully) that has not been solved/answered.
Issue Nr. 2 (show/hide)
okay, calling panel.syncSize() & viewport.syncSize() "solved" the problem (see below). Are you sure that this is the correct way to show/hide the buttonbar and there is nothing to fix?
ps. maybe my english is not that good, I do not really understand your last post.
Solution that works:
public void onModuleLoad() {
final ContentPanel panel = new ContentPanel();
final Viewport viewport = new Viewport();
final ToolBar toolbar = new ToolBar();
toolbar.add(new Button("show / hide ButtonBar", new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
if (panel.getButtonBar().isVisible()) {
panel.getButtonBar().setVisible(false);
panel.syncSize();
viewport.syncSize();
} else {
panel.getButtonBar().setVisible(true);
panel.syncSize();
viewport.syncSize();
}
}
}));
panel.addButton(new Button("TestButton"));
panel.add(toolbar);
viewport.setLayout(new FitLayout());
viewport.add(panel);
RootPanel.get().add(viewport);
}
sven
29 May 2009, 12:39 AM
The problem is that you are hiding only the toolbar and not the element that is holding the toolbar. This element has a padding set. So it will not completly collapse. So there are too approaches:
Hide the parent element of the toolbar
Change the css rule that is assigned to the parent element and has the padding set
sven
29 May 2009, 12:40 AM
panel.syncSize();
viewport.syncSize();
syncSize on the panel should be sufficient.
takayser
29 May 2009, 4:11 AM
okay, the one with the padding I understand, thanks for explaining. And if this is the correct behavior like it is now, it is easy to fix it for myself. Thx!
Referring to the other issue: nope, panel.syncSize() is not sufficient, I need to call viewport.syncSize() too.
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.