#include "Core.hpp" #include "Dash.hpp" #include "Toolkit.hpp" #include #include #include #include #include using namespace std; using namespace net::lliurex::llxdo; using namespace net::lliurex::lgi; void Dash::Scroll() { float target=x; float dir=0.0f; Core * core = Core::GetCore(); if(scroll_direction==ScrollDirection::Left) { target+=255.0f; dir=15.0f; } if(scroll_direction==ScrollDirection::Right) { target-=255.0f; dir=-15.0f; } while(true) { x=x+dir; core->Update(); std::chrono::milliseconds dura(15); std::this_thread::sleep_for(dura); if(abs(target-x)<1.0f)break; } scroll_direction=ScrollDirection::Stop; } Dash::Dash():Layer("llxdo::Dash") { ready=false; scroll_direction = ScrollDirection::Stop; } void Dash::OnResize(ResizeEvent * event) { cout<<"Resize to "<width<<"x"<height<width/tile_width; int h_tiles = event->height/tile_height; if(h_tiles>4)h_tiles=4; Core * core = Core::GetCore(); float x_o=10.0f; float y_o=10.0f; int th=0; for(int n=0;nslots.size();n++) { core->slots[n]->x=x_o; core->slots[n]->y=y_o; y_o+=130.0f; th++; if(th==h_tiles) { th=0; y_o=10.0f; x_o+=255.0f; } } } void Dash::OnKeyPress(KeyPressEvent * event) { switch(event->key) { case LGI_KEY_ESCAPE: Core::GetCore()->Quit(); break; case LGI_KEY_LEFT: if(scroll_direction==ScrollDirection::Stop) { scroll_direction = ScrollDirection::Left; scroll_thread = thread(&Dash::Scroll,this); scroll_thread.detach(); } break; case LGI_KEY_RIGHT: if(scroll_direction==ScrollDirection::Stop) { scroll_direction = ScrollDirection::Right; scroll_thread = thread(&Dash::Scroll,this); scroll_thread.detach(); } break; } } void Dash::Draw(cairo_t * cairo) { toolkit::set_source_rgb_ub(cairo,125,125,125); cairo_paint(cairo); if(ready) { Layer::Draw(cairo); } } void Dash::OnDndEnter(DndEnterEvent * event) { } void Dash::OnDndLeave(DndLeaveEvent * event) { } void Dash::OnDndDrop(DndDropEvent * event) { string uri((char *)event->data,event->size); cout<<"drop uri:["<(widget); cout<<"click on "<name<