antiblock
Elveron
  • Chatbox

    You don't have permission to chat.
    Load More
Owsap

[C++] EnableFlash & DisableFlash for Buttons

1 post in this topic

Antes de tudo, eu sei que isso é um pouco inútil, mas para ativar e desativar o efeito a piscar nos botões, decidi usar a função de flash padrão, porque não conhecia uma maneira mais fácil.
 

Spoiler

EterPythonLib/PythonWindow.cpp


/// 1.
// Procura
	void CButton::Flash()
	{
		m_isFlash = true;
	}

// Adiciona abaixo
	void CButton::EnableFlash()
	{
		m_isFlash = true;
		if (!m_overVisual.IsEmpty())
			SetCurrentVisual(&m_overVisual);
	}

	void CButton::DisableFlash()
	{
		m_isFlash = false;
		if (!m_upVisual.IsEmpty())
			SetCurrentVisual(&m_upVisual);
	}


/// 2.
// Procura a função
	void CButton::OnRender()

// Substituir por
	void CButton::OnRender()
	{
		if (!IsShow())
			return;

		if (m_pcurVisual)
		{
			if (m_isFlash)
			{
				if (!IsIn() && !IsPressed())
				{
					if (!m_overVisual.IsEmpty())
						SetCurrentVisual(&m_overVisual);

					if (int(timeGetTime() / 500) % 2)
						return;
				}
			}

			m_pcurVisual->Render();
		}

		PyCallClassMemberFunc(m_poHandler, "OnRender", BuildEmptyTuple());
	}

EterPythonLib/PythonWindow.h


/// 1.
// Procura
			void Flash();

// Adicionar abaixo
			void EnableFlash();
			void DisableFlash();

EterPythonLib/PythonWindowManagerModule.cpp


/// 1.
// Procura
PyObject * wndButtonFlash(PyObject * poSelf, PyObject * poArgs)
{
	UI::CWindow * pWindow;
	if (!PyTuple_GetWindow(poArgs, 0, &pWindow))
		return Py_BuildException();

	((UI::CButton*)pWindow)->Flash();

	return Py_BuildNone();
}

// Adiciona abaixo
PyObject* wndButtonEnableFlash(PyObject* poSelf, PyObject* poArgs)
{
	UI::CWindow * pWindow;
	if (!PyTuple_GetWindow(poArgs, 0, &pWindow))
		return Py_BuildException();

	((UI::CButton*)pWindow)->EnableFlash();

	return Py_BuildNone();
}

PyObject* wndButtonDisableFlash(PyObject* poSelf, PyObject* poArgs)
{
	UI::CWindow * pWindow;
	if (!PyTuple_GetWindow(poArgs, 0, &pWindow))
		return Py_BuildException();

	((UI::CButton*)pWindow)->DisableFlash();

	return Py_BuildNone();
}

/// 2.
// Procura
		{ "Flash",						wndButtonFlash,						METH_VARARGS },

// Adiciona abaixo
		{ "EnableFlash",				wndButtonEnableFlash,				METH_VARARGS },
		{ "DisableFlash",				wndButtonDisableFlash,				METH_VARARGS },

ROOT/ui.py


''' 1. '''
# Procura
	def Flash(self):
		wndMgr.Flash(self.hWnd)

# Adiciona abaixo
	def EnableFlash(self):
		wndMgr.EnableFlash(self.hWnd)

	def DisableFlash(self):
		wndMgr.DisableFlash(self.hWnd)

 

Como um exemplo, aqui está uma demonstração do efeito do flash.

CU52L7z.gif

Share this post


Link to post
Share on other sites
antiblock
https://arwen2.global/

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now