Skip to content
Snippets Groups Projects
Commit a01544f9 authored by Matyáš Latner's avatar Matyáš Latner
Browse files

#58 Main menu items layout refactor

parent 5e2b68ee
No related branches found
No related tags found
No related merge requests found
......@@ -256,10 +256,6 @@ public abstract class AbstractMenu extends Stack implements Disposable {
}
});
menuItemsLayout.addActor(menuItemContainer);
Group menuItemDivider = createMenuItemDivider();
if (menuItemDivider != null) {
menuItemsLayout.addActor(menuItemDivider);
}
IMenuItem[] subMenu = menuItem.getSubmenu();
if (subMenu != null) {
for (IMenuItem submenuItem : subMenu) {
......@@ -267,11 +263,6 @@ public abstract class AbstractMenu extends Stack implements Disposable {
}
}
}
// menuItemsLayout.setDebug(TablexiaSettings.getInstance().isShowBoundingBoxes(), true);
}
protected Group createMenuItemDivider() {
return null;
}
protected Group createMenuItem(final IMenuItem menuItem) {
......
......@@ -33,9 +33,8 @@ public class MainMenu extends AbstractMenu {
private static final Color HIGHLITED_COLOR = new Color(0.780f, 0.698f, 0.600f, 1);
private static final Color DIVIDER_COLOR = new Color(0.780f, 0.698f, 0.600f, 1);
private static final int DIVIDER_WIDTH = 205;
private static final int DIVIDER_LEFT_PADDING = 70;
private static class MenuItemGroup extends Container<HorizontalGroup> {
private static class MenuItemGroup extends Container<Table> {
private static final String MENU_ITEM_FONT_TYPE = ApplicationFontManager.APPLICATION_DEFAULT_FONT_BOLD;
private static final Color MENU_ITEM_FONT_COLOR = new Color(0.325f, 0.278f, 0.255f, 1);
......@@ -47,30 +46,9 @@ public class MainMenu extends AbstractMenu {
private final TextureRegionDrawable highlitedBackground;
public MenuItemGroup(String iconUnpressed, String iconPressed, String title) {
HorizontalGroup horizontalGroup = new HorizontalGroup();
horizontalGroup.setFillParent(true);
setActor(horizontalGroup);
Stack iconStack = new Stack();
horizontalGroup.addActor(iconStack);
highlitedBackground = new TextureRegionDrawable(ApplicationAtlasManager.getInstance().getColorTextureRegion(HIGHLITED_COLOR));
// icons
iconPressedImage = createIcon(iconPressed, iconStack);
iconUnpressedImage = createIcon(iconUnpressed, iconStack);
if (iconPressed != null || iconUnpressed != null) {
Actor iconRightSpace = new Actor();
iconRightSpace.setWidth(ICON_RIGHT_SPACE);
horizontalGroup.addActor(iconRightSpace);
}
// title
if (title != null) {
Label label = new Label(title, new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(MENU_ITEM_FONT_TYPE), MENU_ITEM_FONT_COLOR));
horizontalGroup.addActor(label);
}
Table layoutTable = new Table();
layoutTable.setFillParent(true);
setActor(layoutTable);
addListener(new ClickListener() {
@Override
......@@ -86,8 +64,29 @@ public class MainMenu extends AbstractMenu {
}
});
setTouchable(Touchable.enabled);
setUnpressed();
// highliter
highlitedBackground = new TextureRegionDrawable(ApplicationAtlasManager.getInstance().getColorTextureRegion(HIGHLITED_COLOR));
// icons
Stack iconStack = new Stack();
layoutTable.add(iconStack);
iconPressedImage = createIcon(iconPressed, iconStack);
iconUnpressedImage = createIcon(iconUnpressed, iconStack);
// title
if (title != null) {
Label label = new Label(title, new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(MENU_ITEM_FONT_TYPE), MENU_ITEM_FONT_COLOR));
layoutTable.add(label).expandX().align(Align.left).padLeft(ICON_RIGHT_SPACE);
}
layoutTable.row();
// divider
Image divider = new Image(ApplicationAtlasManager.getInstance().getColorTexture(DIVIDER_COLOR));
divider.getDrawable().setMinWidth(DIVIDER_WIDTH);
layoutTable.add();
layoutTable.add(divider);
}
@Override
......@@ -229,16 +228,6 @@ public class MainMenu extends AbstractMenu {
return new SubMenuItemGroup(menuItem.getTitle(), menuItem.getDescription());
}
protected Group createMenuItemDivider() {
Container<Image> dividerContainer = new Container<Image>();
Image divider = new Image(ApplicationAtlasManager.getInstance().getColorTexture(DIVIDER_COLOR));
divider.getDrawable().setMinWidth(DIVIDER_WIDTH);
dividerContainer.setActor(divider);
dividerContainer.padLeft(DIVIDER_LEFT_PADDING);
return dividerContainer;
}
@Override
protected boolean isScreenPause() {
return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment