-
Notifications
You must be signed in to change notification settings - Fork 3
Gem Gui
George Michaelides edited this page Apr 29, 2015
·
28 revisions
Gem Gui is a customisable Gui engine for rendering controls MonoGame.
var button = GemGui.Button(int x, int y, int sizeX, int sizeY);
Button(int x, int y, int sizeX, int sizeY)
ImageButton(Texture2D image, int x, int y, int sizeX, int sizeY)
Label(Spritefont font, int x, int y, int sizeX, int sizeY, string text)
TextField(int x,int y,int sizeX, int sizeY)
Fields
ViewEvents Events;
RenderStyle Style;
ControlOptions Options;
Region Region;
Methods
void Transform(Action<AControl,double> transformation) //the current control and the elapsed time
void AddTransformation(ITransformation transformation)
void Update(double deltaTime);
void Draw(ABatchDrawable manager);
Assign the controls into groups
var listGroup = GemGui.Groups.ListGroup
listGroup.Assign(buttonOk,buttonCancel)
ListLayout
LinearLayout
GridLayout
##Events
Events respond to touch / mouse and keyboard. It is decided by the AggregationContext according to the hardware settings.
event EventHandler GotFocus;
event EventHandler LostFocus;
event EventHandler Clicked;
event EventHandler GotMouseCapture;
event EventHandler LostMouseCapture;
event EventHandler DragEnter;
event EventHandler DragLeave;
##Styles
Style has render style parameters an instance of ABatchDrawable which renders using spriteBatch and render instructions upon multiple events
float Transparency
Vector2 Scale
float Rotation
Color Color
SpriteEffects SpriteEffect
myButton.Style = StyleFactory.ButtonDefault;
StyleFactory.Add("CustomStyle",
new RenderStyleParameters(),
new DrawDetailed()
(element,style)=> {
element.GotFocus+= (element,args) => style.Transparency = 1.0f;
element.LostFocus+= (element,args) => style.Transparency = 0.5f;
});
myButton.Style = StyleFactory["CustomStyle"];
###Example
var myLabel = GemGui.Label(font: FontContainer["Segoe_10"],
x: 10,
y: 10,
sizeX: 100,
sizeY: 30,
text: "Hello");
myLabel.VerticalAlignment = VerticalAlignment.Center;
var myButton = GemGui.Button(x: 10,
y: 50,
sizeX: 50,
sizeY: 50);
myButton.Style = StyleFactory.ButtonDefault
.Text("Click me")
.TextColor(Color.Red)
.BackgroundColor(Color.White)
.OnClick += (element,args) => Log.Info("i clicked my button");
var group = GemGui.Groups.GridLayout;
group.Assign(myLabel,myButton);