Exemplo n.º 1
0
	void SplitPanel::setHandleThickness(int thickness)
	{
		//TODO: Assert on negative value.

		if (thickness != m_handleThickness)
		{
			m_handleThickness = thickness;
			_updatePreferredSize();
			_updateGeo();
		}
	}
Exemplo n.º 2
0
	void SplitPanel::setHandleSkin(Skin * pSkin)
	{
		if (pSkin != m_pHandleSkin)
		{
			m_pHandleSkin = pSkin;
			_updatePreferredSize();
			bool bGeoChanged = _updateGeo();
			if (!bGeoChanged)
				_requestRender(m_handleGeo);
		}
	}
Exemplo n.º 3
0
	void SplitPanel::_setWidget(Slot * _pSlot, Widget * pNewWidget)
	{
		auto pSlot = static_cast<SplitPanelSlot*>(_pSlot);

		pSlot->replaceWidget(this, pNewWidget);
		pNewWidget->_setSize(pSlot->geo);
		_updatePreferredSize();
		bool bGeoChanged =_updateGeo();
		if (!bGeoChanged)
			_requestRender(pSlot->geo);

	}
Exemplo n.º 4
0
//_____________________________________________________________________________
void WgPopupHook::_requestResize()
{
	_updateGeo();					// Just update this menus geo, don't recursively update children, their position should remain where it is.
}
Exemplo n.º 5
0
	void SplitPanel::_setSize(const Size& size)
	{
		Panel::_setSize(size);
		_updateGeo();
	}
Exemplo n.º 6
0
	void SplitPanel::_receive(Msg * pMsg)
	{
		//TODO: Implement!!!

		State handleState = m_handleState;

		switch (pMsg->type())
		{
			case MsgType::MouseEnter:
			case MsgType::MouseMove:
			{
				if (m_handleState.isPressed())
					return;

				Coord pos = InputMsg::cast(pMsg)->pointerPos() - globalPos();

				bool bHovered = m_handleGeo.contains(pos);
				handleState.setHovered(bHovered);
				break;
			}

			case MsgType::MouseLeave:
			{
				// Unhover handle unless it is pressed

				if (!handleState.isPressed())
					handleState.setHovered(false);
				break;
			}
			case MsgType::MousePress:
			{
				auto p = MouseButtonMsg::cast(pMsg);

				if (p->button() != MouseButton::Left)
					return;

				Coord pos = p->pointerPos() - globalPos();
				if (m_handleGeo.contains(pos))
				{
					m_handlePressOfs = m_bHorizontal ? pos.x - m_handleGeo.x : pos.y - m_handleGeo.y;
					handleState.setPressed(true);
					pMsg->swallow();
				}
				break;
			}

			case MsgType::MouseRelease:
			{
				auto p = MouseButtonMsg::cast(pMsg);

				if (p->button() != MouseButton::Left)
					return;

				if (handleState.isPressed() )
				{
					handleState.setPressed(false);
					pMsg->swallow();
				}
				break;
			}

			case MsgType::MouseDrag:
			{
				auto p = MouseButtonMsg::cast(pMsg);

				if (p->button() != MouseButton::Left)
					return;

				if (handleState.isPressed())
				{
					Coord pos = p->pointerPos() - globalPos();
					int diff = (m_bHorizontal ? pos.x - m_handleGeo.x : pos.y - m_handleGeo.y) - m_handlePressOfs;

					_updateGeo(diff);
					pMsg->swallow();
				}
				break;
			}

			default:
				break;
		}

		if (handleState != m_handleState && m_pHandleSkin)
		{
			if (!m_pHandleSkin->isStateIdentical(handleState, m_handleState))
				_requestRender(m_handleGeo);

			m_handleState = handleState;
		}
	}
Exemplo n.º 7
0
	void SplitPanel::_refresh()
	{
		_updateGeo();
		_requestRender();
	}
Exemplo n.º 8
0
	void SplitPanel::setSplitFactor(float factor)
	{
		limit(factor, 0.f, 1.f);
		m_splitFactor = factor;
		_updateGeo();
	}
Exemplo n.º 9
0
	void SplitPanel::setBrokerFunction(std::function<int(Widget * pFirst, Widget * pSecond, int totalLength, float fraction, int handleMovement)> func)
	{
		m_brokerFunc = func;
		_updateGeo();
	}