void make_progressbar(float value, video::IImage *image) { if(image == NULL) return; core::dimension2d<u32> size = image->getDimension(); u32 barheight = size.Height/16; u32 barpad_x = size.Width/16; u32 barpad_y = size.Height/16; u32 barwidth = size.Width - barpad_x*2; v2u32 barpos(barpad_x, size.Height - barheight - barpad_y); u32 barvalue_i = (u32)(((float)barwidth * value) + 0.5); video::SColor active(255,255,0,0); video::SColor inactive(255,0,0,0); for(u32 x0=0; x0<barwidth; x0++) { video::SColor *c; if(x0 < barvalue_i) c = &active; else c = &inactive; u32 x = x0 + barpos.X; for(u32 y=barpos.Y; y<barpos.Y+barheight; y++) { image->setPixel(x,y, *c); } } }
void DockBarExtension::mouseMoveEvent(QMouseEvent *e) { if(!(e->state() & LeftButton)) return; if(dragging_container == 0) { // Check whether the user has moved far enough. int delay = QApplication::startDragDistance(); if((mclic_pos - e->pos()).manhattanLength() > delay) { int pos = findContainerAtPoint(e->pos()); original_container = 0; if(pos > -1) { original_container = containers.at(pos); mclic_dock_pos = e->pos() - original_container->pos(); dragged_container_original_pos = pos; dragging_container = new DockContainer(original_container->command(), 0, original_container->resName(), original_container->resClass(), true); dragging_container->show(); dragging_container->embed(original_container->embeddedWinId()); grabMouse(); } } } if(dragging_container) { dragging_container->move(e->globalPos() - mclic_dock_pos); // change layout of other containers QPoint dragpos(dragging_container->pos()), barpos(mapToGlobal(pos())); int pdrag1, pdrag2, psz; pdrag1 = dragpos.x() - barpos.x() + DockContainer::sz() / 2; pdrag2 = dragpos.y() - barpos.y() + DockContainer::sz() / 2; if(orientation() == Vertical) { int tmp = pdrag1; pdrag1 = pdrag2; pdrag2 = tmp; psz = height(); } else psz = width(); if(pdrag2 >= 0 && pdrag2 < DockContainer::sz() && pdrag1 >= 0 && pdrag1 < psz) pdrag1 /= DockContainer::sz(); else pdrag1 = dragged_container_original_pos; DockContainer::Vector::iterator it = qFind(containers.begin(), containers.end(), original_container); if(it == containers.end()) { return; } DockContainer::Vector::iterator target = containers.begin(); for(int i = 0; i < pdrag1 && target != containers.end(); ++i) { ++target; } containers.erase(it); containers.insert(target, original_container); layoutContainers(); } }