Skip to content

StripeMenuBar

raeleus edited this page May 28, 2022 · 5 revisions

StripeMenuBar is an easy to implement solution that allows you to build drop down menus in your Scene2D.UI layouts.

StripeMenuBarStyle

A StripeMenuBarStyle is necessary to build a menu. This controls the appearance of the bar and associated menus.

StripeMenuBarStyle style = new StripeMenuBarStyle();

itemFont is a required field.

style.itemFont = skin.getFont("somefont");

The rest of the fields are optional, but you will likely want to utilize all of them if you want a discernable menu.

menuBar is a drawable for the bar that goes across the top of the stage.

subMenuBackground is a drawable for the background of each pop up menu.

itemUp is a drawable for the background of each clickable menu item. This is the normal, unclicked state of the item.

itemOver is a drawable for the background of each clickable menu item. This is the hover state when the mouse is over the item.

itemDown is a drawable for the background of each clickable menu item. This is the pressed state when the user clicks the item.

itemOpen is a drawable for the background of each clickable menu item. This is the open state when the item is selected.

itemDisabled is a drawable for the background of each clickable menu item. This is the disabled state when the item is disabled.

menuUp is a drawable for the background of each clickable top level menu. This is the normal, unclicked state of the menu item. If it is not provided, it is defaulted to the itemUp drawable.

menuOver is a drawable for the background of each clickable top level menu. This is the hover state when the mouse is over the menu item. If it is not provided, it is defaulted to the itemOver drawable.

menuDown is a drawable for the background of each clickable top level menu. This is the pressed state when the user clicks the menu item. If it is not provided, it is defaulted to the itemDown drawable.

menuOpen is a drawable for the background of each clickable top level menu. This is the open state when the menuu item is selected. If it is not provided, it is defaulted to the itemOpen drawable.

menuDisabled is a drawable for the background of each clickable top level menu. This is the disabled state when the menu item is disabled.

submenuUp is a drawable for the background of each clickable submenu. This is the normal, unclicked state of the submenu item. If it is not provided, it is defaulted to the itemUp drawable.

submenuOver is a drawable for the background of each clickable top level submenu. This is the hover state when the mouse is over the submenu item. If it is not provided, it is defaulted to the itemOver drawable.

submenuDown is a drawable for the background of each clickable top level submenu. This is the pressed state when the user clicks the submenu item. If it is not provided, it is defaulted to the itemDown drawable.

submenuOpen is a drawable for the background of each clickable top level submenu. This is the open state when the submenu item is selected. If it is not provided, it is defaulted to the itemOpen drawable.

submenuDisabled is a drawable for the background of each clickable top level submenu. This is the disabled state when the submenu item is disabled.

Building a StripeMenuBar

Create a StripeMenuBar by passing in the style you created or the Skin that you added style to.

StripeMenuBar menuBar = new StripeMenuBar(stage, style);

Make sure to add it to your layout. Typically the menu bar is positioned at the top of the screen.

Table root = new Table();
root.setFillParent(true);
stage.addActor(root);

root.top();
root.add(menuBar).growX();

You can design your menu elements using the Builder

Clone this wiki locally