-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package arc.scene.ui.layout; | ||
|
||
import arc.func.*; | ||
import arc.scene.*; | ||
|
||
public class Spacer extends Element{ | ||
Floatp widthFunc, heightFunc; | ||
|
||
public Spacer(Floatp widthFunc, Floatp heightFunc){ | ||
this.widthFunc = widthFunc; | ||
this.heightFunc = heightFunc; | ||
|
||
width = Scl.scl(widthFunc.get()); | ||
height = Scl.scl(heightFunc.get()); | ||
} | ||
|
||
@Override | ||
public void act(float delta){ | ||
super.act(delta); | ||
|
||
float w = Scl.scl(widthFunc.get()), h = Scl.scl(heightFunc.get()); | ||
if(w != width || h != height){ | ||
width = w; | ||
height = h; | ||
invalidateHierarchy(); | ||
} | ||
} | ||
|
||
@Override | ||
public float getPrefHeight(){ | ||
return heightFunc.get(); | ||
} | ||
|
||
@Override | ||
public float getPrefWidth(){ | ||
return widthFunc.get(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters