Esempio n. 1
0
ActorEditTool::ActorEditTool(SceneView* sceneView, QWidget* parent, AToolManager* toolManager)
	: QDialog(parent),  ATool(toolManager), mSelectedActor(NULL), mState(eSTATE_NORMAL){
    ui.setupUi(this);

	mSceneView = sceneView;

	connect(mSceneView, SIGNAL(onMouseDrag(MouseDragEvent)),
		this, SLOT(onMouseDrag(MouseDragEvent)));

	connect(mSceneView, SIGNAL(onMouseDown(QMouseEvent*)),
		 this, SLOT(onMousePress(QMouseEvent*)));
	
	mScene = sceneView->getScene();
	mPhysics = mScene->getPhysics();

	mParticleEditDialog = new ParticleEditDialog(this, NULL);

	ui.lightAmbientIntensity->setValueRange(0, 100);
	ui.lightDiffuseIntensity->setValueRange(0, 100);

	ui.lightDiffuseIntensity->setSingleStep(0.01);
	ui.lightAmbientIntensity->setSingleStep(0.01);

	ui.lightAttenuation->setDecimals(4);

	// C
	ui.lightAttenuation->setSingleStep(0.001, VecEditWidget::eFIELD_X);
	ui.lightAttenuation->setValueRange(0, 1.0f, VecEditWidget::eFIELD_X);

	// L
	ui.lightAttenuation->setSingleStep(0.01, VecEditWidget::eFIELD_Y);
	ui.lightAttenuation->setValueRange(0, 50.0f, VecEditWidget::eFIELD_Y);

	// Q
	ui.lightAttenuation->setSingleStep(0.001, VecEditWidget::eFIELD_Z);
	ui.lightAttenuation->setValueRange(0, 1.0f, VecEditWidget::eFIELD_Z);

	ui.volume->setValueRange(0, 100);
	ui.minDistance->setValueRange(0.5, 100);
	ui.attenuation->setValueRange(0, 100);
	ui.pitch->setValueRange(0.01, 10);

	selectActor(NULL);
}
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 TextureControl::notifyMouseDrag(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
	{
		mMouseLeftPressed = false;

		if (_id == MyGUI::MouseButton::Right)
		{
			MyGUI::IntPoint mousePoint = MyGUI::InputManager::getInstance().getMousePositionByLayer();
			MyGUI::IntPoint mouseOffset = mousePoint - mRightMouseClick;

			MyGUI::IntPoint offset = mViewOffset + mouseOffset;
			mView->setViewOffset(offset);
		}
		else if (_id == MyGUI::MouseButton::Left)
		{
			onMouseDrag(getMousePosition());
		}
	}
Esempio n. 4
0
void ofxDatGuiComponent::update(bool acceptEvents)
{
// if window does not have focus x & y will both be zero //
    if (acceptEvents && mEnabled && mVisible){
        bool mp = ofGetMousePressed();
        ofPoint mouse = ofPoint(ofGetMouseX() - mParentPosition.x, ofGetMouseY() - mParentPosition.y);
        if (hitTest(mouse)){
            if (!mMouseOver){
                onMouseEnter(mouse);
            }
            if (!mMouseDown && mp){
                onMousePress(mouse);
                if (!mFocused) onFocus();
            }
        }   else{
    // the mouse is not over the component //
            if (mMouseOver){
                onMouseLeave(mouse);
            }
            if (!mMouseDown && mp && mFocused){
                onFocusLost();
            }
        }
        if (mMouseDown) {
            if (mp){
                onMouseDrag(mouse);
            }   else{
                onMouseRelease(mouse);
            }
        }
    }
// don't update children unless they're visible //
    if (this->getIsExpanded()) {
        for(int i=0; i<children.size(); i++) {
            children[i]->update(acceptEvents);
            if (children[i]->getFocused()){
                if (acceptEvents == false ) children[i]->setFocused(false);
                acceptEvents = false;
            }
        }
    }
}
Esempio n. 5
0
	void WidgetInput::_riseMouseDrag(int _left, int _top, MouseButton _id)
	{
		onMouseDrag(_left, _top, _id);
		eventMouseDrag(static_cast<Widget*>(this), _left, _top, _id);
	}
Esempio n. 6
0
bool updateMouse() {
    if (mouse_fd < 0) {
        return false;
    }

    struct input_event mousee;
    while ( readMouseEvent(&mousee) ) {
        
        mouse.velX=0;
        mouse.velY=0;

        float x,y = 0.0f;
        int button = 0;

        switch(mousee.type) {
            // Update Mouse Event
            case EV_KEY:
                switch (mousee.code) {
                    case BTN_LEFT:
                        if (mousee.value == 1){
                            button = 1;
                        }
                        break;
                    case BTN_RIGHT:
                        if(mousee.value == 1){
                            button = 2;
                        }
                        break;
                    case BTN_MIDDLE:
                        if(mousee.value == 1){
                            button = 3;
                        }
                        break;
                    default:
                        button = 0;
                        break;
                }
                if (button != mouse.button) {
                    mouse.button = button;
                    if(mouse.button == 0){
                        onMouseRelease(mouse.x,mouse.y);
                    } else {
                        onMouseClick(mouse.x,mouse.y,mouse.button);
                    }
                }
                break;
            case EV_REL:
                switch (mousee.code) {
                    case REL_X:
                        mouse.velX = mousee.value;
                        break;
                    case REL_Y:
                        mousee.value = mousee.value * -1;
                        mouse.velY = mousee.value;
                        break;
                    // case REL_WHEEL:
                    //     if (mousee.value > 0)
                    //         std::cout << "Mouse wheel Forward" << std::endl;
                    //     else if(mousee.value < 0)
                    //         std::cout << "Mouse wheel Backward" << std::endl;
                    //     break;
                    default:
                        break;
                }
                mouse.x+=mouse.velX;
                mouse.y+=mouse.velY;

                // Clamp values
                if (mouse.x < 0) mouse.x=0;
                if (mouse.y < 0) mouse.y=0;
                if (mouse.x > viewport.z) mouse.x = viewport.z;
                if (mouse.y > viewport.w) mouse.y = viewport.w;

                if (mouse.button != 0) {
                    onMouseDrag(mouse.x,mouse.y,mouse.button);
                } else {
                    onMouseMove(mouse.x,mouse.y);
                }
                break;
            case EV_ABS:
                switch (mousee.code) {
                    case ABS_X:
                        x = ((float)mousee.value/4095.0f)*viewport.z;
                        mouse.velX = x - mouse.x;
                        mouse.x = x;
                        break;
                    case ABS_Y:
                        y = (1.0-((float)mousee.value/4095.0f))*viewport.w;
                        mouse.velY = y - mouse.y;
                        mouse.y = y;
                        break;
                    default:
                        break;
                }
                if (mouse.button != 0) {
                    onMouseDrag(mouse.x,mouse.y,mouse.button);
                } else {
                    onMouseMove(mouse.x,mouse.y);
                }
                break;
            default:
                break;
        }
    }
    return true;
}
Esempio n. 7
0
	void Window::process(const InputState &state) {
		Window *popup = nullptr;
		m_is_focused = true;

		for(int n = 0; n < (int)m_children.size(); n++) {
			m_children[n]->m_is_focused = false;
			m_children[n]->m_is_mouse_over = false;

			if(m_children[n]->m_is_closing) {
				PWindow window = m_children[n];
				m_children.erase(m_children.begin() + n);
				sendEvent(window.get(), Event::window_closed, m_children[n]->m_closing_value); 
				n--;
			}
			else if(m_children[n]->m_is_popup)
				popup = m_children[n].get();
		}

		if(popup) {
			popup->process(state);
			return;
		}

		int2 mouse_pos = state.mousePos();
		int2 local_mouse_pos = mouse_pos - m_clipped_rect.min;
		int finished_dragging = 0;
		bool escape = state.isKeyDown(InputKey::esc);

		InputButton button_map[3] = { InputButton::left, InputButton::right, InputButton::middle };

		if(m_dragging_mode) {
			if(!state.isMouseButtonPressed(button_map[m_dragging_mode - 1]) || escape)
				finished_dragging = escape? -1 : 1;
		}
		else {
			for(int k = 0; k < 3; k++) {
				if(state.isMouseButtonDown(button_map[k])) {
					m_dragging_mode = k + 1;
					m_drag_start = local_mouse_pos;
					break;
				}
			}
		}


		int2 focus_point = m_dragging_mode? m_drag_start : local_mouse_pos;
		bool is_handled = false;

		for(int n = (int)m_children.size() - 1; n >= 0; n--) {
			Window *child = m_children[n].get();
			if(child->isVisible() && m_has_hard_focus == child->m_has_hard_focus) {
				if(m_has_hard_focus || child->rect().isInside(focus_point)) {
					child->m_is_mouse_over = child->clippedRect().isInside(mouse_pos);
					child->process(state);
					is_handled = true;
					break;
				}
			}
		}

		if(!is_handled) {
			if(m_dragging_mode && !is_handled) {
				if(m_has_inner_rect && m_dragging_mode - 1 == 2) {
					setInnerRect(m_inner_rect + state.mouseMove());
					is_handled = true;
				}
				if(!is_handled)
					is_handled = onMouseDrag(state, m_drag_start, local_mouse_pos, m_dragging_mode - 1, finished_dragging);
				if(!is_handled)
					is_handled = onMouseClick(state, local_mouse_pos, m_dragging_mode - 1, finished_dragging);
			}
			if(!is_handled) {
				if(m_has_inner_rect) {
					int wheel = state.mouseWheelMove();
					int2 vector(0, 0);

					if(wheel)
						vector.y += wheel * rect().height() / 8;
					if(state.isKeyDownAuto(InputKey::pageup, 2))
						vector.y += rect().height();
					if(state.isKeyDownAuto(InputKey::pagedown, 2))
						vector.y -= rect().height();

					setInnerRect(m_inner_rect + vector);
				}

				onInput(state);
			}
		}
		
		if(escape && (!m_parent || m_is_popup) && !m_dragging_mode) // sending Event::escape only from main window
			sendEvent(this, Event::escape); //TODO: send only to focused windows

		if(finished_dragging)
			m_dragging_mode = 0;
	}
Esempio n. 8
0
bool GuiSlider::onMouseDown(sf::Vector2f position)
{
    onMouseDrag(position);
    return true;
}
	void callHandlersOnMouseDrag(const Mouse& m){ CALL(onMouseDrag(m)); }