예제 #1
0
bool ContextMenu::processMouse(const scv::MouseEvent &evt) {
   static Kernel *kernel = Kernel::getInstance();
   static MenuHolder *menu = MenuHolder::getInstance();

   if (getStatus() == false || hasSubMenus() == false) return false;

   if (_currSelectedMenu != -1 && _list[_currSelectedMenu]->processMouse(evt) == true) {
      return true;
   } else {
      if (isInside(evt.getPosition())) {
         for (int i = 0; i < _list.size(); i++) {
            if (isInsideItem(evt.getPosition(), i)) {
                  _currSelectedMenu = i;
                  _list[_currSelectedMenu]->setStatus(true);

                  processMouseCallback(evt, std::deque<std::string>(1, _list[i]->_label));

            } else if (i != _currSelectedMenu || ((_currSelectedMenu != -1)? !_list[_currSelectedMenu]->isInside(evt.getPosition()) : true)) {
               _list[i]->setStatus(false);
            }
         }
         return true;
      } else if (!hasSubMenuActive()) {
         _currSelectedMenu = -1;
      }
   }


   return false;
}
예제 #2
0
void CanvasVOrig::onMouseOver(const scv::MouseEvent& evt)
{
   if((((double)evt.getPosition().x - ((double)eixoy + (((450)/((double)nVal))/2.0))) )/((450)/((double)nVal)) >= 0 
     &&(((double)evt.getPosition().x - ((double)eixoy + (((450)/((double)nVal))/2.0))) )/((450)/((double)nVal)) < (double)nVal) {
      position_vector =(int)((((double)evt.getPosition().x - ((double)eixoy+ (((450)/((double)nVal))/2.0))) )/((450)/((double)nVal)));
      position_vector += (int)MyValues->valIni-1;
   }
}
예제 #3
0
void TabbedPane::processMouse(const scv::MouseEvent &evt) {
   static Kernel *kernel = Kernel::getInstance();

   if (isDragging() || isResizing()) {
      Component::processMouse(evt);
      if (getCurrTabIndex() != -1 && isResizing()) {
         configPanel();
      }
   } else {

      if (getCurrTabIndex() == -1 || !_receivingCallbacks) {
         Component::processMouse(evt);
         return;
      } else if(getCurrTabIndex() != -1) {
         getChild(getCurrTabIndex())->setDraggable(false);
         getChild(getCurrTabIndex())->processMouse(evt);
      }

      Component::processMouse(evt);

      Point currPosition = getAbsolutePosition();
      Point relativeMouse = evt.getPosition();

      if (evt.getState() == MouseEvent::UP) configPanel();

      // open menu
      if (isInside(evt.getPosition())) {
         _currecOverTab = -1;
         if (kernel->requestMouseUse(this)) {
            // over menu
            for (int i = 0; i < _children.size(); i++) {
               if (relativeMouse.x > _index[i] + currPosition.x && relativeMouse.x < _index[i + 1] + currPosition.x - 1
                  && relativeMouse.y > currPosition.y && relativeMouse.y < currPosition.y + s_barHeight) {
                     if (getCurrTabIndex() != i) _currecOverTab = i;
                     break;
               }
            }
            if (isFocused()) {
               if (evt.getState() == MouseEvent::CLICK && evt.getButton() == MouseEvent::LEFT) {
                  for (int i = 0; i < _children.size(); i++) {
                     if (relativeMouse.x > _index[i] + currPosition.x && relativeMouse.x < _index[i + 1] + currPosition.x - 1
                        && relativeMouse.y > currPosition.y && relativeMouse.y < currPosition.y + s_barHeight) {
                           setCurrTabIndex(i);
                           _currecOverTab   = -1;
                           configPanel();
                           break;
                     }
                  }
               }
            }
         }
      } else {
         _currecOverTab = -1;
      }
   }
}
예제 #4
0
void ColorPicker::processMouse(const scv::MouseEvent &evt) {
   static Kernel *kernel = Kernel::getInstance();
   static Cursor * cursor = Cursor::getInstance();

   if (!_receivingCallbacks) {
      Component::processMouse(evt);
   } else {
      Panel::processMouse(evt);
   }

   if (!_receivingCallbacks) return;

   if (_pickerWaitingColor) {
      kernel->lockMouseUse(this);
	  cursor->forceCursor(kernel->glfwWindow, GLFW_CROSSHAIR_CURSOR);
      glReadPixels(evt.getPosition().x, evt.getInversePosition().y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &_currentColor);
      setSpinsColor();
      onColorChange();
      if (evt.getState() == MouseEvent::CLICK && evt.getButton() == MouseEvent::LEFT) {
         _btPicker->setState(false);
         _pickerWaitingColor = false;
         _currentColorPosition = foundHSL();
         createTexture();
      }
   } else {
      if (isInside(evt.getPosition()) && kernel->requestMouseUse(this)) {
         if (isFocused()) {
            Point relativeMouse = evt.getPosition()-getAbsolutePosition();
            if (relativeMouse.x < MatrixTemplate<ColorRGBA>::getWidth() && relativeMouse.y < MatrixTemplate<ColorRGBA>::getHeight()) {
				cursor->forceCursor(kernel->glfwWindow, GLFW_CROSSHAIR_CURSOR);
               if (evt.getState() == MouseEvent::CLICK && evt.getButton() == MouseEvent::LEFT) {
                  _isDragging = false;
                  _currentColorPosition = relativeMouse;
                  _currentColor =  ColorRGBA(MatrixTemplate<ColorRGBA>::get(_currentColorPosition.y,_currentColorPosition.x));
                  setSpinsColor();
                  onColorChange();
                  onMouseClick(evt);
               } else if (evt.getState() == MouseEvent::HOLD && evt.getButton() == MouseEvent::LEFT) {
                  kernel->lockMouseUse(this);
                  _isDragging = false;
                  _currentColorPosition = relativeMouse;
                  _currentColor =  ColorRGBA(MatrixTemplate<ColorRGBA>::get(_currentColorPosition.y,_currentColorPosition.x));
                  setSpinsColor();
                  onColorChange();
                  onMouseDrag(evt);
               } else if (evt.getState() == MouseEvent::UP) {
                  kernel->unlockMouseUse(this);
               }
            }
         }
      } else if (evt.getState() == MouseEvent::UP) {
         kernel->unlockMouseUse(this);
      }
   }
}
예제 #5
0
void CanvasPista::onMouseClick(const scv::MouseEvent &evt) {
        Ponto pontoClique(evt.getPosition().x, evt.getPosition().y);
        if (pontosDeControle.size()==0) // Se for o primeiro ponto adicionado
        {
            pontoInicial = pontoClique;
        }
		if (buttonOk == false)
		{
			pontosDeControle.push_back(pontoClique);	 // Adiciona o clique aos pontos de controle
		}
}
예제 #6
0
void ToggleButton::processMouse(const scv::MouseEvent &evt) {
   static Kernel *kernel = Kernel::getInstance();

   Component::processMouse(evt);

   if (!_receivingCallbacks) return;

   if (isInside(evt.getPosition())) {
      if (evt.getState() == MouseEvent::UP && isFocused())
         setState(!getState());
   }
}
예제 #7
0
void CanvasVOrig::onMouseHold (const scv::MouseEvent& evt)
{     
   if((((double)evt.getPosition().x - ((double)eixoy + (((450)/((double)nVal))/2.0))) )/((450)/((double)nVal)) >= 0 
     &&(((double)evt.getPosition().x - ((double)eixoy + (((450)/((double)nVal))/2.0))) )/((450)/((double)nVal)) < (double)nVal) {
      position_vector =(int)((((double)evt.getPosition().x - ((double)eixoy+ (((450)/((double)nVal))/2.0))) )/((450)/((double)nVal)));
      position_vector += (int)MyValues->valIni-1;
      if(((double)evt.getPosition().y - 280.0)*-1.0 < 0) {
         MyValues->initialValues[position_vector] = 0;
      }else if(((double)evt.getPosition().y - 280.0)*-1.0 > 255){
         if(evt.getButton() == GLUT_RIGHT_BUTTON){
            MyValues->initialValues[position_vector] = 0;
         }else if(evt.getButton() == GLUT_LEFT_BUTTON){
            MyValues->initialValues[position_vector] = 255;
         }                      
      } else {
         if(evt.getButton() == GLUT_RIGHT_BUTTON){
            MyValues->initialValues[position_vector] = 0;
         }else if(evt.getButton() == GLUT_LEFT_BUTTON){
            MyValues->initialValues[position_vector] = (((double)evt.getPosition().y - eixox)*-1.0);
         }       
      }
      //MyValues->dctValues = MDCT->DCT(MyValues->initialValues);
      //MyValues->dctEditValues = MyValues->dctValues;
   }
}
예제 #8
0
void ComboBox::processMouse(const scv::MouseEvent &evt) {
   static Kernel *kernel = Kernel::getInstance();

   Component::processMouse(evt);

   //if (!_receivingCallbacks) return;

   if (isInside(evt.getPosition())) {
      if (evt.getState() == MouseEvent::CLICK && evt.getButton() == MouseEvent::LEFT && isFocused()) {
         if (_active) {
            _active = false;
         } else {
            popupMenu();
            _active = true;
         }
      }else if (evt.getState() == MouseEvent::CLICK && evt.getButton() == MouseEvent::RIGHT) {
         _active = false;
      }
   }else if (evt.getState() == MouseEvent::CLICK){
      _active = false;
   }
}