Esempio n. 1
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;
      }
   }
}
Esempio n. 2
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);
      }
   }
}
Esempio n. 3
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());
   }
}
Esempio n. 4
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;
   }
}