List of usage examples for com.badlogic.gdx.scenes.scene2d.utils Drawable getTopHeight
public float getTopHeight();
From source file:CB_UI.GL_UI.Views.splash.java
License:Open Source License
/** * Step 1 <br>/* ww w . j a va2 s . c o m*/ * add Progressbar */ private void ini_Progressbar() { float ref = UI_Size_Base.that.getWindowHeight() / 13; CB_RectF CB_LogoRec = new CB_RectF(this.getHalfWidth() - (ref * 2.5f), this.getHeight() - ((ref * 5) / 4.11f) - ref, ref * 5, (ref * 5) / 4.11f); CB_Logo = new Image(CB_LogoRec, "CB_Logo", false); CB_Logo.setDrawable(new SpriteDrawable(atlas.createSprite("cachebox-logo"))); Label dummy = new Label(); this.initRow(); this.addLast(dummy); this.addNext(dummy); this.addNext(CB_Logo, FIXED); this.addLast(dummy); String VersionString = GlobalCore.getVersionString(); descTextView = new Label(VersionString + GlobalCore.br + GlobalCore.br + GlobalCore.splashMsg, null, null, WrapType.MULTILINE).setHAlignment(HAlignment.CENTER); descTextView.setHeight(descTextView.getTextHeight()); this.addLast(descTextView); Drawable ProgressBack = new NinePatchDrawable(atlas.createPatch(IconName.btnNormal.name())); Drawable ProgressFill = new NinePatchDrawable(atlas.createPatch("progress")); float ProgressHeight = Math.max(ProgressBack.getBottomHeight() + ProgressBack.getTopHeight(), ref / 1.5f); progress = new ProgressBar(new CB_RectF(0, 0, this.getWidth(), ProgressHeight), "Splash.ProgressBar"); progress.setBackground(ProgressBack); progress.setProgressFill(ProgressFill); this.addChild(progress); float logoCalcRef = ref * 1.5f; CB_RectF rec_GC_Logo = new CB_RectF(20, 50, logoCalcRef, logoCalcRef); CB_RectF rec_Mapsforge_Logo = new CB_RectF(200, 50, logoCalcRef, logoCalcRef / 1.142f); CB_RectF rec_FX2_Logo = new CB_RectF(rec_Mapsforge_Logo); CB_RectF rec_LibGdx_Logo = new CB_RectF(20, 50, logoCalcRef * 4.17f * 0.8f, logoCalcRef * 0.8f); CB_RectF rec_OSM = new CB_RectF(rec_Mapsforge_Logo); CB_RectF rec_Route = new CB_RectF(rec_Mapsforge_Logo); rec_FX2_Logo.setX(400); GC_Logo = new Image(rec_GC_Logo, "GC_Logo", false); GC_Logo.setDrawable(new SpriteDrawable(atlas.createSprite("gc_live"))); Mapsforge_Logo = new Image(rec_Mapsforge_Logo, "Mapsforge_Logo", false); Mapsforge_Logo.setDrawable(new SpriteDrawable(atlas.createSprite("mapsforge_logo"))); LibGdx_Logo = new Image(rec_LibGdx_Logo, "LibGdx_Logo", false); LibGdx_Logo.setDrawable(new SpriteDrawable(atlas.createSprite("libgdx"))); Route_Logo = new Image(rec_OSM, "Route_Logo", false); Route_Logo.setDrawable(new SpriteDrawable(atlas.createSprite("openrouteservice_logo"))); OSM_Logo = new Image(rec_Route, "OSM_Logo", false); OSM_Logo.setDrawable(new SpriteDrawable(atlas.createSprite("osm_logo"))); float yPos = descTextView.getY() - GC_Logo.getHeight(); float xPos = (this.getWidth() - ref - GC_Logo.getWidth() - Mapsforge_Logo.getWidth()) / 2; GC_Logo.setPos(xPos, yPos); xPos += GC_Logo.getWidth() + ref; Mapsforge_Logo.setPos(xPos, yPos); xPos += Mapsforge_Logo.getWidth() + ref; yPos -= GC_Logo.getHeight();// + refHeight; LibGdx_Logo.setPos(this.getHalfWidth() - LibGdx_Logo.getHalfWidth(), yPos); yPos -= GC_Logo.getHeight();// xPos = (this.getWidth() - (ref) - Route_Logo.getWidth() - OSM_Logo.getWidth()) / 2; Route_Logo.setPos(xPos, yPos); xPos += Route_Logo.getWidth() + ref; OSM_Logo.setPos(xPos, yPos); this.addChild(GC_Logo); this.addChild(Mapsforge_Logo); this.addChild(LibGdx_Logo); this.addChild(Route_Logo); this.addChild(OSM_Logo); }
From source file:CB_UI_Base.GL_UI.GL_View_Base.java
License:Open Source License
/** * * setting the drawableBackground and changes the Borders (do own Borders afterwards) **//*from www. j a va 2 s.c om*/ public void setBackground(Drawable background) { if (isDisposed) return; drawableBackground = background; if (background != null) { leftBorder = background.getLeftWidth(); rightBorder = background.getRightWidth(); topBorder = background.getTopHeight(); bottomBorder = background.getBottomHeight(); // this.BottomHeight; } else { leftBorder = 0; rightBorder = 0; topBorder = 0; bottomBorder = 0; // this.BottomHeight; } innerWidth = getWidth() - leftBorder - rightBorder; innerHeight = getHeight() - topBorder - bottomBorder; }
From source file:CB_UI_Base.GL_UI.utils.EmptyDrawable.java
License:Apache License
/** Creates a new empty drawable with the same sizing information as the specified drawable. */ public EmptyDrawable(Drawable drawable) { leftWidth = drawable.getLeftWidth(); rightWidth = drawable.getRightWidth(); topHeight = drawable.getTopHeight(); bottomHeight = drawable.getBottomHeight(); minWidth = drawable.getMinWidth();/* ww w . j a v a 2 s .c o m*/ minHeight = drawable.getMinHeight(); }
From source file:com.anstrat.gui.SnapScrollPane.java
License:Apache License
public void layout() { final Drawable bg = style.background; final Drawable hScrollKnob = style.hScrollKnob; final Drawable vScrollKnob = style.vScrollKnob; float bgLeftWidth = 0, bgRightWidth = 0, bgTopHeight = 0, bgBottomHeight = 0; if (bg != null) { bgLeftWidth = bg.getLeftWidth(); bgRightWidth = bg.getRightWidth(); bgTopHeight = bg.getTopHeight(); bgBottomHeight = bg.getBottomHeight(); }/*from w w w . j a v a 2 s.c o m*/ float width = getWidth(); float height = getHeight(); float scrollbarHeight = 0; if (hScrollKnob != null) scrollbarHeight = hScrollKnob.getMinHeight(); if (style.hScroll != null) scrollbarHeight = Math.max(scrollbarHeight, style.hScroll.getMinHeight()); float scrollbarWidth = 0; if (vScrollKnob != null) scrollbarWidth = vScrollKnob.getMinWidth(); if (style.vScroll != null) scrollbarWidth = Math.max(scrollbarWidth, style.vScroll.getMinWidth()); // Get available space size by subtracting background's padded area. areaWidth = width - bgLeftWidth - bgRightWidth; areaHeight = height - bgTopHeight - bgBottomHeight; if (widget == null) return; // Get widget's desired width. float widgetWidth, widgetHeight; if (widget instanceof Layout) { Layout layout = (Layout) widget; widgetWidth = layout.getPrefWidth(); widgetHeight = layout.getPrefHeight(); } else { widgetWidth = widget.getWidth(); widgetHeight = widget.getHeight(); } // Determine if horizontal/vertical scrollbars are needed. scrollX = forceOverscrollX || (widgetWidth > areaWidth && !disableX); scrollY = forceOverscrollY || (widgetHeight > areaHeight && !disableY); boolean fade = fadeScrollBars; if (!fade) { // Check again, now taking into account the area that's taken up by any enabled scrollbars. if (scrollY) { areaWidth -= scrollbarWidth; if (!scrollX && widgetWidth > areaWidth && !disableX) { scrollX = true; } } if (scrollX) { areaHeight -= scrollbarHeight; if (!scrollY && widgetHeight > areaHeight && !disableY) { scrollY = true; areaWidth -= scrollbarWidth; } } } // Set the widget area bounds. widgetAreaBounds.set(bgLeftWidth, bgBottomHeight, areaWidth, areaHeight); if (fade) { // Make sure widget is drawn under fading scrollbars. if (scrollX) areaHeight -= scrollbarHeight; if (scrollY) areaWidth -= scrollbarWidth; } else { if (scrollbarsOnTop) { // Make sure widget is drawn under non-fading scrollbars. if (scrollX) widgetAreaBounds.height += scrollbarHeight; if (scrollY) widgetAreaBounds.width += scrollbarWidth; } else { // Offset widget area y for horizontal scrollbar. if (scrollX) widgetAreaBounds.y += scrollbarHeight; } } // If the widget is smaller than the available space, make it take up the available space. widgetWidth = disableX ? width : Math.max(areaWidth, widgetWidth); widgetHeight = disableY ? height : Math.max(areaHeight, widgetHeight); maxX = widgetWidth - areaWidth; maxY = widgetHeight - areaHeight; if (fade) { // Make sure widget is drawn under fading scrollbars. if (scrollX) maxY -= scrollbarHeight; if (scrollY) maxX -= scrollbarWidth; } amountX = MathUtils.clamp(amountX, 0, maxX); amountY = MathUtils.clamp(amountY, 0, maxY); // Set the bounds and scroll knob sizes if scrollbars are needed. if (scrollX) { if (hScrollKnob != null) { float hScrollHeight = style.hScroll != null ? style.hScroll.getMinHeight() : hScrollKnob.getMinHeight(); hScrollBounds.set(bgLeftWidth, bgBottomHeight, areaWidth, hScrollHeight); hKnobBounds.width = Math.max(hScrollKnob.getMinWidth(), (int) (hScrollBounds.width * areaWidth / widget.getWidth())); hKnobBounds.height = hScrollKnob.getMinHeight(); hKnobBounds.x = hScrollBounds.x + (int) ((hScrollBounds.width - hKnobBounds.width) * getScrollPercentX()); hKnobBounds.y = hScrollBounds.y; } else { hScrollBounds.set(0, 0, 0, 0); hKnobBounds.set(0, 0, 0, 0); } } if (scrollY) { if (vScrollKnob != null) { float vScrollWidth = style.vScroll != null ? style.vScroll.getMinWidth() : vScrollKnob.getMinWidth(); vScrollBounds.set(width - bgRightWidth - vScrollWidth, height - bgTopHeight - areaHeight, vScrollWidth, areaHeight); vKnobBounds.width = vScrollKnob.getMinWidth(); vKnobBounds.height = Math.max(vScrollKnob.getMinHeight(), (int) (vScrollBounds.height * areaHeight / widgetHeight)); vKnobBounds.x = width - bgRightWidth - vScrollKnob.getMinWidth(); vKnobBounds.y = vScrollBounds.y + (int) ((vScrollBounds.height - vKnobBounds.height) * (1 - getScrollPercentY())); } else { vScrollBounds.set(0, 0, 0, 0); vKnobBounds.set(0, 0, 0, 0); } } if (widget.getWidth() != widgetWidth || widget.getHeight() != widgetHeight) { widget.setWidth(widgetWidth); widget.setHeight(widgetHeight); if (widget instanceof Layout) { Layout layout = (Layout) widget; layout.invalidate(); layout.validate(); } } else { if (widget instanceof Layout) ((Layout) widget).validate(); } }
From source file:com.bladecoder.engineeditor.ui.components.CellRenderer.java
License:Apache License
public void layout(CustomListStyle style) { this.style = style; BitmapFont font = style.font;/*from w ww . ja va 2 s. c om*/ Drawable selectedDrawable = style.selection; textOffsetX = selectedDrawable.getLeftWidth(); textOffsetY = selectedDrawable.getTopHeight() - font.getDescent(); itemHeight = font.getCapHeight() - font.getDescent() * 2; if (hasSubtitle()) { itemHeight += style.subtitleFont.getCapHeight() - style.subtitleFont.getDescent() * 2; ; } itemHeight += selectedDrawable.getTopHeight() + selectedDrawable.getBottomHeight(); }
From source file:com.bladecoder.engineeditor.ui.components.CustomList.java
License:Apache License
public void layout() { final BitmapFont font = style.font; final BitmapFont subfont = style.subtitleFont; final Drawable selectedDrawable = style.selection; cellRenderer.layout(style);//from ww w .j a va 2s . c om GlyphLayout textLayout = new GlyphLayout(); prefWidth = 0; for (int i = 0; i < items.size; i++) { textLayout.setText(font, cellRenderer.getCellTitle(items.get(i))); prefWidth = Math.max(textLayout.width, prefWidth); if (cellRenderer.hasImage()) { TextureRegion r = cellRenderer.getCellImage(items.get(i)); float ih = r.getRegionHeight(); float iw = r.getRegionWidth(); if (ih > getItemHeight() - 10) { ih = getItemHeight() - 10; iw *= ih / r.getRegionHeight(); } prefWidth = Math.max(iw + textLayout.width, prefWidth); } if (cellRenderer.hasSubtitle()) { String subtitle = cellRenderer.getCellSubTitle(items.get(i)); if (subtitle != null) { textLayout.setText(subfont, subtitle); prefWidth = Math.max(textLayout.width, prefWidth); } } } prefWidth += selectedDrawable.getLeftWidth() + selectedDrawable.getRightWidth(); prefHeight = items.size * cellRenderer.getItemHeight(); Drawable background = style.background; if (background != null) { prefWidth += background.getLeftWidth() + background.getRightWidth(); prefHeight += background.getTopHeight() + background.getBottomHeight(); } }
From source file:com.bladecoder.engineeditor.ui.components.CustomList.java
License:Apache License
@Override public void draw(Batch batch, float parentAlpha) { validate();//from w ww . j ava2 s .c om Color color = getColor(); batch.setColor(color.r, color.g, color.b, color.a * parentAlpha); float x = getX(), y = getY(), width = getWidth(), height = getHeight(); float itemY = height; Drawable background = style.background; if (background != null) { background.draw(batch, x, y, width, height); float leftWidth = background.getLeftWidth(); x += leftWidth; itemY -= background.getTopHeight(); width -= leftWidth + background.getRightWidth(); } for (int i = 0; i < items.size; i++) { if (cullingArea == null || (itemY - cellRenderer.getItemHeight() <= cullingArea.y + cullingArea.height && itemY >= cullingArea.y)) { T item = items.get(i); boolean selected = selection.contains(item); cellRenderer.draw(batch, parentAlpha, item, selected, x, y + itemY, width, cellRenderer.getItemHeight()); } else if (itemY < cullingArea.y) { break; } itemY -= cellRenderer.getItemHeight(); } }
From source file:com.calanti.androidnativekeyboardinputtest.libgdxModified_1_9_3.CalTextField.java
License:Apache License
protected float getTextY(BitmapFont font, Drawable background) { float height = getHeight(); float textY = textHeight / 2 + font.getDescent(); if (background != null) { float bottom = background.getBottomHeight(); textY = textY + (height - background.getTopHeight() - bottom) / 2 + bottom; } else {/* w w w . j av a 2 s. c o m*/ textY = textY + height / 2; } if (font.usesIntegerPositions()) textY = (int) textY; return textY; }
From source file:com.idp.engine.ui.graphics.actors.TextArea.java
@Override protected void sizeChanged() { lastText = null; // Cause calculateOffsets to recalculate the line breaks. // The number of lines showed must be updated whenever the height is updated BitmapFont font = getStyle().font;//from w w w .j a va 2 s .c o m Drawable background = getStyle().background; float availableHeight = getHeight() - (background == null ? 0 : background.getBottomHeight() + background.getTopHeight()); linesShowing = (int) Math.floor(availableHeight / font.getLineHeight()); }
From source file:com.idp.engine.ui.graphics.actors.TextArea.java
@Override protected float getTextY(BitmapFont font, Drawable background) { float textY = getHeight(); if (background != null) { textY = (int) (textY - background.getTopHeight()); }// w ww. j a va 2 s . co m return textY; }