module Main;

use namespace ui;

UI.Initialize(Arguments);
UI.SetEnableTransparentLayers(false);

class Test : Form {

   protected XMLForm *fx;

   protected Button *bt_quit;

   public method init() : boolean {
      fx <= XMLForm.New_PakFile("test.xfm");
      if(null != fx)
      {
         fx.autoResolveIds(this);

         addLayer(fx, Layout.CENTER);

         // Alright!
         return true;
      }

      // D'oh!
      return false;
   }

   public virtual consumeAction(Action _ac) : boolean {
      switch(@(_ac.getActionProvider()))
      {
         case @(bt_quit):
            UI.Stop();
            return true;
      }
      return Form::consumeAction(_ac);
   }
}

Test test;

if(test.init())
{
   UI.SetRootForm(test);
   UI.OpenWindow(800,600);

   // Benchmark: Redraw UI as fast as possible 
   UI.UpdateFrameRate(true);
   UI.SetEnableForceHighFramerate(true);
   Viewport.swapInterval(0);

   UI.Run();
}