v0.2.4: fixed chrome inconsistency, standardized tab layouts and made them pretty

This commit is contained in:
Evan Debenham 2015-02-07 20:19:11 -05:00
parent 6b432a176e
commit 89d72e60d1
8 changed files with 60 additions and 25 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -35,27 +35,28 @@ public class Chrome {
};
public static NinePatch get( Type type ) {
String Asset = Assets.CHROME;
switch (type) {
case WINDOW:
return new NinePatch( Assets.CHROME, 0, 0, 22, 22, 7 );
return new NinePatch( Asset, 0, 0, 20, 20, 6 );
case TOAST:
return new NinePatch( Assets.CHROME, 22, 0, 18, 18, 5 );
return new NinePatch( Asset, 22, 0, 18, 18, 5 );
case TOAST_TR:
return new NinePatch( Assets.CHROME, 40, 0, 18, 18, 5 );
return new NinePatch( Asset, 40, 0, 18, 18, 5 );
case BUTTON:
return new NinePatch( Assets.CHROME, 58, 0, 4, 4, 1 );
return new NinePatch( Asset, 58, 0, 4, 4, 1 );
case TAG:
return new NinePatch( Assets.CHROME, 22, 18, 16, 14, 3 );
return new NinePatch( Asset, 22, 18, 16, 14, 3 );
case GEM:
return new NinePatch( Assets.CHROME, 0, 32, 32, 32, 13 );
return new NinePatch( Asset, 0, 32, 32, 32, 13 );
case SCROLL:
return new NinePatch( Assets.CHROME, 32, 32, 32, 32, 5, 11, 5, 11 );
return new NinePatch( Asset, 32, 32, 32, 32, 5, 11, 5, 11 );
case TAB_SET:
return new NinePatch( Assets.CHROME, 64, 0, 22, 22, 7, 7, 7, 7 );
return new NinePatch( Asset, 64, 0, 20, 20, 6, 6, 6, 6 );
case TAB_SELECTED:
return new NinePatch( Assets.CHROME, 64, 22, 10, 14, 4, 7, 4, 6 );
return new NinePatch( Asset, 64, 22, 10, 14, 4, 7, 4, 6 );
case TAB_UNSELECTED:
return new NinePatch( Assets.CHROME, 74, 22, 10, 14, 4, 7, 4, 6 );
return new NinePatch( Asset, 74, 22, 10, 14, 4, 7, 4, 6 );
default:
return null;
}

View File

@ -132,15 +132,12 @@ public class WndBag extends WndTabbed {
for (Bag b : bags) {
if (b != null) {
BagTab tab = new BagTab( b );
int tab_width = (slotsWidth-((bags.length-1)*5))/bags.length;
tab.setSize( tab_width, tabHeight() );
//no point in showing tabs if there's just one bag
if (bags.length > 1) add( tab );
add( tab );
tab.select( b == bag );
}
}
layoutTabs();
}
public static WndBag lastBag( Listener listener, Mode mode, String title ) {

View File

@ -102,9 +102,10 @@ public class WndCatalogus extends WndTabbed {
}
};
for (Tab tab : tabs) {
tab.setSize( TAB_WIDTH, tabHeight() );
add( tab );
}
layoutTabs();
select( showPotions ? 0 : 1 );
}

View File

@ -57,7 +57,6 @@ public class WndClass extends WndTabbed {
add( tabMastery );
tab = new RankingTab( TXT_MASTERY, tabMastery );
tab.setSize( TAB_WIDTH, tabHeight() );
add( tab );
resize(
@ -67,6 +66,8 @@ public class WndClass extends WndTabbed {
resize( (int)tabPerks.width, (int)tabPerks.height );
}
layoutTabs();
select( 0 );
}

View File

@ -83,11 +83,10 @@ public class WndHero extends WndTabbed {
buffs.visible = buffs.active = selected;
};
} );
for (Tab tab : tabs) {
tab.setSize( TAB_WIDTH, tabHeight() );
}
resize( WIDTH, (int)Math.max( stats.height(), buffs.height() ) );
layoutTabs();
select( 0 );
}

View File

@ -115,9 +115,10 @@ public class WndRanking extends WndTabbed {
add( pages[i] );
Tab tab = new RankingTab( labels[i], pages[i] );
tab.setSize( TAB_WIDTH, tabHeight() );
add( tab );
}
layoutTabs();
select( 0 );
}

View File

@ -39,9 +39,9 @@ public class WndTabbed extends Window {
}
protected Tab add( Tab tab ) {
tab.setPos( tabs.size() == 0 ?
-chrome.marginLeft() + 1 :
-chrome.marginLeft() :
tabs.get( tabs.size() - 1 ).right(), height );
tab.select( false );
super.add( tab );
@ -100,6 +100,41 @@ public class WndTabbed extends Window {
add( tab );
}
}
public void layoutTabs(){
int fullWidth = width+chrome.marginHor();
int numTabs = tabs.size();
if (numTabs == 0)
return;
if (numTabs == 1) {
tabs.get(0).setSize(fullWidth, tabHeight());
return;
}
int spaces = numTabs-1;
int spacing = -1;
while (spacing == -1) {
for (int i = 0; i <= 5; i++){
if ((fullWidth - i*(spaces)) % numTabs == 0) {
spacing = i;
break;
}
}
if (spacing == -1) fullWidth--;
}
int tabWidth = (fullWidth - spacing*(numTabs-1)) / numTabs;
for (int i = 0; i < tabs.size(); i++){
tabs.get(i).setSize(tabWidth, tabHeight());
tabs.get(i).setPos( i == 0 ?
-chrome.marginLeft() :
tabs.get( i - 1 ).right() + spacing, height );
}
}
protected int tabHeight() {
return 25;