void ui_demo( bool in_loop ) { static bool ran_once = false; if(ran_once) return; ran_once = true; // don't make more than one window Window *wnd = new Window( 200, 100, 400, 300, "User Interface Demo" ); UI::Add( wnd ); wnd->AddChild( new Button( 152, 262, 96, 25, "OK" ) ); wnd->AddChild( new Textbox( 50, 50, 100, 1 ) ); wnd->AddChild( new Checkbox( 50, 100, 0, "Toggle This" ) ); }
int test_ui(int argc, char **argv){ bool quit=false; Input inputs; Timer::Update(); Window *awin = static_cast<Window*>(UI::Add(new Window(0,0,200,400,"A Window"))); Tabs *tabcont = static_cast<Tabs*>(awin->AddChild(new Tabs(5,25,180,300,"Tabs"))); Tab *tab1 = static_cast<Tab*>(tabcont->AddChild(new Tab("Tab1"))); Tab *tab2 = static_cast<Tab*>(tabcont->AddChild(new Tab("Tab2"))); tab1->AddChild(new Picture(50,100,50,50,"Resources/Graphics/corvet.png")); tab1->AddChild(new Checkbox(10,120,true,"Hello")); tab1->AddChild(new Button(100,300,50,20,"A button")); tab1->AddChild(new Button(100,340,50,20,"A button2")); tab2->AddChild(new Slider(5,20,100,20,"Slider")); tab2->AddChild(new Textbox(5,50,100,1,"Hello","Textbox")); tab2->AddChild(new Label(5,80,"Hello")); while( !quit ) { quit = inputs.Update(); Timer::Update(); Video::Erase(); UI::Draw(); Video::Update(); Timer::Delay(); } return 0; }
/**\brief Presents a message with a single "Ok" button. */ void Dialogs::Alert( const char *message ) { Window* win = new Window(325, 265, 325, 130, "Alert"); win->AddChild( ( new Label( 45, 35, message ) ) ) ->AddChild( (new Button( 130, 90, 80, 30, "OK", OKAlertDialog, NULL ) ) ); UI::ModalDialog( win ); }
/**\brief Presents a question with "Ok/Cancel" buttons. * \return Returns true on "Ok", false otherwise */ bool Dialogs::Confirm( const char *message ) { Window* win = new Window(325, 265, 325, 130, "Confirm"); static int value = 0; win->AddChild( ( new Label( 45, 35, message ) ) ) ->AddChild( (new Button( 65, 90, 80, 30, "Cancel", CancelConfirmDialog, &value ) ) ) ->AddChild( (new Button( 190, 90, 80, 30, "OK", OKConfirmDialog, &value ) ) ); UI::ModalDialog( win ); return value; }