Exemple #1
0
  virtual void process(const MouseEvent &e){
    if(gui["rect"].as<bool>()) return;
    Point p = e.getPos();
    
    if(!bounds.contains(p.x,p.y)){
      return;
    }

    if(e.isReleaseEvent()){
      dragged = -1;
      std::fill(handles,handles+4,0);
    }
    if(e.isPressEvent()){
      for(int i=0;i<4;++i){
        if(ps[i].distanceTo(p) < 8){
          dragged = i;
          handles[i] = 2;
        }
      }
    }
    if(e.isDragEvent()){
      if(dragged != -1){
        ps[dragged] = p;
      }
    }else if(e.isMoveEvent()){
      for(int i=0;i<4;++i){
        if(ps[i].distanceTo(p) < 8){
          handles[i] = 1;
        }else{
          handles[i] = 0;
        }
      }
    }
  }
Exemple #2
0
void mouse(const MouseEvent &e){
  if(e.isRight()){
    selroi[1] = selroi[2];
    selroi[0] = Rect::null;
    step();
  }else if(e.isLeft()){
    if(e.isPressEvent()){
      selroi[0] = Rect(e.getPos(),Size(1,1));
    }else if(e.isDragEvent()){
      selroi[0].width = e.getX() - selroi[0].x;
      selroi[0].height = e.getY() - selroi[0].y;
    }else if(e.isReleaseEvent()){
      selroi[1] = selroi[0].normalized();
      selroi[0] = Rect::null;
    }
    step();
  }
}