use of org.apache.pivot.wtk.TabPane in project pivot by apache.
the class TerraTabPaneSkin method getPreferredWidth.
@Override
public int getPreferredWidth(int height) {
int preferredWidth = 0;
TabPane tabPane = (TabPane) getComponent();
Component selectedTab = tabPane.getSelectedTab();
Component corner = tabPane.getCorner();
switch(tabOrientation) {
case HORIZONTAL:
{
if (height != -1) {
if (corner != null) {
height = Math.max(height - Math.max(corner.getPreferredHeight(-1), Math.max(tabButtonPanorama.getPreferredHeight(-1) - 1, 0)), 0);
} else {
height = Math.max(height - (tabButtonPanorama.getPreferredHeight(-1) - 1), 0);
}
height = Math.max(height - (padding.top + padding.bottom + 2), 0);
}
preferredWidth = getPreferredTabWidth(height) + (padding.left + padding.right + 2);
int buttonAreaPreferredWidth = tabButtonPanorama.getPreferredWidth(-1);
if (corner != null) {
buttonAreaPreferredWidth += corner.getPreferredWidth(-1);
}
preferredWidth = Math.max(preferredWidth, buttonAreaPreferredWidth);
break;
}
case VERTICAL:
{
if (height != -1) {
height = Math.max(height - (padding.top + padding.bottom + 2), 0);
}
if (selectedTab == null && selectionChangeTransition == null) {
preferredWidth = 1;
} else {
preferredWidth = getPreferredTabWidth(height) + (padding.left + padding.right);
if (selectionChangeTransition != null) {
float scale = selectionChangeTransition.getScale();
preferredWidth = (int) (preferredWidth * scale);
}
preferredWidth += 2;
}
if (corner != null) {
preferredWidth += Math.max(corner.getPreferredWidth(-1), Math.max(tabButtonPanorama.getPreferredWidth(-1) - 1, 0));
} else {
preferredWidth += Math.max(tabButtonPanorama.getPreferredWidth(-1) - 1, 0);
}
break;
}
default:
{
break;
}
}
return preferredWidth;
}
use of org.apache.pivot.wtk.TabPane in project pivot by apache.
the class TerraTabPaneSkin method getPreferredHeight.
@Override
public int getPreferredHeight(int width) {
int preferredHeight = 0;
TabPane tabPane = (TabPane) getComponent();
Component selectedTab = tabPane.getSelectedTab();
Component corner = tabPane.getCorner();
switch(tabOrientation) {
case HORIZONTAL:
{
if (width != -1) {
width = Math.max(width - (padding.left + padding.right + 2), 0);
}
if (selectedTab == null && selectionChangeTransition == null) {
preferredHeight = 1;
} else {
preferredHeight = getPreferredTabHeight(width) + (padding.top + padding.bottom);
if (selectionChangeTransition != null) {
float scale = selectionChangeTransition.getScale();
preferredHeight = (int) (preferredHeight * scale);
}
preferredHeight += 2;
}
if (corner != null) {
preferredHeight += Math.max(corner.getPreferredHeight(-1), Math.max(tabButtonPanorama.getPreferredHeight(-1) - 1, 0));
} else {
preferredHeight += Math.max(tabButtonPanorama.getPreferredHeight(-1) - 1, 0);
}
break;
}
case VERTICAL:
{
if (width != -1) {
if (corner != null) {
width = Math.max(width - Math.max(corner.getPreferredWidth(-1), Math.max(tabButtonPanorama.getPreferredWidth(-1) - 1, 0)), 0);
} else {
width = Math.max(width - (tabButtonPanorama.getPreferredWidth(-1) - 1), 0);
}
width = Math.max(width - (padding.left + padding.right + 2), 0);
}
preferredHeight = getPreferredTabHeight(width) + (padding.top + padding.bottom + 2);
int buttonAreaPreferredHeight = tabButtonPanorama.getPreferredHeight(-1);
if (corner != null) {
buttonAreaPreferredHeight += corner.getPreferredHeight(-1);
}
preferredHeight = Math.max(preferredHeight, buttonAreaPreferredHeight);
break;
}
default:
{
break;
}
}
return preferredHeight;
}
use of org.apache.pivot.wtk.TabPane in project pivot by apache.
the class TerraTabPaneSkin method getPreferredTabWidth.
private int getPreferredTabWidth(int height) {
int preferredTabWidth = 0;
TabPane tabPane = (TabPane) getComponent();
for (Component tab : tabPane.getTabs()) {
preferredTabWidth = Math.max(preferredTabWidth, tab.getPreferredWidth(height));
}
return preferredTabWidth;
}
Aggregations