コード例 #1
0
	bool GUIDropButton::_mouseEvent(const GUIMouseEvent& ev)
	{
		bool processed = GUIButtonBase::_mouseEvent(ev);

		if(ev.getType() == GUIMouseEventType::MouseDragAndDropDragged)
		{
			if (!_isDisabled())
			{
				if (DragAndDropManager::instance().isDragInProgress())
				{
					if (DragAndDropManager::instance().getDragTypeId() == mDragType)
					{
						if (!_isOn())
							_setOn(true);
					}
					else
					{
						if (_isOn())
							_setOn(false);
					}
				}
				else
				{
					if (_isOn())
						_setOn(false);
				}
			}

			processed = true;
		}
		else if(ev.getType() == GUIMouseEventType::MouseDragAndDropDropped)
		{
			if (!_isDisabled())
			{
				if (_isOn())
					_setOn(false);

				if (DragAndDropManager::instance().isDragInProgress() && DragAndDropManager::instance().getDragTypeId() == mDragType)
				{
					if (!onDataDropped.empty())
						onDataDropped(DragAndDropManager::instance().getDragData());
				}
			}

			processed = true;
		}
		else if (ev.getType() == GUIMouseEventType::MouseDragAndDropLeft)
		{
			if (!_isDisabled())
			{
				if (_isOn())
					_setOn(false);
			}

			processed = true;
		}

		return processed;
	}
コード例 #2
0
	bool GUIButtonBase::_mouseEvent(const GUIMouseEvent& ev)
	{
		if(ev.getType() == GUIMouseEventType::MouseOver)
		{
			if (!_isDisabled())
			{
				_setState(_isOn() ? GUIElementState::HoverOn : GUIElementState::Hover);
				onHover();
			}

			return mBlockPointerEvents;
		}
		else if(ev.getType() == GUIMouseEventType::MouseOut)
		{
			if (!_isDisabled())
			{
				_setState(_isOn() ? GUIElementState::NormalOn : GUIElementState::Normal);
				onOut();
			}

			return mBlockPointerEvents;
		}
		else if(ev.getType() == GUIMouseEventType::MouseDown)
		{
			if (!_isDisabled())
				_setState(_isOn() ? GUIElementState::ActiveOn : GUIElementState::Active);

			return mBlockPointerEvents;
		}
		else if(ev.getType() == GUIMouseEventType::MouseUp)
		{
			if (!_isDisabled())
			{
				_setState(_isOn() ? GUIElementState::HoverOn : GUIElementState::Hover);
				onClick();
			}

			return mBlockPointerEvents;
		}
		else if (ev.getType() == GUIMouseEventType::MouseDoubleClick)
		{
			if (!_isDisabled())
				onDoubleClick();

			return mBlockPointerEvents;
		}

		return false;
	}
コード例 #3
0
	bool GUIHoverHitBox::_mouseEvent(const GUIMouseEvent& ev)
	{
		bool processed = GUIElementContainer::_mouseEvent(ev);

		if (ev.getType() == GUIMouseEventType::MouseOver)
		{
			onHover();
			return false;
		}
		else if (ev.getType() == GUIMouseEventType::MouseOut)
		{
			onOut();
			return false;
		}

		return processed;
	}
コード例 #4
0
	bool GUIColor::_mouseEvent(const GUIMouseEvent& ev)
	{
		if(ev.getType() == GUIMouseEventType::MouseUp)
		{
			if (!_isDisabled())
				onClicked();

			return true;
		}

		return false;
	}
コード例 #5
0
	bool GUIScrollArea::_mouseEvent(const GUIMouseEvent& ev)
	{
		if(ev.getType() == GUIMouseEventType::MouseWheelScroll)
		{
			// Mouse wheel only scrolls on the Y axis
			if(mVertScroll != nullptr)
			{
				UINT32 scrollableHeight = (UINT32)std::max(0, INT32(mContentSize.y) - INT32(mVisibleSize.y));
				float additionalScroll = (float)WheelScrollAmount / scrollableHeight;

				mVertScroll->scroll(additionalScroll * ev.getWheelScrollAmount());
				return true;
			}
		}

		return false;
	}
コード例 #6
0
	bool GUIToggle::_mouseEvent(const GUIMouseEvent& ev)
	{
		bool processed = GUIButtonBase::_mouseEvent(ev);

		if(ev.getType() == GUIMouseEventType::MouseUp)
		{
			if (!_isDisabled())
			{
				if (mIsToggled)
					toggleOff();
				else
					toggleOn();
			}

			processed = true;
		}

		return processed;
	}
コード例 #7
0
	bool GUIFloatField::_mouseEvent(const GUIMouseEvent& event)
	{
		GUIElementContainer::_mouseEvent(event);

		Rect2I draggableArea;

		if(mLabel != nullptr)
			draggableArea = mLabel->_getLayoutData().area;

		if(event.getType() == GUIMouseEventType::MouseDragStart)
		{
			if (!_isDisabled())
			{
				if (draggableArea.contains(event.getDragStartPosition()))
				{
					mLastDragPos = event.getPosition().x;
					mIsDragging = true;
				}
			}

			return true;
		}
		else if(event.getType() == GUIMouseEventType::MouseDrag)
		{
			if (!_isDisabled())
			{
				if (mIsDragging)
				{
					INT32 xDiff = event.getPosition().x - mLastDragPos;

					INT32 jumpAmount = 0;
					Rect2I viewArea = _getParentWidget()->getTarget()->getPixelArea();
					if (event.getPosition().x <= 0)
					{
						Vector2I cursorScreenPos = Cursor::instance().getScreenPosition();

						jumpAmount = viewArea.width - event.getPosition().x - 1;
						cursorScreenPos.x += jumpAmount;

						Cursor::instance().setScreenPosition(cursorScreenPos);
					}
					else if (event.getPosition().x >= (INT32)viewArea.width)
					{
						Vector2I cursorScreenPos = Cursor::instance().getScreenPosition();

						jumpAmount = -(INT32)viewArea.width - (event.getPosition().x - (INT32)viewArea.width) + 1;
						cursorScreenPos.x += jumpAmount;

						Cursor::instance().setScreenPosition(cursorScreenPos);
					}

					float oldValue = getValue();
					float newValue = oldValue + xDiff * DRAG_SPEED;

					mLastDragPos = event.getPosition().x + jumpAmount;

					if (oldValue != newValue)
						valueChanged(newValue);
				}
			}

			return true;
		}
		else if(event.getType() == GUIMouseEventType::MouseDragEnd)
		{
			if (!_isDisabled())
				mIsDragging = false;

			return true;
		}

		return false;
	}
コード例 #8
0
	bool GUITabbedTitleBar::_mouseEvent(const GUIMouseEvent& event)
	{
		if(event.getType() == GUIMouseEventType::MouseDragAndDropDragged)
		{
			if(DragAndDropManager::instance().getDragTypeId() != (UINT32)DragAndDropType::EditorWidget)
				return false;

			EditorWidgetBase* draggedWidget = reinterpret_cast<EditorWidgetBase*>(DragAndDropManager::instance().getDragData());
			const Vector2I& widgetRelPos = event.getPosition();

			if(mTempDraggedWidget == nullptr)
			{
				UINT32 numTabButtons = (UINT32)mTabButtons.size();
				for(UINT32 i = 0; i < numTabButtons; i++)
				{
					UINT32 width = mTabButtons[i]->_getLayoutData().area.width;
					INT32 centerX = mTabButtons[i]->_getLayoutData().area.x + width / 2;

					if((i + 1) == numTabButtons)
					{
						if(i == 0 && widgetRelPos.x <= centerX)
						{
							insertTab(0, draggedWidget->getDisplayName());
							mTempDraggedTabIdx = mTabButtons[0]->getIndex();

							break;
						}
						else if(widgetRelPos.x > centerX)
						{
							addTab(draggedWidget->getDisplayName());
							mTempDraggedTabIdx = mTabButtons[i + 1]->getIndex();

							break;
						}
					}
					else
					{
						if(i == 0 && widgetRelPos.x <= centerX)
						{
							insertTab(0, draggedWidget->getDisplayName());
							mTempDraggedTabIdx = mTabButtons[0]->getIndex();

							break;
						}
						else
						{
							UINT32 nextWidth = mTabButtons[i + 1]->_getLayoutData().area.width;
							INT32 nextCenterX = mTabButtons[i + 1]->_getLayoutData().area.x + nextWidth / 2;

							if(widgetRelPos.x > centerX && widgetRelPos.x < nextCenterX)
							{
								insertTab(i + 1, draggedWidget->getDisplayName());
								mTempDraggedTabIdx = mTabButtons[i + 1]->getIndex();

								break;
							}
						}
					}
				}

				mTempDraggedWidget = draggedWidget;
				startDrag(uniqueIdxToSeqIdx(mTempDraggedTabIdx), Vector2I());
				mInitialDragOffset = Math::roundToInt(mDraggedBtn->_getOptimalSize().x * 0.5f);		
			}

			if(mTempDraggedWidget != nullptr)
				tabDragged(mTempDraggedTabIdx, widgetRelPos);

			return true;
		}
		else if(event.getType() == GUIMouseEventType::MouseDragAndDropDropped)
		{
			if(DragAndDropManager::instance().getDragTypeId() != (UINT32)DragAndDropType::EditorWidget)
				return false;

			if(mTempDraggedWidget != nullptr)
			{
				UINT32 seqIdx = uniqueIdxToSeqIdx(mTempDraggedTabIdx);
				removeTab(mTempDraggedTabIdx);

				endDrag();

				if(!onTabDraggedOn.empty())
					onTabDraggedOn(seqIdx);
			}

			return true;
		}
		else if(event.getType() == GUIMouseEventType::MouseDragAndDropLeft)
		{
			if(mTempDraggedWidget != nullptr)
			{
				removeTab(mTempDraggedTabIdx);

				endDrag();
			}
		}

		return false;
	}
コード例 #9
0
	bool GUIIntField::_mouseEvent(const GUIMouseEvent& event)
	{
		GUIElementContainer::_mouseEvent(event);

		Rect2I draggableArea;

		if(mLabel != nullptr)
			draggableArea = mLabel->_getLayoutData().area;

		if(event.getType() == GUIMouseEventType::MouseDragStart)
		{
			if (!_isDisabled())
			{
				if (draggableArea.contains(event.getDragStartPosition()))
				{
					mLastDragPos = event.getPosition().x;
					mIsDragging = true;
				}
			}

			return true;
		}
		else if(event.getType() == GUIMouseEventType::MouseDrag)
		{
			if (!_isDisabled())
			{
				if (mIsDragging)
				{
					INT32 xDiff = event.getPosition().x - mLastDragPos;

					INT32 jumpAmount = 0;
					if (event.getPosition().x < 0)
					{
						Vector2I cursorScreenPos = Cursor::instance().getScreenPosition();
						cursorScreenPos.x += _getParentWidget()->getTarget()->getWidth();
						jumpAmount = _getParentWidget()->getTarget()->getWidth();

						Cursor::instance().setScreenPosition(cursorScreenPos);
					}
					else if (event.getPosition().x >= _getParentWidget()->getTarget()->getWidth())
					{
						Vector2I cursorScreenPos = Cursor::instance().getScreenPosition();
						cursorScreenPos.x -= _getParentWidget()->getTarget()->getWidth();
						jumpAmount = -_getParentWidget()->getTarget()->getWidth();

						Cursor::instance().setScreenPosition(cursorScreenPos);
					}

					INT32 oldValue = getValue();
					INT32 newValue = oldValue;

					if (xDiff >= DRAG_SPEED)
					{
						while (xDiff >= DRAG_SPEED)
						{
							newValue++;
							xDiff -= DRAG_SPEED;
						}
					}
					else if (xDiff <= -DRAG_SPEED)
					{
						while (xDiff <= -DRAG_SPEED)
						{
							newValue--;
							xDiff += DRAG_SPEED;
						}
					}

					mLastDragPos += (newValue - oldValue) * DRAG_SPEED + jumpAmount;

					if (oldValue != newValue)
						valueChanged(newValue);
				}
			}

			return true;
		}
		else if(event.getType() == GUIMouseEventType::MouseDragEnd)
		{
			if (!_isDisabled())
				mIsDragging = false;

			return true;
		}

		return false;
	}