Skip to content
Snippets Groups Projects
Select Git revision
  • 38ef7e3bab370f4dc7c1c86e43b3f847fdfc70f4
  • main default protected
2 results

application.cpp

Blame
  • application.cpp 804 B
    #include "application.hpp"
    #include "graphics.hpp"
    #include "widget.hpp"
    
    
    using namespace genv;
    
    Application::Application()
    {
        gout.open(910,910);
    
    
    }
    
    void Application::event_loop()
    {
        event ev;
        int focus = -1;
        while(gin >> ev )
        {
            if (ev.type == ev_mouse && ev.button==btn_left)
            {
                for (size_t i=0; i<widgets.size(); i++)
                {
                    if (widgets[i]->isover(ev.pos_x, ev.pos_y))
                    {
                        focus = i;
                    }
                }
            }
            if (focus!=-1)
            {
                widgets[focus]->handle(ev);
            }
            for (Widget * w : widgets)
            {
                w->draw2();
            }
            gout << refresh;
        }
    }
    
    void Application::registerWidget(Widget* w)
    {
        widgets.push_back(w);
    }