Commit cda32b5e authored by Lukas Marik's avatar Lukas Marik

#776 create scrollable layout in UserMenu

parent 2b716f5c
......@@ -67,6 +67,8 @@ public abstract class AbstractMenu extends Stack implements Disposable {
private static final String TABLEXIA_VERSION_LABEL = "%s\r\n%s";
protected static final float SCROLL_PANE_INIT_SIZE = 200f;
protected enum MenuControlType {
MANUAL (true, false, true),
......
......@@ -52,7 +52,6 @@ public class MainMenu extends AbstractMenu {
private static final int SELECTBOX_USER_HEIGHT = 70;
private static final float MENU_PADDING = 15;
private static final float USER_SELECT_BOX_PADDING = 10;
private static final float SCROLL_PANE_INIT_SIZE = 200f;
private Map<IMenuItem, Group> subMenus = new HashMap<IMenuItem, Group>();
private VerticalGroup mainMenuVerticalGroup;
......
......@@ -28,6 +28,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.Align;
import net.engio.mbassy.listener.Handler;
......@@ -98,6 +99,7 @@ public class UserMenu extends AbstractMenu {
private TablexiaComponentDialog syncDialog;
private UserUuidSyncDialogComponent uuidSyncDialogComponent;
private ScrollPane scrollPane;
private Container container;
public UserMenu(Float width, Float height) {
super(width, height);
......@@ -107,9 +109,24 @@ public class UserMenu extends AbstractMenu {
@Override
protected boolean isScreenPause() {
resizeContainerSize();
return MENU_SCREEN_PAUSE;
}
@Override
protected void sizeChanged() {
resizeContainerSize();
super.sizeChanged();
}
private void resizeContainerSize(){
if(getStage() != null && container != null) {
float scrollPaneHeight = TablexiaSettings.getViewportHeight(getStage());
container.height(scrollPaneHeight);
container.invalidateHierarchy();
}
}
@Override
protected MenuControlType getMenuControlType() {
return MENU_CONTROL_TYPE;
......@@ -119,9 +136,6 @@ public class UserMenu extends AbstractMenu {
public void initMenuItems(Container<Group> layoutContainer) {
final VerticalGroup menuItemsLayout = new VerticalGroup();
scrollPane = new ScrollPane(menuItemsLayout);
final Container<ScrollPane> container = new Container<ScrollPane>(scrollPane);
container.setFillParent(true);
final float userMenuItemWidth = getBackground().getWidth();
this.users = UserDAO.selectActiveUsers();
for (final User user : users) {
......@@ -157,6 +171,7 @@ public class UserMenu extends AbstractMenu {
}
});
menuItemsLayout.addActor(userItemGroup);
menuItemsLayout.expand().fill();
userItemGroup.setName(user.getName());
}
final UserMenuNewSelectBoxItemGroup userMenuNewSelectBoxItemGroup = new UserMenuNewSelectBoxItemGroup() {
......@@ -173,6 +188,7 @@ public class UserMenu extends AbstractMenu {
};
userMenuNewSelectBoxItemGroup.setName(NEW_USER_BUTTON);
userMenuNewSelectBoxItemGroup.setSize(userMenuItemWidth, USER_ITEM_HEIGHT);
userMenuNewSelectBoxItemGroup.addListener(new ClickListener() {
@Override
......@@ -182,6 +198,7 @@ public class UserMenu extends AbstractMenu {
}
});
menuItemsLayout.addActor(userMenuNewSelectBoxItemGroup);
menuItemsLayout.expand().fill();
final UserMenuDownloadSelectBoxItemGroup userDownload = new UserMenuDownloadSelectBoxItemGroup() {
@Override
......@@ -204,8 +221,22 @@ public class UserMenu extends AbstractMenu {
}
});
menuItemsLayout.addActor(userDownload);
menuItemsLayout.expand().fill();
scrollPane = new ScrollPane(menuItemsLayout);
container = new Container();
container.setActor(scrollPane);
container.align(Align.top);
if(getStage() == null)
container.height(SCROLL_PANE_INIT_SIZE);
else
container.height(TablexiaSettings.getViewportHeight(getStage()));
layoutContainer.setActor(container);
scrollPane.setScrollingDisabled(true,false);
}
private void showSyncDialog(final String syncUUID) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment