LibGDX how to make a buttons size independent of image - libgdx

When adding images to a TextButton in LibGDX how would I match the button to the contents of the image. Currently when I set size the image scales down to fit the button which leaves a large gap between the edge of the button and the contents of the image (See distance from green debug border to the edge of the buttons image).
I would like to be able to set the size of the button to match the content of the image so that the empty space around the image is ignored. I could crop out the empty space from the image but would have an off centered image due to the drop shadow and so would like to avoid that.
Top image shows the displayed dutton in game including the debug button border in green. Bottom image shows the source image with empty space.
TextButton.TextButtonStyle buttonStyle = new TextButton.TextButtonStyle();
buttonStyle.font = FontLoader.uiFont;
buttonStyle.up = new SpriteDrawable(new Sprite(assetManager.get(UISpriteLoader.SPRITE_UI_TAMING_BUTTON_BASE, Texture.class)));
buttonStyle.down = new SpriteDrawable(new Sprite(assetManager.get(UISpriteLoader.SPRITE_UI_TAMING_BUTTON_PRESSED, Texture.class)));
buttonStyle.over = new SpriteDrawable(new Sprite(assetManager.get(UISpriteLoader.SPRITE_UI_TAMING_BUTTON_HOVER, Texture.class)));
tameButton = new TextButton("Tame", buttonStyle);
tameButton.setPosition(1470, 1080-330-80);
tameButton.setSize(250, 80);
stage.addActor(tameButton);

Use a Ninepatch for your images. It will scale to fill the button out of the box.
I recommend you to use Skin Composer both for making the Ninepatches and for creating a Scene2d skin so you don't have to create your Styles in code.

Related

SSRS 2016 Fix a size of Rectangle

I have a rectangles in my Cockpit with an Image Background. Earlier I have put the Images on this rectangle as Buttons. Now the requierments were changed and I am putting as a button a TextBox with an Image Background so that I can make drill down Buttons.
The Problem is that it changes the size of rectangle in browser or in visual Studio(Preview).
How can I fix the size of rectangle ?
This Image is in VisualStudio Design 1
This Image is in Browser2
I am clicking on "Produktivität" the drill down menu opens but still the Rectangle doesn't have the whole size 3
The Rectangle should have the following size which I gave in Properties4
Thank you in advance!
Ghukas

Background Image on Cover Page Distorted in SSRS

I am trying to incorporate the following image into the cover page of my report.
It's currently saved as a PNG file with dimension 1275 x 1650.
Like a lot of online posts suggested, I
* inserted a rectangle
* set the image as the background image
And here are my properties for the rectangle.
When I rendered my report to PDF, the image was splitted
into multiple blank pages and the bottom of the graphic (with logo and URL)
didn't even show.
How can I make sure this graphic is displayed fully on only the first page?
I can't tell if you have other objects on your cover page, but here's what I did to get this working correctly.
Add an image object to your report.
Make sure the margins are set fairly low(I used .25in for top, bottom, left, and right).
With the margins set at .25in, I set the image object to a size of 8in x 10.5in to fill the remaining space on the page.
In the image object properties, set padding options all to zero and Display to "Fit to size".
Now the trick here, is to put the image object in the very top left corner and resize the report to the exact size of the image object -- no whitespace in the design view. For me, this returns a single page report with the entire image shown on a single page.

Image scale by width in both directions, without stretching the content in the center

I'm trying to set bigger width to my image but I need that the center part of the image remains without stretching. NinePatch assumes keeping corners from stretching, but I want something similar for the center part. I tried to set two different columns of pixels in ninePatch editor and assumed it will be symmetric scaled in both parts , but It takes in consideration only the first part, so I think libgdx ninepatch system does not allow to do that. Any ideas how to solve the problem in most convenient way?
There are no ninepatch equivalent that will allow to stretch an image without stretching a defined center part.
The simplest solution I see is using 2 images on top of each other.
The top image: corresponds to the center part of your final image. You'll set it to the dimensions you want it to appear.
The bottom image: corresponds to the borders of your final image. So basically it will be your final image, in which you replace the center part with blank. This bottom image will be stretched.
By combining these 2 images you'll create the illusion of an image that stretchs but with a center that keeps a constat size.

Adobe Edge Animate: Is there a way to use CSS media queries to resize an image?

I'm using Adobe Edge Animate and I'm really having trouble with all the different screen sizes and resolutions. I see that Adobe is coming out with new products which may address this issue. Basically all I'm tryng to do is have an image display (like a banner for example) that fills the width of the user's screen. I see the following questions, but answers are old and I know that there has been a lot of development in this area. Any ideas greatly apprciated.
Stackoverflow questions
From the splash screen. In the Properties tab change the switch next to the width to make it 100%. Select the Max W parameter and change this to too. All these tweaks will make the layout responsive. Next drag the image onto the stage and position in the top-left corner. In Properties click on Use Presets for Responsive Layout and choose the Center Background Image option, then Apply. This means the image will stay central whenever the stage morphs. Drag the bottom-right corner handle so the image fits over the entire background. Notice the image doesn’t scale or stretch but stays in the centre. In the Position and Size tab is an expand button; click this and add a Max W of (how many px your image is). Change the width to 100% and press Enter. It will jump right back to 75% but it has accepted the change. Click on the resize marker and drag to the left to see what happens when the stage is resized to a smaller layout. As you can see, the background is clipped but the image resizes to fit.
Here is a link to the tutorial I think this will better answer your question if you do this tutorial. http://www.webdesignermag.co.uk/tutorials/create-a-responsive-animation-with-adobe-edge-animate/

Rounded box in SSRS

I have rectangle which act as container for other elements.
Can I somehow setup some property of rectangle to round its corners, in fact, to get rounded box.
In css it is easy, but how to do in SSRS?
Actually, it is fairly easy. I had a bunch of text boxes that a rounded corner border needed to be placed. The first thing I tried was an image control. I placed it on top of my text boxes and set it to "Send to back." It worked well in print rendering, however, in the browser rendering the HTML placed the textboxes after the image making it look horrible.
The solution was this:
Go into paint and draw a rounded corner box the size you need.
Cut the set of text boxes to surround with rounded border.
Place a rectangle control over the entire area all the text boxes covered.
Paste my text boxes onto the rectangle.
Right-Click and choose rectangle properties.
Select the Fill Tab and select "Embedded" image source.
Click Import and select your paint image(i used PNG but it shouldn't matter).
Click Ok.
Find and expand BackgroundImage on Rectangle and change BackgroundRepeat to "Clip.". Otherwise, your image is repeated.
The report should now render properly in both print and html rendering views. Unfortunately, this doesn't seem to stretch/size, so unless you can figure that one out, you will have to repeat whenever you need a different sized rounded box.
Brian
All solution I have seen use a background image inside a textbox.
But you get problems when you try to resize the textbox.
The solution is to insert a 3x3 table inside the texbox.
Insert the 3x3 table
Insert an image on each corner. They will be a quarter of a circle each. (This image is created in MS Paint or your favorite image program)
Make those 4 corners cells unresizable (Set property CanGrow to false). Make sure all the other cells have CanGrow = true if you need it
Make all the cells the same background color (same color as the image you draw).
Write your text in the middle cell.
OPTIONAL: It might also be a good idea to fuse the 3 vertical middle cells if possible. It will allow more space to write text in the cell.
This way you won't have to create new image everytime the size of your textbox change.
You would have to build an image that has a transparent center for adding your text.
All this would be more work than I would want to do just for a report.
I would stick with just the standard textboxes.