Skip to content

Commit

Permalink
Add TabbedPaneTable, close #169
Browse files Browse the repository at this point in the history
  • Loading branch information
kotcrab committed May 3, 2016
1 parent f3ae4ad commit 01eb2ed
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
3 changes: 2 additions & 1 deletion ui/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#### Version: 1.1.0 (LibGDX 1.9.2)
- **Added**: default styles for `ImageButton` and `ImageTextButton`. Note: this is only applies to standard scene2d widgets. VisUI widgets equivalents (`VisImageButton`, `VisImageTextButton`) already had them.
- **Added**: default styles for `ImageButton` and `ImageTextButton`. Note: this is only applies to standard scene2d widgets. VisUI widgets equivalents (`VisImageButton`, `VisImageTextButton`) already had them.
- **Changed**: [#169](https://github.com/kotcrab/vis-editor/issues/169) - `TabbedPane#getTable()` returns `TabbedPaneTable` (holds reference to `TabbedPane` and allow to easily get it's cells for customization)

#### Version: 1.0.2 (LibGDX 1.9.2)
- **Changed**: [#163](https://github.com/kotcrab/vis-editor/issues/163) - When `VisCheckBox` or `VisTextField` is disabled and is marked as invalid then error border won't be drawn.
Expand Down
45 changes: 38 additions & 7 deletions ui/src/com/kotcrab/vis/ui/widget/tabbedpane/TabbedPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class TabbedPane {
private VisImageButtonStyle sharedCloseActiveButtonStyle;

private DragPane tabsPane;
private VisTable mainTable;
private TabbedPaneTable mainTable;

private Array<Tab> tabs;
private IdentityMap<Tab, TabButtonTable> tabsButtonMap;
Expand Down Expand Up @@ -101,7 +101,7 @@ public TabbedPane (TabbedPaneStyle style, Sizes sizes) {

group = new ButtonGroup<Button>();

mainTable = new VisTable();
mainTable = new TabbedPaneTable(this);
tabsPane = new DragPane(style.vertical ? new VerticalFlowGroup() : new HorizontalFlowGroup());
configureDragPane(style);

Expand All @@ -111,21 +111,24 @@ public TabbedPane (TabbedPaneStyle style, Sizes sizes) {
tabsButtonMap = new IdentityMap<Tab, TabButtonTable>();

Cell<DragPane> tabsPaneCell = mainTable.add(tabsPane);
Cell<Image> separatorCell = null;

//note: if separatorBar height/width is not set it may sometimes disappear
//note: if separatorBar height/width is not set explicitly it may sometimes disappear
if (style.separatorBar != null) {
if (style.vertical) {
tabsPaneCell.top().growY().minSize(0, 0);
mainTable.add(new Image(style.separatorBar)).grow().width(style.separatorBar.getMinWidth());
separatorCell = mainTable.add(new Image(style.separatorBar)).grow().width(style.separatorBar.getMinWidth());
} else {
tabsPaneCell.left().growX().minSize(0, 0);
mainTable.row();
mainTable.add(new Image(style.separatorBar)).grow().height(style.separatorBar.getMinHeight());
separatorCell = mainTable.add(new Image(style.separatorBar)).grow().height(style.separatorBar.getMinHeight());
}
} else {
//make sure that tab will fill available space even when there is not separatorBar image set
//make sure that tab will fill available space even when there is no separatorBar image set
mainTable.add().expand().fill();
}

mainTable.setPaneCells(tabsPaneCell, separatorCell);
}

private void configureDragPane (TabbedPaneStyle style) {
Expand Down Expand Up @@ -384,7 +387,7 @@ protected String getTabTitle (Tab tab) {
return tab.isDirty() ? "*" + tab.getTabTitle() : tab.getTabTitle();
}

public Table getTable () {
public TabbedPaneTable getTable () {
return mainTable;
}

Expand Down Expand Up @@ -459,6 +462,34 @@ public TabbedPaneStyle (Drawable separatorBar, Drawable background, VisTextButto
}
}

public static class TabbedPaneTable extends VisTable {
private TabbedPane tabbedPane;
private Cell<DragPane> tabsPaneCell;
private Cell<Image> separatorCell;

public TabbedPaneTable (TabbedPane tabbedPane) {
this.tabbedPane = tabbedPane;
}

private void setPaneCells (Cell<DragPane> tabsPaneCell, Cell<Image> separatorCell) {
this.tabsPaneCell = tabsPaneCell;
this.separatorCell = separatorCell;
}

public Cell<DragPane> getTabsPaneCell () {
return tabsPaneCell;
}

/** @return separator cell or null if separator is not used */
public Cell<Image> getSeparatorCell () {
return separatorCell;
}

public TabbedPane getTabbedPane () {
return tabbedPane;
}
}

private class TabButtonTable extends VisTable {
public VisTextButton button;
public VisImageButton closeButton;
Expand Down

0 comments on commit 01eb2ed

Please # to comment.