Advertisement
Guest User

Untitled

a guest
Jun 10th, 2014
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.57 KB | None | 0 0
  1. import com.badlogic.gdx.scenes.scene2d.Actor;
  2. import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
  3. import com.badlogic.gdx.scenes.scene2d.ui.Label;
  4. import com.badlogic.gdx.scenes.scene2d.ui.Skin;
  5. import com.badlogic.gdx.scenes.scene2d.ui.Table;
  6. import com.badlogic.gdx.scenes.scene2d.utils.Align;
  7. import com.esotericsoftware.tablelayout.Cell;
  8.  
  9. /**
  10.  * Like a regular Window, with a few modifications.
  11.  *
  12.  * @author Mads Peter Horndrup
  13.  */
  14. public class Frame extends MovableTable {
  15.    
  16.     private Table topBar;
  17.     private Table content;
  18.     private Label titleLabel;
  19.  
  20.     public Frame(String title, Skin skin) {
  21.         super(skin);
  22.        
  23.         prepareGUI(title, skin);
  24.        
  25.         dragActors = new Actor[3];
  26.         dragActors[0] = this;
  27.         dragActors[1] = topBar;
  28.         dragActors[2] = titleLabel;
  29.     }
  30.    
  31.     private void prepareGUI(String title, Skin skin) {
  32.         topBar = new Table();
  33.         add(topBar).space(5f).row();
  34.        
  35.         titleLabel = new Label(title, skin);
  36.         topBar.add(titleLabel).expand().align(Align.left).padLeft(5f);
  37.        
  38.         ImageButton closeButton = new ImageButton(skin, "closeDialog");
  39.         topBar.add(closeButton).expand().align(Align.right);
  40.        
  41.         this.getCell(topBar).expand().fill();
  42.        
  43.         content = new Table();
  44.         add(content);
  45.     }
  46.    
  47.     /**
  48.      * Adds an Actor to the content table of this widget.
  49.      */
  50.     public <T extends Actor> Cell<T> addContent (T actor) {
  51.         return (Cell<T>)content.add(actor);
  52.     }
  53.    
  54.     /**
  55.      * Indicates that the next inserted item should be on a different row.
  56.      * @return  The new cell after adding the row.
  57.      */
  58.     public Cell rowContent() {
  59.         return content.row();
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement