Пример #1
0
bool GOGUIEnclosure::HandleMousePress(int x, int y, bool right, GOGUIMouseState& state)
{
	if (!m_BoundingRect.Contains(x, y))
		return false;
	if (right)
	{
		m_enclosure->ShowConfigDialog();
		return true;
	}
	else
	{
		unsigned value;
		if (!m_MouseRect.Contains(x, y))
			return false;
		y -= m_MouseRect.GetY();
		if (y <= m_MouseAxisStart)
			value = (127 * y / m_MouseAxisStart);
		else if (y >= m_MouseAxisEnd)
			value = (m_MouseRect.GetHeight() - y) * 127 / (m_MouseRect.GetHeight() - m_MouseAxisEnd);
		else
			value = 127;

		if (state.GetControl() == this && state.GetIndex() == value)
			return true;
		state.SetControl(this);
		state.SetIndex(value);

		m_enclosure->Set(value);
		return true;
	}
}
Пример #2
0
bool GOGUIButton::HandleMousePress(int x, int y, bool right, GOGUIMouseState& state)
{
	if (!m_MouseRect.Contains(x, y))
		return false;
	if (m_Radius)
	{
		if ((m_MouseRect.GetX() + m_Radius - x) * (m_MouseRect.GetX() + m_Radius - x) + (m_MouseRect.GetY() + m_Radius - y) * (m_MouseRect.GetY() + m_Radius - y) > m_Radius * m_Radius)
			return false;
	}
	if (right)
	{
		m_Button->ShowConfigDialog();
		return true;
	}
	else
	{
		if (state.GetControl() == this)
			return true;
		state.SetControl(this);
		if (m_Button->IsReadOnly())
			return true;

		m_Button->Push();
		return true;
	}
}