Example usage for com.badlogic.gdx.utils Scaling fillX

List of usage examples for com.badlogic.gdx.utils Scaling fillX

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils Scaling fillX.

Prototype

Scaling fillX

To view the source code for com.badlogic.gdx.utils Scaling fillX.

Click Source Link

Document

Scales the source to fill the target in the x direction while keeping the same aspect ratio.

Usage

From source file:com.kotcrab.vis.editor.module.project.assetsmanager.FileItem.java

License:Apache License

private void createContent() {
    String ext = file.extension();
    String relativePath = fileAccess.relativizeToAssetsFolder(file);

    boolean texture = ProjectPathUtils.isTexture(file);
    boolean atlas = ProjectPathUtils.isTextureAtlas(file);

    if (file.isDirectory()) {
        type = AssetType.DIRECTORY;//from w  w  w .ja  v  a2  s . c o  m

        Drawable icon;
        AssetDirectoryDescriptor desc = assetsMetadata.getAsDirectoryDescriptor(file);
        if (desc != null) {
            icon = desc.getAssetsViewIcon();
        } else {
            icon = Icons.FOLDER_MEDIUM.drawable();
        }
        add(new VisImage(icon, Scaling.fillX)).row();

        name = new VisLabel(file.nameWithoutExtension());
    }

    if (ProjectPathUtils.isTrueTypeFont(file)) {
        createDefaultView(AssetType.TTF_FONT, "TTF Font", true);
        return;
    }

    if (ProjectPathUtils.isBitmapFont(file)) {
        createDefaultView(AssetType.BMP_FONT_FILE, "BMP Font", true);
        return;
    }

    if (ProjectPathUtils.isBitmapFontTexture(file)) {
        createDefaultView(AssetType.BMP_FONT_TEXTURE, "BMP Font Texture", true);
        return;
    }

    if (ProjectPathUtils.isTextureAtlasImage(file)) {
        createDefaultView(AssetType.TEXTURE_ATLAS_IMAGE, "TextureAtlas Image", true);
        return;
    }

    if (texture || atlas) {
        type = texture ? AssetType.TEXTURE : AssetType.TEXTURE_ATLAS;

        //don't create region preview for files excluded from texture cache
        AssetDirectoryDescriptor desc = assetsMetadata.getAsDirectoryDescriptorRecursively(file);
        if (desc != null && desc.isExcludeFromTextureCache()) {
            createDefaultView(type, texture ? "Texture" : "Texture Atlas", true);
            return;
        }

        name = new VisLabel(texture ? file.nameWithoutExtension() : file.name(), "small");

        TextureRegion region;

        if (atlas) {
            region = textureCache.getRegion(new AtlasRegionAsset(relativePath, null));
        } else {
            region = textureCache.getRegion(new TextureRegionAsset(relativePath));
        }

        Image img = new Image(region);
        img.setScaling(Scaling.fit);
        add(img).expand().fill().row();

        this.region = region;

        return;
    }

    if (ProjectPathUtils.isParticle(file)) {
        createDefaultView(AssetType.PARTICLE_EFFECT, "Particle Effect", true);
        return;
    }

    if (ProjectPathUtils.isMusicFile(assetsMetadata, file)) {
        createDefaultView(AssetType.MUSIC, "Music");
        return;
    }

    if (ProjectPathUtils.isSoundFile(assetsMetadata, file)) {
        createDefaultView(AssetType.SOUND, "Sound");
        return;
    }

    if (ProjectPathUtils.isFragmentShader(file)) {
        createDefaultView(AssetType.FRAGMENT_SHADER, "Fragment Shader", true);
        return;
    }

    if (ProjectPathUtils.isVertexShader(file)) {
        createDefaultView(AssetType.VERTEX_SHADER, "Vertex Shader", true);
        return;
    }

    if (ProjectPathUtils.isScene(file)) {
        createDefaultView(AssetType.SCENE, "Scene", true);
        return;
    }

    support = findSupportForDirectory(file, relativePath);
    if (support != null) {
        ContentItemProperties item = support.getContentItemProperties(file, relativePath, ext);
        if (item != null) {
            createDefaultView(item.type, item.title, item.hideExtension);
            return;
        }
    }

    type = AssetType.UNKNOWN;
    name = new VisLabel(file.name());
}

From source file:pl.xesenix.games.effects.screens.MenuScreen.java

License:Open Source License

public void resize(int width, int height) {
    Gdx.app.log(XesEffects.LOG, "Resizing MenuScreen");
    super.resize(width, height);

    Vector2 menuTitleSize = Scaling.fillX.apply(512f, 100f, width, height);

    this.layout.setPosition(0, 0);
    this.layout.setWidth(width);
    this.layout.setHeight(height - menuTitleSize.y);
    this.layout.invalidate();
}

From source file:pl.xesenix.games.effects.screens.SplashScreen.java

License:Open Source License

public void show() {
    Gdx.app.log(XesEffects.LOG, "Showing SplashScreen");
    super.show();

    // preparing actors
    // - background:
    this.bgTexture = new Texture("data/splash_screen.png");
    this.bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    TextureRegion bgTextureRegion = new TextureRegion(bgTexture, 0, 0, 512, 512);

    TextureRegionDrawable drawableBg = new TextureRegionDrawable(bgTextureRegion);

    this.bgImage = new Image(drawableBg, Scaling.fillX, Align.left | Align.top);
    this.bgImage.setFillParent(true);

    // building stage
    this.stage.clear();
    this.stage.addActor(this.bgImage);

    // show animation
    this.stage.addAction(sequence(fadeOut(0), moveTo(0, Gdx.graphics.getHeight() / 2),
            parallel(fadeIn(1.5f), moveTo(0, 0, 1.5f))));
}