Example #1
0
	void SeparatePanel::invalidateSize(const MyGUI::IntCoord& _firstPanel, const MyGUI::IntCoord& _separatorH, const MyGUI::IntCoord& _separatorV, const MyGUI::IntCoord& _secondPanel)
	{
		if (mMainWidget->getWidth() <= 0 ||
			mMainWidget->getHeight() <= 0)
			return;

		MyGUI::IntCoord firstPanel = _firstPanel;
		MyGUI::IntCoord separatorH = _separatorH;
		MyGUI::IntCoord separatorV = _separatorV;
		MyGUI::IntCoord secondPanel = _secondPanel;

		if (mPanelAlign.isLeft())
		{
			updateSize(firstPanel.width, secondPanel.width, separatorH.width, mMainWidget->getWidth(), mDefaultPanelSize.width);
			firstPanel.top = separatorH.top = secondPanel.top = 0;
			firstPanel.height = separatorH.height = secondPanel.height = mMainWidget->getHeight();
			firstPanel.left = 0;
			separatorH.left = firstPanel.right();
			secondPanel.left = separatorH.right();
		}
		else if (mPanelAlign.isRight())
		{
			updateSize(firstPanel.width, secondPanel.width, separatorH.width, mMainWidget->getWidth(), mDefaultPanelSize.width);
			firstPanel.top = separatorH.top = secondPanel.top = 0;
			firstPanel.height = separatorH.height = secondPanel.height = mMainWidget->getHeight();
			secondPanel.left = 0;
			separatorH.left = secondPanel.right();
			firstPanel.left = separatorH.right();
		}
		else if (mPanelAlign.isTop())
		{
			updateSize(firstPanel.height, secondPanel.height, separatorV.height, mMainWidget->getHeight(), mDefaultPanelSize.height);
			firstPanel.left = separatorV.left = secondPanel.left = 0;
			firstPanel.width = separatorV.width = secondPanel.width = mMainWidget->getWidth();
			firstPanel.top = 0;
			separatorV.top = firstPanel.bottom();
			secondPanel.top = separatorV.bottom();
		}
		else if (mPanelAlign.isBottom())
		{
			updateSize(firstPanel.height, secondPanel.height, separatorV.height, mMainWidget->getHeight(), mDefaultPanelSize.height);
			firstPanel.left = separatorV.left = secondPanel.left = 0;
			firstPanel.width = separatorV.width = secondPanel.width = mMainWidget->getWidth();
			secondPanel.top = 0;
			separatorV.top = secondPanel.bottom();
			firstPanel.top = separatorV.bottom();
		}

		if (firstPanel != mFirstPanel->getCoord())
			mFirstPanel->setCoord(firstPanel);

		if (separatorH != mSeparatorH->getCoord())
			mSeparatorH->setCoord(separatorH);

		if (separatorV != mSeparatorV->getCoord())
			mSeparatorV->setCoord(separatorV);

		if (secondPanel != mSecondPanel->getCoord())
			mSecondPanel->setCoord(secondPanel);
	}
Example #2
0
	void RegionTextureControl::notifyChangePosition()
	{
		mCoordValue = mAreaSelectorControl->getCoord();

		// снапим к гриду
		if (!MyGUI::InputManager::getInstance().isShiftPressed())
		{
			MyGUI::IntCoord coord = mCoordValue;
			MyGUI::IntCoord actionScale = mAreaSelectorControl->getActionScale();

			if (actionScale.left != 0 && actionScale.width != 0)
			{
				int right = coord.right();
				coord.left = Grid::getInstance().toGrid(coord.left);
				coord.width = right - coord.left;
			}
			else if (actionScale.width != 0)
			{
				int right = Grid::getInstance().toGrid(coord.right());
				coord.width = right - coord.left;
			}
			else if (actionScale.left != 0)
			{
				coord.left = Grid::getInstance().toGrid(coord.left);
			}

			if (actionScale.top != 0 && actionScale.height != 0)
			{
				int bottom = coord.bottom();
				coord.top = Grid::getInstance().toGrid(coord.top);
				coord.height = bottom - coord.top;
			}
			else if (actionScale.height != 0)
			{
				int bottom = Grid::getInstance().toGrid(coord.bottom());
				coord.height = bottom - coord.top;
			}
			else if (actionScale.top != 0)
			{
				coord.top = Grid::getInstance().toGrid(coord.top);
			}

			if (coord != mCoordValue)
			{
				mCoordValue = coord;
				mAreaSelectorControl->setCoord(mCoordValue);
			}
		}

		if (getCurrentRegion() != nullptr)
			getCurrentRegion()->getPropertySet()->setPropertyValue("Position", mCoordValue.print(), mTypeName);
	}
Example #3
0
	void Application::setWindowCoord(const MyGUI::IntCoord& _value)
	{
	#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
		if (_value.empty())
			return;

		MyGUI::IntCoord coord = _value;
		if (coord.left < 0)
			coord.left = 0;
		if (coord.top < 0)
			coord.top = 0;
		if (coord.width < 640)
			coord.width = 640;
		if (coord.height < 480)
			coord.height = 480;
		if (coord.width > GetSystemMetrics(SM_CXSCREEN))
			coord.width = GetSystemMetrics(SM_CXSCREEN);
		if (coord.height > GetSystemMetrics(SM_CYSCREEN))
			coord.height = GetSystemMetrics(SM_CYSCREEN);
		if (coord.right() > GetSystemMetrics(SM_CXSCREEN))
			coord.left = GetSystemMetrics(SM_CXSCREEN) - coord.width;
		if (coord.bottom() > GetSystemMetrics(SM_CYSCREEN))
			coord.top = GetSystemMetrics(SM_CYSCREEN) - coord.height;

		size_t handle = getWindowHandle();
		::MoveWindow((HWND)handle, coord.left, coord.top, coord.width, coord.height, true);
	#endif
	}
Example #4
0
	void SeparatePanel::moveSeparator(const MyGUI::IntPoint& _mousePosition)
	{
		MyGUI::IntPoint offset = _mousePosition - mMousePressedOffset - mMainWidget->getAbsolutePosition();

		// сбрасываем дефолтный размер панели
		mDefaultPanelSize.clear();

		MyGUI::IntCoord firstPanel = mFirstPanel->getCoord();
		MyGUI::IntCoord separatorH = mSeparatorH->getCoord();
		MyGUI::IntCoord separatorV = mSeparatorV->getCoord();
		MyGUI::IntCoord secondPanel = mSecondPanel->getCoord();

		if (mPanelAlign.isLeft())
		{
			firstPanel.width = offset.left - firstPanel.left;
			separatorH.left = offset.left;
			secondPanel.width = secondPanel.right() - (offset.left + separatorH.width);
			secondPanel.left = offset.left + separatorH.width;
		}
		else if (mPanelAlign.isRight())
		{
			secondPanel.width = offset.left - secondPanel.left;
			separatorH.left = offset.left;
			firstPanel.width = firstPanel.right() - (offset.left + separatorH.width);
			firstPanel.left = offset.left + separatorH.width;
		}
		else if (mPanelAlign.isTop())
		{
			firstPanel.height = offset.top - firstPanel.top;
			separatorV.top = offset.top;
			secondPanel.height = secondPanel.bottom() - (offset.top + separatorV.height);
			secondPanel.top = offset.top + separatorV.height;
		}
		else if (mPanelAlign.isBottom())
		{
			secondPanel.height = offset.top - secondPanel.top;
			separatorV.top = offset.top;
			firstPanel.height = firstPanel.bottom() - (offset.top + separatorV.height);
			firstPanel.top = offset.top + separatorV.height;
		}

		invalidateSize(firstPanel, separatorH, separatorV, secondPanel);

		// запоминаем дефолтный размер панели
		mDefaultPanelSize = mFirstPanel->getSize();
	}
Example #5
0
	void WorkspaceControl::notifyChangePosition()
	{
		if (!mMoveableWidget)
			return;

		mCoordValue = mAreaSelectorControl->getCoord();

		// конвертируем в локальные координаты
		if (mCurrentWidget != nullptr)
		{
			MyGUI::Widget* parent = mCurrentWidget->getParent();
			if (parent != nullptr && !mCurrentWidget->isRootWidget())
				mCoordValue = mCoordValue - parent->getAbsolutePosition();
		}

		// снапим к гриду
		if (!MyGUI::InputManager::getInstance().isShiftPressed())
		{
			MyGUI::IntCoord coord = mCoordValue;
			MyGUI::IntCoord actionScale = mAreaSelectorControl->getActionScale();

			if (actionScale.left != 0 && actionScale.width != 0)
			{
				int right = coord.right();
				coord.width = toGrid(coord.width + (mGridStep / 2));
				coord.left = right - coord.width;
			}
			else if (actionScale.width != 0)
			{
				int right = toGrid(coord.right() + (mGridStep / 2));
				coord.width = right - coord.left;
			}
			else if (actionScale.left != 0)
			{
				coord.left = toGrid(coord.left + (mGridStep / 2));
			}

			if (actionScale.top != 0 && actionScale.height != 0)
			{
				int bottom = coord.bottom();
				coord.height = toGrid(coord.height + (mGridStep / 2));
				coord.top = bottom - coord.height;
			}
			else if (actionScale.height != 0)
			{
				int bottom = toGrid(coord.bottom() + (mGridStep / 2));
				coord.height = bottom - coord.top;
			}
			else if (actionScale.top != 0)
			{
				coord.top = toGrid(coord.top + (mGridStep / 2));
			}

			if (coord != mCoordValue)
			{
				mCoordValue = coord;
				updateSelectionFromValue();
			}
		}

		if (mCurrentWidget != nullptr)
			setWidgetCoord(mCurrentWidget, mCoordValue);

		UndoManager::getInstance().addValue(PR_POSITION);
	}
	bool ControllerEdgeHide::addTime(Widget* _widget, float _time)
	{
		const IntSize& view_size = _widget->getParentSize();
		// do nothing if we have minimized window
		if (view_size.width <= 1 && view_size.height <= 1)
			return true;

		Widget* keyFocus = InputManager::getInstance().getKeyFocusWidget();
		Widget* mouseFocus = InputManager::getInstance().getMouseFocusWidget();

		while ((keyFocus != nullptr) && (_widget != keyFocus))
			keyFocus = keyFocus->getParent();
		while ((mouseFocus != nullptr) && (_widget != mouseFocus))
			mouseFocus = mouseFocus->getParent();

		// if our widget or its children have focus
		bool haveFocus = ((keyFocus != nullptr) || (mouseFocus != nullptr)) || (_widget->getVisible() == false);

		mElapsedTime += haveFocus ? -_time : _time;

		if (mElapsedTime >= mTime)
		{
			mElapsedTime = mTime;
		}
		if (mElapsedTime <= 0)
		{
			mElapsedTime = 0.0f;
			return true;
		}

		float k = sin(M_PI * mElapsedTime / mTime - M_PI / 2);
		if (k < 0) k = (-pow(-k, 0.7f) + 1) / 2;
		else k = (pow(k, 0.7f) + 1) / 2;

		MyGUI::IntCoord coord = _widget->getCoord();
		// if widget was moved
		if (coord != mLastCoord)
		{
			// if still moving - leave it alone
			if (haveFocus)
				return true;
			else
				recalculateTime(_widget);
		}

		bool nearBorder = false;

		if ((coord.left <= 0) && !(coord.right() >= view_size.width - 1))
		{
			coord.left = - int( float(coord.width - mRemainPixels - mShadowSize) * k);
			nearBorder = true;
		}
		if ((coord.top <= 0) && !(coord.bottom() >= view_size.height - 1))
		{
			coord.top = - int( float(coord.height - mRemainPixels - mShadowSize) * k);
			nearBorder = true;
		}
		if ((coord.right() >= view_size.width - 1) && !(coord.left <= 0))
		{
			coord.left = int(float(view_size.width - 1) - float(mRemainPixels) * k - float(coord.width) * (1.f - k));
			nearBorder = true;
		}
		if ((coord.bottom() >= view_size.height - 1) && !(coord.top <= 0))
		{
			coord.top = int(float(view_size.height - 1) - float(mRemainPixels) * k - float(coord.height) * (1.f - k));
			nearBorder = true;
		}

		if (nearBorder)
		{
			_widget->setCoord(coord);
		}
		else
		{
			mElapsedTime = 0;
		}
		mLastCoord = coord;

		eventUpdateAction(_widget, this);

		return true;
	}