public static NinePatch get( Type type ) { String Asset = Assets.CHROME; switch (type) { case WINDOW: return new NinePatch( Asset, 0, 0, 20, 20, 6 ); case TOAST: return new NinePatch( Asset, 22, 0, 18, 18, 5 ); case TOAST_TR: return new NinePatch( Asset, 40, 0, 18, 18, 5 ); case BUTTON: return new NinePatch( Asset, 58, 0, 6, 6, 2 ); case TAG: return new NinePatch( Asset, 22, 18, 16, 14, 3 ); case GEM: return new NinePatch( Asset, 0, 32, 32, 32, 13 ); case SCROLL: return new NinePatch( Asset, 32, 32, 32, 32, 5, 11, 5, 11 ); case TAB_SET: return new NinePatch( Asset, 64, 0, 20, 20, 6 ); case TAB_SELECTED: return new NinePatch( Asset, 65, 22, 8, 13, 3, 7, 3, 5 ); case TAB_UNSELECTED: return new NinePatch( Asset, 75, 22, 8, 13, 3, 7, 3, 5 ); default: return null; } } }
@Override protected void onTouchDown() { bg.brightness( 1.2f ); Sample.INSTANCE.play( Assets.SND_CLICK ); }
@Override public void update() { super.update(); if (visible && lightness > 0.5) { if ((lightness -= Game.elapsed) > 0.5) { bg.ra = bg.ga = bg.ba = 2 * lightness - 1; bg.rm = 2 * r * (1 - lightness); bg.gm = 2 * g * (1 - lightness); bg.bm = 2 * b * (1 - lightness); } else { bg.hardlight( r, g, b ); } } } }
@Override protected void layout() { panel.x = this.x; panel.y = this.y; panel.alpha(alpha); panel.visible = updateAvailable || !quiet; updateMessage.x = panel.x+panel.marginLeft(); updateMessage.y = panel.y+panel.marginTop(); updateMessage.measure(); updateMessage.alpha(alpha); updateMessage.visible = updateAvailable || !quiet; panel.size( panel.marginHor()+updateMessage.width(), panel.marginVer()+updateMessage.height()-1); this.width = panel.width(); this.height = panel.height(); }
public void resize( int w, int h ) { this.width = w; this.height = h; chrome.size( width + chrome.marginHor(), height + chrome.marginVer() ); camera.resize( (int)chrome.width, (int)chrome.height ); camera.x = (int)(Game.width - camera.screenWidth()) / 2; camera.y = (int)(Game.height - camera.screenHeight()) / 2; camera.y += yOffset * camera.zoom; shadow.boxRect( camera.x / camera.zoom, camera.y / camera.zoom, chrome.width(), chrome.height ); }
add( shadow ); chrome.x = -chrome.marginLeft(); chrome.y = -chrome.marginTop(); chrome.size( width - chrome.x + chrome.marginRight(), height - chrome.y + chrome.marginBottom() ); add( chrome ); camera.x / camera.zoom, camera.y / camera.zoom, chrome.width(), chrome.height );
panel.size( pw, ph ); panel.x = (w - pw) / 2; panel.y = (h - ph) / 2; panel.x + panel.marginLeft(), panel.y + panel.marginTop(), panel.innerWidth(), panel.innerHeight() );
@Override protected void layout() { super.layout(); bg.x = x; bg.y = y; bg.size( width, height ); close.setPos( bg.x + bg.width() - bg.marginHor() / 2 - MARGIN_HOR - close.width(), y + (height - close.height()) / 2 ); text.x = close.left() - MARGIN_HOR - text.width(); text.y = y + (height - text.height()) / 2; PixelScene.align( text ); }
public void layoutTabs(){ //subract two as there's extra horizontal space for those nobs on the top. int fullWidth = width+chrome.marginHor()-2; 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 <= 3; 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() + 1 : tabs.get( i - 1 ).right() + spacing, height ); } }
protected Tab add( Tab tab ) { tab.setPos( tabs.size() == 0 ? -chrome.marginLeft() + 1 : tabs.get( tabs.size() - 1 ).right(), height ); tab.select( false ); super.add( tab ); tabs.add( tab ); return tab; }
@Override public void draw() { super.draw(); NoosaScript script = NoosaScript.get(); texture.bind(); script.camera( camera() ); script.uModel.valueM4( matrix ); script.lighting( rm, gm, bm, am, ra, ga, ba, aa ); script.drawQuadSet( verticesBuffer, 9 ); } }
public void resize( int w, int h ) { this.width = w; this.height = h; chrome.size( width + chrome.marginHor(), height + chrome.marginVer() ); camera.resize( (int)chrome.width, (int)chrome.height ); camera.x = (int)(Game.width - camera.screenWidth()) / 2; camera.y = (int)(Game.height - camera.screenHeight()) / 2; shadow.boxRect( camera.x / camera.zoom, camera.y / camera.zoom, chrome.width(), chrome.height ); }
add( shadow ); chrome.x = -chrome.marginLeft(); chrome.y = -chrome.marginTop(); chrome.size( width - chrome.x + chrome.marginRight(), height - chrome.y + chrome.marginBottom() ); add( chrome ); camera.x / camera.zoom, camera.y / camera.zoom, chrome.width(), chrome.height );
int pw = 135 + panel.marginLeft() + panel.marginRight() - 2; int ph = h - 16; panel.size( pw, ph ); panel.x = (w - pw) / 2f; panel.y = title.y + title.height(); posY = nextPosY; second = false; info.setRect(0, posY, panel.innerWidth(), 0); content.add(info); posY = nextPosY = info.bottom(); if (!second){ second = true; info.setRect(0, posY, panel.innerWidth()/2f, 0); content.add(info); nextPosY = info.bottom(); } else { second = false; info.setRect(panel.innerWidth()/2f, posY, panel.innerWidth()/2f, 0); content.add(info); nextPosY = Math.max(info.bottom(), nextPosY); content.setSize( panel.innerWidth(), (int)Math.ceil(posY) ); panel.x + panel.marginLeft(), panel.y + panel.marginTop() - 1, panel.innerWidth(),
@Override protected void layout() { super.layout(); bg.x = x; bg.y = y; bg.size( width, height ); close.setPos( bg.x + bg.width() - bg.marginHor() / 2f - MARGIN_HOR - close.width(), y + (height - close.height()) / 2f ); PixelScene.align(close); text.setPos(close.left() - MARGIN_HOR - text.width(), y + (height - text.height()) / 2); PixelScene.align(text); }
public void layoutTabs(){ //subract two as there's extra horizontal space for those nobs on the top. int fullWidth = width+chrome.marginHor()-2; 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 <= 3; 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() + 1 : tabs.get( i - 1 ).right() + spacing, height ); } }
protected Tab add( Tab tab ) { tab.setPos( tabs.size() == 0 ? -chrome.marginLeft() + 1 : tabs.get( tabs.size() - 1 ).right(), height ); tab.select( false ); super.add( tab ); tabs.add( tab ); return tab; }
@Override public void draw() { super.draw(); if (dirty){ if (buffer == null) buffer = new Vertexbuffer(quads); else buffer.updateVertices(quads); dirty = false; } NoosaScript script = NoosaScript.get(); texture.bind(); script.camera( camera() ); script.uModel.valueM4( matrix ); script.lighting( rm, gm, bm, am, ra, ga, ba, aa ); script.drawQuadSet( buffer, 9, 0 ); }